Selaa lähdekoodia

fix qdbt logic, need continue fix build function

Xiaopeng Zhang 6 kuukautta sitten
vanhempi
commit
89446c6618
2 muutettua tiedostoa jossa 256 lisäystä ja 28 poistoa
  1. 140 16
      subdir/db.py
  2. 116 12
      subdir/service.py

+ 140 - 16
subdir/db.py

@@ -7,7 +7,73 @@ from datetime import datetime
 
 
 ###############helper##################
+
+def getDingercj_default(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 == "Qdmx" and 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 getDingercj_(root, bh, bt, qdbm, debm):
+    if bt == 'Default':
+        return getDingercj_default(root, bh, bt, qdbm, debm)
     result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
     "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
     #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
@@ -82,11 +148,72 @@ def getDingercj_(root, bh, bt, qdbm, debm):
         ])
 
     return result
+
+
+def getQingdanrcj_default(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 == "Qdmx" and 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 getQingdanrcj_(root, bh, bt, bm):
-    print("getQingdanrcj_")
-    print(bh)
-    print(bt)
-    print(bm)
+    if bt == 'Default':
+        return getQingdanrcj_default(root, bh, bt, bm)
+    
     result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
     "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
     #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
@@ -408,10 +535,10 @@ async def resolve(data, client):
         
         bts = service.getQdxm(root, entry["bh"])
         for bt in bts:
-            print("###################")
-            print(entry['bh'])
-            print(bt)
-            qdmx = service.getQdmx(root, entry["bh"], bt)
+            if bt == 'Default':
+                qdmx = service.getQdmx_default(root, entry["bh"], bt)
+            else:
+                qdmx = service.getQdmx(root, entry["bh"], bt)
             for qd in qdmx:
                 qd["DogNum"] = entry["num"]
                 qd["Dwgcbh"] = entry["bh"]
@@ -1742,13 +1869,10 @@ async def zongjiaDwgc(client, biao_id, bh):
     qdbt = document['qdbt']
     qdbt_addition = document['qdbt_addition']
     bts = {}
-    distinguish = False
-    if 'Default' in qdbt:
-        pass
-    else:
-        distinguish = True
-        for item in qdbt_addition:
-            bts[item['Mc']] = 0
+    distinguish = True
+    
+    for item in qdbt_addition:
+        bts[item['Mc']] = 0
     
     collection = db["qdxm"]
     qd_sum = 0
@@ -1765,7 +1889,7 @@ async def zongjiaDwgc(client, biao_id, bh):
         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:
+        if distinguish and post['bt'] in bts:
             bts[post['bt']] = bts[post['bt']] + float(post['合价'])
 
 

+ 116 - 12
subdir/service.py

@@ -355,6 +355,8 @@ def getDjcs(root, id):
 
     return result
 
+
+
 def getQdmx(root, bh, bt):
     result = []
     #result = [["序号", "清单编码", "名称", "项目特征", "计算规则", "单位", "数量", "综合单价", "合价", "人工费", "主材费", "设备费", "辅材费", "材料费", "机械费", "管理费", "利润" , "暂估价", "综合人工工日", "备注" ]]
@@ -377,8 +379,7 @@ def getQdmx(root, bh, bt):
     container = None
     for child in Fywj:
         ##child is mx
-        print(child.attrib["Mc"])
-        print(bt)
+        
 
         if child.tag == "QdBt":
             if child.attrib["Mc"] == bt:
@@ -386,18 +387,17 @@ def getQdmx(root, bh, bt):
                 for grandchild in child:
                     count = count + 1
                 if count > 0:
-                    print("############hit##########")
+                    
                     container = child
                     break
-    print("##########container#########")
-    print(container)
+   
+    
     if  container == None:
         container = Fywj
-    print("##########container#########")
-    print(container)
+    
+    
     for child in container:
-        print("##############child##########")
-        print(child)
+        
         #result = [["序号", "清单编码", "名称", "项目特征", "计算规则", "单位", "数量", "综合单价", "合价", "人工费", "主材费",
         #  "设备费", "辅材费", "材料费", "机械费", "管理费", "利润" , "暂估价", "综合人工工日", "备注" ]]
         result.append({
@@ -472,6 +472,106 @@ def getQdmx(root, bh, bt):
 
     return result
 
+def getQdmx_default(root, bh, bt):
+    result = []
+    #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 == 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
+    container = None
+    for child in Fywj:
+        ##child is mx
+        
+
+        if child.tag == "Qdmx":
+
+        #result = [["序号", "清单编码", "名称", "项目特征", "计算规则", "单位", "数量", "综合单价", "合价", "人工费", "主材费",
+        #  "设备费", "辅材费", "材料费", "机械费", "管理费", "利润" , "暂估价", "综合人工工日", "备注" ]]
+            result.append({
+            "操作" : "",
+            "序号": child.attrib["Xh"], "清单编码" : child.attrib["Qdbm"], "名称" : 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"],
+            "备注" : child.attrib["Bz"]}
+            )
+            for child_zj in child:
+                if child_zj.tag == "Qdxdezj":
+                    for child_mx in child_zj:
+                        if child_mx.tag == "QdxdezjMx":
+                            parent = result[-1]
+                            if "__children" in parent:
+                                parent["__children"].append({
+                                "操作" : "",
+                                "序号": None, "清单编码" : child_mx.attrib["Debm"], "名称" : child_mx.attrib["Mc"],"项目特征" : None,
+                                "计算规则" : None,
+                                "单位" : child_mx.attrib["Dw"],
+                                "数量": child_mx.attrib["DwQdSl"],
+                                "综合单价" : child_mx.attrib["Dj"],
+                                "合价" : child_mx.attrib["Hj"],
+                                "人工费": child_mx.attrib["Rgf"],
+                                "主材费" : child_mx.attrib["Zcf"],
+                                "设备费": child_mx.attrib["Sbf"],
+                                "辅材费": child_mx.attrib["Fcf"],
+                                "材料费" : child_mx.attrib["Clf"],
+                                "机械费" : child_mx.attrib["Jxf"],
+                                "管理费": child_mx.attrib["Glf"],
+                                "利润": child_mx.attrib["Lr"],
+                                "暂估价" : None,
+                                "综合人工工日" : None,
+                                "备注" : None}
+
+                            )
+                            else:
+                                parent["__children"] = [{
+                                "操作" : "",
+                                "序号": None, "清单编码" : child_mx.attrib["Debm"], "名称" : child_mx.attrib["Mc"],"项目特征" : None,
+                                "计算规则" : None,
+                                "单位" : child_mx.attrib["Dw"],
+                                "数量": child_mx.attrib["DwQdSl"],
+                                "综合单价" : child_mx.attrib["Dj"],
+                                "合价" : child_mx.attrib["Hj"],
+                                "人工费": child_mx.attrib["Rgf"],
+                                "主材费" : child_mx.attrib["Zcf"],
+                                "设备费": child_mx.attrib["Sbf"],
+                                "辅材费": child_mx.attrib["Fcf"],
+                                "材料费" : child_mx.attrib["Clf"],
+                                "机械费" : child_mx.attrib["Jxf"],
+                                "管理费": child_mx.attrib["Glf"],
+                                "利润": child_mx.attrib["Lr"],
+                                "暂估价" : None,
+                                "综合人工工日" : None,
+                                "备注" : None}]
+
+
+
+    return result
+
 
 
 
@@ -508,7 +608,7 @@ def getQdxm_addition(root, id):
 
 
 
-def getQdxm(root, id):
+def getQdxm(root, id):###qdxm下面既有qdmx,也有qdbt,qdbt可能为空
     result = []
     #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
     item = None
@@ -529,14 +629,18 @@ def getQdxm(root, id):
     
     for child in Fywj:
         ##child is mx
+        if child.tag == 'Qdmx':
+            if 'Default' in result:
+                pass
+            else:
+                result.append('Default')
         if child.tag == "QdBt":
             count = 0
             for grandchild in child:
                 count = count + 1
             if count > 0:
                 result.append(child.attrib["Mc"])
-    if len(result) == 0:
-        result.append("Default")
+    
     return result
 
 def getZjcs(root, id):