Przeglądaj źródła

support tiaojia

Xiaopeng Zhang 6 miesięcy temu
rodzic
commit
49bc052e21
8 zmienionych plików z 123 dodań i 17 usunięć
  1. 2 2
      front/src/App2.js
  2. 4 1
      front/src/Djcs2.js
  3. 4 1
      front/src/Qingdan2.js
  4. 4 2
      front/src/Rcjhz.js
  5. 5 3
      front/src/Service.js
  6. 3 1
      main.py
  7. 62 7
      subdir/db.py
  8. 39 0
      subdir/util.py

+ 2 - 2
front/src/App2.js

@@ -330,9 +330,9 @@ const MUI_X_PRODUCTS = [
     };
 
 
-    const tiaojiaCallback = (bh, bm, jiage) => {
+    const tiaojiaCallback = (bh, bm, mingcheng, danwei, jiage) => {
       setOpen(true); 
-      Service.tiaojia(location['id'], bh, bm, jiage).then(x=>{
+      Service.tiaojia(location['id'], bh, bm, mingcheng, danwei, jiage).then(x=>{
         
         setOpen(false);
       });

+ 4 - 1
front/src/Djcs2.js

@@ -160,9 +160,12 @@ export default function Djcs2({name, bh, rgde, jxde, clde, beizhu, beizhuFK, cli
      
     registerRenderer('customStylesRenderer', (hotInstance, TD, row, column,  prop, value, ...rest) => {
          let newValue = value; 
-          if ((column == 10 || column == 11 || column == 5) && row > 0) {
+          if ((column == 11 || column == 5) && row > 0) {
             newValue = Number(value).toFixed(2).toString();
          }
+         if (column == 10 && row > 0) {
+          newValue = Number(value).toFixed(4).toString();
+         }
          textRenderer(hotInstance, TD, row, column, prop, newValue, ...rest);
          for (let i = 0; i < highlight.current.length; i++) {
           let entry = highlight.current[i];

+ 4 - 1
front/src/Qingdan2.js

@@ -66,8 +66,11 @@ registerAllModules();
 export default function Qingdan2({name, bh, bt, rgde, jxde, clde, beizhu/*后台传回来的附注信息,要整理后才能成为展示用的行*/ , beizhuFK, clickCallback, loadingCallback, dingeclick, tihuanCallback, tihuanClick}) {
      registerRenderer('customStylesRenderer', (hotInstance, TD, row, column, prop, value, ...rest) => {
           let newValue = value; 
-          if ((column == 10 || column == 11 || column == 5) && row > 0) {
+          if (( column == 11 || column == 5) && row > 0) {
             newValue = Number(value).toFixed(2).toString();
+         }
+         if (column == 10 && row > 0) {
+          newValue = Number(value).toFixed(4).toString();
          }
           textRenderer(hotInstance, TD, row, column, prop, newValue, ...rest);
          for (let i = 0; i < highlight.current.length; i++) {

+ 4 - 2
front/src/Rcjhz.js

@@ -65,7 +65,9 @@ export default function Rcjhz({id, bh, tiaojiaCallback}) {
                     {title:"名称", field:"名称", width:150, headerSort:false, formatter:"textarea", headerFilter:"input"}, //hide this column first
                     {title:"规格型号", field:"规格型号", width:70 , headerSort:false, formatter:"textarea"},
                     {title:"单位", field:"单位", width:50, headerSort:false},
-                    {title:"数量", field:"数量", width:100, headerSort:true, sorter:"number" },
+                    {title:"数量", field:"数量", width:100, headerSort:true, sorter:"number", formatter:"money", formatterParams:{
+                      precision:4,
+                  } },
                     {title:"单价", field:"单价", width:100, headerSort:true, sorter:"number", formatter:"money", editor: "input"},
                     {title:"合价", field:"合价", width:100, headerSort:true, sorter:"number", formatter:"money"},
                     {title:"产地", field:"产地", width:50, headerSort:false, },
@@ -96,7 +98,7 @@ export default function Rcjhz({id, bh, tiaojiaCallback}) {
          let sl = newData['数量'];
          newData['合价'] = Number(newDj) * Number(sl);
          myTable.current.updateData([newData]);
-         tiaojiaCallback(bh, newData['编码'], newDj);
+         tiaojiaCallback(bh, newData['编码'], newData['名称'], newData['单位'], newDj);
          
          
          

+ 5 - 3
front/src/Service.js

@@ -932,7 +932,7 @@ async generateQingdanTuijian(name, bh, bt, bm) {
         }
     }
 
-    async tiaojia(biao_id, bh, bm, jiage) {
+    async tiaojia(biao_id, bh, bm, mingcheng, danwei, jiage) {
         let glf = "";
         let lr = "";
         let bz = 0;//changgui
@@ -955,6 +955,8 @@ async generateQingdanTuijian(name, bh, bt, bm) {
                     "biao_id": biao_id,
                     "bh": bh,
                     "bm": bm,
+                    "mingcheng": mingcheng,
+                    "danwei" : danwei, 
                     "jiage": jiage,
                     "glf" : glf,
                     "lr" : lr,
@@ -1436,7 +1438,7 @@ async generateQingdanTuijian(name, bh, bt, bm) {
         let de = qd["_children"].filter(x=>x['key'] == row)[0];
         if (de.hasOwnProperty("rcjdg")) {//新数据
             for (let i = 1; i < de['rcjdg'].length; i++) {
-                de['rcjdg'][i][5] = data[i][5];//更新单价
+                de['rcjdg'][i][5] = data[i][5];//更新单价,底稿的单价不是很需要同步(在人才机汇总修改价格)
                 /****ToDo 更新其他字段 */
                 if (de['rcjdg'][i][2] == data[i][2]) {//更新名称
                     
@@ -1571,7 +1573,7 @@ async generateQingdanTuijian(name, bh, bt, bm) {
         let origin = de['dercj'];
         let change = false;
         for(let i = 1; i < data.length; i++) {
-            let before = origin[i][10];
+            let before = origin[i][10];//含量
             let after = data[i][10];
             if (Number(before) - Number(after) < 0.0001 && Number(before) - Number(after) > -0.0001) {
                 //no change

+ 3 - 1
main.py

@@ -141,6 +141,8 @@ class Tiaojia(BaseModel):
     biao_id: str
     bh: str
     bm: str
+    mingcheng: str
+    danwei: str
     jiage: str
     glf: str
     lr: str
@@ -496,7 +498,7 @@ async def tiaojia(r: Tiaojia):
         glf = '0'
     if r.lr == "":
         lr = '0'
-    return await db.tiaojia(client, r.biao_id, r.bh, r.bm, r.jiage, glf, lr, r.bz)
+    return await db.tiaojia(client, r.biao_id, r.bh, r.bm, r.mingcheng, r.danwei, r.jiage, glf, lr, r.bz)
 
 
 

+ 62 - 7
subdir/db.py

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

+ 39 - 0
subdir/util.py

@@ -0,0 +1,39 @@
+import xml.etree.ElementTree as ET
+from typing import Union
+from fastapi import FastAPI
+import os
+import uuid
+import re
+from fastapi.middleware.cors import CORSMiddleware
+from pydantic import BaseModel
+import pandas as pd
+from numpy import float64
+
+def huizongrcj(data):
+    huizong = {}
+    result = [
+    [ "ID", "编码", "名称", "规格型号", "单位", "数量", "单价", "合价", "产地", 
+    "供应厂商", "人材机类别", "主要材料标志", "主材标志", "设备标志", "甲供标志", "暂估价标志"]]
+    for entry in data:
+        bm = entry[1]
+        name = entry[2]
+        danwei = entry[4]
+        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], result_hl,
+                       value[0][5], result_hj, value[0][6], value[0][7], value[0][8], value[0][13],
+                       value[0][14], value[0][15], value[0][9], value[0][12]])
+    return result
+
+    
+
+