瀏覽代碼

归档报表,写入businessType

MaiXinRong 1 年之前
父節點
當前提交
89253d7ee2
共有 5 個文件被更改,包括 70 次插入21 次删除
  1. 37 0
      app/const/rpt_archive.js
  2. 3 0
      app/service/rpt_archive.js
  3. 3 0
      app/service/rpt_archive_encryption.js
  4. 21 21
      db_script/depart_table.js
  5. 6 0
      sql/update.sql

+ 37 - 0
app/const/rpt_archive.js

@@ -0,0 +1,37 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+const BusinessType = [
+    { stageId: -100, type: 'payment_safe'},
+    { stageId: -200, type: 'budget'},
+    { stageId: -300, type: 'change'},
+    { stageId: -301, type: 'change_plan'},
+    { stageId: -302, type: 'change_project'},
+    { stageId: -303, type: 'change_apply'},
+];
+const getBusinessType = function(stageId) {
+    const sid = parseInt(stageId);
+    if (sid > 0) return 'stage';
+    const bType = BusinessType.find(x => { return x.stageId === sid; });
+    return bType ? bType.type : 'other';
+};
+// { payment_safe: -100, budget: -200, change: -300, ... }
+const BusinessStageId = (function(businessType) {
+    const result = {};
+    for (const bt of businessType) {
+        result[bt.type] = bt.stageId;
+    }
+})(BusinessType);
+
+module.exports = {
+    BusinessType,
+    getBusinessType,
+    BusinessStageId,
+};

+ 3 - 0
app/service/rpt_archive.js

@@ -5,6 +5,7 @@
  */
  */
 
 
 const BaseService = require('../base/base_service');
 const BaseService = require('../base/base_service');
+const rptArchiveConst = require('../const/rpt_archive');
 
 
 module.exports = app => {
 module.exports = app => {
 
 
@@ -82,6 +83,7 @@ module.exports = app => {
                     stage_id,
                     stage_id,
                     business_id,
                     business_id,
                     tender_id,
                     tender_id,
+                    business_type: rptArchiveConst.getBusinessType(stage_id),
                     content: JSON.stringify(archiveArr),
                     content: JSON.stringify(archiveArr),
                 };
                 };
                 // console.log(data);
                 // console.log(data);
@@ -105,6 +107,7 @@ module.exports = app => {
                     stage_id,
                     stage_id,
                     business_id,
                     business_id,
                     tender_id,
                     tender_id,
+                    business_type: rptArchiveConst.getBusinessType(stage_id),
                     content: JSON.stringify(archiveArr),
                     content: JSON.stringify(archiveArr),
                 };
                 };
                 // console.log(data);
                 // console.log(data);

+ 3 - 0
app/service/rpt_archive_encryption.js

@@ -5,6 +5,7 @@
  */
  */
 
 
 const BaseService = require('../base/base_service');
 const BaseService = require('../base/base_service');
+const rptArchiveConst = require('../const/rpt_archive');
 
 
 module.exports = app => {
 module.exports = app => {
 
 
@@ -82,6 +83,7 @@ module.exports = app => {
                     stage_id,
                     stage_id,
                     business_id,
                     business_id,
                     tender_id,
                     tender_id,
+                    business_type: rptArchiveConst.getBusinessType(stage_id),
                     content: JSON.stringify(archiveArr),
                     content: JSON.stringify(archiveArr),
                 };
                 };
                 // console.log(data);
                 // console.log(data);
@@ -105,6 +107,7 @@ module.exports = app => {
                     stage_id,
                     stage_id,
                     business_id,
                     business_id,
                     tender_id,
                     tender_id,
+                    business_type: rptArchiveConst.getBusinessType(stage_id),
                     content: JSON.stringify(archiveArr),
                     content: JSON.stringify(archiveArr),
                 };
                 };
                 // console.log(data);
                 // console.log(data);

+ 21 - 21
db_script/depart_table.js

