浏览代码

fix_rcjhz

Xiaopeng Zhang 5 月之前
父节点
当前提交
30d16c906a
共有 3 个文件被更改,包括 158 次插入46 次删除
  1. 5 2
      README
  2. 100 44
      subdir/db.py
  3. 53 0
      subdir/util.py

+ 5 - 2
README

@@ -7,13 +7,16 @@ Feature
 可以对人材机补充(安装的时候用来补充主材)
 可以选择附注
 可以选择替换预拌砂浆
-对于人材机汇总表,可以改价格(不包括安装费用的子目
+对于人材机汇总表,可以改价格(不包括安装费用的子目和回程费)
 对于费率表,可以改费率
+对于单价措施,可以删除,可以添加单项定额,目前不支持算式定额,只能用定额树,不支持替换人材机,不支持修改定额名称
+单价措施支持附注,不支持预拌砂浆,不支持补充人材机,支持百分比人材机(回程费),
+不支持安装费用????
 
 导入功能
 附注disable
 预拌砂浆disable
-补充enable这个功能
+补充人材机enable这个功能
 安装费用用单位是元的另外一套体系
 
 TODO

+ 100 - 44
subdir/db.py

@@ -1649,6 +1649,7 @@ async def applyFL(client, id, data):
 
 async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz):
     db = client["baojia"]
+    rcjhz = []
     collection = db["qdxm"]
     async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
         if "__children" not in post:
@@ -1698,14 +1699,7 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
                 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']
-            for i in range(1, len(qdrcj)):
-                entry = qdrcj[i]
-                if entry[1] == bm and entry[2] == mingcheng and entry[4] == danwei:
-                    entry[5] = jiage
-                    hanliang = entry[10]
-                    entry[11] = str(float(jiage) * float(hanliang))
+           
             post['综合单价'] = 0
             post['合价'] = 0
             post['人工费'] = 0
@@ -1788,7 +1782,23 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
                            dercj[j][11] = float(post['__children'][i]['综合单价']) * float(dercj[j][10]) / float(100)
                        
                     
-                
+            qdrcj = []
+            for i in range(len(post["__children"])):
+                dercj = post["__children"][i]['dercj']
+                sl = post["__children"][i]['数量']
+                for entry in dercj:
+                    if '000FE' in entry[1] and entry[4] == '%': ##azfy
+                        qdrcj.append(entry)
+                    elif '00EXP001' in entry[1] and entry[4] == '%': ##回程费
+                        qdrcj.append(entry)
+                    elif '99EXP007' in entry[1] and entry[4] == '%': ##回程费
+                        qdrcj.append(entry)
+                    elif '31130104' in entry[1] and entry[4] == '%': ##回程费
+                        qdrcj.append(entry)
+                    elif entry[10] != '含量':
+                        entry[10] = float(sl) * float(entry[10])
+                        qdrcj.append(entry)
+            post["rcj"] = util.huizongrcj_order(qdrcj)
             
             post['综合单价'] = 0
             post['合价'] = 0
@@ -1814,6 +1824,12 @@ 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:]
+        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}):
         if "__children" not in post:
@@ -1843,6 +1859,29 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
                 elif int(rcj[8]) == 3:
                     dejxf = dejxf + float(rcj[11])
             if hitde:
+                for i in range(1, len(dercj)):
+                    rcj = dercj[i]
+                    if rcj[1] == '00EXP001' and rcj[4] == '%':##//回程费占人工费
+                        rcj[11] = float(rcj[10]) * dergf / float(100)
+                    if rcj[1] == '99EXP007' and rcj[4] == '%':##//回程费占机械费
+                        rcj[11] = float(rcj[10]) * dejxf / float(100)
+                    if rcj[1] == '31130104' and rcj[4] == '%':##//回程费占材料费
+                        rcj[11] = float(rcj[10]) * declf / float(100)
+                dergf = 0
+                declf = 0
+                dejxf = 0
+                for i in range(1, len(dercj)):
+                    rcj = dercj[i]
+                    
+                    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])
+ 
+
+
                 entry['人工费'] = str(dergf)
                 entry['辅材费'] = str(declf)
                 entry['材料费'] = str(declf)
@@ -1859,48 +1898,65 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
                 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 and entry[2] == mingcheng and entry[4] == danwei:
-                    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)
+            qdrcj = []
+            for i in range(len(post["__children"])):
+                dercj = post["__children"][i]['dercj']
+                sl = post["__children"][i]['数量']
+                for entry in dercj:
+                    if '000FE' in entry[1] and entry[4] == '%': ##azfy
+                        qdrcj.append(entry)
+                    elif '00EXP001' in entry[1] and entry[4] == '%': ##回程费
+                        qdrcj.append(entry)
+                    elif '99EXP007' in entry[1] and entry[4] == '%': ##回程费
+                        qdrcj.append(entry)
+                    elif '31130104' in entry[1] and entry[4] == '%': ##回程费
+                        qdrcj.append(entry)
+                    elif entry[10] != '含量':
+                        entry[10] = float(sl) * float(entry[10])
+                        qdrcj.append(entry)
+            post["rcj"] = util.huizongrcj_order(qdrcj)
+            post['综合单价'] = 0
+            post['合价'] = 0
+            post['人工费'] = 0
+            post['主材费'] = 0
+            post['设备费'] = 0
+            post['辅材费'] = 0
+            post['材料费'] = 0
+            post['机械费'] = 0
             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))
