Browse Source

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

zhongzewei 6 years atrás
parent
commit
b984e11ec0

+ 1 - 2
modules/main/controllers/project_controller.js

@@ -28,8 +28,7 @@ module.exports = {
     getData: function (req, res) {
         //add
         console.log(`------------------------------------------`);
-        console.log(req.session.sessionUser);
-        console.log(req.session.userAccount);
+        console.log(`${req.session.sessionUser.real_name}--id:${req.session.sessionUser.id}--取getdata数据`);
         console.log(`------------------------------------------`);
         //add
         if(typeof req.body.data === 'object'){

+ 3 - 3
modules/main/controllers/ration_controller.js

@@ -15,7 +15,7 @@ let controller = {
         let data = req.body.data;
         data = JSON.parse(data);
         let userID = req.session.sessionUser.id;
-        return await ration_facade.replaceRations(userID,data);
+        return await ration_facade.replaceRations(userID,data,req.session.sessionCompilation);
     },
     addNewRation:async function(req) {
         let data = req.body.data;
@@ -23,7 +23,7 @@ let controller = {
             data = JSON.stringify(data);
         }
         data = JSON.parse(data);
-        return await ration_facade.addNewRation(data);
+        return await ration_facade.addNewRation(data,req.session.sessionCompilation);
     },
     addMultiRation: async function (req) {
         let data = req.body.data;
@@ -31,7 +31,7 @@ let controller = {
             data = JSON.stringify(data);
         }
         data = JSON.parse(data);
-        return await ration_facade.addMultiRation(data.newDatas);
+        return await ration_facade.addMultiRation(data.newDatas,req.session.sessionCompilation);
     }
 };
 

+ 50 - 27
modules/main/facade/ration_facade.js

@@ -20,13 +20,14 @@ let coeMolde = mongoose.model('std_ration_lib_coe_list');
 let _= require('lodash');
 const projectDao = require('../../pm/models/project_model').project;
 let projectModel = mongoose.model('projects');
+const fs = require('fs');
 
 module.exports = {
     replaceRations: replaceRations,
     addNewRation:addNewRation,
     addMultiRation: addMultiRation
 };
-async function addNewRation(data) {
+async function addNewRation(data,compilation) {
     let query = data.itemQuery;
     let stdRation = null;
     let startTime = +new Date();
@@ -44,16 +45,16 @@ async function addNewRation(data) {
     let addRationGLJTime = +new Date();
     console.log("插入新定额时间-------------------------------"+(addRationGLJTime - stdRationTime));
     if(stdRation){
-        return await addRationSubList(stdRation,newRation,data.needInstall);
+        return await addRationSubList(stdRation,newRation,data.needInstall,compilation);
     }else {
         return {ration:newRation};
     }
 }
 
-async function addMultiRation(datas) {
+async function addMultiRation(datas,compilation) {
     let rst = [];
     for(let data of datas){
-        let r = await addNewRation(data);
+        let r = await addNewRation(data,compilation);
         rst.push(r);
     }
     return rst;
@@ -120,12 +121,12 @@ async function insertNewRation(newData,defaultLibID,std,calQuantity) {//插入
     return newData;*/
 }
 
-async function replaceRations(userID,data) {
+async function replaceRations(userID,data,compilation) {
     let searchDao = new SearchDao();
     let recodes = [];
     for(let recode of data.nodeInfo){
         let stdRation = await searchDao.getRationItem(userID,data.libIDs,recode.newCode, null);
-        let newRecode = await replaceRation(recode,stdRation,data.defaultLibID,data.projectID,data.calQuantity);
+        let newRecode = await replaceRation(recode,stdRation,data.defaultLibID,data.projectID,data.calQuantity,compilation);
         if(newRecode){
             recodes.push(newRecode);
         }else {
@@ -135,25 +136,25 @@ async function replaceRations(userID,data) {
     return recodes;
 }
 
-async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuantity) {
+async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuantity,compilation) {
     if(nodeInfo.newCode == null||nodeInfo.newCode ==""){//说明是删除编号,则要变成一条空定额
         await deleRationSubRecode(projectID,nodeInfo.ID);//删除定额下挂的各种数据,如定额工料机等
         return await setEmptyRation(projectID,nodeInfo.ID);
     }else if(stdRation){
         await deleRationSubRecode(projectID,nodeInfo.ID);//删除定额下挂的各种数据,如定额工料机等
         let newRation = await updateRation(stdRation,defaultLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity);//生成并插入新的定额
-        return await addRationSubList(stdRation,newRation,nodeInfo.needInstall);
+        return await addRationSubList(stdRation,newRation,nodeInfo.needInstall,compilation);
     }else {
         return null;
     }
 }
 
-async function addRationSubList(stdRation,newRation,needInstall) {
+async function addRationSubList(stdRation,newRation,needInstall,compilation) {
     let startTime = +new Date();
     let ration_gljs = await addRationGLJ(stdRation,newRation);
     let addRationGLJTime = +new Date();
     console.log("添加定额工料机时间-----"+(addRationGLJTime - startTime));
-    let ration_coes = await addRationCoe(stdRation,newRation);
+    let ration_coes = await addRationCoe(stdRation,newRation,compilation);
     let addRationCoeTime = +new Date();
     console.log("添加定额coe时间-----"+(addRationCoeTime - addRationGLJTime));
     let ration_installs = [];
@@ -203,7 +204,7 @@ async function addRationInstallFee(std,newRation) {
     return install_fee_list;
 }
 
-async function addRationCoe(std,newRation) {
+async function addRationCoe(std,newRation,compilation) {
     let ration_coe_list = [];
     let seq = 0;
     if(std.hasOwnProperty('rationCoeList')&&std.rationCoeList.length>0){//添加标准库的工料机
@@ -225,33 +226,55 @@ async function addRationCoe(std,newRation) {
             }
         }
     }
+    let lastCoe = await getCustomerCoe(newRation.projectID,newRation.ID,seq,compilation);
+    ration_coe_list.push(lastCoe);
+    await ration_coe.insertMany(ration_coe_list);
+    return ration_coe_list;
+
+}
+
+function getCustomerCoeData() {
+    var coeList = [
+         {amount:1, operator:'*', gljCode:null, coeType:'定额'},
+        { amount:1, operator:'*', gljCode:null, coeType:'人工'},
+        { amount:1, operator:'*', gljCode:null, coeType:'材料'},
+        { amount:1, operator:'*', gljCode:null, coeType:'机械'},
+        { amount:1, operator:'*', gljCode:null, coeType:'主材'},
+        { amount:1, operator:'*', gljCode:null, coeType:'设备'}
+    ];
+    return coeList;
+};
+
+
+async function getCustomerCoe(projectID,rationID,seq,compilation){//取自定义乘系数,根据编办不同,内容可能不同
+    //生成默认的自定义乘系数
     let lastCoe ={
         coeID:-1,
         name : '自定义系数',
         content:'人工×1,材料×1,机械×1,主材×1,设备×1',
         isAdjust:0,
         seq:seq,
-        rationID : newRation.ID,
-        projectID : newRation.projectID
+        rationID : rationID,
+        projectID : projectID
     };
     lastCoe.ID = uuidV1();
     lastCoe.coes = getCustomerCoeData();
-    ration_coe_list.push(lastCoe);
-    await ration_coe.insertMany(ration_coe_list);
-    return ration_coe_list;
-
+    try {
+    //查看编办中有没有重写路径
+     if(compilation.overWriteUrl && compilation.overWriteUrl!=""){
+         let overWrite = require("../../.."+compilation.overWriteUrl);
+         if(overWrite.getCusCoeContent) lastCoe.content = overWrite.getCusCoeContent();
+         if(overWrite.getCustomerCoeData) lastCoe.coes = overWrite.getCustomerCoeData();
+     }
+     return lastCoe
+   }catch (err){
+       console.log("读取自定义系数重写文件失败");
+       console.log(err.message);
+       return lastCoe
+   }
 }
 
-function getCustomerCoeData() {
-    var coeList = [];
-    coeList.push({ amount:1, operator:'*', gljCode:null, coeType:'定额'});
-    coeList.push({ amount:1, operator:'*', gljCode:null, coeType:'人工'});
-    coeList.push({ amount:1, operator:'*', gljCode:null, coeType:'材料'});
-    coeList.push({ amount:1, operator:'*', gljCode:null, coeType:'机械'});
-    coeList.push({ amount:1, operator:'*', gljCode:null, coeType:'主材'});
-    coeList.push({ amount:1, operator:'*', gljCode:null, coeType:'设备'});
-    return coeList;
-};
+
 
 async function addRationGLJ(std,newRation) {
     let newRationGLJList = [];

+ 17 - 3
modules/ration_glj/facade/glj_calculate_facade.js

@@ -28,6 +28,15 @@ let stateSeq ={
     cusCoe:6,
     adjMak:7
 };
+//自定义乘系数与定额工料机类型映射表
+let coeTypeMap = {
+    "人工":1,
+    "材料":2,
+    "机械":3,
+    "施工机具":3,
+    "主材":4,
+    "设备":5
+};
 
 
 async function calculateQuantity(query,noNeedCal,refreshRationName = false){
@@ -299,7 +308,7 @@ function everyCoe(quantity,coe,glj) {
                 coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
             } else if(coe.coes[i].coeType=='定额'){
                 coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
-            }else if(coe.coes[i].coeType==getGLJTypeByID(glj.type)){
+            }else if(coeTypeMap[coe.coes[i].coeType]==getRootGLJType(glj.type).ID){
                 coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
             }
         }
@@ -314,7 +323,7 @@ function calculateQuantityByCustomerCoes(quantify,coe,glj) {
         return getCalculateResult(quantify, coe.coes[0])
     }else {
         for(let i=1;i<coe.coes.length;i++){
-            if(coe.coes[i].coeType.search(getGLJTypeByID(glj.type))!=-1){
+            if(coeTypeMap[coe.coes[i].coeType]==getRootGLJType(glj.type).ID){
                 return getCalculateResult(quantify,coe.coes[i])
             }
         }
@@ -344,10 +353,15 @@ function getCalculateResult(quantify,c) {
     return q;
 }
 
-function getGLJTypeByID(id) {
+function getRootGLJType(id){
     let glj_type_object = glj_type_util.getStdGljTypeCacheObj();
     let topTypeId = glj_type_object.getTopParentIdByItemId(id);
     let type = glj_type_object.getItemById(topTypeId);
+    return type;
+}
+
+function getGLJTypeByID(id) {
+    let type = getRootGLJType(id);
     if(type!=undefined){
         return type.fullName;
     }else {

+ 1 - 0
modules/users/controllers/login_controller.js

@@ -97,6 +97,7 @@ class LoginController {
             console.log(error);
             return response.json({error: 1, msg: error});
         }
+        console.log(`${request.session.sessionUser.real_name}--id:${request.session.sessionUser.id}--登录了系统`);
         response.json({
             error: 0,
             msg: '',

+ 54 - 68
web/building_saas/main/js/views/zmhs_view.js

@@ -116,12 +116,15 @@ let zmhs_obj = {
         let me = zmhs_obj;
         if(me.coeSheetData[context.row]){
             let data = me.coeSheetData[context.row];
-            $('#coe_ration').val(data.coes[0].amount);
+            for(let c of data.coes){
+                $("#"+ c.coeType).val(c.amount);
+            }
+            /*$('#coe_ration').val(data.coes[0].amount);
             $('#manual').val(data.coes[1].amount);
             $('#material').val(data.coes[2].amount);
             $('#manchine').val(data.coes[3].amount);
             $('#mainM').val(data.coes[4].amount);
-            $('#equipment').val(data.coes[5].amount);
+            $('#equipment').val(data.coes[5].amount);*/
         }
     },
     updateCusCoeAfterEditor:function(){
@@ -135,70 +138,53 @@ let zmhs_obj = {
         var coe = _.find(zmhs_obj.coeSheetData, function (c) {
             return c.coeID == -1;
         });
-        var newValue = zmhs_obj.numberValueChecking($('#' + id).val());
-        if (newValue) {
-            newValue = _.round(newValue, 2);
-            if (newValue == coe.coes[name].amount) return;
-            if (id == 'coe_ration') {
-                $('#coe_ration').val(newValue);
-                $('#manual').val(newValue);
-                $('#material').val(newValue);
-                $('#manchine').val(newValue);
-                $('#mainM').val(newValue);
-                $('#equipment').val(newValue);
+        if(coe){
+            let newValue = zmhs_obj.numberValueChecking($('#' + id).val());
+            if (newValue) {
+                newValue = _.round(newValue, 2);
+                if (newValue == coe.coes[name].amount) return;
+                if (id == '定额') {
+                    for(let c of coe.coes){
+                        $('#'+c.coeType).val(newValue)
+                    }
+                    /*$('#coe_ration').val(newValue);
+                    $('#manual').val(newValue);
+                    $('#material').val(newValue);
+                    $('#manchine').val(newValue);
+                    $('#mainM').val(newValue);
+                    $('#equipment').val(newValue);*/
+                } else {
+                    $('#' + id).val(newValue);
+                }
             } else {
-                $('#' + id).val(newValue);
+                $('#' + id).val(coe.coes[name].amount);
             }
-        } else {
-            $('#' + id).val(coe.coes[name].amount);
         }
+
     },
     checkIfNeedUpdate(){
-        var data = _.find(zmhs_obj.coeSheetData, function (c) {
+        let data = _.find(zmhs_obj.coeSheetData, function (c) {
             return c.coeID == -1;
         });
-        var result = {
-            isNeed: false
-        }
-        var coe_ration = $('#coe_ration').val();
-        var manual = $('#manual').val();
-        var material = $('#material').val();
-        var manchine = $('#manchine').val();
-        var mainM = $('#mainM').val();
-        var equipment = $('#equipment').val();
-        if (coe_ration != data.coes[0].amount) {
-            result.isNeed = true;
-            data.coes[0].amount = coe_ration;
-        }
-        if (manual != data.coes[1].amount) {
-            result.isNeed = true;
-            data.coes[1].amount = manual;
-        }
-        if (material != data.coes[2].amount) {
-            result.isNeed = true;
-            data.coes[2].amount = material;
-        }
-        if (manchine != data.coes[3].amount) {
-            result.isNeed = true;
-            data.coes[3].amount = manchine;
-        }
-        if (mainM != data.coes[4].amount) {
-            result.isNeed = true;
-            data.coes[4].amount = mainM;
-        }
-        if (equipment != data.coes[5].amount) {
-            result.isNeed = true;
-            data.coes[5].amount = equipment;
-        }
-        if (result.isNeed) {
-            result.doc = {
-                coes: data.coes
-            };
-            result.query = {
-                projectID: data.projectID,
-                ID: data.ID,
-                rationID: data.rationID
-            };
+        let result = {isNeed: false};
+        if(data){
+            for(let c of data.coes){
+                let amount = $("#"+c.coeType).val();
+                if(amount!=c.amount){
+                    result.isNeed = true;
+                    c.amount = amount;
+                }
+            }
+            if (result.isNeed) {
+                result.doc = {
+                    coes: data.coes
+                };
+                result.query = {
+                    projectID: data.projectID,
+                    ID: data.ID,
+                    rationID: data.rationID
+                };
+            }
         }
         return result;
 
@@ -229,22 +215,22 @@ let zmhs_obj = {
         let recode = me.coeSheetData[args.row];
         projectObj.project.ration_coe.adjustCoeClick(recode, newval);
     },
-    generateHtmlString: function (context,cellRect) {
+    generateHtmlString: function (context,cellRect) {//这里要改成动态的了,根据自定义系数内容生成对应的输入框
         let me = zmhs_obj;
         let height = cellRect.height;
         let newString = "<div style='height:"+ height+"px'><div onclick='zmhs_obj.coeSheet.endEdit()' style='margin:-1px 1px 0px'>自定义系数</div></div><form style='margin-top:1px' ><table  width='100%'  cellpadding='0'  border='1px' bordercolor='#CCCCCC' cellspacing='0px' style='border-collapse:collapse;font-size: 10px;'>";
-        newString += me.getOneRow('定额', 0, 'coe_ration',height);
-        newString += me.getOneRow('人工', 1, 'manual',height);
-        newString += me.getOneRow('材料', 2, 'material',height);
-        newString += me.getOneRow('机械', 3, 'manchine',height);
-        newString += me.getOneRow('主材', 4, 'mainM',height);
-        newString += me.getOneRow('设备', 5, 'equipment',height);
+        let cus_coe =  me.coeSheetData[context.row];
+        if(cus_coe){
+            for(let i =0;i< cus_coe.coes.length;i++){
+                newString += me.getOneRow(cus_coe.coes[i].coeType, i, cus_coe.coes[i].coeType,height)
+            }
+        }
         newString += "</table></form>";
         return newString;
     },
     getOneRow: function (text, name, id,inputHeight) {
-        var rowstr = "<tr ><td style='width: 40%'>" + text
-            + ":</td><td style='width: 60%' align='right'><input type='text' value='1' name=" + name
+        var rowstr = "<tr ><td style='width: 50%'>" + text
+            + ":</td><td style='width: 50%' align='right'><input type='text' value='1' name=" + name
             + " style='width:40px;border:0;height:"+ inputHeight+"px;' align='right' id=" + id + " onchange='zmhs_obj.onInputChange(this.id,this.name)' autocomplete='off'></td></tr>";
         return rowstr;
 

+ 42 - 10
web/over_write/js/chongqing_2018.js

@@ -47,13 +47,17 @@ if(typeof materialComponent !== 'undefined'){
 
 // CSL, 2018-08-21 计算程序、基数 的覆盖。---------------------------------------------------------------------------------
 let isCQ2018 = true;
-baseMaterialTypes.push(gljType.OTHER_MATERIAL);
-allMaterialTypes.delete(gljType.EQUIPMENT);
-baseMachineTypes.delete(gljType.MACHINE_COMPOSITION);
-baseMachineTypes.push(gljType.INSTRUMENT, gljType.FUEL_POWER_FEE, gljType.DEPRECIATION_FEE,
-    gljType.INSPECTION_FEE, gljType.MAINTENANCE, gljType.DISMANTLING_FREIGHT_FEE,
-    gljType.VERIFICATION_FEE, gljType.OTHER_FEE, gljType.OTHER_MACHINE_USED);
-baseMachineMasterTypes.push(gljType.INSTRUMENT);
+
+if(typeof baseMaterialTypes !== 'undefined'){
+    baseMaterialTypes.push(gljType.OTHER_MATERIAL);
+    allMaterialTypes.delete(gljType.EQUIPMENT);
+    baseMachineTypes.delete(gljType.MACHINE_COMPOSITION);
+    baseMachineTypes.push(gljType.INSTRUMENT, gljType.FUEL_POWER_FEE, gljType.DEPRECIATION_FEE,
+        gljType.INSPECTION_FEE, gljType.MAINTENANCE, gljType.DISMANTLING_FREIGHT_FEE,
+        gljType.VERIFICATION_FEE, gljType.OTHER_FEE, gljType.OTHER_MACHINE_USED);
+    baseMachineMasterTypes.push(gljType.INSTRUMENT);
+}
+
 
 function overwriteRationCalcBases (taxType){
     if (rationCalcBases){
@@ -198,8 +202,12 @@ var cpFeeTypes2018 = [
     {type: 'environmentTax', name: '环境保护税'},
     {type: 'common', name: '工程造价'}
 ];
-cpFeeTypes.splice(0, cpFeeTypes.length);
-for (let e of cpFeeTypes2018) cpFeeTypes.push(e);
+
+if(typeof cpFeeTypes !== 'undefined'){
+    cpFeeTypes.splice(0, cpFeeTypes.length);
+    for (let e of cpFeeTypes2018) cpFeeTypes.push(e);
+}
+
 
 
 //清单计算基数相关
@@ -278,8 +286,32 @@ if(typeof figureClassTemplate !== 'undefined'){
     figureClassTemplate['ADDED_VALUE_TAX'] = {flag: fixedFlag.ADDED_VALUE_TAX, filter: ['SJ', 'ZZS', 'SQGCZJ']}
 };
 //去除分类分包费
-if($('#cbClassList')){
+if(typeof $ !== 'undefined' && $('#cbClassList')){
     $('#cbClassList').find('li:eq(5)').remove();
 }
 
 
+
+
+//这个文档浏览器库和服务器端共用,所以这个文件中用到的变量都要记得做undefined判断,不然后端读取时会有问题
+//=================================================== 前后端分割线 ======================================================================
+if(typeof module !== 'undefined'){
+    module.exports = {
+        getCusCoeContent: getCusCoeContent,
+        getCustomerCoeData: getCustomerCoeData
+    };
+}
+
+function getCusCoeContent() {
+    return '人工×1,材料×1,施工机具×1,主材×1'
+}
+
+function getCustomerCoeData() {
+    return [
+        {amount:1, operator:'*', gljCode:null, coeType:'定额'},
+        { amount:1, operator:'*', gljCode:null, coeType:'人工'},
+        { amount:1, operator:'*', gljCode:null, coeType:'材料'},
+        { amount:1, operator:'*', gljCode:null, coeType:'施工机具'},
+        { amount:1, operator:'*', gljCode:null, coeType:'主材'}
+    ]
+}