|
@@ -10,6 +10,7 @@ let ration = mongoose.model('ration');
|
|
let ration_coe = mongoose.model('ration_coe');
|
|
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 std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
|
|
let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
|
|
|
|
+let project_model = mongoose.model('projects');
|
|
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');
|
|
let decimal_facade = require('../../main/facade/decimal_facade');
|
|
@@ -19,7 +20,7 @@ module.exports={
|
|
calculateQuantity:calculateQuantity,
|
|
calculateQuantity:calculateQuantity,
|
|
getGLJTypeByID:getGLJTypeByID
|
|
getGLJTypeByID:getGLJTypeByID
|
|
}
|
|
}
|
|
-//辅助定额调整、替换工料机、标准附注条件调整、添加工料机、自定义消耗量(包括删除工料机)、自定义乘系数、市场单价调整
|
|
|
|
|
|
+//辅助定额调整、替换工料机、标准附注条件调整、添加工料机、自定义消耗量(包括删除工料机)、自定义乘系数、面积增加、市场单价调整
|
|
let stateSeq ={
|
|
let stateSeq ={
|
|
ass:1,
|
|
ass:1,
|
|
replace:2,
|
|
replace:2,
|
|
@@ -27,7 +28,8 @@ let stateSeq ={
|
|
add:4,
|
|
add:4,
|
|
cusQuantity:5,
|
|
cusQuantity:5,
|
|
cusCoe:6,
|
|
cusCoe:6,
|
|
- adjMak:7
|
|
|
|
|
|
+ area:7,
|
|
|
|
+ adjMak:8
|
|
};
|
|
};
|
|
//自定义乘系数与定额工料机类型映射表
|
|
//自定义乘系数与定额工料机类型映射表
|
|
let coeTypeMap = {
|
|
let coeTypeMap = {
|
|
@@ -40,7 +42,7 @@ let coeTypeMap = {
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
-async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
|
|
|
|
+async function calculateQuantity(query,noNeedCal,refreshRationName = false,areaIncreaseFee,areaSetting){
|
|
try {
|
|
try {
|
|
let result ={
|
|
let result ={
|
|
glj_result:[],
|
|
glj_result:[],
|
|
@@ -55,6 +57,7 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
if(!impactRation){//如果定额不存在或者已删除,返回空
|
|
if(!impactRation){//如果定额不存在或者已删除,返回空
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+ if(areaIncreaseFee !== null || areaIncreaseFee !== undefined) impactRation.areaIncreaseFee = areaIncreaseFee;
|
|
if(impactRation._doc.hasOwnProperty("rationAssList")&&impactRation.rationAssList.length>0){
|
|
if(impactRation._doc.hasOwnProperty("rationAssList")&&impactRation.rationAssList.length>0){
|
|
let temTimes = [];
|
|
let temTimes = [];
|
|
let thirdRationCodes=[];
|
|
let thirdRationCodes=[];
|
|
@@ -89,6 +92,8 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
if(noNeedCal==null && result.glj_result.length > 0){
|
|
if(noNeedCal==null && result.glj_result.length > 0){
|
|
await ration_glj.bulkWrite(generateUpdateTasks(result.glj_result));
|
|
await ration_glj.bulkWrite(generateUpdateTasks(result.glj_result));
|
|
}
|
|
}
|
|
|
|
+ if(impactRation.areaIncreaseFee == true) await setAreaAdjustState(impactRation.projectID,adjustState,areaSetting);
|
|
|
|
+
|
|
adjustState= _.sortByOrder(adjustState, ['index'], ['asc']);
|
|
adjustState= _.sortByOrder(adjustState, ['index'], ['asc']);
|
|
adjustState=_.map(adjustState, _.property('content'));
|
|
adjustState=_.map(adjustState, _.property('content'));
|
|
let adjustStateString = adjustState.join(';');
|
|
let adjustStateString = adjustState.join(';');
|
|
@@ -98,7 +103,8 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
setData.name = newName;
|
|
setData.name = newName;
|
|
result.rationName = newName;
|
|
result.rationName = newName;
|
|
}
|
|
}
|
|
- await ration.update({ID:query.rationID},setData);
|
|
|
|
|
|
+ //如果uareaIncreaseFee有值说明是从其它更新定额的地方进来的,后面会一起更新
|
|
|
|
+ if(areaIncreaseFee === null || areaIncreaseFee === undefined) await ration.update({ID:query.rationID},setData);
|
|
result.adjustState=adjustStateString;
|
|
result.adjustState=adjustStateString;
|
|
return result;
|
|
return result;
|
|
}catch (err){
|
|
}catch (err){
|
|
@@ -107,6 +113,31 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+async function setAreaAdjustState(projectID,adjustState,areaSetting){
|
|
|
|
+ if(!areaSetting){
|
|
|
|
+ let project = await project_model.findOne({ID:projectID},'property.areaSetting');
|
|
|
|
+ areaSetting = project.property.areaSetting;
|
|
|
|
+ }
|
|
|
|
+ if(areaSetting){
|
|
|
|
+ let stringArr = [];
|
|
|
|
+ let labour = getStr(areaSetting.labour);
|
|
|
|
+ let material = getStr(areaSetting.material);
|
|
|
|
+ let machine = getStr(areaSetting.machine);
|
|
|
|
+ if(labour !="") stringArr.push(`人工*${labour}`);
|
|
|
|
+ if(material !="") stringArr.push(`材料*${material}`);
|
|
|
|
+ if(machine !="") stringArr.push(`机械*${machine}`);
|
|
|
|
+ if(stringArr.length > 0){
|
|
|
|
+ adjustState.push({index:stateSeq.area,content:`面积:${stringArr.join(',')}`});//面积:人工*1.1,材料*1.015”。
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function getStr(num) {
|
|
|
|
+ if(num != 0) return 1 + num/100;
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
function quantityUpdateCheck(glj,r) {//检查,有改变的才更新
|
|
function quantityUpdateCheck(glj,r) {//检查,有改变的才更新
|
|
for(let key in r.doc){
|
|
for(let key in r.doc){
|
|
if(glj._doc[key] != r.doc[key]) return true
|
|
if(glj._doc[key] != r.doc[key]) return true
|
|
@@ -259,7 +290,8 @@ function generateAdjustState(glj,coeList,adjustState,gljList,quantity) {
|
|
for(let i=0;i<coeList.length;i++){
|
|
for(let i=0;i<coeList.length;i++){
|
|
if(coeList[i].isAdjust==1){
|
|
if(coeList[i].isAdjust==1){
|
|
if(i==coeList.length-1){
|
|
if(i==coeList.length-1){
|
|
- adjustState.push({index:stateSeq.cusCoe,content:getContent(coeList[i].coes)});//自定义乘系数要去掉倍数为1的
|
|
|
|
|
|
+ let cus_content = getContent(coeList[i].coes);
|
|
|
|
+ if(cus_content !="") adjustState.push({index:stateSeq.cusCoe,content:cus_content});//自定义乘系数要去掉倍数为1的
|
|
}else {
|
|
}else {
|
|
if(coeList[i].select_code && coeList[i].select_code!=""){
|
|
if(coeList[i].select_code && coeList[i].select_code!=""){
|
|
_.remove(adjustState,{'content':coeList[i].original_code+'换'+coeList[i].select_code});//去掉替换工料机自动生成的调整状态
|
|
_.remove(adjustState,{'content':coeList[i].original_code+'换'+coeList[i].select_code});//去掉替换工料机自动生成的调整状态
|