|
@@ -310,6 +310,7 @@ module.exports = app => {
|
|
|
try {
|
|
|
// 添加推送
|
|
|
const noticeContent = await this.getNoticeContent(pid, audit.tid, stageId, audit.aid)
|
|
|
+ const auditors = await this.getAuditGroupByListWithOwner(stageId, times)
|
|
|
const records = [
|
|
|
{
|
|
|
pid,
|
|
@@ -319,7 +320,7 @@ module.exports = app => {
|
|
|
content: noticeContent
|
|
|
}
|
|
|
]
|
|
|
- this.ctx.stage.auditors.forEach(audit => {
|
|
|
+ auditors.forEach(audit => {
|
|
|
records.push({
|
|
|
pid,
|
|
|
type: pushType.stage,
|
|
@@ -745,120 +746,6 @@ module.exports = app => {
|
|
|
default:
|
|
|
throw '无效审批操作'
|
|
|
}
|
|
|
-
|
|
|
- // const transaction = await this.db.beginTransaction();
|
|
|
- // try {
|
|
|
- // // 更新当前审核流程
|
|
|
- // await transaction.update(this.tableName, {id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time});
|
|
|
- // if (checkData.checkType === auditConst.status.checked) { // 审批通过
|
|
|
- // const nextAudit = await this.getDataByCondition({sid: stageId, times: times, order: audit.order + 1});
|
|
|
- // // 无下一审核人表示,审核结束
|
|
|
- // if (nextAudit) {
|
|
|
- // // 计算该审批人最终数据
|
|
|
- // await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
|
- // // 复制一份下一审核人数据
|
|
|
- // await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, nextAudit.order, transaction);
|
|
|
- // // 流程至下一审批人
|
|
|
- // await transaction.update(this.tableName, {id: nextAudit.id, status: auditConst.status.checking, begin_time: time});
|
|
|
- // // 同步 期信息
|
|
|
- // const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
|
|
|
- // await transaction.update(this.ctx.service.stage.tableName, {
|
|
|
- // id: stageId, status: auditConst.status.checking,
|
|
|
- // contract_tp: tpData.contract_tp,
|
|
|
- // qc_tp: tpData.qc_tp,
|
|
|
- // });
|
|
|
- // } else {
|
|
|
- // // 本期结束
|
|
|
- // // 生成截止本期数据 final数据
|
|
|
- // await this.ctx.service.stageBillsFinal.generateFinalData(transaction, this.ctx.tender, this.ctx.stage);
|
|
|
- // await this.ctx.service.stagePosFinal.generateFinalData(transaction, this.ctx.tender, this.ctx.stage);
|
|
|
- // // 计算并合同支付最终数据
|
|
|
- // await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
|
- // // 同步 期信息
|
|
|
- // const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
|
|
|
- // await transaction.update(this.ctx.service.stage.tableName, {
|
|
|
- // id: stageId, status: checkData.checkType,
|
|
|
- // contract_tp: tpData.contract_tp,
|
|
|
- // qc_tp: tpData.qc_tp,
|
|
|
- // });
|
|
|
- // }
|
|
|
- // } else if (checkData.checkType === auditConst.status.checkNo) { // 审批退回 原报, times+1
|
|
|
- // // 同步 期信息
|
|
|
- // const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
|
|
|
- // await transaction.update(this.ctx.service.stage.tableName, {
|
|
|
- // id: stageId, status: checkData.checkType,
|
|
|
- // contract_tp: tpData.contract_tp,
|
|
|
- // qc_tp: tpData.qc_tp,
|
|
|
- // times: times + 1,
|
|
|
- // });
|
|
|
- // // 拷贝新一次审核流程列表
|
|
|
- // // const auditors = await this.getAllDataByCondition({
|
|
|
- // // where: {sid: stageId, times: times},
|
|
|
- // // columns: ['tid', 'sid', 'aid', 'order']
|
|
|
- // // });
|
|
|
- // const sql = 'SELECT `tid`, `sid`, `aid`, `order` FROM ?? WHERE `sid` = ? and `times` = ? GROUP BY `aid`';
|
|
|
- // const sqlParam = [this.tableName, stageId, times];
|
|
|
- // const auditors = await this.db.query(sql, sqlParam);
|
|
|
- // let order = 1;
|
|
|
- // for (const a of auditors) {
|
|
|
- // a.times = times + 1;
|
|
|
- // a.order = order;
|
|
|
- // a.status = auditConst.status.uncheck;
|
|
|
- // order++;
|
|
|
- // }
|
|
|
- // await transaction.insert(this.tableName, auditors);
|
|
|
- // // 计算该审批人最终数据
|
|
|
- // await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
|
- // // 复制一份最新数据给原报
|
|
|
- // await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times + 1, 0, transaction);
|
|
|
- // } else if (checkData.checkType === auditConst.status.checkNoPre) { // 审批退回 上一审批人
|
|
|
- // // 同步 期信息
|
|
|
- // const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
|
|
|
- // await transaction.update(this.ctx.service.stage.tableName, {
|
|
|
- // id: stageId, status: checkData.checkType,
|
|
|
- // contract_tp: tpData.contract_tp,
|
|
|
- // qc_tp: tpData.qc_tp,
|
|
|
- // });
|
|
|
- // // 将当前审批人 与 上一审批人再次添加至流程,顺移其后审批人流程顺序
|
|
|
- // if (audit.order > 1) {
|
|
|
- // // 顺移气候审核人流程顺序
|
|
|
- // this.initSqlBuilder();
|
|
|
- // this.sqlBuilder.setAndWhere('sid', { value: this.ctx.stage.id, operate: '=', });
|
|
|
- // this.sqlBuilder.setAndWhere('order', { value: audit.order, operate: '>', });
|
|
|
- // this.sqlBuilder.setUpdateData('order', { value: 2, selfOperate: '+', });
|
|
|
- // const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
|
|
|
- // const data = await transaction.query(sql, sqlParam);
|
|
|
- //
|
|
|
- // // 上一审批人,当前审批人 再次添加至流程
|
|
|
- // const preAuditor = await this.getDataByCondition({sid: stageId, times: times, order: audit.order - 1});
|
|
|
- // const newAuditors = [];
|
|
|
- // newAuditors.push({
|
|
|
- // tid: preAuditor.tid, sid: preAuditor.sid, aid: preAuditor.aid,
|
|
|
- // times: preAuditor.times, order: preAuditor.order + 2, status: auditConst.status.checking,
|
|
|
- // begin_time: time,
|
|
|
- // });
|
|
|
- // newAuditors.push({
|
|
|
- // tid: audit.tid, sid: audit.sid, aid: audit.aid,
|
|
|
- // times: audit.times, order: audit.order + 2, status: auditConst.status.uncheck
|
|
|
- // });
|
|
|
- // await transaction.insert(this.tableName, newAuditors);
|
|
|
- //
|
|
|
- // // 计算该审批人最终数据
|
|
|
- // await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
|
- // // 复制一份最新数据给上一人
|
|
|
- // await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, audit.order + 1, transaction);
|
|
|
- // } else {
|
|
|
- // throw '审核数据错误';
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // throw '无效审批操作';
|
|
|
- // }
|
|
|
- //
|
|
|
- // await transaction.commit();
|
|
|
- // } catch (err) {
|
|
|
- // await transaction.rollback();
|
|
|
- // throw err;
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
/**
|