spss.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. 'use strict';
  2. /**
  3. * 要求必须有ctx.subProject
  4. * 如果不是子项目内部使用,需要先载入ctx.subProject再使用
  5. *
  6. * @author Mai
  7. * @date
  8. * @version
  9. */
  10. class reportMemorySpss {
  11. constructor(ctx) {
  12. this.ctx = ctx;
  13. }
  14. async _loadTypeData(type) {
  15. if (!this[type]) this[type] = await this.ctx.service.spssStash.getLatestSpssStash(this.ctx.subProject.id, type);
  16. }
  17. async getTypeTender(type) {
  18. await this._loadTypeData(type);
  19. return this[type] ? this[type].spss_select : [];
  20. }
  21. async getTyperBills(type) {
  22. await this._loadTypeData(type);
  23. return this[type] && this[type].spss_result ? this[type].spss_result.bills : [];
  24. }
  25. getBillsPosData(bills) {
  26. const pos = [];
  27. for (const b of bills) {
  28. if (!b.pos || b.pos.length === 0) continue;
  29. b.pos.forEach(x => { x.lid === b.ledger_id; });
  30. pos.push(...b.pos);
  31. }
  32. return pos;
  33. }
  34. async getTypePos(type) {
  35. await this._loadTypeData(type);
  36. return this[type] && this[type].spss_result ? this.getBillsPosData(this[type].spss_result.bills) : [];
  37. }
  38. async getGatherStageInfoTender() {
  39. return await this.getTypeTender('gather_stage_info');
  40. }
  41. async getGatherStageInfo() {
  42. await this._loadTypeData('gather_stage_info');
  43. return this.gather_stage_info.spss_result || [];
  44. }
  45. async getGatherLedgerTender() {
  46. return await this.getTypeTender('gather_ledger');
  47. }
  48. async getGatherLedgerBills() {
  49. return await this.getTyperBills('gather_ledger');
  50. }
  51. async getGatherLedgerPos() {
  52. return await this.getTypePos('gather_ledger');
  53. }
  54. async getGatherStageTender() {
  55. return await this.getTypeTender('gather_stage');
  56. }
  57. async getGatherStageBills() {
  58. return await this.getTyperBills('gather_stage');
  59. }
  60. async getGatherStagePos() {
  61. return await this.getTypePos('gather_stage');
  62. }
  63. async getGatherStageExtraTender() {
  64. return await this.getTypeTender('gather_stage_extra');
  65. }
  66. async getGatherStageJgcl() {
  67. const type = 'gather_stage_extra';
  68. await this._loadTypeData(type);
  69. return this[type] && this[type].spss_result ? this[type].spss_result.jgcl : [];
  70. }
  71. async getGatherStageYjcl() {
  72. const type = 'gather_stage_extra';
  73. await this._loadTypeData(type);
  74. return this[type] && this[type].spss_result ? this[type].spss_result.yjcl : [];
  75. }
  76. async getGatherStageBonus() {
  77. const type = 'gather_stage_extra';
  78. await this._loadTypeData(type);
  79. return this[type] && this[type].spss_result ? this[type].spss_result.bonus : [];
  80. }
  81. async getGatherStageOther() {
  82. const type = 'gather_stage_extra';
  83. await this._loadTypeData(type);
  84. return this[type] && this[type].spss_result ? this[type].spss_result.other : [];
  85. }
  86. async getGatherStageSafeProd() {
  87. const type = 'gather_stage_extra';
  88. await this._loadTypeData(type);
  89. return this[type] && this[type].spss_result ? this[type].spss_result.safeProd : [];
  90. }
  91. async getGatherStageTempLand() {
  92. const type = 'gather_stage_extra';
  93. await this._loadTypeData(type);
  94. return this[type] && this[type].spss_result ? this[type].spss_result.tempLand : [];
  95. }
  96. async getGatherStagePayTender() {
  97. return await this.getTypeTender('gather_stage_pay');
  98. }
  99. async getGatherStagePay() {
  100. const type = 'gather_stage_pay';
  101. await this._loadTypeData(type);
  102. return this[type] && this[type].spss_result ? this[type].spss_result.pays : [];
  103. }
  104. async getCompareLedgerTender() {
  105. return await this.getTypeTender('compare_ledger');
  106. }
  107. async getCompareLedgerBills() {
  108. return await this.getTyperBills('compare_ledger');
  109. }
  110. async getCompareLedgerPos() {
  111. return await this.getTypePos('compare_ledger');
  112. }
  113. async getCompareStageTender() {
  114. return await this.getTypeTender('compare_stage');
  115. }
  116. async getCompareStageBills() {
  117. return await this.getTyperBills('compare_stage');
  118. }
  119. async getCompareStagePos() {
  120. return await this.getTypePos('compare_stage');
  121. }
  122. }
  123. module.exports = reportMemorySpss;