瀏覽代碼

台账、计量单元,注释旧的获取本期数据代码

MaiXinRong 3 年之前
父節點
當前提交
d3f4a5f9a3
共有 4 個文件被更改,包括 75 次插入118 次删除
  1. 1 1
      app/controller/spss_controller.js
  2. 1 4
      app/controller/stage_controller.js
  3. 47 87
      app/service/stage_bills.js
  4. 26 26
      app/service/stage_pos.js

+ 1 - 1
app/controller/spss_controller.js

@@ -90,7 +90,7 @@ module.exports = app => {
             const data = await this._getTzData(tid, true);
             const stage = await this._checkStage(tid, sorder);
             const bills = await this.ctx.service.stageBills.getAuditorStageData2(tid, stage.id, stage.curTimes, stage.curOrder);
-            const pos = await this.ctx.service.stagePos.getAuditorStageData(tid, stage.id, stage.curTimes, stage.curOrder);
+            const pos = await this.ctx.service.stagePos.getAuditorStageData2(tid, stage.id, stage.curTimes, stage.curOrder);
             data.stage = {
                 sid: stage.id, sorder: stage.order, curTimes: stage.curTimes, curOrder: stage.curOrder,
                 bills: bills, pos: pos

+ 1 - 4
app/controller/stage_controller.js

@@ -251,7 +251,6 @@ module.exports = app => {
             // 查询截止上期数据
             if (ctx.stage.order > 1) {
                 preStageData = await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1);
-                // renderData.preStageData = await ctx.service.stageBills.getEndStageData(ctx.tender.id, ctx.stage.order - 1);
             } else {
                 preStageData = [];
             }
@@ -283,7 +282,6 @@ module.exports = app => {
             // console.time('pre');
             if (ctx.stage.order > 1) {
                 preStageData = await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1);
-                // responseData.data.preStageData = await ctx.service.stagePos.getEndStageData(ctx.tender.id, ctx.stage.order - 1);
             } else {
                 preStageData = [];
             }
@@ -418,7 +416,6 @@ module.exports = app => {
                 // console.time('pre');
                 if (ctx.stage.order > 1) {
                     preStageData = await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1);
-                    // responseData.data.preStageData = await ctx.service.stagePos.getEndStageData(ctx.tender.id, ctx.stage.order - 1);
                 } else {
                     preStageData = [];
                 }
@@ -1258,7 +1255,7 @@ module.exports = app => {
                     const compareTimes = ctx.stage.status === auditConst.status.checkNo && !ctx.stage.readOnly
                         ? ctx.stage.curTimes - 1 : ctx.stage.curTimes;
                     data.bills = await ctx.service.stageBills.getAuditorStageData2(ctx.tender.id, ctx.stage.id, compareTimes, order);
-                    data.pos = await ctx.service.stagePos.getAuditorStageData(ctx.tender.id, ctx.stage.id, compareTimes, order);
+                    data.pos = await ctx.service.stagePos.getAuditorStageData2(ctx.tender.id, ctx.stage.id, compareTimes, order);
                     result.roles.push(data);
                 }
                 ctx.body = { err: 0, msg: '', data: result };

+ 47 - 87
app/service/stage_bills.js

@@ -33,32 +33,32 @@ module.exports = app => {
          * @param {Number|Array} lid - 台账节点id(可以为空)
          * @return {Promise<*>}
          */
-        async getLastestStageData(tid, sid, lid) {
-            let lidSql = '',
-                result;
-            if (lid) {
-                if (lid instanceof Array) {
-                    lidSql = lid.length > 0 ? ' And lid in (' + this.ctx.helper.getInArrStrSqlFilter(lid) + ')' : '';
-                } else {
-                    lidSql = ' And lid in (' + this.db.escape(lid) + ')';
-                }
-            }
-            const sql = 'SELECT Bills.* FROM ' + this.departTableName(tid) + ' As Bills ' +
-                        '  INNER JOIN ( ' +
-                        '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.departTableName(tid) +
-                        '      WHERE tid = ? And sid = ?' + lidSql +
-                        '      GROUP BY `lid`' +
-                        '  ) As MaxFilter ' +
-                        '  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);
-            } else if (lid instanceof Array) {
-                return await this.db.query(sql, sqlParam);
-            }
-            return await this.db.queryOne(sql, sqlParam);
-
-        }
+        // async getLastestStageData(tid, sid, lid) {
+        //     let lidSql = '',
+        //         result;
+        //     if (lid) {
+        //         if (lid instanceof Array) {
+        //             lidSql = lid.length > 0 ? ' And lid in (' + this.ctx.helper.getInArrStrSqlFilter(lid) + ')' : '';
+        //         } else {
+        //             lidSql = ' And lid in (' + this.db.escape(lid) + ')';
+        //         }
+        //     }
+        //     const sql = 'SELECT Bills.* FROM ' + this.departTableName(tid) + ' As Bills ' +
+        //                 '  INNER JOIN ( ' +
+        //                 '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.departTableName(tid) +
+        //                 '      WHERE tid = ? And sid = ?' + lidSql +
+        //                 '      GROUP BY `lid`' +
+        //                 '  ) As MaxFilter ' +
+        //                 '  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);
+        //     } else if (lid instanceof Array) {
+        //         return await this.db.query(sql, sqlParam);
+        //     }
+        //     return await this.db.queryOne(sql, sqlParam);
+        //
+        // }
 
         /**
          * 查询 某期 某轮审批 某人数据
@@ -69,27 +69,27 @@ module.exports = app => {
          * @param {Number|Array} lid - 台账节点id(可以为空)
          * @return {Promise<*>}
          */
-        async getAuditorStageData(tid, sid, times, order, lid) {
-            const lidSql = lid ? ' And Bills.lid in (?)' : '';
-            const sql = 'SELECT Bills.* FROM ' + this.departTableName(tid) + ' As Bills ' +
-                '  INNER JOIN ( ' +
-                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `tid`, `sid` From ' + this.departTableName(tid) +
-                '      WHERE (`times` < ? OR (`times` = ? AND `order` <= ?)) And tid = ? And sid = ?' + lidSql +
-                '      GROUP BY `lid`' +
-                '  ) As MaxFilter ' +
-                '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid' +
-                '    AND Bills.sid = MaxFilter.sid';
-            const sqlParam = [times, times, order, tid, sid];
-            if (!lid) {
-                return await this.db.query(sql, sqlParam);
-            } else if (lid instanceof Array) {
-                sqlParam.push(lid.join(', '));
-                return await this.db.query(sql, sqlParam);
-            }
-            sqlParam.push(lid);
-            return await this.db.queryOne(sql, sqlParam);
-
-        }
+        // async getAuditorStageData(tid, sid, times, order, lid) {
+        //     const lidSql = lid ? ' And Bills.lid in (?)' : '';
+        //     const sql = 'SELECT Bills.* FROM ' + this.departTableName(tid) + ' As Bills ' +
+        //         '  INNER JOIN ( ' +
+        //         '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `tid`, `sid` From ' + this.departTableName(tid) +
+        //         '      WHERE (`times` < ? OR (`times` = ? AND `order` <= ?)) And tid = ? And sid = ?' + lidSql +
+        //         '      GROUP BY `lid`' +
+        //         '  ) As MaxFilter ' +
+        //         '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid' +
+        //         '    AND Bills.sid = MaxFilter.sid';
+        //     const sqlParam = [times, times, order, tid, sid];
+        //     if (!lid) {
+        //         return await this.db.query(sql, sqlParam);
+        //     } else if (lid instanceof Array) {
+        //         sqlParam.push(lid.join(', '));
+        //         return await this.db.query(sql, sqlParam);
+        //     }
+        //     sqlParam.push(lid);
+        //     return await this.db.queryOne(sql, sqlParam);
+        //
+        // }
 
         _getFilterSql(where, asTable = '') {
             let whereSql = '';
@@ -140,46 +140,6 @@ module.exports = app => {
             return this._.map(this._.filter(stageBills, 'used'), 'lid');
         }
 
-        /**
-         * 获取截止本期数据
-         * @param {Number} tid - 标段id
-         * @param {Number} sorder - 截止期序号
-         * @param {String|Array[String]} lid - 台账id
-         * @returns {Promise<*>}
-         */
-        async getEndStageData(tid, sorder, lid) {
-            let lidSql = '';
-            if (lid) {
-                if (lid instanceof Array) {
-                    lidSql = lid.length > 0 ? ' And lid in (' + this.ctx.helper.getInArrStrSqlFilter(lid) + ')' : '';
-                } else {
-                    lidSql = ' And lid in (' + this.db.escape(lid) + ')';
-                }
-            }
-
-            const sql = 'SELECT Bills.tid, Bills.lid,' +
-                '  Sum(Bills.contract_qty) As contract_qty, Sum(Bills.contract_tp) As contract_tp,' +
-                '  Sum(Bills.qc_qty) As qc_qty, Sum(Bills.qc_tp) As qc_tp FROM ' + this.tableName + ' As Bills ' +
-                '  INNER JOIN ( ' +
-                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `sid` From ' + this.tableName +
-                '      WHERE tid = ? ' + lidSql +
-                '      GROUP BY `lid`, `sid`' +
-                '  ) As MaxFilter ' +
-                '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid And Bills.`sid` = MaxFilter.`sid`' +
-                '  INNER JOIN ' + this.ctx.service.stage.tableName + ' As Stage' +
-                '  ON Bills.sid = Stage.id' +
-                '  WHERE Stage.order <= ?' +
-                '  GROUP BY `lid`';
-            const sqlParam = [tid, sorder];
-            if (!lid) {
-                return await this.db.query(sql, sqlParam);
-            } else if (lid instanceof Array) {
-                return await this.db.query(sql, sqlParam);
-            }
-            return await this.db.queryOne(sql, sqlParam);
-
-        }
-
         async getStageBills(tid, sid, lid) {
             const sql = 'SELECT Stage.*, Ledger.unit_price FROM ?? As Stage, ?? As Ledger ' +
                         '  Where Stage.tid = ?, Stage.sid = ?, Stage.lid = ?, Stage.lid = Ledger.id ' +

+ 26 - 26
app/service/stage_pos.js

@@ -53,19 +53,19 @@ module.exports = app => {
          * @param {Number|Array} pid - 部位明细id(可以为空)
          * @returns {Promise<*>}
          */
-        async getLastestStageData(tid, sid, where) {
-            const filterSql = this._getPosFilterSql(where);
-            const sql = 'SELECT Pos.id, Pos.tid, Pos.sid, Pos.lid, Pos.pid, Pos.contract_qty, Pos.qc_qty, Pos.postil, Pos.times, Pos.order, Pos.contract_expr FROM ' +
-                '  (SELECT * FROM ' + this.tableName + ' WHERE tid = ? And sid = ?) As Pos ' +
-                '  INNER JOIN ( ' +
-                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `tid`, `sid`, `pid` From ' + this.tableName +
-                '      WHERE `tid` = ? And sid = ?' + filterSql +
-                '      GROUP BY `pid`' +
-                '  ) As MaxFilter ' +
-                '  ON (Pos.times * ' + timesLen + ' + Pos.order) = MaxFilter.flow And Pos.pid = MaxFilter.pid And Pos.sid = MaxFilter.sid';
-            const sqlParam = [tid, sid, tid, sid];
-            return await this.db.query(sql, sqlParam);
-        }
+        // async getLastestStageData(tid, sid, where) {
+        //     const filterSql = this._getPosFilterSql(where);
+        //     const sql = 'SELECT Pos.id, Pos.tid, Pos.sid, Pos.lid, Pos.pid, Pos.contract_qty, Pos.qc_qty, Pos.postil, Pos.times, Pos.order, Pos.contract_expr FROM ' +
+        //         '  (SELECT * FROM ' + this.tableName + ' WHERE tid = ? And sid = ?) As Pos ' +
+        //         '  INNER JOIN ( ' +
+        //         '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `tid`, `sid`, `pid` From ' + this.tableName +
+        //         '      WHERE `tid` = ? And sid = ?' + filterSql +
+        //         '      GROUP BY `pid`' +
+        //         '  ) As MaxFilter ' +
+        //         '  ON (Pos.times * ' + timesLen + ' + Pos.order) = MaxFilter.flow And Pos.pid = MaxFilter.pid And Pos.sid = MaxFilter.sid';
+        //     const sqlParam = [tid, sid, tid, sid];
+        //     return await this.db.query(sql, sqlParam);
+        // }
         /**
          * 查询 某期 某轮审批 某审核人数据
          * @param {Number} tid - 标段id
@@ -75,19 +75,19 @@ module.exports = app => {
          * @param {Number|Array|Null} pid - 部位明细id - 为空则查询全部
          * @returns {Promise<*>}
          */
-        async getAuditorStageData(tid, sid, times, order, where) {
-            const filterSql = this._getPosFilterSql(where);
-            const sql = 'SELECT Pos.id, Pos.tid, Pos.sid, Pos.pid, Pos.lid, Pos.contract_qty, Pos.qc_qty, Pos.postil, Pos.times, Pos.order, Pos.contract_expr FROM ' +
-                '  (SELECT * FROM '+ this.tableName + ' WHERE tid = ? And sid = ?) As Pos ' +
-                '  INNER JOIN ( ' +
-                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `pid`, `sid` From ' + this.tableName +
-                '      WHERE (`times` < ? OR (`times` = ? AND `order` <= ?)) And tid = ? And sid = ?' + filterSql +
-                '      GROUP BY `pid`' +
-                '  ) As MaxFilter ' +
-                '  ON (Pos.times * ' + timesLen + ' + Pos.order) = MaxFilter.flow And Pos.pid = MaxFilter.pid And Pos.sid = MaxFilter.sid';
-            const sqlParam = [tid, sid, times, times, order, tid, sid];
-            return await this.db.query(sql, sqlParam);
-        }
+        // async getAuditorStageData(tid, sid, times, order, where) {
+        //     const filterSql = this._getPosFilterSql(where);
+        //     const sql = 'SELECT Pos.id, Pos.tid, Pos.sid, Pos.pid, Pos.lid, Pos.contract_qty, Pos.qc_qty, Pos.postil, Pos.times, Pos.order, Pos.contract_expr FROM ' +
+        //         '  (SELECT * FROM '+ this.tableName + ' WHERE tid = ? And sid = ?) As Pos ' +
+        //         '  INNER JOIN ( ' +
+        //         '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `pid`, `sid` From ' + this.tableName +
+        //         '      WHERE (`times` < ? OR (`times` = ? AND `order` <= ?)) And tid = ? And sid = ?' + filterSql +
+        //         '      GROUP BY `pid`' +
+        //         '  ) As MaxFilter ' +
+        //         '  ON (Pos.times * ' + timesLen + ' + Pos.order) = MaxFilter.flow And Pos.pid = MaxFilter.pid And Pos.sid = MaxFilter.sid';
+        //     const sqlParam = [tid, sid, times, times, order, tid, sid];
+        //     return await this.db.query(sql, sqlParam);
+        // }
 
         _filterLastestData(stagePos) {
             const stagePosIndex = {};