|
@@ -7,6 +7,7 @@ let logger = require("../../../logs/log_helper").logger;
|
|
|
let mongoose = require('mongoose');
|
|
|
let stdLabourCoesModel = mongoose.model('std_labour_coes');
|
|
|
let projectLabourCoesModel = mongoose.model('labour_coes');
|
|
|
+let EngineeringLibModel = require("../../users/models/engineering_lib_model");
|
|
|
|
|
|
module.exports = {
|
|
|
newProjectLabourCoe: newProjectLabourCoe,
|
|
@@ -15,10 +16,16 @@ module.exports = {
|
|
|
};
|
|
|
|
|
|
async function newProjectLabourCoe(data) {
|
|
|
- let stdLC = await getStdLabourCoe(data.libID);
|
|
|
+ let valid_LC_libs = [];
|
|
|
+ let egnrID = data.property.engineering_id;
|
|
|
+ let egnrModel = new EngineeringLibModel();
|
|
|
+ let egnr = await egnrModel.getEngineering(egnrID);
|
|
|
+ if(egnr){ valid_LC_libs = egnr._doc.artificial_lib };
|
|
|
+ // 绑定多个人工系数标准文件时,默认取第一个作为标准模板。
|
|
|
+ let stdLC = await getStdLabourCoe(valid_LC_libs[0].id);
|
|
|
let doc={
|
|
|
ID: uuidV1(),
|
|
|
- projectID: data.projectID,
|
|
|
+ projectID: data.ID,
|
|
|
name: data.name,
|
|
|
libID: stdLC.ID,
|
|
|
libName: stdLC.libName,
|
|
@@ -34,6 +41,7 @@ async function getProjectLabourCoe(ID) {
|
|
|
return projLC;
|
|
|
};
|
|
|
|
|
|
+
|
|
|
async function getStdLabourCoe(libID) {
|
|
|
let stdLC = await stdLabourCoesModel.findOne({ID:libID});
|
|
|
return stdLC;
|