Xiaopeng Zhang 5 kuukautta sitten
vanhempi
commit
fb4e2062c1
5 muutettua tiedostoa jossa 479 lisäystä ja 959 poistoa
  1. 1 1
      README
  2. 25 183
      main.py
  3. 381 451
      subdir/db.py
  4. 70 322
      subdir/service.py
  5. 2 2
      subdir/util.py

+ 1 - 1
README

@@ -1,5 +1,5 @@
 Feature 
-对于清单表,可以删除,添加常规定额,添加单项定额
+对于清单表,可以删除,添加常规定额,添加单项定额,添加算式定额
 对于清单表,可以改定额的名称,改定额的数量
 对于定额表,对于人材机,可以替换,可以改名称,
 可以改单价(但是目前还不支持改单价后反应到其他定额,这个功能比较消耗性能, 完全可以不允许改单价,只能在汇总表改单价)

+ 25 - 183
main.py

@@ -60,69 +60,19 @@ app.add_middleware(
     allow_methods=["*"],
     allow_headers=["*"],
 )
-app.add_middleware(GZipMiddleware, minimum_size=1000, compresslevel=5)
+##app.add_middleware(GZipMiddleware, minimum_size=1000, compresslevel=5)
 
-app.mount("/static", StaticFiles(directory="front/dist"), name="static")
-manager = ConnectionManager()
+##app.mount("/static", StaticFiles(directory="front/dist"), name="static")
+##manager = ConnectionManager()
 
 
-for root, dirs, files in os.walk("./data", topdown=False):
-    for name in files:
-        print(os.path.join(root, name))
-        file_data = os.path.join(root, name)
 
 
 
 
 
-def getDetail(root):
 
