Parcourir la source

刷新缓存方法调整

MaiXinRong il y a 1 an
Parent
commit
22b324cea5
2 fichiers modifiés avec 16 ajouts et 11 suppressions
  1. 3 1
      app/service/stage_audit.js
  2. 13 10
      app/service/tender_cache.js

+ 3 - 1
app/service/stage_audit.js

@@ -97,7 +97,9 @@ module.exports = app => {
                 '  WHERE la.`sid` = ? and la.`status` = ? and la.`times` = ?' +
                 '  ORDER BY `order` DESC';
             const sqlParam = [stageId, status, times ? times: 1];
-            return await this.db.query(sql, sqlParam);
+            const result = await this.db.query(sql, sqlParam);
+            if (result.length === 0) return [];
+            return result.filter(x => { x.order === result[result.length - 1].order });
         }
 
         /**

+ 13 - 10
app/service/tender_cache.js

@@ -365,12 +365,13 @@ module.exports = app => {
                 const preStage = lastStage.order > 1 ? await this.ctx.service.stage.getDataByCondition({ tid: lastStage.tid, order: lastStage.order - 1}) : null;
                 if (lastStage.status === auditConst.stage.status.uncheck) {
                     if (preStage) {
-                        const preAuditor = await this.ctx.service.stageAudit.getLastestAuditor(preStage.id, preStage.times, preStage.status);
-                        data.stage_flow_pre_uid = preAuditor.aid;
-                        data.stage_flow_pre_info = JSON.stringify({
-                            order: preAuditor.order, status: preAuditor.status, time: preAuditor.end_time,
+                        const preAuditors = await this.ctx.service.stageAudit.getLastestAuditors(preStage.id, preStage.times, preStage.status);
+                        const preAuditorIds = preAuditors.map(x => { return x.aid; });
+                        data.stage_flow_pre_uid = preAuditorIds.join(',');
+                        data.stage_flow_pre_info = JSON.stringify(preAuditors.map(preAuditor => { return {
+                            order: preAuditor.order, audit_type: preAuditor.audit_type, audit_order: preAuditor.order, status: preAuditor.status, time: preAuditor.end_time,
                             name: preAuditor.name, company: preAuditor.company, role: preAuditor.role, mobile: preAuditor.mobile, telephone: preAuditor.telephone,
-                        });
+                        }}));
                         data.stage_flow_pre_tp = JSON.stringify({
                             contract_tp: preStage.contract_tp || 0, qc_tp: preStage.qc_tp || 0, contract_pc_tp: preStage.contract_pc_tp, qc_pc_tp: preStage.qc_pc_tp, pc_tp: preStage.pc_tp,
                             positive_qc_tp: preStage.positive_qc_tp, positive_qc_pc_tp: preStage.positive_qc_pc_tp, negative_qc_tp: preStage.negative_qc_pc_tp, negative_qc_pc_tp: preStage.negative_qc_pc_tp,
@@ -393,7 +394,7 @@ module.exports = app => {
                     await this._calcTp(lastStage, tp);
                     data.stage_flow_pre_uid = preAuditorIds.join(',');
                     data.stage_flow_pre_info = JSON.stringify(preAuditors.map(preAuditor => { return {
-                        order: lastStage.order, audit_order: preAuditor.order, status: preAuditor.status, time: preAuditor.end_time,
+                        order: lastStage.order, audit_type: preAuditor.audit_type, audit_order: preAuditor.order, status: preAuditor.status, time: preAuditor.end_time,
                         name: preAuditor.name, company: preAuditor.company, role: preAuditor.role, mobile: preAuditor.mobile, telephone: preAuditor.telephone,
                     }}));
                     data.stage_flow_cur_tp = JSON.stringify(tp);
@@ -402,14 +403,15 @@ module.exports = app => {
                     lastStage.curOrder = 0;
                     await this._calcTp(lastStage, tp);
                     data.stage_flow_cur_uid = lastStage.user_id;
-                    const curInfo = await this.ctx.service.projectAccount.getAccountCacheData(lastStage.user_id, { order: lastStage.order, audit_order: 0, audit_type: auditConst.auditType.key.common, status: auditConst.stage.status.uncheck });
+                    const curInfo = await this.ctx.service.projectAccount.getAccountCacheData(lastStage.user_id,
+                        { order: lastStage.order, audit_order: 0, audit_type: auditConst.auditType.key.common, status: auditConst.stage.status.uncheck });
                     data.stage_flow_cur_info = JSON.stringify(curInfo);
                     data.stage_flow_cur_tp = JSON.stringify(tp);
                     const preAuditors = await this.ctx.service.stageAudit.getLastestAuditors(lastStage.id, lastStage.times - 1, lastStage.status);
                     const preAuditorIds = preAuditors.map(x => { return x.aid; });
                     data.stage_flow_pre_uid = preAuditorIds.join(',');
                     data.stage_flow_pre_info = JSON.stringify(preAuditors.map(preAuditor => { return {
-                        order: lastStage.order, audit_order: preAuditor.order, status: preAuditor.status, time: preAuditor.end_time,
+                        order: lastStage.order, audit_type: preAuditor.audit_type, audit_order: preAuditor.order, status: preAuditor.status, time: preAuditor.end_time,
                         name: preAuditor.name, company: preAuditor.company, role: preAuditor.role, mobile: preAuditor.mobile, telephone: preAuditor.telephone,
                     }}));
                     const his = lastStage.tp_history.find(x => { return x.times === preAuditors[0].times && x.order === preAuditors[0].order; });
@@ -438,12 +440,13 @@ module.exports = app => {
                         const preAuditorIds = preAuditors.map(x => { return x.aid; });
                         data.stage_flow_pre_uid = preAuditorIds.join(',');
                         data.stage_flow_pre_info = JSON.stringify(preAuditors.map(preAuditor => { return {
-                            order: lastStage.order, audit_order: preAuditor.audit_order, status: preAuditor.status, time: preAuditor.end_time,
+                            order: lastStage.order, audit_type: preAuditor.audit_type, audit_order: preAuditor.audit_order, status: preAuditor.status, time: preAuditor.end_time,
                             name: preAuditor.name, company: preAuditor.company, role: preAuditor.role, mobile: preAuditor.mobile, telephone: preAuditor.telephone,
                         }}));
                     } else {
                         data.stage_flow_pre_uid = lastStage.user_id;
-                        const preInfo = await this.ctx.service.projectAccount.getAccountCacheData(lastStage.user_id, { order: 0, status: auditConst.stage.status.uncheck, time: curAuditors[0].begin_time });
+                        const preInfo = await this.ctx.service.projectAccount.getAccountCacheData(lastStage.user_id,
+                            { order: lastStage.order, audit_order: 0, audit_type: 1, status: auditConst.stage.status.uncheck, time: curAuditors[0].begin_time });
                         data.stage_flow_pre_info = JSON.stringify(preInfo);
                     }
                     const his = preAuditors.length > 0