Jelajahi Sumber

1. 汇总表,汇总区间,标段信息&合同支付,提供截止上,截止本数据
2. 汇总表,汇总区间,标段信息&合同支付,根据终审审批通过时间汇总

MaiXinRong 2 tahun lalu
induk
melakukan
b43488bdac
1 mengubah file dengan 73 tambahan dan 37 penghapusan
  1. 73 37
      app/service/rpt_gather_memory.js

+ 73 - 37
app/service/rpt_gather_memory.js

@@ -760,19 +760,49 @@ module.exports = app => {
                 info.end_sf_tp = helper.add(stage.sf_tp, stage.pre_sf_tp);
             }
         }
-
-        async _getStagesTenderInfo(stages, info) {
+        async _getStagesTenderInfo(stages, info, preStage) {
             const helper = this.ctx.helper;
+            if (preStage) {
+                info.pre_contract_tp = helper.add(preStage.contract_tp, preStage.pre_contract_tp);
+                info.pre_qc_tp = helper.add(preStage.qc_tp, preStage.pre_qc_tp);
+                info.pre_gather_tp = helper.add(info.pre_contract_tp, info.pre_qc_tp);
+                info.pre_yf_tp = helper.add(preStage.yf_tp, preStage.pre_yf_tp);
+            }
+
             for (const stage of stages) {
                 await this.ctx.service.stage.doCheckStage(stage);
                 await this.ctx.service.stage.checkStageGatherData(stage, this.ctx.session.sessionUser.is_admin);
 
+
                 info.contract_tp = helper.add(info.contract_tp, stage.contract_tp);
                 info.qc_tp = helper.add(info.qc_tp, stage.qc_tp);
 
                 info.yf_tp = helper.add(info.yf_tp, stage.yf_tp);
             }
             info.gather_tp = helper.add(info.contract_tp, info.qc_tp);
+            info.end_contract_tp = helper.add(info.pre_contract_tp, info.contract_tp);
+            info.end_qc_tp = helper.add(info.pre_qc_tp, info.qc_tp);
+            info.end_gather_tp = helper.add(info.pre_gather_tp, info.gather_tp);
+            info.end_yf_tp = helper.add(info.pre_yf_tp, info.yf_tp);
+        }
+
+        async _gatherZoneTenderInfo(tender, index, zone) {
+            const info = await this._getBaseTenderInfo(tender);
+            const [stages, preStage, endStage] = await this._getTimeZoneStages(tender, zone);
+            await this._getStagesTenderInfo(stages, info, preStage);
+            this.resultTenderInfo.push(info);
+        }
+        async _gatherOrderZoneTenderInfo(tender, index, stageZone) {
+            const info = await this._getBaseTenderInfo(tender);
+            const [stages, preStage, endStage] = await this._getOrderZoneStages(tender, stageZone);
+            await this._getStagesTenderInfo(stages, info, preStage);
+            this.resultTenderInfo.push(info);
+        }
+        async _gatherCheckedZoneTenderInfo(tender, index, zone) {
+            const info = await this._getBaseTenderInfo(tender);
+            const [stages, preStage, endStage] = await this._getCheckedZoneStages(tender, zone);
+            await this._getStagesTenderInfo(stages, info, preStage);
+            this.resultTenderInfo.push(info);
         }
 
         async _gatherMonthTenderInfo(tender, index, month, hasPre) {
@@ -782,7 +812,6 @@ module.exports = app => {
             await this._getStageTenderInfo(stage, info);
             this.resultTenderInfo.push(info);
         }
-
         async _gatherOrderTenderInfo(tender, index, order, hasPre) {
             const info = await this._getBaseTenderInfo(tender);
             const stages = await this._getValidStages(tender.id);
@@ -790,28 +819,12 @@ module.exports = app => {
             await this._getStageTenderInfo(stage, info);
             this.resultTenderInfo.push(info);
         }
-
-        async _gatherZoneTenderInfo(tender, index, zone) {
-            const info = await this._getBaseTenderInfo(tender);
-            const stages = await this._getTimeZoneStages(tender, zone);
-            await this._getStagesTenderInfo(stages, info);
-            this.resultTenderInfo.push(info);
-        }
-
-        async _gatherOrderZoneTenderInfo(tender, index, stageZone) {
-            const info = await this._getBaseTenderInfo(tender);
-            const stages = await this._getOrderZoneStages(tender, stageZone);
-            await this._getStagesTenderInfo(stages, info);
-            this.resultTenderInfo.push(info);
-        }
-
         async _gatherFinalTenderInfo(tender, index, hasPre) {
             const info = await this._getBaseTenderInfo(tender);
             const stages = await this._getValidStages(tender.id);
             await this._getStageTenderInfo(stages[0], info);
             this.resultTenderInfo.push(info);
         }
-
         async _gatherCheckedFinalTenderInfo(tender, index, hasPre) {
             const info = await this._getBaseTenderInfo(tender);
             const stages = await this._getCheckedStages(tender.id);
@@ -823,7 +836,6 @@ module.exports = app => {
             const info = await this._getBaseTenderInfo(tender);
             this.resultTenderInfo.push(info);
         }
-
         async _gatherSpecialTenderInfo(tender, sKey) {
             const info = await this._getBaseTenderInfo(tender);
             info.spec = sKey;
@@ -863,6 +875,9 @@ module.exports = app => {
                         case 'stage-zone':
                             await this._gatherOrderZoneTenderInfo(tender, commonIndex, gsCustom.stage_zone);
                             break;
+                        case 'checked-zone':
+                            await this._gatherCheckedZoneTenderInfo(tender, commonIndex, gsCustom.checked_zone);
+                            break;
                     }
                     commonIndex++;
                 } else {
@@ -932,12 +947,26 @@ module.exports = app => {
                 }
             }
         }
-
-        async _gatherStagesPay(completeData, tender, stages) {
+        async _gatherStagesPay(completeData, tender, stages, preStage) {
             const helper = this.ctx.helper;
             completeData.id = tender.id;
             completeData.name = tender.name;
 
+            const preDealPay = preStage ? await this.ctx.service.stagePay.getStagePays(preStage) : [];
+            for (const dp of preDealPay) {
+                dp.end_tp = helper.add(dp.pre_tp, dp.tp);
+                this._gatherPayRecord(dp, function (gatherData, sourceData) {
+                    gatherData[completeData.prefix + 'id'] = tender.id;
+                    gatherData[completeData.prefix + 'name'] = tender.name;
+
+                    gatherData[completeData.prefix + 'pre_tp'] = sourceData.end_tp;
+                    gatherData.s_pre_tp = helper.add(gatherData.s_pre_tp, sourceData.end_tp);
+
+                    gatherData[completeData.prefix + 'end_tp'] = sourceData.end_tp;
+                    gatherData.s_end_tp = helper.add(gatherData.s_end_tp, sourceData.end_tp);
+                });
+            }
+
             for (const stage of stages) {
                 await this.ctx.service.stage.doCheckStage(stage);
 
@@ -951,43 +980,47 @@ module.exports = app => {
 
                         gatherData[completeData.prefix + 'tp'] = helper.add(gatherData[completeData.prefix + 'tp'], sourceData.tp);
                         gatherData['s_' + 'tp'] = helper.add(gatherData['s_' + 'tp'], sourceData.tp);
+
+                        gatherData[completeData.prefix + 'end_tp'] = helper.add(gatherData[completeData.prefix + 'end_tp'], sourceData.tp);
+                        gatherData['s_' + 'end_tp'] = helper.add(gatherData['s_' + 'end_tp'], sourceData.tp);
                     });
                 }
             }
         }
 
+        async _gatherZoneStagePay(sTender, completeData, zone) {
+            const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
+            const [stages, preStage, endStage] = await this._getTimeZoneStages(tender, zone);
+            await this._gatherStagesPay(completeData, tender, stages, preStage);
+        }
+        async _gatherOrderZoneStagePay(sTender, completeData, stageZone) {
+            const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
+            const [stages, preStage, endStage] = await this._getOrderZoneStages(tender, stageZone);
+            await this._gatherStagesPay(completeData, tender, stages, preStage);
+        }
+        async _gatherCheckedZoneStagePay(sTender, completeData, zone) {
+            const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
+            const [stages, preStage, endStage] = await this._getCheckedZoneStages(tender, zone);
+            await this._gatherStagesPay(completeData, tender, stages, preStage);
+        }
+
         async _gatherMonthStagePay(sTender, completeData, month, hasPre) {
             const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
             const stages = await this._getValidStages(tender.id);
             const stage = this.ctx.helper._.find(stages, {s_time: month});
             await this._gatherStagePay(completeData, tender, stage, hasPre);
         }
-
         async _gatherOrderStagePay(sTender, completeData, order, hasPre) {
             const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
             const stages = await this._getValidStages(tender.id);
             const stage = this.ctx.helper._.find(stages, {order: order});
             await this._gatherStagePay(completeData, tender, stage, hasPre);
         }
-
-        async _gatherZoneStagePay(sTender, completeData, zone) {
-            const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
-            const stages = await this._getTimeZoneStages(tender, zone);
-            await this._gatherStagesPay(completeData, tender, stages);
-        }
-
-        async _gatherOrderZoneStagePay(sTender, completeData, stageZone) {
-            const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
-            const stages = await this._getOrderZoneStages(tender, stageZone)
-            await this._gatherStagesPay(completeData, tender, stages);
-        }
-
         async _gatherFinalStagePay(sTender, completeData, hasPre) {
             const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
             const stages = await this._getValidStages(tender.id);
             await this._gatherStagePay(completeData, tender, stages[0], hasPre);
         }
-
         async _gatherCheckedFinalStagePay(sTender, completeData, hasPre) {
             const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
             const stages = await this._getCheckedStages(tender.id);
@@ -1028,6 +1061,9 @@ module.exports = app => {
                         case 'stage-zone':
                             await this._gatherOrderZoneStagePay(tender, completeData, gsCustom.stage_zone);
                             break;
+                        case 'checked-zone':
+                            await this._gatherCheckedZoneStagePay(tender, completeData, gsCustom.checked_zone);
+                            break;
                     }
                     commonIndex++;
                 }