|
@@ -606,12 +606,25 @@ module.exports = app => {
|
|
|
* @return {Promise<Array>} 查询结果集
|
|
|
*/
|
|
|
async getAuditGroupByList(tender_id, times = 1, transaction = null) {
|
|
|
+ // const sql =
|
|
|
+ // 'SELECT la.`audit_id`, la.`status`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.`audit_order` ' +
|
|
|
+ // ' FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
|
|
|
+ // ' WHERE la.`tender_id` = ? and la.`times` = ? GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
|
|
|
+ // const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tender_id, times];
|
|
|
+ // return transaction ? await transaction.query(sql, sqlParam) : await this.db.query(sql, sqlParam);
|
|
|
const sql =
|
|
|
'SELECT la.`audit_id`, la.`status`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.`audit_order` ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
|
|
|
- ' WHERE la.`tender_id` = ? and la.`times` = ? GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
|
|
|
+ ' WHERE la.`tender_id` = ? and la.`times` = ? ORDER BY la.`audit_order` DESC';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tender_id, times];
|
|
|
- return transaction ? await transaction.query(sql, sqlParam) : await this.db.query(sql, sqlParam);
|
|
|
+ const result = transaction ? await transaction.query(sql, sqlParam) : await this.db.query(sql, sqlParam);
|
|
|
+ const audits = [];
|
|
|
+ for (const r of result) {
|
|
|
+ if (audits.findIndex(a => a.audit_id === r.audit_id) === -1) {
|
|
|
+ audits.push(r);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return audits.reverse();
|
|
|
}
|
|
|
|
|
|
/**
|