|
@@ -13,7 +13,7 @@ import STDMixRatioModel from "../../common/std/std_mix_ratio_model";
|
|
|
import UnitPriceFileModel from "./unit_price_file_model";
|
|
|
import GLJTypeConst from "../../common/const/glj_type_const";
|
|
|
import RationGLJFacade from "../../ration_glj/facade/ration_glj_facade";
|
|
|
-import STDRationLibGLJListModel from "../../common/std/std_ration_lib_glj_list_model";
|
|
|
+import STDGLJLibGLJListModel from "../../common/std/std_glj_lib_glj_list_model";
|
|
|
import STDGLJType from "../../../public/cache/std_glj_type_util";
|
|
|
import MixRatioModel from "./mix_ratio_model";
|
|
|
|
|
@@ -410,18 +410,18 @@ class GLJListModel extends BaseModel {
|
|
|
*/
|
|
|
async compositionInit(code, projectId, unitPriceFileId) {
|
|
|
// 查找对应组成物的项目工料机数据
|
|
|
- let [projectGljList, compositionList] = await this.getCompositionGLJList(code, projectId, 'name');
|
|
|
+ let [projectGljList, compositionGljList] = await this.getCompositionGLJList(code, projectId, 'name');
|
|
|
|
|
|
// 整理配合比待插入数据
|
|
|
let mixRatioInsertData = [];
|
|
|
- for (let tmp of compositionList) {
|
|
|
+ for (let tmp of compositionGljList) {
|
|
|
// 配合比数据插入
|
|
|
let mixRatioData = {
|
|
|
consumption: tmp.consumption,
|
|
|
- glj_id: tmp.glj_id,
|
|
|
+ glj_id: tmp.ID,
|
|
|
unit_price_file_id: unitPriceFileId,
|
|
|
- connect_code: tmp.connect_code,
|
|
|
- glj_type: tmp.glj_type
|
|
|
+ connect_code: tmp.connectCode,
|
|
|
+ glj_type: tmp.gljType
|
|
|
};
|
|
|
mixRatioInsertData.push(mixRatioData);
|
|
|
}
|
|
@@ -434,32 +434,9 @@ class GLJListModel extends BaseModel {
|
|
|
throw '组成物插入单价数据失败!';
|
|
|
}
|
|
|
// 如果已经存在则后续操作停止
|
|
|
- if(projectGljList.length === compositionList.length) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 插入不存在的项目工料机数据
|
|
|
- let notInGLJId = [];
|
|
|
- let compositionData = {};
|
|
|
- for(let tmp of compositionList) {
|
|
|
- compositionData[tmp.glj_id] = tmp;
|
|
|
- if (projectGljList[tmp.name] !== undefined) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 把不存在的工料机总库id加入数组
|
|
|
- notInGLJId.push(tmp.glj_id);
|
|
|
- }
|
|
|
-
|
|
|
- // 如果没有对应的数据则忽略后面的操作
|
|
|
- if (notInGLJId.length <= 0) {
|
|
|
+ if(projectGljList.length === compositionGljList.length) {
|
|
|
return;
|
|
|
}
|
|
|
- // 查找对应工料机总库数据
|
|
|
- let stdRationLibGLJListModel = new STDRationLibGLJListModel();
|
|
|
- let stdGLJData = await stdRationLibGLJListModel.getDataById(notInGLJId);
|
|
|
- if (stdGLJData === null || stdGLJData.length <= 0) {
|
|
|
- throw '没有找到对应的工料机总库数据';
|
|
|
- }
|
|
|
|
|
|
// 获取工料机类型以及整理数据
|
|
|
let gljTypeList = STDGLJType.getStdGljTypeCacheObj().toArray();
|
|
@@ -471,7 +448,10 @@ class GLJListModel extends BaseModel {
|
|
|
// 整理插入的数据
|
|
|
let gljInsertData = [];
|
|
|
let unitPriceInsertData = [];
|
|
|
- for (let tmp of stdGLJData) {
|
|
|
+ for(let tmp of compositionGljList) {
|
|
|
+ if (projectGljList[tmp.name] !== undefined) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
// 项目工料机插入的数据
|
|
|
let gljData = {
|
|
|
glj_id: tmp.ID,
|
|
@@ -479,7 +459,7 @@ class GLJListModel extends BaseModel {
|
|
|
code: tmp.code,
|
|
|
name: tmp.name,
|
|
|
specs: tmp.specs,
|
|
|
- unit: tmp.unit,
|
|
|
+ unit: tmp.unit === undefined ? '' : tmp.unit,
|
|
|
};
|
|
|
gljInsertData.push(gljData);
|
|
|
|
|
@@ -523,6 +503,7 @@ class GLJListModel extends BaseModel {
|
|
|
try {
|
|
|
// 查找对应的项目工料机数据
|
|
|
let projectGLJData = await this.getDataById(projectGLJId);
|
|
|
+
|
|
|
let allowType = [GLJTypeConst.MIX_RATIO, GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR,
|
|
|
GLJTypeConst.GENERAL_MACHINE];
|
|
|
|
|
@@ -587,17 +568,17 @@ class GLJListModel extends BaseModel {
|
|
|
* @return {Promise} 返回组成物工料机数据和组成物列表数据
|
|
|
*/
|
|
|
async getCompositionGLJList(code, projectId, indexBy = null) {
|
|
|
- // 首先获取对应组成物列表
|
|
|
- let stdMixRatioModel = new STDMixRatioModel();
|
|
|
- let compositionList = await stdMixRatioModel.getDataByCode(code);
|
|
|
+ // 获取对应的组成物数据
|
|
|
+ let stdGljLibGljListModel = new STDGLJLibGLJListModel();
|
|
|
+ let componentGljList = await stdGljLibGljListModel.getComponent(code);
|
|
|
|
|
|
- if (compositionList.length <= 0) {
|
|
|
+ if (componentGljList.length <= 0) {
|
|
|
throw '不存在对应的组成物';
|
|
|
}
|
|
|
|
|
|
let codeList = [];
|
|
|
let nameList = [];
|
|
|
- for(let tmp of compositionList) {
|
|
|
+ for(let tmp of componentGljList) {
|
|
|
codeList.push(tmp.code);
|
|
|
nameList.push(tmp.name);
|
|
|
}
|
|
@@ -606,7 +587,7 @@ class GLJListModel extends BaseModel {
|
|
|
let condition = {code: {"$in": codeList}, name: {"$in": nameList}, project_id: projectId};
|
|
|
let gljData = await this.findDataByCondition(condition, {_id: 0}, false, indexBy);
|
|
|
|
|
|
- return [gljData, compositionList];
|
|
|
+ return [gljData, componentGljList];
|
|
|
}
|
|
|
|
|
|
/**
|