-    print(root.tag)
-    print(root.text)
-    print(root.attrib)
-    result = []
-    result.append(["名称", "金额", "暂估价", "安全文明施工费", "规费"])
-    for child in root:
-        print(child.tag)
-        print(child.attrib)
-    
-        if child.tag == "TouBiaoXx":
-            result.append([child.attrib["Zbr"], child.attrib["Tbzj"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
-        if child.tag == "Dxgcxx":
-            Dxgcbh = child.attrib["Dxgcbh"]
-            Dxgcmc = child.attrib["Dxgcmc"]
 
-            result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
-
-    return result
-def getOutline(root):
-
-    print(root.tag)
-    print(root.text)
-    print(root.attrib)
-    result = []
-    for child in root:
-        print(child.tag)
-        print(child.attrib)
-    
-        if child.tag == "TouBiaoXx":
-            result.append({"id" : "TouBiaoXx", "label" : "投标信息" })
-        if child.tag == "Dxgcxx":
-            Dxgcbh = child.attrib["Dxgcbh"]
-            Dxgcmc = child.attrib["Dxgcmc"]
-            result2 = []
-            for child1 in child:
-                #print("level2===================================")
-                #print(child1.tag)
-                #print(child1.attrib)
-                Dwgcbh = child1.attrib["Dwgcbh"]
-                Dwgcmc = child1.attrib["Dwgcmc"]
-                Zylb = child1.attrib["Zylb"]
-                result2.append({"id" : Dwgcbh,"Zylb":Zylb,  "label": Dwgcmc, "children" : service.getDwgc(root, Dwgcbh, Zylb)})
-
-            result.append({"id" : Dxgcbh, "label" : Dxgcmc, "children" : result2})
-
-    return result
 
 class Info(BaseModel):
     name: str
@@ -162,48 +112,21 @@ class UpdateZjcs(BaseModel):
     fl: str
     
 
-@app.post("/outline")
-async def read_root(info: Info):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return getOutline(root)
+
 
 @app.post("/outline2")
 async def read_root2(info: Info):
     
     return await db.getOutline(client, info.name)
 
-@app.post("/detail")
-async def read_detail(info: Info):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return getDetail(root)
+
 
 @app.post("/detail2")
 async def read_detail2(info: Info):
     
     return await db.getDetail(client, info.name)
 
-@app.post("/baojiahuizong/")
-async def read_bjhz(info: InfoWithID):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return service.getBjhz(root, info.id)
+
 
 @app.post("/baojiahuizong2/")
 async def read_bjhz2(info: InfoWithID):
@@ -221,16 +144,7 @@ async def read_bjhz2(info: InfoWithID):
         raw2.append(entry)
     return raw2
 
-@app.post("/guifeishuijin/")
-async def read_gfsj(info: InfoWithID):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return service.getGfsj(root, info.id)
+
 
 @app.post("/guifeishuijin2/")
 async def read_gfsj2(info: InfoWithID):
@@ -244,16 +158,7 @@ async def read_gfsj2(info: InfoWithID):
     return raw2
 
 
-@app.post("/qitaxiangmu/")
-async def read_qtxm(info: InfoWithID):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return service.getQtxm(root, info.id)
+
 
 @app.post("/qitaxiangmu2/")
 async def read_qtxm2(info: InfoWithID):
@@ -270,96 +175,40 @@ async def read_qtxm2(info: InfoWithID):
 async def zygczgj(info: InfoWithID):
     return await db.getZygczgj(client, info.name, info.id)
 
-@app.post("/zanliejine/")
-async def read_zlje(info: InfoWithID):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return service.getZlje(root, info.id)
+
 
 
 @app.post("/zanliejine2/")
 async def read_zlje2(info: InfoWithID):
     return await db.getZlje(client, info.name, info.id)
 
-@app.post("/jirigong/")
-async def read_jrg(info: InfoWithID):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return service.getJrg(root, info.id)
+
 
 @app.post("/jirigong2/")
 async def read_jrg2(info: InfoWithID):
     return await db.getJrg(client, info.name, info.id)
 
-@app.post("/zongchengbaofuwufei/")
-async def read_zcbfwf(info: InfoWithID):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return service.getZcbfwf(root, info.id)
+
 
 @app.post("/zongchengbaofuwufei2/")
 async def read_zcbfwf2(info: InfoWithID):
     return await db.getZcbfwf(client, info.name, info.id)
 
 
-@app.post("/fabaorengongyingcailiao/")
-async def read_fbrgycl(info: InfoWithID):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return service.getFbrgycl(root, info.id)
+
 
 @app.post("/fabaorengongyingcailiao2/")
 async def read_fbrgycl2(info: InfoWithID):
     return await db.getFbrgycl(client, info.name, info.id)
 
 
-@app.post("/rencaijihuizong/")
-async def read_rcjhz(info: InfoWithID):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return service.getRcjhz(root, info.id)
 
 @app.post("/rencaijihuizong2/")
 async def read_rcjhz2(info: InfoWithID):
     return await db.getRcjhz(client, info.name, info.id)
 
 
-@app.post("/qingdanxiangmu/")
-async def read_qdxm(info: InfoWithID):
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            if name == info.name:
-                print(os.path.join(root, name))
-                file_data = os.path.join(root, name)
-    tree = ET.parse(file_data)
-    root = tree.getroot()
-    return service.getQdxm(root, info.id)
-    #return []
+
 
 @app.post("/qingdanxiangmu2/")
 async def read_qdxm2(info: InfoWithID):
@@ -437,14 +286,7 @@ async def read_djcs(item : Zjcs):
         raw2.append(entry)
     return raw2
 
-@app.post("/files/")
-async def read_files():
-    result = []
-    for root, dirs, files in os.walk("./data", topdown=False):
-        for name in files:
-            print(os.path.join(root, name))
-            result.append([name, "", ""])
-    return result
+
 
 @app.post("/files2/")
 async def read_files2():
@@ -821,14 +663,14 @@ async def resolve(data):
     await db.resolve(data, client)##manager.send_personal_message(f"You wrote: {data}", websocket)
 
 
-@app.websocket("/ws")
-async def websocket_endpoint(websocket: WebSocket):
-    await manager.connect(websocket)
-    try:
-        while True:
-            data = await websocket.receive_text()
-            await resolve(websocket, data)
-            ##await manager.broadcast(f"Client #{client_id} says: {data}")
-    except WebSocketDisconnect:
-        manager.disconnect(websocket)
-        ##await manager.broadcast(f"Client  left the chat")
+##@app.websocket("/ws")
+##async def websocket_endpoint(websocket: WebSocket):
+##    await manager.connect(websocket)
+##    try:
+##        while True:
+##            data = await websocket.receive_text()
+##            await resolve(websocket, data)
+##            ##await manager.broadcast(f"Client #{client_id} says: {data}")
+##    except WebSocketDisconnect:
+##        manager.disconnect(websocket)
+##        ##await manager.broadcast(f"Client  left the chat")

+ 381 - 451
subdir/db.py

@@ -651,6 +651,9 @@ def roundstr4(input):
     b = round(a, 4)
     return str(b)
 
+
+
+###################################build xml file##################################
 async def build(client, root, id):
     db = client["baojia"]
     collection = db["jingjibiao"]
@@ -876,12 +879,6 @@ async def build(client, root, id):
                             QdxrcjhlMx.set('Zcbz', str(qdmx['rcj'][i][14]))
                             QdxrcjhlMx.set('Sbbz', str(qdmx['rcj'][i][15]))
 
-
-
-
-
-
-
             ########################################Csxm##########################
             Csxm = ET.SubElement(Dwgcxx, 'Csxm')
             ZjCs = ET.SubElement(Csxm, 'ZjCs')
@@ -986,36 +983,6 @@ async def build(client, root, id):
                             CsxrcjhlMx.set('Zcbz', str(djcs['rcj'][i][14]))
                             CsxrcjhlMx.set('Sbbz', str(djcs['rcj'][i][15]))
 
-
-                                
-
-
-
-
-
-                        
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
             ########################################Qtxm##########################
             Qtxm = ET.SubElement(Dwgcxx, 'Qtxm')
             for qtxm_ in qtxm:
@@ -1100,20 +1067,7 @@ async def build(client, root, id):
                     RcjhzMx.set('Zgjbz', str(rcjhz[i][15]))
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+############################end of build xml file#################################
 
 async def delete_files(client, id):
     db = client["baojia"]
@@ -1134,10 +1088,6 @@ async def list_files(client):
 
 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
     
     
@@ -1327,13 +1277,8 @@ async def getDjcs(client, objectid, id):
     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):
@@ -1374,10 +1319,7 @@ async def getQdmx(client, name, bh, bt):
     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
 
@@ -1431,152 +1373,390 @@ async def searchde(client, zhuanye, text):
 
 
 
-##################################editor##########################
-
-
-async def updatezjcs(client, id, bh, mc, fl):
-    db = client["baojia"]
-    collection = db["Dwgc"]
-    
-    document =  await collection.find_one({'biao_id': id, 'Dwgcbh': bh}, {'rcjhz': 0})
-    zjcs = document['zjcs']
-    for entry in zjcs:
-        if entry['名称'] == mc:
-            entry['费率'] = fl
-            entry['金额'] = str(float(entry['计算基数']) * float(fl) / float(100))
-
-    await collection.update_one({'biao_id': id, "Dwgcbh": bh}, {'$set': {'zjcs': zjcs}})
-    
+##################################editor_code##########################
+def bjhz_template():
+    result = []
+    result.append({'序号': '1', '名称': '分部分项工程', '金额': '0', '暂估价': '0', '类别' : '1', '__children': [
+        {'序号': '1.1', '名称': '人工费', '金额': '0', '暂估价': '0', '类别' : '1.1'},
+        {'序号': '1.2', '名称': '材料费', '金额': '0', '暂估价': '0', '类别' : '1.2'},
+        {'序号': '1.3', '名称': '施工机具使用费', '金额': '0', '暂估价': '0', '类别' : '1.3'},
+        {'序号': '1.4', '名称': '企业管理费', '金额': '0', '暂估价': '0', '类别' : '1.4'},
+        {'序号': '1.5', '名称': '利润', '金额': '0', '暂估价': '0', '类别' : '1.5'}
+    ]})
+    result.append({'序号': '2', '名称': '措施项目', '金额': '0', '暂估价': '0', '类别' : '2', '__children': [
+        {'序号': '2.1', '名称': '单价措施项目费', '金额': '0', '暂估价': '0', '类别' : '2.1'},
+        {'序号': '2.2', '名称': '总价措施项目费', '金额': '0', '暂估价': '0', '类别' : '2.2', '__children' : [
+        {'序号': '2.2.1', '名称': '其中:安全文明施工措施费', '金额': '0', '暂估价': '0', '类别' : '2.2.1'},]
+        }
+       
+    ]})
+    result.append({'序号': '3', '名称': '其他项目', '金额': '0', '暂估价': '0', '类别' : '3', '__children': [
+        {'序号': '3.1', '名称': '其中:暂列金额', '金额': '0', '暂估价': '0', '类别' : '3.1'},
+        {'序号': '3.2', '名称': '其中:专业工程暂估价', '金额': '0', '暂估价': '0', '类别' : '3.2'},
+        {'序号': '3.3', '名称': '其中:计日工', '金额': '0', '暂估价': '0', '类别' : '3.3'},
+        {'序号': '3.4', '名称': '其中:总承包服务费', '金额': '0', '暂估价': '0', '类别' : '3.4'},
         
+    ]})
+    result.append({'序号': '4', '名称': '规费', '金额': '0', '暂估价': '0', '类别' : '4', })
+    result.append({'序号': '5', '名称': '税金', '金额': '0', '暂估价': '0', '类别' : '5', })
+    result.append({'序号': '6', '名称': '工程造价', '金额': '0', '暂估价': '0', '类别' : '6', })
 
+    return result
 
 
-async def save(client, data):
+async def zongjiaDwgc(client, biao_id, bh):
     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}, {'__children': 0}):
