| 
					
				 | 
			
			
				@@ -26,7 +26,7 @@ import GljDao from "../../complementary_glj_lib/models/gljModel"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const complementaryGljModel = mongoose.model('complementary_glj_lib'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const stdGljModel = mongoose.model('std_glj_lib_gljList'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const gljClassModel = mongoose.model('std_glj_lib_gljClass'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import  projCounter from '../../main/models/proj_counter_model'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const projectDao = require('../../pm/models/project_model').project; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 module.exports = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     save: save, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -175,11 +175,11 @@ function createNewRecord(ration_glj) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return newRecoed 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-async function getInfoFromProjectGLJ(ration_glj,unitPriceFileId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+async function getInfoFromProjectGLJ(ration_glj,unitPriceFileId,ext) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let data = getGLJSearchInfo(ration_glj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let projectGljModel = new GLJListModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        let result = await projectGljModel.addList(data,unitPriceFileId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let result = await projectGljModel.addList(data,unitPriceFileId,ext); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let typeString = result.type+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ration_glj.marketPrice = result.unit_price.market_price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ration_glj.adjustPrice = result.unit_price.base_price; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -590,12 +590,22 @@ function getGLJSearchInfo(ration_glj) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+async function prepareExtData(projectID,compilation) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let ext , unitFileId ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let property = await projectDao.getProjectProperty(projectID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ext = projectDao.getExtendData(property,compilation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    unitFileId = property.unitPriceFile !== undefined ? property.unitPriceFile.id : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return [unitFileId,ext]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-async function addGLJ(rgList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+async function addGLJ(rgList,compilation) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let newRecodes = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (rgList.length <= 0) return {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let [unitFileId,ext] = await  prepareExtData(rgList[0].projectGLJID,compilation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for (let g of rgList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let projectGljModel = new GLJListModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        let result = await projectGljModel.addList(getGLJSearchInfo(g)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let result = await projectGljModel.addList(getGLJSearchInfo(g),unitFileId,ext); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let typeString = result.type+''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         g.marketPrice = result.unit_price.market_price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         g.adjustPrice = result.unit_price.base_price; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -625,10 +635,11 @@ async function addGLJ(rgList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-async function replaceGLJ(data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+async function replaceGLJ(data,compilation) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let rdata = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let projectGljModel = new GLJListModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    let result = await projectGljModel.addList(getGLJSearchInfo(data)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let [unitFileId,ext] = await  prepareExtData(data.projectID,compilation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let result = await projectGljModel.addList(getGLJSearchInfo(data),unitFileId,ext); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let typeString = result.type+''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     data.projectGLJID = result.id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -653,10 +664,12 @@ async function replaceGLJ(data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     rdata.name = stateResult.rationName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return rdata; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-async function mReplaceGLJ(data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+async function mReplaceGLJ(data,compilation) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let mresult = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let projectGljModel = new GLJListModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    let result = await projectGljModel.addList(getGLJSearchInfo(data.doc)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let [unitFileId,ext] = await prepareExtData(data.doc.projectID,compilation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let result = await projectGljModel.addList(getGLJSearchInfo(data.doc),unitFileId,ext); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let typeString = result.type+''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let newDoc = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     newDoc.projectGLJID = result.id; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -771,7 +784,7 @@ async function getGLJClass(info, data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-async function insertGLJAsRation(data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+async function insertGLJAsRation(data,compilation) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let gljList = data.gljList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (data.hasOwnProperty("selectedSerialNo")) { //如果需要,更新序列号。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let query = { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -781,11 +794,11 @@ async function insertGLJAsRation(data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await ration.update(query, {$inc: {serialNo: gljList.length}}, {multi: true}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let [unitFileId,ext] = await prepareExtData(data.doc.projectID,compilation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for (let glj of gljList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let p_glj = getGLJSearchInfo(glj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let projectGljModel = new GLJListModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        let result = await projectGljModel.addList(p_glj);//逐条添加到项目工料机 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let result = await projectGljModel.addList(p_glj,unitFileId,ext);//逐条添加到项目工料机 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let typeString = result.type+''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glj.marketPrice = result.unit_price.market_price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glj.adjustPrice = result.unit_price.base_price; 
			 |