瀏覽代碼

缓存增加容错

MaiXinRong 2 年之前
父節點
當前提交
b944b3ae9b
共有 2 個文件被更改,包括 10 次插入10 次删除
  1. 2 2
      app/service/stage_audit.js
  2. 8 8
      app/service/tender_cache.js

+ 2 - 2
app/service/stage_audit.js

@@ -78,7 +78,7 @@ module.exports = app => {
 
         async getLastestAuditor(stageId, times, status) {
             const sql =
-                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`,' +
+                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.audit_type, la.audit_order,' +
                 '    la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
                 '    FROM ' + this.tableName + ' AS la' +
                 '    Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`aid` = pa.`id`' +
@@ -90,7 +90,7 @@ module.exports = app => {
 
         async getLastestAuditors(stageId, times, status) {
             const sql =
-                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`,' +
+                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.audit_type, la.audit_order,' +
                 '    la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
                 '    FROM ' + this.tableName + ' AS la' +
                 '    Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`aid` = pa.`id`' +

+ 8 - 8
app/service/tender_cache.js

@@ -221,7 +221,7 @@ module.exports = app => {
                 data.stage_flow_pre_uid = preAuditorIds.join(',');
                 const info = await this.ctx.service.projectAccount.getAccountCacheDatas(preAuditorIds,
                     { order: stage.order, status: preAuditors[0].status, audit_type:preAuditors[0].audit_type, audit_order: preAuditors[0].audit_order, time: new Date() });
-                data.stage_flow_pre_info = JSON.stringify(info);
+                data.stage_flow_pre_info = info.length > 0 ? JSON.stringify(info) : '';
             } else {
                 data.stage_flow_pre_uid = orgCache.stage_flow_cur_uid;
                 data.stage_flow_pre_info = orgCache.stage_flow_cur_info;
@@ -232,7 +232,7 @@ module.exports = app => {
                 const auditorIds = auditors.map(x => { return x.aid; });
                 data.stage_flow_cur_uid = auditorIds.join(',');
                 const info = await this.ctx.service.projectAccount.getAccountCacheDatas(auditorIds, { order: stage.order, audit_type: auditors[0].audit_type, status, audit_order: auditors[0].audit_order });
-                data.stage_flow_cur_info = JSON.stringify(info);
+                data.stage_flow_cur_info = info.length > 0 ? JSON.stringify(info) : '';
             }
             if (status === auditConst.stage.status.checked && (!auditors || auditors.length === 0)) data.stage_complete_count = stage.order;
             data.stage_flow_cur_tp = JSON.stringify(tp);
@@ -368,10 +368,10 @@ module.exports = app => {
                         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 {
+                        data.stage_flow_pre_info = preAuditors.length > 0 ? 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,10 +393,10 @@ module.exports = app => {
                     lastStage.curOrder = preAuditors[0].order;
                     await this._calcTp(lastStage, tp);
                     data.stage_flow_pre_uid = preAuditorIds.join(',');
-                    data.stage_flow_pre_info = JSON.stringify(preAuditors.map(preAuditor => { return {
+                    data.stage_flow_pre_info = preAuditors.length > 0 ? JSON.stringify(preAuditors.map(preAuditor => { return {
                         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);
                     data.stage_flow_pre_tp = JSON.stringify(tp);
                 } else if (lastStage.status === auditConst.stage.status.checkNo) {
@@ -410,10 +410,10 @@ module.exports = app => {
                     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 {
+                    data.stage_flow_pre_info = preAuditors.length > 0 ? JSON.stringify(preAuditors.map(preAuditor => { return {
                         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; });
                     if (his) {
                         tp.contract_tp = his.contract_tp;