draftAct.setExtValue1(psMsg.getMainParam());
}
if (StringUtils.hasText(psMsg.getSubParam())) {
draftAct.setExtValue2(psMsg.getSubParam());
}
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();
approvalActs.add(childAct);
}
// tempPd.registerToProcessDefinition(false, false);
pm.changeProcessDefinition(instanceId, tempPd);
// 결재선 다이나믹 체인지 End
instance.setProperty(approvalLineAct.getTracingTag(), ExternalApprovalLineActivity.KEY_APPR_KEY, psMsg.getApprovalKey());
approvalLineDAO.update(al);
approverDAO.update(approverList);
if (psMsg.isFirstTaskCompleted()) {
pm.completeWorkitem(instanceId, draftAct.getTracingTag(), null, new org.uengine.kernel.ResultPayload());