|
@@ -28,11 +28,13 @@ import com.platform.dao.vo.sb.SbInfoWorkplaceVO;
|
|
|
import com.platform.office.poi.excel.ExcelImportUtil;
|
|
|
import com.platform.office.poi.excel.entity.ImportParams;
|
|
|
import com.platform.rest.log.annotation.SysLog;
|
|
|
+import com.platform.service.business.SbInfoActivitiBusinessService;
|
|
|
import com.platform.service.sb.SbInfoService;
|
|
|
import com.platform.service.upms.SysUserService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.activiti.engine.HistoryService;
|
|
|
+import org.activiti.engine.IdentityService;
|
|
|
import org.activiti.engine.RuntimeService;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.history.HistoricProcessInstance;
|
|
@@ -64,10 +66,7 @@ import java.util.*;
|
|
|
public class SbInfoActivitiController {
|
|
|
|
|
|
private final SbInfoService sbInfoService;
|
|
|
- private final RuntimeService runtimeService;
|
|
|
- private final HistoryService historyService;
|
|
|
- private final TaskService taskService;
|
|
|
- private final SysUserService sysUserService;
|
|
|
+ private final SbInfoActivitiBusinessService sbInfoActivitiBusinessService;
|
|
|
|
|
|
/**
|
|
|
* 启动:将设备id和表单id设置到businessKey中
|
|
@@ -77,22 +76,7 @@ public class SbInfoActivitiController {
|
|
|
@SysLog("设备报废提交审批")
|
|
|
@PutMapping("/start")
|
|
|
public R start(@RequestBody SbInfoDTO sbInfoDTO) {
|
|
|
- ActApplyInfo applyInfo = new ActApplyInfo(sbInfoDTO.getId(),
|
|
|
- sbInfoDTO.getName() + "-" + sbInfoDTO.getNo(), ActApplyEnum.SB_INFO_SCRAP_TEST.getName(),
|
|
|
- 0,
|
|
|
- LocalDateTime.now());
|
|
|
- Map<String, Object> map = new HashMap<>(1);
|
|
|
- UserInfo user = SecurityUtils.getUserInfo();
|
|
|
- applyInfo.setUserId(user.getUserId());
|
|
|
- applyInfo.setUserName(user.getRealName());
|
|
|
- map.put("data", applyInfo);
|
|
|
- map.put("userId", applyInfo.getUserId());
|
|
|
- ProcessInstance instance = runtimeService.startProcessInstanceByKey(ActApplyEnum.SB_INFO_SCRAP_TEST.getName(), map);
|
|
|
- if (instance == null) {
|
|
|
- throw new BusinessException(ResultCode.ACTIVITI_PROCESS_NOT_EXIST.getDescription());
|
|
|
- }
|
|
|
- log.info("流程实例ID:" + instance.getId());
|
|
|
- log.info("流程定义ID:" + instance.getProcessDefinitionId());
|
|
|
+ ProcessInstance instance = sbInfoActivitiBusinessService.start(sbInfoDTO);
|
|
|
SbInfo sbInfo = new SbInfo();
|
|
|
sbInfo.setStatus(SbInfoStatusEnum.IN_SCRAP.getValue());
|
|
|
sbInfo.setId(sbInfoDTO.getId());
|
|
@@ -110,47 +94,16 @@ public class SbInfoActivitiController {
|
|
|
@SysLog("设备报废审核")
|
|
|
@PutMapping("/audit")
|
|
|
public R audit(@RequestBody SbInfoDTO sbInfoDTO) {
|
|
|
- UserInfo user = SecurityUtils.getUserInfo();
|
|
|
- String taskId = sbInfoDTO.getTaskId();
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- Integer result = 0;
|
|
|
- if (sbInfoDTO.getAuditFlag()) {
|
|
|
- result = 1;// 同意
|
|
|
- } else {
|
|
|
- result = 0;// 拒绝
|
|
|
- }
|
|
|
- map.put("result", result);
|
|
|
- taskService.addComment(taskId, sbInfoDTO.getProcessInstanceId(), sbInfoDTO.getRefuseReason());
|
|
|
- taskService.complete(taskId, map);
|
|
|
- if(checkFinish(sbInfoDTO.getProcessInstanceId())){
|
|
|
+ boolean flag = sbInfoActivitiBusinessService.audit(sbInfoDTO);
|
|
|
+ if(sbInfoActivitiBusinessService.checkFinish(sbInfoDTO.getProcessInstanceId())){
|
|
|
SbInfo sbInfo = new SbInfo();
|
|
|
- sbInfo.setStatus(SbInfoStatusEnum.SCRAPED.getValue());
|
|
|
+ sbInfo.setStatus(flag?SbInfoStatusEnum.SCRAPED.getValue():SbInfoStatusEnum.REFUSE_SCRAPED.getValue());
|
|
|
sbInfo.setId(sbInfoDTO.getId());
|
|
|
sbInfoService.updateByPrimaryKeySelective(sbInfo);
|
|
|
}
|
|
|
return new R<>();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 判定流程是否结束
|
|
|
- * @param processInstanceId
|
|
|
- * @return
|
|
|
- */
|
|
|
- private boolean checkFinish(String processInstanceId) {
|
|
|
- HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
|
|
- if (Objects.isNull(historicProcessInstance)) {
|
|
|
- log.info("完成1");
|
|
|
- return true;
|
|
|
- }
|
|
|
- if (Objects.isNull(historicProcessInstance.getEndTime())) {
|
|
|
- log.info("未完成");
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- log.info("完成2");
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 审核
|
|
|
*
|
|
@@ -160,21 +113,12 @@ public class SbInfoActivitiController {
|
|
|
@SysLog("设备报废终止审核")
|
|
|
@PutMapping("/stop")
|
|
|
public R stop(@RequestBody SbInfoDTO sbInfoDTO) {
|
|
|
- String processInstanceId = sbInfoDTO.getProcessInstanceId();
|
|
|
- if (StringUtils.isNotEmpty(processInstanceId)) {
|
|
|
- runtimeService.deleteProcessInstance(processInstanceId, "");
|
|
|
- historyService.deleteHistoricProcessInstance(processInstanceId);
|
|
|
- }
|
|
|
- SbInfo sbInfo = new SbInfo();
|
|
|
- sbInfo.setId(sbInfoDTO.getId());
|
|
|
- sbInfo.setProcessInstanceId(null);
|
|
|
- sbInfo.setStatus(SbInfoStatusEnum.IN_STORE.getValue());
|
|
|
- sbInfoService.updateByPrimaryKeySelective(sbInfo);
|
|
|
+ sbInfoActivitiBusinessService.stop(sbInfoDTO);
|
|
|
return new R<>();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 审核
|
|
|
+ * 转签
|
|
|
*
|
|
|
* @param sbInfoDTO
|
|
|
* @return R
|
|
@@ -182,19 +126,7 @@ public class SbInfoActivitiController {
|
|
|
@SysLog("设备报废转签")
|
|
|
@PutMapping("/assign")
|
|
|
public R assign(@RequestBody SbInfoDTO sbInfoDTO) {
|
|
|
- String taskId = sbInfoDTO.getTaskId();
|
|
|
- String userId = sbInfoDTO.getChangeUser();
|
|
|
- if (StringUtils.isEmpty(taskId)) {
|
|
|
- throw new BusinessException("taskId为空,请选择");
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(userId)) {
|
|
|
- throw new BusinessException("请设置转签人员");
|
|
|
- }
|
|
|
- SysUser sysUser = sysUserService.getModelById(userId);
|
|
|
- if(sysUser == null){
|
|
|
- throw new BusinessException("用户不存在,请选择其他人员");
|
|
|
- }
|
|
|
- taskService.setAssignee(taskId, userId);
|
|
|
+ sbInfoActivitiBusinessService.assign(sbInfoDTO);
|
|
|
return new R<>();
|
|
|
}
|
|
|
|
|
@@ -207,56 +139,7 @@ public class SbInfoActivitiController {
|
|
|
@SysLog("设备报废审核历史")
|
|
|
@GetMapping("/history/{processInstanceId}")
|
|
|
public R history(@PathVariable("processInstanceId") String processInstanceId) {
|
|
|
- //获取历史祥情
|
|
|
- List<HistoricTaskInstance> taskList = historyService.createHistoricTaskInstanceQuery()
|
|
|
- .processInstanceId(processInstanceId)
|
|
|
- .includeTaskLocalVariables()
|
|
|
- .orderByHistoricTaskInstanceEndTime().desc()
|
|
|
- .list();
|
|
|
- List<Comment> commentList = taskService.getProcessInstanceComments(processInstanceId);
|
|
|
- List<ActivitiTaskDetail> tasks = new ArrayList<>();
|
|
|
- if (taskList != null && taskList.size() > 0) {
|
|
|
- for (HistoricTaskInstance task : taskList) {
|
|
|
- ActivitiTaskDetail detail = new ActivitiTaskDetail();
|
|
|
- if (task.getStartTime() != null) {
|
|
|
- detail.setStartTime(DateUtils.dateToLocalDateTime(task.getStartTime()));
|
|
|
- }
|
|
|
- if (task.getEndTime() != null) {
|
|
|
- detail.setEndTime(DateUtils.dateToLocalDateTime(task.getEndTime()));
|
|
|
- }
|
|
|
- detail.setAssignee(task.getAssignee());
|
|
|
- if (StringUtils.isBlank(task.getAssignee())) {
|
|
|
- detail.setUserName("等待签收");
|
|
|
- } else {
|
|
|
- SysUser sysUser = sysUserService.getModelById(task.getAssignee());
|
|
|
- if (sysUser == null) {
|
|
|
- detail.setUserName("用户已删除");
|
|
|
- } else {
|
|
|
- detail.setUserName(sysUser.getRealName());
|
|
|
- }
|
|
|
- }
|
|
|
- detail.setName(task.getName());
|
|
|
- detail.setNodeKey(task.getTaskDefinitionKey());
|
|
|
- Map<String, Object> map = task.getProcessVariables();
|
|
|
- if (map != null && map.size() > 0) {
|
|
|
- for (String key : map.keySet()) {
|
|
|
- if (key.equals("result")) {
|
|
|
- detail.setResult(map.get(key).toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (commentList != null && commentList.size() > 0) {
|
|
|
- for (Comment comment : commentList) {
|
|
|
- if (comment.getTaskId().equals(task.getId())) {
|
|
|
- detail.setApproveComment(comment.getFullMessage());
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- tasks.add(detail);
|
|
|
- }
|
|
|
- }
|
|
|
- return new R(tasks);
|
|
|
+ return new R(sbInfoActivitiBusinessService.history(processInstanceId));
|
|
|
}
|
|
|
|
|
|
}
|