|
|
@@ -72,9 +72,9 @@ module.exports={
|
|
|
}
|
|
|
return result;
|
|
|
},
|
|
|
- pasteBlock : async function(data){
|
|
|
+ pasteBlock : async function(data,compilation){
|
|
|
let pasteTasks = [
|
|
|
- pasteRationsAndRationGLJ(data.rations,data.ration_gljs),//这一步会花费比较多时间
|
|
|
+ pasteRationsAndRationGLJ(data.rations,data.ration_gljs,compilation),//这一步会花费比较多时间
|
|
|
pasteOtherData(data)
|
|
|
];
|
|
|
let [rationsAndRationGLJ,resultMap] = await Promise.all(pasteTasks);
|
|
|
@@ -148,19 +148,22 @@ async function pasteOtherData(data) {
|
|
|
return {bills:bills,quantity_details:quantity_details,ration_coes:ration_coes,ration_installations:ration_installations,ration_templates:ration_templates,updateData:updateData}
|
|
|
}
|
|
|
|
|
|
-async function pasteRationsAndRationGLJ (rations,ration_gljs) {
|
|
|
+async function pasteRationsAndRationGLJ (rations,ration_gljs,compilation) {
|
|
|
let projectGljModel = new GLJListModel();
|
|
|
- let gljMap = {};
|
|
|
- let new_ration_gljs=[];
|
|
|
+ let gljMap = {}, new_ration_gljs=[],projectID=null;
|
|
|
+ if(rations.length > 0) projectID = rations[0].projectID;
|
|
|
+ if(projectID==null && ration_gljs.length > 0) projectID = ration_gljs[0].projectID;
|
|
|
+ if(projectID == null) return {rations:rations,new_ration_gljs:new_ration_gljs};
|
|
|
+ let [unitFileId,ext] = await ration_glj_facade.prepareExtData(projectID,compilation);
|
|
|
//先根据定额类型的工料机,插入到项目工料机中
|
|
|
for(let r of rations){
|
|
|
if(r.type == rationType.gljRation){
|
|
|
- await getProjectGLJ(r,rationKeyArray,gljMap);
|
|
|
+ await getProjectGLJ(r,rationKeyArray,gljMap,unitFileId,ext);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for(let rg of ration_gljs){
|
|
|
- await getProjectGLJ(rg,gljKeyArray,gljMap);
|
|
|
+ await getProjectGLJ(rg,gljKeyArray,gljMap,unitFileId,ext);
|
|
|
let temRecord = ration_glj_facade.createNewRecord(rg);
|
|
|
rg.rcode?temRecord.rcode = rg.rcode:'';
|
|
|
rg.hasOwnProperty("customQuantity")?temRecord.customQuantity = rg.customQuantity:'';
|
|
|
@@ -170,16 +173,16 @@ async function pasteRationsAndRationGLJ (rations,ration_gljs) {
|
|
|
rations.length>0?await insertMany(rations,ration_Model):'';
|
|
|
new_ration_gljs.length>0?await insertMany(new_ration_gljs,ration_glj_Model):'';
|
|
|
|
|
|
- return{rations:rations,new_ration_gljs:new_ration_gljs};
|
|
|
+ return {rations:rations,new_ration_gljs:new_ration_gljs};
|
|
|
|
|
|
- async function getProjectGLJ (glj,keyArray,gljMap) {
|
|
|
+ async function getProjectGLJ (glj,keyArray,gljMap,unitFileId,ext) {
|
|
|
let keyIndex = projectGljModel.getIndex(glj,keyArray);
|
|
|
let pgljResult = null;
|
|
|
if(gljMap[keyIndex]){
|
|
|
pgljResult = gljMap[keyIndex]
|
|
|
}else {
|
|
|
let p_glj = ration_glj_facade.getGLJSearchInfo(glj);
|
|
|
- pgljResult = await projectGljModel.addList(p_glj);//逐条添加到项目工料机
|
|
|
+ pgljResult = await projectGljModel.addList(p_glj,unitFileId,ext);//逐条添加到项目工料机
|
|
|
gljMap[keyIndex] = pgljResult;
|
|
|
}
|
|
|
setResult(glj,pgljResult);
|