|
@@ -182,11 +182,17 @@ module.exports = app => {
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
await transaction.update(this.tableName, {id: audit.id, status: auditConst.status.checking, begin_time: new Date()});
|
|
|
- await transaction.update(this.ctx.service.stage.tableName, {id: stageId, status: auditConst.status.checking});
|
|
|
// 计算原报最终数据
|
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
|
// 复制一份下一审核人数据
|
|
|
await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, 1, transaction);
|
|
|
+ // 更新期数据
|
|
|
+ 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
|
|
|
+ });
|
|
|
// todo 更新标段tender状态 ?
|
|
|
await transaction.commit();
|
|
|
} catch(err) {
|
|
@@ -229,17 +235,32 @@ module.exports = app => {
|
|
|
// 流程至下一审批人
|
|
|
await transaction.update(this.tableName, {id: nextAudit.id, status: auditConst.status.checking, begin_time: time});
|
|
|
// 同步 期信息
|
|
|
- await transaction.update(this.ctx.service.stage.tableName, {id: stageId, status: auditConst.status.checking});
|
|
|
+ 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 {
|
|
|
// 本期结束
|
|
|
// 计算并合同支付最终数据
|
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
|
// 同步 期信息
|
|
|
- await transaction.update(this.ctx.service.stage.tableName, {id: stageId, status: checkData.checkType});
|
|
|
+ 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) { // 审批退回 原报
|
|
|
// 同步 期信息
|
|
|
- await transaction.update(this.ctx.service.stage.tableName, {id: stageId, status: checkData.checkType});
|
|
|
+ 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,
|
|
|
+ });
|
|
|
// 拷贝新一次审核流程列表
|
|
|
const auditors = await this.getAllDataByCondition({
|
|
|
where: {sid: stageId, times: times},
|
|
@@ -256,7 +277,12 @@ module.exports = app => {
|
|
|
await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times + 1, 0, transaction);
|
|
|
} else if (checkData.checkType === auditConst.status.checkNoPre) { // 审批退回 上一审批人
|
|
|
// 同步 期信息
|
|
|
- await transaction.update(this.ctx.service.stage.tableName, {id: stageId, status: checkData.checkType});
|
|
|
+ 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) {
|
|
|
// 顺移气候审核人流程顺序
|
|
@@ -315,6 +341,30 @@ module.exports = app => {
|
|
|
const sqlParam = [this.tableName, this.ctx.service.stage.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checking];
|
|
|
return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取 某时间后 审批进度 更新的期
|
|
|
+ * @param {Number} pid - 查询标段
|
|
|
+ * @param {Number} uid - 查询人
|
|
|
+ * @param {Date} time - 查询时间
|
|
|
+ * @returns {Promise<*>}
|
|
|
+ */
|
|
|
+ async getNoticeStage(pid, uid, time) {
|
|
|
+ const sql = 'SELECT t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
|
|
|
+ ' s.`order` As `s_order`, s.`status` As `s_status`, ' +
|
|
|
+ ' sa.`aid`, sa.`times`, sa.`order`, sa.`end_time`, sa.`tid`, sa.`sid`, sa.`status`, ' +
|
|
|
+ ' pa.`name` As `su_name`, pa.role As `su_role`, pa.company As `su_company`' +
|
|
|
+ ' FROM ?? As t' +
|
|
|
+ ' LEFT JOIN ?? As s On t.`id` = s.`tid`' +
|
|
|
+ ' LEFT JOIN ?? As sa ON s.`id` = sa.`sid`' +
|
|
|
+ ' LEFT JOIN ?? As pa ON sa.`aid` = pa.`id`' +
|
|
|
+ ' WHERE sa.`aid` <> ? and sa.`end_time` > ? and t.`project_id` = ?' +
|
|
|
+ ' GROUP By t.`id`' +
|
|
|
+ ' ORDER By sa.`end_time`';
|
|
|
+ const sqlParam = [this.ctx.service.tender.tableName, this.ctx.service.stage.tableName, this.tableName,
|
|
|
+ this.ctx.service.projectAccount.tableName, uid, time, pid];
|
|
|
+ return await this.db.query(sql, sqlParam);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return StageAudit;
|