|
@@ -1,13 +1,10 @@
|
|
|
package com.ym.mec.education.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.ym.mec.education.base.BaseResponse;
|
|
|
import com.ym.mec.education.base.PageResponse;
|
|
|
import com.ym.mec.education.entity.SysRole;
|
|
|
import com.ym.mec.education.entity.SysUser;
|
|
|
-import com.ym.mec.education.enums.ApprovalStatusEnum;
|
|
|
import com.ym.mec.education.req.ApprovalReq;
|
|
|
import com.ym.mec.education.resp.ApprovalResp;
|
|
|
import com.ym.mec.education.service.ApprovalService;
|
|
@@ -18,8 +15,11 @@ import org.snaker.engine.IQueryService;
|
|
|
import org.snaker.engine.access.Page;
|
|
|
import org.snaker.engine.access.QueryFilter;
|
|
|
import org.snaker.engine.core.AccessService;
|
|
|
-import org.snaker.engine.core.TaskService;
|
|
|
-import org.snaker.engine.entity.*;
|
|
|
+import org.snaker.engine.core.OrderService;
|
|
|
+import org.snaker.engine.entity.HistoryOrder;
|
|
|
+import org.snaker.engine.entity.HistoryTask;
|
|
|
+import org.snaker.engine.entity.Task;
|
|
|
+import org.snaker.engine.entity.WorkItem;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -44,7 +44,7 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
|
@Autowired
|
|
|
- private TaskService taskService;
|
|
|
+ private OrderService orderService;
|
|
|
@Autowired
|
|
|
private ISysRoleService roleService;
|
|
|
|
|
@@ -86,6 +86,9 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
page.setPageSize(approvalReq.getPageSize());
|
|
|
QueryFilter queryFilter = new QueryFilter();
|
|
|
queryFilter.setOperator(approvalReq.getUserId().toString());
|
|
|
+ if (StringUtils.isNotBlank(approvalReq.getApprovalType())) {
|
|
|
+ queryFilter.setDisplayName(approvalReq.getApprovalType());
|
|
|
+ }
|
|
|
queryService.getHistoryOrders(page, queryFilter);
|
|
|
Page<ApprovalResp> pageResult = new Page();
|
|
|
BeanUtils.copyProperties(page, pageResult);
|
|
@@ -93,8 +96,8 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
if (!CollectionUtils.isEmpty(page.getResult())) {
|
|
|
page.getResult().forEach(item -> {
|
|
|
ApprovalResp approvalResp = initApprovalResp(item.getVariable(), userService.getById(item.getCreator()));
|
|
|
- approvalResp.setOrderId(item.getId()).setApprovalType(item.getProcessName())
|
|
|
- .setApprovalDate(item.getCreateTime().substring(0, 10));
|
|
|
+ approvalResp.setOrderId(item.getId()).setApprovalType(item.getProcessName()).setApprovalDate(item.getCreateTime())
|
|
|
+ .setOrderState(item.getOrderState());
|
|
|
list.add(approvalResp);
|
|
|
});
|
|
|
}
|
|
@@ -107,33 +110,24 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
if (Objects.isNull(approvalReq.getOrderId())) {
|
|
|
return BaseResponse.errorParam();
|
|
|
}
|
|
|
- Order order = queryService.getOrder(approvalReq.getOrderId());
|
|
|
- ApprovalResp approvalResp = initApprovalResp(order.getVariable(), userService.getById(order.getCreator()));
|
|
|
+ HistoryOrder histOrder = queryService.getHistOrder(approvalReq.getOrderId());
|
|
|
+ ApprovalResp approvalResp = initApprovalResp(histOrder.getVariable(), userService.getById(histOrder.getCreator()));
|
|
|
+ approvalResp.setApprovalDate(histOrder.getCreateTime()).setOrderState(histOrder.getOrderState())
|
|
|
+ .setOrderId(approvalReq.getOrderId());
|
|
|
QueryFilter queryFilter = new QueryFilter();
|
|
|
- queryFilter.setOperator(order.getCreator()).orderBy("create_Time desc");
|
|
|
+ queryFilter.setOperator(histOrder.getCreator()).orderBy("create_Time desc");
|
|
|
List<HistoryTask> historyTaskList = queryService.getHistoryTasks(queryFilter);
|
|
|
List<Task> activeTaskList = queryService.getActiveTasks(queryFilter);
|
|
|
List<ApprovalResp.ApprovalHistoryInfo> historyInfoList = Lists.newArrayList();
|
|
|
- ApprovalResp.ApprovalHistoryInfo approvalHistoryInfo = ApprovalResp.getApprovalHistoryInfo();
|
|
|
- approvalHistoryInfo.setOperator("我").setStatus("发起申请");
|
|
|
- historyInfoList.add(approvalHistoryInfo);
|
|
|
if (!CollectionUtils.isEmpty(historyTaskList)) {
|
|
|
historyTaskList.forEach(task -> {
|
|
|
- ApprovalResp.ApprovalHistoryInfo historyInfo = initApprovalHisotoryVariable(task.getVariable());
|
|
|
- SysRole role = roleService.getById(task.getOperator());
|
|
|
- if (Objects.nonNull(role)) {
|
|
|
- Optional.ofNullable(role.getRoleName()).ifPresent(roleName -> historyInfo.setOperator(roleName));
|
|
|
- }
|
|
|
+ ApprovalResp.ApprovalHistoryInfo historyInfo = initApprovalHisotoryVariable(task.getVariable(), task.getOperator());
|
|
|
historyInfoList.add(historyInfo);
|
|
|
});
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(activeTaskList)) {
|
|
|
historyTaskList.forEach(task -> {
|
|
|
- ApprovalResp.ApprovalHistoryInfo historyInfo = initApprovalHisotoryVariable(task.getVariable());
|
|
|
- SysRole role = roleService.getById(task.getOperator());
|
|
|
- if (Objects.nonNull(role)) {
|
|
|
- Optional.ofNullable(role.getRoleName()).ifPresent(roleName -> historyInfo.setOperator(roleName));
|
|
|
- }
|
|
|
+ ApprovalResp.ApprovalHistoryInfo historyInfo = initApprovalHisotoryVariable(task.getVariable(), task.getOperator());
|
|
|
historyInfoList.add(historyInfo);
|
|
|
});
|
|
|
}
|
|
@@ -146,12 +140,7 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
if (Objects.isNull(approvalReq.getOrderId()) || Objects.isNull(approvalReq.getUserId())) {
|
|
|
return BaseResponse.errorParam();
|
|
|
}
|
|
|
- //查询该实例最新的任务
|
|
|
- QueryFilter queryFilter = new QueryFilter();
|
|
|
- queryFilter.setOrderId(approvalReq.getOrderId()).orderBy("create_Time desc");
|
|
|
- List<Task> taskList = queryService.getActiveTasks(queryFilter);
|
|
|
- taskList.stream().findFirst().ifPresent(task -> taskService.withdrawTask(task.getId(),
|
|
|
- approvalReq.getUserId().toString()));
|
|
|
+ orderService.withdraw(approvalReq.getOrderId(), approvalReq.getUserId().toString());
|
|
|
return BaseResponse.success("取消成功");
|
|
|
}
|
|
|
|
|
@@ -175,8 +164,7 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
if (!CollectionUtils.isEmpty(page.getResult())) {
|
|
|
page.getResult().forEach(item -> {
|
|
|
ApprovalResp approvalResp = initApprovalResp(item.getVariable(), userService.getById(item.getCreator()));
|
|
|
- approvalResp.setOrderId(item.getId()).setApprovalType(item.getProcessName())
|
|
|
- .setApprovalDate(item.getCreateTime().substring(0, 10));
|
|
|
+ approvalResp.setOrderId(item.getId()).setApprovalType(item.getProcessName()).setApprovalDate(item.getCreateTime());
|
|
|
list.add(approvalResp);
|
|
|
});
|
|
|
}
|
|
@@ -192,8 +180,7 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
page.getResult().forEach(item -> {
|
|
|
SysUser user = userService.getById(item.getCreator());
|
|
|
ApprovalResp approvalResp = initApprovalResp(item.getOrderVariable(), user);
|
|
|
- approvalResp.setTaskId(item.getTaskId()).setApprovalType(item.getProcessName())
|
|
|
- .setApprovalDate(item.getOrderCreateTime().substring(0, 10));
|
|
|
+ approvalResp.setApprovalType(item.getProcessName()).setApprovalDate(item.getOrderCreateTime());
|
|
|
list.add(approvalResp);
|
|
|
});
|
|
|
}
|
|
@@ -213,21 +200,17 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
private ApprovalResp initApprovalVariable(String variable) {
|
|
|
ApprovalResp approvalResp = new ApprovalResp();
|
|
|
if (StringUtils.isNotBlank(variable)) {
|
|
|
- JSONObject jsonObject = JSON.parseObject(variable);
|
|
|
- approvalResp.setStatus(ApprovalStatusEnum.getMsgByCode(jsonObject.getString("status")));
|
|
|
- Optional.ofNullable(jsonObject.getString("startTime")).ifPresent(time -> approvalResp.setStartTime(time));
|
|
|
- Optional.ofNullable(jsonObject.getString("endTime")).ifPresent(time -> approvalResp.setEndTime(time));
|
|
|
- Optional.ofNullable(jsonObject.getString("remark")).ifPresent(remark -> approvalResp.setRemark(remark));
|
|
|
+ approvalResp.setVariableJson(variable);
|
|
|
}
|
|
|
return approvalResp;
|
|
|
}
|
|
|
|
|
|
- private ApprovalResp.ApprovalHistoryInfo initApprovalHisotoryVariable(String variable) {
|
|
|
+ private ApprovalResp.ApprovalHistoryInfo initApprovalHisotoryVariable(String variable, String operator) {
|
|
|
ApprovalResp.ApprovalHistoryInfo historyInfo = ApprovalResp.getApprovalHistoryInfo();
|
|
|
- if (StringUtils.isNotBlank(variable)) {
|
|
|
- JSONObject jsonObject = JSON.parseObject(variable);
|
|
|
- historyInfo.setStatus(ApprovalStatusEnum.getMsgByCode(jsonObject.getString("status")));
|
|
|
- Optional.ofNullable(jsonObject.getString("reason")).ifPresent(reason -> historyInfo.setReason(reason));
|
|
|
+ historyInfo.setVariableJson(variable);
|
|
|
+ SysRole role = roleService.getById(operator);
|
|
|
+ if (Objects.nonNull(role)) {
|
|
|
+ Optional.ofNullable(role.getRoleName()).ifPresent(roleName -> historyInfo.setOperator(roleName));
|
|
|
}
|
|
|
return historyInfo;
|
|
|
}
|