|
@@ -2,12 +2,45 @@
|
|
|
* Created by zhang on 2018/1/26.
|
|
|
*/
|
|
|
let projectsModel = require("../../pm/models/project_schema");
|
|
|
+let async_n = require("async");
|
|
|
+let ration_model = require('../models/ration');
|
|
|
+let bill_model = require('../models/bills');
|
|
|
+let consts = require('../models/project_consts');
|
|
|
+let projectConsts = consts.projectConst;
|
|
|
|
|
|
module.exports = {
|
|
|
markUpdateProject:markUpdateProject,
|
|
|
- removeProjectMark:removeProjectMark
|
|
|
+ removeProjectMark:removeProjectMark,
|
|
|
+ updateNodes:updateNodes
|
|
|
};
|
|
|
|
|
|
+function updateNodes(datas,callback) {
|
|
|
+ let tasks = [];
|
|
|
+ for(let node of datas){
|
|
|
+ tasks.push(updateOne(node))
|
|
|
+ }
|
|
|
+ async_n.parallel(tasks, function(err, results) {
|
|
|
+ if (!err){
|
|
|
+ callback(0, '', results);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ console.log(err);
|
|
|
+ callback(1, 'save project failed'+err.message, null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ function updateOne(node) {
|
|
|
+ if(node.type == projectConsts.BILLS){
|
|
|
+ return function (asCallback) {
|
|
|
+ bill_model.model.findOneAndUpdate({projectID: node.data.projectID, ID: node.data.ID,deleteInfo: null}, node.data,{new: true}, asCallback);
|
|
|
+ }
|
|
|
+ }else if(node.type ==projectConsts.RATION){
|
|
|
+ return function (asCallback) {
|
|
|
+ ration_model.model.findOneAndUpdate({projectID: node.data.projectID, ID: node.data.ID,deleteInfo: null}, node.data,{new: true}, asCallback);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//data = {feeRateID:111111,projectID:1245}; type = feeRate
|
|
|
async function markUpdateProject(data,type) {
|
|
|
let tasks=[];
|