|  | @@ -21,6 +21,35 @@ import stdgljutil  from "../../../public/cache/std_glj_type_util";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  var rationItemDAO = function(){};
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +// 由于导入excel时,excel数据存在负的工程量,所以导入后一些定额人材机的消耗量可能为负,需要处理
 | 
	
		
			
				|  |  | +rationItemDAO.prototype.handleMinusQuantity = async function() {
 | 
	
		
			
				|  |  | +    const updateTask = [];
 | 
	
		
			
				|  |  | +    const repIDs = new Set();
 | 
	
		
			
				|  |  | +    const rations = await rationItemModel.find({'rationGljList.consumeAmt': {$lt: 0}}).lean();
 | 
	
		
			
				|  |  | +    for (const ration of rations) {
 | 
	
		
			
				|  |  | +        repIDs.add(ration.rationRepId);
 | 
	
		
			
				|  |  | +        const rationGLJList = [];
 | 
	
		
			
				|  |  | +        for (const rGLJ of ration.rationGljList) {
 | 
	
		
			
				|  |  | +            rationGLJList.push({
 | 
	
		
			
				|  |  | +                gljId: rGLJ.gljId,
 | 
	
		
			
				|  |  | +                consumeAmt: Math.abs(rGLJ.consumeAmt),
 | 
	
		
			
				|  |  | +                proportion: rGLJ.proportion
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        updateTask.push({
 | 
	
		
			
				|  |  | +            updateOne: {
 | 
	
		
			
				|  |  | +                filter: { ID: ration.ID },
 | 
	
		
			
				|  |  | +                update: { $set: { rationGljList: rationGLJList } }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    if (updateTask.length) {
 | 
	
		
			
				|  |  | +        await rationItemModel.bulkWrite(updateTask);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    console.log(`repIDs`);
 | 
	
		
			
				|  |  | +    console.log(repIDs);
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  rationItemDAO.prototype.prepareInitData = async function (rationRepId) {
 | 
	
		
			
				|  |  |      // 定额库
 | 
	
		
			
				|  |  |      const libTask = stdRationLibModel.findOne({ID: rationRepId}, '-_id ID dispName gljLib');
 | 
	
	
		
			
				|  | @@ -878,7 +907,7 @@ rationItemDAO.prototype.batchAddFromExcel = async function(rationRepId, data) {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              const tmpRationGlj = {
 | 
	
		
			
				|  |  |                  gljId: stdGLJList[tmp[1]],
 | 
	
		
			
				|  |  | -                consumeAmt: tmp[4],
 | 
	
		
			
				|  |  | +                consumeAmt: Math.abs(tmp[4]),
 | 
	
		
			
				|  |  |                  proportion: 0,
 | 
	
		
			
				|  |  |              };
 | 
	
		
			
				|  |  |              lastData.rationGljList.push(tmpRationGlj);
 |