Browse Source

support summarize data

Xiaopeng Zhang 6 months ago
parent
commit
43e92ca46a
4 changed files with 233 additions and 14 deletions
  1. 31 9
      front/src/App2.js
  2. 81 0
      front/src/Bjhz.js
  3. 8 1
      main.py
  4. 113 4
      subdir/db.py

+ 31 - 9
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 Bjhz from './Bjhz';
 import Zjcs2 from './Zjcs2';
 import Djcs2 from './Djcs2';
 import Service from './Service';
@@ -225,7 +226,9 @@ const MUI_X_PRODUCTS = [
     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 [qdbt, setQdbt] = React.useState([]);
     const [qdbh, setQdbh] = React.useState(null);
     const [value, setValue] = React.useState('1');
@@ -721,14 +724,15 @@ const MUI_X_PRODUCTS = [
           let regex = /[0-9]*/; 
           let id = itemId.match(regex)[0];     
           Service.generateBaojiahuizong2(location["id"], id).then(x=>{
-                  setNestDetail(x);
+                  setBjhzData(x);
                   setNest(true);
                   setQingdan(false);
                   setCuoshi(false);
                   setQufei(false);
                   setRcjhz(false);
                   setGfsj(false);
-                  setColumnHeaders(["序号", "名称", "金额", "暂估价", "类别"]);
+                  setBjhz(true);
+                  //setColumnHeaders(["序号", "名称", "金额", "暂估价", "类别"]);
                 });
         }
         else if (itemId.includes("gui fei shui jin")) {
@@ -742,6 +746,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(false);
                   setRcjhz(false);
                   setGfsj(true);
+                  setBjhz(false);
                   //setColumnHeaders(["序号", "名称", "取费基数", "计算基础","费率", "金额", "类别"]);
                 });
 
@@ -759,6 +764,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(false);
                   setRcjhz(false);
                   setGfsj(false);
+                  setBjhz(false);
                   //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
                 });
 
@@ -774,6 +780,7 @@ const MUI_X_PRODUCTS = [
           setQufei(false);
           setRcjhz(false);
           setGfsj(false);
+          setBjhz(false);
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
 
         }
@@ -790,6 +797,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(false);
                   setRcjhz(false);
                   setGfsj(false);
+                  setBjhz(false);
                   setColumnHeaders(["序号", "名称", "金额", "项目类别", "备注"]);
                 });
 
@@ -806,6 +814,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(false);
                   setRcjhz(false);
                   setGfsj(false);
+                  setBjhz(false);
                   //setColumnHeaders(["序号", "名称", "金额", "项目类别", "备注"]);
                 });
         }
@@ -822,6 +831,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(false);
                   setRcjhz(false);
                   setGfsj(false);
+                  setBjhz(false);
                 });
 
         }
@@ -838,6 +848,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(false);
                   setRcjhz(false);
                   setGfsj(false);
+                  setBjhz(false);
                 });
 
         }
@@ -854,6 +865,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(false);
                   setRcjhz(false);
                   setGfsj(false);
+                  setBjhz(false);
                 });
 
         }
@@ -870,6 +882,7 @@ const MUI_X_PRODUCTS = [
                   setQufei(false);
                   setRcjhz(false);
                   setGfsj(false);
+                  setBjhz(false);
                 });
 
         }
@@ -886,6 +899,7 @@ const MUI_X_PRODUCTS = [
                   setCuoshi(false);
                   setQufei(false);
                   setGfsj(false);
+                  setBjhz(false);
                   setQdbh(id);
                 //}
                 //)
@@ -901,6 +915,7 @@ const MUI_X_PRODUCTS = [
             setQufei(false);
             setRcjhz(false);
             setGfsj(false);
+            setBjhz(false);
         });
 
         }
@@ -1057,6 +1072,7 @@ const MUI_X_PRODUCTS = [
                   setCuoshi(false);
                   setRcjhz(false);
                   setGfsj(false);
+                  setBjhz(false);
                  }}>费率</Button>
 
             
