fix:修复提交审批的时候出现事件id重复的问题

This commit is contained in:
lulz1 2024-07-12 14:15:07 +08:00
parent c62a6f661a
commit bdbff65d70
1 changed files with 18 additions and 9 deletions

View File

@ -15,8 +15,7 @@ import java.util.stream.Collectors;
import static com.chint.domain.aggregates.approval.ApprovalMethod.APPROVE;
import static com.chint.domain.aggregates.approval.ApprovalType.LEG_ADD_CHANGE_BATCH;
import static com.chint.infrastructure.constant.LegConstant.LEG_APPROVAL_STATUS_PREPARE;
import static com.chint.infrastructure.constant.LegConstant.LEG_APPROVAL_STATUS_SUBMIT;
import static com.chint.infrastructure.constant.LegConstant.*;
public class ApprovalLegAddAndChangeBatch extends ApprovalProcess {
@ -113,26 +112,36 @@ public class ApprovalLegAddAndChangeBatch extends ApprovalProcess {
if (this.getApprovalMethod() == null || this.getApprovalMethod().equals(APPROVE)) {
//所有被提交审批的被加入审批事件
String approvalRecordNo = approvalData.getApprovalRecordNo();
addApprovalEventAndRecord(LegApprovalEvent.submit(approvalRecordNo));
addApprovalEventAndRecord(LEG_APPROVAL_STATUS_SUBMIT, approvalRecordNo);
} else {
//所有被提交审批的被加入知会事件
String approvalRecordNo = approvalData.getApprovalRecordNo();
addApprovalEventAndRecord(LegApprovalEvent.notifyEvent(approvalRecordNo));
addApprovalEventAndRecord(LEG_APPROVAL_STATUS_NOTIFY, approvalRecordNo);
}
bpmPlatform.submitLegAddOrChangeApproval(approvalData);
return this;
}
private void addApprovalEventAndRecord(LegApprovalEvent event) {
private void addApprovalEventAndRecord(Integer legApprovalEventType, String approvalRecordNo) {
ApprovalRecord approvalRecord = this.getApprovalRecord();
approvalData.getAddLegList().forEach(leg -> {
leg.addEvent(event);
approvalRecord.addLeg(leg);
if (legApprovalEventType == LEG_APPROVAL_STATUS_SUBMIT) {
leg.addEvent(LegApprovalEvent.submit(approvalRecordNo));
approvalRecord.addLeg(leg);
} else {
leg.addEvent(LegApprovalEvent.notifyEvent(approvalRecordNo));
approvalRecord.addLeg(leg);
}
});
approvalData.getChangeLegList().forEach(it -> {
Leg newLeg = it.getFirst();
newLeg.addEvent(event);
approvalRecord.addLeg(newLeg);
if (legApprovalEventType == LEG_APPROVAL_STATUS_SUBMIT) {
newLeg.addEvent(LegApprovalEvent.submit(approvalRecordNo));
approvalRecord.addLeg(newLeg);
} else {
newLeg.addEvent(LegApprovalEvent.notifyEvent(approvalRecordNo));
approvalRecord.addLeg(newLeg);
}
});
bpmPlatform.submitLegAddOrChangeApproval(approvalData);
}