Bläddra i källkod

报表,推送其他归档报表

MaiXinRong 1 år sedan
förälder
incheckning
62732ef89b
4 ändrade filer med 55 tillägg och 0 borttagningar
  1. 3 0
      app/const/spec_3f.js
  2. 19 0
      app/controller/report_archive_controller.js
  3. 1 0
      app/router.js
  4. 32 0
      app/service/spec_msg.js

+ 3 - 0
app/const/spec_3f.js

@@ -30,6 +30,9 @@ const pushTiming = [
     { value:'change_project.flow', name: '变更立项-上报/审批' },
     { value:'change_project.checked', name: '变更立项-审批通过' },
     { value:'report.file', name: '报表-推送归档' },
+    { value:'report.change_file', name: '报表-变更令-同步档案系统' },
+    { value:'report.change_plan_file', name: '报表-变更方案-同步档案系统' },
+    { value:'report.change_apply_file', name: '报表-变更申请-同步档案系统' },
 ];
 
 const pushOperate = (function () {

+ 19 - 0
app/controller/report_archive_controller.js

@@ -882,6 +882,25 @@ module.exports = app => {
                 this.ctx.ajaxErrorBody(err, '操作失败');
             }
         }
+
+        async sendOtherFileMsg(ctx) {
+            try {
+                if (this.ctx.session.sessionUser.accountId !== ctx.tender.data.user_id) throw '您无权操作';
+
+                const data = JSON.parse(ctx.request.body.data);
+                const needFileMsg = await this.ctx.service.specMsg.tenderNeedMsg(this.ctx.session.sessionProject.id, this.ctx.tender.id, data.msgType);
+                if (!needFileMsg) throw '该标段暂不可进行该操作';
+
+                const waitingMsg = await this.ctx.service.specMsg.getDataByCondition({ tid: this.ctx.tender.id, timing: data.msgType, status: [0, 1] });
+                if (waitingMsg) throw '上一次归档完成,未执行完毕,请稍后再试';
+
+                await this.ctx.service.specMsg.addOtherReportMsg(null, this.ctx.session.sessionProject.id, this.ctx.tender.data, data.id, data.msgType);
+                ctx.body = { err: 0, msg: '提交成功,稍后将同步至档案系统', data: null };
+            } catch (err) {
+                this.ctx.log(err);
+                this.ctx.ajaxErrorBody(err, '操作失败');
+            }
+        }
     }
     return ReportArchiveController;
 };

+ 1 - 0
app/router.js

@@ -498,6 +498,7 @@ module.exports = app => {
     app.post('/tender/report_api/removeArchiveEncryption', sessionAuth, 'reportArchiveController.removeReportArchiveEncryption');
     app.post('/tender/:id/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.sendFileMsg');
     app.post('/tender/:id/measure/stage/:order/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, stageCheck, 'reportArchiveController.sendFileMsg');
+    app.post('/tender/:id/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.sendOtherFileMsg');
 
     // 电子签名
     app.get('/tender/:id/signReport', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.signReport');

+ 32 - 0
app/service/spec_msg.js

@@ -7,6 +7,7 @@
  * @date
  * @version
  */
+const pushOperate = require('../const/spec_3f').pushOperate;
 
 module.exports = app => {
     class SpecPull extends app.BaseService {
@@ -110,6 +111,37 @@ module.exports = app => {
                 await this.db.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing, extra_info: JSON.stringify(subInfo || {}) });
             }
         }
+
+        async _getOtherMsgBaseData(id, timing) {
+            switch(timing) {
+                case pushOperate.report.change_file:
+                    const change = await this.ctx.service.change.getAllDataByCondition({ where: { cid: id } });
+                    return change.map(x => { return { cid: x.cid } });
+                case pushOperate.report.change_plan_file:
+                    const changePlan = await this.ctx.service.changePlan.getAllDataByCondition({ where: { id } });
+                    return changePlan.map(x => { return { c_plan_id: x.id } });
+                case pushOperate.report.change_apply_file:
+                    const changeApply = await this.ctx.service.changeApply.getAllDataByCondition({ where: { id } });
+                    return changeApply.map(x => { return { c_apply_id: x.id } });
+                default:
+                    return [];
+            }
+        }
+
+        async addOtherReportMsg(transaction, pid, tender, id, timing, subInfo) {
+            const needMsg = await this.tenderNeedMsg(pid, tender.id, timing);
+            if (!needMsg) return;
+
+            const data = await this._getOtherMsgBaseData(id, timing);
+            const insertMsg = data.map(x => {
+                return { pid, tid: tender.id, timing, extra_info: JSON.stringify(subInfo || {}), ...x };
+            });
+            if (transaction) {
+                await transaction.insert(this.tableName, insertMsg);
+            } else {
+                await this.db.insert(this.tableName, insertMsg);
+            }
+        }
     }
 
     return SpecPull;