فهرست منبع

移除ledger和pos主表中的is_tp和三方数据

MaiXinRong 2 سال پیش
والد
کامیت
5a1e685ba5

+ 7 - 1
app/base/base_bills_service.js

@@ -559,7 +559,7 @@ class BaseBillsSerivce extends TreeService {
         }
     }
 
-    async pasteBlockData (tid, sid, pasteData, defaultData) {
+    async pasteBlockData(tid, sid, pasteData, defaultData) {
         if ((tid <= 0) || (sid <= 0)) return [];
 
         if (!pasteData || pasteData.length <= 0) throw '复制数据错误';
@@ -703,6 +703,12 @@ class BaseBillsSerivce extends TreeService {
             pos: pastePosData,
         };
     }
+
+    async getCompleteDataById(id) {
+        const ledgerBills = await this.getDataById(id);
+        const ledgerExtra = await this.ctx.service.ledgerExtra.getDataById(id);
+        ledgerBills.is_tp = ledgerExtra ? ledgerExtra.is_tp : 0;
+    }
 }
 
 module.exports = BaseBillsSerivce;

+ 8 - 9
app/controller/stage_controller.js

@@ -230,7 +230,7 @@ module.exports = app => {
             if (tender.data.measure_type === measureType.gcl.value) this.ledgerColumn.push('deal_qty', 'deal_tp');
             if (tender.info.display.ledger.dgnQty) this.ledgerColumn.push('dgn_qty1', 'dgn_qty2');
 
-            this.ledgerExtraColumn = [ 'is_tp' ];
+            this.ledgerExtraColumn = ['is_tp'];
             if (this.ctx.session.sessionProject.gxby) this.ledgerExtraColumn.push('gxby_status', 'gxby_url', 'gxby_limit');
             if (this.ctx.session.sessionProject.dagl) this.ledgerExtraColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
 
@@ -272,9 +272,9 @@ module.exports = app => {
             // 查询截止上期数据
             const preStageData = ctx.stage.order > 1 ? await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1) : [];
             this.ctx.helper.assignRelaData(ledgerData, [
-                { data: dgnData, fields: ['deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2'], prefix: '', relaId: 'id'},
-                { data: extraData, fields: this.ledgerExtraColumn, prefix: '', relaId: 'id'},
-                { data: importData, fields: ['is_import'], prefix: '', relaId: 'lid'},
+                { data: dgnData, fields: ['deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2'], prefix: '', relaId: 'id' },
+                { data: extraData, fields: this.ledgerExtraColumn, prefix: '', relaId: 'id' },
+                { data: importData, fields: ['is_import'], prefix: '', relaId: 'lid' },
                 { data: curStageData, fields: ['contract_qty', 'contract_expr', 'contract_tp', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid' },
                 { data: preStageData, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'used'], prefix: 'pre_', relaId: 'lid' },
             ]);
@@ -282,10 +282,9 @@ module.exports = app => {
         }
         async _getStagePosData(ctx) {
             let curStageData;
-            const posData =  ctx.stage.ledgerHis
-                ? await ctx.service.ledger.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.pos_file)
+            const posData = ctx.stage.ledgerHis
+                ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.pos_file)
                 : await ctx.service.pos.getAllDataByCondition({ columns: this.posColumn, where: { tid: ctx.tender.id } });
-            // const posData = await ctx.service.pos.getAllDataByCondition({ columns: posColumn, where: { tid: ctx.tender.id } });
             const extraData = await ctx.service.posExtra.getData(ctx.tender.id, this.posExtraColumn);
             // 根据当前人,或指定对象查询数据
             if (ctx.stage.readOnly) {
@@ -1375,10 +1374,10 @@ module.exports = app => {
                 if (data.main) {
                     result.main = {};
                     result.main.ledger = ctx.stage.ledgerHis
-                        ? await ctx.service.ledger.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.bills_file)
+                        ? await ctx.helper.loadLedgerDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.bills_file)
                         : await ctx.service.ledger.getData(ctx.tender.id);
                     result.main.pos = ctx.stage.ledgerHis
-                        ? await ctx.service.pos.loadDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.pos_file)
+                        ? await ctx.helper.loadLedgerDataFromOss(ctx.tender.id, ctx.stage.ledgerHis.pos_file)
                         : await ctx.service.pos.getPosData({ tid: ctx.tender.id });
                 }
                 for (const order of data.roles) {

+ 10 - 8
app/lib/sum_load.js

@@ -210,7 +210,7 @@ class loadLedgerGclTree extends loadGclBaseTree {
 }
 
 class updateReviseGclTree extends loadGclBaseTree {
-    constructor (ctx, setting) {
+    constructor(ctx, setting) {
         super(ctx, setting);
         this.errors = [];
     }
@@ -308,14 +308,14 @@ class updateReviseGclTree extends loadGclBaseTree {
                 deal_qty: i.deal_qty, deal_tp: i.deal_tp || 0,
                 sgfh_qty: i.sgfh_qty, sjcl_qty: i.sjcl_qty, qtcl_qty: i.qtcl_qty, quantity: i.quantity,
                 sgfh_tp: i.sgfh_tp || 0, sjcl_tp: i.sjcl_tp || 0, qtcl_tp: i.qtcl_tp || 0, total_price: i.total_price || 0,
-            })
+            });
         }
         return result;
     }
 }
 
 class gatherStageGclTree extends loadGclBaseTree {
-    constructor (ctx, setting) {
+    constructor(ctx, setting) {
         super(ctx, setting);
         this.cover = setting.cover;
     }
@@ -369,7 +369,7 @@ class gatherStageGclTree extends loadGclBaseTree {
     gather(source, parent) {
         parent = parent ? parent : this.parent;
         const checkFun = function (node, source) {
-            return  (source.is_tp && node.is_tp) || (!source.is_tp && !node.is_tp);
+            return (source.is_tp && node.is_tp) || (!source.is_tp && !node.is_tp);
         };
         const node = this.ignoreParent ? this.addNodeWithoutParent(source, checkFun) : this.addNode(source, parent, checkFun);
         if (node.is_tp) {
@@ -420,7 +420,7 @@ class gatherStageGclTree extends loadGclBaseTree {
 }
 
 class sumLoad {
-    constructor (ctx) {
+    constructor(ctx) {
         this.ctx = ctx;
     }
 
@@ -524,13 +524,15 @@ class sumLoad {
             parent: select, maxId, type: 'ledger', defaultData, ignoreParent, cover,
         });
         const posterity = await this.ctx.service.ledger.getPosterityByParentId(this.ctx.tender.id, select.ledger_id);
+        const extraData = await this.ctx.service.ledgerExtra.getData(this.ctx.tender.id, ['is_tp']);
         const stageBills = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
         const importLid = await this.ctx.service.stageImportChange.getLeafXmjImportLid(this.ctx.stage.id, select.id);
         this.ctx.helper.assignRelaData(posterity, [
-            { data: importLid, fields: [ 'is_import' ], prefix: '', relaId: 'lid' },
-            { data: stageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp' ], prefix: '', relaId: 'lid' },
+            { data: extraData, fields: ['is_import'], prefix: '', relaId: 'id' },
+            { data: importLid, fields: ['is_import'], prefix: '', relaId: 'lid' },
+            { data: stageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
         ]);
-        const pos = await this.ctx.service.revisePos.getData(this.ctx.tender.id);
+        const pos = await this.ctx.service.pos.getData(this.ctx.tender.id);
         this.loadTree.loadBase(posterity, pos);
 
         for (const tender of tenders) {

+ 0 - 12
app/service/ledger.js

@@ -759,18 +759,6 @@ module.exports = app => {
                 throw (err.stack ? '导入工程量数据出错': err);
             }
         }
-
-        async loadDataFromOss(tid, url) {
-            const data = await this.ctx.helper.loadLedgerDataFromOss(url);
-            const curData = await this.getAllDataByCondition({
-                columns: ['id', 'is_tp', 'gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'],
-                where: { tender_id: tid }
-            });
-            this.ctx.helper.assignRelaData(data, [
-                { data: curData, fields: ['is_tp', 'gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'], prefix: '', relaId: 'id' },
-            ]);
-            return data;
-        }
     }
 
     return Ledger;

+ 6 - 6
app/service/ledger_revise.js

@@ -98,14 +98,14 @@ module.exports = app => {
             const sql = 'Insert Into ' + this.ctx.service.reviseBills.tableName +
                 '  (id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
                 '     quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
-                '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp,' +
+                '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, check_calc,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3)' +
+                '     ex_memo1, ex_memo2, ex_memo3)' +
                 '  Select id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
                 '      quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
-                '      sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp,' +
+                '      sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id,' +
                 '      sgfh_expr, sjcl_expr, qtcl_expr, 0,' +
-                '      gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3' +
+                '      ex_memo1, ex_memo2, ex_memo3' +
                 '  From ' + this.ctx.service.ledger.tableName +
                 '  Where `tender_id` = ?';
             const sqlParam = [tid];
@@ -117,11 +117,11 @@ module.exports = app => {
                 '  (id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, crid, in_time, porder, position,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3)' +
+                '     ex_memo1, ex_memo2, ex_memo3)' +
                 '  Select id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, crid, in_time, porder, position,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit, dagl_limit, ex_memo1, ex_memo2, ex_memo3' +
+                '     ex_memo1, ex_memo2, ex_memo3' +
                 '  From ' + this.ctx.service.pos.tableName +
                 '  Where `tid` = ?';
             const sqlParam = [tid];

+ 0 - 12
app/service/pos.js

@@ -503,18 +503,6 @@ module.exports = app => {
         async deletePosData(transaction, tid, lid) {
             await transaction.delete(this.tableName, {tid: tid, lid: lid});
         }
-
-        async loadDataFromOss(tid, url) {
-            const data = await this.ctx.helper.loadLedgerDataFromOss(url);
-            const curData = await this.getAllDataByCondition({
-                columns: ['id', 'gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'],
-                where: { tid: tid }
-            });
-            this.ctx.helper.assignRelaData(data, [
-                { data: curData, fields: ['gxby_status', 'gxby_limit', 'gxby_url', 'dagl_status', 'dagl_limit', 'dagl_url'], prefix: '', relaId: 'id' },
-            ]);
-            return data;
-        }
     }
 
     return Pos;

+ 2 - 6
app/service/revise_audit.js

@@ -303,15 +303,13 @@ module.exports = app => {
                 this.ctx.service.ledger.tableName +
                 '  (id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
                 '     quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
-                '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp,' +
+                '     sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, check_calc,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit,  dagl_limit,' +
                 '     ex_memo1, ex_memo2, ex_memo3)' +
                 '  Select id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
                 '      quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
-                '      sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp, ' +
+                '      sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, ' +
                 '      sgfh_expr, sjcl_expr, qtcl_expr, check_calc,' +
-                '      gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit,  dagl_limit,' +
                 '      ex_memo1, ex_memo2, ex_memo3' +
                 '  From ' +
                 this.ctx.service.reviseBills.tableName +
@@ -324,12 +322,10 @@ module.exports = app => {
                 '  (id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, crid, porder, position, ' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit,  dagl_limit,' +
                 '     ex_memo1, ex_memo2, ex_memo3)' +
                 '  Select id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, crid, porder, position,' +
                 '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
-                '     gxby_status, dagl_status, gxby_url, dagl_url, gxby_limit,  dagl_limit,' +
                 '     ex_memo1, ex_memo2, ex_memo3' +
                 '  From ' +
                 this.ctx.service.revisePos.tableName +

+ 5 - 5
app/service/stage_bills.js

@@ -215,7 +215,7 @@ module.exports = app => {
             try {
                 for (const d of datas) {
                     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);
+                    const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(d.lid);
                     if (!stageBills || stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
                         await this._insertStageBillsData(transaction, d, stageBills, ledgerBills);
                     } else {
@@ -268,7 +268,7 @@ module.exports = app => {
         async calc(tid, sid, lid, transaction) {
             const info = this.ctx.tender.info;
             const stageBills = await this.getLastestStageData2(tid, sid, lid);
-            const ledgerBills = await this.ctx.service.ledger.getDataById(lid);
+            const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(lid);
             if (!ledgerBills) {
                 throw '提交数据错误';
             }
@@ -316,7 +316,7 @@ module.exports = app => {
                 }
                 if (stageBills) {
                     if (stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
-                        const ledgerBills = await this.ctx.service.ledger.getDataById(data.id);
+                        const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(data.id);
                         await this._insertStageBillsData(transaction, updateData, stageBills, ledgerBills);
                     } else {
                         updateData.id = stageBills.id;
@@ -329,7 +329,7 @@ module.exports = app => {
                 throw err;
             }
 
-            const bills = await this.ctx.service.ledger.getDataById(data.id);
+            const bills = await this.ctx.service.ledger.getCompleteDataById(data.id);
             const curStageData = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, [data.id]);
             return { bills: [bills], curStageData };
         }
@@ -455,7 +455,7 @@ module.exports = app => {
             const conn = await this.db.beginTransaction();
             try {
                 const maxId = await this.ctx.service.ledger._getMaxLid(this.ctx.tender.id);
-                const select = await this.ctx.service.ledger.getDataById(lid);
+                const select = await this.ctx.service.ledger.getCompleteDataById(lid);
                 const sumLoad = new SumLoad(this.ctx);
                 const loadTree = await sumLoad.stageGatherGcl(select, maxId, tenders, null, cover);
                 const result = loadTree.getUpdateData();

+ 2 - 2
app/service/stage_change.js

@@ -140,7 +140,7 @@ module.exports = app => {
                     qty, minus
                 };
             }
-            const ledgerBills = await this.ctx.service.ledger.getDataById(bills.id);
+            const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(bills.id);
             if (!ledgerBills || ledgerBills.tender_id !== this.ctx.tender.id) {
                 throw '提交数据错误';
             }
@@ -213,7 +213,7 @@ module.exports = app => {
                     qty, minus
                 };
             }
-            const ledgerBills = await this.ctx.service.ledger.getDataById(pos.lid);
+            const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(pos.lid);
             if (!ledgerBills || ledgerBills.tender_id !== this.ctx.tender.id) {
                 throw '提交数据错误';
             }

+ 6 - 2
app/service/stage_stash.js

@@ -325,12 +325,16 @@ module.exports = app => {
                     columns: ['id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf', 'code', 'b_code', 'name', 'unit', 'unit_price', 'is_tp'],
                     where: { tender_id: stage.tid},
                 });
+                const extraData = await this.ctx.service.ledgerExtra.getData(this.ctx.tender.id, ['is_tp']);
+                this.ctx.helper.assignRelaData(ledgerData, [
+                    { data: extraData, fields: ['is_import'], prefix: '', relaId: 'id' },
+                ]);
                 const posData = await this.ctx.service.pos.getAllDataByCondition({
                     columns: ['id', 'lid', 'name', 'porder'],
                     where: { tid: stage.tid },
                 });
-                const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id }});
-                const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id }});
+                const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id } });
+                const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id } });
                 const stageBillsDgn = await this.ctx.service.stageBillsDgn.getAllDataByCondition({ where: { tid: stage.tid } });
 
                 const loadModal = new loadStageExcelTree(this.ctx);