Jelajahi Sumber

hisOss相关

MaiXinRong 3 tahun lalu
induk
melakukan
958112b41f
3 mengubah file dengan 17 tambahan dan 10 penghapusan
  1. 10 1
      app/extend/context.js
  2. 1 3
      app/extend/helper.js
  3. 6 6
      app/service/ledger_history.js

+ 10 - 1
app/extend/context.js

@@ -66,5 +66,14 @@ module.exports = {
                 body: this.session.body,
             }));
         }
-    }
+    },
+
+    get hisOssPath() {
+        return this.app.config.hisOssPath;
+    },
+
+    get hisOss() {
+        return this.app.hisOss;
+    },
+
 };

+ 1 - 3
app/extend/helper.js

@@ -1474,11 +1474,9 @@ module.exports = {
     },
 
     async loadLedgerDataFromOss(url) {
-        console.time(url);
-        const File = await this.ctx.app.hisOss.get(this.ctx.app.config.hisOssPath + url);
+        const File = await this.ctx.hisOss.get(this.ctx.hisOssPath + url);
         if (File.res.status !== 200) return '获取修订台账有误';
         const result = JSON.parse(File.content);
-        console.timeEnd(url);
         return result;
     },
 };

+ 6 - 6
app/service/ledger_history.js

@@ -48,11 +48,11 @@ module.exports = app => {
 
             const billsHis = `${this.ctx.session.sessionProject.id}/${tender.id}/ledger/bills${timestamp}.json`;
             const bills = await this.ctx.service.ledger.getData(tender.id);
-            await this.ctx.oss.put(billsHis, Buffer.from(JSON.stringify(bills), 'utf8'));
+            await this.ctx.hisOss.put(this.ctx.hisOssPath + billsHis, Buffer.from(JSON.stringify(bills), 'utf8'));
 
             const posHis = `${this.ctx.session.sessionProject.id}/${tender.id}/ledger/pos${timestamp}.json`;
             const pos = await this.ctx.service.pos.getPosData({ tid: tender.id });
-            await this.ctx.oss.put(posHis, Buffer.from(JSON.stringify(pos), 'utf8'));
+            await this.ctx.hisOss.put(this.ctx.hisOssPath + posHis, Buffer.from(JSON.stringify(pos), 'utf8'));
 
             const result = await this.db.insert(this.tableName, {
                 pid: this.ctx.session.sessionProject.id, tid: tender.id,
@@ -75,11 +75,11 @@ module.exports = app => {
 
             const billsHis = `${this.ctx.session.sessionProject.id}/${revise.tid}/ledger/bills${timestamp}-r.json`;
             const bills = await this.ctx.service.reviseBills.getData(revise.tid);
-            await this.ctx.oss.put(billsHis, Buffer.from(JSON.stringify(bills), 'utf8'));
+            await this.ctx.hisOss.put(this.ctx.hisOssPath + billsHis, Buffer.from(JSON.stringify(bills), 'utf8'));
 
             const posHis = `${this.ctx.session.sessionProject.id}/${revise.tid}/ledger/pos${timestamp}-r.json`;
             const pos = await this.ctx.service.revisePos.getData(revise.tid);
-            await this.ctx.oss.put(posHis, Buffer.from(JSON.stringify(pos), 'utf8'));
+            await this.ctx.hisOss.put(this.ctx.hisOssPath + posHis, Buffer.from(JSON.stringify(pos), 'utf8'));
 
             const result = await this.db.insert(this.tableName, {
                 pid: this.ctx.session.sessionProject.id, tid: revise.tid,
@@ -108,12 +108,12 @@ module.exports = app => {
             const billsHis = `${this.ctx.session.sessionProject.id}/${change.tid}/ledger/bills${timestamp}-c.json`;
             const bills = await this.ctx.service.ledger.getData(change.tid);
             if (newBillsNodes.length > 0) bills.push(...newBillsNodes);
-            await this.ctx.oss.put(billsHis, Buffer.from(JSON.stringify(bills), 'utf8'));
+            await this.ctx.hisOss.put(this.ctx.hisOssPath + billsHis, Buffer.from(JSON.stringify(bills), 'utf8'));
 
             const posHis = `${this.ctx.session.sessionProject.id}/${change.tid}/ledger/pos${timestamp}-c.json`;
             const pos = await this.ctx.service.pos.getPosData({ tid: change.tid });
             if (newPosNodes.length > 0) pos.push(...newPosNodes);
-            await this.ctx.oss.put(posHis, Buffer.from(JSON.stringify(pos), 'utf8'));
+            await this.ctx.hisOss.put(this.ctx.hisOssPath + posHis, Buffer.from(JSON.stringify(pos), 'utf8'));
 
             const result = await transaction.insert(this.tableName, {
                 pid: this.ctx.session.sessionProject.id, tid: change.tid,