-        qdrcj = post['rcj'][1:]
-        for entry in qdrcj:
-            print(entry[4])
-            if entry[4] != '%':
-                entry[10] = float(entry[10]) * float(post['数量'])
-        rcjhz = rcjhz + qdrcj
+    djcs_sum = 0###单价措施汇总
     collection = db["Djcs"]
     async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}, {'__children': 0}):
-        
-        qdrcj = post['rcj'][1:]
-        for entry in qdrcj:
-            print(entry[4])
-            if entry[4] != '%':
-                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}})
-    await zongjiaDwgc(client, biao_id, bh)
-    await tbxx(client, biao_id)
-    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 = []
+        djcs_sum = djcs_sum + float(post['合价'])
+    
+    collection = db['Dwgc']
+    document = await collection.find_one({'biao_id': biao_id, "Dwgcbh": bh}, {'rcjhz': 0})
+    qdbt = document['qdbt']
+    qdbt_addition = document['qdbt_addition']
+    bts = {}
+    distinguish = True
+    
+    for item in qdbt_addition:
+        bts[item['Mc']] = 0
+    
     collection = db["qdxm"]
+    qd_sum = 0###清单汇总
+    rgf_sum = 0
+    clf_sum = 0
+    jxf_sum = 0
+    glf_sum = 0
+    lr_sum = 0
+    fbrgycl_sum = 0
     async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}, {'__children': 0}):
-        qdrcj = post['rcj'][1:]
-        for entry in qdrcj:
-            if entry[4] != '%':
-                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}, {'__children': 0}):
-        qdrcj = post['rcj'][1:]
-        for entry in qdrcj:
-            if entry[4] != '%':
-                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}})
-    await zongjiaDwgc(client, biao_id, bh)
-    await tbxx(client, biao_id)
-    return {"result": "ok"}
+        qd_sum = qd_sum + float(post['合价'])
+        rgf_sum = rgf_sum + float(post['数量']) * float(post['人工费'])
+        clf_sum = clf_sum + float(post['数量']) * float(post['材料费'])
+        jxf_sum = jxf_sum + float(post['数量']) * float(post['机械费'])
+        glf_sum = glf_sum + float(post['数量']) * float(post['管理费'])
+        lr_sum = lr_sum + float(post['数量']) * float(post['利润'])
+        if distinguish and post['bt'] in bts:
+            bts[post['bt']] = bts[post['bt']] + float(post['合价'])
 
-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['综合单价'] 
+    sum = qd_sum + djcs_sum##作为总价措施和后续费用计算的的计算基础
+    fbrgycl = document['fbrgycl']
+    for entry in fbrgycl:
+        fbrgycl_sum = fbrgycl_sum + float(entry['合价'])
+    zjcs = document['zjcs']
+    def process(n):
+        n['计算基数'] = str(sum)
+        n['金额'] = float(sum) * float(n['费率']) / float(100)
+        if "__children" in n:
+            for entry in n['__children']:
+                entry['计算基数'] = str(sum)
+                entry['金额'] = float(sum) * float(entry['费率']) / float(100)
+        return n
 
