Browse Source

调整sql及变更清单列表

ellisran 6 months ago
parent
commit
4465146d45

+ 36 - 33
app/service/change.js

@@ -341,7 +341,7 @@ module.exports = app => {
                         sql =
                             'SELECT a.* FROM ?? AS a WHERE a.tid = ? AND' +
                             ' (a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
-                            ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid))' +
+                            // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
                             ' OR a.status = ?)' + stateSql;
                         sqlParam = [
                             this.tableName,
@@ -350,9 +350,9 @@ module.exports = app => {
                             audit.change.status.uncheck,
                             this.ctx.service.changeAudit.tableName,
                             this.ctx.session.sessionUser.accountId,
-                            audit.change.status.checkNo,
-                            this.ctx.service.changeAudit.tableName,
-                            this.ctx.session.sessionUser.accountId,
+                            // audit.change.status.checkNo,
+                            // this.ctx.service.changeAudit.tableName,
+                            // this.ctx.session.sessionUser.accountId,
                             audit.change.status.checked,
                         ];
                         break;
@@ -364,8 +364,9 @@ module.exports = app => {
                         sql =
                             'SELECT a.* FROM ?? AS a WHERE' +
                             ' (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
-                            (this.ctx.session.sessionUser.is_admin ? '' : ' AND ((a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
-                            ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid)))');
+                            (this.ctx.session.sessionUser.is_admin ? '' : ' AND (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))'
+                            // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)))'
+                            );
                         sqlParam = [
                             this.tableName,
                             audit.change.status.uncheck,
@@ -375,18 +376,18 @@ module.exports = app => {
                             audit.change.status.uncheck,
                             this.ctx.service.changeAudit.tableName,
                             this.ctx.session.sessionUser.accountId,
-                            audit.change.status.checkNo,
-                            this.ctx.service.changeAudit.tableName,
-                            this.ctx.session.sessionUser.accountId,
+                            // audit.change.status.checkNo,
+                            // this.ctx.service.changeAudit.tableName,
+                            // this.ctx.session.sessionUser.accountId,
                         ];
                         break;
                     case 2: // 进行中(所有的)
                     case 4: // 终止(所有的)
                         sql =
                             'SELECT a.* FROM ?? AS a WHERE ' +
-                            'a.status = ? AND a.tid = ?' + stateSql +
+                            '(a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
                             (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)');
-                        sqlParam = [this.tableName, status, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
+                        sqlParam = [this.tableName, status, audit.change.status.checkNoPre, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
                         break;
                     case 3: // 已完成(所有的)
                         sql = 'SELECT a.* FROM ?? AS a WHERE a.status = ? AND a.tid = ?' + stateSql;
@@ -434,7 +435,7 @@ module.exports = app => {
                     const sql =
                         'SELECT count(*) AS count FROM ?? AS a WHERE a.tid = ? AND ' +
                         '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
-                        ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid))' +
+                        // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
                         ' OR a.status = ? )' + stateSql;
                     const sqlParam = [
                         this.tableName,
@@ -443,9 +444,9 @@ module.exports = app => {
                         audit.change.status.uncheck,
                         this.ctx.service.changeAudit.tableName,
                         this.ctx.session.sessionUser.accountId,
-                        audit.change.status.checkNo,
-                        this.ctx.service.changeAudit.tableName,
-                        this.ctx.session.sessionUser.accountId,
+                        // audit.change.status.checkNo,
+                        // this.ctx.service.changeAudit.tableName,
+                        // this.ctx.session.sessionUser.accountId,
                         audit.change.status.checked,
                     ];
                     const result = await this.db.query(sql, sqlParam);
@@ -464,8 +465,9 @@ module.exports = app => {
                     const sql2 =
                         'SELECT count(*) AS count FROM ?? AS a WHERE' +
                         ' (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
-                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND ((a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
-                            ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid)))');
+                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))'
+                        // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)))'
+                        );
                     const sqlParam2 = [
                         this.tableName,
                         audit.change.status.uncheck,
@@ -475,9 +477,9 @@ module.exports = app => {
                         audit.change.status.uncheck,
                         this.ctx.service.changeAudit.tableName,
                         this.ctx.session.sessionUser.accountId,
-                        audit.change.status.checkNo,
-                        this.ctx.service.changeAudit.tableName,
-                        this.ctx.session.sessionUser.accountId,
+                        // audit.change.status.checkNo,
+                        // this.ctx.service.changeAudit.tableName,
+                        // this.ctx.session.sessionUser.accountId,
                     ];
                     const result2 = await this.db.query(sql2, sqlParam2);
                     return result2[0].count;
@@ -485,9 +487,9 @@ module.exports = app => {
                 case 4: // 终止(所有的)
                     const sql3 =
                         'SELECT count(*) AS count FROM ?? AS a WHERE ' +
-                        'a.status = ? AND a.tid = ?' + stateSql +
+                        '(a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
                         (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)');
-                    const sqlParam3 = [this.tableName, status, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
+                    const sqlParam3 = [this.tableName, status, audit.change.status.checkNoPre, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
                     const result3 = await this.db.query(sql3, sqlParam3);
                     return result3[0].count;
                 case 3: // 已完成(所有的)
@@ -513,7 +515,7 @@ module.exports = app => {
                     const sql =
                         'SELECT SUM(cast (a.total_price as decimal(18,6))) AS total_price FROM ?? AS a WHERE a.tid = ? AND ' +
                         '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
-                        ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid))' +
+                        // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid))' +
                         ' OR a.status = ? )' + stateSql;
                     const sqlParam = [
                         this.tableName,
@@ -522,9 +524,9 @@ module.exports = app => {
                         audit.change.status.uncheck,
                         this.ctx.service.changeAudit.tableName,
                         this.ctx.session.sessionUser.accountId,
-                        audit.change.status.checkNo,
-                        this.ctx.service.changeAudit.tableName,
-                        this.ctx.session.sessionUser.accountId,
+                        // audit.change.status.checkNo,
+                        // this.ctx.service.changeAudit.tableName,
+                        // this.ctx.session.sessionUser.accountId,
                         audit.change.status.checked,
                     ];
                     const result = await this.db.query(sql, sqlParam);
@@ -538,8 +540,9 @@ module.exports = app => {
                     const sql2 =
                         'SELECT SUM(cast (a.total_price as decimal(18,6))) AS total_price FROM ?? AS a WHERE' +
                         ' (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
-                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND ((a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
-                            ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid)))');
+                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))'
+                        // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid)))'
+                        );
                     const sqlParam2 = [
                         this.tableName,
                         audit.change.status.uncheck,
@@ -549,9 +552,9 @@ module.exports = app => {
                         audit.change.status.uncheck,
                         this.ctx.service.changeAudit.tableName,
                         this.ctx.session.sessionUser.accountId,
-                        audit.change.status.checkNo,
-                        this.ctx.service.changeAudit.tableName,
-                        this.ctx.session.sessionUser.accountId,
+                        // audit.change.status.checkNo,
+                        // this.ctx.service.changeAudit.tableName,
+                        // this.ctx.session.sessionUser.accountId,
                     ];
                     const result2 = await this.db.query(sql2, sqlParam2);
                     return result2[0].total_price ? result2[0].total_price : 0;
@@ -559,9 +562,9 @@ module.exports = app => {
                 case 4: // 终止(所有的)
                     const sql3 =
                         'SELECT SUM(cast (a.total_price as decimal(18,6))) AS total_price FROM ?? AS a WHERE ' +
-                        'a.status = ? AND a.tid = ?' + stateSql +
+                        '(a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
                         (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)');
-                    const sqlParam3 = [this.tableName, status, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
+                    const sqlParam3 = [this.tableName, status, audit.change.status.checkNoPre, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
                     const result3 = await this.db.query(sql3, sqlParam3);
                     return result3[0].total_price ? result3[0].total_price : 0;
                 case 3: // 已完成(所有的)

+ 0 - 3
app/service/change_apply.js

@@ -184,7 +184,6 @@ module.exports = app => {
                     case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
                         sql =
                             'SELECT a.*, p.name as account_name FROM ?? AS a LEFT JOIN ?? AS p On a.notice_uid = p.id WHERE ' +
-                            // 'a.id IN (SELECT b.caid FROM ?? AS b WHERE b.aid = ? AND a.times = b.times GROUP BY b.caid) AND ' +
                             'a.uid = ? AND a.tid = ? AND (a.status = ? OR a.status = ? OR a.status = ?)';
                         sqlParam = [
                             this.tableName,
@@ -281,7 +280,6 @@ module.exports = app => {
                 case 5: // 待上报(所有的)PS:取未上报,退回的变更立项
                     const sql2 =
                         'SELECT count(*) AS count FROM ?? AS a WHERE ' +
-                        // 'a.id IN (SELECT b.caid FROM ?? AS b WHERE b.aid = ? AND a.times = b.times GROUP BY b.caid) ' +
                         'a.uid = ? AND a.tid = ? AND (a.status = ? OR a.status = ? OR a.status = ?)';
                     const sqlParam2 = [
                         this.tableName,
@@ -354,7 +352,6 @@ module.exports = app => {
                 case 5: // 待上报(所有的)PS:取未上报,退回的变更立项
                     const sql2 =
                         'SELECT SUM(cast (a.total_price as decimal(18,6))) AS total_price FROM ?? AS a WHERE ' +
-                        // 'a.id IN (SELECT b.caid FROM ?? AS b WHERE b.aid = ? AND a.times = b.times GROUP BY b.caid) ' +
                         'a.uid = ? AND a.tid = ? AND (a.status = ? OR a.status = ? OR a.status = ?)';
                     const sqlParam2 = [
                         this.tableName,

+ 0 - 2
app/service/change_plan.js

@@ -205,7 +205,6 @@ module.exports = app => {
                     case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
                         sql =
                             'SELECT a.*, p.name as account_name FROM ?? AS a LEFT JOIN ?? AS p On a.uid = p.id WHERE ' +
-                            // 'a.id IN (SELECT b.cpid FROM ?? AS b WHERE b.aid = ? AND a.times = b.times GROUP BY b.cpid) AND ' +
                             'a.uid = ? AND a.tid = ? AND (a.status = ? OR a.status = ? OR a.status = ?)';
                         sqlParam = [
                             this.tableName,
@@ -302,7 +301,6 @@ module.exports = app => {
                 case 5: // 待上报(所有的)PS:取未上报,退回的变更立项
                     const sql2 =
                         'SELECT count(*) AS count FROM ?? AS a WHERE ' +
-                        // 'a.id IN (SELECT b.cpid FROM ?? AS b WHERE b.aid = ? AND a.times = b.times GROUP BY b.cpid) ' +
                         'a.uid = ? AND a.tid = ? AND (a.status = ? OR a.status = ? OR a.status = ?)';
                     const sqlParam2 = [
                         this.tableName,

+ 0 - 2
app/service/change_project.js

@@ -188,7 +188,6 @@ module.exports = app => {
                     case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
                         sql =
                             'SELECT a.*, p.name as account_name FROM ?? AS a LEFT JOIN ?? AS p On a.uid = p.id WHERE ' +
-                            // 'a.id IN (SELECT b.cpid FROM ?? AS b WHERE b.aid = ? AND a.times = b.times GROUP BY b.cpid) AND ' +
                             'a.uid = ? AND a.tid = ? AND (a.status = ? OR a.status = ? OR a.status = ?)';
                         sqlParam = [
                             this.tableName,
@@ -316,7 +315,6 @@ module.exports = app => {
                 case 5: // 待上报(所有的)PS:取未上报,退回的变更立项
                     const sql2 =
                         'SELECT count(*) AS count FROM ?? AS a WHERE ' +
-                        // 'a.id IN (SELECT b.cpid FROM ?? AS b WHERE b.aid = ? AND a.times = b.times GROUP BY b.cpid) ' +
                         'a.uid = ? AND a.tid = ? AND (a.status = ? OR a.status = ? OR a.status = ?)';
                     const sqlParam2 = [
                         this.tableName,

+ 0 - 1
app/service/financial_pay.js

@@ -121,7 +121,6 @@ module.exports = app => {
                 case 5: // 待上报(所有的)PS:取未上报,退回的变更立项
                     const sql2 =
                         'SELECT count(*) AS count FROM ?? as a WHERE ' +
-                        // 'a.id IN (SELECT b.cpid FROM ?? AS b WHERE b.aid = ? AND a.times = b.times GROUP BY b.cpid) ' +
                         'a.spid = ?' + addSql + ' AND (a.status = ? OR a.status = ?)';
                     const sqlParam2 = [
                         this.tableName,