|
@@ -373,7 +373,7 @@ module.exports = app => {
|
|
|
' p.name As audit_name, p.role As audit_role, p.company As audit_company' +
|
|
|
' FROM ' + this.tableName + ' AS ra' +
|
|
|
' Left Join ' + this.ctx.service.ledgerRevise.tableName + ' As r On ra.rid = r.id' +
|
|
|
- ' Left Join '+ this.ctx.service.tender.tableName +' AS t On r.tid = t.id' +
|
|
|
+ ' Left Join ' + this.ctx.service.tender.tableName + ' AS t On r.tid = t.id' +
|
|
|
' Left Join ' + this.ctx.service.projectAccount.tableName + ' As p On ra.audit_id = p.id' +
|
|
|
' WHERE r.`valid` != 0 and ((ra.`audit_id` = ? and ra.`status` = ?) OR' +
|
|
|
' (r.`uid` = ? and r.`status` = ? and ra.`status` = ? and ra.`times` = (r.`times`-1)))';
|
|
@@ -389,18 +389,18 @@ module.exports = app => {
|
|
|
* @returns {Promise<*>}
|
|
|
*/
|
|
|
async getNoticeRevise(projectId, auditorId, noticeTime) {
|
|
|
- const sql = 'SELECT ra.`audit_id`, ra.`times`, ra.`audit_order`, ra.`end_time`, ra.`status`,' +
|
|
|
- ' r.id, r.corder, r.uid, r.status, r.content, ' +
|
|
|
+ const sql = 'SELECT * FROM (SELECT ra.`audit_id`, ra.`times`, ra.`audit_order`, ra.`end_time`, ra.`status`,' +
|
|
|
+ ' r.id, r.corder, r.uid, r.status As `r_status`, r.content, ' +
|
|
|
' t.`id` As t_id, t.`name` As t_name, t.`project_id` As t_pid, t.`type` As t_type, t.`user_id` As t_uid, ' +
|
|
|
' pa.name As `ru_name`, pa.role As `ru_role`, pa.company As `ru_company`' +
|
|
|
- ' FROM ' + this.tableName + ' As ra' +
|
|
|
- ' LEFT JOIN ' + this.ctx.service.ledgerRevise.tableName + ' As r ON ra.rid = r.id' +
|
|
|
- ' LEFT JOIN ' + this.ctx.service.tender.tableName + ' As t ON r.`tid` = t.`id`' +
|
|
|
+ ' FROM (SELECT * FROM ?? WHERE `user_id` = ? OR `id` in (SELECT `tender_id` FROM ?? WHERE `audit_id` = ? GROUP BY `tender_id`)) As t' +
|
|
|
+ ' LEFT JOIN ' + this.ctx.service.ledgerRevise.tableName + ' As r ON r.`tid` = t.`id`' +
|
|
|
+ ' LEFT JOIN ' + this.tableName + ' As ra ON ra.rid = r.id' +
|
|
|
' LEFT JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa ON ra.`audit_id` = pa.`id`' +
|
|
|
- ' WHERE ra.audit_id <> ? and ra.end_time > ? and t.project_id = ?' +
|
|
|
- ' GROUP By t.`id`' +
|
|
|
- ' ORDER By ra.`end_time`';
|
|
|
- const sqlParam = [auditorId, noticeTime, projectId];
|
|
|
+ ' WHERE ra.end_time > ? and t.project_id = ?' +
|
|
|
+ ' ORDER By ra.`end_time` DESC LIMIT 1000) as new_t GROUP BY new_t.`id`' +
|
|
|
+ ' ORDER By new_t.`end_time`';
|
|
|
+ const sqlParam = [this.ctx.service.tender.tableName, auditorId, this.tableName, auditorId, noticeTime, projectId];
|
|
|
return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
|