|
@@ -397,12 +397,13 @@ module.exports = app => {
|
|
|
* @param auditorId
|
|
|
* @return {Promise<*>}
|
|
|
*/
|
|
|
- async getAuditChangeProject(auditorId) {
|
|
|
+ async getAuditChangeProject(auditorId, spid = '') {
|
|
|
+ const spSql = spid ? ' and t.`spid` = "' + spid + '"' : '';
|
|
|
const sql = 'SELECT ma.`aid`, ma.`times`, ma.`order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`cpid`,' +
|
|
|
' m.`status` As `mstatus`, m.`code` As `mcode`,' +
|
|
|
' t.`name`, t.`project_id`, t.`type`, t.`user_id` ' +
|
|
|
' FROM ?? AS ma LEFT JOIN ?? AS m ON ma.`cpid` = m.`id` LEFT JOIN ?? As t ON ma.`tid` = t.`id`' +
|
|
|
- ' WHERE ((ma.`aid` = ? and ma.`status` = ?) OR (m.`uid` = ? and ma.`status` = ? and m.`status` = ? and ma.`times` = (m.`times`-1)))' +
|
|
|
+ ' WHERE ((ma.`aid` = ? and ma.`status` = ?) OR (m.`uid` = ? and ma.`status` = ? and m.`status` = ? and ma.`times` = (m.`times`-1)))' + spSql +
|
|
|
' ORDER BY ma.`begin_time` DESC';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.changeProject.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checking, auditorId, auditConst.status.back, auditConst.status.back];
|
|
|
const result = await this.db.query(sql, sqlParam);
|
|
@@ -424,7 +425,13 @@ module.exports = app => {
|
|
|
* @param auditorId
|
|
|
* @return {Promise<*>}
|
|
|
*/
|
|
|
- async getCountByChecked(auditorId) {
|
|
|
+ async getCountByChecked(auditorId, spid = '') {
|
|
|
+ if (spid) {
|
|
|
+ const sql = 'SELECT count(*) AS count FROM ?? AS a LEFT JOIN ?? AS t ON a.tid = t.id WHERE a.`aid` = ? AND a.`status` in (' + this.ctx.helper.getInArrStrSqlFilter([auditConst.status.checked, auditConst.status.back, auditConst.status.checkNo]) + ') AND t.`spid` = ?';
|
|
|
+ const sqlParam = [this.tableName, this.ctx.service.tender.tableName, auditorId, spid];
|
|
|
+ const result = await this.db.queryOne(sql, sqlParam);
|
|
|
+ return result.count ? result.count : 0;
|
|
|
+ }
|
|
|
return await this.db.count(this.tableName, { aid: auditorId, status: [auditConst.status.checked, auditConst.status.back, auditConst.status.checkNo] });
|
|
|
}
|
|
|
|
|
@@ -434,10 +441,12 @@ module.exports = app => {
|
|
|
* @param auditorId
|
|
|
* @return {Promise<*>}
|
|
|
*/
|
|
|
- async getLastEndTimeByChecked(auditorId) {
|
|
|
- const sql = 'SELECT `end_time` FROM ?? WHERE `aid` = ? ' +
|
|
|
- 'AND `status` in (' + this.ctx.helper.getInArrStrSqlFilter([auditConst.status.checked, auditConst.status.back, auditConst.status.checkNo]) + ') ORDER BY `end_time` DESC';
|
|
|
- const sqlParam = [this.tableName, auditorId];
|
|
|
+ async getLastEndTimeByChecked(auditorId, spid = '') {
|
|
|
+ const sqSql = spid ? ' AND t.`spid` = "' + spid + '"' : '';
|
|
|
+ const sql = 'SELECT a.`end_time` FROM ?? AS a LEFT JOIN ?? AS t ON a.`tid` = t.`id` WHERE a.`aid` = ? ' +
|
|
|
+ 'AND a.`status` in (' + this.ctx.helper.getInArrStrSqlFilter([auditConst.status.checked, auditConst.status.back, auditConst.status.checkNo]) + ')' + sqSql +
|
|
|
+ ' ORDER BY a.`end_time` DESC';
|
|
|
+ const sqlParam = [this.tableName, this.ctx.service.tender.tableName, auditorId];
|
|
|
const result = await this.db.queryOne(sql, sqlParam);
|
|
|
return result ? result.end_time : null;
|
|
|
}
|
|
@@ -530,7 +539,7 @@ module.exports = app => {
|
|
|
const records = [];
|
|
|
const auditors = await this.getAuditorsWithOwner(cpId, times);
|
|
|
auditors.forEach(audit => {
|
|
|
- records.push({ pid, type: pushType.changeProject, uid: audit.aid, status: auditConst.status.checked, content: noticeContent });
|
|
|
+ records.push({ pid, tid: selfAudit.tid, type: pushType.changeProject, uid: audit.aid, status: auditConst.status.checked, content: noticeContent });
|
|
|
});
|
|
|
await transaction.insert('zh_notice', records);
|
|
|
if (audits.length === 1 || selfAudit.audit_type !== auditType.key.and) {
|
|
@@ -660,9 +669,9 @@ module.exports = app => {
|
|
|
await this.ctx.service.noticeAgain.stopNoticeAgain(transaction, this.tableName, this._.map(updateData, 'id'));
|
|
|
// 添加到消息推送表
|
|
|
const noticeContent = await this.getNoticeContent(pid, selfAudit.tid, cpId, selfAudit.aid, checkData.opinion);
|
|
|
- const records = [{ pid, type: pushType.changeProject, uid: this.ctx.change.uid, status: auditConst.status.back, content: noticeContent }];
|
|
|
+ const records = [{ pid, tid: selfAudit.tid, type: pushType.changeProject, uid: this.ctx.change.uid, status: auditConst.status.back, content: noticeContent }];
|
|
|
auditors.forEach(audit => {
|
|
|
- records.push({ pid, type: pushType.changeProject, uid: audit.aid, status: auditConst.status.back, content: noticeContent });
|
|
|
+ records.push({ pid, tid: selfAudit.tid, type: pushType.changeProject, uid: audit.aid, status: auditConst.status.back, content: noticeContent });
|
|
|
});
|
|
|
await transaction.insert(this.ctx.service.noticePush.tableName, records);
|
|
|
// 同步期信息
|
|
@@ -728,9 +737,9 @@ module.exports = app => {
|
|
|
// 获取推送必要信息
|
|
|
const noticeContent = await this.getNoticeContent(pid, selfAudit.tid, cpId, selfAudit.aid, checkData.opinion);
|
|
|
// 添加推送
|
|
|
- const records = [{ pid, type: pushType.changeProject, uid: this.ctx.change.uid, status: auditConst.status.checkNo, content: noticeContent }];
|
|
|
+ const records = [{ pid, tid: selfAudit.tid, type: pushType.changeProject, uid: this.ctx.change.uid, status: auditConst.status.checkNo, content: noticeContent }];
|
|
|
auditors.forEach(audit => {
|
|
|
- records.push({ pid, type: pushType.changeProject, uid: audit.aid, status: auditConst.status.checkNo, content: noticeContent });
|
|
|
+ records.push({ pid, tid: selfAudit.tid, type: pushType.changeProject, uid: audit.aid, status: auditConst.status.checkNo, content: noticeContent });
|
|
|
});
|
|
|
await transaction.insert('zh_notice', records);
|
|
|
// 本期结束
|
|
@@ -1083,10 +1092,11 @@ module.exports = app => {
|
|
|
// const auditors = await this.db.query(sql, sqlParam);
|
|
|
// 添加到消息推送表
|
|
|
const noticeContent = await this.getNoticeContent(pid, change.tid, change.id, this.ctx.session.sessionUser.accountId, '发起修订');
|
|
|
- const records = [{ pid, type: pushType.changeProject, uid: change.uid, status: auditConst.status.revise, content: noticeContent }];
|
|
|
+ const records = [{ pid, tid: change.tid, type: pushType.changeProject, uid: change.uid, status: auditConst.status.revise, content: noticeContent }];
|
|
|
auditors.forEach(auditor => {
|
|
|
records.push({
|
|
|
pid,
|
|
|
+ tid: change.tid,
|
|
|
type: pushType.changeProject,
|
|
|
uid: auditor.aid,
|
|
|
status: auditConst.status.revise,
|
|
@@ -1150,10 +1160,11 @@ module.exports = app => {
|
|
|
const auditors = await this.getUniqAuditor(change.id, change.times - 1); // 全部参与的审批人
|
|
|
// 添加到消息推送表
|
|
|
const noticeContent = await this.getNoticeContent(pid, change.tid, change.id, this.ctx.session.sessionUser.accountId, '撤销修订');
|
|
|
- const records = [{ pid, type: pushType.changeProject, uid: change.uid, status: auditConst.status.cancelRevise, content: noticeContent }];
|
|
|
+ const records = [{ pid, tid: change.tid, type: pushType.changeProject, uid: change.uid, status: auditConst.status.cancelRevise, content: noticeContent }];
|
|
|
auditors.forEach(auditor => {
|
|
|
records.push({
|
|
|
pid,
|
|
|
+ tid: change.tid,
|
|
|
type: pushType.changeProject,
|
|
|
uid: auditor.aid,
|
|
|
status: auditConst.status.cancelRevise,
|