|
@@ -743,13 +743,13 @@ async def applyFL(client, id, data):
|
|
|
sl = float(post['数量'])
|
|
sl = float(post['数量'])
|
|
|
if rgfs < 0.0001 and clfs < 0.0001 and jxfs < 0.0001:
|
|
if rgfs < 0.0001 and clfs < 0.0001 and jxfs < 0.0001:
|
|
|
continue
|
|
continue
|
|
|
- danxiang = False
|
|
|
|
|
|
|
+ ##danxiang = False
|
|
|
|
|
|
|
|
- for child in post['__children']:
|
|
|
|
|
|
|
+ for child in post['__children']:##一条定额
|
|
|
bm = child['清单编码']
|
|
bm = child['清单编码']
|
|
|
if bm.startswith("D"):
|
|
if bm.startswith("D"):
|
|
|
- danxiang = True
|
|
|
|
|
- break
|
|
|
|
|
|
|
+ ##danxiang = True
|
|
|
|
|
+ continue
|
|
|
rgf = float(child['人工费'])
|
|
rgf = float(child['人工费'])
|
|
|
clf = float(child['材料费'])
|
|
clf = float(child['材料费'])
|
|
|
jxf = float(child['机械费'])
|
|
jxf = float(child['机械费'])
|
|
@@ -767,32 +767,237 @@ async def applyFL(client, id, data):
|
|
|
child['利润'] = (rgf) * lr / float(100)
|
|
child['利润'] = (rgf) * lr / float(100)
|
|
|
child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
|
|
child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
|
|
|
child['合价'] = sl * sl_ * child['综合单价']
|
|
child['合价'] = sl * sl_ * child['综合单价']
|
|
|
- if not danxiang:
|
|
|
|
|
|
|
+ if True:
|
|
|
|
|
+ post['管理费'] = 0
|
|
|
|
|
+ post['利润'] = 0
|
|
|
|
|
+ for entry in post['__children']:
|
|
|
|
|
+ post['管理费'] = post['管理费'] + float(entry['管理费']) * float(entry['数量'])
|
|
|
|
|
+ post['利润'] = post['利润'] + float(entry['利润']) * float(entry['数量'])
|
|
|
|
|
+ post['管理费'] = str(post['管理费'])
|
|
|
|
|
+ post['利润'] = str(post['利润'])
|
|
|
|
|
+ post['综合单价'] = str(float(post['人工费']) + float(post['材料费']) + float(post['机械费']) + float(post['管理费']) + float(post['利润']))
|
|
|
|
|
+ post['合价'] = str(float(post['综合单价']) * float(post['数量']))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ await collection.replace_one({'_id': post['_id']}, post )
|
|
|
|
|
+ collection = db['Djcs']
|
|
|
|
|
+
|
|
|
|
|
+ for dxgc in xm["children"]:
|
|
|
|
|
+ for dwgc in dxgc["children"]:
|
|
|
|
|
+ bh = dwgc['key']
|
|
|
|
|
+ glf = float(dwgc['管理费(%)'])
|
|
|
|
|
+ lr = float(dwgc['利润(%)'])
|
|
|
|
|
+ bz = dwgc['备注']
|
|
|
|
|
+ ##print(bh+glf+lr+bz)
|
|
|
|
|
+ async for post in collection.find({'biao_id': id, "Dwgcbh": bh}):
|
|
|
|
|
+ rgfs = float(post['人工费'])
|
|
|
|
|
+ clfs = float(post['材料费'])
|
|
|
|
|
+ jxfs = float(post['机械费'])
|
|
|
|
|
+ sl = float(post['数量'])
|
|
|
|
|
+ if rgfs < 0.0001 and clfs < 0.0001 and jxfs < 0.0001:
|
|
|
|
|
+ continue
|
|
|
|
|
+ ##danxiang = False##一般有单项定额的,清单就一条定额,就是这个单项定额
|
|
|
|
|
+
|
|
|
|
|
+ for child in post['__children']:
|
|
|
|
|
+ bm = child['清单编码']
|
|
|
|
|
+ if bm.startswith("D"):
|
|
|
|
|
+ ##danxiang = True
|
|
|
|
|
+ continue
|
|
|
|
|
+ rgf = float(child['人工费'])
|
|
|
|
|
+ clf = float(child['材料费'])
|
|
|
|
|
+ jxf = float(child['机械费'])
|
|
|
|
|
+ zhdj = float(child['综合单价'])
|
|
|
|
|
+ sl_ = float(child['数量'])
|
|
|
if len(bz) == 0:
|
|
if len(bz) == 0:
|
|
|
- ##常规计算
|
|
|
|
|
- post['管理费'] = (rgfs + jxfs) * glf / float(100)
|
|
|
|
|
- post['利润'] = (rgfs + jxfs) * lr / float(100)
|
|
|
|
|
- post['综合单价'] = rgfs + clfs + jxfs + post['管理费'] + post['利润']
|
|
|
|
|
- post['合价'] = sl * post['综合单价']
|
|
|
|
|
- if post['清单编码'] == "010101001001":
|
|
|
|
|
- print(post['人工费'])
|
|
|
|
|
- print(post['材料费'])
|
|
|
|
|
- print(post['机械费'])
|
|
|
|
|
- print(post['管理费'])
|
|
|
|
|
- print(post['利润'])
|
|
|
|
|
- print(post['综合单价'])
|
|
|
|
|
- print(sl)
|
|
|
|
|
- print(post['合价'])
|
|
|
|
|
|
|
+ ##常规计算
|
|
|
|
|
+ child['管理费'] = (rgf + jxf) * glf / float(100)
|
|
|
|
|
+ child['利润'] = (rgf + jxf) * lr / float(100)
|
|
|
|
|
+ child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
|
|
|
|
|
+ child['合价'] = sl * sl_ * child['综合单价']
|
|
|
|
|
|
|
|
else:
|
|
else:
|
|
|
- post['管理费'] = (rgfs) * glf / float(100)
|
|
|
|
|
- post['利润'] = (rgfs) * lr / float(100)
|
|
|
|
|
- post['综合单价'] = rgfs + clfs + jxfs + post['管理费'] + post['利润']
|
|
|
|
|
- post['合价'] = sl * post['综合单价']
|
|
|
|
|
-
|
|
|
|
|
|
|
+ child['管理费'] = (rgf) * glf / float(100)
|
|
|
|
|
+ child['利润'] = (rgf) * lr / float(100)
|
|
|
|
|
+ child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
|
|
|
|
|
+ child['合价'] = sl * sl_ * child['综合单价']
|
|
|
|
|
+ if True:
|
|
|
|
|
+ post['管理费'] = 0
|
|
|
|
|
+ post['利润'] = 0
|
|
|
|
|
+ for entry in post['__children']:
|
|
|
|
|
+ post['管理费'] = post['管理费'] + float(entry['管理费']) * float(entry['数量'])
|
|
|
|
|
+ post['利润'] = post['利润'] + float(entry['利润']) * float(entry['数量'])
|
|
|
|
|
+ post['管理费'] = str(post['管理费'])
|
|
|
|
|
+ post['利润'] = str(post['利润'])
|
|
|
|
|
+ post['综合单价'] = str(float(post['人工费']) + float(post['材料费']) + float(post['机械费']) + float(post['管理费']) + float(post['利润']))
|
|
|
|
|
+ post['合价'] = str(float(post['综合单价']) * float(post['数量']))
|
|
|
|
|
+
|
|
|
|
|
|
|
|
await collection.replace_one({'_id': post['_id']}, post )
|
|
await collection.replace_one({'_id': post['_id']}, post )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {"result": "ok"}
|
|
return {"result": "ok"}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+async def tiaojia(client, biao_id, bh, bm, jiage, glf, lr, bz):
|
|
|
|
|
+ db = client["baojia"]
|
|
|
|
|
+ collection = db["qdxm"]
|
|
|
|
|
+ async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
|
|
|
|
|
+ children = post["__children"]
|
|
|
|
|
+ qdsl = post['数量']
|
|
|
|
|
+ hit = False
|
|
|
|
|
+ for entry in children:###对一条定额,调价
|
|
|
|
|
+ hitde = False
|
|
|
|
|
+ dercj = entry["dercj"]
|
|
|
|
|
+ dergf = 0
|
|
|
|
|
+ declf = 0
|
|
|
|
|
+ dejxf = 0
|
|
|
|
|
+ for i in range(1, len(dercj)):
|
|
|
|
|
+ rcj = dercj[i]
|
|
|
|
|
+ if rcj[1] == bm:
|
|
|
|
|
+ hit = True
|
|
|
|
|
+ hitde = True
|
|
|
|
|
+ rcj[5] = jiage
|
|
|
|
|
+ hanliang = rcj[10]
|
|
|
|
|
+ rcj[11] = str(float(jiage) * float(hanliang))
|
|
|
|
|
+ if int(rcj[8]) == 1:
|
|
|
|
|
+ dergf = dergf + float(rcj[11])
|
|
|
|
|
+ elif int(rcj[8]) == 2:
|
|
|
|
|
+ declf = declf + float(rcj[11])
|
|
|
|
|
+ elif int(rcj[8]) == 3:
|
|
|
|
|
+ dejxf = dejxf + float(rcj[11])
|
|
|
|
|
+ if hitde:
|
|
|
|
|
+ entry['人工费'] = str(dergf)
|
|
|
|
|
+ entry['辅材费'] = str(declf)
|
|
|
|
|
+ entry['材料费'] = str(declf)
|
|
|
|
|
+ entry['机械费'] = str(dejxf)
|
|
|
|
|
+ if bm.startswith("D"):
|
|
|
|
|
+ entry['管理费'] = '0'
|
|
|
|
|
+ entry['利润'] = '0'
|
|
|
|
|
+ elif bz == 0:
|
|
|
|
|
+ entry['管理费'] = str((dergf + dejxf) * float(glf) / float(100))
|
|
|
|
|
+ entry['利润'] = str((dergf + dejxf) * float(lr) / float(100))
|
|
|
|
|
+ else:
|
|
|
|
|
+ entry['管理费'] = str((dergf) * float(glf) / float(100))
|
|
|
|
|
+ entry['利润'] = str((dergf) * float(lr) / float(100))
|
|
|
|
|
+ entry['综合单价'] = str(float(entry['人工费']) + float(entry['材料费']) + float(entry['机械费']) + float(entry['管理费']) + float(entry['利润']))
|
|
|
|
|
+ entry['合价'] = str(float(entry['综合单价']) * float(entry['数量']) * float(qdsl))
|
|
|
|
|
+ if hit:
|
|
|
|
|
+ ##调整清单
|
|
|
|
|
+ qdrcj = post['rcj']
|
|
|
|
|
+ qdrgf = 0
|
|
|
|
|
+ qdclf = 0
|
|
|
|
|
+ qdjxf = 0
|
|
|
|
|
+ for i in range(1, len(qdrcj)):
|
|
|
|
|
+ entry = qdrcj[i]
|
|
|
|
|
+ if entry[1] == bm:
|
|
|
|
|
+ entry[5] = jiage
|
|
|
|
|
+ hanliang = entry[10]
|
|
|
|
|
+ entry[11] = str(float(jiage) * float(hanliang))
|
|
|
|
|
+ if int(entry[8]) == 1:
|
|
|
|
|
+ qdrgf = qdrgf + float(entry[11])
|
|
|
|
|
+ elif int(entry[8]) == 2:
|
|
|
|
|
+ qdclf = qdclf + float(entry[11])
|
|
|
|
|
+ elif int(entry[8]) == 3:
|
|
|
|
|
+ qdjxf = qdjxf + float(entry[11])
|
|
|
|
|
+ post['人工费'] = str(qdrgf)
|
|
|
|
|
+ post['辅材费'] = str(qdclf)
|
|
|
|
|
+ post['材料费'] = str(qdclf)
|
|
|
|
|
+ post['机械费'] = str(qdjxf)
|
|
|
|
|
+ post['管理费'] = 0
|
|
|
|
|
+ post['利润'] = 0
|
|
|
|
|
+ for entry in children:
|
|
|
|
|
+ post['管理费'] = post['管理费'] + float(entry['管理费']) * float(entry['数量'])
|
|
|
|
|
+ post['利润'] = post['利润'] + float(entry['利润']) * float(entry['数量'])
|
|
|
|
|
+ post['管理费'] = str(post['管理费'])
|
|
|
|
|
+ post['利润'] = str(post['利润'])
|
|
|
|
|
+
|
|
|
|
|
+ post['综合单价'] = str(float(post['人工费']) + float(post['材料费']) + float(post['机械费']) + float(post['管理费']) + float(post['利润']))
|
|
|
|
|
+ post['合价'] = str(float(post['综合单价']) * float(qdsl))
|
|
|
|
|
+ await collection.replace_one({'_id': post['_id']}, post )
|
|
|
|
|
+ collection = db["Djcs"]
|
|
|
|
|
+ async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
|
|
|
|
|
+ children = post["__children"]
|
|
|
|
|
+ qdsl = post['数量']
|
|
|
|
|
+ hit = False
|
|
|
|
|
+ for entry in children:###对一条定额,调价
|
|
|
|
|
+ hitde = False
|
|
|
|
|
+ dercj = entry["dercj"]
|
|
|
|
|
+ dergf = 0
|
|
|
|
|
+ declf = 0
|
|
|
|
|
+ dejxf = 0
|
|
|
|
|
+ for i in range(1, len(dercj)):
|
|
|
|
|
+ rcj = dercj[i]
|
|
|
|
|
+ if rcj[1] == bm:
|
|
|
|
|
+ hit = True
|
|
|
|
|
+ hitde = True
|
|
|
|
|
+ rcj[5] = jiage
|
|
|
|
|
+ hanliang = rcj[10]
|
|
|
|
|
+ rcj[11] = str(float(jiage) * float(hanliang))
|
|
|
|
|
+ if int(rcj[8]) == 1:
|
|
|
|
|
+ dergf = dergf + float(rcj[11])
|
|
|
|
|
+ elif int(rcj[8]) == 2:
|
|
|
|
|
+ declf = declf + float(rcj[11])
|
|
|
|
|
+ elif int(rcj[8]) == 3:
|
|
|
|
|
+ dejxf = dejxf + float(rcj[11])
|
|
|
|
|
+ if hitde:
|
|
|
|
|
+ entry['人工费'] = str(dergf)
|
|
|
|
|
+ entry['辅材费'] = str(declf)
|
|
|
|
|
+ entry['材料费'] = str(declf)
|
|
|
|
|
+ entry['机械费'] = str(dejxf)
|
|
|
|
|
+ if bm.startswith("D"):
|
|
|
|
|
+ entry['管理费'] = '0'
|
|
|
|
|
+ entry['利润'] = '0'
|
|
|
|
|
+ elif bz == 0:
|
|
|
|
|
+ entry['管理费'] = str((dergf + dejxf) * float(glf) / float(100))
|
|
|
|
|
+ entry['利润'] = str((dergf + dejxf) * float(lr) / float(100))
|
|
|
|
|
+ else:
|
|
|
|
|
+ entry['管理费'] = str((dergf) * float(glf) / float(100))
|
|
|
|
|
+ entry['利润'] = str((dergf) * float(lr) / float(100))
|
|
|
|
|
+ entry['综合单价'] = str(float(entry['人工费']) + float(entry['材料费']) + float(entry['机械费']) + float(entry['管理费']) + float(entry['利润']))
|
|
|
|
|
+ entry['合价'] = str(float(entry['综合单价']) * float(entry['数量']) * float(qdsl))
|
|
|
|
|
+ if hit:
|
|
|
|
|
+ ##调整清单
|
|
|
|
|
+ qdrcj = post['rcj']
|
|
|
|
|
+ qdrgf = 0
|
|
|
|
|
+ qdclf = 0
|
|
|
|
|
+ qdjxf = 0
|
|
|
|
|
+ for i in range(1, len(qdrcj)):
|
|
|
|
|
+ entry = qdrcj[i]
|
|
|
|
|
+ if entry[1] == bm:
|
|
|
|
|
+ entry[5] = jiage
|
|
|
|
|
+ hanliang = entry[10]
|
|
|
|
|
+ entry[11] = str(float(jiage) * float(hanliang))
|
|
|
|
|
+ if int(entry[8]) == 1:
|
|
|
|
|
+ qdrgf = qdrgf + float(entry[11])
|
|
|
|
|
+ elif int(entry[8]) == 2:
|
|
|
|
|
+ qdclf = qdclf + float(entry[11])
|
|
|
|
|
+ elif int(entry[8]) == 3:
|
|
|
|
|
+ qdjxf = qdjxf + float(entry[11])
|
|
|
|
|
+ post['人工费'] = str(qdrgf)
|
|
|
|
|
+ post['辅材费'] = str(qdclf)
|
|
|
|
|
+ post['材料费'] = str(qdclf)
|
|
|
|
|
+ post['机械费'] = str(qdjxf)
|
|
|
|
|
+ post['管理费'] = 0
|
|
|
|
|
+ post['利润'] = 0
|
|
|
|
|
+ for entry in children:
|
|
|
|
|
+ post['管理费'] = post['管理费'] + float(entry['管理费']) * float(entry['数量'])
|
|
|
|
|
+ post['利润'] = post['利润'] + float(entry['利润']) * float(entry['数量'])
|
|
|
|
|
+ post['管理费'] = str(post['管理费'])
|
|
|
|
|
+ post['利润'] = str(post['利润'])
|
|
|
|
|
+
|
|
|
|
|
+ post['综合单价'] = str(float(post['人工费']) + float(post['材料费']) + float(post['机械费']) + float(post['管理费']) + float(post['利润']))
|
|
|
|
|
+ post['合价'] = str(float(post['综合单价']) * float(qdsl))
|
|
|
|
|
+ await collection.replace_one({'_id': post['_id']}, post )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|