فهرست منبع

1. 计量单元,复制粘贴整块
2. 导入合同数据问题

MaiXinRong 2 ماه پیش
والد
کامیت
0898a7009d
6فایلهای تغییر یافته به همراه63 افزوده شده و 8 حذف شده
  1. 6 0
      app/public/js/ledger.js
  2. 6 0
      app/service/ancillary_gcl.js
  3. 5 5
      app/service/calc_tmpl.js
  4. 3 2
      app/service/cost_stage_detail.js
  5. 39 1
      app/service/pos.js
  6. 4 0
      sql/update.sql

+ 6 - 0
app/public/js/ledger.js

@@ -3425,6 +3425,10 @@ $(document).ready(function() {
                     const detailRange = posCalcDetail.detail.getPartData(p.id);
                     p.calcDetail = detailRange;
                 }
+                p.ancGcl = ancGcl.getPartData(p.id);
+                for (const ag of p.ancGcl) {
+                    if (ag.calc_template) ag.calcDetail = ancGclDetail.detail.getPartData(ag.id);
+                }
                 iRow++;
             }
             return copyBlockList;
@@ -3450,6 +3454,8 @@ $(document).ready(function() {
                 if (result.posCalcDetail) posCalcDetail.detail.updateDatas(result.posCalcDetail);
                 const ledgerResult = ledgerTree.loadPostData(data.ledger);
                 treeOperationObj.refreshTree(ledgerSheet, ledgerResult);
+                if (result.ancGcl) ancGcl.updateDatas(result.ancGcl);
+                if (result.ancGclDetail) ancGclDetail.detail.updateDatas(result.ancGclDetail);
                 removeLocalCache(copyBlockTag);
                 posOperationObj.loadCurPosData();
             });

+ 6 - 0
app/service/ancillary_gcl.js

@@ -244,6 +244,12 @@ module.exports = app => {
         async deletePosPartData(transaction, tid, pid) {
             await transaction.delete(this.tableName, { tid: tid, pid: pid });
         }
+
+        async getUsedCalcTemplate(tid) {
+            const sql = `SELECT calc_template, count(id) as count FROM ${this.tableName} WHERE tid = ? and calc_template <> '' GROUP BY calc_template`;
+            const result = await this.db.query(sql, [tid]);
+            return result;
+        }
     }
 
     return AncillaryGcl;

+ 5 - 5
app/service/calc_tmpl.js

@@ -355,12 +355,12 @@ module.exports = app => {
             const tender = await this.ctx.service.tender.getAllDataByCondition({ columns: ['id'], where: { project_id: templates[0].pid }});
             for (const t of tender) {
                 const used = await this.ctx.service.ledgerExtra.getUsedCalcTemplate(t.id);
+                const ancGclUsed = await this.ctx.service.ancillaryGcl.getUsedCalcTemplate(t.id);
                 templates.forEach(x => {
-                    const u = used.find(ut => { return ut.calc_template === x.id; });
-                    if (u) {
-                        x.used.push(t.id);
-                        x.used_count = this.ctx.helper.add(x.used_count + u.count);
-                    }
+                    const u = used.find(ut => { return ut.calc_template === x.id; }) || { count: 0 };
+                    const u2 = ancGclUsed.find(ut => { return ut.calc_template === x.id; }) || { count: 0 };
+                    if (u.count > 0 || u2.count > 0) x.used.push(t.id);
+                    x.used_count = this.ctx.helper.sum([ x.used_count, u.count, u2.count ]);
                 });
             }
         }

+ 3 - 2
app/service/cost_stage_detail.js

