Commit 96d1778b authored by neo's avatar neo

[dev] split startInstanceAndAssigne to two transextion

parent 2287fb7f
......@@ -39,15 +39,32 @@ public class ApprovalService {
@Autowired
PeriodReportMapper reportMapper;
@Transactional
public void startInstanceAndAssignee(ApprovalDto dto) {
PeriodApprove pa = new PeriodApprove();
String instanceId = startInstance(dto, pa);
startAssignee(pa, instanceId);
}
public List<ApprovalTask> getTask(String assignee) {
List<Task> tasks = taskService.createTaskQuery().taskAssignee(assignee).list();
List<ApprovalTask> list = new ArrayList<>();
for (Task task : tasks) {
ApprovalTask t = new ApprovalTask();
list.add(t.copyfrom(task));
}
return list;
}
@Transactional
private void startInstance(ApprovalDto dto, PeriodApprove pa) {
PeriodReportExample pre = new PeriodReportExample();
pre.createCriteria().andProjectIdEqualTo(dto.getProjectId()).andPeriodEqualTo(dto.getPeriod());
List<PeriodReport> currentReports = reportMapper.selectByExample(pre);
MyAsserts.assertNotEmpty(currentReports, Exceptions.NOT_FOUND_REPORT_EXCEPTION);
PeriodApprove pa = new PeriodApprove();
pa.setId(UUID.randomUUID().toString());
pa.setPeriod(dto.getPeriod());
pa.setYear(dto.getYear());
......@@ -74,10 +91,13 @@ public class ApprovalService {
pa.setReportIds(reportIds.toString());
pa.setTemplateIds(reportTemplateIds.toString());
pa.setStatus(Constant.APPROVAL_COMMITTED);
periodApproveMapper.insert(pa);
}
@Transactional
private void startAssignee(PeriodApprove pa) {
List<Task> tasks = taskService.createTaskQuery().taskAssignee(Constant.ASSIGNEE_ACCOUNTANT).processInstanceId(
pi.getId()).list();
pa.getInstanceId()).list();
if (tasks != null && tasks.size() == 1) {
Task task = tasks.get(0);
......@@ -87,23 +107,13 @@ public class ApprovalService {
taskService.complete(task.getId(), map);
taskService.createAttachment("java.lang.String", task.getId(), task.getProcessInstanceId(),
"period_approval_uuid", pa.getId(), pa.getId());
periodApproveMapper.insert(pa);
periodApproveMapper.updateByPrimaryKeySelective(pa);
} else {
logger.warn("task must not null or size eq 1");
}
}
public List<ApprovalTask> getTask(String assignee) {
List<Task> tasks = taskService.createTaskQuery().taskAssignee(assignee).list();
List<ApprovalTask> list = new ArrayList<>();
for (Task task : tasks) {
ApprovalTask t = new ApprovalTask();
list.add(t.copyfrom(task));
}
return list;
}
@Transactional
public void checkTask(String taskId, String decide) {
Map<String, Object> map = new HashMap<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment