|
@@ -1570,8 +1570,7 @@ module.exports = app => {
|
|
|
' FROM ?? AS sa ' +
|
|
|
' Left Join ?? AS s On sa.`sid` = s.`id` ' +
|
|
|
' Left Join ?? As t ON sa.`tid` = t.`id`' +
|
|
|
- ' WHERE ((sa.`aid` = ? and sa.`status` = ?) OR (s.`user_id` = ? and sa.`status` = ? and s.`status` = ? and sa.`times` = (s.`times`-1))' +
|
|
|
- ' OR (s.`user_id` = ? and s.`status` = ? and sa.`times` = s.`times`))' +
|
|
|
+ ' WHERE (sa.`aid` = ? and sa.`status` = ?) OR (s.`user_id` = ? and sa.`status` = ? and s.`status` = ? and sa.`times` = (s.`times`-1))' +
|
|
|
' ORDER BY sa.`begin_time` DESC';
|
|
|
const sqlParam = [
|
|
|
this.tableName,
|
|
@@ -1582,19 +1581,42 @@ module.exports = app => {
|
|
|
auditorId,
|
|
|
auditConst.status.checkNo,
|
|
|
auditConst.status.checkNo,
|
|
|
- auditorId,
|
|
|
- auditConst.status.uncheck,
|
|
|
];
|
|
|
const result = await this.db.query(sql, sqlParam);
|
|
|
// 过滤result中存在重复sid的值, 保留最新的一条
|
|
|
+ const sql1 = 'SELECT s.`order` As `sorder`, s.`status` AS `sstatus`, s.`in_time` AS `begin_time`,' +
|
|
|
+ ' t.`name`, t.`project_id`, t.`type`, t.`user_id`' +
|
|
|
+ ' FROM ?? AS s' +
|
|
|
+ ' Left Join ?? As t ON s.`tid` = t.`id`' +
|
|
|
+ ' WHERE s.`user_id` = ? and s.`status` != ?' +
|
|
|
+ ' ORDER BY s.`in_time` ASC';
|
|
|
+ const sqlParam1 = [this.ctx.service.stage.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checked];
|
|
|
+ const result1 = await this.db.query(sql1, sqlParam1);
|
|
|
+ const filterResult1 = [];
|
|
|
+ const tidArr = [];
|
|
|
+ for (const res of result1) {
|
|
|
+ if (tidArr.indexOf(res.tid) === -1) {
|
|
|
+ tidArr.push(res.tid);
|
|
|
+ if (res.sstatus === auditConst.status.uncheck) {
|
|
|
+ filterResult1.push(res);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
const filterResult = [];
|
|
|
const sidArr = [];
|
|
|
for (const r of result) {
|
|
|
if (sidArr.indexOf(r.sid) === -1) {
|
|
|
filterResult.push(r);
|
|
|
sidArr.push(r.sid);
|
|
|
+ if (tidArr.indexOf(r.tid) !== -1) {
|
|
|
+ const index = filterResult1.findIndex(item => item.tid === r.tid);
|
|
|
+ if (index !== -1) filterResult1.splice(index, 1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ // 合并并按begin_time排序
|
|
|
+ filterResult.push(...filterResult1);
|
|
|
+ filterResult.sort((a, b) => b.begin_time - a.begin_time);
|
|
|
return filterResult;
|
|
|
}
|
|
|
|