|
@@ -11,6 +11,7 @@ let ration_coe = mongoose.model('ration_coe');
|
|
let std_ration_lib_ration_items = mongoose.model('std_ration_lib_ration_items');
|
|
let std_ration_lib_ration_items = mongoose.model('std_ration_lib_ration_items');
|
|
let glj_type_util = require('../../../public/cache/std_glj_type_util');
|
|
let glj_type_util = require('../../../public/cache/std_glj_type_util');
|
|
const scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
const scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
|
|
+let decimal_facade = require('../../main/facade/decimal_facade');
|
|
|
|
|
|
module.exports={
|
|
module.exports={
|
|
calculateQuantity:calculateQuantity,
|
|
calculateQuantity:calculateQuantity,
|
|
@@ -86,7 +87,9 @@ function generateUpdateTasks(result) {
|
|
|
|
|
|
|
|
|
|
async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noNeedCal) {
|
|
async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noNeedCal) {
|
|
- let quantity = scMathUtil.roundTo(parseFloat(glj.quantity),-6);
|
|
|
|
|
|
+ let decimalObject =await decimal_facade.getProjectDecimal(glj.projectID);
|
|
|
|
+ let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
|
|
|
|
+ let quantity = scMathUtil.roundTo(parseFloat(glj.quantity),-decimal);
|
|
let result={
|
|
let result={
|
|
query:{
|
|
query:{
|
|
ID:glj.ID,
|
|
ID:glj.ID,
|
|
@@ -99,7 +102,7 @@ async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noN
|
|
try {
|
|
try {
|
|
if(noNeedCal==null){
|
|
if(noNeedCal==null){
|
|
if(!glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null){
|
|
if(!glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null){
|
|
- quantity =scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-6);
|
|
|
|
|
|
+ quantity =scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-decimal);
|
|
quantity =calculateAss(quantity,assList,glj);
|
|
quantity =calculateAss(quantity,assList,glj);
|
|
quantity = calculateQuantityByCoes(quantity,coeList,glj);
|
|
quantity = calculateQuantityByCoes(quantity,coeList,glj);
|
|
}else {
|
|
}else {
|
|
@@ -110,9 +113,9 @@ async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noN
|
|
if(customerCoe.isAdjust==1){
|
|
if(customerCoe.isAdjust==1){
|
|
quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj);
|
|
quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj);
|
|
}
|
|
}
|
|
- result.doc.quantity =_.round(quantity,3);
|
|
|
|
|
|
+ result.doc.quantity =scMathUtil.roundToString(quantity,decimal);
|
|
}
|
|
}
|
|
- generateAdjustState(glj,coeList,adjustState,index);
|
|
|
|
|
|
+ generateAdjustState(glj,coeList,adjustState,index,result.doc.quantity);
|
|
return result;
|
|
return result;
|
|
}catch (err){
|
|
}catch (err){
|
|
throw err;
|
|
throw err;
|
|
@@ -134,12 +137,12 @@ function calculateAss(quantity,assList,glj) {
|
|
return scMathUtil.roundTo(quantity,-6);
|
|
return scMathUtil.roundTo(quantity,-6);
|
|
}
|
|
}
|
|
|
|
|
|
-function generateAdjustState(glj,coeList,adjustState,index) {
|
|
|
|
|
|
+function generateAdjustState(glj,coeList,adjustState,index,quantity) {
|
|
//替换工料机 and 添加工料机
|
|
//替换工料机 and 添加工料机
|
|
if(glj._doc.createType=='replace'){
|
|
if(glj._doc.createType=='replace'){
|
|
adjustState.push({index:stateSeq.replase,content:glj.rcode+'换'+glj.code});
|
|
adjustState.push({index:stateSeq.replase,content:glj.rcode+'换'+glj.code});
|
|
}else if(glj._doc.createType=='add'){
|
|
}else if(glj._doc.createType=='add'){
|
|
- adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+glj.quantity});
|
|
|
|
|
|
+ adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+parseFloat(quantity)});
|
|
}
|
|
}
|
|
// to do
|
|
// to do
|
|
|
|
|
|
@@ -158,8 +161,8 @@ function generateAdjustState(glj,coeList,adjustState,index) {
|
|
|
|
|
|
//自定义消耗量
|
|
//自定义消耗量
|
|
if(glj._doc.createType!='add'&&glj._doc.hasOwnProperty('customQuantity')){
|
|
if(glj._doc.createType!='add'&&glj._doc.hasOwnProperty('customQuantity')){
|
|
- if(glj.customQuantity!==null){
|
|
|
|
- adjustState.push({index:stateSeq.cusQuantity,content:glj.code+'量'+glj.customQuantity});
|
|
|
|
|
|
+ if(glj.customQuantity!==null&&glj.customQuantity!=""){
|
|
|
|
+ adjustState.push({index:stateSeq.cusQuantity,content:glj.code+'量'+parseFloat(glj.customQuantity)});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//市场单价调整
|
|
//市场单价调整
|