|
@@ -36,13 +36,17 @@ module.exports = app => {
|
|
|
* @returns {Promise<*>}
|
|
|
*/
|
|
|
async getLastestStageData(tid, sid, lid, pid) {
|
|
|
- const sql = 'SELECT c.* FROM ' + this.tableName + ' As c ' +
|
|
|
+ const sql = 'SELECT c.*,' +
|
|
|
+ ' oc.code As c_code, oc.new_code As c_new_code' +
|
|
|
+ ' FROM ' + this.tableName + ' As c ' +
|
|
|
' INNER JOIN ( ' +
|
|
|
' SELECT MAX(`stimes`) As `stimes`, MAX(`sorder`) As `sorder`, `lid`, `pid`, `sid` From ' + this.tableName +
|
|
|
' WHERE tid = ? And sid = ? And lid = ? And pid = ?' +
|
|
|
' GROUP By `lid`, `pid`' +
|
|
|
' ) As m ' +
|
|
|
- ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid`';
|
|
|
+ ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid`' +
|
|
|
+ ' LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
|
|
|
+ ' ON c.cid = oc.cid';
|
|
|
const sqlParam = [tid, sid, lid, pid ? pid : -1];
|
|
|
return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
@@ -58,7 +62,7 @@ module.exports = app => {
|
|
|
* @returns {Promise<*>}
|
|
|
*/
|
|
|
async getAuditorStageData(tid, sid, times, order, lid, pid) {
|
|
|
- const sql = 'SELECT c.*' +
|
|
|
+ const sql = 'SELECT c.*,' +
|
|
|
' oc.code As c_code, oc.new_code As c_new_code' +
|
|
|
' FROM ' + this.tableName + ' As c ' +
|
|
|
' INNER JOIN ( ' +
|
|
@@ -66,9 +70,9 @@ module.exports = app => {
|
|
|
' WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?)) And lid = ? And pid = ?' +
|
|
|
' GROUP By `lid`, `pid`' +
|
|
|
' ) As m ' +
|
|
|
- ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid`'
|
|
|
- ' LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
|
|
|
- ' ON c.cid = oc.cid';
|
|
|
+ ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid`' +
|
|
|
+ ' LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
|
|
|
+ ' ON c.cid = oc.cid';
|
|
|
const sqlParam = [tid, sid, times, times, order, lid, pid ? pid : -1];
|
|
|
return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
@@ -90,13 +94,17 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
async getAuditorAllStageData(tid, sid, times, order) {
|
|
|
- const sql = 'SELECT c.* FROM ' + this.tableName + ' As c ' +
|
|
|
+ const sql = 'SELECT c.*, ' +
|
|
|
+ ' oc.code As c_code, oc.new_code As c_new_code' +
|
|
|
+ ' FROM ' + this.tableName + ' As c ' +
|
|
|
' INNER JOIN ( ' +
|
|
|
' SELECT MAX(`stimes`) As `stimes`, MAX(`sorder`) As `sorder`, `lid`, `pid`, `sid` From ' + this.tableName +
|
|
|
' WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?))' +
|
|
|
' GROUP By `lid`, `pid`' +
|
|
|
' ) As m ' +
|
|
|
- ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.`sid` = m.`sid`';
|
|
|
+ ' ON c.stimes = m.stimes And c.sorder = m.sorder And c.`sid` = m.`sid`' +
|
|
|
+ ' LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
|
|
|
+ ' ON c.cid = oc.cid';
|
|
|
const sqlParam = [tid, sid, times, times, order];
|
|
|
return await this.db.query(sql, sqlParam);
|
|
|
}
|