stage_bills.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. 'use strict';
  2. /**
  3. * 期计量 - 部位明细计量
  4. *
  5. * @author Mai
  6. * @date 2018/12/8
  7. * @version
  8. */
  9. const calcFields = ['contract_qty', 'qc_qty'];
  10. const auditConst = require('../const/audit');
  11. const timesLen = auditConst.stage.timesLen;
  12. module.exports = app => {
  13. class StageBills extends app.BaseService {
  14. /**
  15. * 构造函数
  16. *
  17. * @param {Object} ctx - egg全局变量
  18. * @return {void}
  19. */
  20. constructor(ctx) {
  21. super(ctx);
  22. this.depart = 10;
  23. this.tableName = 'stage_bills';
  24. }
  25. /**
  26. * 查询期计量最后审核人数据
  27. * @param {Number} tid - 标段id
  28. * @param {Number} sid - 期id
  29. * @param {Number|Array} lid - 台账节点id(可以为空)
  30. * @return {Promise<*>}
  31. */
  32. async getLastestStageData(tid, sid, lid) {
  33. let lidSql = '',
  34. result;
  35. if (lid) {
  36. if (lid instanceof Array) {
  37. lidSql = lid.length > 0 ? ' And lid in (' + this.ctx.helper.getInArrStrSqlFilter(lid) + ')' : '';
  38. } else {
  39. lidSql = ' And lid in (' + this.db.escape(lid) + ')';
  40. }
  41. }
  42. const sql = 'SELECT Bills.* FROM ' + this.departTableName(tid) + ' As Bills ' +
  43. ' INNER JOIN ( ' +
  44. ' SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.departTableName(tid) +
  45. ' WHERE tid = ? And sid = ?' + lidSql +
  46. ' GROUP BY `lid`' +
  47. ' ) As MaxFilter ' +
  48. ' ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid And Bills.`sid` = MaxFilter.`sid`';
  49. const sqlParam = [tid, sid];
  50. if (!lid) {
  51. return await this.db.query(sql, sqlParam);
  52. } else if (lid instanceof Array) {
  53. return await this.db.query(sql, sqlParam);
  54. }
  55. return await this.db.queryOne(sql, sqlParam);
  56. }
  57. /**
  58. * 查询 某期 某轮审批 某人数据
  59. * @param {Number} tid - 标段id
  60. * @param {Number} sid - 期id
  61. * @param {Number} times - 第几轮
  62. * @param {Number} order - 流程
  63. * @param {Number|Array} lid - 台账节点id(可以为空)
  64. * @return {Promise<*>}
  65. */
  66. async getAuditorStageData(tid, sid, times, order, lid) {
  67. const lidSql = lid ? ' And Bills.lid in (?)' : '';
  68. const sql = 'SELECT Bills.* FROM ' + this.departTableName(tid) + ' As Bills ' +
  69. ' INNER JOIN ( ' +
  70. ' SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `tid`, `sid` From ' + this.departTableName(tid) +
  71. ' WHERE (`times` < ? OR (`times` = ? AND `order` <= ?)) And tid = ? And sid = ?' + lidSql +
  72. ' GROUP BY `lid`' +
  73. ' ) As MaxFilter ' +
  74. ' ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid' +
  75. ' AND Bills.sid = MaxFilter.sid';
  76. const sqlParam = [times, times, order, tid, sid];
  77. if (!lid) {
  78. return await this.db.query(sql, sqlParam);
  79. } else if (lid instanceof Array) {
  80. sqlParam.push(lid.join(', '));
  81. return await this.db.query(sql, sqlParam);
  82. }
  83. sqlParam.push(lid);
  84. return await this.db.queryOne(sql, sqlParam);
  85. }
  86. async getLastestStageData2(tid, sid, lid) {
  87. let lidSql = '',
  88. result;
  89. if (lid) {
  90. if (lid instanceof Array) {
  91. lidSql = lid.length > 0 ? ' And lid in (' + this.ctx.helper.getInArrStrSqlFilter(lid) + ')' : '';
  92. } else {
  93. lidSql = ' And lid in (' + this.db.escape(lid) + ')';
  94. }
  95. }
  96. const sql = 'SELECT Bills.* FROM ' + this.tableName + ' As Bills ' +
  97. ' INNER JOIN ( ' +
  98. ' SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.tableName +
  99. ' WHERE tid = ? And sid = ?' + lidSql +
  100. ' GROUP BY `lid`' +
  101. ' ) As MaxFilter ' +
  102. ' ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid And Bills.`sid` = MaxFilter.`sid`';
  103. const sqlParam = [tid, sid];
  104. if (!lid) {
  105. return await this.db.query(sql, sqlParam);
  106. } else if (lid instanceof Array) {
  107. return await this.db.query(sql, sqlParam);
  108. }
  109. return await this.db.queryOne(sql, sqlParam);
  110. }
  111. async getStageUsedBills(tid, sid) {
  112. const sql = 'SELECT Bills.lid, ((not IsNull(Bills.contract_qty) and Bills.contract_qty <> 0) or (not IsNull(Bills.qc_qty) and Bills.qc_qty <> 0)) As used' +
  113. ' FROM ' + this.tableName + ' As Bills ' +
  114. ' INNER JOIN ( ' +
  115. ' SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.tableName +
  116. ' WHERE tid = ? And sid = ?' +
  117. ' GROUP BY `lid`' +
  118. ' ) As MaxFilter ' +
  119. ' ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid And Bills.`sid` = MaxFilter.`sid`';
  120. const sqlParam = [tid, sid];
  121. const stageBills = await this.db.query(sql, sqlParam);
  122. return this._.map(this._.filter(stageBills, 'used'), 'lid');
  123. }
  124. /**
  125. * 获取截止本期数据
  126. * @param {Number} tid - 标段id
  127. * @param {Number} sorder - 截止期序号
  128. * @param {String|Array[String]} lid - 台账id
  129. * @returns {Promise<*>}
  130. */
  131. async getEndStageData(tid, sorder, lid) {
  132. let lidSql = '';
  133. if (lid) {
  134. if (lid instanceof Array) {
  135. lidSql = lid.length > 0 ? ' And lid in (' + this.ctx.helper.getInArrStrSqlFilter(lid) + ')' : '';
  136. } else {
  137. lidSql = ' And lid in (' + this.db.escape(lid) + ')';
  138. }
  139. }
  140. const sql = 'SELECT Bills.tid, Bills.lid,' +
  141. ' Sum(Bills.contract_qty) As contract_qty, Sum(Bills.contract_tp) As contract_tp,' +
  142. ' Sum(Bills.qc_qty) As qc_qty, Sum(Bills.qc_tp) As qc_tp FROM ' + this.tableName + ' As Bills ' +
  143. ' INNER JOIN ( ' +
  144. ' SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.tableName +
  145. ' WHERE tid = ? ' + lidSql +
  146. ' GROUP BY `lid`, `sid`' +
  147. ' ) As MaxFilter ' +
  148. ' ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid And Bills.`sid` = MaxFilter.`sid`' +
  149. ' INNER JOIN ' + this.ctx.service.stage.tableName + ' As Stage' +
  150. ' ON Bills.sid = Stage.id' +
  151. ' WHERE Stage.order <= ?' +
  152. ' GROUP BY `lid`';
  153. const sqlParam = [tid, sorder];
  154. if (!lid) {
  155. return await this.db.query(sql, sqlParam);
  156. } else if (lid instanceof Array) {
  157. return await this.db.query(sql, sqlParam);
  158. }
  159. return await this.db.queryOne(sql, sqlParam);
  160. }
  161. async getStageBills(tid, sid, lid) {
  162. const sql = 'SELECT Stage.*, Ledger.unit_price FROM ?? As Stage, ?? As Ledger ' +
  163. ' Where Stage.tid = ?, Stage.sid = ?, Stage.lid = ?, Stage.lid = Ledger.id ' +
  164. ' Order Stage.time DESC, Stage.order DESC ';
  165. const sqlParam = [this.tableName, this.ctx.service.ledger.tableName];
  166. sqlParam.push(this.db.escape(tid));
  167. sqlParam.push(this.db.escape(sid));
  168. sqlParam.push(this.db.escape(lid));
  169. return await this.db.queryOne(sql, sqlParam);
  170. }
  171. _calcStageBillsData(data, orgData, ledgerData) {
  172. const info = this.ctx.tender.info;
  173. const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerData.unit);
  174. if (data.contract_qty !== undefined) {
  175. data.contract_qty = this.round(data.contract_qty, precision.value);
  176. data.contract_tp = this.ctx.helper.mul(data.contract_qty, ledgerData.unit_price, info.decimal.tp);
  177. }
  178. if (data.qc_qty !== undefined) {
  179. data.qc_qty = this.round(data.qc_qty, precision.value);
  180. data.qc_tp = this.ctx.helper.mul(data.qc_qty, ledgerData.unit_price, info.decimal.tp);
  181. }
  182. if (ledgerData.is_tp && data.contract_tp !== undefined) {
  183. data.contract_tp = this.ctx.helper.round(data.contract_tp, info.decimal.tp);
  184. }
  185. }
  186. async _insertStageBillsData(transaction, insertData, orgData, ledgerData) {
  187. const info = this.ctx.tender.info;
  188. const d = {
  189. tid: this.ctx.tender.id,
  190. lid: ledgerData.id,
  191. sid: this.ctx.stage.id,
  192. times: this.ctx.stage.curTimes,
  193. order: this.ctx.stage.curOrder,
  194. said: this.ctx.session.sessionUser.accountId,
  195. };
  196. if (orgData) {
  197. d.contract_qty = orgData.contract_qty;
  198. d.contract_tp = orgData.contract_tp;
  199. d.qc_qty = orgData.qc_qty;
  200. d.qc_tp = orgData.qc_tp;
  201. d.postil = orgData.postil;
  202. }
  203. const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerData.unit);
  204. if (insertData.contract_qty !== undefined) {
  205. d.contract_qty = this.round(insertData.contract_qty, precision.value);
  206. d.contract_tp = this.ctx.helper.mul(d.contract_qty, ledgerData.unit_price, info.decimal.tp);
  207. }
  208. if (insertData.contract_expr !== undefined) d.contract_expr = insertData.contract_expr;
  209. if (insertData.qc_qty !== undefined) {
  210. d.qc_qty = this.round(insertData.qc_qty, precision.value);
  211. d.qc_tp = this.ctx.helper.mul(d.qc_qty, ledgerData.unit_price, info.decimal.tp);
  212. }
  213. if (insertData.postil) {
  214. d.postil = insertData.postil;
  215. }
  216. if (ledgerData.is_tp && insertData.contract_tp !== undefined) {
  217. d.contract_tp = this.ctx.helper.round(insertData.contract_tp, info.decimal.tp);
  218. }
  219. await transaction.insert(this.tableName, d);
  220. }
  221. /**
  222. * 前端提交数据
  223. * @param {Object|Array} data - 提交的数据
  224. * @return {Promise<void>}
  225. */
  226. async updateStageData(data) {
  227. const datas = data instanceof Array ? data : [data];
  228. const transaction = await this.db.beginTransaction();
  229. try {
  230. for (const d of datas) {
  231. const stageBills = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, d.lid);
  232. const ledgerBills = await this.ctx.service.ledger.getDataById(d.lid);
  233. if (!stageBills || stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
  234. await this._insertStageBillsData(transaction, d, stageBills, ledgerBills);
  235. } else {
  236. d.id = stageBills.id;
  237. this._calcStageBillsData(d, stageBills, ledgerBills);
  238. await transaction.update(this.tableName, d);
  239. }
  240. }
  241. await transaction.commit();
  242. } catch (err) {
  243. await transaction.rollback();
  244. throw err;
  245. }
  246. return await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, this._.map(datas, 'lid'));
  247. }
  248. /**
  249. * 根据
  250. * @param transaction
  251. * @param ledgerBills
  252. * @param stageBills
  253. * @param data
  254. * @return {Promise<void>}
  255. * @private
  256. */
  257. async updateStageBillsQty(transaction, ledgerBills, stageBills, data) {
  258. if (stageBills) {
  259. if ((data.contract_qty === undefined || stageBills.contract_qty !== data.contract_qty) ||
  260. (data.qc_qty === undefined || stageBills.qc_qty !== data.qc_qty)) {
  261. if (stageBills.times === this.ctx.stage.curTimes && stageBills.order === this.ctx.stage.curOrder) {
  262. data.id = stageBills.id;
  263. this._calcStageBillsData(data, stageBills, ledgerBills);
  264. await transaction.update(this.tableName, data);
  265. } else {
  266. await this._insertStageBillsData(transaction, data, stageBills, ledgerBills);
  267. }
  268. }
  269. } else {
  270. await this._insertStageBillsData(transaction, data, stageBills, ledgerBills);
  271. }
  272. }
  273. /**
  274. * 重算 本期计量 数量 (根据部位明细)
  275. * @param {Number} tid - 标段id
  276. * @param {Number} id - 需要计算的节点的id
  277. * @param {Number} lid - 台账id
  278. * @param {Object} transaction - 操作所属事务
  279. * @return {Promise<void>}
  280. */
  281. async calc(tid, sid, lid, transaction) {
  282. const info = this.ctx.tender.info;
  283. const stageBills = await this.getLastestStageData(tid, sid, lid);
  284. const ledgerBills = await this.ctx.service.ledger.getDataById(lid);
  285. if (!ledgerBills) {
  286. throw '提交数据错误';
  287. }
  288. const posGather = await this.ctx.service.stagePos.getPosGather(tid, sid, lid, transaction);
  289. if (!posGather) { return; }
  290. const precision = this.ctx.helper.findPrecision(info.precision, ledgerBills.unit);
  291. // 计算
  292. if (posGather.contract_qty !== undefined) {
  293. posGather.contract_qty = this.round(posGather.contract_qty, precision.value);
  294. posGather.contract_tp = this.ctx.helper.mul(posGather.contract_qty, ledgerBills.unit_price, info.decimal.tp);
  295. }
  296. if (posGather.qc_qty !== undefined) {
  297. posGather.qc_qty = this.round(posGather.qc_qty, precision.value);
  298. posGather.qc_tp = this.ctx.helper.mul(posGather.qc_qty, ledgerBills.unit_price, info.decimal.tp);
  299. }
  300. if (stageBills) {
  301. if (stageBills.contract_qty === posGather.contract_qty && stageBills.qc_qty === posGather.qc_qty) {
  302. return;
  303. }
  304. if (stageBills.times === this.ctx.stage.curTimes && stageBills.order === this.ctx.stage.curOrder) {
  305. posGather.id = stageBills.id;
  306. await transaction.update(this.tableName, posGather);
  307. } else {
  308. await this._insertStageBillsData(transaction, posGather, stageBills, ledgerBills);
  309. }
  310. } else {
  311. await this._insertStageBillsData(transaction, posGather, stageBills, ledgerBills);
  312. }
  313. }
  314. async updateStageBillsCalcType(data) {
  315. const stageBills = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, data.id);
  316. const updateData = { contract_qty: null, contract_tp: null };
  317. const transaction = await this.db.beginTransaction();
  318. try {
  319. await transaction.update(this.ctx.service.ledger.tableName, data);
  320. if (stageBills) {
  321. if (stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
  322. const ledgerBills = await this.ctx.service.ledger.getDataById(data.id);
  323. await this._insertStageBillsData(transaction, updateData, stageBills, ledgerBills);
  324. } else {
  325. updateData.id = stageBills.id;
  326. await transaction.update(this.tableName, updateData);
  327. }
  328. }
  329. await transaction.commit();
  330. } catch (err) {
  331. await transaction.rollback();
  332. throw err;
  333. }
  334. const bills = await this.ctx.service.ledger.getDataById(data.id);
  335. const curStageData = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [data.id]);
  336. return { bills: [bills], curStageData };
  337. }
  338. async getSumTotalPrice(stage) {
  339. const sql = 'SELECT Sum(`contract_tp`) As `contract_tp`, Sum(`qc_tp`) As `qc_tp` FROM ' + this.departTableName(stage.tid) + ' As Bills ' +
  340. ' INNER JOIN ( ' +
  341. ' SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid`, `sid` From ' + this.departTableName(stage.tid) +
  342. ' WHERE (`times` < ? OR (`times` = ? AND `order` <= ?)) AND `sid` = ?' +
  343. ' GROUP BY `lid`' +
  344. ' ) As MaxFilter ' +
  345. ' ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.flow And Bills.lid = MaxFilter.lid And Bills.sid = MaxFilter.sid';
  346. const sqlParam = [stage.curTimes, stage.curTimes, stage.curOrder, stage.id];
  347. const result = await this.db.queryOne(sql, sqlParam);
  348. return result;
  349. }
  350. async getSumTotalPriceFilter(stage, operate, filter) {
  351. const sql = 'SELECT Sum(`contract_tp`) As `contract_tp`, Sum(`qc_tp`) As `qc_tp`' +
  352. ' FROM ' + this.departTableName(stage.tid) + ' As Bills ' +
  353. ' INNER JOIN ( ' +
  354. ' SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid` From ' + this.departTableName(stage.tid) +
  355. ' WHERE (`times` < ? OR (`times` = ? AND `order` <= ?)) AND `sid` = ?' +
  356. ' GROUP BY `lid`' +
  357. ' ) As MaxFilter ' +
  358. ' ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.flow And Bills.lid = MaxFilter.lid ' +
  359. ' INNER JOIN ' + this.ctx.service.ledger.departTableName(stage.tid) + ' As Ledger ON Bills.lid = Ledger.id' +
  360. ' WHERE Bills.sid = ? And Ledger.b_code ' + operate + ' ?';
  361. const sqlParam = [stage.times, stage.curTimes, stage.curOrder, stage.id, stage.id, filter];
  362. const result = await this.db.queryOne(sql, sqlParam);
  363. return result;
  364. }
  365. async getSumTotalPriceGcl(stage, regText) {
  366. if (regText) {
  367. return await this.getSumTotalPriceFilter(stage, 'REGEXP', regText);
  368. }
  369. return await this.getSumTotalPriceFilter(stage, '<>', this.db.escape(''));
  370. }
  371. async getSumTotalPriceNotGcl(stage) {
  372. return await this.getSumTotalPriceFilter(stage, '=', this.db.escape(''));
  373. }
  374. /**
  375. * 多期清单数据整合 (材料调差调用)
  376. * @param {Number} tid - 标段id
  377. * @param {String} stage_id_list - 期id列表
  378. * @return {Promise<void>}
  379. */
  380. async getStagesData(tid, stage_id_list) {
  381. const whereSql = this.ctx.helper.whereSql({tid: tid, sid: stage_id_list.split(',')});
  382. const sql = 'SELECT Bills.lid, Bills.tid, Bills.sid,' +
  383. ' Sum(Bills.contract_qty) As contract_qty, Sum(Bills.contract_tp) As contract_tp,' +
  384. ' Sum(Bills.qc_qty) As qc_qty, Sum(Bills.qc_tp) As qc_tp' +
  385. ' FROM ' + this.tableName + ' As Bills ' +
  386. ' INNER JOIN ( ' +
  387. ' SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `tid`, `lid`, `sid` From ' + this.tableName + whereSql + ' GROUP BY `lid`, `sid`' +
  388. ' ) As MaxFilter ' +
  389. ' ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.tid = MaxFilter.tid And Bills.lid = MaxFilter.lid And Bills.`sid` = MaxFilter.`sid`' +
  390. ' GROUP BY Bills.lid';
  391. const result = await this.db.query(sql);
  392. return result;
  393. }
  394. /**
  395. * 获取多期(合同和数量变更相加)计量-小计(材料调差调用)
  396. * @param {Number} tid - 标段id
  397. * @param {String} stage_id_list - 期id列表
  398. * @param {String} lid - 台账id
  399. * @param {String} xid - 项目节id
  400. * @return {Promise<void>}
  401. */
  402. async getGatherQtyByMaterial(tid, stage_id_list, lid) {
  403. stage_id_list = stage_id_list !== null ? stage_id_list.split(',') : [];
  404. let gather_qty = 0;
  405. for (const sid of stage_id_list) {
  406. const sql = 'SELECT Bills.* FROM ' + this.tableName + ' As Bills ' +
  407. ' INNER JOIN ( ' +
  408. ' SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.tableName +
  409. ' WHERE tid = ? And sid = ?' +
  410. ' GROUP BY `lid`' +
  411. ' ) As MaxFilter ' +
  412. ' ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid And Bills.`sid` = MaxFilter.`sid`' +
  413. ' WHERE Bills.lid = ?';
  414. const sqlParam = [tid, sid, lid];
  415. const result = await this.db.queryOne(sql, sqlParam);
  416. if (result) {
  417. gather_qty = this.ctx.helper.add(gather_qty, this.ctx.helper.add(result.contract_qty, result.qc_qty));
  418. }
  419. }
  420. return gather_qty !== 0 ? gather_qty : null;
  421. }
  422. async getSumTotalPriceByMaterial(stage_list) {
  423. let contract_tp = 0;
  424. let qc_tp = 0;
  425. for (const stage of stage_list) {
  426. const result = await this.getSumTotalPrice(stage);
  427. if (result) {
  428. contract_tp = this.ctx.helper.add(contract_tp, result.contract_tp);
  429. qc_tp = this.ctx.helper.add(qc_tp, result.qc_tp);
  430. }
  431. }
  432. return { contract_tp, qc_tp };
  433. }
  434. async getSumTotalPriceGclByMaterial(stage_list, regText) {
  435. let contract_tp = 0;
  436. let qc_tp = 0;
  437. for (const stage of stage_list) {
  438. const result = await this.getSumTotalPriceGcl(stage, regText);
  439. if (result) {
  440. contract_tp = this.ctx.helper.add(contract_tp, result.contract_tp);
  441. qc_tp = this.ctx.helper.add(qc_tp, result.qc_tp);
  442. }
  443. }
  444. return { contract_tp, qc_tp };
  445. }
  446. }
  447. return StageBills;
  448. };