|
@@ -320,6 +320,19 @@ rationItemDAO.prototype.updateRationBasePrc = function (basePrcArr, callback) {
|
|
|
if(theGlj.gljType > 300 && theGlj.gljType < 400){
|
|
|
gljParentType = 3;
|
|
|
}
|
|
|
+ //管理费
|
|
|
+ if(theGlj.gljType === 6){
|
|
|
+ gljParentType = 6;
|
|
|
+ }
|
|
|
+ //利润
|
|
|
+ if(theGlj.gljType === 7){
|
|
|
+ gljParentType = 7;
|
|
|
+ }
|
|
|
+ //风险费
|
|
|
+ if(theGlj.gljType === 8){
|
|
|
+ gljParentType = 8;
|
|
|
+ }
|
|
|
+ if(theGlj)
|
|
|
if(theGlj.ID === adjGljId){
|
|
|
gljArr.push({gljId: theGlj.ID, basePrice: adjBasePrice, gljParentType: gljParentType});
|
|
|
}
|
|
@@ -336,7 +349,14 @@ rationItemDAO.prototype.updateRationBasePrc = function (basePrcArr, callback) {
|
|
|
})
|
|
|
});
|
|
|
//recalculate the price of ration
|
|
|
- let labourPrc = [], materialPrc = [], machinePrc = [], singlePrc, updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, basePrice: 0};
|
|
|
+ let labourPrc = [],
|
|
|
+ materialPrc = [],
|
|
|
+ machinePrc = [],
|
|
|
+ managePrc = [],
|
|
|
+ profitPrc = [],
|
|
|
+ riskPrc = [],
|
|
|
+ singlePrc,
|
|
|
+ updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, managePrice: 0, profitPrice: 0, riskPrice: 0, basePrice: 0};
|
|
|
gljArr.forEach(function (gljItem) {
|
|
|
if(gljItem.gljParentType !== -1){
|
|
|
singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
|
|
@@ -346,9 +366,18 @@ rationItemDAO.prototype.updateRationBasePrc = function (basePrcArr, callback) {
|
|
|
else if(gljItem.gljParentType ===2){
|
|
|
materialPrc.push(singlePrc);
|
|
|
}
|
|
|
- else{
|
|
|
+ else if(gljItem.gljParentType === 3){
|
|
|
machinePrc.push(singlePrc);
|
|
|
}
|
|
|
+ else if(gljItem.gljParentType === 6){
|
|
|
+ managePrc.push(singlePrc);
|
|
|
+ }
|
|
|
+ else if(gljItem.gljParentType === 7){
|
|
|
+ profitPrc.push(singlePrc);
|
|
|
+ }
|
|
|
+ else if(gljItem.gljParentType === 8){
|
|
|
+ riskPrc.push(singlePrc);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
if(labourPrc.length > 0){
|
|
@@ -372,7 +401,29 @@ rationItemDAO.prototype.updateRationBasePrc = function (basePrcArr, callback) {
|
|
|
}
|
|
|
updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
|
|
|
}
|
|
|
- updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.materialPrice + updatePrc.machinePrice, -2);
|
|
|
+ if(managePrc.length > 0){
|
|
|
+ let sumMgP = 0;
|
|
|
+ for(let i =0; i< managePrc.length; i++){
|
|
|
+ sumMgP = scMathUtil.roundTo(sumMgP + managePrc[i], processDecimal);
|
|
|
+ }
|
|
|
+ updatePrc.managePrice = scMathUtil.roundTo(sumMgP, -2);
|
|
|
+ }
|
|
|
+ if(profitPrc.length > 0){
|
|
|
+ let sumPfP = 0;
|
|
|
+ for(let i =0; i< profitPrc.length; i++){
|
|
|
+ sumPfP = scMathUtil.roundTo(sumPfP + profitPrc[i], processDecimal);
|
|
|
+ }
|
|
|
+ updatePrc.profitPrice = scMathUtil.roundTo(sumPfP, -2);
|
|
|
+ }
|
|
|
+ if(riskPrc.length > 0){
|
|
|
+ let sumRkP = 0;
|
|
|
+ for(let i =0; i< riskPrc.length; i++){
|
|
|
+ sumRkP = scMathUtil.roundTo(sumRkP + riskPrc[i], processDecimal);
|
|
|
+ }
|
|
|
+ updatePrc.riskPrice = scMathUtil.roundTo(sumRkP, -2);
|
|
|
+ }
|
|
|
+ updatePrc.basePrice = scMathUtil.roundTo(
|
|
|
+ updatePrc.labourPrice + updatePrc.materialPrice + updatePrc.machinePrice + updatePrc.managePrice + updatePrc.profitPrice + updatePrc.riskPrice, -2);
|
|
|
let task = {
|
|
|
updateOne: {
|
|
|
filter: {
|
|
@@ -525,8 +576,14 @@ rationItemDAO.prototype.updateAnnotation = function (lastOpr, repId, updateArr,
|
|
|
rationItemDAO.prototype.calcForRation = function (stdGljList, ration) {
|
|
|
const processDecimal = -6;
|
|
|
//根据工料机类型划分价格
|
|
|
- const labour = [1], material = [201, 202, 203, 204, 205, 206], machine = [301, 302, 303];
|
|
|
- let labourPrc = [], materialPrc = [], machinePrc = [], singlePrc, updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, basePrice: 0};
|
|
|
+ const labour = [1],
|
|
|
+ material = [201, 202, 203, 204, 205, 206],
|
|
|
+ machine = [301, 302, 303],
|
|
|
+ manage = [6],
|
|
|
+ profit = [7],
|
|
|
+ risk = [8];
|
|
|
+ let labourPrc = [], materialPrc = [], machinePrc = [], managePrc = [], profitPrc = [], riskPrc = [],
|
|
|
+ singlePrc, updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, basePrice: 0, managePrice: 0, profitPrice: 0, riskPrice: 0};
|
|
|
let rationGljList = ration.rationGljList;
|
|
|
for(let rationGlj of rationGljList){
|
|
|
let glj = stdGljList[rationGlj.gljId];
|
|
@@ -542,6 +599,15 @@ rationItemDAO.prototype.calcForRation = function (stdGljList, ration) {
|
|
|
else if(prcType === 'machine'){
|
|
|
machinePrc.push(singlePrc);
|
|
|
}
|
|
|
+ else if(prcType === 'manage'){
|
|
|
+ managePrc.push(singlePrc);
|
|
|
+ }
|
|
|
+ else if(prcType === 'profit'){
|
|
|
+ profitPrc.push(singlePrc);
|
|
|
+ }
|
|
|
+ else if(prcType === 'risk'){
|
|
|
+ riskPrc.push(singlePrc);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//计算人工费
|
|
@@ -568,8 +634,33 @@ rationItemDAO.prototype.calcForRation = function (stdGljList, ration) {
|
|
|
}
|
|
|
updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
|
|
|
}
|
|
|
+ //管理费
|
|
|
+ if(managePrc.length > 0){
|
|
|
+ let sumMgP = 0;
|
|
|
+ for(let i = 0, len = managePrc.length; i < len; i++){
|
|
|
+ sumMgP = scMathUtil.roundTo(sumMgP + managePrc[i], processDecimal);
|
|
|
+ }
|
|
|
+ updatePrc.managePrice = scMathUtil.roundTo(sumMgP, -2);
|
|
|
+ }
|
|
|
+ //利润
|
|
|
+ if(profitPrc.length > 0){
|
|
|
+ let sumPfP = 0;
|
|
|
+ for(let i = 0, len = profitPrc.length; i < len; i++){
|
|
|
+ sumPfP = scMathUtil.roundTo(sumPfP + profitPrc[i], processDecimal);
|
|
|
+ }
|
|
|
+ updatePrc.profitPrice = scMathUtil.roundTo(sumPfP, -2);
|
|
|
+ }
|
|
|
+ //风险费
|
|
|
+ if(riskPrc.length > 0){
|
|
|
+ let sumRkP = 0;
|
|
|
+ for(let i = 0, len = riskPrc.length; i < len; i++){
|
|
|
+ sumRkP = scMathUtil.roundTo(sumRkP + riskPrc[i], processDecimal);
|
|
|
+ }
|
|
|
+ updatePrc.riskPrice = scMathUtil.roundTo(sumRkP, -2);
|
|
|
+ }
|
|
|
//基价
|
|
|
- updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.materialPrice + updatePrc.machinePrice, -2);
|
|
|
+ updatePrc.basePrice = scMathUtil.roundTo(
|
|
|
+ updatePrc.labourPrice + updatePrc.materialPrice + updatePrc.machinePrice + updatePrc.managePrice + updatePrc.profitPrice + updatePrc.riskPrice, -2);
|
|
|
//更新定额数据
|
|
|
ration.labourPrice = updatePrc.labourPrice.toString();
|
|
|
ration.materialPrice = updatePrc.materialPrice.toString();
|
|
@@ -581,15 +672,24 @@ rationItemDAO.prototype.calcForRation = function (stdGljList, ration) {
|
|
|
}
|
|
|
//是否属于人工、材料、机械类型
|
|
|
function getParentType(type){
|
|
|
- if(labour.indexOf(type) !== -1){
|
|
|
+ if(labour.includes(type)){
|
|
|
return 'labour';
|
|
|
}
|
|
|
- if(material.indexOf(type) !== -1){
|
|
|
+ if(material.includes(type)){
|
|
|
return 'material';
|
|
|
}
|
|
|
- if(machine.indexOf(type) !== -1){
|
|
|
+ if(machine.includes(type)){
|
|
|
return 'machine';
|
|
|
}
|
|
|
+ if(manage.includes(type)){
|
|
|
+ return 'manage';
|
|
|
+ }
|
|
|
+ if(profit.includes(type)){
|
|
|
+ return 'profit';
|
|
|
+ }
|
|
|
+ if(risk.includes(type)){
|
|
|
+ return 'risk'
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|