|
@@ -96,14 +96,14 @@ async function deleteMaterialRation(data) {
|
|
|
async function modifyMaterialRation(data,compilation) {
|
|
async function modifyMaterialRation(data,compilation) {
|
|
|
let model = data.type == "freight"?freightCalcModel:originaltCalcModel;
|
|
let model = data.type == "freight"?freightCalcModel:originaltCalcModel;
|
|
|
if(data.field == "code"){
|
|
if(data.field == "code"){
|
|
|
- let [newRation,ration_gljs] = await getNewMaterialRationDatas(data,compilation);
|
|
|
|
|
|
|
+ let [newRation,ration_gljs,projectGLJList] = await getNewMaterialRationDatas(data,compilation);
|
|
|
let quantity = data.rations[data.row].quantity;
|
|
let quantity = data.rations[data.row].quantity;
|
|
|
newRation.quantity = quantity;
|
|
newRation.quantity = quantity;
|
|
|
data.rations[data.row] = newRation;
|
|
data.rations[data.row] = newRation;
|
|
|
_.remove(data.ration_gljs,{rationID:data.rationID});
|
|
_.remove(data.ration_gljs,{rationID:data.rationID});
|
|
|
data.ration_gljs = data.ration_gljs.concat(ration_gljs);
|
|
data.ration_gljs = data.ration_gljs.concat(ration_gljs);
|
|
|
await model.update({'ID':data.parentID},{rations:data.rations,ration_gljs:data.ration_gljs});
|
|
await model.update({'ID':data.parentID},{rations:data.rations,ration_gljs:data.ration_gljs});
|
|
|
- return {ration:newRation,ration_gljs:ration_gljs}
|
|
|
|
|
|
|
+ return {ration:newRation,ration_gljs:ration_gljs,projectGLJList:projectGLJList}
|
|
|
}else {
|
|
}else {
|
|
|
let doc = {},pre = "rations.$.";
|
|
let doc = {},pre = "rations.$.";
|
|
|
let field = pre+data.field;
|
|
let field = pre+data.field;
|
|
@@ -125,10 +125,10 @@ async function modifyMaterialRation(data,compilation) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function addMaterialRation(data,compilation) {
|
|
async function addMaterialRation(data,compilation) {
|
|
|
- let [newRation,ration_gljs] = await getNewMaterialRationDatas(data,compilation);
|
|
|
|
|
|
|
+ let [newRation,ration_gljs,projectGLJList] = await getNewMaterialRationDatas(data,compilation);
|
|
|
let model = data.type == "freight"?freightCalcModel:originaltCalcModel;
|
|
let model = data.type == "freight"?freightCalcModel:originaltCalcModel;
|
|
|
await model.update({ID:data.parentID},{$push:{rations:newRation,ration_gljs:{$each:ration_gljs}}});
|
|
await model.update({ID:data.parentID},{$push:{rations:newRation,ration_gljs:{$each:ration_gljs}}});
|
|
|
- return{ration:newRation,ration_gljs:ration_gljs};
|
|
|
|
|
|
|
+ return{ration:newRation,ration_gljs:ration_gljs,projectGLJList:projectGLJList};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function getNewMaterialRationDatas(data,compilation){
|
|
async function getNewMaterialRationDatas(data,compilation){
|
|
@@ -137,8 +137,8 @@ async function getNewMaterialRationDatas(data,compilation){
|
|
|
if(!stdRation) throw "找不到指定的定额!";//new Error("找不到指定的定额!");
|
|
if(!stdRation) throw "找不到指定的定额!";//new Error("找不到指定的定额!");
|
|
|
|
|
|
|
|
let newRation = await createNewMaterialRation(stdRation,data.quantityDecimal,data.projectID);
|
|
let newRation = await createNewMaterialRation(stdRation,data.quantityDecimal,data.projectID);
|
|
|
- let ration_gljs = await addRationGLJ(stdRation,newRation,compilation,true,data.connect_key);
|
|
|
|
|
- return [newRation,ration_gljs];
|
|
|
|
|
|
|
+ let [ration_gljs,projectGLJList] = await addRationGLJ(stdRation,newRation,compilation,true,data.connect_key);
|
|
|
|
|
+ return [newRation,ration_gljs,projectGLJList];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -296,7 +296,7 @@ async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuanti
|
|
|
|
|
|
|
|
async function addRationSubList(stdRation,newRation,needInstall,compilation,cleanzmhs=false) {
|
|
async function addRationSubList(stdRation,newRation,needInstall,compilation,cleanzmhs=false) {
|
|
|
let startTime = +new Date();
|
|
let startTime = +new Date();
|
|
|
- let ration_gljs = await addRationGLJ(stdRation,newRation,compilation);
|
|
|
|
|
|
|
+ let [ration_gljs,projectGLJList] = await addRationGLJ(stdRation,newRation,compilation);
|
|
|
let addRationGLJTime = +new Date();
|
|
let addRationGLJTime = +new Date();
|
|
|
console.log("添加定额工料机时间-----"+(addRationGLJTime - startTime));
|
|
console.log("添加定额工料机时间-----"+(addRationGLJTime - startTime));
|
|
|
let ration_coes = await addRationCoe(stdRation,newRation,compilation);
|
|
let ration_coes = await addRationCoe(stdRation,newRation,compilation);
|
|
@@ -313,7 +313,7 @@ async function addRationSubList(stdRation,newRation,needInstall,compilation,clea
|
|
|
//添加定额模板子目
|
|
//添加定额模板子目
|
|
|
ration_template = await addRationTemplate(stdRation,newRation);
|
|
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?[ration_template]:[]};
|
|
|
|
|
|
|
+ return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installations:ration_installations,ration_templates:ration_template?[ration_template]:[],projectGLJList:projectGLJList};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function addRationInstallFee(std,newRation) {
|
|
async function addRationInstallFee(std,newRation) {
|
|
@@ -480,6 +480,7 @@ function getExtendData(property,compilation) {
|
|
|
async function addRationGLJ(std,newRation,compilation,isMaterial,connect_key) {
|
|
async function addRationGLJ(std,newRation,compilation,isMaterial,connect_key) {
|
|
|
let newRationGLJList = [];
|
|
let newRationGLJList = [];
|
|
|
let rationGLJShowList = [];
|
|
let rationGLJShowList = [];
|
|
|
|
|
+ let projectGLJList = [];
|
|
|
let unitPriceFileId = 0;
|
|
let unitPriceFileId = 0;
|
|
|
let property = await projectDao.getProjectProperty(newRation.projectID);
|
|
let property = await projectDao.getProjectProperty(newRation.projectID);
|
|
|
if(property){
|
|
if(property){
|
|
@@ -526,10 +527,11 @@ async function addRationGLJ(std,newRation,compilation,isMaterial,connect_key) {
|
|
|
let std_glj = getStdGlj(sub,stdGLJMap,cptGLJMap,{},ext);
|
|
let std_glj = getStdGlj(sub,stdGLJMap,cptGLJMap,{},ext);
|
|
|
if(std_glj){
|
|
if(std_glj){
|
|
|
ration_glj_facade.setPropertyFromStd(newGLJ,std_glj);
|
|
ration_glj_facade.setPropertyFromStd(newGLJ,std_glj);
|
|
|
- let info = await ration_glj_facade.getInfoFromProjectGLJ(newGLJ,unitPriceFileId,ext);
|
|
|
|
|
|
|
+ let [info,projectGLJ] = await ration_glj_facade.getInfoFromProjectGLJ(newGLJ,unitPriceFileId,ext);
|
|
|
newGLJ = ration_glj_facade.createNewRecord(info);
|
|
newGLJ = ration_glj_facade.createNewRecord(info);
|
|
|
newRationGLJList.push(newGLJ);
|
|
newRationGLJList.push(newGLJ);
|
|
|
rationGLJShowList.push(info);
|
|
rationGLJShowList.push(info);
|
|
|
|
|
+ projectGLJList.push(projectGLJ);
|
|
|
}
|
|
}
|
|
|
//let InfoFromProjectGLJ = +new Date();
|
|
//let InfoFromProjectGLJ = +new Date();
|
|
|
//console.log("找到项目工料机时间-------------------------------"+(InfoFromProjectGLJ - std_gljTime));
|
|
//console.log("找到项目工料机时间-------------------------------"+(InfoFromProjectGLJ - std_gljTime));
|
|
@@ -537,7 +539,7 @@ async function addRationGLJ(std,newRation,compilation,isMaterial,connect_key) {
|
|
|
}
|
|
}
|
|
|
let before = +new Date();
|
|
let before = +new Date();
|
|
|
console.log("总查询时间为-------------------------------"+(before-first));
|
|
console.log("总查询时间为-------------------------------"+(before-first));
|
|
|
- if(isMaterial == true) return newRationGLJList;//如果是材料计算的工料机,这里返回就可以了
|
|
|
|
|
|
|
+ if(isMaterial == true) return [newRationGLJList,projectGLJList];//如果是材料计算的工料机,这里返回就可以了
|
|
|
|
|
|
|
|
if(newRationGLJList.length>0){
|
|
if(newRationGLJList.length>0){
|
|
|
await ration_glj.insertMany(newRationGLJList);
|
|
await ration_glj.insertMany(newRationGLJList);
|
|
@@ -545,7 +547,7 @@ async function addRationGLJ(std,newRation,compilation,isMaterial,connect_key) {
|
|
|
let after = +new Date();
|
|
let after = +new Date();
|
|
|
console.log("实际插入时间为-------------------------------"+(after-before));
|
|
console.log("实际插入时间为-------------------------------"+(after-before));
|
|
|
console.log("总操作时间为-------------------------------"+(after-first));
|
|
console.log("总操作时间为-------------------------------"+(after-first));
|
|
|
- return rationGLJShowList;
|
|
|
|
|
|
|
+ return [rationGLJShowList,projectGLJList];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getStdGlj(sub,stdGLJMap,cptGLJMap,newGLJ,ext) {
|
|
function getStdGlj(sub,stdGLJMap,cptGLJMap,newGLJ,ext) {
|
|
@@ -585,10 +587,13 @@ async function deleteSubListByQuery(delete_query,cleanzmhs=false) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function updateCoeAdjust(data,compilation) {
|
|
async function updateCoeAdjust(data,compilation) {
|
|
|
- let replace = [];
|
|
|
|
|
|
|
+ let replace = [],projectGLJList=[];
|
|
|
await ration_coe.update({ID:data.ID},data.doc);
|
|
await ration_coe.update({ID:data.ID},data.doc);
|
|
|
//添加单个工料机的情况
|
|
//添加单个工料机的情况
|
|
|
- if (data.add.length > 0) await ration_glj_facade.insertAddTypeGLJ(data.add,compilation);
|
|
|
|
|
|
|
+ if (data.add.length > 0){
|
|
|
|
|
+ let [tg,pl] = await ration_glj_facade.insertAddTypeGLJ(data.add,compilation);
|
|
|
|
|
+ if(pl.length > 0) projectGLJList = projectGLJList.concat(pl);
|
|
|
|
|
+ }
|
|
|
if(data.delete.length > 0) await ration_glj_facade.deleteGLJ(data.delete);
|
|
if(data.delete.length > 0) await ration_glj_facade.deleteGLJ(data.delete);
|
|
|
|
|
|
|
|
//替换工料机的情况
|
|
//替换工料机的情况
|
|
@@ -596,6 +601,7 @@ async function updateCoeAdjust(data,compilation) {
|
|
|
for(let r of data.replace){
|
|
for(let r of data.replace){
|
|
|
let r_result = await ration_glj_facade.replaceGLJByData(r,compilation);
|
|
let r_result = await ration_glj_facade.replaceGLJByData(r,compilation);
|
|
|
replace.push(r_result.data) ;
|
|
replace.push(r_result.data) ;
|
|
|
|
|
+ projectGLJList.push(r_result.projectGLJ);
|
|
|
if(r_result.newRecodes.length > 0) data.add = data.add.concat(r_result.newRecodes);
|
|
if(r_result.newRecodes.length > 0) data.add = data.add.concat(r_result.newRecodes);
|
|
|
if(r_result.deleteList.length > 0) data.delete = data.delete.concat(r_result.deleteList);
|
|
if(r_result.deleteList.length > 0) data.delete = data.delete.concat(r_result.deleteList);
|
|
|
}
|
|
}
|
|
@@ -614,7 +620,7 @@ async function updateCoeAdjust(data,compilation) {
|
|
|
adjustState:cal_result.adjustState,
|
|
adjustState:cal_result.adjustState,
|
|
|
name:cal_result.rationName
|
|
name:cal_result.rationName
|
|
|
};
|
|
};
|
|
|
- return {coe:coe,ration_glj:ration_glj,ration:ration,add:data.add,delete:data.delete,replace:replace}
|
|
|
|
|
|
|
+ return {coe:coe,ration_glj:ration_glj,ration:ration,add:data.add,delete:data.delete,replace:replace,projectGLJList:projectGLJList}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|