rpt_gather_memory.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const Ledger = require('../lib/ledger');
  10. const PayCalculator = require('../lib/pay_calc');
  11. const auditConst = require('../const/audit');
  12. const payConst = require('../const/deal_pay');
  13. const moment = require('moment');
  14. const indexPre = 'id_';
  15. const normalPrefix = 't_', sumPrefix = 's_', specPrefix = 'ts_';
  16. const gatherUtils = {
  17. completeGatherData: function (datas, completeDatas) {
  18. for (const data of datas) {
  19. for (const cd of completeDatas) {
  20. data[cd.prefix + 'id'] = cd.id;
  21. data[cd.prefix + 'name'] = cd.name;
  22. }
  23. }
  24. },
  25. gatherStage: function (tender, gatherNode, sourceNode, prefix, helper) {
  26. gatherNode[prefix + 'id'] = tender.id;
  27. gatherNode[prefix + 'name'] = tender.name;
  28. gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
  29. gatherNode[prefix + "tp"] = helper.add(gatherNode[prefix + "tp"], sourceNode.total_price);
  30. gatherNode[prefix + "dgn_qty1"] = helper.add(gatherNode[prefix + "dgn_qty1"], sourceNode.dgn_qty1);
  31. gatherNode[prefix + "dgn_qty2"] = helper.add(gatherNode[prefix + "dgn_qty2"], sourceNode.dgn_qty2);
  32. gatherNode[prefix + "contract_qty"] = helper.add(gatherNode[prefix + "contract_qty"], sourceNode.contract_qty);
  33. gatherNode[prefix + "contract_tp"] = helper.add(gatherNode[prefix + "contract_tp"], sourceNode.contract_tp);
  34. gatherNode[prefix + "qc_qty"] = helper.add(gatherNode[prefix + "qc_qty"], sourceNode.qc_qty);
  35. gatherNode[prefix + "qc_tp"] = helper.add(gatherNode[prefix + "qc_tp"], sourceNode.qc_tp);
  36. gatherNode[prefix + "gather_qty"] = helper.add(gatherNode[prefix + "gather_qty"], sourceNode.gather_qty);
  37. gatherNode[prefix + "gather_tp"] = helper.add(gatherNode[prefix + "gather_tp"], sourceNode.gather_tp);
  38. gatherNode[prefix + "pre_contract_qty"] = helper.add(gatherNode[prefix + "pre_contract_qty"], sourceNode.pre_contract_qty);
  39. gatherNode[prefix + "pre_contract_tp"] = helper.add(gatherNode[prefix + "pre_contract_tp"], sourceNode.pre_contract_tp);
  40. gatherNode[prefix + "pre_qc_qty"] = helper.add(gatherNode[prefix + "pre_qc_qty"], sourceNode.pre_qc_qty);
  41. gatherNode[prefix + "pre_qc_tp"] = helper.add(gatherNode[prefix + "pre_qc_tp"], sourceNode.pre_qc_tp);
  42. gatherNode[prefix + "pre_gather_qty"] = helper.add(gatherNode[prefix + "pre_gather_qty"], sourceNode.pre_gather_qty);
  43. gatherNode[prefix + "pre_gather_tp"] = helper.add(gatherNode[prefix + "pre_gather_tp"], sourceNode.pre_gather_tp);
  44. gatherNode[prefix + "end_contract_qty"] = helper.add(gatherNode[prefix + "end_contract_qty"], sourceNode.end_contract_qty);
  45. gatherNode[prefix + "end_contract_tp"] = helper.add(gatherNode[prefix + "end_contract_tp"], sourceNode.end_contract_tp);
  46. gatherNode[prefix + "end_qc_qty"] = helper.add(gatherNode[prefix + "end_qc_qty"], sourceNode.end_qc_qty);
  47. gatherNode[prefix + "end_qc_tp"] = helper.add(gatherNode[prefix + "end_qc_tp"], sourceNode.end_qc_tp);
  48. gatherNode[prefix + "end_gather_qty"] = helper.add(gatherNode[prefix + "end_gather_qty"], sourceNode.end_gather_qty);
  49. gatherNode[prefix + "end_gather_tp"] = helper.add(gatherNode[prefix + "end_gather_tp"], sourceNode.end_gather_tp);
  50. gatherNode[prefix + "deal_dgn_qty1"] = helper.add(gatherNode[prefix + "deal_dgn_qty1"], sourceNode.deal_dgn_qty1);
  51. gatherNode[prefix + "deal_dgn_qty2"] = helper.add(gatherNode[prefix + "deal_dgn_qty2"], sourceNode.deal_dgn_qty2);
  52. gatherNode[prefix + "c_dgn_qty1"] = helper.add(gatherNode[prefix + "c_dgn_qty1"], sourceNode.c_dgn_qty1);
  53. gatherNode[prefix + "c_dgn_qty2"] = helper.add(gatherNode[prefix + "c_dgn_qty2"], sourceNode.c_dgn_qty2);
  54. gatherNode['s_' + "qty"] = helper.add(gatherNode['s_' + "qty"], sourceNode.quantity);
  55. gatherNode['s_' + "tp"] = helper.add(gatherNode['s_' + "tp"], sourceNode.total_price);
  56. gatherNode['s_' + "dgn_qty1"] = helper.add(gatherNode['s_' + "dgn_qty1"], sourceNode.dgn_qty1);
  57. gatherNode['s_' + "dgn_qty2"] = helper.add(gatherNode['s_' + "dgn_qty2"], sourceNode.dgn_qty2);
  58. gatherNode['s_' + "contract_qty"] = helper.add(gatherNode['s_' + "contract_qty"], sourceNode.contract_qty);
  59. gatherNode['s_' + "contract_tp"] = helper.add(gatherNode['s_' + "contract_tp"], sourceNode.contract_tp);
  60. gatherNode['s_' + "qc_qty"] = helper.add(gatherNode['s_' + "qc_qty"], sourceNode.qc_qty);
  61. gatherNode['s_' + "qc_tp"] = helper.add(gatherNode['s_' + "qc_tp"], sourceNode.qc_tp);
  62. gatherNode['s_' + "gather_qty"] = helper.add(gatherNode['s_' + "gather_qty"], sourceNode.gather_qty);
  63. gatherNode['s_' + "gather_tp"] = helper.add(gatherNode['s_' + "gather_tp"], sourceNode.gather_tp);
  64. gatherNode['s_' + "pre_contract_qty"] = helper.add(gatherNode['s_' + "pre_contract_qty"], sourceNode.pre_contract_qty);
  65. gatherNode['s_' + "pre_contract_tp"] = helper.add(gatherNode['s_' + "pre_contract_tp"], sourceNode.pre_contract_tp);
  66. gatherNode['s_' + "pre_qc_qty"] = helper.add(gatherNode['s_' + "pre_qc_qty"], sourceNode.pre_qc_qty);
  67. gatherNode['s_' + "pre_qc_tp"] = helper.add(gatherNode['s_' + "pre_qc_tp"], sourceNode.pre_qc_tp);
  68. gatherNode['s_' + "pre_gather_qty"] = helper.add(gatherNode['s_' + "pre_gather_qty"], sourceNode.pre_gather_qty);
  69. gatherNode['s_' + "pre_gather_tp"] = helper.add(gatherNode['s_' + "pre_gather_tp"], sourceNode.pre_gather_tp);
  70. gatherNode['s_' + "end_contract_qty"] = helper.add(gatherNode['s_' + "end_contract_qty"], sourceNode.end_contract_qty);
  71. gatherNode['s_' + "end_contract_tp"] = helper.add(gatherNode['s_' + "end_contract_tp"], sourceNode.end_contract_tp);
  72. gatherNode['s_' + "end_qc_qty"] = helper.add(gatherNode['s_' + "end_qc_qty"], sourceNode.end_qc_qty);
  73. gatherNode['s_' + "end_qc_tp"] = helper.add(gatherNode['s_' + "end_qc_tp"], sourceNode.end_qc_tp);
  74. gatherNode['s_' + "end_gather_qty"] = helper.add(gatherNode['s_' + "end_gather_qty"], sourceNode.end_gather_qty);
  75. gatherNode['s_' + "end_gather_tp"] = helper.add(gatherNode['s_' + "end_gather_tp"], sourceNode.end_gather_tp);
  76. gatherNode['s_' + "deal_dgn_qty1"] = helper.add(gatherNode['s_' + "deal_dgn_qty1"], sourceNode.deal_dgn_qty1);
  77. gatherNode['s_' + "deal_dgn_qty2"] = helper.add(gatherNode['s_' + "deal_dgn_qty2"], sourceNode.deal_dgn_qty2);
  78. gatherNode['s_' + "c_dgn_qty1"] = helper.add(gatherNode['s_' + "c_dgn_qty1"], sourceNode.c_dgn_qty1);
  79. gatherNode['s_' + "c_dgn_qty2"] = helper.add(gatherNode['s_' + "c_dgn_qty2"], sourceNode.c_dgn_qty2);
  80. },
  81. gatherZone: function (tender, gatherNode, sourceNode, prefix, helper) {
  82. gatherNode[prefix + 'id'] = tender.id;
  83. gatherNode[prefix + 'name'] = tender.name;
  84. gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
  85. gatherNode[prefix + "tp"] = helper.add(gatherNode[prefix + "tp"], sourceNode.total_price);
  86. gatherNode[prefix + "dgn_qty1"] = helper.add(gatherNode[prefix + "dgn_qty1"], sourceNode.dgn_qty1);
  87. gatherNode[prefix + "dgn_qty2"] = helper.add(gatherNode[prefix + "dgn_qty2"], sourceNode.dgn_qty2);
  88. gatherNode[prefix + "contract_qty"] = helper.add(gatherNode[prefix + "contract_qty"], sourceNode.contract_qty);
  89. gatherNode[prefix + "contract_tp"] = helper.add(gatherNode[prefix + "contract_tp"], sourceNode.contract_tp);
  90. gatherNode[prefix + "qc_qty"] = helper.add(gatherNode[prefix + "qc_qty"], sourceNode.qc_qty);
  91. gatherNode[prefix + "qc_tp"] = helper.add(gatherNode[prefix + "qc_tp"], sourceNode.qc_tp);
  92. gatherNode[prefix + "gather_qty"] = helper.add(gatherNode[prefix + "gather_qty"], sourceNode.gather_qty);
  93. gatherNode[prefix + "gather_tp"] = helper.add(gatherNode[prefix + "gather_tp"], sourceNode.gather_tp);
  94. gatherNode[prefix + "deal_dgn_qty1"] = helper.add(gatherNode[prefix + "deal_dgn_qty1"], sourceNode.deal_dgn_qty1);
  95. gatherNode[prefix + "deal_dgn_qty2"] = helper.add(gatherNode[prefix + "deal_dgn_qty2"], sourceNode.deal_dgn_qty2);
  96. gatherNode[prefix + "c_dgn_qty1"] = helper.add(gatherNode[prefix + "c_dgn_qty1"], sourceNode.c_dgn_qty1);
  97. gatherNode[prefix + "c_dgn_qty2"] = helper.add(gatherNode[prefix + "c_dgn_qty2"], sourceNode.c_dgn_qty2);
  98. gatherNode['s_' + "qty"] = helper.add(gatherNode['s_' + "qty"], sourceNode.quantity);
  99. gatherNode['s_' + "tp"] = helper.add(gatherNode['s_' + "tp"], sourceNode.total_price);
  100. gatherNode['s_' + "contract_qty"] = helper.add(gatherNode['s_' + "contract_qty"], sourceNode.contract_qty);
  101. gatherNode['s_' + "contract_tp"] = helper.add(gatherNode['s_' + "contract_tp"], sourceNode.contract_tp);
  102. gatherNode['s_' + "qc_qty"] = helper.add(gatherNode['s_' + "qc_qty"], sourceNode.qc_qty);
  103. gatherNode['s_' + "qc_tp"] = helper.add(gatherNode['s_' + "qc_tp"], sourceNode.qc_tp);
  104. gatherNode['s_' + "gather_qty"] = helper.add(gatherNode['s_' + "gather_qty"], sourceNode.gather_qty);
  105. gatherNode['s_' + "gather_tp"] = helper.add(gatherNode['s_' + "gather_tp"], sourceNode.gather_tp);
  106. },
  107. gatherLedger: function (tender, gatherNode, sourceNode, prefix, helper) {
  108. gatherNode[prefix + 'id'] = tender.id;
  109. gatherNode[prefix + 'name'] = tender.name;
  110. gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
  111. gatherNode[prefix + "tp"] = helper.add(gatherNode[prefix + "tp"], sourceNode.total_price);
  112. gatherNode[prefix + "dgn_qty1"] = helper.add(gatherNode[prefix + "dgn_qty1"], sourceNode.dgn_qty1);
  113. gatherNode[prefix + "dgn_qty2"] = helper.add(gatherNode[prefix + "dgn_qty2"], sourceNode.dgn_qty2);
  114. gatherNode['s_' + "qty"] = helper.add(gatherNode['s_' + "qty"], sourceNode.quantity);
  115. gatherNode['s_' + "tp"] = helper.add(gatherNode['s_' + "tp"], sourceNode.total_price);
  116. },
  117. gatherSpecial: function (gatherNode, sourceNode, prefix, helper) {
  118. gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
  119. gatherNode[prefix + "tp"] = helper.add(gatherNode[prefix + "tp"], sourceNode.total_price);
  120. gatherNode[prefix + "dgn_qty1"] = helper.add(gatherNode[prefix + "dgn_qty1"], sourceNode.dgn_qty1);
  121. gatherNode[prefix + "dgn_qty2"] = helper.add(gatherNode[prefix + "dgn_qty2"], sourceNode.dgn_qty2);
  122. },
  123. };
  124. module.exports = app => {
  125. class RptGatherMemory extends app.BaseService {
  126. /**
  127. * 构造函数
  128. *
  129. * @param {Object} ctx - egg全局context
  130. * @return {void}
  131. */
  132. constructor(ctx) {
  133. super(ctx);
  134. this.resultTree = new Ledger.gatherTree(ctx, {
  135. id: 'id',
  136. pid: 'pid',
  137. order: 'order',
  138. level: 'level',
  139. rootId: -1
  140. });
  141. this.resultTenderInfo = [];
  142. this.resultDealPay = [];
  143. this.resultDealBills = [];
  144. }
  145. async _getValidStages(tenderId) {
  146. const stages = await this.db.select(this.ctx.service.stage.tableName, {
  147. where: { tid: tenderId },
  148. orders: [['order', 'desc']],
  149. });
  150. if (stages.length !== 0) {
  151. const lastStage = stages[0];
  152. if (lastStage.status === auditConst.stage.status.uncheck && lastStage.user_id !== this.ctx.session.sessionUser.accountId) {
  153. stages.splice(0, 1);
  154. }
  155. }
  156. return stages;
  157. }
  158. async _getCheckedStages(tenderId) {
  159. const stages = await this.db.select(this.ctx.service.stage.tableName, {
  160. where: { tid: tenderId },
  161. orders: [['order', 'desc']],
  162. });
  163. if (stages.length !== 0) {
  164. const lastStage = stages[0];
  165. if (lastStage.status !== auditConst.stage.status.checked) {
  166. stages.splice(0, 1);
  167. }
  168. }
  169. return stages;
  170. }
  171. _checkSpecialTender(tender, special) {
  172. if (special) {
  173. for (const spec of special) {
  174. if (tender[spec.key] === true) return spec.key;
  175. }
  176. }
  177. return '';
  178. }
  179. async _getTimeZoneStages(tender, zone) {
  180. const times = zone.split(' - ');
  181. if (times.length !== 2) throw '选择的汇总周期无效';
  182. const beginTime = moment(times[0], 'YYYY-MM');
  183. const endTime = moment(times[1], 'YYYY-MM');
  184. const stages = await this._getValidStages(tender.id), validStages = [];
  185. for (const stage of stages) {
  186. const sTime = moment(stage.s_time, 'YYYY-MM');
  187. if (sTime.isBetween(beginTime, endTime, null, '[]')) {
  188. validStages.push(stage);
  189. }
  190. }
  191. return validStages;
  192. }
  193. async _getOrderZoneStages (tender, zone) {
  194. let [iBegin, iEnd] = zone.split(':');
  195. iBegin = this.ctx.helper._.toInteger(iBegin) || 0;
  196. iEnd = this.ctx.helper._.toInteger(iEnd) || 0;
  197. const stages = await this._getValidStages(tender.id), validStages = [];
  198. for (const stage of stages) {
  199. if (stage.order < iBegin || stage.order > iEnd) continue;
  200. validStages.push(stage);
  201. }
  202. return validStages;
  203. }
  204. /**
  205. * 台账数据
  206. */
  207. async _gatherStageData(completeData, tender, stage, hasPre) {
  208. const helper = this.ctx.helper;
  209. completeData.id = tender.id;
  210. completeData.name = tender.name;
  211. const billsTree = new Ledger.billsTree(this.ctx, {
  212. id: 'ledger_id',
  213. pid: 'ledger_pid',
  214. order: 'order',
  215. level: 'level',
  216. rootId: -1,
  217. keys: ['id', 'tender_id', 'ledger_id'],
  218. stageId: 'id',
  219. calcFields: ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp', 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp'],
  220. calc: function (node) {
  221. if (node.children && node.children.length === 0) {
  222. node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
  223. node.gather_qty = helper.add(node.contract_qty, node.qc_qty);
  224. node.end_contract_qty = helper.add(node.pre_contract_qty, node.contract_qty);
  225. node.end_qc_qty = helper.add(node.pre_qc_qty, node.qc_qty);
  226. node.end_gather_qty = helper.add(node.pre_gather_qty, node.gather_qty);
  227. }
  228. node.pre_gather_tp = helper.add(node.pre_contract_tp, node.pre_qc_tp);
  229. node.gather_tp = helper.add(node.contract_tp, node.qc_tp);
  230. node.end_contract_tp = helper.add(node.pre_contract_tp, node.contract_tp);
  231. node.end_qc_tp = helper.add(node.pre_qc_tp, node.qc_tp);
  232. node.end_gather_tp = helper.add(node.pre_gather_tp, node.gather_tp);
  233. }
  234. });
  235. const billsData = await this.ctx.service.ledger.getData(tender.id);
  236. const dgnData = await this.ctx.service.stageBillsDgn.getDgnData(tender.id);
  237. for (const d of dgnData) {
  238. const l = this.ctx.helper._.find(billsData, {id: d.id});
  239. this.ctx.helper._.assignIn(l, d);
  240. }
  241. if (stage) {
  242. await this.ctx.service.stage.doCheckStage(stage);
  243. if (stage.readOnly) {
  244. const curStage = await this.ctx.service.stageBills.getAuditorStageData(tender.id,
  245. stage.id, stage.curTimes, stage.curOrder);
  246. this.ctx.helper.assignRelaData(billsData, [
  247. {
  248. data: curStage,
  249. fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'],
  250. prefix: '',
  251. relaId: 'lid'
  252. }
  253. ]);
  254. } else {
  255. const curStage = await this.ctx.service.stageBills.getLastestStageData(tender.id, stage.id);
  256. this.ctx.helper.assignRelaData(billsData, [
  257. {
  258. data: curStage,
  259. fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'],
  260. prefix: '',
  261. relaId: 'lid'
  262. }
  263. ]);
  264. }
  265. if (hasPre) {
  266. const preStage = stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(tender, stage.order - 1) : [];
  267. this.ctx.helper.assignRelaData(billsData, [
  268. {
  269. data: preStage,
  270. fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'],
  271. prefix: 'pre_',
  272. relaId: 'lid'
  273. }
  274. ]);
  275. }
  276. }
  277. billsTree.loadDatas(billsData);
  278. billsTree.calculateAll();
  279. this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
  280. gatherUtils.gatherStage(tender, gatherNode, sourceNode, completeData.prefix, helper);
  281. });
  282. }
  283. async _gatherStagesData(completeData, tender, stages) {
  284. const helper = this.ctx.helper;
  285. completeData.id = tender.id;
  286. completeData.name = tender.name;
  287. /**
  288. * 汇总并合并 相关数据
  289. * @param {Array} index - 主数据
  290. * @param {Array[]}rela - 相关数据 {data, fields, prefix, relaId}
  291. */
  292. const sumAssignRelaData = function (index, rela) {
  293. const loadFields = function (datas, fields, prefix, relaId) {
  294. for (const d of datas) {
  295. const key = indexPre + d[relaId];
  296. const m = index[key];
  297. if (m) {
  298. for (const f of fields) {
  299. if (d[f] !== undefined) {
  300. m[prefix + f] = helper.add(m[prefix + f], d[f]);
  301. }
  302. }
  303. }
  304. }
  305. };
  306. for (const r of rela) {
  307. loadFields(r.data, r.fields, r.prefix, r.relaId);
  308. }
  309. };
  310. const billsTree = new Ledger.billsTree(this.ctx, {
  311. id: 'ledger_id',
  312. pid: 'ledger_pid',
  313. order: 'order',
  314. level: 'level',
  315. rootId: -1,
  316. keys: ['id', 'tender_id', 'ledger_id'],
  317. stageId: 'id',
  318. calcFields: ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp'],
  319. calc: function (node) {
  320. if (node.children && node.children.length === 0) {
  321. node.gather_qty = helper.add(node.contract_qty, node.qc_qty);
  322. }
  323. node.gather_tp = helper.add(node.contract_tp, node.qc_tp);
  324. }
  325. });
  326. const billsData = await this.ctx.service.ledger.getData(tender.id);
  327. const dgnData = await this.ctx.service.stageBillsDgn.getDgnData(tender.id);
  328. for (const d of dgnData) {
  329. const l = this.ctx.helper._.find(billsData, {id: d.id});
  330. this.ctx.helper._.assignIn(l, d);
  331. }
  332. let billsIndexData = {};
  333. for (const bd of billsData) {
  334. billsIndexData[indexPre + bd.id] = bd;
  335. }
  336. for (const stage of stages) {
  337. await this.ctx.service.stage.doCheckStage(stage);
  338. if (stage.readOnly) {
  339. const curStage = await this.ctx.service.stageBills.getAuditorStageData(tender.id,
  340. stage.id, stage.curTimes, stage.curOrder);
  341. sumAssignRelaData(billsIndexData, [{
  342. data: curStage,
  343. fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'],
  344. prefix: '',
  345. relaId: 'lid'
  346. }]);
  347. } else {
  348. const curStage = await this.ctx.service.stageBills.getLastestStageData(tender.id, stage.id);
  349. sumAssignRelaData(billsIndexData, [{
  350. data: curStage,
  351. fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'],
  352. prefix: '',
  353. relaId: 'lid'
  354. }]);
  355. }
  356. }
  357. billsTree.loadDatas(billsData);
  358. billsTree.calculateAll();
  359. this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
  360. gatherUtils.gatherZone(tender, gatherNode, sourceNode, completeData.prefix, helper);
  361. });
  362. }
  363. async _gatherMonthData(tender, completeData, month, hasPre) {
  364. const stages = await this._getValidStages(tender.id);
  365. const stage = this.ctx.helper._.find(stages, {s_time: month});
  366. await this._gatherStageData(completeData, tender, stage, hasPre);
  367. }
  368. async _gatherIndexData(tender, completeData, index, hasPre) {
  369. const stages = await this._getValidStages(tender.id);
  370. const stage = this.ctx.helper._.find(stages, {order: index});
  371. await this._gatherStageData(completeData, tender, stage, hasPre);
  372. }
  373. async _gatherZoneData(tender, completeData, zone) {
  374. const stages = await this._getTimeZoneStages(tender, zone);
  375. await this._gatherStagesData(completeData, tender, stages);
  376. }
  377. async _gatherIndexZoneData(tender, completeData, stageZone) {
  378. const stages = await this._getOrderZoneStages(tender, stageZone);
  379. await this._gatherStagesData(completeData, tender, stages);
  380. }
  381. async _gatherFinalData(tender, completeData, hasPre) {
  382. const stages = await this._getValidStages(tender.id);
  383. await this._gatherStageData(completeData, tender, stages[0], hasPre);
  384. }
  385. async _gatherCheckedFinalData(tender, completeData, hasPre) {
  386. const stages = await this._getCheckedStages(tender.id);
  387. await this._gatherStageData(completeData, tender, stages[0], hasPre);
  388. }
  389. async _gatherLedgerData(tender, completeData) {
  390. const helper = this.ctx.helper;
  391. const billsTree = new Ledger.billsTree(this.ctx, {
  392. id: 'ledger_id',
  393. pid: 'ledger_pid',
  394. order: 'order',
  395. level: 'level',
  396. rootId: -1,
  397. keys: ['id', 'tender_id', 'ledger_id'],
  398. stageId: 'id',
  399. calcFields: ['deal_tp', 'total_price'],
  400. });
  401. const billsData = await this.ctx.service.ledger.getData(tender.id);
  402. billsTree.loadDatas(billsData);
  403. billsTree.calculateAll();
  404. this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
  405. gatherUtils.gatherLedger(tender, gatherNode, sourceNode, completeData.prefix, helper);
  406. });
  407. }
  408. async _gatherSpecialData(tender, sKey) {
  409. const helper = this.ctx.helper;
  410. const billsTree = new Ledger.billsTree(this.ctx, {
  411. id: 'ledger_id',
  412. pid: 'ledger_pid',
  413. order: 'order',
  414. level: 'level',
  415. rootId: -1,
  416. keys: ['id', 'tender_id', 'ledger_id'],
  417. stageId: 'id',
  418. calcFields: ['deal_tp', 'total_price'],
  419. });
  420. const billsData = await this.ctx.service.ledger.getData(tender.id);
  421. billsTree.loadDatas(billsData);
  422. billsTree.calculateAll();
  423. this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
  424. gatherUtils.gatherSpecial(gatherNode, sourceNode, 'ts_' + sKey + '_', helper);
  425. });
  426. }
  427. async getGatherStageBills(memFieldKeys, gsDefine, gsCustom) {
  428. if (!gsDefine || !gsDefine.enable) return [];
  429. if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
  430. const gsSetting = JSON.parse(gsDefine.setting);
  431. let commonIndex = 0;
  432. const completeDatas = [];
  433. for (const t of gsCustom.tenders) {
  434. const specialKey = this._checkSpecialTender(t, gsSetting.special);
  435. const tender = await this.ctx.service.tender.getCheckTender(t.tid);
  436. this.ctx.query_tender = tender;
  437. try {
  438. if (specialKey === '') {
  439. const completeData = {
  440. prefix: 't_' + commonIndex + '_',
  441. };
  442. completeDatas.push(completeData);
  443. switch (gsSetting.type) {
  444. case 'month':
  445. await this._gatherMonthData(tender, completeData, gsCustom.month, gsSetting.hasPre);
  446. break;
  447. case 'zone':
  448. await this._gatherZoneData(tender, completeData, gsCustom.zone);
  449. break;
  450. case 'final':
  451. await this._gatherFinalData(tender, completeData, gsSetting.hasPre);
  452. break;
  453. case 'checked-final':
  454. await this._gatherCheckedFinalData(tender, completeData, gsSetting.hasPre);
  455. break;
  456. case 'ledger':
  457. await this._gatherLedgerData(tender, completeData);
  458. break;
  459. case 'stage':
  460. await this._gatherIndexData(tender, completeData, gsCustom.stage, gsSetting.hasPre);
  461. break;
  462. case 'stage-zone':
  463. await this._gatherIndexZoneData(tender, completeData, gsCustom.stage_zone);
  464. break;
  465. }
  466. commonIndex++;
  467. } else {
  468. await this._gatherSpecialData(tender, specialKey);
  469. }
  470. } catch(err) {
  471. }
  472. this.ctx.query_tender = null;
  473. }
  474. this.resultTree.generateSortNodes();
  475. gatherUtils.completeGatherData(this.resultTree.nodes, completeDatas);
  476. return this.resultTree.getDefaultDatas();
  477. }
  478. /**
  479. * 标段信息
  480. */
  481. async _getBaseTenderInfo(tender) {
  482. const info = {
  483. id: tender.id,
  484. name: tender.name,
  485. deal_tp: tender.deal_tp,
  486. tp: tender.total_price
  487. };
  488. const deal_bills_sum = await this.ctx.service.dealBills.getSum(tender.id);
  489. info.deal_bills_tp = deal_bills_sum ? deal_bills_sum.total_price : 0;
  490. if (tender.ledger_status === auditConst.ledger.status.uncheck || tender.ledger_status === auditConst.ledger.status.checkNo) {
  491. const sum = await this.ctx.service.ledger.addUp({tender_id: tender.id/*, is_leaf: true*/});
  492. info.tp = sum.total_price;
  493. info.deal_tp = sum.deal_tp;
  494. }
  495. info.deal_info = tender.info.deal_info;
  496. info.construction_unit = tender.info.construction_unit;
  497. info.tech_param = tender.info.tech_param;
  498. info.deal_param = tender.info.deal_param;
  499. info.pay_account = tender.info.pay_account;
  500. info.deal_param.contractPriceWithoutZL = this.ctx.helper.sub(info.deal_param.contractPrice,
  501. info.deal_param.zanLiePrice);
  502. info.bid_info = tender.info.bid_info;
  503. return info;
  504. }
  505. async _getStageTenderInfo(stage, info) {
  506. if (stage) {
  507. const helper = this.ctx.helper;
  508. await this.ctx.service.stage.doCheckStage(stage);
  509. await this.ctx.service.stage.checkStageGatherData(stage);
  510. info.pre_contract_tp = stage.pre_contract_tp;
  511. info.pre_qc_tp = stage.pre_qc_tp;
  512. info.pre_gather_tp = helper.add(info.pre_contract_tp, info.pre_qc_tp);
  513. info.contract_tp = stage.contract_tp;
  514. info.qc_tp = stage.qc_tp;
  515. info.gather_tp = helper.add(info.contract_tp, info.qc_tp);
  516. info.end_contract_tp = helper.add(info.pre_contract_tp, info.contract_tp);
  517. info.end_qc_tp = helper.add(info.pre_qc_tp, info.qc_tp);
  518. info.end_gather_tp = helper.add(info.pre_gather_tp, info.gather_tp);
  519. info.yf_tp = stage.yf_tp;
  520. info.pre_yf_tp = stage.pre_yf_tp;
  521. info.end_yf_tp = helper.add(stage.yf_tp, stage.pre_yf_tp);
  522. }
  523. }
  524. async _getStagesTenderInfo(stages, info) {
  525. const helper = this.ctx.helper;
  526. for (const stage of stages) {
  527. await this.ctx.service.stage.doCheckStage(stage);
  528. await this.ctx.service.stage.checkStageGatherData(stage);
  529. info.contract_tp = helper.add(info.contract_tp, stage.contract_tp);
  530. info.qc_tp = helper.add(info.qc_tp, stage.qc_tp);
  531. info.yf_tp = helper.add(info.yf_tp, stage.yf_tp);
  532. }
  533. info.gather_tp = helper.add(info.contract_tp, info.qc_tp);
  534. }
  535. async _gatherMonthTenderInfo(tender, index, month, hasPre) {
  536. const info = await this._getBaseTenderInfo(tender);
  537. const stages = await this._getValidStages(tender.id);
  538. const stage = this.ctx.helper._.find(stages, {s_time: month});
  539. await this._getStageTenderInfo(stage, info);
  540. this.resultTenderInfo.push(info);
  541. }
  542. async _gatherOrderTenderInfo(tender, index, order, hasPre) {
  543. const info = await this._getBaseTenderInfo(tender);
  544. const stages = await this._getValidStages(tender.id);
  545. const stage = this.ctx.helper._.find(stages, {order: order});
  546. await this._getStageTenderInfo(stage, info);
  547. this.resultTenderInfo.push(info);
  548. }
  549. async _gatherZoneTenderInfo(tender, index, zone) {
  550. const info = await this._getBaseTenderInfo(tender);
  551. const stages = await this._getTimeZoneStages(tender, zone);
  552. await this._getStagesTenderInfo(stages, info);
  553. this.resultTenderInfo.push(info);
  554. }
  555. async _gatherOrderZoneTenderInfo(tender, index, stageZone) {
  556. const info = await this._getBaseTenderInfo(tender);
  557. const stages = await this._getOrderZoneStages(tender, stageZone);
  558. await this._getStagesTenderInfo(stages, info);
  559. this.resultTenderInfo.push(info);
  560. }
  561. async _gatherFinalTenderInfo(tender, index, hasPre) {
  562. const info = await this._getBaseTenderInfo(tender);
  563. const stages = await this._getValidStages(tender.id);
  564. await this._getStageTenderInfo(stages[0], info);
  565. this.resultTenderInfo.push(info);
  566. }
  567. async _gatherCheckedFinalTenderInfo(tender, index, hasPre) {
  568. const info = await this._getBaseTenderInfo(tender);
  569. const stages = await this._getCheckedStages(tender.id);
  570. await this._getStageTenderInfo(stages[0], info);
  571. this.resultTenderInfo.push(info);
  572. }
  573. async _gatherLedgerTenderInfo(tender, index) {
  574. const info = await this._getBaseTenderInfo(tender);
  575. this.resultTenderInfo.push(info);
  576. }
  577. async _gatherSpecialTenderInfo(tender, sKey) {
  578. const info = await this._getBaseTenderInfo(tender);
  579. info.spec = sKey;
  580. this.resultTenderInfo.push(info);
  581. }
  582. async getGatherTenderInfo(memFieldKeys, gsDefine, gsCustom) {
  583. if (!gsDefine || !gsDefine.enable) return [];
  584. if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
  585. this.resultTenderInfo = [];
  586. const gsSetting = JSON.parse(gsDefine.setting);
  587. let commonIndex = 0;
  588. for (const t of gsCustom.tenders) {
  589. const specialKey = this._checkSpecialTender(t, gsSetting.special);
  590. const tender = await this.ctx.service.tender.getCheckTender(t.tid);
  591. this.ctx.query_tender = tender;
  592. try {
  593. if (specialKey === '') {
  594. switch (gsSetting.type) {
  595. case 'month':
  596. await this._gatherMonthTenderInfo(tender, commonIndex, gsCustom.month, gsSetting.hasPre);
  597. break;
  598. case 'zone':
  599. await this._gatherZoneTenderInfo(tender, commonIndex, gsCustom.zone);
  600. break;
  601. case 'final':
  602. await this._gatherFinalTenderInfo(tender, commonIndex, gsSetting.hasPre);
  603. break;
  604. case 'checked-final':
  605. await this._gatherCheckedFinalTenderInfo(tender, commonIndex, gsSetting.hasPre);
  606. break;
  607. case 'ledger':
  608. await this._gatherLedgerTenderInfo(tender, commonIndex);
  609. break;
  610. case 'stage':
  611. await this._gatherOrderTenderInfo(tender, commonIndex, gsCustom.stage, gsSetting.hasPre);
  612. break;
  613. case 'stage-zone':
  614. await this._gatherOrderZoneTenderInfo(tender, commonIndex, gsCustom.stage_zone);
  615. break;
  616. }
  617. commonIndex++;
  618. } else {
  619. await this._gatherSpecialTenderInfo(tender, specialKey);
  620. }
  621. } catch (err) {
  622. }
  623. this.ctx.query_tender = null;
  624. }
  625. return this.resultTenderInfo;
  626. }
  627. /**
  628. * 合同支付
  629. */
  630. _gatherPayRecord(dealPay, fun) {
  631. let rdp;
  632. if (dealPay.ptype !== payConst.payType.normal) {
  633. rdp = this.ctx.helper._.find(this.resultDealPay, {ptype: dealPay.ptype});
  634. } else {
  635. rdp = this.ctx.helper._.find(this.resultDealPay, {
  636. name: dealPay.name,
  637. minus: dealPay.minus ? true : false,
  638. is_yf: dealPay.is_yf ? true : false,
  639. });
  640. }
  641. if (!rdp) {
  642. rdp = {
  643. ptype: dealPay.ptype,
  644. name: dealPay.name,
  645. minus: dealPay.minus ? true : false,
  646. is_yf: dealPay.is_yf ? true : false,
  647. };
  648. this.resultDealPay.push(rdp);
  649. }
  650. if (fun) fun(rdp, dealPay);
  651. }
  652. async _checkStagePayCalc(tender, stage, dealPay) {
  653. if (!stage.readOnly) {
  654. // 计算 本期金额
  655. const payCalculator = new PayCalculator(this.ctx, stage, tender.info);
  656. await payCalculator.calculateAll(dealPay);
  657. }
  658. }
  659. async _gatherStagePay(completeData, tender, stage, hasPre) {
  660. if (stage) {
  661. completeData.id = tender.id;
  662. completeData.name = tender.name;
  663. const helper = this.ctx.helper;
  664. await this.ctx.service.stage.doCheckStage(stage);
  665. const dealPay = await this.ctx.service.stagePay.getStagePays(stage);
  666. await this._checkStagePayCalc(tender, stage, dealPay);
  667. for (const dp of dealPay) {
  668. dp.end_tp = helper.add(dp.pre_tp, dp.tp);
  669. this._gatherPayRecord(dp, function (gatherData, sourceData) {
  670. gatherData[completeData.prefix + 'id'] = tender.id;
  671. gatherData[completeData.prefix + 'name'] = tender.name;
  672. gatherData[completeData.prefix + 'tp'] = helper.add(gatherData[completeData.prefix + 'tp'], sourceData.tp);
  673. gatherData[completeData.prefix + 'pre_tp'] = helper.add(gatherData[completeData.prefix + 'pre_tp'], sourceData.pre_tp);
  674. gatherData[completeData.prefix + 'end_tp'] = helper.add(gatherData[completeData.prefix + 'end_tp'], sourceData.end_tp);
  675. gatherData['s_' + 'tp'] = helper.add(gatherData['s_' + 'tp'], sourceData.tp);
  676. gatherData['s_' + 'pre_tp'] = helper.add(gatherData['s_' + 'pre_tp'], sourceData.pre_tp);
  677. gatherData['s_' + 'end_tp'] = helper.add(gatherData['s_' + 'end_tp'], sourceData.end_tp);
  678. });
  679. }
  680. }
  681. }
  682. async _gatherStagesPay(completeData, tender, stages) {
  683. const helper = this.ctx.helper;
  684. completeData.id = tender.id;
  685. completeData.name = tender.name;
  686. for (const stage of stages) {
  687. await this.ctx.service.stage.doCheckStage(stage);
  688. const dealPay = await this.ctx.service.stagePay.getStagePays(stage);
  689. await this._checkStagePayCalc(tender, stage, dealPay);
  690. for (const dp of dealPay) {
  691. dp.end_tp = helper.add(dp.pre_tp, dp.tp);
  692. this._gatherPayRecord(dp, function (gatherData, sourceData) {
  693. gatherData[completeData.prefix + 'id'] = tender.id;
  694. gatherData[completeData.prefix + 'name'] = tender.name;
  695. gatherData[completeData.prefix + 'tp'] = helper.add(gatherData[completeData.prefix + 'tp'], sourceData.tp);
  696. gatherData['s_' + 'tp'] = helper.add(gatherData['s_' + 'tp'], sourceData.tp);
  697. });
  698. }
  699. }
  700. }
  701. async _gatherMonthStagePay(sTender, completeData, month, hasPre) {
  702. const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
  703. const stages = await this._getValidStages(tender.id);
  704. const stage = this.ctx.helper._.find(stages, {s_time: month});
  705. await this._gatherStagePay(completeData, tender, stage, hasPre);
  706. }
  707. async _gatherOrderStagePay(sTender, completeData, order, hasPre) {
  708. const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
  709. const stages = await this._getValidStages(tender.id);
  710. const stage = this.ctx.helper._.find(stages, {order: order});
  711. await this._gatherStagePay(completeData, tender, stage, hasPre);
  712. }
  713. async _gatherZoneStagePay(sTender, completeData, zone) {
  714. const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
  715. const stages = await this._getTimeZoneStages(tender, zone);
  716. await this._gatherStagesPay(completeData, tender, stages);
  717. }
  718. async _gatherOrderZoneStagePay(sTender, completeData, stageZone) {
  719. const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
  720. const stages = await this._getOrderZoneStages(tender, stageZone)
  721. await this._gatherStagesPay(completeData, tender, stages);
  722. }
  723. async _gatherFinalStagePay(sTender, completeData, hasPre) {
  724. const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
  725. const stages = await this._getValidStages(tender.id);
  726. await this._gatherStagePay(completeData, tender, stages[0], hasPre);
  727. }
  728. async _gatherCheckedFinalStagePay(sTender, completeData, hasPre) {
  729. const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
  730. const stages = await this._getCheckedStages(tender.id);
  731. await this._gatherStagePay(completeData, tender, stages[0], hasPre);
  732. }
  733. async getGatherStagePay(memFieldKeys, gsDefine, gsCustom) {
  734. if (!gsDefine || !gsDefine.enable) return [];
  735. if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
  736. this.resultTenderInfo = [];
  737. const gsSetting = JSON.parse(gsDefine.setting);
  738. let commonIndex = 0;
  739. const completeDatas = [];
  740. for (const tender of gsCustom.tenders) {
  741. const specialKey = this._checkSpecialTender(tender, gsSetting.special);
  742. if (specialKey === '') {
  743. const completeData = {
  744. prefix: 't_' + commonIndex + '_',
  745. };
  746. completeDatas.push(completeData);
  747. switch (gsSetting.type) {
  748. case 'month':
  749. await this._gatherMonthStagePay(tender, completeData, gsCustom.month, gsSetting.hasPre);
  750. break;
  751. case 'zone':
  752. await this._gatherZoneStagePay(tender, completeData, gsCustom.zone);
  753. break;
  754. case 'final':
  755. await this._gatherFinalStagePay(tender, completeData, gsSetting.hasPre);
  756. break;
  757. case 'checked-final':
  758. await this._gatherCheckedFinalStagePay(tender, completeData, gsSetting.hasPre);
  759. break;
  760. case 'stage':
  761. await this._gatherOrderStagePay(tender, completeData, gsCustom.stage, gsSetting.hasPre);
  762. break;
  763. case 'stage-zone':
  764. await this._gatherOrderZoneStagePay(tender, completeData, gsCustom.stage_zone);
  765. break;
  766. }
  767. commonIndex++;
  768. }
  769. // 合同支付,只有在每一期中有数据,故特殊标段直接不汇总合同支付
  770. }
  771. gatherUtils.completeGatherData(this.resultDealPay, completeDatas);
  772. return this.resultDealPay;
  773. }
  774. /**
  775. * 签约清单
  776. */
  777. async _gatherDealBills(tender, fun) {
  778. const dealBills = await this.ctx.service.dealBills.getAllDataByCondition({
  779. where: { tender_id: tender.id }
  780. });
  781. for (const db of dealBills) {
  782. let rdb = this.ctx.helper._.find(this.resultDealBills, {
  783. code: db.code,
  784. name: db.name,
  785. unit: db.unit,
  786. unit_price: db.unit_price ? db.unit_price: 0,
  787. });
  788. if (!rdb) {
  789. rdb = {
  790. code: db.code,
  791. name: db.name,
  792. unit: db.unit,
  793. unit_price: db.unit_price ? db.unit_price: 0,
  794. };
  795. this.resultDealBills.push(rdb);
  796. }
  797. if (fun) fun(rdb, db);
  798. }
  799. }
  800. async _gatherCommonDealBills(sTender, completeData) {
  801. const self = this;
  802. const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
  803. completeData.id = tender.id;
  804. completeData.name = tender.name;
  805. await this._gatherDealBills(tender, function (gatherData, sourceData) {
  806. gatherData[completeData.prefix + 'id'] = tender.id;
  807. gatherData[completeData.prefix + 'name'] = tender.name;
  808. gatherData[completeData.prefix + 'qty'] = sourceData.quantity;
  809. gatherData[completeData.prefix + 'tp'] = sourceData.total_price;
  810. gatherData['s_' + 'qty'] = self.ctx.helper.add(gatherData['s_' + 'qty'], sourceData.quantity);
  811. gatherData['s_' + 'tp'] = self.ctx.helper.add(gatherData['s_' + 'tp'], sourceData.total_price);
  812. });
  813. }
  814. async _gatherSpecialDealBills(sTender, sKey) {
  815. const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
  816. await this._gatherDealBills(tender, function (gatherData, sourceData) {
  817. const prefix = 'ts_' + sKey + '_';
  818. gatherData[prefix + 'qty'] = sourceData.quantity;
  819. gatherData[prefix + 'tp'] = sourceData.total_price;
  820. });
  821. }
  822. async getGatherDealBills(memFieldKeys, gsDefine, gsCustom) {
  823. if (!gsDefine || !gsDefine.enable) return [];
  824. if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
  825. this.resultTenderInfo = [];
  826. const gsSetting = JSON.parse(gsDefine.setting);
  827. let commonIndex = 0;
  828. const completeDatas = [];
  829. for (const tender of gsCustom.tenders) {
  830. const specialKey = this._checkSpecialTender(tender, gsSetting.special);
  831. if (specialKey === '') {
  832. const completeData = {
  833. prefix: 't_' + commonIndex + '_',
  834. };
  835. completeDatas.push(completeData);
  836. await this._gatherCommonDealBills(tender, completeData);
  837. commonIndex++;
  838. } else {
  839. await this._gatherSpecialDealBills(tender, specialKey);
  840. }
  841. }
  842. gatherUtils.completeGatherData(this.resultDealBills, completeDatas);
  843. return this.resultDealBills;
  844. }
  845. }
  846. return RptGatherMemory;
  847. };