instance.getWorkList().completeWorkItem(aacMsg.getTaskId(), new KeyedParameter[]{}, instance.getProcessTransactionContext());
//반려시에는 ExternalApprovalActivity 의 afterComplete 를 타지 않는다.(바로 윗줄에 보면 worklist 테이블만 update 시킨다.) 따라서 수동 update
Calendar endTime = GlobalContext.getNow(instance.getProcessTransactionContext());
ApproverDAO approverDAO = new ApproverDAO(DefaultConnectionFactory.create().getDataSource());
Approver approver = approverDAO.getByInstanceIdAndTracingTag(aacMsg.getApprovalKey(), Integer.parseInt(instance.getInstanceId()), aacMsg.getTracingTag());
approver.setTruthEmpCode(aacMsg.getEndpoint());
approver.setTaskId(approvalAct.getTaskIds(instance)[0]);
approver.setStatus(ExternalApprovalActivity.SIGN_REJECT);
approver.setEndDate(new Timestamp(endTime.getTimeInMillis()));
approver.setComment(aacMsg.getComment());
approverDAO.update(approver);
//반려 로직
ExternalApprovalLineActivity approvalLineAct = approvalAct.getApprovalLineActivity();
int rejectOption = approvalLineAct.getRejectOption();
// 기안 단계로 반려
if (rejectOption == ExternalApprovalLineActivity.LOOPING_OPTION_BACK_TO_DRAFT) {
approvalLineAct.getDraftActivity().compensateToThis(instance);
// 결재 DB update
List<Approver> _approverList = approverDAO.list(aacMsg.getApprovalKey());
int version = _approverList.get(0).getVersion() + 1;
for (int i = 0; i < _approverList.size(); i++) {
Approver _approver = _approverList.get(i);
_approver.setVersion(version);
_approver.setComment(null);
_approver.setEndDate(null);
_approver.setTruthEmpCode(null);
_approver.setStatus(null);
if (i > 0) {
_approver.setTracingTag(null);
_approver.setTaskId(null);
}
}
approvalLine.setVersion(version);
approvalLineDAO.update(approvalLine);
approverDAO.add(_approverList);
// 바로 이전 결재로 반려
} else if (rejectOption == ExternalApprovalLineActivity.LOOPING_OPTION_BACK_TO_PREV) {
Vector<? extends Activity> childActs = approvalLineAct.getChildActivities();
Activity currentAct = instance.getProcessDefinition().getActivity(aacMsg.getTracingTag());
int prevIndex = 0;
if (currentAct.getParentActivity() instanceof AllActivity) {
prevIndex = childActs.indexOf(currentAct.getParentActivity()) - 1;
} else {
prevIndex = childActs.indexOf(approvalAct) - 1;
}
Activity prevAct = childActs.get(prevIndex);
Approver prevApprover = approverDAO.getByInstanceIdAndTracingTag(aacMsg.getApprovalKey(), Integer.parseInt(instance.getInstanceId()), prevAct.getTracingTag());
prevAct.compensateToThis(instance);
// ExternalApprovalActivity 의 afterExecute() 를 타기 때문에 강제로 다시 update
approverDAO.update(prevApprover);
// 결재 DB update
List<Approver> _approverList = approverDAO.list(aacMsg.getApprovalKey());
int version = _approverList.get(0).getVersion() + 1;
for (int i = 0; i < _approverList.size(); i++) {
Approver _approver = _approverList.get(i);
_approver.setVersion(version);
if ( aacMsg.getTracingTag().equalsIgnoreCase(_approver.getTracingTag()) &&
_approver.getTaskId().equalsIgnoreCase(aacMsg.getTaskId()) ) {
// 현재 결재자
_approver.setComment(null);
_approver.setEndDate(null);
_approver.setTruthEmpCode(null);
_approver.setStatus(null);
_approver.setTaskId(null);
// 이전 결재자
Approver _prevApprover = _approverList.get(i - 1);
_prevApprover.setComment(null);
_prevApprover.setEndDate(null);
_prevApprover.setTruthEmpCode(null);
_prevApprover.setStatus(null);
}
}
approvalLine.setVersion(version);
approvalLineDAO.update(approvalLine);
approverDAO.add(_approverList);
// 플래그로 반려
} else if (rejectOption == ExternalApprovalLineActivity.LOOPING_OPTION_BACK_TO_FLAG) {
BackActivity backActivity = new BackActivity();
backActivity.setTargetSource(BackActivity.Flag);
backActivity.setFlag(approvalLineAct.getFlag());
backActivity.executeActivity(instance);
// 결재선 종료
} else if (rejectOption == ExternalApprovalLineActivity.LOOPING_OPTION_FINISH) {
approvalAct.setEndTime(instance, endTime);
approvalAct.getApprovalLineActivity().fireComplete(instance);
}
// 전결
} else if (ExternalApprovalActivity.SIGN_ARBITRARY_APPROVED.equalsIgnoreCase(aacMsg.getApprovalStatus())) {
ExternalApprovalActivity approvalAct = (ExternalApprovalActivity) instance.getProcessDefinition().getActivity(aacMsg.getTracingTag());
approvalAct.setApprovalStatus(instance, ExternalApprovalActivity.SIGN_ARBITRARY_APPROVED);
String taskId = approvalAct.getTaskIds(instance)[0];
Calendar endTime = GlobalContext.getNow(instance.getProcessTransactionContext());
instance.getWorkList().completeWorkItem(taskId, new KeyedParameter[]{}, instance.getProcessTransactionContext());
approvalAct.setEndTime(instance, endTime);
//전결시에는 NavienApprovalActivity 의 afterComplete 를 타지 않는다.(바로 윗줄에 보면 worklist 테이블만 update 시킨다.) 따라서 수동 update
ApproverDAO approverDAO = new ApproverDAO(DefaultConnectionFactory.create().getDataSource());
Approver approver = approverDAO.getByInstanceIdAndTracingTag(aacMsg.getApprovalKey(), Integer.parseInt(instance.getInstanceId()), aacMsg.getTracingTag());
approver.setTruthEmpCode(aacMsg.getEndpoint());
approver.setTaskId(taskId);
approver.setStatus(ExternalApprovalActivity.SIGN_ARBITRARY_APPROVED);
approver.setEndDate(new Timestamp(endTime.getTimeInMillis()));
approver.setComment(aacMsg.getComment());
approverDAO.update(approver);
approvalAct.getApprovalLineActivity().fireComplete(instance);
}