|
@@ -73,7 +73,7 @@ module.exports = app => {
|
|
|
* @return {Promise<*>}
|
|
|
*/
|
|
|
async getAuditGroupByList(changeId, times) {
|
|
|
- const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`cpid`, la.`aid`, la.`order` ' +
|
|
|
+ const sql = 'SELECT pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`cpid`, la.`aid`, la.`order` ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id`' +
|
|
|
' WHERE la.`cpid` = ? and la.`times` = ? and la.`status` != ? and la.`status` != ? GROUP BY la.`aid` ORDER BY la.`order`';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, changeId, times, auditConst.status.revise, auditConst.status.cancelRevise];
|
|
@@ -472,15 +472,26 @@ module.exports = app => {
|
|
|
if (!audit) {
|
|
|
throw '审核数据错误';
|
|
|
}
|
|
|
- const sql = 'SELECT `tid`, `cpid`, `aid`, `order` FROM ?? WHERE `cpid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC';
|
|
|
- const sqlParam = [this.tableName, cpId, times];
|
|
|
- const auditors = await this.db.query(sql, sqlParam);
|
|
|
+ // 需要剔除原报可能存在修订进入流程的情况
|
|
|
+ // const sql = 'SELECT `tid`, `cpid`, `aid`, `order` FROM ?? WHERE `cpid` = ? and `times` = ? and `status` != ? AND `status` != ? GROUP BY `aid` ORDER BY `id` ASC';
|
|
|
+ // const sqlParam = [this.tableName, cpId, times];
|
|
|
+ // const auditors = await this.db.query(sql, sqlParam);
|
|
|
+ const auditors = await this.getAuditGroupByList(cpId, times);
|
|
|
let order = 1;
|
|
|
+ const newAuditors = [];
|
|
|
for (const a of auditors) {
|
|
|
a.times = times + 1;
|
|
|
a.order = order;
|
|
|
a.status = auditConst.status.uncheck;
|
|
|
order++;
|
|
|
+ newAuditors.push({
|
|
|
+ tid: a.tid,
|
|
|
+ cpid: cpId,
|
|
|
+ times: a.times,
|
|
|
+ order: a.order,
|
|
|
+ status: a.status,
|
|
|
+ aid: a.aid,
|
|
|
+ });
|
|
|
}
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
@@ -498,7 +509,7 @@ module.exports = app => {
|
|
|
times: times + 1,
|
|
|
});
|
|
|
// 拷贝新一次审核流程列表
|
|
|
- await transaction.insert(this.tableName, auditors);
|
|
|
+ await transaction.insert(this.tableName, newAuditors);
|
|
|
// 微信模板通知
|
|
|
const users = this._.uniq(this._.concat(this._.map(auditors, 'aid'), this.ctx.change.uid));
|
|
|
const wechatData = {
|