Xiaopeng Zhang пре 6 месеци
родитељ
комит
57b5f057f7
6 измењених фајлова са 480 додато и 33 уклоњено
  1. 2 0
      README
  2. 39 8
      front/src/App2.js
  3. 124 0
      front/src/Rcjhz.js
  4. 64 1
      front/src/Service.js
  5. 22 0
      main.py
  6. 229 24
      subdir/db.py

+ 2 - 0
README

@@ -1,2 +1,4 @@
 JD_PeiBiF 表很有用,它可以用来找一个材料的组成。
 举个例子,810078NT3 是陶粒混凝土CL20,他是由中沙,水泥,陶粒组成,这个关系在JD_PeiBiF立面可以查到·
+TODO
+回程费 按照百分比算的

+ 39 - 8
front/src/App2.js

@@ -24,6 +24,7 @@ import Zjcs from './Zjcs';
 import Djcs2 from './Djcs2';
 import Service from './Service';
 import Qufei from './Qufei';
+import Rcjhz from './Rcjhz';
 import {useLocation, useParams} from "react-router";
 import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
 import Typography from '@mui/material/Typography';
@@ -218,6 +219,7 @@ const MUI_X_PRODUCTS = [
     const [qingdan, setQingdan] = React.useState(false);
     const [cuoshi, setCuoshi] = React.useState(false);
     const [qufei, setQufei] = React.useState(false);
+    const [rcjhz, setRcjhz] = React.useState(false);
     const [qdbt, setQdbt] = React.useState([]);
     const [qdbh, setQdbh] = React.useState(null);
     const [value, setValue] = React.useState('1');
@@ -327,6 +329,15 @@ const MUI_X_PRODUCTS = [
         tihuanRowRef.current = row;
     };
 
+
+    const tiaojiaCallback = (bh, bm, jiage) => {
+      setOpen(true); 
+      Service.tiaojia(location['id'], bh, bm, jiage).then(x=>{
+        
+        setOpen(false);
+      });
+    };
+
     const handleClose = () => {
       setDopen(false);
     };
@@ -647,6 +658,7 @@ const MUI_X_PRODUCTS = [
                   setQingdan(false);
                   setCuoshi(false);
                   setQufei(false);
+                  setRcjhz(false);
                   setColumnHeaders(["序号", "名称", "金额", "暂估价", "类别"]);
                 });
         }
@@ -659,6 +671,7 @@ const MUI_X_PRODUCTS = [
                   setQingdan(false);
                   setCuoshi(false);
                   setQufei(false);
+                  setRcjhz(false);
                   setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
                 });
 
@@ -674,6 +687,7 @@ const MUI_X_PRODUCTS = [
                   setQdbt(x);
                   setQdbh(id);
                   setQufei(false);
+                  setRcjhz(false);
                   //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
                 });
 
@@ -687,6 +701,7 @@ const MUI_X_PRODUCTS = [
           setCuoshi(true);
           setDwgc(id);
           setQufei(false);
+          setRcjhz(false);
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
 
         }
@@ -701,6 +716,7 @@ const MUI_X_PRODUCTS = [
                   setQingdan(false);
                   setCuoshi(false);
                   setQufei(false);
+                  setRcjhz(false);
                   setColumnHeaders(["序号", "名称", "金额", "项目类别", "备注"]);
                 });
 
@@ -716,6 +732,7 @@ const MUI_X_PRODUCTS = [
                   setQingdan(false);
                   setCuoshi(false);
                   setQufei(false);
+                  setRcjhz(false);
                 });
 
         }
@@ -730,6 +747,7 @@ const MUI_X_PRODUCTS = [
                   setQingdan(false);
                   setCuoshi(false);
                   setQufei(false);
+                  setRcjhz(false);
                 });
 
         }
@@ -744,6 +762,7 @@ const MUI_X_PRODUCTS = [
                   setQingdan(false);
                   setCuoshi(false);
                   setQufei(false);
+                  setRcjhz(false);
                 });
 
         }
