|
@@ -246,11 +246,11 @@ async function addRationGLJ(std,newRation) {
|
|
|
let cptGLJID=[];//补充工料机ID数组
|
|
|
//let stdGLJID = _.map(std.rationGljList,'gljId');
|
|
|
for(let tem_g of std.rationGljList){
|
|
|
- if(tem_g.type == 'std'){
|
|
|
- stdGLJID.push(tem_g.gljId);
|
|
|
- }else if(tem_g.type == 'complementary'){
|
|
|
+ if(tem_g.type == 'complementary'){
|
|
|
cptGLJID.push(tem_g.gljId);
|
|
|
- }
|
|
|
+ }else {
|
|
|
+ stdGLJID.push(tem_g.gljId);
|
|
|
+ }
|
|
|
}
|
|
|
let stdGLJList = stdGLJID.length > 0 ? await std_glj_lib_gljList_model.find({'ID':{'$in':stdGLJID}}):[];//速度优化-------先一次性取出所有的工料机列表
|
|
|
let stdGLJMap = _.indexBy(stdGLJList, 'ID');
|
|
@@ -269,13 +269,13 @@ async function addRationGLJ(std,newRation) {
|
|
|
newGLJ.quantity = sub.consumeAmt;
|
|
|
newGLJ.glj_repository_id = std.rationRepId;
|
|
|
let std_glj = null;
|
|
|
- if(sub.type == 'std'){//有可能来自标准工料机库或补充工料机库
|
|
|
- std_glj = stdGLJMap[sub.gljId];
|
|
|
- newGLJ.from = 'std';
|
|
|
- }else if(sub.type == 'complementary'){
|
|
|
+ if(sub.type == 'complementary'){//有可能来自标准工料机库或补充工料机库
|
|
|
std_glj = cptGLJMap[sub.gljId];
|
|
|
newGLJ.from = 'cpt';
|
|
|
- }
|
|
|
+ }else {
|
|
|
+ std_glj = stdGLJMap[sub.gljId];
|
|
|
+ newGLJ.from = 'std';
|
|
|
+ }
|
|
|
let std_gljTime = +new Date();
|
|
|
if(std_glj){
|
|
|
newGLJ.name = std_glj.name;
|