+            for i in range(len(post["__children"])):
+                post['综合单价'] += float(post['__children'][i]['数量']) * float(post['__children'][i]['综合单价'])
+                post['合价'] += float(post['__children'][i]['合价'])
+                post['人工费'] += float(post['__children'][i]['数量']) * float(post['__children'][i]['人工费'])
+                post['主材费'] += float(post['__children'][i]['数量']) * float(post['__children'][i]['主材费'])
+                post['设备费'] += float(post['__children'][i]['数量']) * float(post['__children'][i]['设备费'])
+                post['辅材费'] += float(post['__children'][i]['数量']) * float(post['__children'][i]['辅材费'])
+                post['材料费'] += float(post['__children'][i]['数量']) * float(post['__children'][i]['材料费'])
+                post['机械费'] += float(post['__children'][i]['数量']) * float(post['__children'][i]['机械费'])
+                post['管理费'] += float(post['__children'][i]['数量']) * float(post['__children'][i]['管理费'])
+                post['利润'] += float(post['__children'][i]['数量']) * float(post['__children'][i]['利润'])
+            
+            
             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:]
+        for entry in qdrcj:
+            if entry[4] != '%':
+                entry[10] = float(entry[10]) * float(post['数量'])
+        rcjhz = rcjhz + qdrcj
+    newHuizong = util.huizongrcj(rcjhz)
     collection = db["Dwgc"]
     document = await collection.find_one({'biao_id': biao_id, "Dwgcbh": bh})
-    hz = document['rcjhz']
-    for entry in hz:
-        if entry[1] == bm and entry[2] == mingcheng and entry[4] == danwei:
-            entry[6] = jiage
-            entry[7] = float(jiage) * float(entry[5])
-    await collection.update_one({'biao_id': biao_id, "Dwgcbh": bh}, {'$set': {'rcjhz': hz}})
+    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 newHuizong
 
 
 

+ 53 - 0
subdir/util.py

@@ -27,6 +27,50 @@ def indexrcj(rcjhz, rcjarray):
     ##raise Exception("not found rcjid")
     return ""
 
+def huizongrcj_order(data):
+    
+    huizong = {}
+    result = [
+    [ "ID", "编码", "名称", "规格型号", "单位", "数量", "单价", "合价", "产地", 
+    "供应厂商", "人材机类别", "主要材料标志", "主材标志", "设备标志", "甲供标志", "暂估价标志"]]
+    left = []
+    for entry in data:
+        bm = entry[1]
+        name = entry[2]
+        danwei = entry[4]
+        if '000FE' in bm and danwei == '%': ##azfy
+            left.append(entry)
+            continue
+        if '00EXP001' in bm and danwei == '%': ##azfy
+            left.append(entry)
+            continue
+        if '99EXP007' in bm and danwei == '%': ##azfy
+            left.append(entry)
+            continue
+        if '31130104' in bm and danwei == '%': ##azfy
+            left.append(entry)
+            continue
+        key = bm + name + danwei
+        if key in huizong:
+            huizong[key].append(entry)
+        else:
+            huizong[key] = [entry]
+    for key,value in huizong.items():
+        result_hl = 0
+        for i in range(0, len(value)):
+            result_hl = result_hl + float(value[i][10])
+        result_dj = float(value[0][5])
+        result_hj = result_hl * result_dj
+        result.append([value[0][0], value[0][1], value[0][2], value[0][3], value[0][4], 
+                       value[0][5],value[0][6], value[0][7], value[0][8], value[0][9], result_hl,
+                           result_hj, value[0][12],value[0][13],
+                       value[0][14], value[0][15],  ])
+    for entry in left:
+        result.append([entry[0], entry[1], entry[2], entry[3], entry[4], entry[5],
+                       entry[6], entry[7], entry[8], entry[9], entry[10], entry[11],
+                       entry[12], entry[13], entry[14], entry[15]])
+    return result
+
 def huizongrcj(data):
     
     huizong = {}
@@ -41,6 +85,15 @@ def huizongrcj(data):
         if '000FE' in bm and danwei == '%': ##azfy
             left.append(entry)
             continue
+        if '00EXP001' in bm and danwei == '%': ##azfy
+            left.append(entry)
+            continue
+        if '99EXP007' in bm and danwei == '%': ##azfy
+            left.append(entry)
+            continue
+        if '31130104' in bm and danwei == '%': ##azfy
+            left.append(entry)
+            continue
         key = bm + name + danwei
         if key in huizong:
             huizong[key].append(entry)