Browse Source

变更清单调用后,再取消调用, 然后工程变更中删除变更清单后,调用变更令显示相关

MaiXinRong 4 years ago
parent
commit
028b813152
2 changed files with 26 additions and 14 deletions
  1. 1 1
      app/extend/helper.js
  2. 25 13
      app/service/stage_change.js

+ 1 - 1
app/extend/helper.js

@@ -1190,7 +1190,7 @@ module.exports = {
                 checkData[f.tp] = b[f.tp] || 0;
                 calcData[f.tp] = this.mul(b.unit_price, b[f.qty], decimal.tp) || 0;
             }
-            if (!_.isMatch(checkData, calcData)) {
+            if (!this._.isMatch(checkData, calcData)) {
                 result.error.push({
                     ledger_id: b.ledger_id,
                     b_code: b.b_code,

+ 25 - 13
app/service/stage_change.js

@@ -40,13 +40,16 @@ module.exports = app => {
                 '  oc.p_code As c_code, oc.new_code As c_new_code' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid` From ' + this.tableName +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
                 '      WHERE tid = ? And sid = ? And lid = ? And pid = ?' +
-                '      GROUP By `lid`, `pid`' +
+                '      GROUP By `lid`, `pid`, `cid`, `cbid`' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
-                '  ON c.cid = oc.cid';
+                '  ON c.cid = oc.cid' +
+                '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
+                '  ON c.cbid = ocb.id' +
+                '  WHERE not ISNULL(ocb.id)';
             const sqlParam = [tid, sid, lid, pid ? pid : -1];
             return await this.db.query(sql, sqlParam);
         }
@@ -66,13 +69,16 @@ module.exports = app => {
                 '  oc.p_code As c_code, oc.new_code As c_new_code' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid` From ' + this.tableName +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
                 '      WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?)) And lid = ? And pid = ?' +
                 '      GROUP By `lid`, `pid`' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
-                '  ON c.cid = oc.cid';
+                '  ON c.cid = oc.cid' +
+                '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
+                '  ON c.cbid = ocb.id' +
+                '  WHERE not ISNULL(ocb.id)';
             const sqlParam = [tid, sid, times, times, order, lid, pid ? pid : -1];
             return await this.db.query(sql, sqlParam);
         }
@@ -82,13 +88,16 @@ module.exports = app => {
                 '  oc.p_code As c_code, oc.new_code As c_new_code' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid` From ' + this.tableName +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
                 '      WHERE tid = ? And sid = ?' +
                 '      GROUP By `lid`, `pid`' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
-                '  ON c.cid = oc.cid';
+                '  ON c.cid = oc.cid'+
+                '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
+                '  ON c.cbid = ocb.id' +
+                '  WHERE not ISNULL(ocb.id)';
             const sqlParam = [tid, sid];
             return await this.db.query(sql, sqlParam);
         }
@@ -98,13 +107,16 @@ module.exports = app => {
                 '  oc.p_code As c_code, oc.new_code As c_new_code' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid` From ' + this.tableName +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
                 '      WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?))' +
                 '      GROUP By `lid`, `pid`' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
-                '  ON c.cid = oc.cid';
+                '  ON c.cid = oc.cid'+
+                '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
+                '  ON c.cbid = ocb.id' +
+                '  WHERE not ISNULL(ocb.id)';
             const sqlParam = [tid, sid, times, times, order];
             return await this.db.query(sql, sqlParam);
         }