Browse Source

变更概况,隐藏导入变更的数据

MaiXinRong 2 years ago
parent
commit
c257dc2c13
4 changed files with 48 additions and 42 deletions
  1. 2 2
      app/lib/sum_load.js
  2. 40 39
      app/service/stage_change.js
  3. 1 1
      app/service/stage_change_final.js
  4. 5 0
      sql/update.sql

+ 2 - 2
app/lib/sum_load.js

@@ -427,7 +427,7 @@ class gatherStageGclTree extends loadGclBaseTree {
             if (bn.change_detail && bn.change_detail.length > 0) {
                 for (const cd of bn.change_detail) {
                     result.qc_detail.push({
-                        lid: bn.id, rela_tid: cd.tid, rela_sid: cd.sid, rela_lid: cd.lid, rela_cid: cd.cid, rela_cbid: cd.cbid, rela_qty: cd.qty
+                        lid: bn.id, rela_tid: cd.tid, rela_sid: cd.sid, rela_lid: cd.lid, rela_cid: cd.cid, rela_cbid: cd.cbid, rela_qty: cd.qty, rela_minus: cd.minus, rela_no_value: cd.no_value, unit_price: bn.unit_price,
                     });
                 }
             }
@@ -534,7 +534,7 @@ class sumLoad {
             if (!b.change_detail) b.change_detail = [];
             let c = b.change_detail.find(x => { return x.cbid === csc.cbid });
             if (!c) {
-                c = { tid: csc.tid, sid: csc.sid, cid: csc.cid, cbid: csc.cbid, lid: csc.lid, c_code: csc.c_code };
+                c = { tid: csc.tid, sid: csc.sid, cid: csc.cid, cbid: csc.cbid, lid: csc.lid, c_code: csc.c_code, minus: csc.minus, no_value: csc.no_value };
                 b.change_detail.push(c);
             }
             c.qty = this.ctx.helper.add(c.qty, csc.qty);

+ 40 - 39
app/service/stage_change.js

@@ -548,7 +548,7 @@ module.exports = app => {
         }
 
         async getSumLoadFinalData(sid) {
-            const sql = 'Select cf.tid, cf.sid, cf.lid, cf.pid, cf.cid, cf.cbid, cf.qty, cf.stimes, cf.sorder, c.code As c_code' +
+            const sql = 'Select cf.tid, cf.sid, cf.lid, cf.pid, cf.cid, cf.cbid, cf.qty, cf.stimes, cf.sorder, cf.minus, cf.no_value, c.code As c_code,' +
                 '  FROM ' + this.tableName + ' cf' +
                 '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' +
                 '  Where cf.sid = ?';
@@ -618,44 +618,45 @@ module.exports = app => {
             });
             if (change.length === 0) return [];
 
-            const changeBills = await this.ctx.service.changeAuditList.getAllDataByCondition({
-                where: { cid: change.map(x => { return x.cid; }) }
-            });
-            const changeBillsIndex = {}, changeBillsPart = {};
-            for (const cb of changeBills) {
-                changeBillsIndex[cb.id] = cb;
-                if (!changeBillsPart[cb.cid]) changeBillsPart[cb.cid] = [];
-                changeBillsPart[cb.cid].push(cb);
-            }
-            const stageChangeBills = await this.getChangeBillsWithUsedInfo(stage);
-            for (const scb of stageChangeBills) {
-                if (!scb.qty) continue;
-
-                const cb = changeBillsIndex[scb.cbid];
-                if (cb) cb.used_qty = this.ctx.helper.add(cb.used_qty, scb.qty);
-            }
-            for (const cid in changeBillsPart) {
-                const c = change.find(x => { return x.cid === cid });
-                if (!c) continue;
-
-                for (const cb of changeBillsPart[cid]) {
-                    cb.tp = this.ctx.helper.mul(cb.spamount, cb.unit_price, c.tp_decimal || this.ctx.tender.info.decimal.tp);
-                    cb.used_tp = this.ctx.helper.mul(cb.used_qty, cb.unit_price, this.ctx.tender.info.decimal.tp);
-
-                    c.used_tp = this.ctx.helper.add(c.used_tp, cb.used_tp);
-                    if (cb.spamount > 0) {
-                        c.p_tp = this.ctx.helper.add(c.p_tp, cb.tp);
-                        c.p_used_tp = this.ctx.helper.add(c.p_used_tp, cb.used_tp);
-                    } else if (cb.spamount < 0){
-                        c.n_tp = this.ctx.helper.add(c.n_tp, cb.tp);
-                        c.n_used_tp = this.ctx.helper.add(c.n_used_tp, cb.used_tp);
-                    }
-                }
-                c.used_pt = c.total_price ? this.ctx.helper.mul(this.ctx.helper.div(c.used_tp, c.total_price, 4), 100) : 0;
-                c.p_used_pt = c.p_tp ? this.ctx.helper.mul(this.ctx.helper.div(c.p_used_tp, c.p_tp, 4), 100) : 0;
-                c.n_used_pt = c.n_tp ? this.ctx.helper.mul(this.ctx.helper.div(c.n_used_tp, c.n_tp, 4), 100) : 0;
-            }
-            return change;
+            // 因为总包导入后,单价不一定与分包相关,为了避免错误,不计算
+            // const changeBills = await this.ctx.service.changeAuditList.getAllDataByCondition({
+            //     where: { cid: change.map(x => { return x.cid; }) }
+            // });
+            // const changeBillsIndex = {}, changeBillsPart = {};
+            // for (const cb of changeBills) {
+            //     changeBillsIndex[cb.id] = cb;
+            //     if (!changeBillsPart[cb.cid]) changeBillsPart[cb.cid] = [];
+            //     changeBillsPart[cb.cid].push(cb);
+            // }
+            // const stageChangeBills = await this.getChangeBillsWithUsedInfo(stage);
+            // for (const scb of stageChangeBills) {
+            //     if (!scb.qty) continue;
+            //
+            //     const cb = changeBillsIndex[scb.cbid];
+            //     if (cb) cb.used_qty = this.ctx.helper.add(cb.used_qty, scb.qty);
+            // }
+            // for (const cid in changeBillsPart) {
+            //     const c = change.find(x => { return x.cid === cid });
+            //     if (!c) continue;
+            //
+            //     for (const cb of changeBillsPart[cid]) {
+            //         cb.tp = this.ctx.helper.mul(cb.spamount, cb.unit_price, c.tp_decimal || this.ctx.tender.info.decimal.tp);
+            //         cb.used_tp = this.ctx.helper.mul(cb.used_qty, cb.unit_price, this.ctx.tender.info.decimal.tp);
+            //
+            //         c.used_tp = this.ctx.helper.add(c.used_tp, cb.used_tp);
+            //         if (cb.spamount > 0) {
+            //             c.p_tp = this.ctx.helper.add(c.p_tp, cb.tp);
+            //             c.p_used_tp = this.ctx.helper.add(c.p_used_tp, cb.used_tp);
+            //         } else if (cb.spamount < 0){
+            //             c.n_tp = this.ctx.helper.add(c.n_tp, cb.tp);
+            //             c.n_used_tp = this.ctx.helper.add(c.n_used_tp, cb.used_tp);
+            //         }
+            //     }
+            //     c.used_pt = c.total_price ? this.ctx.helper.mul(this.ctx.helper.div(c.used_tp, c.total_price, 4), 100) : 0;
+            //     c.p_used_pt = c.p_tp ? this.ctx.helper.mul(this.ctx.helper.div(c.p_used_tp, c.p_tp, 4), 100) : 0;
+            //     c.n_used_pt = c.n_tp ? this.ctx.helper.mul(this.ctx.helper.div(c.n_used_tp, c.n_tp, 4), 100) : 0;
+            // }
+            // return change;
         }
 
         async getStageMinusChange(stage) {

+ 1 - 1
app/service/stage_change_final.js

@@ -72,7 +72,7 @@ module.exports = app => {
         }
 
         async getSumLoadFinalData(sid) {
-            const sql = 'Select cf.tid, cf.sid, cf.lid, cf.cid, cf.cbid, cf.qty, c.code As c_code' +
+            const sql = 'Select cf.tid, cf.sid, cf.lid, cf.cid, cf.cbid, cf.qty, cf.minus, cf.no_value, c.code As c_code' +
                 '  FROM ' + this.tableName + ' cf' +
                 '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' +
                 '  Where cf.sid = ?';

+ 5 - 0
sql/update.sql

@@ -13,3 +13,8 @@ CREATE TABLE `zh_wx_work` (
   PRIMARY KEY (`id`),
   UNIQUE KEY `corpid` (`corpid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='企业微信信息表';
+
+ALTER TABLE `zh_stage_import_change`
+ADD COLUMN `rela_minus`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否负变更' AFTER `rela_qty`,
+ADD COLUMN `rela_no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否不计价' AFTER `rela_minus`,
+ADD COLUMN `unit_price`  decimal(24,8) NOT NULL DEFAULT 0.00000000 COMMENT '清单单价' AFTER `rela_no_value`;