|
|
@@ -46,9 +46,9 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
|
glj_result:[],
|
|
|
rationID:query.rationID
|
|
|
};
|
|
|
- let impactRation = await ration.findOne({ID:query.rationID,projectID:query.projectID});
|
|
|
+ let impactRation = await ration.findOne({ID:query.rationID});
|
|
|
let gljList = await ration_glj.find(query);//{projectID:query.projectID,rationID:query.rationID}
|
|
|
- let coeList = await ration_coe.find({projectID:query.projectID,rationID:query.rationID}).sort('seq').exec();
|
|
|
+ let coeList = await ration_coe.find({rationID:query.rationID}).sort('seq').exec();
|
|
|
let assList=[];
|
|
|
let assRation = null;
|
|
|
let adjustState=[];
|
|
|
@@ -68,10 +68,10 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
|
gljList = sortRationGLJ(gljList);
|
|
|
for(let i =0;i<gljList.length;i++ ){
|
|
|
let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,noNeedCal);
|
|
|
- result.glj_result.push(r);
|
|
|
+ if(quantityUpdateCheck(gljList[i],r) == true) result.glj_result.push(r);
|
|
|
}
|
|
|
|
|
|
- if(noNeedCal==null){
|
|
|
+ if(noNeedCal==null && result.glj_result.length > 0){
|
|
|
await ration_glj.bulkWrite(generateUpdateTasks(result.glj_result));
|
|
|
}
|
|
|
adjustState= _.sortByOrder(adjustState, ['index'], ['asc']);
|
|
|
@@ -83,7 +83,7 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
|
setData.name = newName;
|
|
|
result.rationName = newName;
|
|
|
}
|
|
|
- await ration.update({projectID:query.projectID,ID:query.rationID,deleteInfo: null},setData);
|
|
|
+ await ration.update({ID:query.rationID},setData);
|
|
|
result.adjustState=adjustStateString;
|
|
|
return result;
|
|
|
}catch (err){
|
|
|
@@ -92,6 +92,14 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function quantityUpdateCheck(glj,r) {//检查,有改变的才更新
|
|
|
+ for(let key in r.doc){
|
|
|
+ if(glj._doc[key] != r.doc[key]) return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
function generateRationName(ration,gljList) {
|
|
|
let caption = ration.caption ? ration.caption:ration.name;
|
|
|
if(ration.rationAssList && ration.rationAssList.length > 0){
|