Procházet zdrojové kódy

台账修订后,计量期,缓存相关

MaiXinRong před 1 rokem
rodič
revize
bec5f70097

+ 1 - 2
app/controller/measure_controller.js

@@ -47,8 +47,7 @@ module.exports = app => {
                     auditConst2: JSON.stringify(auditConst),
                     auditType,
                 };
-                renderData.stages = await ctx.service.stage.getValidStages(ctx.tender.id);
-                if (renderData.stages.length > 0) await this.ctx.service.stage.checkStageGatherData(renderData.stages[0], this.ctx.session.sessionUser.is_admin);
+                renderData.stages = await ctx.service.stage.getValidStages(ctx.tender.id, this.ctx.session.sessionUser.is_admin);
                 for (const s of renderData.stages) {
                     // 根据期状态返回展示用户
                     s.curAuditors = await ctx.service.stageAudit.getAuditorsByStatus(s.id, s.status, s.times);

+ 1 - 0
app/lib/revise_price.js

@@ -391,6 +391,7 @@ class revisePriceCalc {
         if (result.ibData.length > 0) await transaction.insert(this.ctx.service.stageBills.tableName, result.ibData);
         if (result.ubData.length > 0) await transaction.updateRows(this.ctx.service.stageBills.tableName, result.ubData);
         if (result.scData.length > 0) await transaction.updateRows(this.ctx.service.stageChange.tableName, result.scData);
+        if (result.ibData.length > 0 || result.ubData.length > 0) await transaction.update(this.ctx.service.stage.tableName, { id: stage.id, check_calc: true});
     }
     /**
      * 计算修订台账

+ 2 - 2
app/service/stage.js

@@ -407,7 +407,7 @@ module.exports = app => {
          * @param tenderId
          * @return {Promise<void>}
          */
-        async getValidStages(tenderId) {
+        async getValidStages(tenderId, force = false) {
             let stages = await this.db.select(this.tableName, {
                 where: { tid: tenderId },
                 orders: [['order', 'desc']],
@@ -423,7 +423,7 @@ module.exports = app => {
             if (stages.length === 0) return stages;
 
             for (const s of stages) {
-                if (s.status !== auditConst.stage.status.checked) await this.checkStageGatherData(s, true);
+                if (s.status !== auditConst.stage.status.checked) await this.checkStageGatherData(s, force);
                 s.tp = this.ctx.helper.sum([s.contract_tp, s.qc_tp, s.pc_tp]);
                 s.pre_tp = this.ctx.helper.add(s.pre_contract_tp, s.pre_qc_tp);
                 s.end_tp = this.ctx.helper.add(s.pre_tp, s.tp);

+ 4 - 4
app/service/stage_audit.js

@@ -574,10 +574,10 @@ module.exports = app => {
                                 await this.ctx.service.stageTempLand.addInitialStageData(ns, this.ctx.stage, transaction);
                             }
                             const preStageTp = {
-                                pre_contract_tp: this.ctx.helper.sum([this.ctx.stage.pre_contract_tp, stageTp.contract_tp, stageTp.contract_pc_tp]),
-                                pre_qc_tp: this.ctx.helper.sum([this.ctx.stage.pre_qc_tp, stageTp.qc_tp, stageTp.qc_pc_tp]),
-                                pre_positive_qc_tp: this.ctx.helper.sum([this.ctx.stage.pre_positive_qc_tp, stageTp.positive_qc_tp, stageTp.positive_qc_pc_tp]),
-                                pre_negative_qc_tp: this.ctx.helper.sum([this.ctx.stage.pre_negative_qc_tp, stageTp.negative_qc_tp, stageTp.negative_qc_pc_tp]),
+                                pre_contract_tp: this.ctx.helper.sum([this.ctx.stage.pre_contract_tp, stageTp.contract_tp, this.ctx.stage.contract_pc_tp]),
+                                pre_qc_tp: this.ctx.helper.sum([this.ctx.stage.pre_qc_tp, stageTp.qc_tp, this.ctx.stage.qc_pc_tp]),
+                                pre_positive_qc_tp: this.ctx.helper.sum([this.ctx.stage.pre_positive_qc_tp, stageTp.positive_qc_tp, this.ctx.stage.positive_qc_pc_tp]),
+                                pre_negative_qc_tp: this.ctx.helper.sum([this.ctx.stage.pre_negative_qc_tp, stageTp.negative_qc_tp, this.ctx.stage.negative_qc_pc_tp]),
                                 pre_yf_tp: this.ctx.helper.add(this.ctx.stage.pre_yf_tp, stageTp.yf_tp),
                                 pre_sf_tp: this.ctx.helper.add(this.ctx.stage.pre_sf_tp, stageTp.sf_tp),
                             };