| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003 |
- import xml.etree.ElementTree as ET
- from subdir import service
- from bson.objectid import ObjectId
- import uuid
- def getDingercj_(root, bh, bt, qdbm, debm):
- result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
- #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
- item = None
- for child in root:
-
- if child.tag == "Dxgcxx":
- for child1 in child:
- Dwgcbh = child1.attrib["Dwgcbh"]
- if Dwgcbh == bh:
- item = child1
- break
- ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
- Fywj = None
- for child in item:
- if child.tag == 'Qdxm':
- Fywj= child
- break
- Rcjhz = None
- for child in item:
- if child.tag == 'Rcjhz':
- Rcjhz = child
- break
- kv = {}
- for entry in Rcjhz:
- kv[entry.attrib["RcjId"]]=entry
- container = None
- for child in Fywj:
- ##child is mx
- if child.tag == "QdBt":
- if child.attrib["Mc"] == bt:
- container = child
- break
- if not container:
- container = Fywj
- zimu = None
- for child in container:
- if child.attrib["Qdbm"] == qdbm:
- zimu = child
- break
- box = None
- if not zimu:
- return result
- for child in zimu:
- if child.tag == "Qdxdezj":
- box = child
- break
- hlmx_parent = None
- for child in box:
- if child.attrib["Debm"] == debm:
- for grandchild in child:
- if grandchild.tag == "Qdxdercjhl":
- hlmx_parent = grandchild
- for child in hlmx_parent:
- result.append([child.attrib["RcjId"],
- kv[child.attrib["RcjId"]].attrib["RcjBm"],
- kv[child.attrib["RcjId"]].attrib["Mc"],
- kv[child.attrib["RcjId"]].attrib["Ggxh"],
- kv[child.attrib["RcjId"]].attrib["Dw"],
- kv[child.attrib["RcjId"]].attrib["Dj"],
- kv[child.attrib["RcjId"]].attrib["Cd"],
- kv[child.attrib["RcjId"]].attrib["Gycs"],
- kv[child.attrib["RcjId"]].attrib["Rcjlb"],
- kv[child.attrib["RcjId"]].attrib["Jgbz"],
- child.attrib["Rcjhl"], child.attrib["Rcjhj"], "",
- "", "", ""
- ])
- return result
- def getQingdanrcj_(root, bh, bt, bm):
- result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
- #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
- item = None
- for child in root:
-
- if child.tag == "Dxgcxx":
- for child1 in child:
- Dwgcbh = child1.attrib["Dwgcbh"]
- if Dwgcbh == bh:
- item = child1
- break
- ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
- Fywj = None
- for child in item:
- if child.tag == 'Qdxm':
- Fywj= child
- break
- Rcjhz = None
- for child in item:
- if child.tag == 'Rcjhz':
- Rcjhz = child
- break
- kv = {}
- for entry in Rcjhz:
- kv[entry.attrib["RcjId"]]=entry
- container = None
- for child in Fywj:
- ##child is mx
- if child.tag == "QdBt":
- if child.attrib["Mc"] == bt:
- container = child
- break
- if not container:
- container = Fywj
- zimu = None
- for child in container:
- if child.attrib["Qdbm"] == bm:
- zimu = child
- break
- box = None
- if not zimu:
- return result
- for child in zimu:
- if child.tag == "Qdxrcjhl":
- box = child
- break
- for child in box:
- result.append([child.attrib["RcjId"],
- kv[child.attrib["RcjId"]].attrib["RcjBm"],
- kv[child.attrib["RcjId"]].attrib["Mc"],
- kv[child.attrib["RcjId"]].attrib["Ggxh"],
- kv[child.attrib["RcjId"]].attrib["Dw"],
- kv[child.attrib["RcjId"]].attrib["Dj"],
- kv[child.attrib["RcjId"]].attrib["Cd"],
- kv[child.attrib["RcjId"]].attrib["Gycs"],
- kv[child.attrib["RcjId"]].attrib["Rcjlb"],
- kv[child.attrib["RcjId"]].attrib["Jgbz"],
- child.attrib["Rcjhl"], child.attrib["Rcjhj"], child.attrib["Zgjbz"],
- child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"]
- ])
- return result
- def getDjcsDingercj_(root, bh, bt, qdbm, debm):
- result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
- #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
- item = None
- for child in root:
-
- if child.tag == "Dxgcxx":
- for child1 in child:
- Dwgcbh = child1.attrib["Dwgcbh"]
- if Dwgcbh == bh:
- item = child1
- break
- ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
- Fywj = None
- for child in item:
- if child.tag == 'Csxm':
- Fywj= child
- break
- Rcjhz = None
- for child in item:
- if child.tag == 'Rcjhz':
- Rcjhz = child
- break
- kv = {}
- for entry in Rcjhz:
- kv[entry.attrib["RcjId"]]=entry
- container = None
- for child in Fywj:
- if child.tag == "DjCs":
- container = child
- break
- zimu = None
- for child in container:
- if child.attrib["Bm"] == qdbm:
- zimu = child
- break
- box = None
- if not zimu:
- return result
- for child in zimu:
- if child.tag == "Csxdezj":
- box = child
- break
- hlmx_parent = None
- for child in box:
- if child.attrib["Debm"] == debm:
- for grandchild in child:
- if grandchild.tag == "Csxdercjhl":
- hlmx_parent = grandchild
- for child in hlmx_parent:
- result.append([child.attrib["RcjId"],
- kv[child.attrib["RcjId"]].attrib["RcjBm"],
- kv[child.attrib["RcjId"]].attrib["Mc"],
- kv[child.attrib["RcjId"]].attrib["Ggxh"],
- kv[child.attrib["RcjId"]].attrib["Dw"],
- kv[child.attrib["RcjId"]].attrib["Dj"],
- kv[child.attrib["RcjId"]].attrib["Cd"],
- kv[child.attrib["RcjId"]].attrib["Gycs"],
- kv[child.attrib["RcjId"]].attrib["Rcjlb"],
- kv[child.attrib["RcjId"]].attrib["Jgbz"],
- child.attrib["Rcjhl"], child.attrib["Rcjhj"], "",
- "", "", ""
- ])
- return result
- def getDjcsQingdanrcj_(root, bh, bt, bm):
- result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
- "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
- #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
- item = None
- for child in root:
-
- if child.tag == "Dxgcxx":
- for child1 in child:
- Dwgcbh = child1.attrib["Dwgcbh"]
- if Dwgcbh == bh:
- item = child1
- break
- ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
- Fywj = None
- for child in item:
- if child.tag == 'Csxm':
- Fywj= child
- break
- hl_parent = None
- for child in Fywj:
- if child.tag == "DjCs":
- hl_parent = child
- Rcjhz = None
- for child in item:
- if child.tag == 'Rcjhz':
- Rcjhz = child
- break
- kv = {}
- for entry in Rcjhz:
- kv[entry.attrib["RcjId"]]=entry
- zimu = None
- for child in hl_parent:
- if child.attrib["Bm"] == bm:
- zimu = child
- break
- box = None
- if not zimu:
- return result
- for child in zimu:
- if child.tag == "Csxrcjhl":
- box = child
- break
- for child in box:
- result.append([child.attrib["RcjId"],
- kv[child.attrib["RcjId"]].attrib["RcjBm"],
- kv[child.attrib["RcjId"]].attrib["Mc"],
- kv[child.attrib["RcjId"]].attrib["Ggxh"],
- kv[child.attrib["RcjId"]].attrib["Dw"],
- kv[child.attrib["RcjId"]].attrib["Dj"],
- kv[child.attrib["RcjId"]].attrib["Cd"],
- kv[child.attrib["RcjId"]].attrib["Gycs"],
- kv[child.attrib["RcjId"]].attrib["Rcjlb"],
- kv[child.attrib["RcjId"]].attrib["Jgbz"],
- child.attrib["Rcjhl"], child.attrib["Rcjhj"], child.attrib["Zgjbz"],
- child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"]
- ])
- return result
- async def resolve(manager, websocket, data, client):
- tree = ET.parse("data/" + data)
- root = tree.getroot()
- print(root)
- Dwgcbh = []
- jingjibiao = {}
- jingjibiao["BiaoDuanNO"] = root.attrib["BiaoDuanNO"]
- jingjibiao["Jsfs"] = root.attrib["Jsfs"]
- jingjibiao["Version"] = root.attrib["Version"]
- jingjibiao["Xmmc"] = root.attrib["Xmmc"]
- jingjibiao["Dxgcxx"] = []
- for child in root:
- if child.tag == "ZhaoBiaoXx":
- jingjibiao["ZhaoBiaoXx"] = {}
- jingjibiao["ZhaoBiaoXx"]["BzTime"] = child.attrib["BzTime"]
- jingjibiao["ZhaoBiaoXx"]["Bzr"] = child.attrib["Bzr"]
- jingjibiao["ZhaoBiaoXx"]["FhTime"] = child.attrib["FhTime"]
- jingjibiao["ZhaoBiaoXx"]["Fhr"] = child.attrib["Fhr"]
- jingjibiao["ZhaoBiaoXx"]["Zbr"] = child.attrib["Zbr"]
- jingjibiao["ZhaoBiaoXx"]["ZbrDb"] = child.attrib["ZbrDb"]
- jingjibiao["ZhaoBiaoXx"]["Zxr"] = child.attrib["Zxr"]
- jingjibiao["ZhaoBiaoXx"]["ZxrDb"] = child.attrib["ZxrDb"]
- elif child.tag == "TouBiaoXx":
- jingjibiao["TouBiaoXx"] = {}
- jingjibiao["TouBiaoXx"]["Zbr"] = child.attrib["Zbr"]
- jingjibiao["TouBiaoXx"]["Tbr"] = child.attrib["Tbr"]
- jingjibiao["TouBiaoXx"]["TbrDb"] = child.attrib["TbrDb"]
- jingjibiao["TouBiaoXx"]["Bzr"] = child.attrib["Bzr"]
- jingjibiao["TouBiaoXx"]["BzTime"] = child.attrib["BzTime"]
- jingjibiao["TouBiaoXx"]["Tbzj"] = child.attrib["Tbzj"]
- jingjibiao["TouBiaoXx"]["Zgj"] = child.attrib["Zgj"]
- jingjibiao["TouBiaoXx"]["Aqwmf"] = child.attrib["Aqwmf"]
- jingjibiao["TouBiaoXx"]["Gf"] = child.attrib["Gf"]
- elif child.tag == "Dxgcxx":
- Dxgcxx = {}
- Dxgcxx["Aqwmf"] = child.attrib["Aqwmf"]
- Dxgcxx["Dxgcbh"] = child.attrib["Dxgcbh"]
- Dxgcxx["Dxgcmc"] = child.attrib["Dxgcmc"]
- Dxgcxx["Gf"] = child.attrib["Gf"]
- Dxgcxx["Je"] = child.attrib["Je"]
- Dxgcxx["Zgj"] = child.attrib["Zgj"]
- Dxgcxx["Dwgc"] = []
- for grandchild in child:
- if grandchild.tag == "Dwgcxx":
- Dwgcxx = {}
- Dwgcxx["DogNum"] = grandchild.attrib["DogNum"]
- Dwgcxx["Dwgcbh"] = grandchild.attrib["Dwgcbh"]
- Dwgcbh.append({"bh": grandchild.attrib["Dwgcbh"], "num": grandchild.attrib["DogNum"]})
- Dwgcxx["Dwgcmc"] = grandchild.attrib["Dwgcmc"]
- Dwgcxx["MachineKey"] = grandchild.attrib["MachineKey"]
- Dwgcxx["SoftName"] = grandchild.attrib["SoftName"]
- Dwgcxx["SoftNum"] = grandchild.attrib["SoftNum"]
- Dwgcxx["Zylb"] = grandchild.attrib["Zylb"]
- Dxgcxx["Dwgc"].append(Dwgcxx)
- jingjibiao["Dxgcxx"].append(Dxgcxx)
- db = client["baojia"]
- collection = db["jingjibiao"]
- biao_id = (await collection.insert_one(jingjibiao)).inserted_id
- biao_id = str(biao_id)
- collection = db["Dwgc"]
- for entry in Dwgcbh:
- bjhz = service.getBjhz(root, entry["bh"])###array which contains __children
- gfsj = service.getGfsj(root, entry["bh"])##array which contains __children
- qtxm = service.getQtxm(root, entry["bh"])##array which contains __children
- zlje = service.getZlje(root, entry["bh"])
- jrg = service.getJrg(root, entry["bh"])
- zcbfwf = service.getZcbfwf(root, entry["bh"])
- fbrgycl = service.getFbrgycl(root, entry["bh"])
- rcjhz = service.getRcjhz(root, entry["bh"])
- zjcs = service.getZjcs(root, entry["bh"])
- qdbt = service.getQdxm(root, entry["bh"])
- Dwgc = {}
- Dwgc["bjhz"] = bjhz
- Dwgc["gfsj"] = gfsj
- Dwgc["qtxm"] = qtxm
- Dwgc["zlje"] = zlje
- Dwgc["jrg"] = jrg
- Dwgc["zcbfwf"] = zcbfwf
- Dwgc["fbrgycl"] = fbrgycl
- Dwgc["rcjhz"] = rcjhz
- Dwgc["zjcs"] = zjcs
- Dwgc["qdbt"] = qdbt
- Dwgc["DogNum"] = entry["num"]
- Dwgc["Dwgcbh"] = entry["bh"]
- Dwgc["biao_id"] = biao_id
- await collection.insert_one(Dwgc)
- collection = db["Djcs"]
- for entry in Dwgcbh:
-
- djcs = service.getDjcs(root, entry["bh"])
- for cs in djcs:
- cs["DogNum"] = entry["num"]
- cs["Dwgcbh"] = entry["bh"]
- cs["biao_id"] = entry["biao_id"]
- rcj = getDjcsQingdanrcj_(root, entry["bh"], "", cs['清单编码'])
- cs["rcj"] = rcj
- if "__children" in cs:
- children = cs["__children"]
- for child in children:
- dercj = getDjcsDingercj_(root, entry["bh"], "", cs["清单编码"], child["清单编码"])
- child["dercj"] = dercj
- child['fuzhuEnable'] = False
- await collection.insert_one(cs)
- collection = db["qdxm"]
- for entry in Dwgcbh:
-
- bts = service.getQdxm(root, entry["bh"])
- for bt in bts:
-
- qdmx = service.getQdmx(root, entry["bh"], bt)
- for qd in qdmx:
- qd["DogNum"] = entry["num"]
- qd["Dwgcbh"] = entry["bh"]
- qd["biao_id"] = biao_id
- qd["bt"] = bt
- rcj = getQingdanrcj_(root, entry["bh"], bt, qd["清单编码"])
- qd["rcj"] = rcj
- if "__children" in qd:
- children = qd["__children"]
- for child in children:
- dercj = getDingercj_(root, entry["bh"], bt, qd["清单编码"], child["清单编码"])
- child["dercj"] = dercj
- child['fuzhuEnable'] = False
- await collection.insert_one(qd)
-
- collection = db["qufei"]
- document = jingjibiao
- dxgc = document['Dxgcxx']
- result = []
- for entry in dxgc:
- newone = {"名称" : entry['Dxgcmc'], "工程类型":"", "工程类别": "", "管理费(%)": "", "利润(%)": "","备注":"", "key" : str(uuid.uuid4()) }
- children = []
- for dwgc in entry['Dwgc']:
- children.append({"名称" : dwgc['Dwgcmc'], "工程类型":"", "工程类别": "", "管理费(%)": "", "利润(%)": "","备注":"", "key" : dwgc['Dwgcbh']})
- newone["children"] = children
- result.append(newone)
- await collection.insert_one({"biao_id": biao_id, "qufei": [{
- "名称" : document['Xmmc'], "工程类型":"", "工程类别": "", "管理费(%)": "", "利润(%)": "","备注":"", "key" : str(uuid.uuid4()), "children" : result
- }]})
- await manager.send_personal_message(f"You wrote: {data}", websocket)
- async def list_files(client):
- db = client["baojia"]
- collection = db["jingjibiao"]
- result = []
- async for post in collection.find():
- result.append([str(post['_id']), post["Xmmc"]])
- return result
- def getDwgc(id, Zylb):
- result = []
- #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
-
-
- ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
- id = id + "Zylb" + Zylb
-
-
- result.append({"id": id + "bao jia hui zong", "label": "报价汇总表"})
-
- result.append({"id": id + "gui fei shui jin", "label": "规费税金"})
-
- result.append({"id": id + "qing dan xiang mu", "label": "清单项目"})
-
- result.append({"id": id + "cuo shi xiang mu", "label": "措施项目"})
-
- result.append({"id": id +"qi ta xiang mu", "label": "其他项目"})
-
- result.append({"id": id +"zan lie jin e", "label": "暂列金额"})
-
- result.append({"id": id +"cai liao zan gu jia", "label": "材料暂估价"})
-
- result.append({"id": id + "zhuan ye gong cheng zan gu jia", "label": "专业工程暂估价"})
-
- result.append({"id": id + "ji ri gong", "label": "计日工"})
-
- result.append({"id": id + "zong cheng bao fu wu fei", "label": "总承包服务费"})
-
- result.append({"id": id + "zong jia xiang mu jin du kuan zhi fu fen jie", "label": "总价项目进度款支付分解"})
-
- result.append({"id": id + "fa bao ren gong ying cai liao", "label": "发包人供应材料"})
-
- result.append({"id": id + "cheng bao ren gong ying cai liao", "label": "承包人供应材料"})
-
- result.append({"id": id + "ren cai ji hui zong", "label": "人材机汇总"})
-
- return result
- async def getOutline(client, id):
- db = client["baojia"]
- collection = db["jingjibiao"]
- document = await collection.find_one({'_id': ObjectId(id)})
- result = []
- if 'TouBiaoXx' in document:
- result.append({"id" : "TouBiaoXx", "label" : "投标信息" })
- if 'Dxgcxx' in document:
- Dxgcxx = document["Dxgcxx"]
- for dxgc in Dxgcxx:
- result2 = []
- Dwgc = dxgc["Dwgc"]
- for grandchild in Dwgc:
- result2.append({"id" : grandchild['Dwgcbh'], "Zylb":grandchild['Zylb'], "label": grandchild["Dwgcmc"], "children" : getDwgc(grandchild['Dwgcbh'], grandchild['Zylb'])})
- result.append({"id" : dxgc['Dxgcbh'], "label" : dxgc['Dxgcmc'], "children" : result2})
- return result
-
- async def getDetail(client, id):
- db = client["baojia"]
- collection = db["jingjibiao"]
- document = await collection.find_one({'_id': ObjectId(id)})
- result = []
- result.append(["名称", "金额", "暂估价", "安全文明施工费", "规费"])
- if 'TouBiaoXx' in document:
- toubiaoxx = document["TouBiaoXx"]
- result.append([toubiaoxx["Zbr"], toubiaoxx["Tbzj"], toubiaoxx["Zgj"], toubiaoxx["Aqwmf"], toubiaoxx["Gf"]])
-
- if 'Dxgcxx' in document:
- Dxgcxx = document["Dxgcxx"]
- for dxgc in Dxgcxx:
-
- result.append([dxgc["Dxgcmc"], dxgc["Je"], dxgc["Zgj"], dxgc["Aqwmf"], dxgc["Gf"]])
- return result
- async def getBjhz(client, objectid, id):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
- return document['bjhz']
- async def getGfsj(client, objectid, id):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
- return document['gfsj']
- async def getQtxm(client, objectid, id):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
- return document['qtxm']
- async def getZlje(client, objectid, id):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
- return document['zlje']
- async def getJrg(client, objectid, id):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
- return document['jrg']
- async def getZcbfwf(client, objectid, id):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({"Dwgcbh": id, "biao_id": objectid})
- return document['zcbfwf']
-
- async def getFbrgycl(client, objectid, id):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
- return document['fbrgycl']
- async def getRcjhz(client, objectid, id):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
- return document['rcjhz']
- async def getZjcs(client, objectid, id):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
- return document['zjcs']
- async def getDjcs(client, objectid, id):
- db = client["baojia"]
- collection = db["Djcs"]
- result = []
- async for post in collection.find({"Dwgcbh": id, "biao_id": objectid}):
- ##post["ID"] = post["_id"]
- del post["_id"]
- ##print( post["rcj"])
- ## del post["DogNum"]
- result.append(post)
- return result
- async def getDjcsQingdanrcj(client, name, bh, bt, bm):
- db = client["baojia"]
-
- collection = db["Djcs"]
- document = await collection.find_one({ "Dwgcbh": bh, "清单编码": bm, "biao_id": name})
- result = document["rcj"]
- return result
- async def getDjcsDingercj(client, name, bh, bt, qdbm, debm):
- db = client["baojia"]
-
- collection = db["Djcs"]
- document = await collection.find_one({"Dwgcbh": bh, "清单编码": qdbm, "biao_id": name})
- children = document["__children"]
- result = []
- for child in children:
- if child["清单编码"] == debm:
- result = child["dercj"]
- return result
- async def getQdxm(client, name, bh):
- db = client["baojia"]
- collection = db["Dwgc"]
- document = await collection.find_one({'biao_id': name, "Dwgcbh": bh})
- if document:
- return document['qdbt']
- else:
- return []
-
- async def getQdmx(client, name, bh, bt):
- db = client["baojia"]
- collection = db["qdxm"]
- result = []
- async for post in collection.find({'biao_id': name, "Dwgcbh": bh, "bt": bt}):
- ##post["ID"] = post["_id"]
- del post["_id"]
- #del post["rcj"]
- #del post["DogNum"]
- result.append(post)
- return result
- async def getQingdanrcj(client, name, bh, bt, bm):
- db = client["baojia"]
- collection = db["qdxm"]
- document = await collection.find_one({ "Dwgcbh": bh, "清单编码": bm, "biao_id": name, "bt": bt})
- result = document["rcj"]
- return result
- async def getDingercj(client, name, bh, bt, qdbm, debm):
- db = client["baojia"]
-
- collection = db["qdxm"]
- document = await collection.find_one({"Dwgcbh": bh, "清单编码": qdbm, "biao_id": name, "bt": bt})
- result = []
- if "__children" in document:
- children = document["__children"]
-
- for child in children:
- if child["清单编码"] == debm:
- result = child["dercj"]
- return result
- async def getQufei(client, id):
- db = client["baojia"]
- collection = db["qufei"]
- document = await collection.find_one({'biao_id': id})
- return document['qufei']
- async def save(client, data):
- db = client["baojia"]
- collection = db["qdxm"]
- for entry in data:
- entry["__children"] = entry["_children"]
- del entry["_children"]
- await collection.replace_one({"biao_id": entry["biao_id"], "Dwgcbh": entry["Dwgcbh"], "bt": entry["bt"], "清单编码": entry["清单编码"]}, entry)
- return {"result": "ok"}
- async def savedjcs(client, data):
- db = client["baojia"]
- collection = db["Djcs"]
- for entry in data:
- entry["__children"] = entry["_children"]
- del entry["_children"]
- await collection.replace_one({"biao_id": entry["biao_id"], "Dwgcbh": entry["Dwgcbh"], "清单编码": entry["清单编码"]}, entry)
- return {"result": "ok"}
- async def applyFL(client, id, data):
- db = client["baojia"]
- collection = db["qufei"]
-
- await collection.replace_one({"biao_id": id}, {"biao_id": id, "qufei": data})
- collection = db['qdxm']
- xm = data[0]
- 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:
- ##常规计算
- child['管理费'] = (rgf + jxf) * glf / float(100)
- child['利润'] = (rgf + jxf) * lr / float(100)
- child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
- child['合价'] = sl * sl_ * child['综合单价']
- else:
- 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 )
- 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:
- ##常规计算
- child['管理费'] = (rgf + jxf) * glf / float(100)
- child['利润'] = (rgf + jxf) * lr / float(100)
- child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
- child['合价'] = sl * sl_ * child['综合单价']
- else:
- 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 )
- 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 )
-
-
|