project_facade.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. /**
  2. * Created by zhang on 2018/1/26.
  3. */
  4. module.exports = {
  5. markUpdateProject:markUpdateProject,
  6. removeProjectMark:removeProjectMark,
  7. updateNodes:updateNodes,
  8. calcInstallationFee:calcInstallationFee,
  9. calcOverHeightFee: calcOverHeightFee,
  10. saveProperty: saveProperty,
  11. getDefaultColSetting: getDefaultColSetting,
  12. markProjectsToChange:markProjectsToChange,
  13. getSEIProjects:getSEIProjects,
  14. loadSEIProjectData:loadSEIProjectData,
  15. setSEILibData:setSEILibData,
  16. getIndexReportData:getIndexReportData
  17. };
  18. let mongoose = require('mongoose');
  19. let logger = require("../../../logs/log_helper").logger;
  20. let projectsModel = mongoose.model('projects');
  21. let async_n = require("async");
  22. let _ = require('lodash');
  23. let ration_model = require('../models/ration');
  24. let bill_model = require('../models/bills');
  25. let consts = require('../models/project_consts');
  26. let projectConsts = consts.projectConst;
  27. let ration_glj_model = mongoose.model('ration_glj');
  28. let rationTemplateModel = mongoose.model('ration_template');
  29. let project_glj_model = mongoose.model('glj_list');
  30. let ration_glj_facade = require("../../ration_glj/facade/ration_glj_facade");
  31. const uuidV1 = require('uuid/v1');
  32. const gljUtil = require('../../../public/gljUtil');
  33. let stdColSettingModel = mongoose.model('std_main_col_lib');
  34. import GLJListModel from "../../glj/models/glj_list_model";
  35. let economicLib = mongoose.model('std_economic_lib');
  36. let engineerFeatureLib = mongoose.model('std_engineer_feature_lib');
  37. let engineerInfoLib = mongoose.model('std_engineer_info_lib');
  38. let mainQuantityLib = mongoose.model('std_main_quantity_lib');
  39. let materialLib = mongoose.model('std_material_lib');
  40. import fixedFlag from '../../common/const/bills_fixed';
  41. const scMathUtil = require('../../../public/scMathUtil').getUtil();
  42. const billsLibDao = require("../../bills_lib/models/bills_lib_interfaces");
  43. async function calcInstallationFee(data) {
  44. let result={};
  45. let billTasks = generateTasks(data.bills,data.useID);
  46. let rationTasks = generateTasks(data.ration,data.useID);
  47. if(billTasks.length>0){
  48. await bill_model.model.bulkWrite(billTasks);
  49. }
  50. console.log(rationTasks);
  51. if(rationTasks.length>0){
  52. await ration_model.model.bulkWrite(rationTasks);
  53. }
  54. //如果删除定额,需要删除对应的工料机
  55. if(data.ration.delete.length>0){
  56. let rationIDS = _.map(data.ration.delete,'ID');
  57. await ration_glj_model.deleteMany({projectID: data.ration.delete[0].projectID, rationID: {"$in": rationIDS}});//删除定额工料机
  58. }
  59. let rationGLJTasks = [];
  60. let updateList = [];
  61. if(data.ration.update.length>0){//如果有需要更新的定额工料机
  62. for(let ur of data.ration.update){
  63. for(let g of ur.glj){
  64. let gTasks = {
  65. updateOne:{
  66. filter:{
  67. ID:g.ID,
  68. projectID:g.projectID
  69. },
  70. update :{
  71. quantity:g.quantity,
  72. rationItemQuantity:g.rationItemQuantity
  73. }
  74. }
  75. };
  76. rationGLJTasks.push(gTasks);
  77. updateList.push(g);
  78. }
  79. }
  80. }
  81. if(rationGLJTasks.length>0){
  82. await ration_glj_model.bulkWrite(rationGLJTasks);
  83. }
  84. let newGljList = [];
  85. if(data.ration.add.length>0){//新增的安装子目要增加对应的工料机
  86. for(let nr of data.ration.add){
  87. for(let tkey in nr.glj){
  88. let [newRecode,projectGLJ] = await createRationGLJData(nr.glj[tkey])
  89. newGljList.push(newRecode);
  90. }
  91. }
  92. }
  93. if(newGljList.length>0){
  94. await ration_glj_model.insertMany(newGljList);
  95. }
  96. result.update = updateList;
  97. result.add = newGljList;
  98. return result;
  99. }
  100. async function createRationGLJData(glj) {
  101. glj.ID = uuidV1();
  102. let [info,projectGLJ ] = await ration_glj_facade.getInfoFromProjectGLJ(glj);
  103. let newRecode = ration_glj_facade.createNewRecord(info);
  104. return [newRecode,projectGLJ];
  105. }
  106. function generateTasks(data,userID) {
  107. let tasks=[];
  108. let deleteInfo={deleted: true, deleteDateTime: new Date(), deleteBy: userID};
  109. if(data.delete && data.delete.length > 0){
  110. for(let bd of data.delete){
  111. //原先是假删除,现在改成真删除
  112. let task = {
  113. deleteOne:{
  114. filter:{
  115. ID:bd.ID,
  116. projectID:bd.projectID
  117. }
  118. }
  119. };
  120. /* let task={
  121. updateOne:{
  122. filter:{
  123. ID:bd.ID,
  124. projectID:bd.projectID
  125. },
  126. update :{
  127. deleteInfo:deleteInfo
  128. }
  129. }
  130. };*/
  131. tasks.push(task);
  132. }
  133. }
  134. if(data.add && data.add.length > 0){
  135. for(let n_data of data.add){
  136. let task = {
  137. insertOne :{
  138. document:n_data
  139. }
  140. };
  141. tasks.push(task);
  142. }
  143. }
  144. return tasks;
  145. }
  146. /**
  147. * 计取超高降效费,可能包含更新清单、更新定额、新增清单、新增定额及其子数据、删除定额及其子数据
  148. * @param {Object} data - {updateData: {ration: [],..}, addData: {ration: [],...}, deleteData: {ration: [],...}}
  149. * @return {Object} - {bills: Array, rationGLJ: Array}
  150. */
  151. async function calcOverHeightFee(data) {
  152. // 更新数据
  153. async function update({ project, bills, ration }) {
  154. const tasks = [];
  155. // 更新项目
  156. if (project && project.ID) {
  157. const projectTask = projectsModel.update({ ID: project.ID },
  158. { 'property.overHeightOption': project.overHeightOption, 'property.overHeightSpecificID': project.overHeightSpecificID });
  159. tasks.push(projectTask);
  160. }
  161. // 更新清单和定额的超高降效列
  162. const models = [];
  163. if (bills.length) {
  164. models.push({ model: bill_model.model, items: bills });
  165. }
  166. if (ration.length) {
  167. models.push({ model: ration_model.model, items: ration });
  168. }
  169. models.forEach(modelData => {
  170. const bulkTask = modelData.items.map(item => (
  171. {
  172. updateOne: {
  173. filter: { ID: item.ID },
  174. update: { overHeight: item.overHeight }
  175. }
  176. }));
  177. const task = modelData.model.bulkWrite(bulkTask);
  178. tasks.push(task);;
  179. });
  180. if (!tasks.length) {
  181. return;
  182. }
  183. await Promise.all(tasks);
  184. }
  185. // 插入数据
  186. async function add({ bills, ration, rationGLJ}) {
  187. const tasks = [];
  188. // 匹配标准清单,加上工作内容等数据
  189. for (const billsItem of bills) {
  190. let stdBills = await billsLibDao.getStdBillsByCode(billsItem);
  191. stdBills = stdBills ? stdBills._doc : null;
  192. if (stdBills) {
  193. // 获取项目清单所需要的数据
  194. const projectBillsData = billsLibDao.getDataToProjectBills(stdBills);
  195. Object.assign(billsItem, projectBillsData);
  196. } else {
  197. delete billsItem.billsLibId;
  198. }
  199. billsItem.code += '001';
  200. }
  201. // 新增清单
  202. if (bills.length) {
  203. tasks.push(bill_model.model.insertMany(bills));
  204. }
  205. // 新增定额
  206. if (ration.length) {
  207. tasks.push(ration_model.model.insertMany(ration));
  208. }
  209. // 完整的定额人材机数据
  210. const completeRationGLJList = [];
  211. // 完整的项目人材机数据
  212. const completeProjectGLJList = [];
  213. // createRationGLJData方法不能并行,涉及到项目人材机的新增,如果并行可能会重复插入数据
  214. for (const rGLJ of rationGLJ) {
  215. const [completeRGLJ, completePGLJ] = await createRationGLJData(rGLJ);
  216. completeRationGLJList.push(completeRGLJ);
  217. completeProjectGLJList.push(completePGLJ);
  218. }
  219. if (completeRationGLJList.length) {
  220. tasks.push(ration_glj_model.insertMany(completeRationGLJList))
  221. }
  222. // if (rationGLJ.length) {
  223. // // 定额人材机需要新增项目人材机、单价文件、且返回完整的定额人材机数据
  224. // const rationGLJTasks = rationGLJ.map(glj => createRationGLJData(glj));
  225. // completeRationGLJList = await Promise.all(rationGLJTasks);
  226. // // 新增定额人材机
  227. // tasks.push(ration_glj_model.insertMany(completeRationGLJList));
  228. // }
  229. // 返回新的清单、定额人材机、项目人材机数据数据
  230. const rst = {
  231. bills,
  232. rationGLJ: completeRationGLJList,
  233. projectGLJ: completeProjectGLJList,
  234. }
  235. if (!tasks.length) {
  236. return rst;
  237. }
  238. await Promise.all(tasks);
  239. return rst;
  240. }
  241. // 删除数据
  242. async function del({ ration }) {
  243. const tasks = [];
  244. const rationIDList = ration.map(item => item.ID);
  245. if (!rationIDList.length) {
  246. return;
  247. }
  248. // 删除定额数据
  249. const rationTask = ration_model.model.deleteMany({ ID: {$in: rationIDList} });
  250. tasks.push(rationTask);
  251. // 删除定额人材机数据
  252. const rationGLJTask = ration_glj_model.deleteMany({ rationID: {$in: rationIDList} });
  253. tasks.push(rationGLJTask);
  254. await Promise.all(tasks);
  255. }
  256. // 处理任务
  257. const { updateData, addData, deleteData } = data;
  258. const updateTask = update(updateData);
  259. const addTask = add(addData);
  260. const delTask = del(deleteData);
  261. const [updateRst, addRst, delRst] = await Promise.all([updateTask, addTask, delTask]);
  262. return addRst;
  263. }
  264. async function updateNodes(datas){
  265. let nodeGroups = _.groupBy(datas,'type');
  266. let rationTasks = [];
  267. let billTasks = [];
  268. let rationGLJTasks = [];
  269. let projectGLJTasks = [];
  270. let projectTasks = [];
  271. let rationTemplateTasks = [];
  272. let asyncTasks = [];
  273. for(let type in nodeGroups){
  274. for(let node of nodeGroups[type]){
  275. if(type == projectConsts.BILLS){
  276. billTasks.push(getTask(node));
  277. }else if(type == projectConsts.RATION){
  278. rationTasks.push(getTask(node));
  279. }else if(type == projectConsts.RATION_GLJ){
  280. rationGLJTasks.push(getTask(node));
  281. }else if(type == projectConsts.PROJECTGLJ){
  282. projectGLJTasks.push(getTask(node,'id'));
  283. }else if(type == projectConsts.PROJECT){
  284. projectTasks.push(getTask(node));
  285. }else if(type == projectConsts.RATION_TEMPLATE){
  286. rationTemplateTasks.push(getTask(node))
  287. }
  288. }
  289. }
  290. //test------------------------
  291. if (billTasks.length) {
  292. console.log(`billTasks===============================`);
  293. billTasks.forEach(task => {
  294. if (task.updateOne.update.name === '分部分项工程') {
  295. console.log(`task.updateOne.filter`);
  296. console.log(task.updateOne.filter);
  297. console.log(`task.updateOne.update`);
  298. console.log(task.updateOne.update);
  299. }
  300. /*console.log(`task.updateOne.filter`);
  301. console.log(task.updateOne.filter);
  302. console.log(`task.updateOne.update`);
  303. console.log(task.updateOne.update);*/
  304. });
  305. }
  306. //test------------------------
  307. rationTasks.length>0?asyncTasks.push(ration_model.model.bulkWrite(rationTasks)):'';
  308. billTasks.length>0?asyncTasks.push(bill_model.model.bulkWrite(billTasks)):"";
  309. rationGLJTasks.length>0?asyncTasks.push(ration_glj_model.bulkWrite(rationGLJTasks)):"";
  310. projectGLJTasks.length>0?asyncTasks.push(project_glj_model.bulkWrite(projectGLJTasks)):"";
  311. projectTasks.length>0?asyncTasks.push(projectsModel.bulkWrite(projectTasks)):"";
  312. rationTemplateTasks.length>0?asyncTasks.push(rationTemplateModel.bulkWrite(rationTemplateTasks)):"";
  313. return asyncTasks.length>0?await Promise.all(asyncTasks):"";
  314. function getTask(node,idFiled = 'ID') {
  315. let task={
  316. updateOne:{
  317. filter:{},
  318. update :_.cloneDeep(node.data)
  319. }
  320. };
  321. task.updateOne.filter[idFiled] = node.data[idFiled];//现在复制项目也重新生成一个新的ID了,所以ID是唯一的
  322. delete task.updateOne.update[idFiled];//防止误操作
  323. return task;
  324. }
  325. }
  326. /*function updateNodes(datas,callback) {
  327. let tasks = [];
  328. for(let node of datas){
  329. tasks.push(updateOne(node))
  330. }
  331. async_n.parallel(tasks, function(err, results) {
  332. if (!err){
  333. callback(0, '', results);
  334. }
  335. else{
  336. console.log(err);
  337. callback(1, 'save project failed'+err.message, null);
  338. }
  339. });
  340. function updateOne(node) {
  341. if(node.type == projectConsts.BILLS){
  342. return function (asCallback) {
  343. bill_model.model.findOneAndUpdate({projectID: node.data.projectID, ID: node.data.ID,deleteInfo: null}, node.data,{new: true}, asCallback);
  344. }
  345. }else if(node.type ==projectConsts.RATION){
  346. return function (asCallback) {
  347. ration_model.model.findOneAndUpdate({projectID: node.data.projectID, ID: node.data.ID,deleteInfo: null}, node.data,{new: true}, asCallback);
  348. }
  349. }
  350. }
  351. }*/
  352. //data = {feeRateID:111111,projectID:1245}; type = feeRate
  353. async function markUpdateProject(data,type) {
  354. let query = {deleteInfo:null};
  355. if(type=="feeRate"){//更改了费率
  356. query['property.feeFile.id'] = data.feeRateID;
  357. }
  358. if(type=="unitFile"){//更改了单价文件
  359. query['property.unitPriceFile.id'] = data.unitFileID;//unitPriceFile
  360. }
  361. let projects = await projectsModel.find(query);
  362. return await markProjectsToChange(projects,type,data.projectID);
  363. }
  364. async function markProjectsToChange(projects,type,extProjectID){
  365. let tasks=[];
  366. for(let p of projects){
  367. if(extProjectID && p.ID===extProjectID) continue;//排除当前项目
  368. tasks.push(generateMarkTask(type,p.ID));
  369. }
  370. return tasks.length>0 ? await projectsModel.bulkWrite(tasks):null;
  371. }
  372. async function removeProjectMark(projectID) {
  373. return await projectsModel.findOneAndUpdate({ID:projectID},{"$unset":{"changeMark":1}});
  374. }
  375. function generateMarkTask(value,projectID) {
  376. let task = {
  377. updateOne:{
  378. filter:{
  379. ID:projectID
  380. },
  381. update:{
  382. changeMark:value
  383. }
  384. }
  385. };
  386. return task
  387. }
  388. // {projectID: 5, propertyName: 'aaa', propertyValue: 1}
  389. function saveProperty(data, callback){
  390. let obj = {};
  391. let pn = 'property.' + data.propertyName;
  392. obj[pn] = data.propertyValue;
  393. projectsModel.update({"ID": data.projectID}, obj, function (err) {
  394. if (err) {
  395. logger.err(pn + ' save error: ' + err);
  396. callback(err, null)
  397. } else {
  398. logger.info(pn + ' saved.');
  399. callback('', null);
  400. }}
  401. );
  402. }
  403. async function getDefaultColSetting(libID){
  404. return await stdColSettingModel.findOne({ID: libID, deleted: false}, '-_id main_tree_col');
  405. }
  406. function sortChildren(lists) {
  407. let IDMap ={},nextMap = {}, firstNode = null,newList=[];
  408. for(let l of lists){
  409. if(l.children&&l.children.length > 0) l.children = sortChildren(l.children);//递规排序
  410. IDMap[l.ID] = l;
  411. if(l.NextSiblingID!=-1) nextMap[l.NextSiblingID] = l;
  412. }
  413. for(let t of lists){
  414. if(!nextMap[t.ID]){ //如果在下一节点映射没找到,则是第一个节点
  415. firstNode = t;
  416. break;
  417. }
  418. }
  419. if(firstNode){
  420. newList.push(firstNode);
  421. delete IDMap[firstNode.ID];
  422. setNext(firstNode,newList);
  423. }
  424. //容错处理,如果链断了的情况,直接添加到后面
  425. for(let key in IDMap){
  426. if(IDMap[key]) newList.push(IDMap[key])
  427. }
  428. return newList;
  429. function setNext(node,array) {
  430. if(node.NextSiblingID != -1){
  431. let next = IDMap[node.NextSiblingID];
  432. if(next){
  433. array.push(next);
  434. delete IDMap[next.ID];
  435. setNext(next,array);
  436. }
  437. }
  438. }
  439. }
  440. async function getSEIProjects(projectID) {
  441. let project = await projectsModel.findOne({ID:projectID});
  442. if(!project) throw new Error(`找不到建设项目:${projectID}`);
  443. let tem_e = await projectsModel.find({ParentID:project.ID});
  444. let engineers = [];
  445. for(let e of tem_e){
  446. if(!e.deleteInfo || !e.deleteInfo.deleted){
  447. let tenders = await projectsModel.find({ParentID:e.ID});
  448. let children = [];
  449. for(let t of tenders){
  450. if(!t.deleteInfo || !t.deleteInfo.deleted){
  451. children.push(t);
  452. }
  453. }
  454. e._doc.children = children;
  455. engineers.push(e);
  456. }
  457. }
  458. engineers = sortChildren(engineers);
  459. project._doc.children = engineers;
  460. return project;
  461. }
  462. async function loadSEIProjectData(projectID) {
  463. let gljListModel = new GLJListModel();
  464. let [gljList, mixRatioConnectData,mixRatioMap,unitPriceMap] = await gljListModel.getListByProjectId(projectID);
  465. let rations = await ration_model.getDataSync(projectID);
  466. let bills = await bill_model.getDataSync(projectID);
  467. let ration_gljs = await ration_glj_model.find({projectID:projectID});
  468. let projectGLJs = {
  469. gljList : gljList,
  470. mixRatioConnectData:mixRatioConnectData,
  471. mixRatioMap:mixRatioMap,
  472. unitPriceMap:unitPriceMap
  473. };
  474. return{bills:bills,rations:rations,ration_gljs:ration_gljs,projectGLJs:projectGLJs}
  475. }
  476. async function setSEILibData(property){
  477. if(property.engineerInfoLibID){//工程信息指标
  478. let engineerInfo = await engineerInfoLib.findOne({'ID':property.engineerInfoLibID});
  479. if(engineerInfo) property.engineerInfos = engineerInfo.info;
  480. }
  481. if(property.engineerFeatureLibID){//工程特征指标
  482. let engineerFeature = await engineerFeatureLib.findOne({'ID':property.engineerFeatureLibID});
  483. if(engineerFeature) property.engineerFeatures = engineerFeature.features;
  484. }
  485. if(property.materialLibID){//主要工料指标
  486. let material = await materialLib.findOne({'ID':property.materialLibID});
  487. if(material) property.materials = material.materials;
  488. }
  489. if(property.mainQuantityLibID){//主要工程量指标
  490. let mainQuantity = await mainQuantityLib.findOne({'ID':property.mainQuantityLibID});
  491. if(mainQuantity) property.mainQuantities = mainQuantity.index;
  492. }
  493. if(property.economicLibID){//主要工程量指标
  494. let economic = await economicLib.findOne({'ID':property.economicLibID});
  495. if(economic) property.economics = economic.index;
  496. }
  497. }
  498. async function getIndexReportData(projectID,keyArr) {
  499. let project = await projectsModel.findOne({ID:projectID});
  500. let bills = await bill_model.getDataSync(projectID);
  501. let result = {};
  502. for(let key of keyArr){
  503. switch (key) {
  504. case 'ProjectCostFields':
  505. result[key] =getEngineerCostData(project.property,bills);
  506. break;
  507. case 'ProjectEcoFields':
  508. result[key] = getEconomicDatas(project.property,bills);
  509. break;
  510. case 'ProjectLabMaterialFields':
  511. result[key] = await getMainMaterialDatas(projectID,project.property);
  512. break;
  513. case 'ProjectQtyFields':
  514. result[key] = await getQuantityDatas(project.property,bills);
  515. break;
  516. case 'ProjectInfoFields':
  517. result[key] = getEngineerInfoData(project.property.engineerInfos);
  518. break;
  519. case 'ProjectFeatureFields':
  520. result[key] = getEngineerFeaturesDatas(project.property.engineerFeatures);
  521. break;
  522. }
  523. }
  524. return result
  525. }
  526. function getEngineerInfoData(engineerInfos) {
  527. let datas = [];
  528. for(let info of engineerInfos){
  529. let d = {
  530. name:info.dispName,
  531. value:info.value
  532. };
  533. datas.push(d);
  534. }
  535. return datas;
  536. }
  537. function getEngineerFeaturesDatas(engineerFeatures) {
  538. let datas = [];
  539. if (engineerFeatures !== null && engineerFeatures !== undefined) {
  540. for(let f of engineerFeatures){
  541. let tem = {
  542. ID:f.ID,
  543. name:f.name,
  544. value:f.value,
  545. ParentID:f.ParentID
  546. }
  547. datas.push(tem);
  548. }
  549. }
  550. return datas;
  551. }
  552. function getQuantityDatas(property,bills) {
  553. return gljUtil.getQuantityDatas(property.engineerFeatures,property.mainQuantities,bills,fixedFlag,_,scMathUtil,property.decimal)
  554. }
  555. function getEconomicDatas(property,bills) {
  556. return gljUtil.getEconomicDatas(property.engineerFeatures,property.economics,bills,fixedFlag,_,scMathUtil,property.decimal)
  557. }
  558. function getEngineerCostData(property,bills){
  559. let datas = [];
  560. let priceIndex = gljUtil.getEngineerCostData(property,bills,fixedFlag,scMathUtil);
  561. for(let c of priceIndex.children){
  562. let tem = {
  563. name:c.name,
  564. cost:parseFloat(c.attrs[0].value),
  565. unitCost:parseFloat(c.attrs[1].value),
  566. per:parseFloat(c.attrs[2].value)
  567. };
  568. datas.push(tem);
  569. }
  570. return datas;
  571. }
  572. async function getMainMaterialDatas(projectID,property) {
  573. let gljListModel = new GLJListModel();
  574. let [gljList, mixRatioConnectData,mixRatioMap,unitPriceMap] = await gljListModel.getListByProjectId(projectID, property.unitPriceFile?property.unitPriceFile.id:null);
  575. gljList = JSON.parse(JSON.stringify(gljList));
  576. await calcProjectGLJQuantity(projectID,{gljList:gljList,mixRatioMap:mixRatioMap},property);
  577. return gljUtil.getMainMaterialDatas(property.engineerFeatures,property.materials,{gljList:gljList},property.calcOptions,property.decimal,false,_,scMathUtil)
  578. }
  579. async function calcProjectGLJQuantity(projectID,projectGLJDatas,property){
  580. let q_decimal = property.decimal.glj.quantity;
  581. let rationGLJDatas = await ration_glj_model.find({'projectID':projectID});
  582. let rationDatas = await ration_model.model.find({'projectID':projectID});
  583. gljUtil.calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,[],q_decimal)
  584. }