| 
					
				 | 
			
			
				@@ -10,7 +10,6 @@ let rationRepositoryDao = require('./repository_map'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const scMathUtil = require('../../../public/scMathUtil').getUtil(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const rationItemModel = mongoose.model('std_ration_lib_ration_items'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const stdRationLibModel = mongoose.model('std_ration_lib_map'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-const stdRationSectionModel = mongoose.model('std_ration_lib_ration_chapter_trees'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const compleRationModel = mongoose.model('complementary_ration_items'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import STDGLJListModel from '../../std_glj_lib/models/gljModel'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import InstallationDao from '../models/installation'; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -21,6 +20,82 @@ import stdgljutil  from "../../../public/cache/std_glj_type_util"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 var rationItemDAO = function(){}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/* rationItemDAO.prototype.copyLib = async function (sourceLibID, targetLibID) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // coe-list 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const coeIDMap = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const newCoeData = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const sourceCoeData = await _stdRationCoeModel.find({ libID: sourceLibID }, '-_id').lean(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const coeCount = await counter.counterDAO.getIDAfterCount(counter.moduleName.coeList, sourceCoeData.length); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const coeIdx = coeCount.sequence_value - (sourceCoeData.length - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sourceCoeData.forEach((coe, index) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        coeIDMap[coe.ID] = coeIdx + index; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        newCoeData.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ...coe, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            libID: targetLibID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ID: coeIDMap[coe.ID] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    await stdRationCoeModel.insertMany(newCoeData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // ration-section 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const sectionIDMap = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const newSectionData = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const sourceSectionData = await _stdRationSectionModel.find({ rationRepId: sourceLibID }, '-_id').lean(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const sectionCount = await counter.counterDAO.getIDAfterCount(counter.moduleName.rationTree, sourceSectionData.length); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const sectionIdx = sectionCount.sequence_value - (sourceSectionData.length - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sourceSectionData.forEach((section, index) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sectionIDMap[section.ID] = sectionIdx + index; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sourceSectionData.forEach(section => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        newSectionData.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ...section, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            rationRepId: targetLibID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ID: sectionIDMap[section.ID], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ParentID: sectionIDMap[section.ParentID] || -1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            NextSiblingID: sectionIDMap[section.NextSiblingID] || -1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    await stdRationSectionModel.insertMany(newSectionData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // glj 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const sourceGLJData = await stdGLJModel.find({ repositoryId: 182 }, '-_id').lean(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const gljIDMap = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sourceGLJData.forEach(glj => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        gljIDMap[glj.orgID] = glj.ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const newGLJData = sourceGLJData.map(glj => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        delete glj.orgID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return glj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    await stdGLJModel.remove({ repositoryId: 182 }); // 5412 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    await stdGLJModel.insertMany(newGLJData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // ration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const newRationData = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const sourceRationData = await _rationItemModel.find({ rationRepId: sourceLibID }, '-_id').lean(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const rationCount = await counter.counterDAO.getIDAfterCount(counter.moduleName.rations, sourceRationData.length); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const rationIdx = rationCount.sequence_value - (sourceRationData.length - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sourceRationData.forEach((ration, index) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const rationID = rationIdx + index; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const sectionID = sectionIDMap[ration.sectionId]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const newRationCoeList = (ration.rationCoeList || []).map(rCoe => ({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            no: rCoe.no, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ID: coeIDMap[rCoe.ID] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const newRationGLJList = (ration.rationGljList || []).map(rGLJ => ({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ...rGLJ, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            gljId: gljIDMap[rGLJ.gljId], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        newRationData.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ...ration, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            rationRepId: targetLibID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ID: rationID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sectionId: sectionID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            rationCoeList: newRationCoeList, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            rationGljList: newRationGLJList 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    await rationItemModel.insertMany(newRationData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 由于导入excel时,excel数据存在负的工程量,所以导入后一些定额人材机的消耗量可能为负,需要处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 rationItemDAO.prototype.handleMinusQuantity = async function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const updateTask = []; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -46,8 +121,6 @@ rationItemDAO.prototype.handleMinusQuantity = async function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (updateTask.length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await rationItemModel.bulkWrite(updateTask); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    console.log(`repIDs`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    console.log(repIDs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 rationItemDAO.prototype.prepareInitData = async function (rationRepId) { 
			 |