-                    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['利润'])
+    ##目标数据,会存到数据库
+    result = [process(item) for item in zjcs]
+    for entry in result:
+        if '安全文明施工' in entry['名称']:
+            sum_ = 0
+            for child in entry['__children']:
+                sum_ = sum_ + float(child['金额'])
+            entry['金额'] = str(sum_)
+            entry['计算基数'] = str(sum_)
+    zjcs_sum = 0###总价措施汇总
+    for entry in result:
+        zjcs_sum = zjcs_sum + float(entry['金额'])
+    qtxm = document['qtxm']##dwgc qtxm
+    qtxm_sum = 0###其他项目汇总, 为了计算规费税金,其他项目本身不会改变
+    for entry in qtxm:
+        qtxm_sum = qtxm_sum + float(entry['金额'])
+    gfsj = document['gfsj']
+    gf_sum = 0###规费税金汇总
+    sj_sum = 0
+    for item in gfsj:
+        if item['名称'] == '规费':
+            child = item['__children']
+            for children in child:
+                children['取费基数'] = str(sum + zjcs_sum + qtxm_sum)
+                children['金额'] = str(float(sum + zjcs_sum + qtxm_sum) * float(children['费率']) / float(100))
+                gf_sum = gf_sum + float(children['金额'])
+    for item in gfsj:
+        if item['名称'] == '规费':
+            item['取费基数'] = str(gf_sum)
+            item['金额'] = str(gf_sum)
+    for item in gfsj:
+        if item['名称'] == '税金':
+            item['取费基数'] = str(sum + zjcs_sum + qtxm_sum + gf_sum - fbrgycl_sum / float(1.01))
+            item['金额'] = float(item['取费基数']) * float(item['费率']) / float(100)
+            sj_sum = float(item['金额'])
+    for item in gfsj:
+        if item['名称'] == '合计':
+            item['取费基数'] = str(sj_sum + gf_sum)
+            item['金额'] = item['取费基数']
+
+    qtxm = document['qtxm']
+    zlje = 0
+    zygczgj = 0
+    jrg = 0
+    zcbfwf = 0
+    clzgj = 0
+    for entry in qtxm:
+        if entry['序号'] == '1':
+            zlje = entry['金额']
+        if entry['序号'] == '3':
+            jrg = entry['金额']
+        if entry['序号'] == '4':
+            zcbfwf = entry['金额']
+        if entry['序号'] == '2':
+            for child in entry['__children']:
+                if child['序号'] == '2.2':
+                    zygczgj = child['金额']
+                if child['序号'] == '2.1':
+                    clzgj = child['金额']
+    ###重新算了一遍其他项目汇总
+    qtxm_sum = float(zlje) + float(zygczgj) + float(jrg) + float(zcbfwf) + float(clzgj)
+                
+    bjhz = bjhz_template()
+    for entry in bjhz:
+        if entry['序号'] == '1':
+            entry['金额'] = qd_sum
+            for child in entry['__children']:
+                if child['序号'] == '1.1':
+                    child['金额'] = str(rgf_sum)
+                if child['序号'] == '1.2':
+                    child['金额'] = str(clf_sum)
+                if child['序号'] == '1.3':
+                    child['金额'] = str(jxf_sum)
+                if child['序号'] == '1.4':
+                    child['金额'] = str(glf_sum)
+                if child['序号'] == '1.5':
+                    child['金额'] = str(lr_sum)
+        if entry['序号'] == '2':
+            entry['金额'] = str(djcs_sum + zjcs_sum)
+            for child in entry['__children']:
+                if child['序号'] == '2.1':
+                    child['金额'] = str(djcs_sum)
+                if child['序号'] == '2.2':
+                    child['金额'] = str(zjcs_sum)
+                    for grandchild in child['__children']:
+                        if grandchild['序号'] == '2.2.1':
+                            grandchild['金额'] = str(sum_)
+        if entry['序号'] == '3':
+            entry['金额'] = str(qtxm_sum)
+        if entry['序号'] == '4':
+            entry['金额'] = str(gf_sum)
+        if entry['序号'] == '5':
+            entry['金额'] = str(sj_sum)
+        if entry['序号'] == '6':
+            entry['金额'] = str(float(qd_sum) + float(djcs_sum) + float(zjcs_sum) + float(qtxm_sum) + float(gf_sum) + float(sj_sum))
+        
+
+    collection = db['Dwgc']
+    if distinguish:
+        for entry in qdbt_addition:
+            entry['Je'] = str(bts[entry['Mc']])    
+    await collection.update_one({'biao_id': biao_id, "Dwgcbh": bh}, {'$set': {'zjcs': result, 'gfsj' : gfsj, 'bjhz': bjhz, 'qdbt_addition' : qdbt_addition}})
+    
+
+
+async def tbxx(client, biao_id):
+    db = client["baojia"]
+    collection = db["jingjibiao"]
+    document = await collection.find_one({'_id': ObjectId(biao_id)})
+    dxgcxx = document['Dxgcxx']
+    tbxx = document['TouBiaoXx']
+    tbxx['Tbzj'] = '0'
+    tbxx['Zgj'] = '0'
+    tbxx['Aqwmf'] = '0'
+    tbxx['Gf'] = '0'
+    
+    dwdx = {}##单位工程映射单项工程
+    for dxgc in dxgcxx:
+        dxgc['Aqwmf'] = '0'
+        dxgc['Gf'] = '0'
+        dxgc['Je'] = '0'
+        dxgc['Zgj'] = '0'
+        mc = dxgc['Dxgcmc']
+        Dwgc = dxgc['Dwgc']
+        for dwgc in Dwgc:
+            Dwgcbh = dwgc['Dwgcbh']
+            dwdx[Dwgcbh] = dxgc
+    collection = db['Dwgc']
+    async for post in collection.find({'biao_id': biao_id}):
+        bh = post['Dwgcbh']
+        dx = dwdx[bh]
+        bjhz = post['bjhz']
+        
+        if len(bjhz) == 0:
+            pass
+        else:
+            qtxm = post['qtxm']
+            dx['Aqwmf'] = str(float(dx['Aqwmf']) + float(bjhz[1]['__children'][1]['__children'][0]['金额']))
+            dx['Gf'] = str(float(dx['Gf']) + float(bjhz[3]['金额']))
+            dx['Je'] = str(float(dx['Je']) + float(bjhz[5]['金额']))
+            dx['Zgj']= str(float(dx['Zgj']) + float(qtxm[1]['金额']))
+    for dxgc in dxgcxx:
+        tbxx['Tbzj'] = str(float(tbxx['Tbzj']) + float(dxgc['Je']))
+        tbxx['Zgj'] = str(float(tbxx['Zgj']) + float(dxgc['Zgj']))
+        tbxx['Aqwmf'] = str(float(tbxx['Aqwmf']) + float(dxgc['Aqwmf']))
+        tbxx['Gf'] = str(float(tbxx['Gf']) + float(dxgc['Gf']))
+    collection = db["jingjibiao"]
+
+
+    await collection.update_one({'_id': ObjectId(biao_id)}, {'$set': {'Dxgcxx': dxgcxx, 'TouBiaoXx' : tbxx}})
+
+
+
+
+
+async def updatezjcs(client, id, bh, mc, fl):
+    db = client["baojia"]
+    collection = db["Dwgc"]
+    
+    document =  await collection.find_one({'biao_id': id, 'Dwgcbh': bh}, {'rcjhz': 0})
+    zjcs = document['zjcs']
+    for entry in zjcs:
+        if entry['名称'] == mc:
+            entry['费率'] = fl
+            entry['金额'] = str(float(entry['计算基数']) * float(fl) / float(100))
+    
+
+    await collection.update_one({'biao_id': id, "Dwgcbh": bh}, {'$set': {'zjcs': zjcs}})
+    await zongjiaDwgc(client, id, bh)
+    await tbxx(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}, {'__children': 0}):
+        qdrcj = post['rcj'][1:]
+        for entry in qdrcj:
+            print(entry[4])
+            if entry[4] != '%':
+                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}, {'__children': 0}):
+        
+        qdrcj = post['rcj'][1:]
+        for entry in qdrcj:
+            print(entry[4])
+            if entry[4] != '%':
+                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}})
+    await zongjiaDwgc(client, biao_id, bh)
+    await tbxx(client, biao_id)
+    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}, {'__children': 0}):
+        qdrcj = post['rcj'][1:]
+        for entry in qdrcj:
+            if entry[4] != '%':
+                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}, {'__children': 0}):
+        qdrcj = post['rcj'][1:]
+        for entry in qdrcj:
+            if entry[4] != '%':
+                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}})
+    await zongjiaDwgc(client, biao_id, bh)
+    await tbxx(client, biao_id)
+    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['数量']))
                     
@@ -1646,7 +1826,7 @@ async def applyFL(client, id, data):
     return {"result": "ok"}
 
 
-
+###人材机汇总页面调价
 async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz):
     db = client["baojia"]
     rcjhz = []
@@ -1753,7 +1933,7 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
                        post["__children"][i]['合价'] = post["__children"][i]['综合单价'] * float(post["__children"][i]['数量']) * float(post['数量'])
                        dercj = post["__children"][i]['dercj']
                        for j in range(1, len(dercj)):
