Browse Source

bug fixed

zhangweicheng 7 years ago
parent
commit
3412f7413e
3 changed files with 24 additions and 13 deletions
  1. 2 2
      logs/log4js.json
  2. 13 11
      modules/ration_glj/facade/glj_calculate_facade.js
  3. 9 0
      test/logs/testlog.js

+ 2 - 2
logs/log4js.json

@@ -16,7 +16,7 @@
     "default": { "appenders": ["console"], "level": "debug"},
     "logInfo":{ "appenders": ["logInfo","console"], "level": "debug"},
     "logDebug":{ "appenders": ["logDebug","console"], "level": "debug"},
-    "logWarn":{ "appenders": ["logWarn"], "level": "debug"},
-    "logErr":{ "appenders": ["logErr"], "level": "debug"}
+    "logWarn":{ "appenders": ["logWarn","console"], "level": "debug"},
+    "logErr":{ "appenders": ["logErr","console"], "level": "debug"}
   }
 }

+ 13 - 11
modules/ration_glj/facade/glj_calculate_facade.js

@@ -51,7 +51,7 @@ async function calculateQuantity(query,isMarkPriceAjust){
                  }
          }
          for(let i =0;i<gljList.length;i++ ){
-             let r = await calculateQuantityPerGLJ(gljList[i],impactRation,coeList,assList,adjustState,isMarkPriceAjust);
+             let r = await calculateQuantityPerGLJ(gljList[i],i,coeList,assList,adjustState,isMarkPriceAjust);
              result.glj_result.push(r);
          }
 
@@ -85,7 +85,7 @@ function generateUpdateTasks(result) {
 }
 
 
-async function calculateQuantityPerGLJ(glj,ration,coeList,assList,adjustState,isMarkPriceAjust) {
+async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,isMarkPriceAjust) {
     let quantity =  glj.quantity;
     let result={
         query:{
@@ -112,7 +112,7 @@ async function calculateQuantityPerGLJ(glj,ration,coeList,assList,adjustState,is
             }
             result.doc.quantity =_.round(quantity,3);
         }
-        generateAdjustState(glj,coeList,adjustState);
+        generateAdjustState(glj,coeList,adjustState,index);
         return result;
     }catch (err){
         throw err;
@@ -134,23 +134,25 @@ function calculateAss(quantity,assList,glj) {
     return quantity;
 }
 
-function generateAdjustState(glj,coeList,adjustState) {
+function generateAdjustState(glj,coeList,adjustState,index) {
    //替换工料机 and  添加工料机
 
     // to do
 
   //标准附注条件调整 + 自定义乘系数
-    for(let i=0;i<coeList.length;i++){
-        if(coeList[i].isAdjust==1){
-            if(i==coeList.length-1){
-                adjustState.push({index:stateSeq.cusCoe,content:coeList[i].content});
-            }else {
-                adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].content});
+    if(0==index){
+        for(let i=0;i<coeList.length;i++){
+            if(coeList[i].isAdjust==1){
+                if(i==coeList.length-1){
+                    adjustState.push({index:stateSeq.cusCoe,content:coeList[i].content});
+                }else {
+                    adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].content});
+                }
             }
         }
     }
 
- //自定义消耗量
+    //自定义消耗量
     if(glj._doc.hasOwnProperty('customQuantity')){
         if(glj.customQuantity!==null){
             adjustState.push({index:stateSeq.cusQuantity,content:glj.code+'量'+glj.customQuantity});

+ 9 - 0
test/logs/testlog.js

@@ -0,0 +1,9 @@
+/**
+ * Created by chen on 2017/9/13.
+ */
+let logger = require("../../logs/log_helper").logger;
+
+logger.info("log info...");
+logger.debug("log debug...");
+logger.warn("log warn...");
+logger.err("log err...");