Activity approvalLineAct = draftAct.getParentActivity();
while (!(approvalLineAct instanceof ExternalApprovalLineActivity)) {
approvalLineAct = approvalLineAct.getParentActivity();
}
ComplexActivity parent = (ComplexActivity) approvalLineAct;
if (parent.getChildActivities().size() > 1) {
parent.getChildActivities().clear();
parent.addChildActivity(draftAct);
}
String preApprovalType = null;
for (Approver approver : approverList) {
if (ExternalApprovalActivity.APPROVAL_TYPE_DRAFT.equalsIgnoreCase(approver.getType())) {
approver.setTracingTag(draftAct.getTracingTag());
approver.setTaskId(draftAct.getTaskIds(instance)[0]);
approver.setTruthEmpCode(approver.getEmpCode());
approver.setStatus(ExternalApprovalActivity.SIGN_DRAFT);
approver.setEndDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));
approver.setComment(psMsg.getComment());
approvalActs.add(draftAct);
continue;
}
ExternalApprovalActivity childAct = (ExternalApprovalActivity) draftAct.clone();
childAct.setName("결재");
childAct.setTracingTag(null);
childAct.setRole(null);
childAct.setApprovalTypeByString(approver.getType());
RoleMapping rm = RoleMapping.create();
rm.setEndpoint(approver.getEmpCode());
rm.fill(instance);
// 결재 -> 합의
if (!ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(preApprovalType) && ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(approver.getType())) {
AllActivity allAct = new AllActivity();
allAct.setTracingTag(null);
parent.addChildActivity(allAct);
parent = allAct;
// 합의 -> 결재
} else if (ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(preApprovalType) && !ExternalApprovalActivity.APPROVAL_TYPE_COOPERATION.equals(approver.getType())) {
parent = (ComplexActivity) approvalLineAct;
}
parent.addChildActivity(childAct);
childAct.setApprover(instance, rm);
approver.setTracingTag(childAct.getTracingTag());
preApprovalType = approver.getType();