Browse Source

优化计量台账,本期数据读取相关

MaiXinRong 3 years ago
parent
commit
7ea2c482d7

+ 1 - 1
app/controller/measure_controller.js

@@ -220,7 +220,7 @@ module.exports = app => {
                     for (const order of data.stages) {
                         const data = { order, bills: [], pos: [] };
                         const stage = await this.ctx.service.stage.getDataByCondition({ tid: ctx.tender.id, order });
-                        data.bills = await ctx.service.stageBills.getLastestStageData(ctx.tender.id, stage.id);
+                        data.bills = await ctx.service.stageBills.getLastestStageData2(ctx.tender.id, stage.id);
                         data.pos = await ctx.service.stagePos.getLastestStageData2(ctx.tender.id, stage.id);
                         result.stages.push(data);
                     }

+ 2 - 2
app/controller/revise_controller.js

@@ -955,10 +955,10 @@ module.exports = app => {
         async _loadLastStageBillsData(ctx) {
             let curStageData;
             if (ctx.lastStage.readOnly) {
-                curStageData = await ctx.service.stageBills.getAuditorStageData(ctx.tender.id,
+                curStageData = await ctx.service.stageBills.getAuditorStageData2(ctx.tender.id,
                     ctx.lastStage.id, ctx.lastStage.curTimes, ctx.lastStage.curOrder);
             } else {
-                curStageData = await ctx.service.stageBills.getLastestStageData(ctx.tender.id, ctx.lastStage.id);
+                curStageData = await ctx.service.stageBills.getLastestStageData2(ctx.tender.id, ctx.lastStage.id);
             }
             const preStageData = ctx.lastStage.order > 1
                 ? await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, ctx.lastStage.order - 1)

+ 3 - 3
app/controller/schedule_controller.js

@@ -247,7 +247,7 @@ module.exports = app => {
                     });
                     // let preStageData;
                     // 当前操作人查看最新数据,其他人查看历史数据
-                    const curStageData = await ctx.service.stageBills.getLastestStageData(ctx.tender.id, stageInfo.id);
+                    const curStageData = await ctx.service.stageBills.getLastestStageData2(ctx.tender.id, stageInfo.id);
                     // // 查询截止上期数据
                     // if (stageInfo.order > 1) {
                     //     preStageData = await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, stageInfo.order - 1);
@@ -277,7 +277,7 @@ module.exports = app => {
             });
             let preStageData;
             // 当前操作人查看最新数据,其他人查看历史数据
-            const curStageData = await ctx.service.stageBills.getLastestStageData(ctx.tender.id, stageInfo.id);
+            const curStageData = await ctx.service.stageBills.getLastestStageData2(ctx.tender.id, stageInfo.id);
             // 查询截止上期数据
             if (stageInfo.order > 1) {
                 preStageData = await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, stageInfo.order - 1);
@@ -307,7 +307,7 @@ module.exports = app => {
                     tid: ctx.tender.id,
                     order: scheduleStage[0].order,
                 });
