Browse Source

1.资金监管功能改动,2.质量巡检单ai生成功能wap版

ellisran 3 weeks ago
parent
commit
d4d73b1e7e
2 changed files with 29 additions and 23 deletions
  1. 1 1
      app/controller/financial_controller.js
  2. 28 22
      app/service/financial_pay.js

+ 1 - 1
app/controller/financial_controller.js

@@ -1340,7 +1340,7 @@ module.exports = app => {
                 responseData.data.tenders = hadTender ? await ctx.service.tender.getAllDataByCondition({ where: tenderCondition, columns: ['id', 'name'] }) : [];
                 responseData.data.transferList = tid === null ? await ctx.service.financialTransfer.getAllDataByCondition({ where: { spid: ctx.subProject.id } }) : [];
                 responseData.data.transferTenderList = tid === null ? await ctx.service.financialTransferTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } }) : [];
-                responseData.data.payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, 0, filterTids);
+                responseData.data.payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, null, 0, filterTids);
                 ctx.body = responseData;
             } catch (err) {
                 this.log(err);

+ 28 - 22
app/service/financial_pay.js

@@ -40,8 +40,11 @@ module.exports = app => {
          * @param {int} hadlimit - 分页
          * @return {object} list - 列表
          */
-        async getListByStatus(spid, fpcid, status = 0, tid = null, used = null, hadlimit = 0, sortBy = '', orderBy = '') {
+        async getListByStatus(spid, fpcid = null, status = 0, tid = null, used = null, hadlimit = 0, sortBy = '', orderBy = '') {
             let addSql = '';
+            if (fpcid) {
+                addSql += ' AND a.fpcid = ' + fpcid;
+            }
             if (tid !== null) {
                 if (tid.length === 0) {
                     return [];
@@ -55,19 +58,19 @@ module.exports = app => {
             let sqlParam = '';
             switch (status) {
                 case 0: // 所有
-                    sql = 'SELECT a.* FROM ?? As a WHERE a.spid = ? AND a.fpcid = ?' + addSql;
-                    sqlParam = [this.tableName, spid, fpcid];
+                    sql = 'SELECT a.* FROM ?? As a WHERE a.spid = ?' + addSql;
+                    sqlParam = [this.tableName, spid];
                     break;
                 case 1: // 待处理(你的)
-                    sql = 'SELECT a.* FROM ?? as a WHERE a.spid = ? AND a.fpcid = ?' + addSql + ' AND (a.id in(SELECT b.fpid FROM ?? as b WHERE b.spid = ? AND b.fpcid = ? AND b.aid = ? AND b.status = ?) OR (a.uid = ? AND (a.status = ? OR a.status = ?)))';
-                    sqlParam = [this.tableName, spid, fpcid, this.ctx.service.financialPayAudit.tableName, spid, fpcid, this.ctx.session.sessionUser.accountId, auditConst.status.checking, this.ctx.session.sessionUser.accountId, auditConst.status.uncheck, auditConst.status.checkNo];
+                    sql = 'SELECT a.* FROM ?? as a WHERE a.spid = ?' + addSql + ' AND (a.id in(SELECT b.fpid FROM ?? as b WHERE b.spid = ? AND b.aid = ? AND b.status = ?) OR (a.uid = ? AND (a.status = ? OR a.status = ?)))';
+                    sqlParam = [this.tableName, spid, this.ctx.service.financialPayAudit.tableName, spid, this.ctx.session.sessionUser.accountId, auditConst.status.checking, this.ctx.session.sessionUser.accountId, auditConst.status.uncheck, auditConst.status.checkNo];
                     break;
                 case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
                     sql =
-                        'SELECT a.* FROM ?? as a WHERE a.spid = ? AND a.fpcid = ?' + addSql + ' AND (a.status = ? OR a.status = ?)';
+                        'SELECT a.* FROM ?? as a WHERE a.spid = ?' + addSql + ' AND (a.status = ? OR a.status = ?)';
                     sqlParam = [
                         this.tableName,
-                        spid, fpcid,
+                        spid,
                         auditConst.status.uncheck,
                         auditConst.status.checkNo,
                     ];
@@ -75,14 +78,14 @@ module.exports = app => {
                 case 2: // 进行中(所有的)
                 case 4: // 终止(所有的)
                     sql = 'SELECT a.* FROM ?? as a WHERE ' +
-                        'a.status = ? AND a.spid = ? AND a.fpcid = ?' + addSql + ' AND (a.uid = ? OR ' +
+                        'a.status = ? AND a.spid = ?' + addSql + ' AND (a.uid = ? OR ' +
                         'a.id IN (SELECT b.fpid FROM ?? AS b WHERE b.aid = ? GROUP BY b.fpid))';
-                    sqlParam = [this.tableName, status, spid, fpcid, this.ctx.session.sessionUser.accountId,
+                    sqlParam = [this.tableName, status, spid, this.ctx.session.sessionUser.accountId,
                         this.ctx.service.financialPayAudit.tableName, this.ctx.session.sessionUser.accountId];
                     break;
                 case 3: // 已完成(所有的)
-                    sql = 'SELECT a.* FROM ?? as a WHERE a.status = ? AND a.spid = ? AND a.fpcid = ?' + addSql;
-                    sqlParam = [this.tableName, status, spid, fpcid];
+                    sql = 'SELECT a.* FROM ?? as a WHERE a.status = ? AND a.spid = ?' + addSql;
+                    sqlParam = [this.tableName, status, spid];
                     break;
                 default:
                     break;
@@ -112,8 +115,11 @@ module.exports = app => {
          * @param {int} status - 状态
          * @return {void}
          */
-        async getCountByStatus(spid, fpcid, status = 0, tid = null, used = null) {
+        async getCountByStatus(spid, fpcid = null, status = 0, tid = null, used = null) {
             let addSql = '';
+            if (fpcid) {
+                addSql += ' AND a.fpcid = ' + fpcid;
+            }
             if (tid !== null) {
                 if (tid.length === 0) {
                     return 0;
@@ -125,22 +131,22 @@ module.exports = app => {
             }
             switch (status) {
                 case 0: // 所有
-                    const sql5 = 'SELECT count(*) AS count FROM ?? As a WHERE a.spid = ? AND a.fpcid = ?' + addSql;
-                    const sqlParam5 = [this.tableName, spid, fpcid];
+                    const sql5 = 'SELECT count(*) AS count FROM ?? As a WHERE a.spid = ?' + addSql;
+                    const sqlParam5 = [this.tableName, spid];
                     const result5 = await this.db.query(sql5, sqlParam5);
                     return result5[0].count;
                 case 1: // 待处理(你的)
-                    const sql6 = 'SELECT count(*) AS count FROM ?? as a WHERE a.spid = ? AND a.fpcid = ?' + addSql + ' AND (a.id in(SELECT b.fpid FROM ?? as b WHERE b.spid = ? AND b.fpcid = ? AND b.aid = ? AND b.status = ?) OR (a.uid = ? AND (a.status = ? OR a.status = ?)))';
-                    const sqlParam6 = [this.tableName, spid, fpcid, this.ctx.service.financialPayAudit.tableName, spid, fpcid, this.ctx.session.sessionUser.accountId, auditConst.status.checking, this.ctx.session.sessionUser.accountId, auditConst.status.uncheck, auditConst.status.checkNo];
+                    const sql6 = 'SELECT count(*) AS count FROM ?? as a WHERE a.spid = ?' + addSql + ' AND (a.id in(SELECT b.fpid FROM ?? as b WHERE b.spid = ? AND b.aid = ? AND b.status = ?) OR (a.uid = ? AND (a.status = ? OR a.status = ?)))';
+                    const sqlParam6 = [this.tableName, spid, this.ctx.service.financialPayAudit.tableName, spid, this.ctx.session.sessionUser.accountId, auditConst.status.checking, this.ctx.session.sessionUser.accountId, auditConst.status.uncheck, auditConst.status.checkNo];
                     const result6 = await this.db.query(sql6, sqlParam6);
                     return result6[0].count;
                 case 5: // 待上报(所有的)PS:取未上报,退回的变更立项
                     const sql2 =
                         'SELECT count(*) AS count FROM ?? as a WHERE ' +
-                        'a.spid = ? AND a.fpcid = ?' + addSql + ' AND (a.status = ? OR a.status = ?)';
+                        'a.spid = ?' + addSql + ' AND (a.status = ? OR a.status = ?)';
                     const sqlParam2 = [
                         this.tableName,
-                        spid, fpcid,
+                        spid,
                         auditConst.status.uncheck,
                         auditConst.status.checkNo,
                     ];
@@ -150,13 +156,13 @@ module.exports = app => {
                 case 4: // 终止(所有的)
                     const sql3 =
                         'SELECT count(*) AS count FROM ?? as a WHERE ' +
-                        'a.status = ? AND a.spid = ? AND a.fpcid = ?' + addSql + ' AND (a.uid = ? OR a.id IN (SELECT b.fpid FROM ?? AS b WHERE b.aid = ? GROUP BY b.fpid))';
-                    const sqlParam3 = [this.tableName, status, spid, fpcid, this.ctx.session.sessionUser.accountId, this.ctx.service.financialPayAudit.tableName, this.ctx.session.sessionUser.accountId];
+                        'a.status = ? AND a.spid = ?' + addSql + ' AND (a.uid = ? OR a.id IN (SELECT b.fpid FROM ?? AS b WHERE b.aid = ? GROUP BY b.fpid))';
+                    const sqlParam3 = [this.tableName, status, spid, this.ctx.session.sessionUser.accountId, this.ctx.service.financialPayAudit.tableName, this.ctx.session.sessionUser.accountId];
                     const result3 = await this.db.query(sql3, sqlParam3);
                     return result3[0].count;
                 case 3: // 已完成(所有的)
-                    const sql4 = 'SELECT count(*) AS count FROM ?? as a WHERE a.status = ? AND a.spid = ? AND a.fpcid = ?' + addSql;
-                    const sqlParam4 = [this.tableName, status, spid, fpcid];
+                    const sql4 = 'SELECT count(*) AS count FROM ?? as a WHERE a.status = ? AND a.spid = ?' + addSql;
+                    const sqlParam4 = [this.tableName, status, spid];
                     const result4 = await this.db.query(sql4, sqlParam4);
                     return result4[0].count;
                 default: