|
@@ -15,15 +15,17 @@ module.exports = {
|
|
|
deleteSubListByQuery:deleteSubListByQuery,
|
|
deleteSubListByQuery:deleteSubListByQuery,
|
|
|
updateCoeAdjust:updateCoeAdjust,
|
|
updateCoeAdjust:updateCoeAdjust,
|
|
|
getUnitPriceData:getUnitPriceData,
|
|
getUnitPriceData:getUnitPriceData,
|
|
|
- setIDfromCounter:setIDfromCounter,
|
|
|
|
|
- getNewProjectGLJFromMissMixratio:getNewProjectGLJFromMissMixratio
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
let mongoose = require('mongoose');
|
|
let mongoose = require('mongoose');
|
|
|
-import SearchDao from '../../complementary_ration_lib/models/searchModel';
|
|
|
|
|
-import GLJListModel from "../../glj/models/glj_list_model";
|
|
|
|
|
-import e from 'express';
|
|
|
|
|
|
|
+const SearchDao = require('../../complementary_ration_lib/models/searchModel');
|
|
|
|
|
+const GLJListModel = require("../../glj/models/glj_list_model");
|
|
|
|
|
+const {
|
|
|
|
|
+ getProjectGLJNewData,
|
|
|
|
|
+ setIDfromCounter
|
|
|
|
|
+} = require('../facade/common_facade');
|
|
|
|
|
+const e = require('express');
|
|
|
const scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
const scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
|
let gljUtil = require('../../../public/gljUtil');
|
|
let gljUtil = require('../../../public/gljUtil');
|
|
|
let ration_glj_facade = require("../../ration_glj/facade/ration_glj_facade");
|
|
let ration_glj_facade = require("../../ration_glj/facade/ration_glj_facade");
|
|
@@ -51,7 +53,6 @@ let compleCoeModel = mongoose.model('complementary_ration_coe_list');
|
|
|
let projectGLJModel = mongoose.model("glj_list");
|
|
let projectGLJModel = mongoose.model("glj_list");
|
|
|
let mixRatioModel = mongoose.model("mix_ratio");
|
|
let mixRatioModel = mongoose.model("mix_ratio");
|
|
|
let complementaryGljLibModel = mongoose.model('complementary_glj_lib');
|
|
let complementaryGljLibModel = mongoose.model('complementary_glj_lib');
|
|
|
-let counterModel = mongoose.model('counter');
|
|
|
|
|
|
|
|
|
|
let _= require('lodash');
|
|
let _= require('lodash');
|
|
|
const projectDao = require('../../pm/models/project_model').project;
|
|
const projectDao = require('../../pm/models/project_model').project;
|
|
@@ -590,7 +591,7 @@ async function addRationGLJ(std,newRation,compilation,isMaterial,connect_key) {
|
|
|
if(isMaterial == true){//材料计算添加时要先检查
|
|
if(isMaterial == true){//材料计算添加时要先检查
|
|
|
for(let sub of std.rationGljList){
|
|
for(let sub of std.rationGljList){
|
|
|
let t_g = getStdGlj(sub,stdGLJMap,cptGLJMap,{},ext);
|
|
let t_g = getStdGlj(sub,stdGLJMap,cptGLJMap,{},ext);
|
|
|
- if(t_g && connect_key == gljUtil.getIndex(t_g,['code','name','specs','unit','gljType'])) throw `本定额中包含工料机[${t_g.code}]${t_g.name},与当前工料机编号相同,添加定额失败`;
|
|
|
|
|
|
|
+ if(t_g && connect_key == gljUtil.getIndex(t_g,['code','name','specs','unit','gljType'])) throw `本定额中包含工料机[${t_g.code}]${t_g.name},与当前工料机编号相同,添加定额失败!`;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
for(let sub of std.rationGljList){
|
|
for(let sub of std.rationGljList){
|
|
@@ -972,104 +973,6 @@ async function getMixRatioInfo(projectID,projectGLJMap,newProjectGLJList,mixRati
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-//根据缺少项目工料机的组成物信息,反向生成对应的项目工料机
|
|
|
|
|
-async function getNewProjectGLJFromMissMixratio(projectID,lessMix,projectGLJMap,newProjectGLJList,ext){
|
|
|
|
|
- let lessIDList=[];
|
|
|
|
|
- let uniqMap ={};//去重
|
|
|
|
|
- let lessStdMix = [];//防止组成物中改了名称等,但是通过glj_id取出来的是还没改前的原始数据
|
|
|
|
|
- if(lessMix.length > 0){
|
|
|
|
|
- for(let lm of lessMix){
|
|
|
|
|
- let parentglj = projectGLJMap[lm.connect_key];
|
|
|
|
|
- if(!parentglj) throw `含有组成物工料机${lm.connect_key},没有找到,添加定额失败`;
|
|
|
|
|
- if((parentglj.from == "std" || lm.from == "std") && lm.code!="80CCS"){//车船税特殊处理
|
|
|
|
|
- if(!uniqMap[lm.glj_id]){
|
|
|
|
|
- lessIDList.push(lm.glj_id);
|
|
|
|
|
- uniqMap[lm.glj_id] = lm;
|
|
|
|
|
- }
|
|
|
|
|
- lessStdMix.push(lm);
|
|
|
|
|
- }else {//来自组成物的直接设置
|
|
|
|
|
- lm.from = 'cpt';
|
|
|
|
|
- lm.gljType = lm.type;
|
|
|
|
|
- let t_mg = getProjectGLJNewData(lm,projectID);
|
|
|
|
|
- newProjectGLJList.push(t_mg);
|
|
|
|
|
- projectGLJMap[getIndex(lm)] = t_mg;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if(lessIDList.length > 0){
|
|
|
|
|
- let less_stds = await std_glj_lib_gljList_model.find({'ID':{'$in':lessIDList}}).lean();
|
|
|
|
|
- let less_stds_map = {};
|
|
|
|
|
- for(let les of less_stds){
|
|
|
|
|
- less_stds_map[les.ID] = les;
|
|
|
|
|
- }
|
|
|
|
|
- for(let t_l_m of lessStdMix){
|
|
|
|
|
- let t_nglj = less_stds_map[t_l_m.glj_id];
|
|
|
|
|
- t_nglj.from = 'std';
|
|
|
|
|
- //防止组成物中改了名称等,但是通过glj_id取出来的是还没改前的原始数据
|
|
|
|
|
- t_nglj.name = t_l_m.name;
|
|
|
|
|
- t_nglj.code = t_l_m.code;
|
|
|
|
|
- t_nglj.gljType = t_l_m.type;
|
|
|
|
|
- t_nglj.specs = t_l_m.specs;
|
|
|
|
|
- t_nglj.unit = t_l_m.unit;
|
|
|
|
|
- let t_np = getProjectGLJNewData(t_nglj,projectID,ext);
|
|
|
|
|
- newProjectGLJList.push(t_np);
|
|
|
|
|
- projectGLJMap[getIndex(t_l_m)] = t_np;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return newProjectGLJList;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-function getProjectGLJNewData(tmp,projectId,ext){
|
|
|
|
|
- let gljData = {
|
|
|
|
|
- glj_id: tmp.ID,
|
|
|
|
|
- repositoryId:tmp.repositoryId,
|
|
|
|
|
- project_id: projectId,
|
|
|
|
|
- code: tmp.code,
|
|
|
|
|
- name: tmp.name,
|
|
|
|
|
- specs: tmp.specs?tmp.specs:'',
|
|
|
|
|
- unit: tmp.unit === undefined ? '' : tmp.unit,
|
|
|
|
|
- type: tmp.gljType,
|
|
|
|
|
- adjCoe:tmp.adjCoe,
|
|
|
|
|
- original_code:tmp.code,
|
|
|
|
|
- materialType: tmp.materialType, //三材类别
|
|
|
|
|
- materialCoe: tmp.materialCoe,
|
|
|
|
|
- base_price: tmp.basePrice,
|
|
|
|
|
- market_price: tmp.basePrice,
|
|
|
|
|
- is_adjust_price:0,
|
|
|
|
|
- is_main_material:1,
|
|
|
|
|
- from:tmp.from?tmp.from:"std"
|
|
|
|
|
- };
|
|
|
|
|
- if(gljData.from == 'std' && ext && ext.priceField &&(tmp.priceProperty && tmp.priceProperty[ext.priceField]!= undefined && tmp.priceProperty[ext.priceField]!=null)){
|
|
|
|
|
- const basePrice = scMathUtil.roundTo(tmp.priceProperty[ext.priceField],-6);
|
|
|
|
|
- gljData.base_price = basePrice;
|
|
|
|
|
- gljData.market_price = basePrice;
|
|
|
|
|
- }
|
|
|
|
|
- return gljData;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-async function setIDfromCounter(name,list,map,keyfield){//map,keyfield
|
|
|
|
|
-
|
|
|
|
|
- let update = {$inc: {sequence_value: list.length}};
|
|
|
|
|
- let condition = {_id: name};
|
|
|
|
|
- let options = {new: true};
|
|
|
|
|
-
|
|
|
|
|
- // 先查找更新
|
|
|
|
|
- let counter = await counterModel.findOneAndUpdate(condition, update, options);
|
|
|
|
|
- let firstID = counter.sequence_value - (list.length - 1);
|
|
|
|
|
- for(let a of list){
|
|
|
|
|
- a.id = firstID;
|
|
|
|
|
- firstID+=1
|
|
|
|
|
- if(map && keyfield){
|
|
|
|
|
- let key = a[keyfield];
|
|
|
|
|
- map[key]?map[key].push(a):map[key]=[a]
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
function getStdGlj(sub,stdGLJMap,cptGLJMap,newGLJ,ext) {
|
|
function getStdGlj(sub,stdGLJMap,cptGLJMap,newGLJ,ext) {
|
|
|
let std_glj = null;
|
|
let std_glj = null;
|
|
|
if(sub.type == 'complementary'){//有可能来自标准工料机库或补充工料机库
|
|
if(sub.type == 'complementary'){//有可能来自标准工料机库或补充工料机库
|
|
@@ -1170,7 +1073,7 @@ async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,cal
|
|
|
//定额前缀 none:0, complementary:1, borrow: 2
|
|
//定额前缀 none:0, complementary:1, borrow: 2
|
|
|
ration.prefix = '';
|
|
ration.prefix = '';
|
|
|
//借用优先级比补充高
|
|
//借用优先级比补充高
|
|
|
- if(ration.from === ' std' && std.rationRepId !== parseInt(defaultLibID)){//借用
|
|
|
|
|
|
|
+ if(ration.from === 'std' && std.rationRepId !== parseInt(defaultLibID)){//借用
|
|
|
ration.prefix = '借';
|
|
ration.prefix = '借';
|
|
|
} else if(ration.from === 'cpt') {
|
|
} else if(ration.from === 'cpt') {
|
|
|
ration.prefix = '补';
|
|
ration.prefix = '补';
|