Exemplo n.º 1
0
def delete_delivery(request):
    '删除配送规则'
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=3)
        rs2,rs1=verifyData(rs1,length=3,required=[0,2],delivery=1)

        html=u"<table width='800'><tr><th>门店代码</th><th>门店名称</th><th>配送日</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td style='background-color:yellow;'>" + rs[3] + "</td>"
                html+="</tr>"
        #log(rs1)
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(html)
    else:
        t=get_template('mana1/delete_delivery.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 2
0
def save_quantou(request):
    '保存拳头产品'
    rs1=[]
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"])

    for rs in rs1:
        if rs[2]==u'数据库已存在!':
            try:
                confsql.runSql("delete from quantou where proid='"+rs[0]+"'")
            except:
                rs[2]=u'删除失败!'
        try:
            confsql.runSql("insert into quantou values('"+rs[0]+"','"+datetime.date.today().strftime("%Y-%m-%d")+"')")
            rs[2]=u'插入成功!'
        except:
            rs[2]=u'插入失败!'
        res={}
        res['proid']=rs[0]
        res['proname']=rs[1]
        res['info']=rs[2]
        result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 3
0
def deleteData_quantou(request):
    '删除数据'
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"],itemlenth=0)
    if len(rs1)>0:
        for rs in rs1:
            if rs[2]<>'': #出错信息的保留
                res={}
                res['proid']=rs[0]
                res['proname']=rs[1]
                res['info']=rs[2]
                result.append(res)
            else:
                try:
                    res={}
                    sqlstr=u"delete from quantou where proid='"+rs[0]+"'"
                    confsql.runSql(sqlstr)
                    res={}
                    res['proid']=rs[0]
                    res['proname']=rs[1]
                    res['info']=u'删除成功!'
                    result.append(res)
                except:
                    res={}
                    res['proid']=rs[0]
                    res['proname']=rs[1]
                    res['info']=u'删除失败!'
                    result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 4
0
def delete_quantou(request):
    '删除订货规则'
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=2)
        rs2,rs1=verifyData(rs1,length=2,required=[0])

        html=u"<table width='400'><tr><th>商品代码</th><th>商品名称</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td style='background-color:yellow'>" + rs[2] + "</td>"
                html+="</tr>"
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(Context(html))
    else:
        t=get_template('mana1/delete_quantou.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 5
0
def delete_tianshu(request):
    '删除订货规则'
    if request.method == 'POST':
        value = request.POST['value']
        rs1 = trim_csv(value, itemlenth=4)
        rs2, rs1 = verifyData(rs1, length=4, required=[0, 2, 3])

        html = u"<table width='800'><tr><th>门店代码</th><th>门店名称</th><th>安全库存天数</th><th>配送周期天数</th></tr>"
        if len(rs2) > 0:
            for rs in rs2:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td style='background-color:yellow'>" + rs[4] + "</td>"
                html += "</tr>"
        if len(rs1) > 0:
            for rs in rs1:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td></td>"
                html += "</tr>"
        html += "</table>"
        return HttpResponse(Context(html))
    else:
        t = get_template('mana1/delete_tianshu.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 6
0
def save_tianshu(request):
    '保存拳头产品'
    rs1 = []
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"])

    for rs in rs1:
        if rs[4] == u'数据库已存在!':
            try:
                confsql.runSql("delete from tianshu where braid='" + rs[0] +
                               "'")
            except:
                rs[4] = u'删除失败!'
        try:
            confsql.runSql("insert into tianshu values('" + rs[0] + "','" +
                           rs[2] + "','" + rs[3] + "','" +
                           datetime.date.today().strftime("%Y-%m-%d") + "')")
            rs[4] = u'插入成功!'
        except:
            rs[4] = u'插入失败!'
        res = {}
        res['braid'] = rs[0]
        res['braname'] = rs[1]
        res['anquankucun'] = rs[2]
        res['peisongzhouqi'] = rs[3]
        res['info'] = rs[4]
        result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 7
0
def delete_product_gl_packetqty_rules(request):
    '删除配货规则'
    if request.method == 'POST':
        value = request.POST['value']
        rs1 = trim_csv(value, itemlenth=4)
        rs2, rs1 = verifyData(rs1, length=4, required=[0, 2, 3], psrules=1)

        html = u"<table width='800'><tr><th>代码</th><th>名称</th><th>代码说明</th><th>配货单位</th></tr>"
        if len(rs2) > 0:
            for rs in rs2:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td style='background-color:yellow;'>" + rs[
                    4] + "</td>"
                html += "</tr>"
        if len(rs1) > 0:
            for rs in rs1:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td></td>"
                html += "</tr>"
        html += "</table>"
        return HttpResponse(html)
    else:
        t = get_template('mana1/delete_product_gl_packetqty_rules.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 8
0
def delete_product_gl_packetqty_rules(request):
    '删除配货规则'
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=4)
        rs2,rs1=verifyData(rs1,length=4,required=[0,2,3],psrules=1)

        html=u"<table width='800'><tr><th>代码</th><th>名称</th><th>代码说明</th><th>配货单位</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td style='background-color:yellow;'>" + rs[4] + "</td>"
                html+="</tr>"
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(html)
    else:
        t=get_template('mana1/delete_product_gl_packetqty_rules.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 9
0
def rewrite_verify(request):  #审核处理重写

    #os.system("cmd /c D:/django/mysite/mana1/writemc.py")

    myjson = simplejson.loads(request.POST["myjson"])

    rs1 = functions.trim_csv(myjson["table"], 7)

    s = ""  #存放门店名单

    for rs in rs1:

        if rs[0] == "1":  #勾选的门店

            s += "'" + rs[1] + "',"

    s = s[0:-1]

    #os.system('cmd.exe /c c:/ZSW/memcached/memcached.exe -m 256 -p 11211') #开启内存服务

    html = ""

    if s <> "":

        writemc.Writemc(sqlstr=s)

        result = confsql.runquery(u"select * from brainfo where 门店代码 in(" + s +
                                  ")")  #获取门店综合信息 供门店审核是否需要重写

        html = "<tr><th>重算</th><th>门店代码</th><th>门店名称</th><th>品项数</th><th>库存数量</th><th>建议订货总量</th><th>建议订货总额</th></tr>"

        for rs in result:

            html += "<tr><td><input type='checkbox'></td><td>" + str(
                rs[0]) + "</td><td>" + str(
                    rs[1].encode("utf8")) + "</td><td>" + str(
                        rs[2]) + "</td><td>" + str(rs[3]) + "</td><td>" + str(
                            rs[4]) + "</td><td>" + str(rs[5]) + "</td></tr>"

        return HttpResponse(html)

    else:

        writemc.Writemc()  #全部重写

        result = confsql.runquery(
            "select * from brainfo")  #获取门店综合信息 供门店审核是否需要重写

        html = "<tr><th>重算</th><th>门店代码</th><th>门店名称</th><th>品项数</th><th>库存数量</th><th>建议订货总量</th><th>建议订货总额</th></tr>"

        for rs in result:

            html += "<tr><td><input type='checkbox'></td><td>" + str(
                rs[0]) + "</td><td>" + str(
                    rs[1].encode("utf8")) + "</td><td>" + str(
                        rs[2]) + "</td><td>" + str(rs[3]) + "</td><td>" + str(
                            rs[4]) + "</td><td>" + str(rs[5]) + "</td></tr>"

        return HttpResponse(html)
Exemplo n.º 10
0
def import_product_gl_packetqty_rules(request):
    '商品配送规则导入'
    if request.method == 'POST':
        value = request.POST['value']
        rs1 = trim_csv(value, itemlenth=4)
        rs2, rs1 = verifyData(rs1, length=4, required=[0, 2, 3], psrules=1)

        temp = []
        for rs in rs1:
            excode = rs[2]
            if rs[2] == u'商品代码':
                excode = 'sp'
            if rs[2] == u'小类代码':
                excode = 'xl'
            if rs[2] == u'中类代码':
                excode = 'zl'
            if rs[2] == u'大类代码':
                excode = 'dl'
            '重复项覆盖'
            sqlstr = "select * from product_gl_packetqty_rules where xcode='" + rs[
                0] + "' and excode='" + excode + "'"
            if confsql.checkExist(
                    sqlstr) == 1:  #检查xcode,excode,packetqty 数据库是否已存在
                rs.append(u'数据库已存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        html = u"<table width='800'><tr><th>代码</th><th>名称</th><th>代码说明</th><th>配货单位</th></tr>"
        if len(rs2) > 0:
            for rs in rs2:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td style='background-color:yellow;'>" + rs[
                    4] + "</td>"
                html += "</tr>"
        if len(rs1) > 0:
            for rs in rs1:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td></td>"
                html += "</tr>"
        html += "</table>"
        return HttpResponse(html)
    else:
        t = get_template('mana1/import_product_gl_packetqty_rules.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 11
0
def save_maxmin(request):
    ' 上下限导入检查 写入数据库 '
    try:
        rs1 = []
        result = []
        myjson = simplejson.loads(request.POST["myjson"])
        rs1 = trim_csv(myjson["table"])
        banben = myjson["banben"]
        startdate = myjson["startdate"]
        enddate = myjson["enddate"]
        #插入数据库
        sqlstr = ""
        for rs in rs1:
            if rs[6] == '':
                sqlstr += "delete from maxmin where braid ='" + rs[
                    0] + "' and proid='" + rs[
                        2] + "' and banben='" + banben + "';"
        if sqlstr <> "":
            confsql.runSql(sqlstr)  #数据库
        sqlstr = ""
        for rs in rs1:
            if rs[6] == '':
                adddate = datetime.datetime.now().strftime(
                    '%Y-%m-%d')  #最后追加插入日期
                sqlstr += "insert into maxmin(braid,proid,maxval,minval,banben,startdate,enddate,adddate) values('" + rs[
                    0] + "','" + rs[2] + "','" + rs[4] + "','" + rs[
                        5] + "','" + banben + "','" + startdate + "','" + enddate + "','" + adddate + "');"
                rs[6] = '插入成功!'
                res = {}
                res['braid'] = rs[0]
                res['braname'] = rs[1]
                res['proid'] = rs[2]
                res['proname'] = rs[3]
                res['maxval'] = rs[4]
                res['minval'] = rs[5]
                res['info'] = rs[6]
                result.append(res)
            else:
                res = {}
                res['braid'] = rs[0]
                res['braname'] = rs[1]
                res['proid'] = rs[2]
                res['proname'] = rs[3]
                res['maxval'] = rs[4]
                res['minval'] = rs[5]
                res['info'] = rs[6]
                result.append(res)
        if sqlstr <> "":
            confsql.runSql(sqlstr)  #数据库
        jsonres = simplejson.dumps(result)
        log(jsonres)
        return HttpResponse(jsonres)
    except:
        return HttpResponse(0)
Exemplo n.º 12
0
def save_basedisplay(request):
    '保存订货量修改规则'
    rs1 = []
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"])

    for rs in rs1:
        if rs[5] <> '':
            if rs[5] == u'数据库已存在!':
                try:
                    confsql.runSql("update basedisplay set basedisplay='" +
                                   rs[4] + "' where braid='" + rs[0] +
                                   "' and proid='" + rs[2] + "'")
                    rs[5] = '插入成功!'
                except:
                    rs[5] = '插入失败!'
                res = {}
                res['braid'] = rs[0]
                res['braname'] = rs[1]
                res['proid'] = rs[2]
                res['proname'] = rs[3]
                res['basedisplay'] = rs[4]
                res['info'] = rs[5]
                result.append(res)
            else:
                res = {}
                res['braid'] = rs[0]
                res['braname'] = rs[1]
                res['proid'] = rs[2]
                res['proname'] = rs[3]
                res['basedisplay'] = rs[4]
                res['info'] = rs[5]
                result.append(res)
        else:  #无误的
            try:
                confsql.runSql(
                    "insert into basedisplay(braid,proid,basedisplay) values('"
                    + rs[0] + "','" + rs[2] + "','" + rs[4] + "')")
                rs[5] = '插入成功!'
            except:
                rs[5] = '插入失败!'
            res = {}
            res['braid'] = rs[0]
            res['braname'] = rs[1]
            res['proid'] = rs[2]
            res['proname'] = rs[3]
            res['basedisplay'] = rs[4]
            res['info'] = rs[5]
            result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 13
0
def import_product_gl_packetqty_rules(request):
    '商品配送规则导入'
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=4)
        rs2,rs1=verifyData(rs1,length=4,required=[0,2,3],psrules=1)

        temp=[]
        for rs in rs1:
            excode=rs[2]
            if rs[2]==u'商品代码':
                excode='sp'
            if rs[2]==u'小类代码':
                excode='xl'
            if rs[2]==u'中类代码':
                excode='zl'
            if rs[2]==u'大类代码':
                excode='dl'
            '重复项覆盖'
            sqlstr="select * from product_gl_packetqty_rules where xcode='"+rs[0]+"' and excode='"+excode+"'"
            if confsql.checkExist(sqlstr)==1: #检查xcode,excode,packetqty 数据库是否已存在
                rs.append(u'数据库已存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        html=u"<table width='800'><tr><th>代码</th><th>名称</th><th>代码说明</th><th>配货单位</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td style='background-color:yellow;'>" + rs[4] + "</td>"
                html+="</tr>"
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(html)
    else:
        t=get_template('mana1/import_product_gl_packetqty_rules.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 14
0
def deleteData_product_gl_packetqty_rules(request):
    '删除数据'
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"])
    #log(rs1)
    if len(rs1) > 0:
        for rs in rs1:
            if rs[4] <> '':  #出错信息的保留
                res = {}
                res['xcode'] = rs[0]
                res['name'] = rs[1]
                res['excode'] = rs[2]
                res['packetqty1'] = rs[3]
                res['info'] = rs[4]
                result.append(res)
            else:
                try:
                    #sp, xl, zl, dl, null
                    excode = rs[2]
                    if rs[2] == u'商品代码':
                        excode = 'sp'
                    if rs[2] == u'小类代码':
                        excode = 'xl'
                    if rs[2] == u'中类代码':
                        excode = u'zl'
                    if rs[2] == '大类代码':
                        excode = u'dl'
                    #log("delete from product_gl_packetqty_rules where xcode='"+rs[0]+"' and excode='"+excode+"'")
                    confsql.runSql(
                        "delete from product_gl_packetqty_rules where xcode='"
                        + rs[0] + "' and excode='" + excode + "'")

                    res = {}
                    res['xcode'] = rs[0]
                    res['name'] = rs[1]
                    res['excode'] = rs[2]
                    res['packetqty1'] = rs[3]
                    res['info'] = u'删除成功!'
                    result.append(res)
                except:
                    res = {}
                    res['xcode'] = rs[0]
                    res['name'] = rs[1]
                    res['excode'] = rs[2]
                    res['packetqty1'] = rs[3]
                    res['info'] = u'删除失败!'
                    result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 15
0
def rewrite_verify(request): #审核处理重写

    #os.system("cmd /c D:/django/mysite/mana1/writemc.py")

    myjson = simplejson.loads(request.POST["myjson"])

    rs1=functions.trim_csv(myjson["table"],7)

    s="" #存放门店名单

    for rs in rs1:

        if rs[0]=="1": #勾选的门店

            s+="'"+rs[1]+"',"

    s=s[0:-1]

    #os.system('cmd.exe /c c:/ZSW/memcached/memcached.exe -m 256 -p 11211') #开启内存服务

    html=""

    if s<>"":

        writemc.Writemc(sqlstr=s)

        result=confsql.runquery(u"select * from brainfo where 门店代码 in("+s+")") #获取门店综合信息 供门店审核是否需要重写

        html="<tr><th>重算</th><th>门店代码</th><th>门店名称</th><th>品项数</th><th>库存数量</th><th>建议订货总量</th><th>建议订货总额</th></tr>"

        for rs in result:

            html+="<tr><td><input type='checkbox'></td><td>"+str(rs[0])+"</td><td>"+str(rs[1].encode("utf8"))+"</td><td>"+str(rs[2])+"</td><td>"+str(rs[3])+"</td><td>"+str(rs[4])+"</td><td>"+str(rs[5])+"</td></tr>"

        return HttpResponse(html)

    else:

        writemc.Writemc() #全部重写

        result=confsql.runquery("select * from brainfo") #获取门店综合信息 供门店审核是否需要重写

        html="<tr><th>重算</th><th>门店代码</th><th>门店名称</th><th>品项数</th><th>库存数量</th><th>建议订货总量</th><th>建议订货总额</th></tr>"

        for rs in result:

            html+="<tr><td><input type='checkbox'></td><td>"+str(rs[0])+"</td><td>"+str(rs[1].encode("utf8"))+"</td><td>"+str(rs[2])+"</td><td>"+str(rs[3])+"</td><td>"+str(rs[4])+"</td><td>"+str(rs[5])+"</td></tr>"

        return HttpResponse(html)
Exemplo n.º 16
0
def deleteData_product_gl_packetqty_rules(request):
    '删除数据'
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"])
    #log(rs1)
    if len(rs1)>0:
        for rs in rs1:
            if rs[4]<>'': #出错信息的保留
                res={}
                res['xcode']=rs[0]
                res['name']=rs[1]
                res['excode']=rs[2]
                res['packetqty1']=rs[3]
                res['info']=rs[4]
                result.append(res)
            else:
                try:
                    #sp, xl, zl, dl, null
                    excode=rs[2]
                    if rs[2]==u'商品代码':
                        excode='sp'
                    if rs[2]==u'小类代码':
                        excode='xl'
                    if rs[2]==u'中类代码':
                        excode=u'zl'
                    if rs[2]=='大类代码':
                        excode=u'dl'
                    #log("delete from product_gl_packetqty_rules where xcode='"+rs[0]+"' and excode='"+excode+"'")
                    confsql.runSql("delete from product_gl_packetqty_rules where xcode='"+rs[0]+"' and excode='"+excode+"'")
                    
                    res={}
                    res['xcode']=rs[0]
                    res['name']=rs[1]
                    res['excode']=rs[2]
                    res['packetqty1']=rs[3]
                    res['info']=u'删除成功!'
                    result.append(res)
                except:
                    res={}
                    res['xcode']=rs[0]
                    res['name']=rs[1]
                    res['excode']=rs[2]
                    res['packetqty1']=rs[3]
                    res['info']=u'删除失败!'
                    result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 17
0
def save_basedisplay(request):
    '保存订货量修改规则'
    rs1=[]
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"])

    for rs in rs1:
        if rs[5]<>'':
            if rs[5]==u'数据库已存在!':
                try:
                    confsql.runSql("update basedisplay set basedisplay='"+rs[4]+"' where braid='"+rs[0]+"' and proid='"+rs[2]+"'")
                    rs[5]='插入成功!'
                except:
                    rs[5]='插入失败!'
                res={}
                res['braid']=rs[0]
                res['braname']=rs[1]
                res['proid']=rs[2]
                res['proname']=rs[3]
                res['basedisplay']=rs[4]
                res['info']=rs[5]
                result.append(res)
            else:
                res={}
                res['braid']=rs[0]
                res['braname']=rs[1]
                res['proid']=rs[2]
                res['proname']=rs[3]
                res['basedisplay']=rs[4]
                res['info']=rs[5]
                result.append(res)
        else: #无误的
            try:
                confsql.runSql("insert into basedisplay(braid,proid,basedisplay) values('"+rs[0]+"','"+rs[2]+"','"+rs[4]+"')")
                rs[5]='插入成功!'
            except:
                rs[5]='插入失败!'
            res={}
            res['braid']=rs[0]
            res['braname']=rs[1]
            res['proid']=rs[2]
            res['proname']=rs[3]
            res['basedisplay']=rs[4]
            res['info']=rs[5]
            result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 18
0
def save_maxmin(request):
    ' 上下限导入检查 写入数据库 '
    try:
        rs1=[]
        result=[]
        myjson=simplejson.loads(request.POST["myjson"])
        rs1=trim_csv(myjson["table"])
        banben=myjson["banben"]
        startdate=myjson["startdate"]
        enddate=myjson["enddate"]
        #插入数据库
        sqlstr=""
        for rs in rs1:
            if rs[6]=='':
                sqlstr+="delete from maxmin where braid ='" + rs[0] + "' and proid='" + rs[2] + "' and banben='" + banben + "';"
        if sqlstr<>"":
            confsql.runSql(sqlstr)  #数据库
        sqlstr=""
        for rs in rs1:
            if rs[6]=='':
                adddate=datetime.datetime.now().strftime('%Y-%m-%d') #最后追加插入日期
                sqlstr+="insert into maxmin(braid,proid,maxval,minval,banben,startdate,enddate,adddate) values('"+rs[0]+"','"+rs[2]+"','"+rs[4]+"','"+rs[5]+"','"+banben+"','"+startdate+"','"+enddate+"','"+adddate+"');"
                rs[6]='插入成功!'
                res={}
                res['braid']=rs[0]
                res['braname']=rs[1]
                res['proid']=rs[2]
                res['proname']=rs[3]
                res['maxval']=rs[4]
                res['minval']=rs[5]
                res['info']=rs[6]
                result.append(res)
            else:
                res={}
                res['braid']=rs[0]
                res['braname']=rs[1]
                res['proid']=rs[2]
                res['proname']=rs[3]
                res['maxval']=rs[4]
                res['minval']=rs[5]
                res['info']=rs[6]
                result.append(res)
        if sqlstr<>"":
            confsql.runSql(sqlstr)  #数据库
        jsonres=simplejson.dumps(result)
        log(jsonres)
        return  HttpResponse(jsonres)
    except:
        return HttpResponse(0)
Exemplo n.º 19
0
def import_basedisplay(request):
    '订货量修改规则导入'
    if request.method == 'POST':
        value = request.POST['value']
        rs1 = trim_csv(value, itemlenth=5)
        rs2, rs1 = verifyData(rs1, length=5, required=[0, 2, 4])

        '重复项覆盖'
        temp = []
        for rs in rs1:
            sqlstr = u"select * from basedisplay where braid='" + rs[
                0] + "' and proid='" + rs[2] + "'"
            if confsql.checkExist(sqlstr) == 1:  #检查braid,proid数据库是否已存在
                rs.append(u'数据库已存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        html = u"<table width='1000'><tr><th>门店代码</th><th>门店名称</th><th>商品代码</th><th>商品名称</th><th>基本陈列量</th></tr>"
        if len(rs2) > 0:
            for rs in rs2:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td style='background-color:yellow'>" + rs[5] + "</td>"
                html += "</tr>"
        if len(rs1) > 0:
            for rs in rs1:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td></td>"
                html += "</tr>"
        html += "</table>"
        return HttpResponse(Context(html))
    else:
        t = get_template('mana1/import_basedisplay.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 20
0
def import_basedisplay(request):
    '订货量修改规则导入'
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=5)
        rs2,rs1=verifyData(rs1,length=5,required=[0,2,4])

        '重复项覆盖'
        temp=[]
        for rs in rs1:
            sqlstr=u"select * from basedisplay where braid='"+rs[0]+"' and proid='"+rs[2]+"'"
            if confsql.checkExist(sqlstr)==1: #检查braid,proid数据库是否已存在
                rs.append(u'数据库已存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        html=u"<table width='1000'><tr><th>门店代码</th><th>门店名称</th><th>商品代码</th><th>商品名称</th><th>基本陈列量</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td style='background-color:yellow'>" + rs[5] + "</td>"
                html+="</tr>"
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(Context(html))
    else:
        t=get_template('mana1/import_basedisplay.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 21
0
def save_delivery(request):
    '''配送规则导入检查并插入数据库'''
    rs1=[]
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"])
    adddate=datetime.datetime.now().strftime('%Y-%m-%d')

    for rs in rs1:
        #log(rs)
        if rs[3]<>'':
            if rs[3]==u'数据库已存在':
                try:
                    #confsql.runSql("update delivery set adddate='"+adddate+"' where braid='"+rs[0]+"' and weekdelivery='"+rs[2]+"'")
                    sqlstr ="delete from delivery where braid='"+rs[0]+"' and weekdelivery='"+rs[2]+"'; "
                    sqlstr +=" insert into delivery(braid,weekdelivery,adddate) values('"+rs[0]+"','"+rs[2]+"','"+adddate+"') "
                    confsql.runSql(sqlstr)
                    rs[3]=u'插入成功!'
                except:
                    rs[3]=u'插入失败!'
            else:
                    res={}
                    res['braid']=rs[0]
                    res['braname']=rs[1]
                    res['weekdelivery']=rs[2]
                    res['adddate']=adddate
                    res['info']=rs[3]
                    result.append(res)
        else:
            try:
                sqlstr="insert into delivery(braid,weekdelivery,adddate) values('"+rs[0]+"','"+rs[2]+"','"+adddate+"')"
                confsql.runSql(sqlstr)
                rs[3]=u'插入成功!'
            except:
                rs[3]=u'插入失败!'
            res={}
            res['braid']=rs[0]
            res['braname']=rs[1]
            res['weekdelivery']=rs[2]
            res['adddate']=adddate
            res['info']=rs[3]
            result.append(res)

    jsonres=simplejson.dumps(result)
    return  HttpResponse(jsonres)
Exemplo n.º 22
0
def import_tianshu(request):
    if request.method == 'POST':
        value = request.POST['value']
        rs1 = trim_csv(value, itemlenth=4)
        rs2, rs1 = verifyData(rs1, length=4, required=[0, 2, 3])

        '重复项覆盖'
        temp = []
        if len(rs1) > 0:
            for rs in rs1:
                if confsql.checkExist("select * from tianshu where braid='" +
                                      rs[0] + "'") == 1:  #检查数据库是否已存在
                    temp.append(rs)
                    rs.append(u'数据库已存在!')
                    rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        html = u"<table width='800'><tr><th>门店代码</th><th>门店名称</th><th>安全库存天数</th><th>送货周期天数</th></tr>"
        if len(rs2) > 0:
            for rs in rs2:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td style='background-color:yellow'>" + rs[4] + "</td>"
                html += "</tr>"
        if len(rs1) > 0:
            for rs in rs1:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td></td>"
                html += "</tr>"
        html += "</table>"
        return HttpResponse(Context(html))
    else:
        t = get_template('mana1/import_tianshu.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 23
0
def import_tianshu(request):
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=4)
        rs2,rs1=verifyData(rs1,length=4,required=[0,2,3])

        '重复项覆盖'
        temp=[]
        if len(rs1)>0:
            for rs in rs1:
                if confsql.checkExist("select * from tianshu where braid='"+rs[0]+"'")==1: #检查数据库是否已存在
                    temp.append(rs)
                    rs.append(u'数据库已存在!')
                    rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        html=u"<table width='800'><tr><th>门店代码</th><th>门店名称</th><th>安全库存天数</th><th>送货周期天数</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td style='background-color:yellow'>" + rs[4] + "</td>"
                html+="</tr>"
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(Context(html))
    else:
        t=get_template('mana1/import_tianshu.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 24
0
def import_delivery(request):
    ''' 配送日期导入 '''
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value, itemlenth=3) #去除行尾多余换行符 rs1存放初始值
        rs2,rs1=verifyData(rs1,length=3,required=[0,2],delivery=1)
        
        #数据库已存在给予提示
        temp=[]
        for rs in rs1:
            if confsql.checkExist("select * from delivery where braid='"+rs[0]+"' and weekdelivery='"+rs[2]+"'")==1:
                temp.append(rs)
                rs.append(u'数据库已存在!')
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        html=u"<table width='800'><tr><th>门店代码</th><th>门店名称</th><th>配送日</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td style='background-color:yellow;'>" + rs[3] + "</td>"
                html+="</tr>"
        #log(rs1)
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(html)
    else:
        t=get_template('mana1/import_delivery.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 25
0
def deleteData_basedisplay(request):
    '删除数据'
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"], itemlenth=0)
    if len(rs1) > 0:
        for rs in rs1:
            if rs[5] <> '':  #出错信息的保留
                res = {}
                res['braid'] = rs[0]
                res['braname'] = rs[1]
                res['proid'] = rs[2]
                res['proname'] = rs[3]
                res['basedisplay'] = rs[4]
                res['info'] = rs[5]
                result.append(res)
            else:
                try:
                    sqlstr = u"delete from basedisplay where braid='" + rs[
                        0] + "' and proid='" + rs[2] + "'"
                    confsql.runSql(sqlstr)
                    res = {}
                    res['braid'] = rs[0]
                    res['braname'] = rs[1]
                    res['proid'] = rs[2]
                    res['proname'] = rs[3]
                    res['basedisplay'] = rs[4]
                    res['info'] = u'删除成功!'
                    result.append(res)
                except:
                    res = {}
                    res['braid'] = rs[0]
                    res['braname'] = rs[1]
                    res['proid'] = rs[2]
                    res['proname'] = rs[3]
                    res['basedisplay'] = rs[4]
                    res['info'] = u'删除失败!'
                    result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 26
0
def import_maxmin(request):
    ''' 上下限导入界面 '''
    if request.method == 'POST':
        '''暂存数据 初步检查'''
        try:
            value = request.POST['value']
            rs1 = trim_csv(value, itemlenth=6)  #去除行尾多余换行符 rs1存放初始值
            rs2, rs1 = verifyData(rs1, length=6, required=[4], maxmin=1)

            html = u"<table width='1000'><tr><th>门店代码</th><th>门店名称</th><th>商品代码</th><th>商品名称</th><th>上限</th><th>下限</th><th></th></tr>"
            if len(rs2) > 0:
                for rs in rs2:
                    html += "<tr>"
                    html += "<td>" + rs[0] + "</td>"
                    html += "<td>" + rs[1] + "</td>"
                    html += "<td>" + rs[2] + "</td>"
                    html += "<td>" + rs[3] + "</td>"
                    html += "<td>" + rs[4] + "</td>"
                    html += "<td>" + rs[5] + "</td>"
                    html += "<td style='background-color:yellow'>" + rs[
                        6] + "</td>"
                    html += "</tr>"
            if len(rs1) > 0:
                for rs in rs1:
                    html += "<tr>"
                    html += "<td>" + rs[0] + "</td>"
                    html += "<td>" + rs[1] + "</td>"
                    html += "<td>" + rs[2] + "</td>"
                    html += "<td>" + rs[3] + "</td>"
                    html += "<td>" + rs[4] + "</td>"
                    html += "<td>" + rs[5] + "</td>"
                    html += "<td></td>"
                    html += "</tr>"
            html += "</table>"
            return HttpResponse(html)
        except:
            return HttpResponse(0)
    else:
        t = get_template('mana1/import_maxmin.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 27
0
def import_maxmin(request):
    ''' 上下限导入界面 '''
    if request.method=='POST':
        '''暂存数据 初步检查'''
        try:
            value=request.POST['value']
            rs1=trim_csv(value,itemlenth=6) #去除行尾多余换行符 rs1存放初始值
            rs2,rs1=verifyData(rs1,length=6,required=[4],maxmin=1)

            html=u"<table width='1000'><tr><th>门店代码</th><th>门店名称</th><th>商品代码</th><th>商品名称</th><th>上限</th><th>下限</th><th></th></tr>"
            if len(rs2)>0:
                for rs in rs2:
                    html+="<tr>"
                    html+="<td>" + rs[0] + "</td>"
                    html+="<td>" + rs[1] + "</td>"
                    html+="<td>" + rs[2] + "</td>"
                    html+="<td>" + rs[3] + "</td>"
                    html+="<td>" + rs[4] + "</td>"
                    html+="<td>" + rs[5] + "</td>"
                    html+="<td style='background-color:yellow'>" + rs[6] + "</td>"
                    html+="</tr>"
            if len(rs1)>0:
                for rs in rs1:
                    html+="<tr>"
                    html+="<td>" + rs[0] + "</td>"
                    html+="<td>" + rs[1] + "</td>"
                    html+="<td>" + rs[2] + "</td>"
                    html+="<td>" + rs[3] + "</td>"
                    html+="<td>" + rs[4] + "</td>"
                    html+="<td>" + rs[5] + "</td>"
                    html+="<td></td>"
                    html+="</tr>"
            html+="</table>"
            return HttpResponse(html)
        except:
            return HttpResponse(0)
    else:
        t=get_template('mana1/import_maxmin.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 28
0
def delete_dhrules(request):
    '删除订货规则'
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=8)
        rs2,rs1=verifyData(rs1,length=8,required=[5,6,7],dhrules=1)

        html=u"<table width='1000'><tr><th>门店代码</th><th>门店名称</th><th>代码</th><th>名称</th><th>代码说明</th><th>规则对象</th><th>规则说明</th><th>规则值</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td>" + rs[5] + "</td>"
                html+="<td>" + rs[6] + "</td>"
                html+="<td>" + rs[7] + "</td>"
                html+="<td style='background-color:yellow'>" + rs[8] + "</td>"
                html+="</tr>"
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td>" + rs[5] + "</td>"
                html+="<td>" + rs[6] + "</td>"
                html+="<td>" + rs[7] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(Context(html))
    else:
        t=get_template('mana1/delete_dhrules.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 29
0
def delete_dhrules(request):
    '删除订货规则'
    if request.method == 'POST':
        value = request.POST['value']
        rs1 = trim_csv(value, itemlenth=8)
        rs2, rs1 = verifyData(rs1, length=8, required=[5, 6, 7], dhrules=1)

        html = u"<table width='1000'><tr><th>门店代码</th><th>门店名称</th><th>代码</th><th>名称</th><th>代码说明</th><th>规则对象</th><th>规则说明</th><th>规则值</th></tr>"
        if len(rs2) > 0:
            for rs in rs2:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td>" + rs[5] + "</td>"
                html += "<td>" + rs[6] + "</td>"
                html += "<td>" + rs[7] + "</td>"
                html += "<td style='background-color:yellow'>" + rs[8] + "</td>"
                html += "</tr>"
        if len(rs1) > 0:
            for rs in rs1:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td>" + rs[5] + "</td>"
                html += "<td>" + rs[6] + "</td>"
                html += "<td>" + rs[7] + "</td>"
                html += "<td></td>"
                html += "</tr>"
        html += "</table>"
        return HttpResponse(Context(html))
    else:
        t = get_template('mana1/delete_dhrules.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 30
0
def deleteData_delivery(request):
    '删除数据'
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"],itemlenth=0)
    adddate=datetime.datetime.now().strftime('%Y-%m-%d')
    if len(rs1)>0:
        for rs in rs1:
            if rs[3]<>'': #出错信息的保留
                res={}
                res['braid']=rs[0]
                res['braname']=rs[1]
                res['weekdelivery']=rs[2]
                res['adddate']=adddate
                res['info']=rs[3]
                result.append(res)
            else:
                try:
                    sqlstr="delete from delivery where braid='"+rs[0]+"' and weekdelivery='"+rs[2]+"'"
                    confsql.runSql(sqlstr)
                    res={}
                    res['braid']=rs[0]
                    res['braname']=rs[1]
                    res['weekdelivery']=rs[2]
                    res['adddate']=adddate
                    res['info']=u'删除成功!'
                    result.append(res)
                except:
                    res={}
                    res['braid']=rs[0]
                    res['braname']=rs[1]
                    res['weekdelivery']=rs[2]
                    res['adddate']=adddate
                    res['info']=u'删除失败!'
                    result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 31
0
def deleteData_dhrulesYuzhi(request):
    '删除数据'
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"])
    if len(rs1)>0:
        for rs in rs1:
            if rs[12]<>'': #出错信息的保留
                res={}
                res['mdcode']=rs[0]
                res['mdname']=rs[1]
                res['xcode']=rs[2]
                res['name']=rs[3]
                res['excode']=rs[4]
                res['yqkey']=rs[5]
                res['yqrule']=rs[6]
                res['yqvalue']=rs[7]
                res['startdate']=rs[8]
                res['enddate']=rs[9]
                res['remark']=rs[10]
                res['adddate']=rs[11]
                res['info']=rs[12]
                result.append(res)
            else: #无出错信息的执行删除
                try:
                    excode=rs[4]
                    if rs[4]==u'商品代码':
                        excode='sp'
                    if rs[4]==u'品牌小类代码':
                        excode='braxl'
                    if rs[4]==u'大类代码':
                        excode='prodl'
                    if rs[4]==u'中类代码':
                        excode='prozl'
                    if rs[4]==u'小类代码':
                        excode='proxl'
                    confsql.runSql("delete from dhrulesYuzhi where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and startdate='"+rs[8]+"' and enddate = '" + rs[9] + "'")
                    res={}
                    res['mdcode']=rs[0]
                    res['mdname']=rs[1]
                    res['xcode']=rs[2]
                    res['name']=rs[3]
                    res['excode']=rs[4]
                    res['yqkey']=rs[5]
                    res['yqrule']=rs[6]
                    res['yqvalue']=rs[7]
                    res['startdate']=rs[8]
                    res['enddate']=rs[9]
                    res['remark']=rs[10]
                    res['adddate']=rs[11]
                    res['info']=u'删除成功!'
                    result.append(res)
                except:
                    res['mdcode']=rs[0]
                    res['mdname']=rs[1]
                    res['xcode']=rs[2]
                    res['name']=rs[3]
                    res['excode']=rs[4]
                    res['yqkey']=rs[5]
                    res['yqrule']=rs[6]
                    res['yqvalue']=rs[7]
                    res['startdate']=rs[8]
                    res['enddate']=rs[9]
                    res['remark']=rs[10]
                    res['adddate']=rs[11]
                    res['info']=u'删除失败!'
                    result.append(res)
    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 32
0
def import_dhrules(request):
    '订货量修改规则导入'
    if request.method == 'POST':
        value = request.POST['value']
        rs1 = trim_csv(value, itemlenth=8)
        rs2, rs1 = verifyData(rs1, length=8, required=[5, 6, 7], dhrules=1)

        '重复项覆盖'
        temp = []
        for rs in rs1:
            excode = rs[4]
            if rs[4] == u'商品代码':
                excode = 'sp'
            if rs[4] == u'小类代码':
                excode = 'xl'
            if rs[4] == u'中类代码':
                excode = 'zl'
            if rs[4] == u'大类代码':
                excode = 'dl'

            yqkey = rs[5]
            if rs[5] == u'上阈值':
                yqkey = 'maxlimit'
            if rs[5] == u'下阈值':
                yqkey = 'minlimit'

            sqlstr = u"select * from dhrules where mdcode='" + rs[
                0] + "' and xcode = '" + rs[
                    2] + "' and excode='" + excode + "' and yqkey='" + yqkey + "'"
            if confsql.checkExist(sqlstr) == 1:  #检查mdcode,excode,yqkey数据库是否已存在
                rs.append(u'数据库已存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        html = u"<table width='1000'><tr><th>门店代码</th><th>门店名称</th><th>代码</th><th>名称</th><th>代码说明</th><th>规则对象</th><th>规则说明</th><th>规则值</th></tr>"
        if len(rs2) > 0:
            for rs in rs2:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td>" + rs[5] + "</td>"
                html += "<td>" + rs[6] + "</td>"
                html += "<td>" + rs[7] + "</td>"
                html += "<td style='background-color:yellow'>" + rs[8] + "</td>"
                html += "</tr>"
        if len(rs1) > 0:
            for rs in rs1:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td>" + rs[5] + "</td>"
                html += "<td>" + rs[6] + "</td>"
                html += "<td>" + rs[7] + "</td>"
                html += "<td></td>"
                html += "</tr>"
        html += "</table>"
        return HttpResponse(Context(html))
    else:
        t = get_template('mana1/import_dhrules.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 33
0
def save_dhrulesYuzhi(request):
    rs1=[]
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"])

    for rs in rs1:
        excode=rs[4]
        if rs[4]==u'商品代码':
            excode='sp'
        if rs[4]==u'品牌小类代码':
            excode='braxl'
        if rs[4]==u'大类代码':
            excode='prodl'
        if rs[4]==u'中类代码':
            excode='prozl'
        if rs[4]==u'小类代码':
            excode='proxl'
        adddate = time.strftime("%Y-%m-%d", time.localtime())

        if rs[10]<>'':
            if rs[10]==u'数据库已存在!':
                try:
                    confsql.runSql(u"delete from dhrulesYuzhi where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and startdate='"+rs[7]+"' and enddate = '" + rs[8] + "'")
                    confsql.runSql(u"insert into dhrulesYuzhi (mdcode,xcode,excode,yqkey,yqrule,yqvalue,startdate,enddate,remark,adddate) values('"+rs[0]+"','"+rs[2]+"','"+excode+"','"+rs[5]+"','相对值','"+rs[6]+"','"+rs[7]+"','"+rs[8]+"','"+adddate+"')")
                    rs[10]=u'插入成功!'
                except:
                    rs[10]=u'插入失败!'
            res={}
            res['mdcode']=rs[0]
            res['mdname']=rs[1]
            res['xcode']=rs[2]
            res['name']=rs[3]
            res['excode']=rs[4]
            res['yqkey']=rs[5]
            res['yqrule']=u"相对值"
            res['yqvalue']=rs[6]
            res['startdate']=rs[7]
            res['enddate']=rs[8]
            res['remark']=rs[9]
            res['info']=rs[10]
            result.append(res)
        else: #无误的
            try:
                sqlstr=u"insert into dhrulesYuzhi (mdcode,xcode,excode,yqkey,yqrule,yqvalue,startdate,enddate,remark,adddate) values('"+rs[0]+"','"+rs[2]+"','"+excode+"','"+rs[5]+"','"+u"相对值"+"','"+rs[6]+"','"+rs[7]+"','"+rs[8]+"','"+rs[9]+"','"+adddate+"')"
                confsql.runSql(sqlstr)
                rs[10]=u'插入成功!'
            except:
                rs[10]=u'插入失败!'
            res={}
            res['mdcode']=rs[0]
            res['mdname']=rs[1]
            res['xcode']=rs[2]
            res['name']=rs[3]
            res['excode']=rs[4]
            res['yqkey']=rs[5]
            res['yqrule']=u"相对值"
            res['yqvalue']=rs[6]
            res['startdate']=rs[7]
            res['enddate']=rs[8]
            res['remark']=rs[9]
            res['info']=rs[10]
            result.append(res)
    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 34
0
def delete_dhrulesYuzhi(request):
    '删除暂停订货范围规则'
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=12)
        rs2,rs1=verifyData(rs1,length=12,required=[5,6,7,8,9])

        '是否重复'
        temp=[]
        for rs in rs1:
            excode=rs[4]
            if rs[4]==u'商品代码':
                excode='sp'
            if rs[4]==u'品牌小类代码':
                excode='braxl'
            if rs[4]==u'大类代码':
                excode='prodl'
            if rs[4]==u'中类代码':
                excode='prozl'
            if rs[4]==u'小类代码':
                excode='proxl'
            sqlstr=u"select * from dhrulesYuzhi where mdcode='"+rs[0]+"' and xcode = '"+ rs[2] +"' and excode='"+excode+"' and startdate='"+rs[8]+"' and enddate = '" + rs[9] + "'"
            if confsql.checkExist(sqlstr)<>1: #检查mdcode,excode,yqkey数据库是否已存在
                rs.append(u'数据库不存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '门店代码商品代码 长度检查'
        temp=[]
        for rs in rs1:
            if len(rs[0])<>5: #门店代码 5位
                rs.append(u'门店代码长度必须为5位!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '代码说明 检查'
        temp=[]
        for rs in rs1:
            if rs[4] <>u"商品代码" and rs[4]<>u"品牌小类代码" and rs[4]<>u"大类代码" and rs[4]<>u"中类代码" and rs[4]<>u"小类代码":
                rs.append(u'代码说明不符要求!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '代码 检查'
        temp=[]
        for rs in rs1:
            if rs[4]==u"商品代码" or rs[4]==u"品牌小类代码" or rs[4]==u"小类代码":
                if len(rs[2])<>8: #商品代码或品牌小类代码 8位
                    rs.append(u'代码长度不符!')
                    temp.append(rs)
                    rs2.append(rs)
            if rs[4]==u"中类代码":
                if len(rs[2])<>5:
                    rs.append(u'代码长度不符!')
                    temp.append(rs)
                    rs2.append(rs)
            if rs[4]==u"大类代码":
                if len(rs[2])<>2:
                    rs.append(u'代码长度不符!')
                    temp.append(rs)
                    rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '规则说明只能填相对值'
        temp=[]
        for rs in rs1:
            if rs[6]<>u'相对值':
                rs.append(u'规则说明只能填“相对值”!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '规则值为百分比格式且大于0'
        temp=[]
        for rs in rs1:
            if type(eval(rs[7]))<>type(1.00) or eval(rs[7])<0:
                rs.append(u'规则值必须为正百分比格式!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '开始日期格式检查'
        temp=[]
        for rs in rs1:
            m=re.match(r'^\w\w\w\w-\w\w-\w\w$',rs[8])
            if m==None: #日期格式 yyyy-mm-dd
                rs.append(u'日期格式必须为yyyy-mm-dd!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '结束日期格式检查'
        temp=[]
        for rs in rs1:
            m=re.match(r'^\w\w\w\w-\w\w-\w\w$',rs[9])
            if m==None: #日期格式 yyyy-mm-dd
                rs.append(u'日期格式必须为yyyy-mm-dd!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)


        html=u"<table width='1200'><thead><tr><th>门店代码</th><th>门店名称</th><th>代码</th><th>代码名称</th><th>代码说明</th><th>规则对象</th><th>规则说明</th><th>规则值</th><th>开始日期</th><th>结束日期</th><th>备注</th><th>添加日期</th></tr></thead><tbody>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td>" + rs[5] + "</td>"
                html+="<td>" + rs[6] + "</td>"
                html+="<td>" + rs[7] + "</td>"
                html+="<td>" + rs[8] + "</td>"
                html+="<td>" + rs[9] + "</td>"
                html+="<td>" + rs[10] + "</td>"
                html+="<td>" + rs[11] + "</td>"
                html+="<td style='background-color:yellow'>" + rs[12] + "</td>"
                html+="</tr>"
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td>" + rs[5] + "</td>"
                html+="<td>" + rs[6] + "</td>"
                html+="<td>" + rs[7] + "</td>"
                html+="<td>" + rs[8] + "</td>"
                html+="<td>" + rs[9] + "</td>"
                html+="<td>" + rs[10] + "</td>"
                html+="<td>" + rs[11] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</tbody></table>"
        return HttpResponse(Context(html))
    else:
        t=get_template('mana1/delete_dhrulesYuzhi.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 35
0
def save_dhPauserules(request):
    rs1 = []
    result = []
    myjson = simplejson.loads(request.POST["myjson"].encode('utf8'))
    rs1 = trim_csv(myjson["table"])

    for rs in rs1:
        excode = rs[4]
        if rs[4] == u'商品代码':
            excode = 'sp'
        if rs[4] == u'小类代码':
            excode = 'xl'
        if rs[4] == u'中类代码':
            excode = 'zl'
        if rs[4] == u'大类代码':
            excode = 'dl'

        adddate = time.strftime("%Y-%m-%d", time.localtime())

        if rs[7] <> '':
            if rs[7] == u'数据库已存在!':
                try:

                    #confsql.runSql("update dhrules set yqrule='"+yqrule+"',yqvalue='"+rs[7]+"' where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and yqkey='"+yqkey+"'")
                    #log("delete from dhpauserules where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and startdate='"+rs[5]+"' and enddate = '" + rs[6] + "'")
                    confsql.runSql("delete from dhpauserules where mdcode='" +
                                   rs[0] + "' and xcode='" + rs[2] +
                                   "' and excode='" + excode +
                                   "' and startdate='" + rs[5] +
                                   "' and enddate = '" + rs[6] + "'")

                    confsql.runSql(
                        "insert into dhpauserules (mdcode,xcode,excode,startdate, enddate, adddate) values('"
                        + rs[0] + "','" + rs[2] + "','" + excode + "','" +
                        rs[5] + "','" + rs[6] + "','" + adddate + "')")
                    rs[7] = '插入成功!'
                except:
                    rs[7] = '插入失败!'
                res = {}
                res['mdcode'] = rs[0]
                res['mdname'] = rs[1]
                res['xcode'] = rs[2]
                res['name'] = rs[3]
                res['excode'] = rs[4]
                res['startdate'] = rs[5]
                res['enddate'] = rs[6]
                res['info'] = rs[7]
                result.append(res)
            else:
                res = {}
                res['mdcode'] = rs[0]
                res['mdname'] = rs[1]
                res['xcode'] = rs[2]
                res['name'] = rs[3]
                res['excode'] = rs[4]
                res['startdate'] = rs[5]
                res['enddate'] = rs[6]
                res['info'] = rs[7]
                result.append(res)
        else:  #无误的
            try:
                confsql.runSql(
                    "insert into dhpauserules (mdcode,xcode,excode,startdate, enddate, adddate) values('"
                    + rs[0] + "','" + rs[2] + "','" + excode + "','" + rs[5] +
                    "','" + rs[6] + "','" + adddate + "')")
                rs[7] = '插入成功!'
            except:
                rs[7] = '插入失败!'
            res = {}
            res['mdcode'] = rs[0]
            res['mdname'] = rs[1]
            res['xcode'] = rs[2]
            res['name'] = rs[3]
            res['excode'] = rs[4]
            res['startdate'] = rs[5]
            res['enddate'] = rs[6]
            res['info'] = rs[7]
            result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 36
0
def deleteData_dhPauserules(request):
    '删除数据'
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"],itemlenth=0)
    if len(rs1)>0:
        for rs in rs1:
            if rs[7]<>'': #出错信息的保留
                res={}
                res['mdcode']=rs[0]
                res['mdname']=rs[1]
                res['xcode']=rs[2]
                res['name']=rs[3]
                res['excode']=rs[4]
                res['startdate']=rs[5]
                res['enddate']=rs[6]
               
                res['info']=rs[7]
                result.append(res)
            else:
                try:
                    #sp, xl, zl, dl, null
                    res={}
                    excode=rs[4]
                    if rs[4]==u'商品代码':
                        excode='sp'
                    if rs[4]==u'小类代码':
                        excode='xl'
                    if rs[4]==u'中类代码':
                        excode='zl'
                    if rs[4]==u'大类代码':
                        excode='dl'
                        
                    
                        
                        
                        
                    confsql.runSql("delete from dhpauserules where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and startdate='"+rs[5]+"' and enddate = '" + rs[6] + "'")
                    res={}
                    res['mdcode']=rs[0]
                    res['mdname']=rs[1]
                    res['xcode']=rs[2]
                    res['name']=rs[3]
                    res['excode']=rs[4]
                    res['startdate']=rs[5]
                    res['enddate']=rs[6]
                    res['info']=u'删除成功!'
                    result.append(res)
                except:
                    res['mdcode']=rs[0]
                    res['mdname']=rs[1]
                    res['xcode']=rs[2]
                    res['name']=rs[3]
                    res['excode']=rs[4]
                    res['startdate']=rs[5]
                    res['enddate']=rs[6]
                    res['info']=u'删除失败!'
                    result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 37
0
def deleteData_dhrules(request):
    '删除数据'
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"], itemlenth=0)
    if len(rs1) > 0:
        for rs in rs1:
            if rs[8] <> '':  #出错信息的保留
                res = {}
                res['mdcode'] = rs[0]
                res['mdname'] = rs[1]
                res['xcode'] = rs[2]
                res['name'] = rs[3]
                res['excode'] = rs[4]
                res['yqkey'] = rs[5]
                res['yqrule'] = rs[6]
                res['yqvalue'] = rs[7]
                res['info'] = rs[8]
                result.append(res)
            else:
                try:
                    #sp, xl, zl, dl, null
                    res = {}
                    excode = rs[4]
                    if rs[4] == u'商品代码':
                        excode = 'sp'
                    if rs[4] == u'小类代码':
                        excode = 'xl'
                    if rs[4] == u'中类代码':
                        excode = 'zl'
                    if rs[4] == u'大类代码':
                        excode = 'dl'

                    yqkey = rs[5]
                    if rs[5] == u'上阈值':
                        yqkey = 'maxlimit'
                    if rs[5] == u'下阈值':
                        yqkey = 'minlimit'

                    sqlstr = u"delete from dhrules where mdcode='" + rs[
                        0] + "' and xcode ='" + rs[
                            2] + "' and excode='" + excode + "' and yqkey='" + yqkey + "'"
                    #log(sqlstr)
                    confsql.runSql(sqlstr)
                    res = {}
                    res['mdcode'] = rs[0]
                    res['mdname'] = rs[1]
                    res['xcode'] = rs[2]
                    res['name'] = rs[3]
                    res['excode'] = rs[4]
                    res['yqkey'] = rs[5]
                    res['yqrule'] = rs[6]
                    res['yqvalue'] = rs[7]
                    res['info'] = u'删除成功!'
                    result.append(res)
                except:
                    res = {}
                    res['mdcode'] = rs[0]
                    res['mdname'] = rs[1]
                    res['xcode'] = rs[2]
                    res['name'] = rs[3]
                    res['excode'] = rs[4]
                    res['yqkey'] = rs[5]
                    res['yqrule'] = rs[6]
                    res['yqvalue'] = rs[7]
                    res['info'] = u'删除失败!'
                    result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 38
0
def delete_maxminCuxiaori(request):
    '删除促销日上下限规则'
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=10)
        rs2,rs1=verifyData(rs1,length=10,required=[0,2,4,5,6,7,8])

        '重复项覆盖'
        temp=[]
        for rs in rs1:
            excode=rs[4]
            if rs[4]==u'商品代码':
                excode='sp'
            if rs[4]==u'品牌小类代码':
                excode='braxl'
            if rs[4]==u'大类代码':
                excode='prodl'
            if rs[4]==u'中类代码':
                excode='prozl'
            if rs[4]==u'小类代码':
                excode='proxl'
            sqlstr=u"select * from maxminCuxiaori where mdcode='"+rs[0]+"' and xcode = '"+ rs[2] +"' and excode='"+excode+"' and startdate='"+rs[7]+"' and enddate = '" + rs[8] + "'"
            if confsql.checkExist(sqlstr)<>1: #检查mdcode,excode,yqkey数据库是否已存在
                rs.append(u'数据库中不存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '门店代码商品代码 长度检查'
        temp=[]
        for rs in rs1:
            if len(rs[0])<>5: #门店代码 5位
                rs.append(u'门店代码长度必须为5位')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '代码说明 检查'
        temp=[]
        for rs in rs1:
            if rs[4] <>u"商品代码" and rs[4]<>u"品牌小类代码" and rs[4]<>u"大类代码" and rs[4]<>u"中类代码" and rs[4]<>u"小类代码":
                rs.append(u'代码说明不符要求')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '代码 检查 未考虑大,中类,小类'
        """temp=[]
        for rs in rs1:
            if len(rs[2])<>8: #商品代码或品牌小类代码 8位
                rs.append(u'商品代码或品牌小类代码长度必须为8位')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)"""

        '上下限倍数必须是数值'
        temp=[]
        for rs in rs1:
            if type(eval(rs[5]))<>type(1.00) and type(eval(rs[5]))<>type(1):
                rs.append(u'上限倍数必须是数值')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        temp=[]
        for rs in rs1:
            if type(eval(rs[6]))<>type(1.00) and type(eval(rs[6]))<>type(1):
                rs.append(u'下限倍数必须是数值')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '开始日期格式检查'
        temp=[]
        for rs in rs1:
            m=re.match(r'^\w\w\w\w-\w\w-\w\w$',rs[7])
            if m==None: #日期格式 yyyy-mm-dd
                rs.append(u'日期格式必须为yyyy-mm-dd')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        '结束日期格式检查'
        temp=[]
        for rs in rs1:
            m=re.match(r'^\w\w\w\w-\w\w-\w\w$',rs[8])
            if m==None: #日期格式 yyyy-mm-dd
                rs.append(u'日期格式必须为yyyy-mm-dd')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        html=u"<table width='1200'><tr><th>门店代码</th><th>门店名称</th><th>代码</th><th>代码名称</th><th>代码说明</th><th>上限倍数</th><th>下限倍数</th><th>规则开始时间</th><th>规则结束时间</th><th>备注</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td>" + rs[5] + "</td>"
                html+="<td>" + rs[6] + "</td>"
                html+="<td>" + rs[7] + "</td>"
                html+="<td>" + rs[8] + "</td>"
                html+="<td>" + rs[9] + "</td>"
                html+="<td style='background-color:yellow'>" + rs[10] + "</td>"
                html+="</tr>"
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td>" + rs[5] + "</td>"
                html+="<td>" + rs[6] + "</td>"
                html+="<td>" + rs[7] + "</td>"
                html+="<td>" + rs[8] + "</td>"
                html+="<td>" + rs[9] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(Context(html))
    else:
        t=get_template('mana1/delete_maxminCuxiaori.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 39
0
def rewrite(request):

    if request.method=='POST':

        #检查格式是否正确,并返回检查结果

        rs1=functions.trim_csv(request.POST['value'],itemlenth=7)

        rs2=[] #存放最终结果

        rs_temp=[] #存放临时数据

        #不能有空

        for rs in rs1:

            if rs[0]=="" or rs[1]=="" or rs[2]==""  or rs[3]=="" or rs[4]=="" or rs[5]=="" or rs[6]=="":

                rs_temp.append(rs)

                rs.append("不能有为空的项")

                rs2.append(rs)

        if len(rs_temp)>0:

            for rs in rs_temp:

                rs1.remove(rs)



        rs_temp=[] #存放临时数据

        #门店代码为五位码

        for rs in rs1:

            if len(rs[1])<>5:

                rs_temp.append(rs)

                rs.append("门店代码应为五位码")

                rs2.append(rs)

        if len(rs_temp)>0:

            for rs in rs_temp:

                rs1.remove(rs)



        #没有问题的数据

        for rs in rs1:

            rs.append("")

            rs2.append(rs)



        s="<table width='800'><tr><th>审核</th><th>门店代码</th><th>门店名称</th><th>品项数</th><th>库存数量</th><th>建议订货总量</th><th>建议订货总额</th><th>说明</th></tr>"

        for rs in rs2:

            if rs[0]=='0':

                s+="<tr><td><input type='checkbox'></td>"

            else:

                s+="<tr><td><input type='checkbox' checked='checked'></td>"

            s+="<td>"+rs[1]+"</td><td>"+rs[2]+"</td><td>"+rs[3]+"</td><td>"+rs[4]+"</td><td>"+rs[5]+"</td><td>"+rs[6]+"</td>"

            if rs[7]=="":

                s+="<td>"+rs[7]+"</td></tr>"

            else:

                s+="<td style='background-color:yellow'>"+rs[7]+"</td></tr>"

        s+="</table>"

        return HttpResponse(s)

    else:

        t=get_template("mana1/rewrite.html")

        #result=[{"门店代码":"00001","品项数":3500,"库存数量":23340,"库存金额":4337979.32,"建议订货总量":2344,"建议订货总额":34345434},{"门店代码":"00002","品项数":3500,"库存数量":23340,"库存金额":4337979.32,"建议订货总量":2344,"建议订货总额":34345434},{"门店代码":"00003","品项数":3500,"库存数量":23340,"库存金额":4337979.32,"建议订货总量":2344,"建议订货总额":34345434}]

        result=confsql.runquery("select 门店代码, 门店名称, 品项数, 库存数量, 建议订货总量, 建议订货总额 from brainfo") #获取门店综合信息 供门店审核是否需要重写

        html=t.render(Context({'result':result}))

        return  HttpResponse(html)
Exemplo n.º 40
0
def save_product_gl_packetqty_rules(request):
    '保存商品配货单位规则'
    rs1 = []
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"])

    #sp, xl, zl, dl, null
    for rs in rs1:
        excode = rs[2]
        if rs[2] == u'商品代码':
            excode = 'sp'
        if rs[2] == u'小类代码':
            excode = 'xl'
        if rs[2] == u'中类代码':
            excode = 'zl'
        if rs[2] == u'大类代码':
            excode = 'dl'

        if rs[4] <> '':
            if rs[4] == u'数据库已存在!':
                try:
                    sqlstr = "delete from product_gl_packetqty_rules where xcode='" + rs[
                        0] + "' and excode='" + excode + "'"
                    confsql.runSql(sqlstr)
                    sqlstr = "insert into product_gl_packetqty_rules (xcode,excode,packetqty1) values('" + rs[
                        0] + "','" + excode + "','" + rs[3] + "')"
                    confsql.runSql(sqlstr)
                    rs[4] = '插入成功!'
                except:
                    rs[4] = '插入失败!'
                res = {}
                res['xcode'] = rs[0]
                res['name'] = rs[1]
                res['excode'] = rs[2]
                res['packetqty1'] = rs[3]
                res['info'] = rs[4]
                result.append(res)
            else:
                res = {}
                res['xcode'] = rs[0]
                res['name'] = rs[1]
                res['excode'] = rs[2]
                res['packetqty1'] = rs[3]
                res['info'] = rs[4]
                result.append(res)
        else:
            try:
                sqlstr = "insert into product_gl_packetqty_rules (xcode,excode,packetqty1) values('" + rs[
                    0] + "','" + excode + "','" + rs[3] + "')"
                confsql.runSql(sqlstr)
                rs[4] = '插入成功!'
            except:
                rs[4] = '插入失败!'
            res = {}
            res['xcode'] = rs[0]
            res['name'] = rs[1]
            res['excode'] = rs[2]
            res['packetqty1'] = rs[3]
            res['info'] = rs[4]
            result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 41
0
def deleteData_dhrulesYuzhi(request):
    '删除数据'
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"])
    if len(rs1) > 0:
        for rs in rs1:
            if rs[12] <> '':  #出错信息的保留
                res = {}
                res['mdcode'] = rs[0]
                res['mdname'] = rs[1]
                res['xcode'] = rs[2]
                res['name'] = rs[3]
                res['excode'] = rs[4]
                res['yqkey'] = rs[5]
                res['yqrule'] = rs[6]
                res['yqvalue'] = rs[7]
                res['startdate'] = rs[8]
                res['enddate'] = rs[9]
                res['remark'] = rs[10]
                res['adddate'] = rs[11]
                res['info'] = rs[12]
                result.append(res)
            else:  #无出错信息的执行删除
                try:
                    excode = rs[4]
                    if rs[4] == u'商品代码':
                        excode = 'sp'
                    if rs[4] == u'品牌小类代码':
                        excode = 'braxl'
                    if rs[4] == u'大类代码':
                        excode = 'prodl'
                    if rs[4] == u'中类代码':
                        excode = 'prozl'
                    if rs[4] == u'小类代码':
                        excode = 'proxl'
                    confsql.runSql("delete from dhrulesYuzhi where mdcode='" +
                                   rs[0] + "' and xcode='" + rs[2] +
                                   "' and excode='" + excode +
                                   "' and startdate='" + rs[8] +
                                   "' and enddate = '" + rs[9] + "'")
                    res = {}
                    res['mdcode'] = rs[0]
                    res['mdname'] = rs[1]
                    res['xcode'] = rs[2]
                    res['name'] = rs[3]
                    res['excode'] = rs[4]
                    res['yqkey'] = rs[5]
                    res['yqrule'] = rs[6]
                    res['yqvalue'] = rs[7]
                    res['startdate'] = rs[8]
                    res['enddate'] = rs[9]
                    res['remark'] = rs[10]
                    res['adddate'] = rs[11]
                    res['info'] = u'删除成功!'
                    result.append(res)
                except:
                    res['mdcode'] = rs[0]
                    res['mdname'] = rs[1]
                    res['xcode'] = rs[2]
                    res['name'] = rs[3]
                    res['excode'] = rs[4]
                    res['yqkey'] = rs[5]
                    res['yqrule'] = rs[6]
                    res['yqvalue'] = rs[7]
                    res['startdate'] = rs[8]
                    res['enddate'] = rs[9]
                    res['remark'] = rs[10]
                    res['adddate'] = rs[11]
                    res['info'] = u'删除失败!'
                    result.append(res)
    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 42
0
def delete_dhrulesYuzhi(request):
    '删除暂停订货范围规则'
    if request.method == 'POST':
        value = request.POST['value']
        rs1 = trim_csv(value, itemlenth=12)
        rs2, rs1 = verifyData(rs1, length=12, required=[5, 6, 7, 8, 9])

        '是否重复'
        temp = []
        for rs in rs1:
            excode = rs[4]
            if rs[4] == u'商品代码':
                excode = 'sp'
            if rs[4] == u'品牌小类代码':
                excode = 'braxl'
            if rs[4] == u'大类代码':
                excode = 'prodl'
            if rs[4] == u'中类代码':
                excode = 'prozl'
            if rs[4] == u'小类代码':
                excode = 'proxl'
            sqlstr = u"select * from dhrulesYuzhi where mdcode='" + rs[
                0] + "' and xcode = '" + rs[
                    2] + "' and excode='" + excode + "' and startdate='" + rs[
                        8] + "' and enddate = '" + rs[9] + "'"
            if confsql.checkExist(sqlstr) <> 1:  #检查mdcode,excode,yqkey数据库是否已存在
                rs.append(u'数据库不存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '门店代码商品代码 长度检查'
        temp = []
        for rs in rs1:
            if len(rs[0]) <> 5:  #门店代码 5位
                rs.append(u'门店代码长度必须为5位!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '代码说明 检查'
        temp = []
        for rs in rs1:
            if rs[4] <> u"商品代码" and rs[4] <> u"品牌小类代码" and rs[
                    4] <> u"大类代码" and rs[4] <> u"中类代码" and rs[4] <> u"小类代码":
                rs.append(u'代码说明不符要求!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '代码 检查'
        temp = []
        for rs in rs1:
            if rs[4] == u"商品代码" or rs[4] == u"品牌小类代码" or rs[4] == u"小类代码":
                if len(rs[2]) <> 8:  #商品代码或品牌小类代码 8位
                    rs.append(u'代码长度不符!')
                    temp.append(rs)
                    rs2.append(rs)
            if rs[4] == u"中类代码":
                if len(rs[2]) <> 5:
                    rs.append(u'代码长度不符!')
                    temp.append(rs)
                    rs2.append(rs)
            if rs[4] == u"大类代码":
                if len(rs[2]) <> 2:
                    rs.append(u'代码长度不符!')
                    temp.append(rs)
                    rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '规则说明只能填相对值'
        temp = []
        for rs in rs1:
            if rs[6] <> u'相对值':
                rs.append(u'规则说明只能填“相对值”!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '规则值为百分比格式且大于0'
        temp = []
        for rs in rs1:
            if type(eval(rs[7])) <> type(1.00) or eval(rs[7]) < 0:
                rs.append(u'规则值必须为正百分比格式!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '开始日期格式检查'
        temp = []
        for rs in rs1:
            m = re.match(r'^\w\w\w\w-\w\w-\w\w$', rs[8])
            if m == None:  #日期格式 yyyy-mm-dd
                rs.append(u'日期格式必须为yyyy-mm-dd!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '结束日期格式检查'
        temp = []
        for rs in rs1:
            m = re.match(r'^\w\w\w\w-\w\w-\w\w$', rs[9])
            if m == None:  #日期格式 yyyy-mm-dd
                rs.append(u'日期格式必须为yyyy-mm-dd!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        html = u"<table width='1200'><thead><tr><th>门店代码</th><th>门店名称</th><th>代码</th><th>代码名称</th><th>代码说明</th><th>规则对象</th><th>规则说明</th><th>规则值</th><th>开始日期</th><th>结束日期</th><th>备注</th><th>添加日期</th></tr></thead><tbody>"
        if len(rs2) > 0:
            for rs in rs2:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td>" + rs[5] + "</td>"
                html += "<td>" + rs[6] + "</td>"
                html += "<td>" + rs[7] + "</td>"
                html += "<td>" + rs[8] + "</td>"
                html += "<td>" + rs[9] + "</td>"
                html += "<td>" + rs[10] + "</td>"
                html += "<td>" + rs[11] + "</td>"
                html += "<td style='background-color:yellow'>" + rs[
                    12] + "</td>"
                html += "</tr>"
        if len(rs1) > 0:
            for rs in rs1:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td>" + rs[5] + "</td>"
                html += "<td>" + rs[6] + "</td>"
                html += "<td>" + rs[7] + "</td>"
                html += "<td>" + rs[8] + "</td>"
                html += "<td>" + rs[9] + "</td>"
                html += "<td>" + rs[10] + "</td>"
                html += "<td>" + rs[11] + "</td>"
                html += "<td></td>"
                html += "</tr>"
        html += "</tbody></table>"
        return HttpResponse(Context(html))
    else:
        t = get_template('mana1/delete_dhrulesYuzhi.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 43
0
def save_dhrulesYuzhi(request):
    rs1 = []
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"])

    for rs in rs1:
        excode = rs[4]
        if rs[4] == u'商品代码':
            excode = 'sp'
        if rs[4] == u'品牌小类代码':
            excode = 'braxl'
        if rs[4] == u'大类代码':
            excode = 'prodl'
        if rs[4] == u'中类代码':
            excode = 'prozl'
        if rs[4] == u'小类代码':
            excode = 'proxl'
        adddate = time.strftime("%Y-%m-%d", time.localtime())

        if rs[10] <> '':
            if rs[10] == u'数据库已存在!':
                try:
                    confsql.runSql(u"delete from dhrulesYuzhi where mdcode='" +
                                   rs[0] + "' and xcode='" + rs[2] +
                                   "' and excode='" + excode +
                                   "' and startdate='" + rs[7] +
                                   "' and enddate = '" + rs[8] + "'")
                    confsql.runSql(
                        u"insert into dhrulesYuzhi (mdcode,xcode,excode,yqkey,yqrule,yqvalue,startdate,enddate,remark,adddate) values('"
                        + rs[0] + "','" + rs[2] + "','" + excode + "','" +
                        rs[5] + "','相对值','" + rs[6] + "','" + rs[7] + "','" +
                        rs[8] + "','" + adddate + "')")
                    rs[10] = u'插入成功!'
                except:
                    rs[10] = u'插入失败!'
            res = {}
            res['mdcode'] = rs[0]
            res['mdname'] = rs[1]
            res['xcode'] = rs[2]
            res['name'] = rs[3]
            res['excode'] = rs[4]
            res['yqkey'] = rs[5]
            res['yqrule'] = u"相对值"
            res['yqvalue'] = rs[6]
            res['startdate'] = rs[7]
            res['enddate'] = rs[8]
            res['remark'] = rs[9]
            res['info'] = rs[10]
            result.append(res)
        else:  #无误的
            try:
                sqlstr = u"insert into dhrulesYuzhi (mdcode,xcode,excode,yqkey,yqrule,yqvalue,startdate,enddate,remark,adddate) values('" + rs[
                    0] + "','" + rs[2] + "','" + excode + "','" + rs[
                        5] + "','" + u"相对值" + "','" + rs[6] + "','" + rs[
                            7] + "','" + rs[8] + "','" + rs[
                                9] + "','" + adddate + "')"
                confsql.runSql(sqlstr)
                rs[10] = u'插入成功!'
            except:
                rs[10] = u'插入失败!'
            res = {}
            res['mdcode'] = rs[0]
            res['mdname'] = rs[1]
            res['xcode'] = rs[2]
            res['name'] = rs[3]
            res['excode'] = rs[4]
            res['yqkey'] = rs[5]
            res['yqrule'] = u"相对值"
            res['yqvalue'] = rs[6]
            res['startdate'] = rs[7]
            res['enddate'] = rs[8]
            res['remark'] = rs[9]
            res['info'] = rs[10]
            result.append(res)
    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 44
0
def deleteData_dhPauserules(request):
    '删除数据'
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"], itemlenth=0)
    if len(rs1) > 0:
        for rs in rs1:
            if rs[7] <> '':  #出错信息的保留
                res = {}
                res['mdcode'] = rs[0]
                res['mdname'] = rs[1]
                res['xcode'] = rs[2]
                res['name'] = rs[3]
                res['excode'] = rs[4]
                res['startdate'] = rs[5]
                res['enddate'] = rs[6]

                res['info'] = rs[7]
                result.append(res)
            else:
                try:
                    #sp, xl, zl, dl, null
                    res = {}
                    excode = rs[4]
                    if rs[4] == u'商品代码':
                        excode = 'sp'
                    if rs[4] == u'小类代码':
                        excode = 'xl'
                    if rs[4] == u'中类代码':
                        excode = 'zl'
                    if rs[4] == u'大类代码':
                        excode = 'dl'

                    confsql.runSql("delete from dhpauserules where mdcode='" +
                                   rs[0] + "' and xcode='" + rs[2] +
                                   "' and excode='" + excode +
                                   "' and startdate='" + rs[5] +
                                   "' and enddate = '" + rs[6] + "'")
                    res = {}
                    res['mdcode'] = rs[0]
                    res['mdname'] = rs[1]
                    res['xcode'] = rs[2]
                    res['name'] = rs[3]
                    res['excode'] = rs[4]
                    res['startdate'] = rs[5]
                    res['enddate'] = rs[6]
                    res['info'] = u'删除成功!'
                    result.append(res)
                except:
                    res['mdcode'] = rs[0]
                    res['mdname'] = rs[1]
                    res['xcode'] = rs[2]
                    res['name'] = rs[3]
                    res['excode'] = rs[4]
                    res['startdate'] = rs[5]
                    res['enddate'] = rs[6]
                    res['info'] = u'删除失败!'
                    result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 45
0
def save_product_gl_packetqty_rules(request):
    '保存商品配货单位规则'
    rs1=[]
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"])

    #sp, xl, zl, dl, null
    for rs in rs1:
        excode=rs[2]
        if rs[2]==u'商品代码':
            excode='sp'
        if rs[2]==u'小类代码':
            excode='xl'
        if rs[2]==u'中类代码':
            excode='zl'
        if rs[2]==u'大类代码':
            excode='dl'

        if rs[4]<>'':
            if rs[4]==u'数据库已存在!':
                try:
                    sqlstr="delete from product_gl_packetqty_rules where xcode='"+rs[0]+"' and excode='" + excode + "'"
                    confsql.runSql(sqlstr)
                    sqlstr="insert into product_gl_packetqty_rules (xcode,excode,packetqty1) values('"+rs[0]+"','"+excode+"','"+rs[3]+"')"
                    confsql.runSql(sqlstr)
                    rs[4]='插入成功!'
                except:
                    rs[4]='插入失败!'
                res={}
                res['xcode']=rs[0]
                res['name']=rs[1]
                res['excode']=rs[2]
                res['packetqty1']=rs[3]
                res['info']=rs[4]
                result.append(res)
            else:
                res={}
                res['xcode']=rs[0]
                res['name']=rs[1]
                res['excode']=rs[2]
                res['packetqty1']=rs[3]
                res['info']=rs[4]
                result.append(res)
        else:
            try:
                sqlstr="insert into product_gl_packetqty_rules (xcode,excode,packetqty1) values('"+rs[0]+"','"+excode+"','"+rs[3]+"')"
                confsql.runSql(sqlstr)
                rs[4]='插入成功!'
            except:
                rs[4]='插入失败!'
            res={}
            res['xcode']=rs[0]
            res['name']=rs[1]
            res['excode']=rs[2]
            res['packetqty1']=rs[3]
            res['info']=rs[4]
            result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 46
0
def save_dhrules(request):
    '保存订货量修改规则'
    rs1 = []
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"])

    for rs in rs1:
        excode = rs[4]
        if rs[4] == u'商品代码':
            excode = 'sp'
        if rs[4] == u'小类代码':
            excode = 'xl'
        if rs[4] == u'中类代码':
            excode = 'zl'
        if rs[4] == u'大类代码':
            excode = 'dl'

        yqkey = rs[5]
        if rs[5] == u'上阈值':
            yqkey = 'maxlimit'
        if rs[5] == u'下阈值':
            yqkey = 'minlimit'

        yqrule = rs[6]
        if rs[6] == u'绝对值':
            yqrule = 'jd'
        if rs[6] == u'相对值':
            yqrule = 'xd'

        if rs[8] <> '':
            if rs[8] == u'数据库已存在!':
                try:
                    #confsql.runSql("update dhrules set yqrule='"+yqrule+"',yqvalue='"+rs[7]+"' where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and yqkey='"+yqkey+"'")
                    confsql.runSql("delete from dhrules where mdcode='" +
                                   rs[0] + "' and xcode='" + rs[2] +
                                   "' and excode='" + excode +
                                   "' and yqkey='" + yqkey + "'")
                    confsql.runSql(
                        "insert into dhrules (mdcode,xcode,excode,yqkey,yqrule,yqvalue) values('"
                        + rs[0] + "','" + rs[2] + "','" + excode + "','" +
                        yqkey + "','" + yqrule + "','" + rs[7] + "')")
                    rs[8] = '插入成功!'
                except:
                    rs[8] = '插入失败!'
                res = {}
                res['mdcode'] = rs[0]
                res['mdname'] = rs[1]
                res['xcode'] = rs[2]
                res['name'] = rs[3]
                res['excode'] = rs[4]
                res['yqkey'] = rs[5]
                res['yqrule'] = rs[6]
                res['yqvalue'] = rs[7]
                res['info'] = rs[8]
                result.append(res)
            else:
                res = {}
                res['mdcode'] = rs[0]
                res['mdname'] = rs[1]
                res['xcode'] = rs[2]
                res['name'] = rs[3]
                res['excode'] = rs[4]
                res['yqkey'] = rs[5]
                res['yqrule'] = rs[6]
                res['yqvalue'] = rs[7]
                res['info'] = rs[8]
                result.append(res)
        else:  #无误的
            try:
                confsql.runSql(
                    "insert into dhrules (mdcode,xcode,excode,yqkey,yqrule,yqvalue) values('"
                    + rs[0] + "','" + rs[2] + "','" + excode + "','" + yqkey +
                    "','" + yqrule + "','" + rs[7] + "')")
                rs[8] = '插入成功!'
            except:
                rs[8] = '插入失败!'
            res = {}
            res['mdcode'] = rs[0]
            res['mdname'] = rs[1]
            res['xcode'] = rs[2]
            res['name'] = rs[3]
            res['excode'] = rs[4]
            res['yqkey'] = rs[5]
            res['yqrule'] = rs[6]
            res['yqvalue'] = rs[7]
            res['info'] = rs[8]
            result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 47
0
def save_dhrules(request):
    '保存订货量修改规则'
    rs1=[]
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"])

    for rs in rs1:
        excode=rs[4]
        if rs[4]==u'商品代码':
            excode='sp'
        if rs[4]==u'小类代码':
            excode='xl'
        if rs[4]==u'中类代码':
            excode='zl'
        if rs[4]==u'大类代码':
            excode='dl'
            
        yqkey = rs[5]
        if rs[5]==u'上阈值':
            yqkey='maxlimit'
        if rs[5]==u'下阈值':
            yqkey='minlimit'
            
        yqrule = rs[6]
        if rs[6]==u'绝对值':
            yqrule='jd'
        if rs[6]==u'相对值':
            yqrule='xd'
            
        

        if rs[8]<>'':
            if rs[8]==u'数据库已存在!':
                try:
                    #confsql.runSql("update dhrules set yqrule='"+yqrule+"',yqvalue='"+rs[7]+"' where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and yqkey='"+yqkey+"'")
                    confsql.runSql("delete from dhrules where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and yqkey='"+yqkey+"'")
                    confsql.runSql("insert into dhrules (mdcode,xcode,excode,yqkey,yqrule,yqvalue) values('"+rs[0]+"','"+rs[2]+"','"+excode+"','"+yqkey+"','"+yqrule+"','"+rs[7]+"')")
                    rs[8]='插入成功!'
                except:
                    rs[8]='插入失败!'
                res={}
                res['mdcode']=rs[0]
                res['mdname']=rs[1]
                res['xcode']=rs[2]
                res['name']=rs[3]
                res['excode']=rs[4]
                res['yqkey']=rs[5]
                res['yqrule']=rs[6]
                res['yqvalue']=rs[7]
                res['info']=rs[8]
                result.append(res)
            else:
                res={}
                res['mdcode']=rs[0]
                res['mdname']=rs[1]
                res['xcode']=rs[2]
                res['name']=rs[3]
                res['excode']=rs[4]
                res['yqkey']=rs[5]
                res['yqrule']=rs[6]
                res['yqvalue']=rs[7]
                res['info']=rs[8]
                result.append(res)
        else: #无误的
            try:
                confsql.runSql("insert into dhrules (mdcode,xcode,excode,yqkey,yqrule,yqvalue) values('"+rs[0]+"','"+rs[2]+"','"+excode+"','"+yqkey+"','"+yqrule+"','"+rs[7]+"')")
                rs[8]='插入成功!'
            except:
                rs[8]='插入失败!'
            res={}
            res['mdcode']=rs[0]
            res['mdname']=rs[1]
            res['xcode']=rs[2]
            res['name']=rs[3]
            res['excode']=rs[4]
            res['yqkey']=rs[5]
            res['yqrule']=rs[6]
            res['yqvalue']=rs[7]
            res['info']=rs[8]
            result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 48
0
def deleteData_maxminCuxiaori(request):
    '删除数据'
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"])
    if len(rs1)>0:
        for rs in rs1:
            if rs[10]<>'': #出错信息的保留
                res={}
                res['mdcode']=rs[0]
                res['mdname']=rs[1]
                res['xcode']=rs[2]
                res['name']=rs[3]
                res['excode']=rs[4]
                res['max_multiple']=rs[5]
                res['min_multiple']=rs[6]
                res['startdate']=rs[7]
                res['enddate']=rs[8]
                res['remark']=rs[9]
                res['info']=rs[10]
                result.append(res)
            else:
                try:
                    #sp, xl, zl, dl, null
                    excode=rs[4]
                    if rs[4]==u'商品代码':
                        excode='sp'
                    if rs[4]==u'品牌小类代码':
                        excode='braxl'
                    if rs[4]==u'大类代码':
                        excode='prodl'
                    if rs[4]==u'中类代码':
                        excode='prozl'
                    if rs[4]==u'小类代码':
                        excode='proxl'
                    confsql.runSql("delete from maxminCuxiaori where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and startdate='"+rs[7]+"' and enddate = '" + rs[8] + "'")
                    res={}
                    res['mdcode']=rs[0]
                    res['mdname']=rs[1]
                    res['xcode']=rs[2]
                    res['name']=rs[3]
                    res['excode']=rs[4]
                    res['max_multiple']=rs[5]
                    res['min_multiple']=rs[6]
                    res['startdate']=rs[7]
                    res['enddate']=rs[8]
                    res['remark']=rs[9]
                    res['info']=u'删除成功!'
                    result.append(res)
                except:
                    res['mdcode']=rs[0]
                    res['mdname']=rs[1]
                    res['xcode']=rs[2]
                    res['name']=rs[3]
                    res['excode']=rs[4]
                    res['max_multiple']=rs[5]
                    res['min_multiple']=rs[6]
                    res['startdate']=rs[7]
                    res['enddate']=rs[8]
                    res['remark']=rs[9]
                    res['info']=u'删除失败!'
                    result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 49
0
def cleanmc_verify(request): #审核处理清空内存建议值

    

    myjson = simplejson.loads(request.POST["myjson"])

    rs1=functions.trim_csv(myjson["table"],7)

    s=[] #存放门店名单

    for rs in rs1:

        if rs[0]=="1": #勾选的门店

            s.append(rs[1])

    html=""

    if len(s)>0:

        for rs in s:

            #清空数据库指定建议值及内存指定建议值

            result=confsql.runquery("select * from sugvalue where braid='"+str(rs)+"'")

            for rs in result:

                mc.delete(str(rs['braid'])+"__"+str(rs['proid'])+"__sugvalue") #先根据数据库清内存

                confsql.runquery("delete from sugvalue where braid='"+str(rs['braid'])+"'") #后清数据库

                confsql.runquery("delete from brainfo where 门店代码='"+str(rs['braid'])+"'") 

        result=confsql.runquery("select * from brainfo") #获取门店综合信息 供门店审核是否需要重写

        html="<tr><th>重算</th><th>门店代码</th><th>门店名称</th><th>品项数</th><th>库存数量</th><th>建议订货总量</th><th>建议订货总额</th></tr>"

        for rs in result:

            html+="<tr><td><input type='checkbox'></td><td>"+str(rs[0])+"</td><td>"+str(rs[1].encode("utf8"))+"</td><td>"+str(rs[2])+"</td><td>"+str(rs[3])+"</td><td>"+str(rs[4])+"</td><td>"+str(rs[5])+"</td></tr>"

        return HttpResponse(html)

    else:

        #全部重写

        result=confsql.runquery("select * from sugvalue")

        for rs in result:

            mc.delete(str(rs['braid'])+"__"+str(rs['proid'])+"__sugvalue")

        confsql.runquery("delete from sugvalue")

        confsql.runquery("delete from brainfo")

        result=confsql.runquery("select * from brainfo") #获取门店综合信息 供门店审核是否需要重写

        html="<tr><th>重算</th><th>门店代码</th><th>门店名称</th><th>品项数</th><th>库存数量</th><th>建议订货总量</th><th>建议订货总额</th></tr>"

        for rs in result:

            html+="<tr><td><input type='checkbox'></td><td>"+str(rs[0])+"</td><td>"+str(rs[1].encode("utf8"))+"</td><td>"+str(rs[2])+"</td><td>"+str(rs[3])+"</td><td>"+str(rs[4])+"</td><td>"+str(rs[5])+"</td></tr>"

        return HttpResponse(html)
Exemplo n.º 50
0
def import_dhrules(request):
    '订货量修改规则导入'
    if request.method=='POST':
        value=request.POST['value']
        rs1=trim_csv(value,itemlenth=8)
        rs2,rs1=verifyData(rs1,length=8,required=[5,6,7],dhrules=1)

        '重复项覆盖'
        temp=[]
        for rs in rs1:
            excode=rs[4]
            if rs[4]==u'商品代码':
                excode='sp'
            if rs[4]==u'小类代码':
                excode='xl'
            if rs[4]==u'中类代码':
                excode='zl'
            if rs[4]==u'大类代码':
                excode='dl'
                
            yqkey = rs[5]
            if rs[5]==u'上阈值':
                yqkey='maxlimit'
            if rs[5]==u'下阈值':
                yqkey='minlimit'
            
            
            
            sqlstr=u"select * from dhrules where mdcode='"+rs[0]+"' and xcode = '"+ rs[2] +"' and excode='"+excode+"' and yqkey='"+yqkey+"'"
            if confsql.checkExist(sqlstr)==1: #检查mdcode,excode,yqkey数据库是否已存在
                rs.append(u'数据库已存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)

        html=u"<table width='1000'><tr><th>门店代码</th><th>门店名称</th><th>代码</th><th>名称</th><th>代码说明</th><th>规则对象</th><th>规则说明</th><th>规则值</th></tr>"
        if len(rs2)>0:
            for rs in rs2:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td>" + rs[5] + "</td>"
                html+="<td>" + rs[6] + "</td>"
                html+="<td>" + rs[7] + "</td>"
                html+="<td style='background-color:yellow'>" + rs[8] + "</td>"
                html+="</tr>"
        if len(rs1)>0:
            for rs in rs1:
                html+="<tr>"
                html+="<td>" + rs[0] + "</td>"
                html+="<td>" + rs[1] + "</td>"
                html+="<td>" + rs[2] + "</td>"
                html+="<td>" + rs[3] + "</td>"
                html+="<td>" + rs[4] + "</td>"
                html+="<td>" + rs[5] + "</td>"
                html+="<td>" + rs[6] + "</td>"
                html+="<td>" + rs[7] + "</td>"
                html+="<td></td>"
                html+="</tr>"
        html+="</table>"
        return HttpResponse(Context(html))
    else:
        t=get_template('mana1/import_dhrules.html')
        html=t.render(Context())
        return HttpResponse(html)
Exemplo n.º 51
0
def deleteData_maxminCuxiaori(request):
    '删除数据'
    result = []
    myjson = simplejson.loads(request.POST["myjson"])
    rs1 = trim_csv(myjson["table"])
    if len(rs1) > 0:
        for rs in rs1:
            if rs[10] <> '':  #出错信息的保留
                res = {}
                res['mdcode'] = rs[0]
                res['mdname'] = rs[1]
                res['xcode'] = rs[2]
                res['name'] = rs[3]
                res['excode'] = rs[4]
                res['max_multiple'] = rs[5]
                res['min_multiple'] = rs[6]
                res['startdate'] = rs[7]
                res['enddate'] = rs[8]
                res['remark'] = rs[9]
                res['info'] = rs[10]
                result.append(res)
            else:
                try:
                    #sp, xl, zl, dl, null
                    excode = rs[4]
                    if rs[4] == u'商品代码':
                        excode = 'sp'
                    if rs[4] == u'品牌小类代码':
                        excode = 'braxl'
                    if rs[4] == u'大类代码':
                        excode = 'prodl'
                    if rs[4] == u'中类代码':
                        excode = 'prozl'
                    if rs[4] == u'小类代码':
                        excode = 'proxl'
                    confsql.runSql(
                        "delete from maxminCuxiaori where mdcode='" + rs[0] +
                        "' and xcode='" + rs[2] + "' and excode='" + excode +
                        "' and startdate='" + rs[7] + "' and enddate = '" +
                        rs[8] + "'")
                    res = {}
                    res['mdcode'] = rs[0]
                    res['mdname'] = rs[1]
                    res['xcode'] = rs[2]
                    res['name'] = rs[3]
                    res['excode'] = rs[4]
                    res['max_multiple'] = rs[5]
                    res['min_multiple'] = rs[6]
                    res['startdate'] = rs[7]
                    res['enddate'] = rs[8]
                    res['remark'] = rs[9]
                    res['info'] = u'删除成功!'
                    result.append(res)
                except:
                    res['mdcode'] = rs[0]
                    res['mdname'] = rs[1]
                    res['xcode'] = rs[2]
                    res['name'] = rs[3]
                    res['excode'] = rs[4]
                    res['max_multiple'] = rs[5]
                    res['min_multiple'] = rs[6]
                    res['startdate'] = rs[7]
                    res['enddate'] = rs[8]
                    res['remark'] = rs[9]
                    res['info'] = u'删除失败!'
                    result.append(res)

    jsonres = simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 52
0
def deleteData_dhrules(request):
    '删除数据'
    result=[]
    myjson=simplejson.loads(request.POST["myjson"])
    rs1=trim_csv(myjson["table"],itemlenth=0)
    if len(rs1)>0:
        for rs in rs1:
            if rs[8]<>'': #出错信息的保留
                res={}
                res['mdcode']=rs[0]
                res['mdname']=rs[1]
                res['xcode']=rs[2]
                res['name']=rs[3]
                res['excode']=rs[4]
                res['yqkey']=rs[5]
                res['yqrule']=rs[6]
                res['yqvalue']=rs[7]
                res['info']=rs[8]
                result.append(res)
            else:
                try:
                    #sp, xl, zl, dl, null
                    res={}
                    excode=rs[4]
                    if rs[4]==u'商品代码':
                        excode='sp'
                    if rs[4]==u'小类代码':
                        excode='xl'
                    if rs[4]==u'中类代码':
                        excode='zl'
                    if rs[4]==u'大类代码':
                        excode='dl'
                        
                    yqkey = rs[5]
                    if rs[5]==u'上阈值':
                        yqkey='maxlimit'
                    if rs[5]==u'下阈值':
                        yqkey='minlimit'
                        
                        
                        
                    sqlstr=u"delete from dhrules where mdcode='"+rs[0]+"' and xcode ='"+rs[2] +"' and excode='"+excode+"' and yqkey='"+yqkey+"'"
                    #log(sqlstr)
                    confsql.runSql(sqlstr)
                    res={}
                    res['mdcode']=rs[0]
                    res['mdname']=rs[1]
                    res['xcode']=rs[2]
                    res['name']=rs[3]
                    res['excode']=rs[4]
                    res['yqkey']=rs[5]
                    res['yqrule']=rs[6]
                    res['yqvalue']=rs[7]
                    res['info']=u'删除成功!'
                    result.append(res)
                except:
                    res={}
                    res['mdcode']=rs[0]
                    res['mdname']=rs[1]
                    res['xcode']=rs[2]
                    res['name']=rs[3]
                    res['excode']=rs[4]
                    res['yqkey']=rs[5]
                    res['yqrule']=rs[6]
                    res['yqvalue']=rs[7]
                    res['info']=u'删除失败!'
                    result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)
Exemplo n.º 53
0
def delete_maxminCuxiaori(request):
    '删除促销日上下限规则'
    if request.method == 'POST':
        value = request.POST['value']
        rs1 = trim_csv(value, itemlenth=10)
        rs2, rs1 = verifyData(rs1, length=10, required=[0, 2, 4, 5, 6, 7, 8])

        '重复项覆盖'
        temp = []
        for rs in rs1:
            excode = rs[4]
            if rs[4] == u'商品代码':
                excode = 'sp'
            if rs[4] == u'品牌小类代码':
                excode = 'braxl'
            if rs[4] == u'大类代码':
                excode = 'prodl'
            if rs[4] == u'中类代码':
                excode = 'prozl'
            if rs[4] == u'小类代码':
                excode = 'proxl'
            sqlstr = u"select * from maxminCuxiaori where mdcode='" + rs[
                0] + "' and xcode = '" + rs[
                    2] + "' and excode='" + excode + "' and startdate='" + rs[
                        7] + "' and enddate = '" + rs[8] + "'"
            if confsql.checkExist(sqlstr) <> 1:  #检查mdcode,excode,yqkey数据库是否已存在
                rs.append(u'数据库中不存在!')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '门店代码商品代码 长度检查'
        temp = []
        for rs in rs1:
            if len(rs[0]) <> 5:  #门店代码 5位
                rs.append(u'门店代码长度必须为5位')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '代码说明 检查'
        temp = []
        for rs in rs1:
            if rs[4] <> u"商品代码" and rs[4] <> u"品牌小类代码" and rs[
                    4] <> u"大类代码" and rs[4] <> u"中类代码" and rs[4] <> u"小类代码":
                rs.append(u'代码说明不符要求')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '代码 检查 未考虑大,中类,小类'
        """temp=[]
        for rs in rs1:
            if len(rs[2])<>8: #商品代码或品牌小类代码 8位
                rs.append(u'商品代码或品牌小类代码长度必须为8位')
                temp.append(rs)
                rs2.append(rs)
        if len(temp)>0:
            for rs in temp:
                rs1.remove(rs)"""

        '上下限倍数必须是数值'
        temp = []
        for rs in rs1:
            if type(eval(rs[5])) <> type(1.00) and type(eval(
                    rs[5])) <> type(1):
                rs.append(u'上限倍数必须是数值')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        temp = []
        for rs in rs1:
            if type(eval(rs[6])) <> type(1.00) and type(eval(
                    rs[6])) <> type(1):
                rs.append(u'下限倍数必须是数值')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '开始日期格式检查'
        temp = []
        for rs in rs1:
            m = re.match(r'^\w\w\w\w-\w\w-\w\w$', rs[7])
            if m == None:  #日期格式 yyyy-mm-dd
                rs.append(u'日期格式必须为yyyy-mm-dd')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        '结束日期格式检查'
        temp = []
        for rs in rs1:
            m = re.match(r'^\w\w\w\w-\w\w-\w\w$', rs[8])
            if m == None:  #日期格式 yyyy-mm-dd
                rs.append(u'日期格式必须为yyyy-mm-dd')
                temp.append(rs)
                rs2.append(rs)
        if len(temp) > 0:
            for rs in temp:
                rs1.remove(rs)

        html = u"<table width='1200'><tr><th>门店代码</th><th>门店名称</th><th>代码</th><th>代码名称</th><th>代码说明</th><th>上限倍数</th><th>下限倍数</th><th>规则开始时间</th><th>规则结束时间</th><th>备注</th></tr>"
        if len(rs2) > 0:
            for rs in rs2:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td>" + rs[5] + "</td>"
                html += "<td>" + rs[6] + "</td>"
                html += "<td>" + rs[7] + "</td>"
                html += "<td>" + rs[8] + "</td>"
                html += "<td>" + rs[9] + "</td>"
                html += "<td style='background-color:yellow'>" + rs[
                    10] + "</td>"
                html += "</tr>"
        if len(rs1) > 0:
            for rs in rs1:
                html += "<tr>"
                html += "<td>" + rs[0] + "</td>"
                html += "<td>" + rs[1] + "</td>"
                html += "<td>" + rs[2] + "</td>"
                html += "<td>" + rs[3] + "</td>"
                html += "<td>" + rs[4] + "</td>"
                html += "<td>" + rs[5] + "</td>"
                html += "<td>" + rs[6] + "</td>"
                html += "<td>" + rs[7] + "</td>"
                html += "<td>" + rs[8] + "</td>"
                html += "<td>" + rs[9] + "</td>"
                html += "<td></td>"
                html += "</tr>"
        html += "</table>"
        return HttpResponse(Context(html))
    else:
        t = get_template('mana1/delete_maxminCuxiaori.html')
        html = t.render(Context())
        return HttpResponse(html)
Exemplo n.º 54
0
def rewrite(request):

    if request.method == 'POST':

        #检查格式是否正确,并返回检查结果

        rs1 = functions.trim_csv(request.POST['value'], itemlenth=7)

        rs2 = []  #存放最终结果

        rs_temp = []  #存放临时数据

        #不能有空

        for rs in rs1:

            if rs[0] == "" or rs[1] == "" or rs[2] == "" or rs[3] == "" or rs[
                    4] == "" or rs[5] == "" or rs[6] == "":

                rs_temp.append(rs)

                rs.append("不能有为空的项")

                rs2.append(rs)

        if len(rs_temp) > 0:

            for rs in rs_temp:

                rs1.remove(rs)

        rs_temp = []  #存放临时数据

        #门店代码为五位码

        for rs in rs1:

            if len(rs[1]) <> 5:

                rs_temp.append(rs)

                rs.append("门店代码应为五位码")

                rs2.append(rs)

        if len(rs_temp) > 0:

            for rs in rs_temp:

                rs1.remove(rs)

        #没有问题的数据

        for rs in rs1:

            rs.append("")

            rs2.append(rs)

        s = "<table width='800'><tr><th>审核</th><th>门店代码</th><th>门店名称</th><th>品项数</th><th>库存数量</th><th>建议订货总量</th><th>建议订货总额</th><th>说明</th></tr>"

        for rs in rs2:

            if rs[0] == '0':

                s += "<tr><td><input type='checkbox'></td>"

            else:

                s += "<tr><td><input type='checkbox' checked='checked'></td>"

            s += "<td>" + rs[1] + "</td><td>" + rs[2] + "</td><td>" + rs[
                3] + "</td><td>" + rs[4] + "</td><td>" + rs[
                    5] + "</td><td>" + rs[6] + "</td>"

            if rs[7] == "":

                s += "<td>" + rs[7] + "</td></tr>"

            else:

                s += "<td style='background-color:yellow'>" + rs[
                    7] + "</td></tr>"

        s += "</table>"

        return HttpResponse(s)

    else:

        t = get_template("mana1/rewrite.html")

        #result=[{"门店代码":"00001","品项数":3500,"库存数量":23340,"库存金额":4337979.32,"建议订货总量":2344,"建议订货总额":34345434},{"门店代码":"00002","品项数":3500,"库存数量":23340,"库存金额":4337979.32,"建议订货总量":2344,"建议订货总额":34345434},{"门店代码":"00003","品项数":3500,"库存数量":23340,"库存金额":4337979.32,"建议订货总量":2344,"建议订货总额":34345434}]

        result = confsql.runquery(
            "select 门店代码, 门店名称, 品项数, 库存数量, 建议订货总量, 建议订货总额 from brainfo"
        )  #获取门店综合信息 供门店审核是否需要重写

        html = t.render(Context({'result': result}))

        return HttpResponse(html)
Exemplo n.º 55
0
def save_dhPauserules(request):
    rs1=[]
    result=[]
    myjson=simplejson.loads(request.POST["myjson"].encode('utf8'))
    rs1=trim_csv(myjson["table"])
    
    for rs in rs1:
        excode=rs[4]
        if rs[4]==u'商品代码':
            excode='sp'
        if rs[4]==u'小类代码':
            excode='xl'
        if rs[4]==u'中类代码':
            excode='zl'
        if rs[4]==u'大类代码':
            excode='dl'
            
        adddate = time.strftime("%Y-%m-%d", time.localtime())

        if rs[7]<>'':
            if rs[7]==u'数据库已存在!':
                try:
                    
                    #confsql.runSql("update dhrules set yqrule='"+yqrule+"',yqvalue='"+rs[7]+"' where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and yqkey='"+yqkey+"'")
                    #log("delete from dhpauserules where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and startdate='"+rs[5]+"' and enddate = '" + rs[6] + "'")
                    confsql.runSql("delete from dhpauserules where mdcode='"+rs[0]+"' and xcode='" +rs[2]+ "' and excode='"+excode+"' and startdate='"+rs[5]+"' and enddate = '" + rs[6] + "'")
                    
                    confsql.runSql("insert into dhpauserules (mdcode,xcode,excode,startdate, enddate, adddate) values('"+rs[0]+"','"+rs[2]+"','"+excode+"','"+rs[5]+"','"+rs[6]+"','"+adddate+"')")
                    rs[7]='插入成功!'
                except:
                    rs[7]='插入失败!'
                res={}
                res['mdcode']=rs[0]
                res['mdname']=rs[1]
                res['xcode']=rs[2]
                res['name']=rs[3]
                res['excode']=rs[4]
                res['startdate']=rs[5]
                res['enddate']=rs[6]                
                res['info']=rs[7]
                result.append(res)
            else:
                res={}
                res['mdcode']=rs[0]
                res['mdname']=rs[1]
                res['xcode']=rs[2]
                res['name']=rs[3]
                res['excode']=rs[4]
                res['startdate']=rs[5]
                res['enddate']=rs[6]                
                res['info']=rs[7]
                result.append(res)
        else: #无误的
            try:
                confsql.runSql("insert into dhpauserules (mdcode,xcode,excode,startdate, enddate, adddate) values('"+rs[0]+"','"+rs[2]+"','"+excode+"','"+rs[5]+"','"+rs[6]+"','"+adddate+"')")
                rs[7]='插入成功!'
            except:
                rs[7]='插入失败!'
            res={}
            res['mdcode']=rs[0]
            res['mdname']=rs[1]
            res['xcode']=rs[2]
            res['name']=rs[3]
            res['excode']=rs[4]
            res['startdate']=rs[5]
            res['enddate']=rs[6]                
            res['info']=rs[7]
            result.append(res)

    jsonres=simplejson.dumps(result)
    return HttpResponse(jsonres)