|
@@ -8,14 +8,20 @@ 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");
|
|
|
+let _=require("lodash");
|
|
|
+let consts = require('../models/project_consts');
|
|
|
+let projectConsts = consts.projectConst;
|
|
|
|
|
|
module.exports = {
|
|
|
newProjectLabourCoe: newProjectLabourCoe,
|
|
|
getProjectLabourCoe: getProjectLabourCoe,
|
|
|
- getStdLabourCoe: getStdLabourCoe
|
|
|
+ getStdLabourCoe: getStdLabourCoe,
|
|
|
+ getData: getData,
|
|
|
+ save: save
|
|
|
};
|
|
|
|
|
|
async function newProjectLabourCoe(data) {
|
|
|
+ logger.info(`Create new LabourCoe file for project : ${data.ID}`);
|
|
|
let valid_LC_libs = [];
|
|
|
let egnrID = data.property.engineering_id;
|
|
|
let egnrModel = new EngineeringLibModel();
|
|
@@ -46,3 +52,19 @@ async function getStdLabourCoe(libID) {
|
|
|
let stdLC = await stdLabourCoesModel.findOne({ID:libID});
|
|
|
return stdLC;
|
|
|
};
|
|
|
+
|
|
|
+// 统一的 getData() 方法供project调用
|
|
|
+function getData (projectID, callback) {
|
|
|
+ projectLabourCoesModel.findOne({projectID: projectID}, '-_id', function(err, datas) {
|
|
|
+ if (!err) {
|
|
|
+ callback(0, projectConsts.LABOUR_COE, datas);
|
|
|
+ } else {
|
|
|
+ callback(1, projectConsts.LABOUR_COE, null);
|
|
|
+ };
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+// 统一的 save() 方法供project调用
|
|
|
+function save (user_id, datas, callback) {
|
|
|
+ projectLabourCoesModel.update({"projectID": 553}, {"libName":"goo"}, callback(null, {data: 'ok'}));
|
|
|
+}
|