stage_bills.js 23 KB

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