@@ -1065,18 +1081,24 @@ const MUI_X_PRODUCTS = [
 
             </Grid>
             <Grid size={9}>
-              {!nest && !qingdan && !cuoshi && !qufei && rcjhz && !gfsj && <Rcjhz 
+              {!nest && !qingdan && !cuoshi && !qufei && rcjhz && !gfsj && !bjhz && <Rcjhz 
               id={location['id']} 
               bh={qdbh}
               tiaojiaCallback={tiaojiaCallback}
               />}
 
-              {nest && !qingdan && !cuoshi && !qufei && !rcjhz && gfsj && <Gfsj 
+              {nest && !qingdan && !cuoshi && !qufei && !rcjhz && gfsj && !bjhz && <Gfsj 
                    data={gfsjData}
               
               />}
+
+
+               {nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && bjhz && <Bjhz 
+                   data={bjhzData}
+              
+               />}
              
-            {!nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && <HotTable nestedRows={false}
+            {!nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz && <HotTable nestedRows={false}
                     data={detail
                     }
                     rowHeaders={true}
@@ -1089,7 +1111,7 @@ const MUI_X_PRODUCTS = [
                     autoWrapCol={false}
                     licenseKey="non-commercial-and-evaluation" // for non-commercial use only
                   />}
-            {nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && <HotTable nestedRows={true}
+            {nest && !qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz && <HotTable nestedRows={true}
                     data={nestDetail
                     }
                     readOnly={true}
@@ -1104,10 +1126,10 @@ const MUI_X_PRODUCTS = [
                     autoWrapCol={false}
                     licenseKey="non-commercial-and-evaluation" // for non-commercial use only
                   />}
-            {!qingdan && !cuoshi && qufei && !rcjhz && !gfsj && <Qufei id={location['id']} qufeiCallback={qufeiCallback}
+            {!qingdan && !cuoshi && qufei && !rcjhz && !gfsj && !bjhz && <Qufei id={location['id']} qufeiCallback={qufeiCallback}
                   />}
 
-            {!nest && qingdan && !cuoshi && !qufei && !rcjhz && !gfsj &&  <TabContext value={value}>
+            {!nest && qingdan && !cuoshi && !qufei && !rcjhz && !gfsj && !bjhz &&  <TabContext value={value}>
                    <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
                       <TabList scrollButtons='auto' 
                               variant="scrollable"
@@ -1136,7 +1158,7 @@ const MUI_X_PRODUCTS = [
                      </TabPanel>
                       )}
                 </TabContext>}
-            {!nest && !qingdan && cuoshi && !qufei && !rcjhz && !gfsj &&  <TabContext value={value}>
+            {!nest && !qingdan && cuoshi && !qufei && !rcjhz && !gfsj && !bjhz &&  <TabContext value={value}>
                    <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
                       <TabList scrollButtons='auto' 
                               variant="scrollable"

+ 81 - 0
front/src/Bjhz.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 Bjhz({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:80, headerSort:false,}, //never hide this column
+                      {title:"名称", field:"名称", width:150, headerSort:false, formatter:"textarea"}, //hide this column first
+                      {title:"金额", field:"金额", width:100,   formatter:"money", },
+                      {title:"暂估价", field:"暂估价", width:100,   formatter:"textarea"},
+                      {title:"类别", field:"类别", width:100,   formatter:"textarea"},
+                    
+              ]
+       }); 
+       
+       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>
+
+
+
+    );
+}

+ 8 - 1
main.py

@@ -206,7 +206,14 @@ async def read_bjhz(info: InfoWithID):
 @app.post("/baojiahuizong2/")
 async def read_bjhz2(info: InfoWithID):
    
-    return await db.getBjhz(client, info.name, info.id)
+    raw = await db.getBjhz(client, info.name, info.id)
+    raw2 = []
+    for entry in raw:
+        if "__children" in entry:
+            entry["_children"] = entry["__children"]
+            del entry["__children"]
+        raw2.append(entry)
+    return raw2
 
 @app.post("/guifeishuijin/")
 async def read_gfsj(info: InfoWithID):

+ 113 - 4
subdir/db.py

@@ -1106,16 +1106,61 @@ async def tiaojia(client, biao_id, bh, bm, mingcheng, danwei, jiage, glf, lr, bz
 
 
 
+def bjhz_template():
+    result = []
+    result.append({'序号': '1', '名称': '分部分项工程', '金额': '0', '暂估价': '0', '类别' : '1', '__children': [
+        {'序号': '1.1', '名称': '人工费', '金额': '0', '暂估价': '0', '类别' : '1.1'},
+        {'序号': '1.2', '名称': '材料费', '金额': '0', '暂估价': '0', '类别' : '1.2'},
+        {'序号': '1.3', '名称': '施工机具使用费', '金额': '0', '暂估价': '0', '类别' : '1.3'},
+        {'序号': '1.4', '名称': '企业管理费', '金额': '0', '暂估价': '0', '类别' : '1.4'},
+        {'序号': '1.5', '名称': '利润', '金额': '0', '暂估价': '0', '类别' : '1.5'}
+    ]})
+    result.append({'序号': '2', '名称': '措施项目', '金额': '0', '暂估价': '0', '类别' : '2', '__children': [
+        {'序号': '2.1', '名称': '单价措施项目费', '金额': '0', '暂估价': '0', '类别' : '2.1'},
+        {'序号': '2.2', '名称': '总价措施项目费', '金额': '0', '暂估价': '0', '类别' : '2.2', '__children' : [
+        {'序号': '2.2.1', '名称': '其中:安全文明施工措施费', '金额': '0', '暂估价': '0', '类别' : '2.2.1'},]
+        }
+       
+    ]})
+    result.append({'序号': '3', '名称': '其他项目', '金额': '0', '暂估价': '0', '类别' : '3', '__children': [
+        {'序号': '3.1', '名称': '其中:暂列金额', '金额': '0', '暂估价': '0', '类别' : '3.1'},
+        {'序号': '3.2', '名称': '其中:专业工程暂估价', '金额': '0', '暂估价': '0', '类别' : '3.2'},
+        {'序号': '3.3', '名称': '其中:计日工', '金额': '0', '暂估价': '0', '类别' : '3.3'},
+        {'序号': '3.4', '名称': '其中:总承包服务费', '金额': '0', '暂估价': '0', '类别' : '3.4'},
+        
+    ]})
+    result.append({'序号': '4', '名称': '规费', '金额': '0', '暂估价': '0', '类别' : '4', })
+    result.append({'序号': '5', '名称': '税金', '金额': '0', '暂估价': '0', '类别' : '5', })
+    result.append({'序号': '6', '名称': '工程造价', '金额': '0', '暂估价': '0', '类别' : '6', })
+
+    return result
+
+
+
+
+
 
 async def zongjiaDwgc(client, biao_id, bh):
     db = client["baojia"]
     collection = db["qdxm"]
-    sum = 0
+    qd_sum = 0
+    djcs_sum = 0
+    rgf_sum = 0
+    clf_sum = 0
+    jxf_sum = 0
+    glf_sum = 0
+    lr_sum = 0
     async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}, {'__children': 0}):
-        sum = sum + float(post['合价'])
+        qd_sum = qd_sum + float(post['合价'])
+        rgf_sum = rgf_sum + float(post['数量']) * float(post['人工费'])
+        clf_sum = clf_sum + float(post['数量']) * float(post['材料费'])
+        jxf_sum = jxf_sum + float(post['数量']) * float(post['机械费'])
+        glf_sum = glf_sum + float(post['数量']) * float(post['管理费'])
+        lr_sum = lr_sum + float(post['数量']) * float(post['利润'])
     collection = db["Djcs"]
     async for post in collection.find({'biao_id': biao_id, "Dwgcbh": bh}, {'__children': 0}):
-        sum = sum + float(post['合价'])
+        djcs_sum = djcs_sum + float(post['合价'])
+    sum = qd_sum + djcs_sum
     collection = db['Dwgc']
     document = await collection.find_one({'biao_id': biao_id, "Dwgcbh": bh}, {'rcjhz': 0})
     zjcs = document['zjcs']
@@ -1167,10 +1212,74 @@ async def zongjiaDwgc(client, biao_id, bh):
         if item['名称'] == '合计':
             item['取费基数'] = str(sj_sum + gf_sum)
             item['金额'] = item['取费基数']
+
+    qtxm = document['qtxm']
+    zlje = 0
+    zygczgj = 0
+    jrg = 0
+    zcbfwf = 0
+    clzgj = 0
+    for entry in qtxm:
+        if entry['序号'] == '1':
+            zlje = entry['金额']
+        if entry['序号'] == '3':
+            jrg = entry['金额']
+        if entry['序号'] == '4':
+            zcbfwf = entry['金额']
+        if entry['序号'] == '2':
+            for child in entry['__children']:
+                if child['序号'] == '2.2':
+                    zygczgj = child['金额']
+                if child['序号'] == '2.1':
+                    clzgj = child['金额']
+    qtxm_sum = zlje + zygczgj + jrg + zcbfwf + clzgj
+                
+
+
+
+
+
+    bjhz = bjhz_template()
+    for entry in bjhz:
+        if entry['序号'] == '1':
+            entry['金额'] = qd_sum
+            for child in entry['__children']:
+                if child['序号'] == '1.1':
+                    child['金额'] = str(rgf_sum)
+                if child['序号'] == '1.2':
+                    child['金额'] = str(clf_sum)
+                if child['序号'] == '1.3':
+                    child['金额'] = str(jxf_sum)
+                if child['序号'] == '1.4':
+                    child['金额'] = str(glf_sum)
+                if child['序号'] == '1.5':
+                    child['金额'] = str(lr_sum)
+        if entry['序号'] == '2':
+            entry['金额'] = str(djcs_sum + zjcs_sum)
+            for child in entry['__children']:
+                if child['序号'] == '2.1':
+                    child['金额'] = str(djcs_sum)
+                if child['序号'] == '2.2':
+                    child['金额'] = str(zjcs_sum)
+                    for grandchild in child['__children']:
+                        if grandchild['序号'] == '2.2.1':
+                            grandchild['金额'] = str(sum_)
+        if entry['序号'] == '3':
+            entry['金额'] = str(qtxm_sum)
+        if entry['序号'] == '4':
+            entry['金额'] = str(gf_sum)
+        if entry['序号'] == '5':
+            entry['金额'] = str(sj_sum)
+        if entry['序号'] == '6':
+            entry['金额'] = str(float(qd_sum) + float(djcs_sum) + float(zjcs_sum) + float(qtxm_sum) + float(gf_sum) + float(sj_sum))
+        
+
+
+
     
 
     
-    await collection.update_one({'biao_id': biao_id, "Dwgcbh": bh}, {'$set': {'zjcs': result, 'gfsj' : gfsj}})
+    await collection.update_one({'biao_id': biao_id, "Dwgcbh": bh}, {'$set': {'zjcs': result, 'gfsj' : gfsj, 'bjhz': bjhz}})