Преглед изворни кода

期审批完成时,检查全部角色签名日期

MaiXinRong пре 1 година
родитељ
комит
1bc5a20451
3 измењених фајлова са 46 додато и 11 уклоњено
  1. 26 0
      app/service/role_rpt_rel.js
  2. 2 0
      app/service/stage_audit.js
  3. 18 11
      db_script/test_query.js

+ 26 - 0
app/service/role_rpt_rel.js

@@ -187,6 +187,32 @@ module.exports = app => {
             }
             return true;
         }
+
+        async checkSignDate(transaction, stage, curAudit, time) {
+            const rptRole = await this.getAllDataByCondition({ where: { sid: stage.id }});
+
+            const updateData = [];
+            for (const rc of rptRole) {
+                if (!rc.rel_content) continue;
+                let bChange = false;
+                const roleContent = JSON.parse(rc.rel_content);
+                for (const role of roleContent) {
+                    if (!role.sign_date) {
+                        if (role.acc_id === curAudit.aid) {
+                            role.sign_date = time;
+                        } else if (role.acc_id === stage.userId) {
+                            role.sign_date = stage.auditors[0].begin_time || time;
+                        } else {
+                            const audit = this.ctx.helper._.findLast(stage.auditors, x => { return x.aid === role.acc_id; });
+                            role.sign_date = audit ? audit.end_time || time : time;
+                        }
+                        bChange = true;
+                    }
+                }
+                if (bChange) updateData.push({ id: rc.id, rel_content: JSON.stringify(roleContent)});
+            }
+            if (updateData.length > 0) await transaction.updateRows(this.tableName, updateData);
+        }
     }
     return RoleRptRel;
 };

+ 2 - 0
app/service/stage_audit.js

@@ -554,6 +554,8 @@ module.exports = app => {
                             code: this.ctx.session.sessionProject.code,
                         };
                         await this.ctx.helper.sendWechat(users, smsTypeConst.const.JL, smsTypeConst.judge.result.toString(), wxConst.template.stage, wechatData);
+                        // 期审批完成,检查角色签名数据
+                        await this.ctx.service.roleRptRel.checkSignDate(transaction, this.ctx.stage, selfAudit, time);
                         // 审批通过 - 检查三方特殊推送
                         await this.ctx.service.specMsg.addStageMsg(transaction, pid, this.ctx.stage, pushOperate.stage.checked);
                     }

+ 18 - 11
db_script/test_query.js

@@ -12,7 +12,8 @@ const saveJSON = async function(obj, file) {
 
 const loadReportArchiveData = async function() {
     //const tid = 4417, sOrder = 2;
-    const tid = 3698, sOrder = 7;
+    // const tid = 3698, sOrder = 7;
+    const tid = 5161, sOrder = 8;
     const stage = await querySql('SELECT * FROM zh_stage where tid = ? and `order` = ?', [tid, sOrder]);
     const rptArchive = await querySql('SELECT * FROM zh_rpt_archive where stage_id = ?', [stage[0].id]);
     for (const ra of rptArchive) {
@@ -20,16 +21,22 @@ const loadReportArchiveData = async function() {
         console.log(BaseUtil.getFileName('rptArchive.json'));
         await saveJSON(ra, BaseUtil.getFileName('rptArchive.json'));
 
-        const roleContent = [];
-        for (const c of ra.content) {
-            console.log(c.rpt_id, stage[0].id);
-            const rptRole = await querySql('SELECT * FROM zh_role_rpt_rel WHERE sid = ? and rpt_id = ?', [stage[0].id, c.rpt_id]);
-            if (rptRole.length > 0) {
-                if (rptRole[0].rel_content) roleContent.push(JSON.stringify(rptRole[0].rel_content));
-            }
-        }
-        await saveJSON(roleContent, BaseUtil.getFileName('roleContent.json'));
+        // for (const c of ra.content) {
+        //     console.log(c.rpt_id, stage[0].id);
+        //     const rptRole = await querySql('SELECT * FROM zh_role_rpt_rel WHERE sid = ? and rpt_id = ?', [stage[0].id, c.rpt_id]);
+        //     if (rptRole.length > 0) {
+        //         if (rptRole[0].rel_content) roleContent.push(JSON.parse(rptRole[0].rel_content));
+        //     }
+        // }
+        // await saveJSON(roleContent, BaseUtil.getFileName('roleContent.json'));
+    }
+    const roleContent = [];
+    const rptRole = await querySql('SELECT * FROM zh_role_rpt_rel WHERE sid = ?', [stage[0].id]);
+    for (const rp of rptRole) {
+        if (rp.rel_content) roleContent.push(JSON.parse(rp.rel_content));
     }
+    await saveJSON(roleContent, BaseUtil.getFileName('roleContent.json'));
+
     const rptSign = await querySql('SELECT * FROM zh_rpt_archive_encryption where stage_id = ?', [stage[0].id]);
     for (const rs of rptSign) {
         rs.content = rs.content ? JSON.parse(rs.content) : [];
@@ -50,7 +57,7 @@ const findRole = async function() {
 
 const doCompleteTest = async function() {
     try {
-        // await loadReportArchiveData();
+        await loadReportArchiveData();
         // await findRole();
     } catch (err) {
         console.log(err);