Browse Source

1. 计量台账,审批退回原报,计量Bug
2. 合同支付,使用金额计量,上报后丢失问题

MaiXinRong 6 years atrás
parent
commit
80e57e1e31

+ 1 - 1
app/const/audit.js

@@ -127,7 +127,7 @@ const stage = (function () {
         org: 1,
         pre: 2,
     };
-    return { status, statusString, statusClass, statusButton, statusButtonClass, auditString, auditStringClass, auditProgress, auditProgressClass, backType }
+    return { status, statusString, statusClass, statusButton, statusButtonClass, auditString, auditStringClass, auditProgress, auditProgressClass, backType, timesLen: 100 }
 })();
 
 

+ 4 - 1
app/service/ledger.js

@@ -26,7 +26,6 @@ const calcFields = ['quantity', 'unit_price', 'total_price', 'deal_qty', 'deal_t
 const upFields = ['unit_price'];
 const qtyFields = ['quantity', 'deal_qty', 'dgn_qty1', 'dgn_qty2'];
 const tpFields = ['total_price', 'deal_tp'];
-const zeroRange = 0.0000000001;
 const rootId = -1;
 const keyPre = 'tender_node_maxId:';
 
@@ -1007,6 +1006,10 @@ module.exports = app => {
             return { delete: deleteData, update: updateData };
         }
 
+        async deleteNodes(tenderId, Ids) {
+
+        }
+
         /**
          * tenderId标段中, 选中节点selectId上移
          *

+ 9 - 8
app/service/stage_bills.js

@@ -9,6 +9,7 @@
  */
 const calcFields = ['contract_qty', 'qc_qty'];
 const auditConst = require('../const/audit');
+const timesLen = auditConst.stage.timesLen;
 
 module.exports = app => {
     class StageBills extends app.BaseService {
@@ -34,11 +35,11 @@ module.exports = app => {
             const lidSql = lid ? ' And lid in (?)' : '';
             const sql = 'SELECT * FROM ' + this.tableName + ' As Bills ' +
                         '  INNER JOIN ( ' +
-                        '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `lid`, `sid` From ' + this.tableName +
+                        '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.tableName +
                         '      WHERE tid = ? And sid = ?' + lidSql +
                         '      GROUP BY `lid`' +
                         '  ) As MaxFilter ' +
-                        '  ON Bills.times = MaxFilter.times And Bills.order = MaxFilter.order And Bills.lid = MaxFilter.lid And Bills.`sid` = MaxFilter.`sid`';
+                        '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid And Bills.`sid` = MaxFilter.`sid`';
             const sqlParam = [tid, sid];
             if (!lid) {
                 return await this.db.query(sql, sqlParam);
@@ -64,11 +65,11 @@ module.exports = app => {
             const lidSql = lid ? ' And Bills.lid in (?)' : '';
             const sql = 'SELECT * FROM ' + this.tableName + ' As Bills ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `lid` From ' + this.tableName +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid` From ' + this.tableName +
                 '      WHERE `times` < ? OR (`times` = ? AND `order` <= ?)' +
                 '      GROUP BY `lid`' +
                 '  ) As MaxFilter ' +
-                '  ON Bills.times = MaxFilter.times And Bills.order = MaxFilter.order And Bills.lid = MaxFilter.lid' +
+                '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid' +
                 '  WHERE Bills.tid = ? And Bills.sid = ?' + lidSql;
             const sqlParam = [times, times, order, tid, sid];
             if (!lid) {
@@ -240,11 +241,11 @@ module.exports = app => {
         async getSumTotalPrice(stage) {
             const sql = 'SELECT Sum(`contract_tp`) As `contract_tp`, Sum(`qc_tp`) As `qc_tp` FROM ' + this.tableName + ' As Bills ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `lid` From ' + this.tableName +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid` From ' + this.tableName +
                 '      WHERE `times` <= ? AND `order` <= ?' +
                 '      GROUP BY `lid`' +
                 '  ) As MaxFilter ' +
-                '  ON Bills.times = MaxFilter.times And Bills.order = MaxFilter.order And Bills.lid = MaxFilter.lid' +
+                '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.flow And Bills.lid = MaxFilter.lid' +
                 '  WHERE Bills.sid = ?';
             const sqlParam = [stage.curTimes, stage.curOrder, stage.id];
             const result = await this.db.queryOne(sql, sqlParam);
@@ -254,11 +255,11 @@ module.exports = app => {
         async getSumTotalPriceFilter(stage, operate, filter) {
             const sql = 'SELECT Sum(`contract_tp`) As `contract_tp`, Sum(`qc_tp`) As `qc_tp` FROM ( ' + this.tableName + ' As Bills ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `lid` From ' + this.tableName +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid` From ' + this.tableName +
                 '      WHERE `times` <= ? AND `order` <= ?' +
                 '      GROUP BY `lid`' +
                 '  ) As MaxFilter ' +
-                '  ON Bills.times = MaxFilter.times And Bills.order = MaxFilter.order And Bills.lid = MaxFilter.lid, ' +
+                '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.flow And Bills.lid = MaxFilter.lid, ' +
                 '  ' + this.ctx.service.ledger.tableName + ' As Ledger ) ' +
                 '  WHERE Bills.sid = ? AND Bills.lid = Ledger.id And Ledger.b_code ' + operate + ' ?';
             const sqlParam = [stage.times, stage.curAuditor ? stage.curAuditor.order : 0, stage.id, filter];

+ 5 - 4
app/service/stage_bills_final.js

@@ -7,6 +7,7 @@
  * @date
  * @version
  */
+const timesLen = require('../const/audit').stage.timesLen;
 
 module.exports = app => {
 
@@ -60,10 +61,10 @@ module.exports = app => {
                     '  FROM (SELECT b.tid, b.sid, b.lid, b.contract_qty, b.contract_tp, b.qc_qty, b.qc_tp' +
                     '    FROM ' + this.ctx.service.stageBills.tableName + ' AS b' +
                     '    INNER JOIN(' +
-                    '      SELECT Max(`times`) As `times`, MAX(`order`) As `order`, `lid` FROM ' + this.ctx.service.stageBills.tableName +
+                    '      SELECT Max(`times` * ' + timesLen + ' + `order`) As `flow`, `lid` FROM ' + this.ctx.service.stageBills.tableName +
                     '      WHERE `sid` = ?' +
                     '      GROUP By `lid`) As MF' +
-                    '    ON b.times = MF.times AND b.order = MF.order AND b.lid = MF.lid' +
+                    '    ON (b.times * ' + timesLen + ' + b.order) = MF.flow AND b.lid = MF.lid' +
                     '    WHERE b.sid = ?) As cur' +
                     '  LEFT JOIN ?? As pre' +
                     '  ON cur.lid = pre.lid And pre.sorder = ?';
@@ -74,10 +75,10 @@ module.exports = app => {
                     '  SELECT b.tid, b.sid, b.lid, ? As `sorder`, b.contract_qty, b.contract_tp, b.qc_qty, b.qc_tp' +
                     '  FROM ' + this.ctx.service.stageBills.tableName + ' AS b' +
                     '  INNER JOIN(' +
-                    '    SELECT Max(`times`) As `times`, MAX(`order`) As `order`, `lid` FROM ' + this.ctx.service.stageBills.tableName +
+                    '    SELECT Max(`times` * ' + timesLen + ' + `order`) As `flow`, `lid` FROM ' + this.ctx.service.stageBills.tableName +
                     '    WHERE `sid` = ?' +
                     '    GROUP By `lid`) As MF' +
-                    '  ON b.times = MF.times AND b.order = MF.order AND b.lid = MF.lid' +
+                    '  ON (b.times * ' + timesLen + ' + b.order) = MF.flow AND b.lid = MF.lid' +
                     '  WHERE b.sid = ?';
                 const sqlParam = [this.tableName, stage.order, stage.id, stage.id];
                 await transaction.query(sql, sqlParam);

+ 7 - 6
app/service/stage_detail.js

@@ -7,6 +7,7 @@
  * @date 2019/2/13
  * @version
  */
+const timesLen = require('../const/audit').stage.timesLen;
 
 module.exports = app => {
     class StageDetail extends app.BaseService {
@@ -32,10 +33,10 @@ module.exports = app => {
             const lidSql = lid ? ' And Bills.lid in (?)' : '';
             const sql = 'SELECT * FROM ' + this.tableName + ' As Bills ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `lid`, `uuid` From ' + this.tableName +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid`, `uuid` From ' + this.tableName +
                 '      GROUP BY `lid`, `uuid`' +
                 '  ) As MaxFilter ' +
-                '  ON Bills.times = MaxFilter.times And Bills.order = MaxFilter.order And Bills.lid = MaxFilter.lid And Bills.uuid = MaxFilter.uuid' +
+                '  ON (Bills.times * ' + timesLen + ' + Bills.order) = MaxFilter.flow And Bills.lid = MaxFilter.lid And Bills.uuid = MaxFilter.uuid' +
                 '  WHERE Bills.tid = ? And Bills.sid = ?' + lidSql;
             const sqlParam = [tid, sid];
             if (!lid) {
@@ -62,11 +63,11 @@ module.exports = app => {
             const lidSql = lid ? ' And Bills.lid in (?)' : '';
             const sql = 'SELECT * FROM ' + this.tableName + ' As Bills ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `lid`, `uuid` From ' + this.tableName +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid`, `uuid` From ' + this.tableName +
                 '      WHERE `tid` = ? And `sid` = ? And (`times` < ? OR (`times` = ? And `order` <= ?))' + lidSql +
                 '      GROUP BY `lid`, `uuid`' +
                 '  ) As MaxFilter ' +
-                '  ON Bills.times = MaxFilter.times And Bills.order = MaxFilter.order And Bills.lid = MaxFilter.lid And Bills.uuid = MaxFilter.uuid' +
+                '  ON (Bills.times * ' + timesLen + ' + Bills.order) = MaxFilter.flow And Bills.lid = MaxFilter.lid And Bills.uuid = MaxFilter.uuid' +
                 '  WHERE Bills.tid = ? And Bills.sid = ?' + lidSql;
             const sqlParam = [tid, sid, times, times, order, tid, sid];
             if (!lid) {
@@ -91,11 +92,11 @@ module.exports = app => {
         async getLastestImStageData(tid, sid, lid, uuid) {
             const sql = 'SELECT * FROM ' + this.tableName + ' As Bills ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `lid`, `uuid` From ' + this.tableName +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid`, `uuid` From ' + this.tableName +
                 '      WHERE lid = ? And uuid = ?' +
                 '      GROUP BY `lid`, `uuid`' +
                 '  ) As MaxFilter ' +
-                '  ON Bills.times = MaxFilter.times And Bills.order = MaxFilter.order And Bills.lid = MaxFilter.lid And Bills.uuid = MaxFilter.uuid' +
+                '  ON (Bills.times * ' + timesLen + ' + Bills.order) = MaxFilter.flow And Bills.lid = MaxFilter.lid And Bills.uuid = MaxFilter.uuid' +
                 '  WHERE Bills.tid = ? And Bills.sid = ?';
             const sqlParam = [lid, uuid, tid, sid];
             return await this.db.queryOne(sql, sqlParam);

+ 6 - 4
app/service/stage_pay.js

@@ -8,6 +8,8 @@
  * @version
  */
 
+const timesLen = require('../const/audit').stage.timesLen;
+
 module.exports = app => {
     class StagePay extends app.BaseService {
         /**
@@ -128,11 +130,11 @@ module.exports = app => {
         async getStageLastestPays(sid) {
             const sql = 'SELECT SP.*, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
                 '  FROM ?? As SP, ?? As P, ( ' +
-                '    SELECT MAX(`times`) As `stimes`, MAX(`order`) As `sorder` ' +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `sprogress` ' +
                 '      FROM ?? ' +
                 '      WHERE `sid` = ? ' +
                 '      GROUP BY `sid`) As M' +
-                '  WHERE SP.`sid` = ? AND SP.`stimes` = M.`stimes` AND SP.`sorder` = M.`sorder` AND SP.`pid` = P.`id` AND P.`valid` = true' +
+                '  WHERE SP.`sid` = ? AND (SP.`stimes` * ' + timesLen + ' + `order`) = M.`sprogress` AND SP.`pid` = P.`id` AND P.`valid` = true' +
                 '  ORDER BY P.`order`';
             const sqlParam = [this.tableName, this.ctx.service.pay.tableName, this.ctx.service.stageAudit.tableName,
                 sid, sid];
@@ -230,8 +232,8 @@ module.exports = app => {
             if (!stage || !transaction || !times || order === undefined) {
                 throw '数据错误';
             }
-            const sql = 'INSERT INTO ?? (`tid`, `sid`, `pid`, `stimes`, `sorder`, `expr`, `pause`, `attachment`, `pre_tp`) ' +
-                        '  SELECT SP.`tid`, SP.`sid`, SP.`pid`, ?, ?, SP.`expr`, SP.`pause`, SP.`attachment`, SP.`pre_tp` ' +
+            const sql = 'INSERT INTO ?? (`tid`, `sid`, `pid`, `stimes`, `sorder`, `tp`, `expr`, `pause`, `attachment`, `pre_tp`) ' +
+                        '  SELECT SP.`tid`, SP.`sid`, SP.`pid`, ?, ?, SP.`tp`, SP.`expr`, SP.`pause`, SP.`attachment`, SP.`pre_tp` ' +
                         '  FROM ?? As SP, ?? As P ' +
                         '  WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? And SP.`pid` = P.`id` And P.`valid`';
             const sqlParam = [this.tableName, times, order, this.tableName, this.ctx.service.pay.tableName,

+ 7 - 6
app/service/stage_pos.js

@@ -9,6 +9,7 @@
  */
 
 const measureType = require('../const/tender').measureType;
+const timesLen = require('../const/audit').stage.timesLen;
 
 module.exports = app => {
     class StagePos extends app.BaseService {
@@ -42,11 +43,11 @@ module.exports = app => {
             }
             const sql = 'SELECT * FROM ' + this.tableName + ' As Pos ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `tid`, `sid`, `pid` From ' + this.tableName +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `tid`, `sid`, `pid` From ' + this.tableName +
                 '      WHERE `tid` = ? And sid = ?' + pidSql +
                 '      GROUP BY `pid`' +
                 '  ) As MaxFilter ' +
-                '  ON Pos.times = MaxFilter.times And Pos.order = MaxFilter.order And Pos.pid = MaxFilter.pid' +
+                '  ON (Pos.times * ' + timesLen + ' + Pos.order) = MaxFilter.flow And Pos.pid = MaxFilter.pid' +
                 '    And Pos.`tid` = MaxFilter.`tid` And Pos.`sid` = MaxFilter.`sid`';
             const sqlParam = [tid, sid];
             if (!pid) {
@@ -75,11 +76,11 @@ module.exports = app => {
             }
             const sql = 'SELECT * FROM ' + this.tableName + ' As Pos ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `pid` From ' + this.tableName +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `pid` From ' + this.tableName +
                 '      WHERE `times` < ? OR (`times` = ? AND `order` <= ?)' +
                 '      GROUP BY `pid`' +
                 '  ) As MaxFilter ' +
-                '  ON Pos.times = MaxFilter.times And Pos.order = MaxFilter.order And Pos.pid = MaxFilter.pid' +
+                '  ON (Pos.times * ' + timesLen + ' + Pos.order) = MaxFilter.flow And Pos.pid = MaxFilter.pid' +
                 '  WHERE Pos.tid = ? And Pos.sid = ?' + pidSql;
             const sqlParam = [times, times, order, tid, sid];
             if (!pid) {
@@ -306,12 +307,12 @@ module.exports = app => {
             const calcQtySql = 'SELECT SUM(`contract_qty`) As `contract_qty`, SUM(`qc_qty`) As `qc_qty` FROM (' +
                 '  SELECT `contract_qty`, `qc_qty` FROM ' + this.ctx.service.stagePos.tableName + ' As Pos ' +
                 '    INNER JOIN (' +
-                '      SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `pid` ' +
+                '      SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `pid` ' +
                 '        FROM ' + this.ctx.service.stagePos.tableName +
                 '        WHERE `tid` = ? And sid = ? And `lid` = ? ' +
                 '        GROUP BY `pid`' +
                 '    ) As MaxFilter ' +
-                '    ON Pos.times = MaxFilter.times And Pos.order = MaxFilter.order And Pos.pid = MaxFilter.pid ' +
+                '    ON (Pos.times * ' + timesLen + ' + Pos.order) = MaxFilter.flow And Pos.pid = MaxFilter.pid ' +
                 '    WHERE Pos.tid = ? And Pos.sid = ? And Pos.lid = ?' +
                 '  ) As Gather';
             const param = [tid, sid, lid];

+ 6 - 4
app/service/stage_pos_final.js

@@ -8,6 +8,8 @@
  * @version
  */
 
+const timesLen = require('../const/audit').stage.timesLen;
+
 module.exports = app => {
 
     class StagePosFinal extends app.BaseService {
@@ -59,10 +61,10 @@ module.exports = app => {
                             '    FROM (SELECT p.tid, p.sid, p.lid, p.pid, p.contract_qty, p.qc_qty' +
                             '      FROM ' + this.ctx.service.stagePos.tableName + ' AS p' +
                             '      INNER JOIN(' +
-                            '        SELECT Max(`times`) As `times`, MAX(`order`) As `order`, `pid` FROM ' + this.ctx.service.stagePos.tableName +
+                            '        SELECT Max(`times` * ' + timesLen + ' + `order`) As `flow`, `pid` FROM ' + this.ctx.service.stagePos.tableName +
                             '        WHERE `sid` = ?' +
                             '        GROUP By `pid`) As MF' +
-                            '      ON p.times = MF.times AND p.order = MF.order AND p.pid = MF.pid' +
+                            '      ON (p.times * ' + timesLen + ' + p.order) = MF.flow AND p.pid = MF.pid' +
                             '      WHERE p.sid = ?) As cur' +
                             '    LEFT JOIN ?? As pre' +
                             '    ON cur.pid = pre.pid AND pre.sorder = ?';
@@ -73,10 +75,10 @@ module.exports = app => {
                             '  SELECT p.tid, p.sid, p.lid, p.pid, ? As `sorder`, p.contract_qty, p.qc_qty' +
                             '  FROM ' + this.ctx.service.stagePos.tableName + ' AS p' +
                             '  INNER JOIN(' +
-                            '    SELECT Max(`times`) As `times`, MAX(`order`) As `order`, `pid` FROM ' + this.ctx.service.stagePos.tableName +
+                            '    SELECT Max(`times` * ' + timesLen +' + `order`) As `flow`, `pid` FROM ' + this.ctx.service.stagePos.tableName +
                             '    WHERE `sid` = ?' +
                             '    GROUP By `pid`) As MF' +
-                            '  ON p.times = MF.times AND p.order = MF.order AND p.pid = MF.pid' +
+                            '  ON (p.times * ' + timesLen + ' + p.order) = MF.flow AND p.pid = MF.pid' +
                             '  WHERE p.sid = ?';
                 const sqlParam = [this.tableName, stage.order, stage.id, stage.id];
                 await transaction.query(sql, sqlParam);