Преглед на файлове

修复中间计量数据撤回bug

laiguoran преди 2 години
родител
ревизия
f18be40e50
променени са 2 файла, в които са добавени 24 реда и са изтрити 2 реда
  1. 4 2
      app/service/stage_audit.js
  2. 20 0
      app/service/stage_detail.js

+ 4 - 2
app/service/stage_audit.js

@@ -1045,6 +1045,7 @@ module.exports = app => {
                     // 先覆盖再删除
                     await this.ctx.service.stageBills.updateAuditStageBills(stageId, this.ctx.stage.user_id, this.ctx.stage.times, 0, curAudit.aid, this.ctx.stage.times, 1, transaction);
                     await this.ctx.service.stagePos.updateAuditStagePos(stageId, this.ctx.stage.user_id, this.ctx.stage.times, 0, curAudit.aid, this.ctx.stage.times, 1, transaction);
+                    await this.ctx.service.stageDetail.updateAuditStageDetail(stageId, this.ctx.stage.times, 0, this.ctx.stage.times, 1, transaction);
                 } else if (this.ctx.stage.cancancel === 2) {
                     const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
                     // 整理当前流程审核人状态更新
@@ -1124,7 +1125,7 @@ module.exports = app => {
                     // 先覆盖再删除
                     await this.ctx.service.stageBills.updateAuditStageBills(stageId, preAudit.aid, this.ctx.stage.times, curAudit.order + 1, curAudit.aid, this.ctx.stage.times, curAudit.order, transaction);
                     await this.ctx.service.stagePos.updateAuditStagePos(stageId, preAudit.aid, this.ctx.stage.times, curAudit.order + 1, curAudit.aid, this.ctx.stage.times, curAudit.order, transaction);
-
+                    await this.ctx.service.stageDetail.updateAuditStageDetail(stageId, this.ctx.stage.times, curAudit.order + 1, this.ctx.stage.times, curAudit.order, transaction);
                     // 锁定本人数据,保留锁定数据相关确认状态
                     // await this.ctx.service.stageAuditAss.lockConfirm4CheckNoPre(this.ctx.stage, curAudit.aid, preAudit.aid, transaction);
                 } else if (this.ctx.stage.cancancel === 3) {
@@ -1207,7 +1208,7 @@ module.exports = app => {
                     // 先覆盖再删除
                     await this.ctx.service.stageBills.updateAuditStageBills(stageId, preAudit.aid, this.ctx.stage.times, curAudit.order + 1, curAudit.aid, this.ctx.stage.times, curAudit.order, transaction);
                     await this.ctx.service.stagePos.updateAuditStagePos(stageId, preAudit.aid, this.ctx.stage.times, curAudit.order + 1, curAudit.aid, this.ctx.stage.times, curAudit.order, transaction);
-
+                    await this.ctx.service.stageDetail.updateAuditStageDetail(stageId, this.ctx.stage.times, curAudit.order + 1, this.ctx.stage.times, curAudit.order, transaction);
                     // 锁定本人数据,保留锁定数据相关确认状态
                     // await this.ctx.service.stageAuditAss.lockConfirm4CheckNoPre(this.ctx.stage, curAudit.aid, preAudit.aid, transaction);
                 } else if (this.ctx.stage.cancancel === 4) {
@@ -1287,6 +1288,7 @@ module.exports = app => {
                     // 先覆盖再删除
                     await this.ctx.service.stageBills.updateAuditStageBills(stageId, curAudit.aid, this.ctx.stage.times - 1, curAudit.order + 2, this.ctx.stage.user_id, this.ctx.stage.times, 0, transaction);
                     await this.ctx.service.stagePos.updateAuditStagePos(stageId, curAudit.aid, this.ctx.stage.times - 1, curAudit.order + 2, this.ctx.stage.user_id, this.ctx.stage.times, 0, transaction);
+                    await this.ctx.service.stageDetail.updateAuditStageDetail(stageId, this.ctx.stage.times - 1, curAudit.order + 2, this.ctx.stage.times, 0, transaction);
                 }
                 // 上报/审批 - 检查三方特殊推送
                 await this.ctx.service.specMsg.addStageMsg(transaction, this.ctx.session.sessionProject.id, this.ctx.stage, pushOperate.stage.flow);

+ 20 - 0
app/service/stage_detail.js

@@ -82,6 +82,26 @@ module.exports = app => {
             }
         }
 
+        async updateAuditStageDetail(sid, newTimes, newOrder, oldTimes, oldOrder, transaction) {
+            const oldSBLists = await this.getAllDataByCondition({ where: { sid, times: oldTimes, order: oldOrder } });
+            const newSBLists = await this.getAllDataByCondition({ where: { sid, times: newTimes, order: newOrder } });
+            const delidList = [];
+            for (const o of oldSBLists) {
+                const newSBInfo = this._.find(newSBLists, { lid: o.lid });
+                if (newSBInfo) {
+                    // 删除
+                    delidList.push(newSBInfo.id);
+                }
+            }
+            if (delidList.length > 0) await transaction.delete(this.tableName, { id: delidList });
+            if (oldSBLists.length > 0) {
+                await transaction.update(this.tableName, {
+                    times: newTimes,
+                    order: newOrder,
+                }, { where: { id: this._.map(oldSBLists, 'id') } });
+            }
+        }
+
         /**
          * 获取 中间计量 用户最新输入数据
          * @param {Number} tid - 标段id