@@ -758,6 +777,7 @@ const MUI_X_PRODUCTS = [
                   setQingdan(false);
                   setCuoshi(false);
                   setQufei(false);
+                  setRcjhz(false);
                 });
 
         }
@@ -766,13 +786,17 @@ const MUI_X_PRODUCTS = [
           let id = itemId.match(regex)[0];     
           setValue("1");
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
-          Service.generateRencaijihuizong2(location["id"], id).then(x=>{
-                  setDetail(x);
+          //Service.generateRencaijihuizong2(location["id"], id).then(x=>{
+                  //setDetail(x);
+                  setRcjhz(true);
                   setNest(false);
                   setQingdan(false);
                   setCuoshi(false);
                   setQufei(false);
-                });
+                  setQdbh(id);
+                //}
+                //)
+                ;
 
         }
         else if (itemId.includes("TouBiaoXx")) {
@@ -782,6 +806,7 @@ const MUI_X_PRODUCTS = [
             setDetail(x);
             setNest(false);
             setQufei(false);
+            setRcjhz(false);
         });
 
         }
@@ -901,6 +926,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(true);
                   setQingdan(false);
                   setCuoshi(false);
+                  setRcjhz(false);
                  }}>费率</Button>
 
             
@@ -909,8 +935,13 @@ const MUI_X_PRODUCTS = [
 
             </Grid>
             <Grid size={9}>
+              {!nest && !qingdan && !cuoshi && !qufei && rcjhz && <Rcjhz 
+              id={location['id']} 
+              bh={qdbh}
+              tiaojiaCallback={tiaojiaCallback}
+              />}
              
-            {!nest && !qingdan && !cuoshi && !qufei && <HotTable nestedRows={false}
+            {!nest && !qingdan && !cuoshi && !qufei && !rcjhz && <HotTable nestedRows={false}
                     data={detail
                     }
                     rowHeaders={true}
@@ -923,7 +954,7 @@ const MUI_X_PRODUCTS = [
                     autoWrapCol={false}
                     licenseKey="non-commercial-and-evaluation" // for non-commercial use only
                   />}
-            {nest && !qingdan && !cuoshi && !qufei && <HotTable nestedRows={true}
+            {nest && !qingdan && !cuoshi && !qufei && !rcjhz && <HotTable nestedRows={true}
                     data={nestDetail
                     }
                     readOnly={true}
@@ -938,10 +969,10 @@ const MUI_X_PRODUCTS = [
                     autoWrapCol={false}
                     licenseKey="non-commercial-and-evaluation" // for non-commercial use only
                   />}
-            {!qingdan && !cuoshi && qufei && <Qufei id={location['id']} qufeiCallback={qufeiCallback}
+            {!qingdan && !cuoshi && qufei && !rcjhz && <Qufei id={location['id']} qufeiCallback={qufeiCallback}
                   />}
 
-            {!nest && qingdan && !cuoshi && !qufei &&  <TabContext value={value}>
+            {!nest && qingdan && !cuoshi && !qufei && !rcjhz &&  <TabContext value={value}>
                    <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
                       <TabList scrollButtons='auto' 
                               variant="scrollable"
@@ -969,7 +1000,7 @@ const MUI_X_PRODUCTS = [
                      </TabPanel>
                       )}
                 </TabContext>}
-            {!nest && !qingdan && cuoshi && !qufei &&  <TabContext value={value}>
+            {!nest && !qingdan && cuoshi && !qufei && !rcjhz &&  <TabContext value={value}>
                    <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
                       <TabList scrollButtons='auto' 
                               variant="scrollable"

+ 124 - 0
front/src/Rcjhz.js

@@ -0,0 +1,124 @@
+import * as React from 'react';
+import Box from "@mui/material/Box";
+import 'handsontable/dist/handsontable.full.min.css';
+//import 'handsontable/styles/ht-theme-main.min.css';
+import { HandsonTable } from 'handsontable/base';
+import {HotTable} from "@handsontable/react";
+//import { registerAllModules } from 'handsontable/registry';
+import {RichTreeView } from "@mui/x-tree-view/RichTreeView";
+import { Grid } from '@mui/material';
+import Tab from "@mui/material/Tab";
+import TabContext from "@mui/lab/TabContext";
+import TabList from "@mui/lab/TabList";
+import TabPanel from "@mui/lab/TabPanel";
+import Stack from "@mui/material/Stack";
+//import { registerPlugin, NestedRows } from 'handsontable/plugins';
+//registerPlugin(NestedRows);
+import Service from './Service';
+import { Table, ConfigProvider, Button as AButton } from "antd";
+import EditableSelect from './EditableSelect';
+import EditableSelectGC from './EditableSelectGC';
+import Editable from './Editable';
+import Button from '@mui/material/Button';
+
+import {copy} from './utils';
+import {TabulatorFull as Tabulator} from "tabulator-tables"; //import Tabulator library
+import "tabulator-tables/dist/css/tabulator.min.css"; //import Tabulator stylesheet
+import './Tabulator.css';
+export default function Rcjhz({id, bh, tiaojiaCallback}) {
+  const myTable = React.useRef(null);
+  const myRef = React.useRef(null);
+  const [detail, setDetail] = React.useState([]);
+  var editCheck = function(cell){
+    //cell - the cell component for the editable cell
+
+    //get row data
+    //console.log(cell);
+    if(cell._cell.row.data['序号']) return false;
+    return true;
+  }
+
+  function handleSelect(row){
+
+  }
+
+
+
+  React.useEffect(() => {
+    myTable.current = new Tabulator(myRef.current, {
+         index: "key",
+         height: 600,
+       data: detail, //link data to table
+       reactiveData: false, //enable data reactivity
+       dataTreeStartExpanded:true,
+       dataTree: true,
+       selectableRows:1, //make rows selectable
+       editTriggerEvent:"dblclick", //trigger edit on double click
+       dataTreeStartExpanded:function(row, level){
+           //console.log(row);
+           //console.log(level);
+           return true; //expand rows where the "driver" data field is true;
+       },
+       columns: [ //Define Table Columns
+                    {title:"ID", field:"ID", width:80, headerSort:false,}, //never hide this column
+                    {title:"编码", field:"编码", width:120,headerSort:false,headerFilter:"input" },
+                    {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", editor: "input"},
+                    {title:"合价", field:"合价", width:100, headerSort:true, sorter:"number", formatter:"money"},
+                    {title:"产地", field:"产地", width:50, headerSort:false, },
+                    {title:"供应厂商", field:"供应厂商", width:80, headerSort:false, },
+                    {title:"人材机类别", field:"人材机类别", width:120, headerSort:true, sorter: 'string', headerFilter:"input"},
+                    {title:"主要材料标志", field:"主要材料标志", width:100, headerSort:false},
+                    {title:"主材标志", field:"主材标志", width:100, headerSort:false, },
+                    {title:"设备标志", field:"设备标志", width:100, headerSort:false, },
+                    {title:"甲供标志", field:"甲供标志", width:100, headerSort:false, },
+                    {title:"暂估价标志", field:"暂估价标志", width:100, headerSort:false, },
+            ]
+     }); 
+     
+     myTable.current.on("cellDblClick", function(e, cell){
+         //e - the click event object
+         //cell - cell component
+         console.log(cell);
+     });
+
+     myTable.current.on("rowSelected", handleSelect);
+     
+
+     myTable.current.on("cellEdited", function(cell){
+         //console.log("edited");
+         //console.log();
+         let newData = copy(cell._cell.row.data);
+         let newDj = newData['单价'];
+         let sl = newData['数量'];
+         newData['合价'] = Number(newDj) * Number(sl);
+         myTable.current.updateData([newData]);
+         tiaojiaCallback(bh, newData['编码'], newDj);
+         
+         
+         
+                          
+                                                      
+         
+     });
+
+
+     myTable.current.on("tableBuilt", () => {
+         Service.generateRencaijihuizong2(id, bh).then(x=>{
+              myTable.current.replaceData(x);
+              });
+       });
+   
+  }, [id, bh]);
+
+    return (
+      <div ref={myRef}> 
+      </div>
+
+
+
+    );
+}

+ 64 - 1
front/src/Service.js

@@ -451,7 +451,30 @@ class Service{
             console.error('error');
         } else {
             const data = await response.json();
-            return data;
+            let result = [];
+            for (let i = 1; i < data.length; i++) {
+                result.push({
+                    'key': uuidv4(),
+                    'ID' : data[i][0],
+                    '编码' : data[i][1],
+                    '名称': data[i][2],
+                    '规格型号' : data[i][3],
+                    '单位' : data[i][4],
+                    '数量' : data[i][5],
+                    '单价' : data[i][6],
+                    '合价' : data[i][7],
+                    '产地' : data[i][8],
+                    '供应厂商' : data[i][9],
+                    '人材机类别' : data[i][10],
+                    '主要材料标志' : data[i][11],
+                    '主材标志' : data[i][12],
+                    '设备标志' : data[i][13],
+                    '甲供标志' : data[i][14],
+                    '暂估价标志' : data[i][15]
+                });
+            }
+            this.setQufeiEntry(id);
+            return result;
         }
     }
     async generateJirigong(name, id) {
@@ -909,6 +932,46 @@ async generateQingdanTuijian(name, bh, bt, bm) {
         }
     }
 
+    async tiaojia(biao_id, bh, bm, jiage) {
+        let glf = "";
+        let lr = "";
+        let bz = 0;//changgui
+        if (this.qufeiEntry['备注'].length == 0) {
+            //changuiqufei
+            glf = this.qufeiEntry['管理费(%)'] ;
+            lr = this.qufeiEntry['利润(%)'];
+        } else {
+            glf = this.qufeiEntry['管理费(%)'] ;
+            lr = this.qufeiEntry['利润(%)'];
+            bz = 1;
+        }
+        const response = await fetch(this.ip().concat( ":8000/tiaojia/"), {
+            method : "POST",
+            headers: {
+                "Content-type": "application/json"
+            },
+            body: JSON.stringify(
+                {
+                    "biao_id": biao_id,
+                    "bh": bh,
+                    "bm": bm,
+                    "jiage": jiage,
+                    "glf" : glf,
+                    "lr" : lr,
+                    "bz" : bz
+                }
+            )
+        });
+        if (!response.ok) {
+            //const error = await response.json();
+            console.error('error');
+        } else {
+            const data = await response.json();
+            this.clearCache();
+            return data;
+        }
+    }
+
 
 
 

+ 22 - 0
main.py

@@ -136,6 +136,16 @@ class InfoWithID(BaseModel):
     name: str
     id: str
 
+
+class Tiaojia(BaseModel):
+    biao_id: str
+    bh: str
+    bm: str
+    jiage: str
+    glf: str
+    lr: str
+    bz: int
+
 @app.post("/outline")
 async def read_root(info: Info):
     for root, dirs, files in os.walk("./data", topdown=False):
@@ -477,6 +487,18 @@ async def applyFL(r: InfoWithID):
     return await db.applyFL(client, r.id, data)
 
 
+@app.post("/tiaojia/")
+async def tiaojia(r: Tiaojia):
+    ##return []
+    glf = r.glf
+    lr = r.lr
+    if r.glf == '':
+        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)
+
+
 
 
 async def resolve(websocket, data):

+ 229 - 24
subdir/db.py

@@ -743,13 +743,13 @@ async def applyFL(client, id, data):
                 sl = float(post['数量'])
                 if rgfs < 0.0001 and clfs < 0.0001 and jxfs < 0.0001:
                     continue
-                danxiang = False
+                ##danxiang = False
                 
-                for child in post['__children']:
+                for child in post['__children']:##一条定额
                     bm = child['清单编码']
                     if bm.startswith("D"):
-                        danxiang = True
-                        break
+                        ##danxiang = True
+                        continue
                     rgf = float(child['人工费'])
                     clf = float(child['材料费'])
                     jxf = float(child['机械费'])
@@ -767,32 +767,237 @@ async def applyFL(client, id, data):
                         child['利润'] = (rgf) * lr / float(100)
                         child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
                         child['合价'] = sl * sl_ * child['综合单价'] 
-                if not danxiang:
+                if True:
+                    post['管理费'] = 0
+                    post['利润'] = 0
+                    for entry in post['__children']:
+                        post['管理费'] = post['管理费'] + float(entry['管理费']) * float(entry['数量'])
+                        post['利润'] = post['利润'] + float(entry['利润']) * float(entry['数量'])
+                    post['管理费'] =  str(post['管理费'])
+                    post['利润'] = str(post['利润'])
+                    post['综合单价'] = str(float(post['人工费']) + float(post['材料费']) + float(post['机械费']) + float(post['管理费']) + float(post['利润']))
+                    post['合价'] = str(float(post['综合单价']) * float(post['数量']))
+                    
+                
+
+                await collection.replace_one({'_id': post['_id']}, post )
+    collection = db['Djcs']
+    
+    for dxgc in xm["children"]:
+        for dwgc in dxgc["children"]:
+            bh = dwgc['key']
+            glf = float(dwgc['管理费(%)'])
+            lr = float(dwgc['利润(%)'])
+            bz = dwgc['备注']
+            ##print(bh+glf+lr+bz)
+            async for post in collection.find({'biao_id': id, "Dwgcbh": bh}):
+                rgfs = float(post['人工费'])
+                clfs = float(post['材料费'])
+                jxfs = float(post['机械费'])
+                sl = float(post['数量'])
+                if rgfs < 0.0001 and clfs < 0.0001 and jxfs < 0.0001:
+                    continue
+                ##danxiang = False##一般有单项定额的,清单就一条定额,就是这个单项定额
+                
+                for child in post['__children']:
+                    bm = child['清单编码']
+                    if bm.startswith("D"):
+                        ##danxiang = True
+                        continue
+                    rgf = float(child['人工费'])
+                    clf = float(child['材料费'])
+                    jxf = float(child['机械费'])
+                    zhdj = float(child['综合单价'])
+                    sl_ = float(child['数量'])
                     if len(bz) == 0:
-                    ##常规计算
-                        post['管理费'] = (rgfs + jxfs) * glf / float(100)
-                        post['利润'] = (rgfs + jxfs) * lr / float(100)
-                        post['综合单价'] = rgfs + clfs + jxfs + post['管理费'] + post['利润']
-                        post['合价'] = sl * post['综合单价'] 
-                        if post['清单编码'] == "010101001001":
-                            print(post['人工费'])
-                            print(post['材料费'])
-                            print(post['机械费'])
-                            print(post['管理费'])
-                            print(post['利润'])
-                            print(post['综合单价'])
-                            print(sl)
-                            print(post['合价'])
+                        ##常规计算
+                        child['管理费'] = (rgf + jxf) * glf / float(100)
+                        child['利润'] = (rgf + jxf) * lr / float(100)
+                        child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
+                        child['合价'] = sl * sl_ * child['综合单价'] 
 
                     else:
-                        post['管理费'] = (rgfs) * glf / float(100)
-                        post['利润'] = (rgfs) * lr / float(100)
-                        post['综合单价'] = rgfs + clfs + jxfs + post['管理费'] + post['利润']
-                        post['合价'] = sl * post['综合单价'] 
-                
+                        child['管理费'] = (rgf) * glf / float(100)
+                        child['利润'] = (rgf) * lr / float(100)
+                        child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
+                        child['合价'] = sl * sl_ * child['综合单价'] 
+                if True:
+                    post['管理费'] = 0
+                    post['利润'] = 0
+                    for entry in post['__children']:
+                        post['管理费'] = post['管理费'] + float(entry['管理费']) * float(entry['数量'])
+                        post['利润'] = post['利润'] + float(entry['利润']) * float(entry['数量'])
+                    post['管理费'] =  str(post['管理费'])
+                    post['利润'] = str(post['利润'])
+                    post['综合单价'] = str(float(post['人工费']) + float(post['材料费']) + float(post['机械费']) + float(post['管理费']) + float(post['利润']))
+                    post['合价'] = str(float(post['综合单价']) * float(post['数量']))
+                    
 
                 await collection.replace_one({'_id': post['_id']}, post )
 
 
 
     return {"result": "ok"}
+
+
+
+async def tiaojia(client, biao_id, bh, bm, jiage, glf, lr, bz):
+    db = client["baojia"]
+    collection = db["qdxm"]
+    async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
+        children = post["__children"]
+        qdsl = post['数量']
+        hit = False
+        for entry in children:###对一条定额,调价
+            hitde = False
+            dercj = entry["dercj"]
+            dergf = 0
+            declf = 0
+            dejxf = 0
+            for i in range(1, len(dercj)):
+                rcj = dercj[i]
+                if rcj[1] == bm:
+                    hit = True
+                    hitde = True
+                    rcj[5] = jiage
+                    hanliang = rcj[10]
+                    rcj[11] = str(float(jiage) * float(hanliang))
+                if int(rcj[8]) == 1:
+                    dergf = dergf + float(rcj[11])
+                elif int(rcj[8]) == 2:
+                    declf = declf + float(rcj[11])
+                elif int(rcj[8]) == 3:
+                    dejxf = dejxf + float(rcj[11])
+                if hitde:
+                    entry['人工费'] = str(dergf)
+                    entry['辅材费'] = str(declf)
+                    entry['材料费'] = str(declf)
+                    entry['机械费'] = str(dejxf)
+                    if bm.startswith("D"):
+                        entry['管理费'] = '0'
+                        entry['利润'] = '0'
+                    elif bz == 0:
+                        entry['管理费'] = str((dergf + dejxf) * float(glf) / float(100))
+                        entry['利润'] =   str((dergf + dejxf) * float(lr) / float(100))
+                    else:
+                        entry['管理费'] = str((dergf) * float(glf) / float(100))
+                        entry['利润'] =   str((dergf) * float(lr) / float(100))
+                    entry['综合单价'] = str(float(entry['人工费']) + float(entry['材料费']) + float(entry['机械费']) + float(entry['管理费']) + float(entry['利润']))
+                    entry['合价'] = str(float(entry['综合单价']) * float(entry['数量']) * float(qdsl))
+        if hit:
+            ##调整清单
+            qdrcj = post['rcj']
+            qdrgf = 0
+            qdclf = 0
+            qdjxf = 0
+            for i in range(1, len(qdrcj)):
+                entry = qdrcj[i]
+                if entry[1] == bm:
+                    entry[5] = jiage
+                    hanliang = entry[10]
+                    entry[11] = str(float(jiage) * float(hanliang))
+                if int(entry[8]) == 1:
+                    qdrgf = qdrgf + float(entry[11])
+                elif int(entry[8]) == 2:
+                    qdclf = qdclf + float(entry[11])
+                elif int(entry[8]) == 3:
+                    qdjxf = qdjxf + float(entry[11])
+            post['人工费'] = str(qdrgf)
+            post['辅材费'] = str(qdclf)
+            post['材料费'] = str(qdclf)
+            post['机械费'] = str(qdjxf)
+            post['管理费'] = 0
+            post['利润'] = 0
+            for entry in children:
+                post['管理费'] = post['管理费'] + float(entry['管理费']) * float(entry['数量'])
+                post['利润'] = post['利润'] + float(entry['利润']) * float(entry['数量'])
+            post['管理费'] =  str(post['管理费'])
+            post['利润'] = str(post['利润'])
+
+            post['综合单价'] = str(float(post['人工费']) + float(post['材料费']) + float(post['机械费']) + float(post['管理费']) + float(post['利润']))
+            post['合价'] = str(float(post['综合单价']) * float(qdsl))
+            await collection.replace_one({'_id': post['_id']}, post )
+    collection = db["Djcs"]
+    async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}):
+        children = post["__children"]
+        qdsl = post['数量']
+        hit = False
+        for entry in children:###对一条定额,调价
+            hitde = False
+            dercj = entry["dercj"]
+            dergf = 0
+            declf = 0
+            dejxf = 0
+            for i in range(1, len(dercj)):
+                rcj = dercj[i]
+                if rcj[1] == bm:
+                    hit = True
+                    hitde = True
+                    rcj[5] = jiage
+                    hanliang = rcj[10]
+                    rcj[11] = str(float(jiage) * float(hanliang))
+                if int(rcj[8]) == 1:
+                    dergf = dergf + float(rcj[11])
+                elif int(rcj[8]) == 2:
+                    declf = declf + float(rcj[11])
+                elif int(rcj[8]) == 3:
+                    dejxf = dejxf + float(rcj[11])
+                if hitde:
+                    entry['人工费'] = str(dergf)
+                    entry['辅材费'] = str(declf)
+                    entry['材料费'] = str(declf)
+                    entry['机械费'] = str(dejxf)
+                    if bm.startswith("D"):
+                        entry['管理费'] = '0'
+                        entry['利润'] = '0'  
+                    elif bz == 0:
+                        entry['管理费'] = str((dergf + dejxf) * float(glf) / float(100))
+                        entry['利润'] =   str((dergf + dejxf) * float(lr) / float(100))
+                    else:
+                        entry['管理费'] = str((dergf) * float(glf) / float(100))
+                        entry['利润'] =   str((dergf) * float(lr) / float(100))
+                    entry['综合单价'] = str(float(entry['人工费']) + float(entry['材料费']) + float(entry['机械费']) + float(entry['管理费']) + float(entry['利润']))
+                    entry['合价'] = str(float(entry['综合单价']) * float(entry['数量']) * float(qdsl))
+        if hit:
+            ##调整清单
+            qdrcj = post['rcj']
+            qdrgf = 0
+            qdclf = 0
+            qdjxf = 0
+            for i in range(1, len(qdrcj)):
+                entry = qdrcj[i]
+                if entry[1] == bm:
+                    entry[5] = jiage
+                    hanliang = entry[10]
+                    entry[11] = str(float(jiage) * float(hanliang))
+                if int(entry[8]) == 1:
+                    qdrgf = qdrgf + float(entry[11])
+                elif int(entry[8]) == 2:
+                    qdclf = qdclf + float(entry[11])
+                elif int(entry[8]) == 3:
+                    qdjxf = qdjxf + float(entry[11])
+            post['人工费'] = str(qdrgf)
+            post['辅材费'] = str(qdclf)
+            post['材料费'] = str(qdclf)
+            post['机械费'] = str(qdjxf)
+            post['管理费'] = 0
+            post['利润'] = 0
+            for entry in children:
+                post['管理费'] = post['管理费'] + float(entry['管理费']) * float(entry['数量'])
+                post['利润'] = post['利润'] + float(entry['利润']) * float(entry['数量'])
+            post['管理费'] =  str(post['管理费'])
+            post['利润'] = str(post['利润'])
+
+            post['综合单价'] = str(float(post['人工费']) + float(post['材料费']) + float(post['机械费']) + float(post['管理费']) + float(post['利润']))
+            post['合价'] = str(float(post['综合单价']) * float(qdsl))
+            await collection.replace_one({'_id': post['_id']}, post )
+
+
+            
+                    
+
+
+
+
+
+