|
@@ -35,6 +35,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.activiti.engine.HistoryService;
|
|
|
import org.activiti.engine.RuntimeService;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
+import org.activiti.engine.history.HistoricProcessInstance;
|
|
|
import org.activiti.engine.history.HistoricTaskInstance;
|
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
|
import org.activiti.engine.task.Comment;
|
|
@@ -76,7 +77,7 @@ public class SbInfoActivitiController {
|
|
|
*/
|
|
|
@SysLog("设备报废提交审批")
|
|
|
@PutMapping("/start")
|
|
|
- public R modModelByDTOForScrapForAudit(@RequestBody SbInfoDTO sbInfoDTO) {
|
|
|
+ public R start(@RequestBody SbInfoDTO sbInfoDTO) {
|
|
|
ActApplyInfo applyInfo = new ActApplyInfo(sbInfoDTO.getId(),
|
|
|
sbInfoDTO.getName() + "-" + sbInfoDTO.getNo(), ActApplyEnum.SB_INFO_SCRAP_TEST.getName(),
|
|
|
0,
|
|
@@ -95,6 +96,7 @@ public class SbInfoActivitiController {
|
|
|
log.info("流程定义ID:" + instance.getProcessDefinitionId());
|
|
|
sbInfoDTO.setProcessInstanceId(instance.getId());
|
|
|
SbInfo sbInfo = new SbInfo();
|
|
|
+ sbInfo.setStatus(SbInfoStatusEnum.IN_SCRAP.getValue());
|
|
|
sbInfo.setId(sbInfoDTO.getId());
|
|
|
sbInfo.setProcessInstanceId(instance.getId());
|
|
|
sbInfoService.updateByPrimaryKeySelective(sbInfo);
|
|
@@ -104,7 +106,7 @@ public class SbInfoActivitiController {
|
|
|
/**
|
|
|
* 审核
|
|
|
*
|
|
|
- * @param sbInfoDTO
|
|
|
+ * @param sbInfoDTO:不包括processInstanceId,
|
|
|
* @return R
|
|
|
*/
|
|
|
@SysLog("设备报废审核")
|
|
@@ -122,9 +124,32 @@ public class SbInfoActivitiController {
|
|
|
map.put("result", result);
|
|
|
taskService.addComment(taskId, sbInfoDTO.getProcessInstanceId(), sbInfoDTO.getRefuseReason());
|
|
|
taskService.complete(taskId, map);
|
|
|
+ if(checkFinish(sbInfoDTO.getProcessInstanceId())){
|
|
|
+ SbInfo sbInfo = new SbInfo();
|
|
|
+ sbInfo.setStatus(SbInfoStatusEnum.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)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (Objects.isNull(historicProcessInstance.getEndTime())) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 审核
|
|
|
*
|
|
@@ -196,7 +221,7 @@ public class SbInfoActivitiController {
|
|
|
}
|
|
|
if (commentList != null && commentList.size() > 0) {
|
|
|
for (Comment comment : commentList) {
|
|
|
- if(comment.getTaskId().equals(task.getId())){
|
|
|
+ if (comment.getTaskId().equals(task.getId())) {
|
|
|
detail.setApproveComment(comment.getFullMessage());
|
|
|
break;
|
|
|
}
|