迭代查询

迭代查询,查询最高级别的单位,好处是看起来非常简单清晰
def setTopDepartSpinfo(spinfo,item,value,depart,comp):
# spinfo={"depart":,"comp":,"operator":,"upload":,"width":,"height":,"thickness":,"spformat":,"spcode":,"spname":,"barcode":,"_id"}
topDepart = getTopDepart(depart,comp)
if topDepart:
topDepartSpinfo = getSpinfo(item,value,topDepart,comp)
if not topDepartSpinfo:
spinfo = copyspinfo(spinfo,topDepart,comp)
# spinfo ={'depart': , 'spname': u'', 'comp':, 'barcode': u'', 'upload':,'thickness': , 'height': , 'spcode': u'', 'width': , 'operator': '', 'spformat': u'', '_id': ''}
return spinfo
return False

ajax跨域请求
from flask.ext.cors import CORS
CORS(app)
端口5002向5003发送一个请求,在5003页面加上这条语句,然后5003就能顺利接收到请求了,而且直接返回需要返回的数据就能接收到

for循环
result = [procimg(spcode, depart, comp, side, {"width": width, "height": height, "thickness": thickness}) for side in sides]

传输习惯,一般传输为json格式
return json.dumps()
 r.json() ??? json.loads(r)

一些参数作为配置写在开头
sourcePath = "E:\HGpicture"
targetPath = "D:\img"


def getTargetPath(spcode,pos,depart,comp,side,picFormat):
pathSave = "\{comp}\{depart}\{pos}\{side}".format(comp=comp, depart=depart, pos=pos, side=side)

图片处理最好不要夹杂有商品信息的处理直接调用商品信息就行了







原文地址:https://www.cnblogs.com/wuqingzangyue/p/5770061.html