@@ -31,27 +31,27 @@ getArrDepartSql(posTables, posDepartKey, orgPosDepart, tableDepart);
 
 
 BaseUtil.saveBufferFile(sqlArr.join('\n'), BaseUtil.getFileName('depart_table.sql'));
 BaseUtil.saveBufferFile(sqlArr.join('\n'), BaseUtil.getFileName('depart_table.sql'));
 
 
-// Select Sum(amount) FROM (
-//     Select Count(*) As amount From zh_settle_bills_bak_0
-//     UNION ALL
-//     Select Count(*) As amount From zh_settle_bills_bak_1
-//     UNION ALL
-//     Select Count(*) As amount From zh_settle_bills_bak_2
-//     UNION ALL
-//     Select Count(*) As amount From zh_settle_bills_bak_3
-//     UNION ALL
-//     Select Count(*) As amount From zh_settle_bills_bak_4
-//     UNION ALL
-//     Select Count(*) As amount From zh_settle_bills_bak_5
-//     UNION ALL
-//     Select Count(*) As amount From zh_settle_bills_bak_6
-//     UNION ALL
-//     Select Count(*) As amount From zh_settle_bills_bak_7
-//     UNION ALL
-//     Select Count(*) As amount From zh_settle_bills_bak_8
-//     UNION ALL
-//     Select Count(*) As amount From zh_settle_bills_bak_9
-// ) As temp;
+Select Sum(amount) FROM (
+    Select Count(*) As amount From zh_settle_bills_bak_0
+    UNION ALL
+    Select Count(*) As amount From zh_settle_bills_bak_1
+    UNION ALL
+    Select Count(*) As amount From zh_settle_bills_bak_2
+    UNION ALL
+    Select Count(*) As amount From zh_settle_bills_bak_3
+    UNION ALL
+    Select Count(*) As amount From zh_settle_bills_bak_4
+    UNION ALL
+    Select Count(*) As amount From zh_settle_bills_bak_5
+    UNION ALL
+    Select Count(*) As amount From zh_settle_bills_bak_6
+    UNION ALL
+    Select Count(*) As amount From zh_settle_bills_bak_7
+    UNION ALL
+    Select Count(*) As amount From zh_settle_bills_bak_8
+    UNION ALL
+    Select Count(*) As amount From zh_settle_bills_bak_9
+) As temp;
 
 
 // 数据量预估
 // 数据量预估
 // qa执行时间(分表100)
 // qa执行时间(分表100)

+ 6 - 0
sql/update.sql

@@ -46,3 +46,9 @@ ADD COLUMN `business_id` VARCHAR(45) NULL COMMENT '有其他业务情况,统
 ADD COLUMN `tender_id` INT(11) NULL AFTER `business_id`,
 ADD COLUMN `tender_id` INT(11) NULL AFTER `business_id`,
 ADD INDEX `PRJ_STG_BZ` (`prj_id` ASC, `stage_id` ASC, `business_id` ASC);
 ADD INDEX `PRJ_STG_BZ` (`prj_id` ASC, `stage_id` ASC, `business_id` ASC);
 ;
 ;
+
+ALTER TABLE `zh_rpt_archive_encryption`
+ADD COLUMN `business_type` varchar(30) NOT NULL DEFAULT 'stage' COMMENT 'stage: 变更令;budget: 动态决算,payment_safe: 支付审批-安全生产费,change: 变更令,change_plan: 变更方案,change_project: 变更立项,change_apply: 变更申请' AFTER `stage_id`;
+
+ALTER TABLE `zh_rpt_archive`
+ADD COLUMN `business_type` varchar(30) NOT NULL DEFAULT 'stage' COMMENT 'stage: 变更令;budget: 动态决算,payment_safe: 支付审批-安全生产费,change: 变更令,change_plan: 变更方案,change_project: 变更立项,change_apply: 变更申请' AFTER `stage_id`;