|
@@ -13,6 +13,7 @@ let bill_model = require('../models/bills');
|
|
let decimal_facade = require('./decimal_facade');
|
|
let decimal_facade = require('./decimal_facade');
|
|
let installationFeeModel = mongoose.model("installation_fee");
|
|
let installationFeeModel = mongoose.model("installation_fee");
|
|
let rationInstallationModel = mongoose.model('ration_installation');
|
|
let rationInstallationModel = mongoose.model('ration_installation');
|
|
|
|
+let rationTemplateModel = mongoose.model('ration_template');
|
|
const uuidV1 = require('uuid/v1');
|
|
const uuidV1 = require('uuid/v1');
|
|
let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
|
|
let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
|
|
let complementary_glj_model = mongoose.model('complementary_glj_lib');
|
|
let complementary_glj_model = mongoose.model('complementary_glj_lib');
|
|
@@ -32,7 +33,8 @@ module.exports = {
|
|
addMultiRation: addMultiRation,
|
|
addMultiRation: addMultiRation,
|
|
getSameSectionRations:getSameSectionRations,
|
|
getSameSectionRations:getSameSectionRations,
|
|
getExtendData:getExtendData,
|
|
getExtendData:getExtendData,
|
|
- getDefaultProgramID:getDefaultProgramID
|
|
|
|
|
|
+ getDefaultProgramID:getDefaultProgramID,
|
|
|
|
+ deleteSubListByQuery:deleteSubListByQuery
|
|
};
|
|
};
|
|
async function addNewRation(data,compilation) {
|
|
async function addNewRation(data,compilation) {
|
|
let query = data.itemQuery;
|
|
let query = data.itemQuery;
|
|
@@ -201,13 +203,15 @@ async function addRationSubList(stdRation,newRation,needInstall,compilation) {
|
|
let ration_coes = await addRationCoe(stdRation,newRation,compilation);
|
|
let ration_coes = await addRationCoe(stdRation,newRation,compilation);
|
|
let addRationCoeTime = +new Date();
|
|
let addRationCoeTime = +new Date();
|
|
console.log("添加定额coe时间-----"+(addRationCoeTime - addRationGLJTime));
|
|
console.log("添加定额coe时间-----"+(addRationCoeTime - addRationGLJTime));
|
|
- let ration_installs = [];
|
|
|
|
|
|
+ let ration_installations = [];
|
|
if(needInstall && stdRation.type == 'std'){//只有标准的定额才有安装增加费,补充的定额没有安装增加费
|
|
if(needInstall && stdRation.type == 'std'){//只有标准的定额才有安装增加费,补充的定额没有安装增加费
|
|
- ration_installs = await addRationInstallFee(stdRation,newRation);
|
|
|
|
|
|
+ ration_installations = await addRationInstallFee(stdRation,newRation);
|
|
}
|
|
}
|
|
let addRationInstallFeeTime = +new Date();
|
|
let addRationInstallFeeTime = +new Date();
|
|
console.log("添加定额install时间-----"+(addRationInstallFeeTime - addRationCoeTime));
|
|
console.log("添加定额install时间-----"+(addRationInstallFeeTime - addRationCoeTime));
|
|
- return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installs:ration_installs};
|
|
|
|
|
|
+ //添加定额模板子目
|
|
|
|
+ let ration_template = await addRationTemplate(stdRation,newRation);
|
|
|
|
+ return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installations:ration_installations,ration_templates:[ration_template]};
|
|
}
|
|
}
|
|
|
|
|
|
async function addRationInstallFee(std,newRation) {
|
|
async function addRationInstallFee(std,newRation) {
|
|
@@ -249,6 +253,38 @@ async function addRationInstallFee(std,newRation) {
|
|
return install_fee_list;
|
|
return install_fee_list;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+async function addRationTemplate(std,newRation) {
|
|
|
|
+ let templateList = [];
|
|
|
|
+ if(std.hasOwnProperty('rationTemplateList') && std.rationTemplateList.length > 0){
|
|
|
|
+ for(let tem of std.rationTemplateList){
|
|
|
|
+ let template = {
|
|
|
|
+ billID:"",
|
|
|
|
+ fxID:"",
|
|
|
|
+ quantity:'',
|
|
|
|
+ coe:""
|
|
|
|
+ }
|
|
|
|
+ template.code = tem.code;
|
|
|
|
+ template.name = tem.name;
|
|
|
|
+ template.type = tem.type;
|
|
|
|
+ template.unit = tem.unit &&_.isString(tem.unit) ?tem.unit.replace(/^\d+/,""):"";
|
|
|
|
+ template.billsLocation = template.billsLocation
|
|
|
|
+ templateList.push(tem)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(templateList.length > 0){
|
|
|
|
+ let ration_template = {};
|
|
|
|
+ ration_template.ID = uuidV1();
|
|
|
|
+ ration_template.projectID = newRation.projectID;
|
|
|
|
+ ration_template.rationID = newRation.ID;
|
|
|
|
+ ration_template.createLocation = 1; //默认模板子目分别放在措施项目下
|
|
|
|
+ ration_template.templateList = templateList;
|
|
|
|
+ await rationTemplateModel.create(ration_template);
|
|
|
|
+ return ration_template;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
async function addRationCoe(std,newRation,compilation) {
|
|
async function addRationCoe(std,newRation,compilation) {
|
|
let ration_coe_list = [];
|
|
let ration_coe_list = [];
|
|
let seq = 0;
|
|
let seq = 0;
|
|
@@ -423,12 +459,18 @@ async function addRationGLJ(std,newRation,compilation) {
|
|
async function deleRationSubRecode(projectID,rationID) {//删除挂在定额下的数据,如工程量明细,定额工料机等
|
|
async function deleRationSubRecode(projectID,rationID) {//删除挂在定额下的数据,如工程量明细,定额工料机等
|
|
let delete_query={projectID: projectID, rationID: rationID};
|
|
let delete_query={projectID: projectID, rationID: rationID};
|
|
//删除工程量明细
|
|
//删除工程量明细
|
|
- await quantity_detail.deleteByQuery(delete_query) ;
|
|
|
|
|
|
+ await deleteSubListByQuery(delete_query) ;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+async function deleteSubListByQuery(delete_query) {
|
|
|
|
+ await quantity_detail.deleteByQuery(delete_query) ;//删除工程量明细
|
|
await ration_coe.deleteMany(delete_query);//删除附注条件
|
|
await ration_coe.deleteMany(delete_query);//删除附注条件
|
|
await ration_glj.deleteMany(delete_query);//删除定额工料机
|
|
await ration_glj.deleteMany(delete_query);//删除定额工料机
|
|
await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
|
|
await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
|
|
|
|
+ await rationTemplateModel.deleteMany(delete_query);//删除模板关联子目
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {
|
|
async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {
|
|
// insertNewRation
|
|
// insertNewRation
|
|
let ration ={};
|
|
let ration ={};
|