|
|
@@ -1,5 +1,5 @@
|
|
|
import xml.etree.ElementTree as ET
|
|
|
-from subdir import service
|
|
|
+from subdir import service, util
|
|
|
from bson.objectid import ObjectId
|
|
|
import uuid
|
|
|
def getDingercj_(root, bh, bt, qdbm, debm):
|
|
|
@@ -705,21 +705,63 @@ async def getQufei(client, id):
|
|
|
async def save(client, data):
|
|
|
db = client["baojia"]
|
|
|
collection = db["qdxm"]
|
|
|
+ biao_id = None
|
|
|
+ bh = None
|
|
|
for entry in data:
|
|
|
entry["__children"] = entry["_children"]
|
|
|
del entry["_children"]
|
|
|
+ biao_id = entry['biao_id']
|
|
|
+ bh = entry['Dwgcbh']
|
|
|
await collection.replace_one({"biao_id": entry["biao_id"], "Dwgcbh": entry["Dwgcbh"], "bt": entry["bt"], "清单编码": entry["清单编码"]}, entry)
|
|
|
-
|
|
|
+ if not biao_id:
|
|
|
+ return {"result" : "ok"}
|
|
|
+ rcjhz = []
|
|
|
+ async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
|
|
|
+ qdrcj = post['rcj'][1:]
|
|
|
+ for entry in qdrcj:
|
|
|
+ entry[10] = float(entry[10]) * float(post['数量'])
|
|
|
+ rcjhz = rcjhz + qdrcj
|
|
|
+ collection = db["Djcs"]
|
|
|
+ async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
|
|
|
+ qdrcj = post['rcj'][1:]
|
|
|
+ for entry in qdrcj:
|
|
|
+ entry[10] = float(entry[10]) * float(post['数量'])
|
|
|
+ rcjhz = rcjhz + qdrcj
|
|
|
+ newHuizong = util.huizongrcj(rcjhz)
|
|
|
+ collection = db["Dwgc"]
|
|
|
+ await collection.update_one({'biao_id': biao_id, 'Dwgcbh': bh}, {'$set': {'rcjhz' : newHuizong}})
|
|
|
return {"result": "ok"}
|
|
|
|
|
|
async def savedjcs(client, data):
|
|
|
db = client["baojia"]
|
|
|
collection = db["Djcs"]
|
|
|
+ biao_id = None
|
|
|
+ bh = None
|
|
|
for entry in data:
|
|
|
entry["__children"] = entry["_children"]
|
|
|
del entry["_children"]
|
|
|
+ biao_id = entry['biao_id']
|
|
|
+ bh = entry['Dwgcbh']
|
|
|
await collection.replace_one({"biao_id": entry["biao_id"], "Dwgcbh": entry["Dwgcbh"], "清单编码": entry["清单编码"]}, entry)
|
|
|
|
|
|
+ if not biao_id:
|
|
|
+ return {"result" : "ok"}
|
|
|
+ rcjhz = []
|
|
|
+ collection = db["qdxm"]
|
|
|
+ async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
|
|
|
+ qdrcj = post['rcj'][1:]
|
|
|
+ for entry in qdrcj:
|
|
|
+ entry[10] = float(entry[10]) * float(post['数量'])
|
|
|
+ rcjhz = rcjhz + qdrcj
|
|
|
+ collection = db["Djcs"]
|
|
|
+ async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
|
|
|
+ qdrcj = post['rcj'][1:]
|
|
|
+ for entry in qdrcj:
|
|
|
+ entry[10] = float(entry[10]) * float(post['数量'])
|
|
|
+ rcjhz = rcjhz + qdrcj
|
|
|
+ newHuizong = util.huizongrcj(rcjhz)
|
|
|
+ collection = db["Dwgc"]
|
|
|
+ await collection.update_one({'biao_id': biao_id, 'Dwgcbh': bh}, {'$set': {'rcjhz' : newHuizong}})
|
|
|
return {"result": "ok"}
|
|
|
|
|
|
async def applyFL(client, id, data):
|
|
|
@@ -841,10 +883,13 @@ async def applyFL(client, id, data):
|
|
|
|
|
|
|
|
|
|
|
|
-async def tiaojia(client, biao_id, bh, bm, jiage, glf, lr, bz):
|
|
|
+async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz):
|
|
|
db = client["baojia"]
|
|
|
collection = db["qdxm"]
|
|
|
async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
|
|
|
+ if "__children" not in post:
|
|
|
+ ##print(post)
|
|
|
+ continue
|
|
|
children = post["__children"]
|
|
|
qdsl = post['数量']
|
|
|
hit = False
|
|
|
@@ -856,7 +901,7 @@ async def tiaojia(client, biao_id, bh, bm, jiage, glf, lr, bz):
|
|
|
dejxf = 0
|
|
|
for i in range(1, len(dercj)):
|
|
|
rcj = dercj[i]
|
|
|
- if rcj[1] == bm:
|
|
|
+ if rcj[1] == bm and rcj[2] == mingcheng and rcj[4] == danwei:
|
|
|
hit = True
|
|
|
hitde = True
|
|
|
rcj[5] = jiage
|
|
|
@@ -892,7 +937,7 @@ async def tiaojia(client, biao_id, bh, bm, jiage, glf, lr, bz):
|
|
|
qdjxf = 0
|
|
|
for i in range(1, len(qdrcj)):
|
|
|
entry = qdrcj[i]
|
|
|
- if entry[1] == bm:
|
|
|
+ if entry[1] == bm and entry[2] == mingcheng and entry[4] == danwei:
|
|
|
entry[5] = jiage
|
|
|
hanliang = entry[10]
|
|
|
entry[11] = str(float(jiage) * float(hanliang))
|
|
|
@@ -916,6 +961,7 @@ async def tiaojia(client, biao_id, bh, bm, jiage, glf, lr, bz):
|
|
|
|
|
|
post['综合单价'] = str(float(post['人工费']) + float(post['材料费']) + float(post['机械费']) + float(post['管理费']) + float(post['利润']))
|
|
|
post['合价'] = str(float(post['综合单价']) * float(qdsl))
|
|
|
+ print(post)
|
|
|
await collection.replace_one({'_id': post['_id']}, post )
|
|
|
collection = db["Djcs"]
|
|
|
async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
|
|
|
@@ -930,7 +976,7 @@ async def tiaojia(client, biao_id, bh, bm, jiage, glf, lr, bz):
|
|
|
dejxf = 0
|
|
|
for i in range(1, len(dercj)):
|
|
|
rcj = dercj[i]
|
|
|
- if rcj[1] == bm:
|
|
|
+ if rcj[1] == bm and rcj[2] == mingcheng and rcj[4] == danwei:
|
|
|
hit = True
|
|
|
hitde = True
|
|
|
rcj[5] = jiage
|
|
|
@@ -966,7 +1012,7 @@ async def tiaojia(client, biao_id, bh, bm, jiage, glf, lr, bz):
|
|
|
qdjxf = 0
|
|
|
for i in range(1, len(qdrcj)):
|
|
|
entry = qdrcj[i]
|
|
|
- if entry[1] == bm:
|
|
|
+ if entry[1] == bm and entry[2] == mingcheng and entry[4] == danwei:
|
|
|
entry[5] = jiage
|
|
|
hanliang = entry[10]
|
|
|
entry[11] = str(float(jiage) * float(hanliang))
|
|
|
@@ -991,6 +1037,15 @@ async def tiaojia(client, biao_id, bh, bm, jiage, glf, lr, bz):
|
|
|
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["Dwgc"]
|
|
|
+ document = await collection.find_one({'biao_id': biao_id, "Dwgcbh": bh})
|
|
|
+ hz = document['rcjhz']
|
|
|
+ for entry in hz:
|
|
|
+ if entry[1] == bm and entry[2] == mingcheng and entry[4] == danwei:
|
|
|
+ entry[6] = jiage
|
|
|
+ entry[7] = float(jiage) * float(entry[5])
|
|
|
+ await collection.update_one({'biao_id': biao_id, "Dwgcbh": bh}, {'$set': {'rcjhz': hz}})
|
|
|
+
|
|
|
|
|
|
|
|
|
|