-                const finalStageData = await ctx.service.stageBills.getLastestStageData(ctx.tender.id, finalStageInfo.id);
+                const finalStageData = await ctx.service.stageBills.getLastestStageData2(ctx.tender.id, finalStageInfo.id);
                 if (finalStageInfo.order > 1) {
                     prefinalStageData = await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, finalStageInfo.order - 1);
                 } else {

+ 1 - 1
app/controller/spss_controller.js

@@ -89,7 +89,7 @@ module.exports = app => {
         async _getStageData(tid, sorder) {
             const data = await this._getTzData(tid, true);
             const stage = await this._checkStage(tid, sorder);
-            const bills = await this.ctx.service.stageBills.getAuditorStageData(tid, stage.id, stage.curTimes, stage.curOrder);
+            const bills = await this.ctx.service.stageBills.getAuditorStageData2(tid, stage.id, stage.curTimes, stage.curOrder);
             const pos = await this.ctx.service.stagePos.getAuditorStageData(tid, stage.id, stage.curTimes, stage.curOrder);
             data.stage = {
                 sid: stage.id, sorder: stage.order, curTimes: stage.curTimes, curOrder: stage.curOrder,

+ 1 - 1
app/controller/stage_controller.js

@@ -1257,7 +1257,7 @@ module.exports = app => {
                     const data = { order, bills: [], pos: [] };
                     const compareTimes = ctx.stage.status === auditConst.status.checkNo && !ctx.stage.readOnly
                         ? ctx.stage.curTimes - 1 : ctx.stage.curTimes;
-                    data.bills = await ctx.service.stageBills.getAuditorStageData(ctx.tender.id, ctx.stage.id, compareTimes, order);
+                    data.bills = await ctx.service.stageBills.getAuditorStageData2(ctx.tender.id, ctx.stage.id, compareTimes, order);
                     data.pos = await ctx.service.stagePos.getAuditorStageData(ctx.tender.id, ctx.stage.id, compareTimes, order);
                     result.roles.push(data);
                 }

+ 2 - 2
app/lib/rptCustomData.js

@@ -234,7 +234,7 @@ class jhHelper {
         // 加载截止上期/本期
         let billsData = await this.ctx.service.ledger.getData(tender.id);
         if (filterGcl) billsData = billsData.filter(x => { return x.b_code && x.is_leaf });
-        const curStage = await this.ctx.service.stageBills.getLastestStageData(tender.id, stage.id);
+        const curStage = await this.ctx.service.stageBills.getLastestStageData2(tender.id, stage.id);
         const preStage = stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(tender, stage.order - 1) : [];
         const loadData = [
             { data: curStage, fields: this.billsQueryField, prefix: '', relaId: 'lid' },
@@ -243,7 +243,7 @@ class jhHelper {
         for (const dc of gsDefine.defaultCompare) {
             const auditor = auditors[dc];
             if (!auditor) continue;
-            const auditorStage = await this.ctx.service.stageBills.getAuditorStageData(tender.id, stage.id, auditor.times, auditor.order);
+            const auditorStage = await this.ctx.service.stageBills.getAuditorStageData2(tender.id, stage.id, auditor.times, auditor.order);
             loadData.push({ data: auditorStage, fields: this.billsQueryField, prefix: `r${dc}_`, relaId: 'lid' });
         }
         helper.assignRelaData(billsData, loadData);

+ 2 - 2
app/lib/stage_im.js

@@ -69,13 +69,13 @@ class StageIm {
     async _loadMainData() {
         const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
         if (this.ctx.stage.readOnly) {
-            const curStage = await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id,
+            const curStage = await this.ctx.service.stageBills.getAuditorStageData2(this.ctx.tender.id,
                 this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder);
             this.ctx.helper.assignRelaData(billsData, [
                 { data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
             ]);
         } else {
-            const curStage = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id);
+            const curStage = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
             this.ctx.helper.assignRelaData(billsData, [
                 { data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
             ]);

+ 1 - 1
app/lib/sum_load.js

@@ -486,7 +486,7 @@ class sumLoad {
             const billsData = await this.ctx.service.ledger.getData(tender.tid);
             const stage = await this.ctx.service.stage.getDataByCondition({tid: tender.tid, order: tender.stage});
             if (!stage) throw '选择的期不存在';
-            const curStageData = await this.ctx.service.stageBills.getLastestStageData(tender.tid, stage.id);
+            const curStageData = await this.ctx.service.stageBills.getLastestStageData2(tender.tid, stage.id);
             const curStageChange = await this.ctx.service.stageChangeFinal.getSumLoadFinalData(stage.id);
             this._loadCurStageAndChange(billsData, curStageData, curStageChange);
             const billsTree = new Ledger.billsTree(this.ctx, {

+ 2 - 2
app/lib/tender_info.js

@@ -42,8 +42,8 @@ class TenderInfo {
         const billsData = await this.ctx.service.ledger.getData(this.tender.id);
         if (this.stage) {
             const curStage = this.stage.readOnly
-                ? await this.ctx.service.stageBills.getAuditorStageData(this.tender.id, this.stage.id, this.stage.curTimes, this.stage.curOrder)
-                : await this.ctx.service.stageBills.getLastestStageData(this.tender.id, this.stage.id);
+                ? await this.ctx.service.stageBills.getAuditorStageData2(this.tender.id, this.stage.id, this.stage.curTimes, this.stage.curOrder)
+                : await this.ctx.service.stageBills.getLastestStageData2(this.tender.id, this.stage.id);
 
             const preStage = this.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(this.tender, this.stage.order - 1) : [];
             this.ctx.helper.assignRelaData(billsData, [

+ 1 - 1
app/service/report.js

@@ -62,7 +62,7 @@ module.exports = app => {
                             runnableKey.push(filter);
                             break;
                         case 'stage_bills':
-                            runnableRst.push(service.stageBills.getLastestStageData(params.tender_id, params.stage_id));
+                            runnableRst.push(service.stageBills.getLastestStageData2(params.tender_id, params.stage_id));
                             runnableKey.push(filter);
                             break;
                         case 'stage_bills_final':

+ 4 - 4
app/service/report_memory.js

@@ -374,13 +374,13 @@ module.exports = app => {
                 }
                 if (this._checkFieldsExist(fields, billsFields.stage)) {
                     if (this.ctx.stage.readOnly) {
-                        const curStage = await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id,
+                        const curStage = await this.ctx.service.stageBills.getAuditorStageData2(this.ctx.tender.id,
                             this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder);
                         this.ctx.helper.assignRelaData(billsData, [
                             {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid'}
                         ]);
                     } else {
-                        const curStage = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id);
+                        const curStage = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
                         this.ctx.helper.assignRelaData(billsData, [
                             {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid'}
                         ]);
@@ -999,8 +999,8 @@ module.exports = app => {
                     calcFields.push('s' + stage.order + '_');
 
                     const curStage = stage.readOnly
-                        ? await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id, stage.id, stage.curTimes, stage.curOrder)
-                        : await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, stage.id);
+                        ? await this.ctx.service.stageBills.getAuditorStageData2(this.ctx.tender.id, stage.id, stage.curTimes, stage.curOrder)
+                        : await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, stage.id);
                     this.ctx.helper.assignRelaData(billsData, [
                         {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp'], prefix: 's' + stage.order + '_', relaId: 'lid'}
                     ]);

+ 4 - 4
app/service/rpt_gather_memory.js

@@ -281,7 +281,7 @@ module.exports = app => {
             if (stage) {
                 await this.ctx.service.stage.doCheckStage(stage);
                 if (stage.readOnly) {
-                    const curStage = await this.ctx.service.stageBills.getAuditorStageData(tender.id,
+                    const curStage = await this.ctx.service.stageBills.getAuditorStageData2(tender.id,
                         stage.id, stage.curTimes, stage.curOrder);
                     this.ctx.helper.assignRelaData(billsData, [
                         {
@@ -292,7 +292,7 @@ module.exports = app => {
                         }
                     ]);
                 } else {
-                    const curStage = await this.ctx.service.stageBills.getLastestStageData(tender.id, stage.id);
+                    const curStage = await this.ctx.service.stageBills.getLastestStageData2(tender.id, stage.id);
                     this.ctx.helper.assignRelaData(billsData, [
                         {
                             data: curStage,
@@ -380,7 +380,7 @@ module.exports = app => {
             for (const stage of stages) {
                 await this.ctx.service.stage.doCheckStage(stage);
                 if (stage.readOnly) {
-                    const curStage = await this.ctx.service.stageBills.getAuditorStageData(tender.id,
+                    const curStage = await this.ctx.service.stageBills.getAuditorStageData2(tender.id,
                         stage.id, stage.curTimes, stage.curOrder);
                     sumAssignRelaData(billsIndexData, [{
                         data: curStage,
@@ -389,7 +389,7 @@ module.exports = app => {
                         relaId: 'lid'
                     }]);
                 } else {
-                    const curStage = await this.ctx.service.stageBills.getLastestStageData(tender.id, stage.id);
+                    const curStage = await this.ctx.service.stageBills.getLastestStageData2(tender.id, stage.id);
                     sumAssignRelaData(billsIndexData, [{
                         data: curStage,
                         fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'],

+ 2 - 2
app/service/rpt_stage_sum_memory.js

@@ -178,8 +178,8 @@ module.exports = app => {
                 defaultData[prefix + 'order'] = stage.order;
 
                 const curStage = stage.readOnly
-                    ? await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id, stage.id, stage.curTimes, stage.curOrder)
-                    : await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, stage.id);
+                    ? await this.ctx.service.stageBills.getAuditorStageData2(this.ctx.tender.id, stage.id, stage.curTimes, stage.curOrder)
+                    : await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, stage.id);
                 this.ctx.helper.assignRelaData(billsData, [
                     {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp'], prefix: prefix, relaId: 'lid', defaultData: defaultData}
                 ]);

+ 6 - 6
app/service/stage_bills.js

@@ -254,7 +254,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 for (const d of datas) {
-                    const stageBills = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, d.lid);
+                    const stageBills = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, d.lid);
                     const ledgerBills = await this.ctx.service.ledger.getDataById(d.lid);
                     if (!stageBills || stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
                         await this._insertStageBillsData(transaction, d, stageBills, ledgerBills);
@@ -269,7 +269,7 @@ module.exports = app => {
                 await transaction.rollback();
                 throw err;
             }
-            return await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, this._.map(datas, 'lid'));
+            return await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, this._.map(datas, 'lid'));
         }
 
         /**
@@ -307,7 +307,7 @@ module.exports = app => {
          */
         async calc(tid, sid, lid, transaction) {
             const info = this.ctx.tender.info;
-            const stageBills = await this.getLastestStageData(tid, sid, lid);
+            const stageBills = await this.getLastestStageData2(tid, sid, lid);
             const ledgerBills = await this.ctx.service.ledger.getDataById(lid);
             if (!ledgerBills) {
                 throw '提交数据错误';
@@ -342,7 +342,7 @@ module.exports = app => {
         }
 
         async updateStageBillsCalcType(data) {
-            const stageBills = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, data.id);
+            const stageBills = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, data.id);
             const updateData = { contract_qty: null, contract_tp: null };
 
             const transaction = await this.db.beginTransaction();
@@ -364,7 +364,7 @@ module.exports = app => {
             }
 
             const bills = await this.ctx.service.ledger.getDataById(data.id);
-            const curStageData = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [data.id]);
+            const curStageData = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, [data.id]);
             return { bills: [bills], curStageData };
         }
 
@@ -495,7 +495,7 @@ module.exports = app => {
                 const result = loadTree.getUpdateData();
                 if (result.errors.length > 100) throw '您导入的数据存在大量数据错误,请您仔细检查';
 
-                const stageBills = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id);
+                const stageBills = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
                 const updateStageBills = [], insertStageBills = [];
                 for (const u of result.update) {
                     const sb = stageBills.find(x => { return x.lid === u.lid; });

+ 1 - 1
app/service/stage_bills_final.js

@@ -76,7 +76,7 @@ module.exports = app => {
                 throw '数据错误';
             }
             if (stage.order > 1) {
-                const cur = await this.ctx.service.stageBills.getLastestStageData(tender.id, stage.id);
+                const cur = await this.ctx.service.stageBills.getLastestStageData2(tender.id, stage.id);
                 const pre = await this.getFinalData(tender, stage.order - 1);
                 if ((!cur || cur.length === 0) && (!pre || pre.length === 0)) return;
                 for (const c of cur) {

+ 3 - 3
app/service/stage_change.js

@@ -188,14 +188,14 @@ module.exports = app => {
                 for (const c of updateChanges) {
                     await transaction.update(this.tableName, c);
                 }
-                const stageBills = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, bills.id);
+                const stageBills = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, bills.id);
                 await this.ctx.service.stageBills.updateStageBillsQty(transaction, ledgerBills, stageBills, { qc_qty: billsQty });
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
                 throw err;
             }
-            const result = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [bills.id]);
+            const result = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, [bills.id]);
             return { bills: { curStageData: result } };
         }
 
@@ -274,7 +274,7 @@ module.exports = app => {
             // 获取返回数据
             try {
                 const data = { bills: {}, pos: {} };
-                data.bills.curStageData = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [pos.lid]);
+                data.bills.curStageData = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, [pos.lid]);
                 data.pos.curStageData = await this.ctx.service.stagePos.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, { pid: pos.id });
                 return data;
             } catch (err) {

+ 2 - 2
app/service/stage_pos.js

@@ -439,7 +439,7 @@ module.exports = app => {
             }
             const updateBillsStage = [], insertBillsStage = [], info = this.ctx.tender.info;
             for (const b of bills) {
-                const stageBills = await this.ctx.service.stageBills.getLastestStageData(b.tender_id, this.ctx.stage.id, b.id);
+                const stageBills = await this.ctx.service.stageBills.getLastestStageData2(b.tender_id, this.ctx.stage.id, b.id);
 
                 const posStage = await this.getLastestStageData2(b.tender_id, this.ctx.stage.id, {lid: b.id});
                 let contract_qty = 0;
@@ -586,7 +586,7 @@ module.exports = app => {
                 if (refreshData.ledger && refreshData.ledger.length > 0) {
                     result.ledger.bills = await this.ctx.service.ledger.getDataByIds(refreshData.ledger);
                     if (refreshData.stageUpdate) {
-                        result.ledger.curStageData = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, refreshData.ledger);
+                        result.ledger.curStageData = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, refreshData.ledger);
                     }
                 }
                 if (refreshData.pos) {

+ 2 - 2
app/service/stage_rela.js

@@ -32,7 +32,7 @@ class srCache {
     async _loadBillsData() {
         const decimal = this.ctx.tender.info.decimal;
         const ledger = await this.ctx.service.ledger.getData(this.stage.tid);
-        const curBillsData = await this.ctx.service.stageBills.getLastestStageData(this.stage.tid, this.stage.id);
+        const curBillsData = await this.ctx.service.stageBills.getLastestStageData2(this.stage.tid, this.stage.id);
         const preStageBills = this.preRelaStage
             ? await this.ctx.service.stageRelaBillsFinal.getAllDataByCondition({ where: { sid: this.preRelaStage.sid, rela_tid: this.preRelaStage.rela_tid } })
             : [];
@@ -303,7 +303,7 @@ module.exports = app => {
         // async _calculateRelaStage(stage, preRelaStage) {
         //     const result = {}, helper = this.ctx.helper, stageBills = [];
         //     const ledger = await this.ctx.service.ledger.getData(stage.tid);
-        //     const curBillsData = await this.ctx.service.stageBills.getLastestStageData(stage.tid, stage.id);
+        //     const curBillsData = await this.ctx.service.stageBills.getLastestStageData2(stage.tid, stage.id);
         //     helper.assignRelaData(ledger, [
         //         { data: curBillsData, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid' },
         //     ]);