Bläddra i källkod

support tbxx summary

Xiaopeng Zhang 6 månader sedan
förälder
incheckning
e3eae94dfd
6 ändrade filer med 197 tillägg och 25 borttagningar
  1. 32 10
      front/src/App2.js
  2. 81 0
      front/src/Tbxx.js
  3. 4 0
      main.py
  4. 2 2
      qufei.py
  5. 75 11
      subdir/db.py
  6. 3 2
      test.py

+ 32 - 10
front/src/App2.js

@@ -24,6 +24,7 @@ import TabPanel from "@mui/lab/TabPanel";
 //registerPlugin(NestedRows);
 import Qingdan2 from './Qingdan2';
 import Gfsj from './Gfsj';
+import Tbxx from './Tbxx';
 import Bjhz from './Bjhz';
 import Zjcs2 from './Zjcs2';
 import Djcs2 from './Djcs2';
@@ -223,12 +224,14 @@ const MUI_X_PRODUCTS = [
     const [nest, setNest] = React.useState(false);
     const [qingdan, setQingdan] = React.useState(false);
     const [cuoshi, setCuoshi] = React.useState(false);
+    const [tbxx, setTbxx] = React.useState(false);
     const [qufei, setQufei] = React.useState(false);
     const [rcjhz, setRcjhz] = React.useState(false);
     const [gfsj, setGfsj] = React.useState(false);
     const [bjhz, setBjhz] = React.useState(false);
     const [gfsjData, setGfsjData] = React.useState([]);
     const [bjhzData, setBjhzData] = React.useState([]);
+    const [tbxxData, setTbxxData] = React.useState([]);
     const [qdbt, setQdbt] = React.useState([]);
     const [qdbh, setQdbh] = React.useState(null);
     const [value, setValue] = React.useState('1');
@@ -732,6 +735,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(false);
                   setBjhz(true);
+                  setTbxx(false);
                   //setColumnHeaders(["序号", "名称", "金额", "暂估价", "类别"]);
                 });
         }
@@ -747,6 +751,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(true);
                   setBjhz(false);
+                  setTbxx(false);
                   //setColumnHeaders(["序号", "名称", "取费基数", "计算基础","费率", "金额", "类别"]);
                 });
 
@@ -765,6 +770,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(false);
                   setBjhz(false);
+                  setTbxx(false);
                   //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
                 });
 
@@ -781,6 +787,7 @@ const MUI_X_PRODUCTS = [
           setRcjhz(false);
           setGfsj(false);
           setBjhz(false);
+          setTbxx(false);
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
 
         }
@@ -798,6 +805,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(false);
                   setBjhz(false);
+                  setTbxx(false);
                   setColumnHeaders(["序号", "名称", "金额", "项目类别", "备注"]);
                 });
 
@@ -815,6 +823,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(false);
                   setBjhz(false);
+                  setTbxx(false);
                   //setColumnHeaders(["序号", "名称", "金额", "项目类别", "备注"]);
                 });
         }
@@ -832,6 +841,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(false);
                   setBjhz(false);
+                  setTbxx(false);
                 });
 
         }
@@ -849,6 +859,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(false);
                   setBjhz(false);
+                  setTbxx(false);
                 });
 
         }
@@ -866,6 +877,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(false);
                   setBjhz(false);
+                  setTbxx(false);
                 });
 
         }
@@ -883,6 +895,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(false);
                   setBjhz(false);
+                  setTbxx(false);
                 });
 
         }
@@ -900,6 +913,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(false);
                   setGfsj(false);
                   setBjhz(false);
+                  setTbxx(false);
                   setQdbh(id);
                 //}
                 //)
@@ -910,12 +924,13 @@ const MUI_X_PRODUCTS = [
             Service.generateDetail2(location["id"]).then(x=>{
             setQingdan(false);
             setCuoshi(false);
-            setDetail(x);
+            setTbxxData(x);
             setNest(false);
             setQufei(false);
             setRcjhz(false);
             setGfsj(false);
             setBjhz(false);
+            setTbxx(true);
         });
 
         }
