|
@@ -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 ' +
|