-                           dercj[j][11] = float(post['__children'][i]['综合单价']) * float(dercj[j][10]) / float(100)
+                           dercj[j][11] = float(added) * float(dercj[j][10]) / float(100)
                        
                     
                     if tag[0] == '人工费+机械费':
@@ -1779,7 +1959,7 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
                        post["__children"][i]['合价'] = post["__children"][i]['综合单价'] * float(post["__children"][i]['数量']) * float(post["数量"])
                        dercj = post["__children"][i]['dercj']
                        for j in range(1, len(dercj)):
-                           dercj[j][11] = float(post['__children'][i]['综合单价']) * float(dercj[j][10]) / float(100)
+                           dercj[j][11] = float(added) * float(dercj[j][10]) / float(100)
                        
                     
             qdrcj = []
@@ -1940,9 +2120,6 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
             
             await collection.replace_one({'_id': post['_id']}, post )
     
-    
-    
-    
     async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}, {'__children': 0}):
         
         qdrcj = post['rcj'][1:]
@@ -1952,7 +2129,7 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
         rcjhz = rcjhz + qdrcj
     newHuizong = util.huizongrcj(rcjhz)
     collection = db["Dwgc"]
-    document = await collection.find_one({'biao_id': biao_id, "Dwgcbh": bh})
+    #document = await collection.find_one({'biao_id': biao_id, "Dwgcbh": bh})
     await collection.update_one({'biao_id': biao_id, "Dwgcbh": bh}, {'$set': {'rcjhz': newHuizong}})
     await zongjiaDwgc(client, biao_id, bh)
     await tbxx(client, biao_id)
@@ -1960,266 +2137,19 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
 
 
 
-def bjhz_template():
-    result = []
-    result.append({'序号': '1', '名称': '分部分项工程', '金额': '0', '暂估价': '0', '类别' : '1', '__children': [
-        {'序号': '1.1', '名称': '人工费', '金额': '0', '暂估价': '0', '类别' : '1.1'},
-        {'序号': '1.2', '名称': '材料费', '金额': '0', '暂估价': '0', '类别' : '1.2'},
-        {'序号': '1.3', '名称': '施工机具使用费', '金额': '0', '暂估价': '0', '类别' : '1.3'},
-        {'序号': '1.4', '名称': '企业管理费', '金额': '0', '暂估价': '0', '类别' : '1.4'},
-        {'序号': '1.5', '名称': '利润', '金额': '0', '暂估价': '0', '类别' : '1.5'}
-    ]})
-    result.append({'序号': '2', '名称': '措施项目', '金额': '0', '暂估价': '0', '类别' : '2', '__children': [
-        {'序号': '2.1', '名称': '单价措施项目费', '金额': '0', '暂估价': '0', '类别' : '2.1'},
-        {'序号': '2.2', '名称': '总价措施项目费', '金额': '0', '暂估价': '0', '类别' : '2.2', '__children' : [
-        {'序号': '2.2.1', '名称': '其中:安全文明施工措施费', '金额': '0', '暂估价': '0', '类别' : '2.2.1'},]
-        }
-       
-    ]})
-    result.append({'序号': '3', '名称': '其他项目', '金额': '0', '暂估价': '0', '类别' : '3', '__children': [
-        {'序号': '3.1', '名称': '其中:暂列金额', '金额': '0', '暂估价': '0', '类别' : '3.1'},
-        {'序号': '3.2', '名称': '其中:专业工程暂估价', '金额': '0', '暂估价': '0', '类别' : '3.2'},
-        {'序号': '3.3', '名称': '其中:计日工', '金额': '0', '暂估价': '0', '类别' : '3.3'},
-        {'序号': '3.4', '名称': '其中:总承包服务费', '金额': '0', '暂估价': '0', '类别' : '3.4'},
-        
-    ]})
-    result.append({'序号': '4', '名称': '规费', '金额': '0', '暂估价': '0', '类别' : '4', })
-    result.append({'序号': '5', '名称': '税金', '金额': '0', '暂估价': '0', '类别' : '5', })
-    result.append({'序号': '6', '名称': '工程造价', '金额': '0', '暂估价': '0', '类别' : '6', })
-
-    return result
-
-
-
-async def tbxx(client, biao_id):
-    db = client["baojia"]
-    collection = db["jingjibiao"]
-    document = await collection.find_one({'_id': ObjectId(biao_id)})
-    dxgcxx = document['Dxgcxx']
-    tbxx = document['TouBiaoXx']
-    tbxx['Tbzj'] = '0'
-    tbxx['Zgj'] = '0'
-    tbxx['Aqwmf'] = '0'
-    tbxx['Gf'] = '0'
-    
-    dwdx = {}##单位工程映射单项工程
-    for dxgc in dxgcxx:
-        dxgc['Aqwmf'] = '0'
-        dxgc['Gf'] = '0'
-        dxgc['Je'] = '0'
-        dxgc['Zgj'] = '0'
-        mc = dxgc['Dxgcmc']
-        Dwgc = dxgc['Dwgc']
-        for dwgc in Dwgc:
-            Dwgcbh = dwgc['Dwgcbh']
-            dwdx[Dwgcbh] = dxgc
-    collection = db['Dwgc']
-    async for post in collection.find({'biao_id': biao_id}):
-        bh = post['Dwgcbh']
-        dx = dwdx[bh]
-        bjhz = post['bjhz']
-        print('######################################################')
-        print(bjhz)
-        if len(bjhz) == 0:
-            pass
-        else:
-            qtxm = post['qtxm']
-            dx['Aqwmf'] = str(float(dx['Aqwmf']) + float(bjhz[1]['__children'][1]['__children'][0]['金额']))
-            dx['Gf'] = str(float(dx['Gf']) + float(bjhz[3]['金额']))
-            dx['Je'] = str(float(dx['Je']) + float(bjhz[5]['金额']))
-            dx['Zgj']= str(float(dx['Zgj']) + float(qtxm[1]['金额']))
-    for dxgc in dxgcxx:
-        tbxx['Tbzj'] = str(float(tbxx['Tbzj']) + float(dxgc['Je']))
-        tbxx['Zgj'] = str(float(tbxx['Zgj']) + float(dxgc['Zgj']))
-        tbxx['Aqwmf'] = str(float(tbxx['Aqwmf']) + float(dxgc['Aqwmf']))
-        tbxx['Gf'] = str(float(tbxx['Gf']) + float(dxgc['Gf']))
-    collection = db["jingjibiao"]
-
-
-    await collection.update_one({'_id': ObjectId(biao_id)}, {'$set': {'Dxgcxx': dxgcxx, 'TouBiaoXx' : tbxx}})
-
-
-
 
 
-        
 
 
-    
         
 
-    
-
 