@@ -281,6 +281,7 @@ module.exports = app => {
             const paySql = `SELECT cp.*, c.c_code, c.name, c.party_b FROM ${this.ctx.service.contractPay.tableName} cp LEFT JOIN ${this.ctx.service.contract.tableName} c ON cp.cid = c.id ` +
                            `    WHERE cp.cid IN(${ids.map(x => { return `'${x}'`}).join(', ')}) AND cp.pay_time >= ? AND cp.pay_time <= ?`;
             const validPays = await this.db.query(paySql, [beginTime, endTime]);
+            console.log(this.db.format(paySql, [beginTime, endTime]));
 
             const insertDetails = [];
             for (const pay of validPays) {
@@ -298,8 +299,8 @@ module.exports = app => {
                 idetail.tax = pay.tax || 0;
                 idetail.pay_tp = this.ctx.helper.add(idetail.pay_tp, pay.pay_price);
                 idetail.cut_tp = this.ctx.helper.add(idetail.cut_tp, pay.debit_price);
-                idetail.yf_tp = this.ctx.helper.add(idetail.sf_tp, pay.yf_price);
-                idetail.sf_tp = this.ctx.helper.add(idetail.yf_tp, pay.sf_price);
+                idetail.yf_tp = this.ctx.helper.add(idetail.yf_tp, pay.yf_price);
+                idetail.sf_tp = this.ctx.helper.add(idetail.sf_tp, pay.sf_price);
                 const divNum = idetail.tax ? this.ctx.helper.add(1, this.ctx.helper.div(idetail.tax, 100)) : 1;
                 idetail.yf_excl_tax_tp = this.ctx.helper.add(idetail.yf_excl_tax_tp, this.ctx.helper.div(pay.yf_price, divNum, this.ctx.costStage.decimal.tp));
                 idetail.sf_excl_tax_tp = this.ctx.helper.add(idetail.sf_excl_tax_tp, this.ctx.helper.div(pay.sf_price, divNum, this.ctx.costStage.decimal.tp));

+ 39 - 1
app/service/pos.js

@@ -429,6 +429,8 @@ module.exports = app => {
             if (!(data.block instanceof Array)) throw '提交数据错误';
 
             const result = { ledger: {}, pos: null };
+            const qtyDecimal = this.ctx.tender.info.decimal.qty;
+            const user_id = this.ctx.session.sessionUser.accountId;
 
             const bills = await this.ctx.service.ledger.getDataById(data.lid);
             const le = await this.ctx.service.ledgerExtra.getDataById(data.lid);
@@ -440,7 +442,7 @@ module.exports = app => {
                 ? { id: bills.id, sgfh_qty: bills.sgfh_qty, sjcl_qty: bills.sjcl_qty, qtcl_qty: bills.qtcl_qty, quantity: bills.quantity, ex_qty1: bills.ex_qty1 }
                 : { id: bills.id, sgfh_qty: 0, sjcl_qty: 0, qtcl_qty: 0, quantity: 0, ex_qty1: 0 };
 
-            const insertPos = [], insertDetail = [];
+            const insertPos = [], insertDetail = [], insertAncGcl = [], insertAncGclDetail = [];
             for (const [i, b] of data.block.entries()) {
                 const nip = {};
                 insertPos.push(nip);
@@ -508,6 +510,38 @@ module.exports = app => {
                 this._calcExpr(nip, 'qtcl_qty', b.qtcl_expr, b.qtcl_qty, precision);
                 nip.quantity = this.ctx.helper.add(nip.sgfh_qty, this.ctx.helper.add(nip.sjcl_qty, nip.qtcl_qty));
                 nip.ex_qty1 = this.ctx.helper.round(b.ex_qty1, precision.value);
+                for (const ag of b.ancGcl) {
+                    const nig = {
+                        id: this.uuid.v4(), tid: this.ctx.tender.id,
+                        add_user_id: user_id, update_user_id: user_id,
+                        lid: nip.lid, pid: nip.id, g_order: ag.g_order,
+                        is_aux: ag.is_aux || 0, name: ag.name || '', unit: ag.unit || '',
+                        drawing_code: ag.drawing_code || '', memo: ag.memo || '',
+                        quantity: ag.quantity || 0, expr: b.expr || '', calc_template: ag.calc_template || ''
+                    };
+                    insertAncGcl.push(nig);
+                    if (!ag.calc_template) continue;
+
+                    let sumQty = 0;
+                    for (const cd of ag.calcDetail) {
+                        const newDetail = {
+                            id: this.uuid.v4(), tid: this.ctx.tender.id, lid: nip.lid, pid: nip.id, ag_id: nig.id,
+                            create_user_id: user_id, update_user_id: user_id,
+                            agd_order: cd.agd_order,
+                            str1 : cd.str1 || '', str2 : cd.str1 || '', str3 : cd.str1 || '', str4 : cd.str1 || '',
+                            num_a : cd.num_a || 0, num_b : cd.num_b || 0, num_c : cd.num_c || 0, num_d : cd.num_d || 0,
+                            num_e : cd.num_e || 0, num_f : cd.num_f || 0, num_g : cd.num_g || 0, num_h : cd.num_h || 0,
+                            num_i : cd.num_i || 0, num_j : cd.num_j || 0, num_k : cd.num_k || 0, num_l : cd.num_l || 0,
+                            num_m : cd.num_m || 0, num_n : cd.num_n || 0, num_o : cd.num_o || 0, num_p : cd.num_p || 0,
+                            num_q : cd.num_q || 0, num_r : cd.num_r || 0, num_s : cd.num_s || 0, num_t : cd.num_t || 0,
+                            num_u : cd.num_u || 0,
+                            qty: cd.qty || 0, expr: cd.expr || 0, spec: cd.spec || ''
+                        };
+                        sumQty = this.ctx.helper.add(sumQty, newDetail.qty);
+                        insertAncGclDetail.push(newDetail);
+                    }
+                    nig.quantity = this.ctx.helper.round(sumQty, qtyDecimal);
+                }
 
                 updateBills.sgfh_qty = this.ctx.helper.add(updateBills.sgfh_qty, nip.sgfh_qty);
                 updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, nip.sjcl_qty);
@@ -527,6 +561,8 @@ module.exports = app => {
             try {
                 await transaction.insert(this.tableName, insertPos);
                 if (insertDetail.length > 0) await transaction.insert(this.ctx.service.posCalcDetail.tableName, insertDetail);
+                if (insertAncGcl.length > 0) await transaction.insert(this.ctx.service.ancillaryGcl.tableName, insertAncGcl);
+                if (insertAncGclDetail.length > 0) await transaction.insert(this.ctx.service.ancillaryGclDetail.tableName, insertAncGclDetail);
                 await transaction.update(this.ctx.service.ledger.tableName, updateBills);
                 await transaction.commit();
             } catch (err) {
@@ -537,6 +573,8 @@ module.exports = app => {
             updateBills.ledger_id = bills.ledger_id;
             result.ledger.update = [updateBills];
             result.posCalcDetail = { add: insertDetail };
+            result.ancGcl = { add: insertAncGcl };
+            result.ancGclDetail = { add: insertAncGclDetail };
             return result;
         }
 

+ 4 - 0
sql/update.sql

@@ -525,6 +525,10 @@ CREATE TABLE `zh_ancillary_gcl_detail`  (
   PRIMARY KEY (`id`)
 );
 
+ALTER TABLE `zh_tender_cache`
+MODIFY COLUMN `stage_flow_cur_info` varchar(5000) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '期-当前流程信息(json)' AFTER `stage_flow_cur_uid`,
+MODIFY COLUMN `stage_flow_pre_info` varchar(5000) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '期-上一流程信息(json)' AFTER `stage_flow_pre_uid`;
+
 ------------------------------------
 -- 表数据
 ------------------------------------