MaiXinRong 3 лет назад
Родитель
Сommit
058c76ece0
3 измененных файлов с 13 добавлено и 31 удалено
  1. 1 0
      app/base/base_service.js
  2. 0 23
      app/service/ledger_audit.js
  3. 12 8
      app/service/report_memory.js

+ 1 - 0
app/base/base_service.js

@@ -96,6 +96,7 @@ class BaseService extends Service {
      * @return {Array} - 返回数据
      */
     async getAllDataByCondition(condition) {
+        if (!condition.where) throw '缺少查询条件';
         return await this.db.select(this.tableName, condition);
     }
 

+ 0 - 23
app/service/ledger_audit.js

@@ -242,26 +242,6 @@ module.exports = app => {
         }
 
         /**
-         * 备份
-         * @param {Object} revise - 修订
-         * @returns {Promise<void>}
-         * @private
-         */
-        async backupLedgerHistoryFile() {
-            const timestamp = (new Date()).getTime();
-
-            const billsHis = `${this.ctx.session.sessionProject.id}/${this.ctx.tender.id}/bills${timestamp}.json`;
-            const bills = await this.ctx.service.ledger.getData(this.ctx.tender.id);
-            await this.ctx.app.hisOss.put(this.ctx.app.config.hisOssPath + billsHis, Buffer.from(JSON.stringify(bills), 'utf8'));
-
-            const posHis = `${this.ctx.session.sessionProject.id}/${this.ctx.tender.id}/pos${timestamp}.json`;
-            const pos = await this.ctx.service.pos.getAllDataByCondition({tid: this.ctx.tender.id});
-            await this.ctx.app.hisOss.put(this.ctx.app.config.hisOssPath + posHis, Buffer.from(JSON.stringify(pos), 'utf8'));
-
-            return [billsHis, posHis];
-        }
-
-        /**
          * 开始审批
          *
          * @param {Number} tenderId - 标段id
@@ -281,9 +261,6 @@ module.exports = app => {
             // 拷贝备份台账数据
             const his_id = await this.ctx.service.ledgerHistory.backupLedgerHistory(this.ctx.tender.data);
 
-            // 拷贝备份台账数据
-            const [billsHis, posHis] = await this.backupLedgerHistoryFile();
-
             const transaction = await this.db.beginTransaction();
             try {
                 await transaction.update(this.tableName, {

+ 12 - 8
app/service/report_memory.js

@@ -840,9 +840,10 @@ module.exports = app => {
 
         async _generateChangeApply(tid) {
             if (!!this.changeApplyData) return;
+            this.changeApplyData = {};
             const where = { tid };
             if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
-            this.changeApplyData.data = await this.ctx.service.changeApply.getAllDataByCondition({ where });
+            this.changeApplyData = { data: await this.ctx.service.changeApply.getAllDataByCondition({ where }) };
         }
 
         async _generateChangeApplyAudit() {
@@ -852,7 +853,7 @@ module.exports = app => {
             for (const c of this.changeApplyData.data) {
                 const changeAudit = await this.ctx.service.changeApplyAudit.getAllDataByCondition({ where: { caid: c.id, times: c.times }});
                 const changeAuditFilter = this.ctx.helper.filterLastestData(changeAudit, ['aid']);
-                this.changeData.audit.push(...changeAuditFilter);
+                this.changeApplyData.audit.push(...changeAuditFilter);
             }
         }
 
@@ -865,12 +866,6 @@ module.exports = app => {
             }
         }
 
-        async _generateChangeProject(tid) {
-            if (!!this.changeProjectData) return;
-            const where = { tid };
-            if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeProject.status.checked;
-            this.changeProjectData.data = await this.ctx.service.changeProject.getAllDataByCondition({ where });
-        }
 
         async getChangeApplyAuditData(tid, sid, fields) {
             try {
@@ -878,10 +873,18 @@ module.exports = app => {
                 await this._generateChangeApplyAudit();
                 return this.changeApplyData.audit;
             } catch (err) {
+                this.ctx.log(err);
                 return [];
             }
         }
 
+        async _generateChangeProject(tid) {
+            if (!!this.changeProjectData) return;
+            const where = { tid };
+            if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeProject.status.checked;
+            this.changeProjectData = { data: await this.ctx.service.changeProject.getAllDataByCondition({ where }) };
+        }
+
         async _generateChangeProjectAudit() {
             if (!!this.changeProjectData.audit) return;
 
@@ -898,6 +901,7 @@ module.exports = app => {
                 await this._generateChangeProject(tid);
                 return this.changeProjectData.data;
             } catch (err) {
+                this.ctx.log(err);
                 return [];
             }
         }