-async def zongjiaDwgc(client, biao_id, bh):
-    db = client["baojia"]
-    djcs_sum = 0
-    collection = db["Djcs"]
-    async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}, {'__children': 0}):
-        djcs_sum = djcs_sum + float(post['合价'])
-    
-    collection = db['Dwgc']
-    document = await collection.find_one({'biao_id': biao_id, "Dwgcbh": bh}, {'rcjhz': 0})
-    qdbt = document['qdbt']
-    qdbt_addition = document['qdbt_addition']
-    bts = {}
-    distinguish = True
     
-    for item in qdbt_addition:
-        bts[item['Mc']] = 0
-    
-    collection = db["qdxm"]
-    qd_sum = 0
-    rgf_sum = 0
-    clf_sum = 0
-    jxf_sum = 0
-    glf_sum = 0
-    lr_sum = 0
-    fbrgycl_sum = 0
-    async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}, {'__children': 0}):
-        qd_sum = qd_sum + float(post['合价'])
-        rgf_sum = rgf_sum + float(post['数量']) * float(post['人工费'])
-        clf_sum = clf_sum + float(post['数量']) * float(post['材料费'])
-        jxf_sum = jxf_sum + float(post['数量']) * float(post['机械费'])
-        glf_sum = glf_sum + float(post['数量']) * float(post['管理费'])
-        lr_sum = lr_sum + float(post['数量']) * float(post['利润'])
-        if distinguish and post['bt'] in bts:
-            bts[post['bt']] = bts[post['bt']] + float(post['合价'])
-
-
-
-
-    sum = qd_sum + djcs_sum
-
-
-
-
-    fbrgycl = document['fbrgycl']
-    for entry in fbrgycl:
-        fbrgycl_sum = fbrgycl_sum + float(entry['合价'])
-    zjcs = document['zjcs']
-    def process(n):
-        n['计算基数'] = str(sum)
-        n['金额'] = float(sum) * float(n['费率']) / float(100)
-        if "__children" in n:
-            for entry in n['__children']:
-                entry['计算基数'] = str(sum)
-                entry['金额'] = float(sum) * float(entry['费率']) / float(100)
-        return n
-
-
-    result = [process(item) for item in zjcs]
-    for entry in result:
-        if '安全文明施工' in entry['名称']:
-            sum_ = 0
-            for child in entry['__children']:
-                sum_ = sum_ + float(child['金额'])
-            entry['金额'] = str(sum_)
-            entry['计算基数'] = str(sum_)
-    zjcs_sum = 0
-    for entry in result:
-        zjcs_sum = zjcs_sum + float(entry['金额'])
-    qtxm = document['qtxm']##dwgc qtxm
-    qtxm_sum = 0
-    for entry in qtxm:
-        qtxm_sum = qtxm_sum + float(entry['金额'])
-    gfsj = document['gfsj']
-    gf_sum = 0
-    sj_sum = 0
-    for item in gfsj:
-        if item['名称'] == '规费':
-            child = item['__children']
-            for children in child:
-                children['取费基数'] = str(sum + zjcs_sum + qtxm_sum)
-                children['金额'] = str(float(sum + zjcs_sum + qtxm_sum) * float(children['费率']) / float(100))
-                gf_sum = gf_sum + float(children['金额'])
-    for item in gfsj:
-        if item['名称'] == '规费':
-            item['取费基数'] = str(gf_sum)
-            item['金额'] = str(gf_sum)
-    for item in gfsj:
-        if item['名称'] == '税金':
-            item['取费基数'] = str(sum + zjcs_sum + qtxm_sum + gf_sum - fbrgycl_sum / float(1.01))
-            item['金额'] = float(item['取费基数']) * float(item['费率']) / float(100)
-            sj_sum = float(item['金额'])
-    for item in gfsj:
-        if item['名称'] == '合计':
-            item['取费基数'] = str(sj_sum + gf_sum)
-            item['金额'] = item['取费基数']
-
-    qtxm = document['qtxm']
-    zlje = 0
-    zygczgj = 0
-    jrg = 0
-    zcbfwf = 0
-    clzgj = 0
-    for entry in qtxm:
-        if entry['序号'] == '1':
-            zlje = entry['金额']
-        if entry['序号'] == '3':
-            jrg = entry['金额']
-        if entry['序号'] == '4':
-            zcbfwf = entry['金额']
-        if entry['序号'] == '2':
-            for child in entry['__children']:
-                if child['序号'] == '2.2':
-                    zygczgj = child['金额']
-                if child['序号'] == '2.1':
-                    clzgj = child['金额']
-    qtxm_sum = float(zlje) + float(zygczgj) + float(jrg) + float(zcbfwf) + float(clzgj)
-                
-
-
-
-
-
-    bjhz = bjhz_template()
-    for entry in bjhz:
-        if entry['序号'] == '1':
-            entry['金额'] = qd_sum
-            for child in entry['__children']:
-                if child['序号'] == '1.1':
-                    child['金额'] = str(rgf_sum)
-                if child['序号'] == '1.2':
-                    child['金额'] = str(clf_sum)
-                if child['序号'] == '1.3':
-                    child['金额'] = str(jxf_sum)
-                if child['序号'] == '1.4':
-                    child['金额'] = str(glf_sum)
-                if child['序号'] == '1.5':
-                    child['金额'] = str(lr_sum)
-        if entry['序号'] == '2':
-            entry['金额'] = str(djcs_sum + zjcs_sum)
-            for child in entry['__children']:
-                if child['序号'] == '2.1':
-                    child['金额'] = str(djcs_sum)
-                if child['序号'] == '2.2':
-                    child['金额'] = str(zjcs_sum)
-                    for grandchild in child['__children']:
-                        if grandchild['序号'] == '2.2.1':
-                            grandchild['金额'] = str(sum_)
-        if entry['序号'] == '3':
-            entry['金额'] = str(qtxm_sum)
-        if entry['序号'] == '4':
-            entry['金额'] = str(gf_sum)
-        if entry['序号'] == '5':
-            entry['金额'] = str(sj_sum)
-        if entry['序号'] == '6':
-            entry['金额'] = str(float(qd_sum) + float(djcs_sum) + float(zjcs_sum) + float(qtxm_sum) + float(gf_sum) + float(sj_sum))
         
 
-
-
     
-    collection = db['Dwgc']
-    if distinguish:
-        for entry in qdbt_addition:
-            entry['Je'] = str(bts[entry['Mc']])
 
 
-    
-    await collection.update_one({'biao_id': biao_id, "Dwgcbh": bh}, {'$set': {'zjcs': result, 'gfsj' : gfsj, 'bjhz': bjhz, 'qdbt_addition' : qdbt_addition}})
-    
 
 
 

+ 70 - 322
subdir/service.py

@@ -10,208 +10,11 @@ from pydantic import BaseModel
 import pandas as pd
 from numpy import float64
 
-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 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 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
 
 
 
@@ -228,134 +31,10 @@ def getQingdanTuijian(bh, bt, bm):
 
         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 getDjcs(root, id):
-    result = []
-    #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 == id:
-                    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
-    Djcs_parent = None
-    for child in Fywj:
-        if child.tag == 'DjCs':
-            Djcs_parent = child
-            break
-    
-    for child in Djcs_parent:
-        ##child is mx {
-        result.append({   
-
-                    "序号": child.attrib["Xh"], "清单编码": child.attrib["Bm"], "名称" : child.attrib["Mc"],
-                     "项目特征" : child.attrib["Xmtz"], 
-                    "计算规则" : child.attrib["Jsgz"], "单位" : child.attrib["Dw"], "数量" : child.attrib["Sl"], 
-                    "综合单价" : child.attrib["Zhdj"], "合价" : child.attrib["Zhhj"], "人工费" : child.attrib["Rgf"],
-                     "主材费" : child.attrib["Zcf"],
-                     "设备费" : child.attrib["Sbf"], "辅材费" : child.attrib["Fcf"], "材料费" : child.attrib["Clf"], 
-                    "机械费" : child.attrib["Jxf"], "管理费" : child.attrib["Glf"], "利润"  : child.attrib["Lr"],
-                     "暂估价" : child.attrib["Zgj"], "综合人工工日" : child.attrib["Zgr"] })
-
-        __children = []
-        zj_parent = None
-        for grandchild in child:
-            if grandchild.tag == "Csxdezj":
-                zj_parent = grandchild
-        
-        if zj_parent:
-            for entry in zj_parent:
-                __children.append({
-                    "序号": None, "清单编码": entry.attrib["Debm"], "名称" : entry.attrib["Mc"],
-                     "项目特征" : None, 
-                    "计算规则" : None, "单位" : entry.attrib["Dw"], "数量" : entry.attrib["DwQdSl"], 
-                    "综合单价" : entry.attrib["Dj"], "合价" : entry.attrib["Hj"], "人工费" : entry.attrib["Rgf"],
-                     "主材费" : entry.attrib["Zcf"],
-                     "设备费" : entry.attrib["Sbf"], "辅材费" : entry.attrib["Fcf"], "材料费" : entry.attrib["Clf"], 
-                    "机械费" : entry.attrib["Jxf"], "管理费" : entry.attrib["Glf"], "利润"  : entry.attrib["Lr"],
-                     "暂估价" : None, "综合人工工日" : None })
 
-        if len(__children) > 0:
-            result[-1]["__children"] = __children 
 
 
 
-    return result
-
 
 
 def getQdmx(root, bh, bt):
@@ -1142,7 +821,7 @@ def read_singledexilie_azfy(debh):
 
 def getDeXilie_azfy(value, id):
     if int(id) == 2075 or int(id) == 2080:
-        return "{\"Unnamed: 0\":{},\"id\":{},\"DEBH\":{},\"GCLMC\":{},\"GCLGG\":{},\"GCLRGR\":{},\"GCLCLF\":{},\"GCLJXF\":{},\"GCLRGF\":{},\"GCLGLF\":{},\"GLFFL\":{},\"GCLLR\":{},\"LRFL\":{},\"PBSL\":{},\"GCLJJ\":{},\"GCLSJDJ\":{},\"PBBH\":{},\"GCPBHJ\":{},\"DW\":{},\"PBDJ\":{},\"PBBHM\":{},\"GCLCLF1\":{},\"THMC\":{},\"YSDELBH\":{},\"THSL\":{},\"GLDE\":{},\"BZBH\":{},\"rglxh\":{},\"zhxs\":{},\"zmsm\":{},\"is_lock\":{},\"dejb\":{},\"sptfl\":{},\"work\":{},\"zhiyin\":{},\"qfbz\":{},\"ischaogao\":{},\"zmlx\":{},\"BH1\":{},\"BH2\":{},\"mcxz\":{},\"DeId\":{}}"
+        return "{\"Unnamed: 0\":{},\"id\":{},\"DEBH\":{},\"GCLMC\":{},\"GCLSJDJ\":{},\"DW\":{},\"DeId\":{}}"
     if int(id) == 2076:
         data = {'DW': ['项', '项', '项', '项', '项', '项', '项', '项', "项", "项", "项", "项", "项", "项", "项", "项"], 
                 'DEBH': ['2-F1', '2-F1', '3-F1', '3-F1', '4-F1',
@@ -1532,6 +1211,7 @@ def getDeXilie(value, id):
     else:
         gj = pd.read_csv("de/xsaz/JD_DanWeiGJ.csv")
         filtered = gj[gj["YSDELBH"]==int(index)]
+    filtered = filtered.drop(['BH1', 'BH2', "GCLCLF", "GCLCLF1", "GCLGG", "GCLGLF", "GCLJJ", "GCLJXF", "GCLLR", "GCLRGF", "GCLRGR", "GCPBHJ", "GLDE", "GLFFL", "LRFL", "PBBH", "PBBHM", "PBDJ", "PBSL", "THMC", "THSL", "dejb", "is_lock", "mcxz", "qfbz", "sptfl"], axis=1)
     return filtered.to_json(force_ascii=False)
 
 
@@ -1730,6 +1410,7 @@ def getSingleDeXilie_xsaz(debh):
                 clde_["SL"] = SL.item()
                 clde_["HJ"] = HJ.item()
                 clde.append(clde_)
+    filtered = filtered.drop(['BH1', 'BH2', "GCLCLF", "GCLCLF1", "GCLGG", "GCLGLF", "GCLJJ", "GCLJXF", "GCLLR", "GCLRGF", "GCLRGR", "GCLSJDJ", "GCPBHJ", "GLDE", "GLFFL", "LRFL", "PBBH", "PBBHM", "PBDJ", "PBSL", "THMC", "THSL", "dejb", "is_lock",  "mcxz", "qfbz",  "sptfl"], axis=1)
     return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
 
 
@@ -1857,6 +1538,7 @@ def getSingleDeXilie_xstj(debh):
                 clde_["SL"] = SL.item()
                 clde_["HJ"] = HJ.item()
                 clde.append(clde_)
+    filtered = filtered.drop(['BH1', 'BH2', "GCLCLF", "GCLCLF1", "GCLGG", "GCLGLF", "GCLJJ", "GCLJXF", "GCLLR", "GCLRGF", "GCLRGR", "GCLSJDJ", "GCPBHJ", "GLDE", "GLFFL", "LRFL", "PBBH", "PBBHM", "PBDJ", "PBSL", "THMC", "THSL", "dejb", "is_lock",  "mcxz", "qfbz",  "sptfl"], axis=1)
     return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
 
 
@@ -1981,6 +1663,7 @@ def getSingleDeXilie_yl(debh):
                 clde_["SL"] = SL.item()
                 clde_["HJ"] = HJ.item()
                 clde.append(clde_)
+    filtered = filtered.drop(['BH1', 'BH2', "GCLCLF", "GCLCLF1", "GCLGG", "GCLGLF", "GCLJJ", "GCLJXF", "GCLLR", "GCLRGF", "GCLRGR", "GCLSJDJ", "GCPBHJ", "GLDE", "GLFFL", "LRFL", "PBBH", "PBBHM", "PBDJ", "PBSL", "THMC", "THSL", "dejb", "is_lock",  "mcxz", "qfbz",  "sptfl"], axis=1)
     return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
 
 
@@ -2106,6 +1789,7 @@ def getSingleDeXilie_az(debh):
                 clde_["SL"] = SL
                 clde_["HJ"] = HJ
                 clde.append(clde_)
+    filtered = filtered.drop(['BH1', 'BH2', "GCLCLF", "GCLCLF1", "GCLGG", "GCLGLF", "GCLJJ", "GCLJXF", "GCLLR", "GCLRGF", "GCLRGR", "GCLSJDJ", "GCPBHJ", "GLDE", "GLFFL", "LRFL", "PBBH", "PBBHM", "PBDJ", "PBSL", "THMC", "THSL", "dejb", "is_lock",  "mcxz", "qfbz",  "sptfl"], axis=1)
     return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
 
 
@@ -2231,6 +1915,7 @@ def getSingleDeXilie_sz(debh):
                 clde_["SL"] = SL.item() if type(SL) == float64 else SL
                 clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
                 clde.append(clde_)
+    filtered = filtered.drop(['BH1', 'BH2', "GCLCLF", "GCLCLF1", "GCLGG", "GCLGLF", "GCLJJ", "GCLJXF", "GCLLR", "GCLRGF", "GCLRGR", "GCLSJDJ", "GCPBHJ", "GLDE", "GLFFL", "LRFL", "PBBH", "PBBHM", "PBDJ", "PBSL", "THMC", "THSL", "dejb", "is_lock",  "mcxz", "qfbz",  "sptfl"], axis=1)
     return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
         
         
@@ -2357,6 +2042,7 @@ def getSingleDeXilie_tj(debh):
                 clde_["SL"] = SL.item() if type(SL) == float64 else SL
                 clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
                 clde.append(clde_)
+    filtered = filtered.drop(['BH1', 'BH2', "GCLCLF", "GCLCLF1", "GCLGG", "GCLGLF", "GCLJJ", "GCLJXF", "GCLLR", "GCLRGF", "GCLRGR", "GCLSJDJ", "GCPBHJ", "GLDE", "GLFFL", "LRFL", "PBBH", "PBBHM", "PBDJ", "PBSL", "THMC", "THSL", "dejb", "is_lock",  "mcxz", "qfbz",  "sptfl"], axis=1)
     return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
 
 def getDwgc(root, id, Zylb):
@@ -2406,3 +2092,65 @@ def getDwgc(root, id, Zylb):
             print(child.tag)
             print("WARNING####################################################################")
     return result
+
+def getDjcs(root, id):
+    result = []
+    #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 == id:
+                    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
+    Djcs_parent = None
+    for child in Fywj:
+        if child.tag == 'DjCs':
+            Djcs_parent = child
+            break
+    
+    for child in Djcs_parent:
+        ##child is mx {
+        result.append({   
+
+                    "序号": child.attrib["Xh"], "清单编码": child.attrib["Bm"], "名称" : child.attrib["Mc"],
+                     "项目特征" : child.attrib["Xmtz"], 
+                    "计算规则" : child.attrib["Jsgz"], "单位" : child.attrib["Dw"], "数量" : child.attrib["Sl"], 
+                    "综合单价" : child.attrib["Zhdj"], "合价" : child.attrib["Zhhj"], "人工费" : child.attrib["Rgf"],
+                     "主材费" : child.attrib["Zcf"],
+                     "设备费" : child.attrib["Sbf"], "辅材费" : child.attrib["Fcf"], "材料费" : child.attrib["Clf"], 
+                    "机械费" : child.attrib["Jxf"], "管理费" : child.attrib["Glf"], "利润"  : child.attrib["Lr"],
+                     "暂估价" : child.attrib["Zgj"], "综合人工工日" : child.attrib["Zgr"] })
+        __children = []
+        zj_parent = None
+        for grandchild in child:
+            if grandchild.tag == "Csxdezj":
+                zj_parent = grandchild
+        
+        if zj_parent:
+            for entry in zj_parent:
+                __children.append({
+                    "序号": None, "清单编码": entry.attrib["Debm"], "名称" : entry.attrib["Mc"],
+                     "项目特征" : None, 
+                    "计算规则" : None, "单位" : entry.attrib["Dw"], "数量" : entry.attrib["DwQdSl"], 
+                    "综合单价" : entry.attrib["Dj"], "合价" : entry.attrib["Hj"], "人工费" : entry.attrib["Rgf"],
+                     "主材费" : entry.attrib["Zcf"],
+                     "设备费" : entry.attrib["Sbf"], "辅材费" : entry.attrib["Fcf"], "材料费" : entry.attrib["Clf"], 
+                    "机械费" : entry.attrib["Jxf"], "管理费" : entry.attrib["Glf"], "利润"  : entry.attrib["Lr"],
+                     "暂估价" : None, "综合人工工日" : None })
+
+        if len(__children) > 0:
+            result[-1]["__children"] = __children 
+
+
+
+    return result
+

+ 2 - 2
subdir/util.py

@@ -31,8 +31,8 @@ def huizongrcj_order(data):
     
     huizong = {}
     result = [
-    [ "ID", "编码", "名称", "规格型号", "单位", "数量", "价", "合价", "产地", 
-    "供应厂商", "人材机类别", "主要材料标志", "主材标志", "设备标志", "甲供标志", "暂估价标志"]]
+    ["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
+    "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
     left = []
     for entry in data:
         bm = entry[1]