@@ -934,7 +949,8 @@ const MUI_X_PRODUCTS = [
         });
         Service.generateDetail2(location['id']).then(x=>{
 
-        setDetail(x);
+        setTbxxData(x);
+        setTbxx(true);
         });
            Service.generateDingeshu(10).then(x=>{
                setOutlineDes_(x);
@@ -1073,6 +1089,7 @@ const MUI_X_PRODUCTS = [
                   setRcjhz(false);
                   setGfsj(false);
                   setBjhz(false);
+                  setTbxx(false);
                  }}>费率</Button>
 
             
@@ -1081,24 +1098,29 @@ const MUI_X_PRODUCTS = [
 
             </Grid>
             <Grid size={9}>
-              {!nest && !qingdan && !cuoshi && !qufei && rcjhz && !gfsj && !bjhz && <Rcjhz 
+              {!nest && !qingdan && !cuoshi && !qufei && rcjhz && !gfsj && !bjhz && !tbxx && <Rcjhz 
               id={location['id']} 
               bh={qdbh}
               tiaojiaCallback={tiaojiaCallback}
               />}
 
-              {nest && !qingdan && !cuoshi && !qufei && !rcjhz && gfsj && !bjhz && <Gfsj 
+              {!nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz && tbxx && <Tbxx 
+              data={tbxxData} 
+              
+              />}
+
+              {nest && !qingdan && !cuoshi && !qufei && !rcjhz && gfsj && !bjhz && !tbxx && <Gfsj 
                    data={gfsjData}
               
               />}
 
 
-               {nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && bjhz && <Bjhz 
+               {nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && bjhz && !tbxx && <Bjhz 
                    data={bjhzData}
               
                />}
              
-            {!nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz && <HotTable nestedRows={false}
+            {!nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz && !tbxx && <HotTable nestedRows={false}
                     data={detail
                     }
                     rowHeaders={true}
@@ -1111,7 +1133,7 @@ const MUI_X_PRODUCTS = [
                     autoWrapCol={false}
                     licenseKey="non-commercial-and-evaluation" // for non-commercial use only
                   />}
-            {nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz && <HotTable nestedRows={true}
+            {nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz && !tbxx && <HotTable nestedRows={true}
                     data={nestDetail
                     }
                     readOnly={true}
@@ -1126,10 +1148,10 @@ const MUI_X_PRODUCTS = [
                     autoWrapCol={false}
                     licenseKey="non-commercial-and-evaluation" // for non-commercial use only
                   />}
-            {!qingdan && !cuoshi && qufei && !rcjhz && !gfsj && !bjhz && <Qufei id={location['id']} qufeiCallback={qufeiCallback}
+            {!qingdan && !cuoshi && qufei && !rcjhz && !gfsj && !bjhz && !tbxx && <Qufei id={location['id']} qufeiCallback={qufeiCallback}
                   />}
 
-            {!nest && qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz &&  <TabContext value={value}>
+            {!nest && qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz  && !tbxx &&  <TabContext value={value}>
                    <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
                       <TabList scrollButtons='auto' 
                               variant="scrollable"
@@ -1158,7 +1180,7 @@ const MUI_X_PRODUCTS = [
                      </TabPanel>
                       )}
                 </TabContext>}
-            {!nest && !qingdan && cuoshi && !qufei && !rcjhz && !gfsj && !bjhz &&  <TabContext value={value}>
+            {!nest && !qingdan && cuoshi && !qufei && !rcjhz && !gfsj && !bjhz && !tbxx &&  <TabContext value={value}>
                    <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
                       <TabList scrollButtons='auto' 
                               variant="scrollable"

+ 81 - 0
front/src/Tbxx.js

@@ -0,0 +1,81 @@
+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 Tbxx({data}) {
+    const myRef = React.useRef();
+    const myTable = React.useRef(null);
+
+
+
+    React.useEffect(() => {
+      myTable.current = new Tabulator(myRef.current, {
+           index: "key",
+           height: 600,
+         data: data, //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:"名称", field:"名称", width:150, headerSort:false, formatter:"textarea"}, //hide this column first
+                      {title:"金额", field:"金额", width:100, headerSort:false, formatter:"money", },
+                      {title:"暂估价", field:"暂估价", width:100, headerSort:false,  formatter:"money"},
+                      {title:"安全文明施工费", field:"安全文明施工费", width:150, headerSort:false,  formatter:"money"},
+                      {title:"规费", field:"规费", width:100, headerSort:false,  formatter:"money"},
+                    
+              ]
+       }); 
+       
+       myTable.current.on("cellDblClick", function(e, cell){
+           //e - the click event object
+           //cell - cell component
+           console.log(cell);
+       });
+  
+       //myTable.current.on("rowSelected", handleSelect);
+       
+  
+       
+  
+  
+      
+     
+    }, [data]);
+    return (
+      <div ref={myRef}> 
+      </div>
+
+
+
+    );
+}

+ 4 - 0
main.py

@@ -211,6 +211,10 @@ async def read_bjhz2(info: InfoWithID):
     for entry in raw:
         if "__children" in entry:
             entry["_children"] = entry["__children"]
+            for grandchild in entry["_children"]:
+                if "__children" in grandchild:
+                    grandchild['_children'] = grandchild['__children']
+                    del grandchild['__children']
             del entry["__children"]
         raw2.append(entry)
     return raw2

+ 2 - 2
qufei.py

@@ -31,9 +31,9 @@ async def resolve(data):
 
 
 import os
-ttt = ['686f656fca53720d42995c7a', '686f6579ec813b9efd38db53', '686f65845e169131760f1420']
+ttt = ['6870b7ce960253992a3d5cf0', '6870b7e467d3b6b24590afd6', '6870b7ed267357fc535650a6']
 
-asyncio.run(resolve(ttt[0]))
+asyncio.run(resolve(ttt[2]))
 
 
 

+ 75 - 11
subdir/db.py

@@ -332,7 +332,8 @@ async def resolve(manager, websocket, data, client):
                     Dxgcxx["Dwgc"].append(Dwgcxx)
             jingjibiao["Dxgcxx"].append(Dxgcxx)
 
-
+    if not 'TouBiaoXx' in jingjibiao:
+        jingjibiao['TouBiaoXx'] = {'Tbzj' : '', 'Zgj' : '', 'Aqwmf' : '', 'Gf' : '' } 
     db = client["baojia"]
     collection = db["jingjibiao"]
     biao_id = (await collection.insert_one(jingjibiao)).inserted_id
@@ -508,17 +509,25 @@ async def getDetail(client, id):
     collection = db["jingjibiao"]
     document = await collection.find_one({'_id': ObjectId(id)})
     result = []
-    result.append(["名称", "金额", "暂估价", "安全文明施工费", "规费"])
+    ##result.append(["名称", "金额", "暂估价", "安全文明施工费", "规费"])
     if 'TouBiaoXx' in document:
         toubiaoxx = document["TouBiaoXx"]
-        result.append([toubiaoxx["Zbr"], toubiaoxx["Tbzj"], toubiaoxx["Zgj"], toubiaoxx["Aqwmf"], toubiaoxx["Gf"]])
+        result.append({'名称': '投标总价', '金额' : toubiaoxx["Tbzj"], '暂估价': toubiaoxx["Zgj"], '安全文明施工费': toubiaoxx["Aqwmf"], '规费' : toubiaoxx["Gf"], '_children': []})
         
-    if 'Dxgcxx' in document:
-        Dxgcxx = document["Dxgcxx"]
-        for dxgc in Dxgcxx:
+        if 'Dxgcxx' in document:
+            Dxgcxx = document["Dxgcxx"]
+            for dxgc in Dxgcxx:
             
-            result.append([dxgc["Dxgcmc"], dxgc["Je"], dxgc["Zgj"], dxgc["Aqwmf"], dxgc["Gf"]])
-    return result
+                result[0]['_children'].append({'名称' :dxgc["Dxgcmc"], '金额' : dxgc["Je"], '暂估价' : dxgc["Zgj"],'安全文明施工费' : dxgc["Aqwmf"], '规费' : dxgc["Gf"]})
+        return result
+    else:
+        if 'Dxgcxx' in document:
+            Dxgcxx = document["Dxgcxx"]
+            for dxgc in Dxgcxx:
+            
+                result.append({'名称' :dxgc["Dxgcmc"], '金额' : dxgc["Je"], '暂估价' : dxgc["Zgj"],'安全文明施工费' : dxgc["Aqwmf"], '规费' : dxgc["Gf"]})
+        return result
+
 
 async def getBjhz(client, objectid, id):
     db = client["baojia"]
@@ -782,6 +791,7 @@ async def save(client, data):
     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):
@@ -815,6 +825,7 @@ async def savedjcs(client, data):
     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):
@@ -935,7 +946,7 @@ async def applyFL(client, id, data):
         for dwgc in dxgc["children"]:
             bh = dwgc['key']
             await zongjiaDwgc(client, id, bh)
-
+    await tbxx(client, id)
     return {"result": "ok"}
 
 
@@ -1103,6 +1114,7 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
             entry[7] = float(jiage) * float(entry[5])
     await collection.update_one({'biao_id': biao_id, "Dwgcbh": bh}, {'$set': {'rcjhz': hz}})
     await zongjiaDwgc(client, biao_id, bh)
+    await tbxx(client, biao_id)
 
 
 
@@ -1137,9 +1149,61 @@ def bjhz_template():
 
 
 
+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']
+        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"]
     collection = db["qdxm"]
@@ -1185,7 +1249,7 @@ async def zongjiaDwgc(client, biao_id, bh):
     zjcs_sum = 0
     for entry in result:
         zjcs_sum = zjcs_sum + float(entry['金额'])
-    qtxm = document['qtxm']
+    qtxm = document['qtxm']##dwgc qtxm
     qtxm_sum = 0
     for entry in qtxm:
         qtxm_sum = qtxm_sum + float(entry['金额'])
@@ -1232,7 +1296,7 @@ async def zongjiaDwgc(client, biao_id, bh):
                     zygczgj = child['金额']
                 if child['序号'] == '2.1':
                     clzgj = child['金额']
-    qtxm_sum = zlje + zygczgj + jrg + zcbfwf + clzgj
+    qtxm_sum = float(zlje) + float(zygczgj) + float(jrg) + float(zcbfwf) + float(clzgj)
                 
 
 

+ 3 - 2
test.py

@@ -324,7 +324,8 @@ async def resolve(data):
                     Dwgcxx["Zylb"] = grandchild.attrib["Zylb"]
                     Dxgcxx["Dwgc"].append(Dwgcxx)
             jingjibiao["Dxgcxx"].append(Dxgcxx)
-
+    if not 'TouBiaoXx' in jingjibiao:
+        jingjibiao['TouBiaoXx'] = {'Tbzj' : '', 'Zgj' : '', 'Aqwmf' : '', 'Gf' : '' } 
 
     db = client["baojia"]
     collection = db["jingjibiao"]
@@ -408,7 +409,7 @@ for root, dirs, files in os.walk("/Users/xiaopengzhang/Downloads/qingdan/data",
         ##print(os.path.join(root, name))
         file_data = os.path.join(root, name)
         ttt.append(file_data)
-asyncio.run(resolve(ttt[0]))
+asyncio.run(resolve(ttt[2]))