diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/service/impl/FlowTaskServiceImpl.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/service/impl/FlowTaskServiceImpl.java index f972b2a9..b1eb836c 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/service/impl/FlowTaskServiceImpl.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/service/impl/FlowTaskServiceImpl.java @@ -34,10 +34,9 @@ import cn.jyjz.xiaoyao.oa.from.service.*; import cn.jyjz.xiaoyao.oa.from.vo.FlowUnionVo; import cn.jyjz.xiaoyao.ocr.dataobject.*; -import cn.jyjz.xiaoyao.ocr.service.OcrPictureService; -import cn.jyjz.xiaoyao.ocr.service.OcrTaskchildPictureService; -import cn.jyjz.xiaoyao.ocr.service.OcrUsersearchService; +import cn.jyjz.xiaoyao.ocr.service.*; import cn.jyjz.xiaoyao.ocr.util.SearchParaFormatting; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -113,6 +112,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask @Resource private OcrPictureService ocrPictureService; + @Resource + private IOcrMsgService ocrMsgService; + @Override public void myTodoTaskList(PageUtils vo, HttpServletRequest request) { @@ -126,24 +128,24 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask .orderByTaskCreateTime() .desc(); // 查询条件 - if(StringUtils.isNotBlank(vo.getKey())){ + if (StringUtils.isNotBlank(vo.getKey())) { taskQuery.taskNameLike("%" + vo.getKey() + "%"); } List tasks = taskQuery.listPage((vo.getCurrPage() - 1) * vo.getPageSize() , vo.getCurrPage() * vo.getPageSize()); - int totalcount = (int)taskQuery.count(); + int totalcount = (int) taskQuery.count(); vo.setTotalCount(totalcount); // 4 / 5 1 5/5 2 6/5 2 - if(totalcount%vo.getPageSize() == 0){ + if (totalcount % vo.getPageSize() == 0) { vo.setTotalPage(totalcount / vo.getPageSize()); - }else{ + } else { vo.setTotalPage((totalcount / vo.getPageSize()) + 1); } List list = new ArrayList<>(); - if(tasks != null && tasks.size() > 0){ + if (tasks != null && tasks.size() > 0) { for (Task task : tasks) { FlowModelVO flowTask = new FlowModelVO(); @@ -158,7 +160,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask String businesskey = processInstance.getBusinessKey(); String[] busskey = businesskey.split(SystemConstantsOa.OA_BUSSINESS_KEY_SPLIT); IFormCustomService iFormCustomService = null; - if(cn.jyjz.xiaoyao.common.base.util.StringUtils.isNotBlank(busskey[2])){ + if (cn.jyjz.xiaoyao.common.base.util.StringUtils.isNotBlank(busskey[2])) { iFormCustomService = SpringUtils.getBean(busskey[2]); //表单主键 @@ -271,14 +273,14 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } - public Category viewForm(String processId,HttpServletRequest request){ + public Category viewForm(String processId, HttpServletRequest request) { HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(processId).singleResult(); historicProcessInstance.getBusinessKey(); //我这里以 流程定义key(oa_category_t定义的关键字,逻辑唯一) + 业务表主键(请假表、调岗表等) + 业务表对应的servicename String businesskey = historicProcessInstance.getBusinessKey(); - if(StringUtils.isBlank(businesskey)){ + if (StringUtils.isBlank(businesskey)) { return null; } @@ -292,7 +294,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask .list(); // 获取节点定义id String taskDefinitionKey = ""; - for(HistoricTaskInstance historicTaskInstance:list){ + for (HistoricTaskInstance historicTaskInstance : list) { taskDefinitionKey = historicTaskInstance.getTaskDefinitionKey(); } @@ -306,7 +308,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } IFormCustomService iFormCustomService = null; - if(cn.jyjz.xiaoyao.common.base.util.StringUtils.isNotBlank(busskey[2])) { + if (cn.jyjz.xiaoyao.common.base.util.StringUtils.isNotBlank(busskey[2])) { iFormCustomService = SpringUtils.getBean(busskey[2]); } @@ -317,6 +319,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask category.setFormid(busskey[1]); return category; } + /** * 获取已办流程过程图 * @@ -324,7 +327,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask * @return */ @Override - public InputStream myDiagram(String processId,HttpServletRequest request){ + public InputStream myDiagram(String processId, HttpServletRequest request) { String processDefinitionId; // 获取当前的流程实例 ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult(); @@ -387,11 +390,11 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask // 初始化返回结果列表 List result = new ArrayList<>(16); - if (StringUtils.isBlank(taskId)){ + if (StringUtils.isBlank(taskId)) { return result; } Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); - if (task == null){ + if (task == null) { return result; } // 任务定义key 等于 当前任务节点id @@ -417,7 +420,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask FlowNode toBackFlowElement = (FlowNode) mainProcess.getFlowElement(activityId, true); // 判断 【工具类判断是否可以从源节点 到 目标节点】 Set set = new HashSet<>(); - if (toBackFlowElement != null && ExecutionGraphUtil.isReachable(mainProcess,toBackFlowElement,currentFlowElement, set)) { + if (toBackFlowElement != null && ExecutionGraphUtil.isReachable(mainProcess, toBackFlowElement, currentFlowElement, set)) { WorkFlowNodeVO workFlowNodeVO = new WorkFlowNodeVO(); workFlowNodeVO.setNodeId(activityId); workFlowNodeVO.setNodeName(toBackFlowElement.getName()); @@ -432,7 +435,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask * 完成任务 */ @Override - public Boolean complete(FlowTaskVO taskVO,HttpServletRequest request) { + public Boolean complete(FlowTaskVO taskVO, HttpServletRequest request) { try { // 当前要处理的任务 Task task = taskService.createTaskQuery().taskId(taskVO.getTaskId()).singleResult(); @@ -441,102 +444,124 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask .processDefinitionId(task.getProcessDefinitionId()) .singleResult(); // 对任务添加对应的审批意见 - taskService.addComment(task.getId(),task.getProcessInstanceId(),taskVO.getTaskComment()); + taskService.addComment(task.getId(), task.getProcessInstanceId(), taskVO.getTaskComment()); - Map variables = new HashMap<>(); - if(null != taskVO.getTaskApprovd() && StringUtils.isNotBlank(taskVO.getTaskApprovd().toString())){ - variables.put("taskApprovd",taskVO.getTaskApprovd().intValue()); + Map variables = new HashMap<>(); + if (null != taskVO.getTaskApprovd() && StringUtils.isNotBlank(taskVO.getTaskApprovd().toString())) { + variables.put("taskApprovd", taskVO.getTaskApprovd().intValue()); } - variables.put("approvd",taskVO.getApprovd()); + variables.put("approvd", taskVO.getApprovd()); //只有同意,再进行候选人设置 - if(taskVO.getApprovd()){ + if (taskVO.getApprovd()) { //进入下一个节点 - taskService.complete(task.getId(),variables); + taskService.complete(task.getId(), variables); //判断是否存在表单二次提交 - if(StringUtils.isNotBlank(taskVO.getDocumentation()) && taskVO.getDocumentation().equals(SystemConstantsOa.OA_TASK_COMPLETE_FORM)){ + if (StringUtils.isNotBlank(taskVO.getDocumentation()) && taskVO.getDocumentation().equals(SystemConstantsOa.OA_TASK_COMPLETE_FORM)) { //获取流程类型 String category = processDefinition.getCategory(); - if(StringUtils.isNotBlank(category)){ + if (StringUtils.isNotBlank(category)) { Category categoryDto = this.categoryService.getCategory(category); //解析页面请求,并持久化 IFormCustomService iFormCustomService = SpringUtils.getBean(categoryDto.getServicename()); //TODO 如果更新失败,需要撤销流程 - if(null == iFormCustomService.editForm(request,taskVO.getFormid())){ + if (null == iFormCustomService.editForm(request, taskVO.getFormid())) { //撤销审批 } } } //判断是否存在表单三次提交 - if(StringUtils.isNotBlank(taskVO.getDocumentation()) && taskVO.getDocumentation().equals(SystemConstantsOa.OA_TASK_COMPLETE_THREE_FORM)){ + if (StringUtils.isNotBlank(taskVO.getDocumentation()) && taskVO.getDocumentation().equals(SystemConstantsOa.OA_TASK_COMPLETE_THREE_FORM)) { //获取流程类型 String category = processDefinition.getCategory(); - if(StringUtils.isNotBlank(category)){ + if (StringUtils.isNotBlank(category)) { Category categoryDto = this.categoryService.getCategory(category); //解析页面请求,并持久化 IFormCustomService iFormCustomService = SpringUtils.getBean(categoryDto.getServicename()); //TODO 如果更新失败,需要撤销流程 - if(null == iFormCustomService.editForm(request,taskVO.getFormid())){ + if (null == iFormCustomService.editForm(request, taskVO.getFormid())) { //撤销审批 } } } - updateAssignee(task.getProcessInstanceId(),task.getProcessDefinitionId(),processDefinition); + updateAssignee(task.getProcessInstanceId(), task.getProcessDefinitionId(), processDefinition); String category = processDefinition.getCategory(); Category categoryDto = this.categoryService.getCategory(category); IFormCustomService iFormCustomService = SpringUtils.getBean(categoryDto.getServicename()); FlowModelVO formData = iFormCustomService.getForm(taskVO.getFormid()); + OcrTaskchildPicture model = ocrTaskchildPictureService.getById(Long.parseLong(taskVO.getFormid())); - List taskList = this.nowRunTask(formData.getProcessInstanceId(),formData.getProcessdefinitionid()); + List taskList = this.nowRunTask(formData.getProcessInstanceId(), formData.getProcessdefinitionid()); Task taskData = null; - if(null != taskList && !taskList.isEmpty()) { + if (null != taskList && !taskList.isEmpty()) { taskData = taskList.get(0); } //判断节点上的描述字段,是否伟finale_judgment,如果是,记录到终审表中,如果终审表已经存在,不再重复记录 - if(null != taskData && StringUtils.isNotBlank(taskData.getDescription()) && taskData.getDescription().equals(SystemConstantsOa.OA_TASK_COMPLETE_FINALE_FORM)){ - UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request)); + if (null != taskData && StringUtils.isNotBlank(taskData.getDescription()) && taskData.getDescription().equals(SystemConstantsOa.OA_TASK_COMPLETE_FINALE_FORM)) { User user = userService.findByLoginname(formData.getAssignee()); - userFinalService.save(user.getId().toString(),taskVO.getFormid()); + userFinalService.save(user.getId().toString(), taskVO.getFormid()); } - + UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request)); + cn.jyjz.xiaoyao.common.base.vo.User byLoginname = userTokenService.findByLoginname(model.getAssignee()); + OcrMsg msg = new OcrMsg(); + msg.setCreateTime(System.currentTimeMillis()); + msg.setSendTime(System.currentTimeMillis()); + msg.setReceiveUserIds(byLoginname.getId().toString()); + msg.setTitile(model.getFromtaskname()); + msg.setSender(Long.valueOf(userToken.getUserid())); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("taskId", model.getFromtaskid()); + jsonObject.put("nodeName", model.getTaskname()); + jsonObject.put("states", model.getStates()); + jsonObject.put("sendUserId", userToken.getUserid()); + jsonObject.put("sendUserName", userToken.getUsername()); + jsonObject.put("sendTime", System.currentTimeMillis()); + jsonObject.put("fromId", model.getId().toString()); + jsonObject.put("taskName", model.getFromtaskname()); + msg.setBusJson(jsonObject.toJSONString()); + msg.setCreateBy(Long.valueOf(userToken.getUserid())); + msg.setCreateTime(System.currentTimeMillis()); + msg.setSendStatus("1"); + + ocrMsgService.save(msg); //增加未查看记录 - userViewApproeService.saveUserViewApproe(formData.getAssignee(),formData.getFormid().toString(),formData.getTenantid().toString()); - }else{ + userViewApproeService.saveUserViewApproe(formData.getAssignee(), formData.getFormid().toString(), formData.getTenantid().toString()); + } else { ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); //我这里以 流程定义key(oa_category_t定义的关键字,逻辑唯一) + 业务表主键(请假表、调岗表等) + 业务表对应的servicename String businesskey = processInstance.getBusinessKey(); //3、修改业务表状态 //判断业务key是否存在 - if(StringUtils.isNotBlank(businesskey)){ + if (StringUtils.isNotBlank(businesskey)) { String assignee = ""; BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); //传节点定义key获取当前节点 FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); - if(flowElement instanceof UserTask) { + if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; //如果审批不存在,需要在候选组中查询 - if(StringUtils.isBlank(userTask.getAssignee())){ + if (StringUtils.isBlank(userTask.getAssignee())) { assignee = userTask.getAssignee(); } } String[] busskey = businesskey.split(SystemConstantsOa.OA_BUSSINESS_KEY_SPLIT); IFormCustomService iFormCustomService = SpringUtils.getBean(busskey[2]); //设置流程结束状态 - iFormCustomService.endForm(busskey[1],SystemConstantsOa.OA_STATUS_TYPE_REFUSE,assignee,task.getProcessInstanceId(),task.getName()); + iFormCustomService.endForm(busskey[1], SystemConstantsOa.OA_STATUS_TYPE_REFUSE, assignee, task.getProcessInstanceId(), task.getName()); } //1、获取终止节点 - List endNodes =findEndFlowElement(task.getProcessDefinitionId()); + List endNodes = findEndFlowElement(task.getProcessDefinitionId()); String endId = endNodes.get(0).getId(); //2、执行终止 List executions = runtimeService.createExecutionQuery().parentId(task.getProcessInstanceId()).list(); @@ -549,26 +574,27 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request)); //保存当前审批用户与业务表的关系 - userapproveService.save(userToken,taskVO,task); + userapproveService.save(userToken, taskVO, task); return true; - }catch (Exception e){ - log.error("e={}",e); + } catch (Exception e) { + log.error("e={}", e); } return false; } /** * 更新当前节点处理人信息 + * * @param processDefinition */ - public void updateAssignee(String processInstanceId,String processDefinitionId,ProcessDefinition processDefinition){ + public void updateAssignee(String processInstanceId, String processDefinitionId, ProcessDefinition processDefinition) { //如果是多个候选人或者是候选组,做任务拾取 - FlowTaskCompleteVO flowTaskCompleteVO = updateNowTaskAssignee(processInstanceId,processDefinitionId); + FlowTaskCompleteVO flowTaskCompleteVO = updateNowTaskAssignee(processInstanceId, processDefinitionId); - if(null != flowTaskCompleteVO){ + if (null != flowTaskCompleteVO) { Task task = taskService.createTaskQuery().taskId(flowTaskCompleteVO.getTaskId()).singleResult(); @@ -578,14 +604,15 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask String businesskey = processInstance.getBusinessKey(); IFormCustomService iFormCustomService = null; - if(StringUtils.isNotBlank(businesskey)){ + if (StringUtils.isNotBlank(businesskey)) { String[] busskey = businesskey.split(SystemConstantsOa.OA_BUSSINESS_KEY_SPLIT); iFormCustomService = SpringUtils.getBean(busskey[2]); - iFormCustomService.updateForm(busskey[1],processDefinition.getDeploymentId(),processDefinition.getId(),flowTaskCompleteVO.getAssignee(),flowTaskCompleteVO.getTaskId(),processInstanceId,task.getName()); + iFormCustomService.updateForm(busskey[1], processDefinition.getDeploymentId(), processDefinition.getId(), flowTaskCompleteVO.getAssignee(), flowTaskCompleteVO.getTaskId(), processInstanceId, task.getName()); } } } + public List findEndFlowElement(String processDefId) { Process mainProcess = repositoryService.getBpmnModel(processDefId).getMainProcess(); Collection list = mainProcess.getFlowElements(); @@ -594,8 +621,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } return list.stream().filter(f -> f instanceof EndEvent).collect(Collectors.toList()); } + /** * 查看当前执行人列表 + * * @param processInstanceId * @return */ @@ -628,7 +657,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } else { //4.审批人ASSIGNEE_为空,组id List gusers = identityService.createUserQuery().memberOfGroup(identityLink.getGroupId()).list(); - if (null != gusers && gusers.size() > 0 ) { + if (null != gusers && gusers.size() > 0) { users.addAll(gusers); } } @@ -640,7 +669,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask return users; } - public List listTask(String processInstanceId){ + public List listTask(String processInstanceId) { List activeActivityIds = runtimeService.getActiveActivityIds(processInstanceId); return activeActivityIds; @@ -649,9 +678,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask /** * 设置当前审批节点的审批人 * 目前只多候选组和多个候选人起作用 + * * @param processInstanceId */ - public FlowTaskCompleteVO updateNowTaskAssignee(String processInstanceId, String processDefinitionId){ + public FlowTaskCompleteVO updateNowTaskAssignee(String processInstanceId, String processDefinitionId) { FlowTaskCompleteVO flowTaskCompleteVO = null; BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); @@ -660,27 +690,27 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask //记录审批人信息 StringBuffer assignee = new StringBuffer(); - for(Task task:taskList){ + for (Task task : taskList) { //传节点定义key获取当前节点 FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); - if(flowElement instanceof UserTask && StringUtils.isBlank(task.getAssignee())) { + if (flowElement instanceof UserTask && StringUtils.isBlank(task.getAssignee())) { UserTask userTask = (UserTask) flowElement; //如果审批不存在,需要在候选组中查询 - if(StringUtils.isBlank(userTask.getAssignee())){ + if (StringUtils.isBlank(userTask.getAssignee())) { //得到候选人 List candidateUsers = userTask.getCandidateUsers(); - if(null != candidateUsers && !candidateUsers.isEmpty()){ + if (null != candidateUsers && !candidateUsers.isEmpty()) { Random rand = new Random(); taskService.claim(task.getId(), candidateUsers.get(rand.nextInt(candidateUsers.size()))); } //得到候选组 List candidateGroups = userTask.getCandidateGroups(); - if(null != candidateGroups && !candidateGroups.isEmpty()){ + if (null != candidateGroups && !candidateGroups.isEmpty()) { String loginuser = null; - for(String groupid:candidateGroups){ + for (String groupid : candidateGroups) { //获取发起人员信息 HistoricProcessInstance hi = historyService.createHistoricProcessInstanceQuery() .processInstanceId(processInstanceId) @@ -688,8 +718,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask //发起人员登录账号 String startUserId = hi.getStartUserId(); //通过候选组主键,查询审批人员信息,并自动拾取 - loginuser = candidateuserService.getClaimUser(startUserId,groupid); - if(StringUtils.isNotBlank(loginuser)){ + loginuser = candidateuserService.getClaimUser(startUserId, groupid); + if (StringUtils.isNotBlank(loginuser)) { taskService.claim(task.getId(), loginuser); } } @@ -698,16 +728,16 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } } - log.info("task.getAssignee()={}",task.getAssignee()); + log.info("task.getAssignee()={}", task.getAssignee()); Task tasknow = taskService.createTaskQuery().taskId(task.getId()).singleResult(); - log.info("tasknow.getAssignee()={}",tasknow.getAssignee()); - if(StringUtils.isNotBlank(tasknow.getAssignee())){ + log.info("tasknow.getAssignee()={}", tasknow.getAssignee()); + if (StringUtils.isNotBlank(tasknow.getAssignee())) { flowTaskCompleteVO = new FlowTaskCompleteVO(); - if(StringUtils.isNotBlank(assignee.toString())){ + if (StringUtils.isNotBlank(assignee.toString())) { assignee.append("," + tasknow.getAssignee()); - }else{ + } else { assignee.append(tasknow.getAssignee()); } flowTaskCompleteVO.setTaskId(tasknow.getId()); @@ -716,18 +746,21 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } return flowTaskCompleteVO; } + /** * 设置当前审批节点的 */ - public List nowRunTask(String processInstanceId, String processDefinitionId){ + public List nowRunTask(String processInstanceId, String processDefinitionId) { List taskList = taskService.createTaskQuery() .processDefinitionId(processDefinitionId).processInstanceId(processInstanceId) .list(); return taskList; } + /** * 获取下一个节点审批人信息 + * * @param userTaskList * @param bpmnModel * @param currentId @@ -759,7 +792,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask break; } else if (targetFlowElement instanceof EndEvent) { // 结束节点 - }else { + } else { // 没有找到用户节点,且下一节点不是最后一个节点,继续查找 getNextUserTaskList(userTaskList, bpmnModel, targetFlowElement.getId()); } @@ -768,10 +801,11 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask /** * 查询我的已办信息 + * * @param pageUtils */ @Override - public void finishedList(PageUtils pageUtils,HttpServletRequest request) { + public void finishedList(PageUtils pageUtils, HttpServletRequest request) { // 获取当前登录的账号 @@ -801,24 +835,24 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask //我这里以 流程定义key(oa_category_t定义的关键字,逻辑唯一) + 业务表主键(请假表、调岗表等) + 业务表对应的servicename String businesskey = historicProcessInstance.getBusinessKey(); - if(StringUtils.isBlank(businesskey)){ + if (StringUtils.isBlank(businesskey)) { continue; } String[] busskey = businesskey.split(SystemConstantsOa.OA_BUSSINESS_KEY_SPLIT); IFormCustomService iFormCustomService = null; - if(cn.jyjz.xiaoyao.common.base.util.StringUtils.isNotBlank(busskey[2])){ + if (cn.jyjz.xiaoyao.common.base.util.StringUtils.isNotBlank(busskey[2])) { iFormCustomService = SpringUtils.getBean(busskey[2]); //表单主键 flowTask = iFormCustomService.getForm(busskey[1]); } - if(null == flowTask){ + if (null == flowTask) { flowTask = new FlowModelVO(); } // 任务审批耗时 - if(null != historicTaskInstance && null != historicTaskInstance.getDurationInMillis()){ - flowTask.setDuration(historicTaskInstance.getDurationInMillis()/1000+"秒"); + if (null != historicTaskInstance && null != historicTaskInstance.getDurationInMillis()) { + flowTask.setDuration(historicTaskInstance.getDurationInMillis() / 1000 + "秒"); } /*Map variableInstances = taskService.getVariableInstances(historicTaskInstance.getId()); @@ -892,9 +926,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask /** * 查看任务的流程记录 + * * @return */ - public List listHistoriceTask(String processInstanceId){ + public List listHistoriceTask(String processInstanceId) { List historicTaskInstanceDtos = new ArrayList<>(); // 查询当前任务的流转信息 List taskHiInstances = historyService.createHistoricTaskInstanceQuery() @@ -909,19 +944,19 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask dto.setTaskName(taskHiInstance.getName()); dto.setFinishTime(taskHiInstance.getEndTime()); //Map variables = taskHiInstance.getTaskLocalVariables(); - Map variables = taskHiInstance.getProcessVariables(); - if(null != variables && null != variables.get("approvd")){ + Map variables = taskHiInstance.getProcessVariables(); + if (null != variables && null != variables.get("approvd")) { dto.setState(variables.get("approvd").toString()); } - if(taskHiInstance.getDurationInMillis() != null){ - dto.setDuration(taskHiInstance.getDurationInMillis()/1000 + "秒"); + if (taskHiInstance.getDurationInMillis() != null) { + dto.setDuration(taskHiInstance.getDurationInMillis() / 1000 + "秒"); } dto.setTaskDefKey(taskHiInstance.getTaskDefinitionKey()); - if(StringUtils.isNotBlank(taskHiInstance.getAssignee())){ - if(SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())){ + if (StringUtils.isNotBlank(taskHiInstance.getAssignee())) { + if (SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())) { dto.setAssigneeName(taskHiInstance.getAssignee()); - }else{ + } else { User user1 = userService.findByLoginname(taskHiInstance.getAssignee()); dto.setAssigneeName(user1.getUsername()); } @@ -930,7 +965,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask // 还需要根据 HistoricTaskInstance 找到对应的 审批意见 List processInstanceComments = taskService.getProcessInstanceComments(processInstanceId); for (Comment comment : processInstanceComments) { - if(comment.getTaskId().equals(taskHiInstance.getId())){ + if (comment.getTaskId().equals(taskHiInstance.getId())) { // 审批意见 String fullMessage = comment.getFullMessage(); dto.setComment(fullMessage); @@ -944,44 +979,44 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask /** * 查询最终审批数据 * - * @param query 搜索条件 - * @param pageUtils 分页参数 + * @param query 搜索条件 + * @param pageUtils 分页参数 * @return */ - public void getFinalProcessInstances( Map query, PageUtils pageUtils){ + public void getFinalProcessInstances(Map query, PageUtils pageUtils) { ParamterPage paramterPage = new ParamterPage(); paramterPage.setStart((pageUtils.getCurrPage() - 1) * pageUtils.getPageSize()); paramterPage.setPagesize(pageUtils.getPageSize()); - if(StringUtils.isNotBlank(pageUtils.getSortname())){ + if (StringUtils.isNotBlank(pageUtils.getSortname())) { paramterPage.setSortname(pageUtils.getSortname()); - }else{ + } else { paramterPage.setSortname("CREATEDATE"); } - if(StringUtils.isNotBlank(pageUtils.getSortorder())){ + if (StringUtils.isNotBlank(pageUtils.getSortorder())) { paramterPage.setSortorder(pageUtils.getSortorder()); - }else{ + } else { paramterPage.setSortorder("DESC"); } Long count = ocrTaskchildPictureService.listFinalCount(query); - query.put("page",paramterPage); + query.put("page", paramterPage); List list = ocrTaskchildPictureService.listFinal(query); - for(OcrTaskchildPicture taskchildPicture:list){ + for (OcrTaskchildPicture taskchildPicture : list) { //查询对应的流程分类 Category category = categoryService.selectDtoById(taskchildPicture.getCategoryid()); taskchildPicture.setCategoryDto(category); - if(StringUtils.isNotBlank(taskchildPicture.getProcessdefinitionid())){ + if (StringUtils.isNotBlank(taskchildPicture.getProcessdefinitionid())) { - List taskList = this.nowRunTask(taskchildPicture.getProcessinstanceid(),taskchildPicture.getProcessdefinitionid()); - if(null != taskList && !taskList.isEmpty()){ + List taskList = this.nowRunTask(taskchildPicture.getProcessinstanceid(), taskchildPicture.getProcessdefinitionid()); + if (null != taskList && !taskList.isEmpty()) { taskchildPicture.setTaskId(taskList.get(0).getId()); - Task tasknow =taskService.createTaskQuery().taskId(taskchildPicture.getTaskId()).singleResult(); + Task tasknow = taskService.createTaskQuery().taskId(taskchildPicture.getTaskId()).singleResult(); BpmnModel bpmnModel = repositoryService.getBpmnModel(tasknow.getProcessDefinitionId()); // 获取节点定义id String taskDefinitionKey = tasknow.getTaskDefinitionKey(); @@ -1008,23 +1043,23 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask dto.setTaskId(taskHiInstance.getId()); dto.setTaskName(taskHiInstance.getName()); dto.setFinishTime(taskHiInstance.getEndTime()); - if(taskHiInstance.getDurationInMillis() != null){ - dto.setDuration(taskHiInstance.getDurationInMillis()/1000 + "秒"); + if (taskHiInstance.getDurationInMillis() != null) { + dto.setDuration(taskHiInstance.getDurationInMillis() / 1000 + "秒"); } dto.setTaskDefKey(taskHiInstance.getTaskDefinitionKey()); //Map variables = taskHiInstance.getTaskLocalVariables(); - Map variables = taskHiInstance.getProcessVariables(); + Map variables = taskHiInstance.getProcessVariables(); - if(null != variables && null != variables.get("approvd")){ + if (null != variables && null != variables.get("approvd")) { dto.setState(variables.get("approvd").toString()); } - if(StringUtils.isNotBlank(taskHiInstance.getAssignee())){ - if(SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())){ + if (StringUtils.isNotBlank(taskHiInstance.getAssignee())) { + if (SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())) { dto.setAssigneeName(taskHiInstance.getAssignee()); - }else{ + } else { User user1 = userService.findByLoginname(taskHiInstance.getAssignee()); dto.setAssigneeName(user1.getUsername()); @@ -1045,7 +1080,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask List processInstanceComments = taskService.getProcessInstanceComments(taskchildPicture.getProcessinstanceid()); for (Comment comment : processInstanceComments) { - if(comment.getTaskId().equals(taskHiInstance.getId())){ + if (comment.getTaskId().equals(taskHiInstance.getId())) { // 审批意见 String fullMessage = comment.getFullMessage(); dto.setComment(fullMessage); @@ -1066,7 +1101,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask public IPage queryPageByUserSearchId(Integer pageNo, Integer pageSize, String userSearchId) { OcrUsersearch ocrUsersearch = ocrUsersearchService.selectByUserSearchId(userSearchId); List ocrUsersearchchildList = ocrUsersearch.getOcrUsersearchchildList(); - for(OcrUsersearchchild ocrUsersearchchild : ocrUsersearchchildList){ + for (OcrUsersearchchild ocrUsersearchchild : ocrUsersearchchildList) { String searchfield = ocrUsersearchchild.getSearchfield(); switch (searchfield) { case "izupuser": @@ -1104,32 +1139,31 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } - /** * 查询我发起的流程实例 * - * @param query 查询条件 - * @param pageUtils 分页参数 + * @param query 查询条件 + * @param pageUtils 分页参数 * @return */ - public void getMyProcessInstances(Map query, PageUtils pageUtils){ + public void getMyProcessInstances(Map query, PageUtils pageUtils) { ParamterPage paramterPage = new ParamterPage(); paramterPage.setStart((pageUtils.getCurrPage() - 1) * pageUtils.getPageSize()); paramterPage.setPagesize(pageUtils.getPageSize()); - if(StringUtils.isNotBlank(pageUtils.getSortname())){ + if (StringUtils.isNotBlank(pageUtils.getSortname())) { paramterPage.setSortname(pageUtils.getSortname()); - }else{ + } else { paramterPage.setSortname("CREATEDATE"); } - if(StringUtils.isNotBlank(pageUtils.getSortorder())){ + if (StringUtils.isNotBlank(pageUtils.getSortorder())) { paramterPage.setSortorder(pageUtils.getSortorder()); - }else{ + } else { paramterPage.setSortorder("DESC"); } - query.put("page",paramterPage); + query.put("page", paramterPage); Long count = flowableccMybatisDao.listMyCcCount(query); List list = flowableccMybatisDao.listMyCc(query); @@ -1141,9 +1175,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask // flowableccIPage.setCurrent(paramterPage.getStart()); // // flowableccIPage.setRecords(list); - for(FlowUnionVo flowUnionVo:list){ + for (FlowUnionVo flowUnionVo : list) { - if(flowUnionVo.getStates() != null){ + if (flowUnionVo.getStates() != null) { String stateText; switch (flowUnionVo.getStates()) { case 1: @@ -1165,7 +1199,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask // 将中文状态赋值给 flowUnionVo 的状态属性 flowUnionVo.setStatesText(stateText); - }else { + } else { //暂定,后期会修改 flowUnionVo.setStatesText("审批中"); } @@ -1173,13 +1207,13 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask Category category = categoryService.selectDtoById(flowUnionVo.getCategoryid()); flowUnionVo.setCategoryDto(category); - if(StringUtils.isNotBlank(flowUnionVo.getProcessdefinitionid())){ + if (StringUtils.isNotBlank(flowUnionVo.getProcessdefinitionid())) { - List taskList = this.nowRunTask(flowUnionVo.getProcessinstanceid(),flowUnionVo.getProcessdefinitionid()); - if(null != taskList && !taskList.isEmpty()){ + List taskList = this.nowRunTask(flowUnionVo.getProcessinstanceid(), flowUnionVo.getProcessdefinitionid()); + if (null != taskList && !taskList.isEmpty()) { flowUnionVo.setTaskId(taskList.get(0).getId()); - Task tasknow =taskService.createTaskQuery().taskId(flowUnionVo.getTaskId()).singleResult(); + Task tasknow = taskService.createTaskQuery().taskId(flowUnionVo.getTaskId()).singleResult(); BpmnModel bpmnModel = repositoryService.getBpmnModel(tasknow.getProcessDefinitionId()); // 获取节点定义id String taskDefinitionKey = tasknow.getTaskDefinitionKey(); @@ -1208,23 +1242,23 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask dto.setTaskName(taskHiInstance.getName()); flowUnionVo.setNodeName(taskHiInstance.getName()); dto.setFinishTime(taskHiInstance.getEndTime()); - if(taskHiInstance.getDurationInMillis() != null){ - dto.setDuration(taskHiInstance.getDurationInMillis()/1000 + "秒"); + if (taskHiInstance.getDurationInMillis() != null) { + dto.setDuration(taskHiInstance.getDurationInMillis() / 1000 + "秒"); } dto.setTaskDefKey(taskHiInstance.getTaskDefinitionKey()); //Map variables = taskHiInstance.getTaskLocalVariables(); - Map variables = taskHiInstance.getProcessVariables(); + Map variables = taskHiInstance.getProcessVariables(); - if(null != variables && null != variables.get("approvd")){ + if (null != variables && null != variables.get("approvd")) { dto.setState(variables.get("approvd").toString()); } - if(StringUtils.isNotBlank(taskHiInstance.getAssignee())){ - if(SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())){ + if (StringUtils.isNotBlank(taskHiInstance.getAssignee())) { + if (SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())) { dto.setAssigneeName(taskHiInstance.getAssignee()); - }else{ + } else { User user1 = userService.findByLoginname(taskHiInstance.getAssignee()); dto.setAssigneeName(user1.getUsername()); @@ -1245,7 +1279,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask List processInstanceComments = taskService.getProcessInstanceComments(flowUnionVo.getProcessinstanceid()); for (Comment comment : processInstanceComments) { - if(comment.getTaskId().equals(taskHiInstance.getId())){ + if (comment.getTaskId().equals(taskHiInstance.getId())) { // 审批意见 String fullMessage = comment.getFullMessage(); dto.setComment(fullMessage); @@ -1261,6 +1295,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask pageUtils.setList(list); } + /** * 查询我的待办、已经办理任务 * @@ -1268,43 +1303,43 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask * @param tenantId * @param pageUtils */ - public void getMyProcessInstances(User user,String tenantId,Map searchQuery, PageUtils pageUtils){ + public void getMyProcessInstances(User user, String tenantId, Map searchQuery, PageUtils pageUtils) { ParamterPage paramterPage = new ParamterPage(); paramterPage.setStart((pageUtils.getCurrPage() - 1) * pageUtils.getPageSize()); paramterPage.setPagesize(pageUtils.getPageSize()); - if(StringUtils.isNotBlank(pageUtils.getSortname())){ + if (StringUtils.isNotBlank(pageUtils.getSortname())) { paramterPage.setSortname(pageUtils.getSortname()); - }else{ + } else { paramterPage.setSortname("CREATEDATE"); } - if(StringUtils.isNotBlank(pageUtils.getSortorder())){ + if (StringUtils.isNotBlank(pageUtils.getSortorder())) { paramterPage.setSortorder(pageUtils.getSortorder()); - }else{ + } else { paramterPage.setSortorder("DESC"); } Map query = new HashMap<>(); - query.put("page",paramterPage); + query.put("page", paramterPage); - query.put("thisLoginUserid",user.getId().toString()); - query.put("searchtenantid",tenantId); + query.put("thisLoginUserid", user.getId().toString()); + query.put("searchtenantid", tenantId); //我的待办数据 - query.put("searchassignee",user.getLoginname()); + query.put("searchassignee", user.getLoginname()); query.putAll(searchQuery); Long count = ocrTaskchildPictureService.listmytaskCount(query); - query.put("page",paramterPage); + query.put("page", paramterPage); List list = ocrTaskchildPictureService.listmytask(query); - for(OcrTaskchildPictureAppro taskchildPicture:list){ + for (OcrTaskchildPictureAppro taskchildPicture : list) { - if(taskchildPicture.getPictureid() != null && !taskchildPicture.getPictureid().isEmpty()){ + if (taskchildPicture.getPictureid() != null && !taskchildPicture.getPictureid().isEmpty()) { Long pictureId = Long.parseLong(taskchildPicture.getPictureid()); LambdaQueryWrapper ocrPictureLambdaQueryWrapper = new LambdaQueryWrapper<>(); - ocrPictureLambdaQueryWrapper.eq(OcrPicture::getId,pictureId); + ocrPictureLambdaQueryWrapper.eq(OcrPicture::getId, pictureId); OcrPicture ocrPictureOne = ocrPictureService.getOne(ocrPictureLambdaQueryWrapper); taskchildPicture.setFromUserName(ocrPictureOne.getField1()); } @@ -1313,13 +1348,13 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask Category category = categoryService.selectDtoById(Long.parseLong(taskchildPicture.getCategoryid())); taskchildPicture.setCategoryDto(category); - if(StringUtils.isNotBlank(taskchildPicture.getProcessdefinitionid())){ + if (StringUtils.isNotBlank(taskchildPicture.getProcessdefinitionid())) { - List taskList = this.nowRunTask(taskchildPicture.getProcessinstanceid(),taskchildPicture.getProcessdefinitionid()); - if(null != taskList && !taskList.isEmpty()){ + List taskList = this.nowRunTask(taskchildPicture.getProcessinstanceid(), taskchildPicture.getProcessdefinitionid()); + if (null != taskList && !taskList.isEmpty()) { taskchildPicture.setTaskId(taskList.get(0).getId()); - Task tasknow =taskService.createTaskQuery().taskId(taskchildPicture.getTaskId()).singleResult(); + Task tasknow = taskService.createTaskQuery().taskId(taskchildPicture.getTaskId()).singleResult(); BpmnModel bpmnModel = repositoryService.getBpmnModel(tasknow.getProcessDefinitionId()); // 获取节点定义id String taskDefinitionKey = tasknow.getTaskDefinitionKey(); @@ -1346,23 +1381,23 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask dto.setTaskId(taskHiInstance.getId()); dto.setTaskName(taskHiInstance.getName()); dto.setFinishTime(taskHiInstance.getEndTime()); - if(taskHiInstance.getDurationInMillis() != null){ - dto.setDuration(taskHiInstance.getDurationInMillis()/1000 + "秒"); + if (taskHiInstance.getDurationInMillis() != null) { + dto.setDuration(taskHiInstance.getDurationInMillis() / 1000 + "秒"); } dto.setTaskDefKey(taskHiInstance.getTaskDefinitionKey()); //Map variables = taskHiInstance.getTaskLocalVariables(); - Map variables = taskHiInstance.getProcessVariables(); + Map variables = taskHiInstance.getProcessVariables(); - if(null != variables && null != variables.get("approvd")){ + if (null != variables && null != variables.get("approvd")) { dto.setState(variables.get("approvd").toString()); } - if(StringUtils.isNotBlank(taskHiInstance.getAssignee())){ - if(SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())){ + if (StringUtils.isNotBlank(taskHiInstance.getAssignee())) { + if (SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())) { dto.setAssigneeName(taskHiInstance.getAssignee()); - }else{ + } else { User user1 = userService.findByLoginname(taskHiInstance.getAssignee()); dto.setAssigneeName(user1.getUsername()); @@ -1383,7 +1418,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask List processInstanceComments = taskService.getProcessInstanceComments(taskchildPicture.getProcessinstanceid()); for (Comment comment : processInstanceComments) { - if(comment.getTaskId().equals(taskHiInstance.getId())){ + if (comment.getTaskId().equals(taskHiInstance.getId())) { // 审批意见 String fullMessage = comment.getFullMessage(); dto.setComment(fullMessage); @@ -1400,11 +1435,11 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask //补充历史状态名称,检查补充节点信息 for (OcrTaskchildPictureAppro ocrTaskchildPictureAppro : list) { //审批节点 当前如果没有历史操作,则将当前节点赋值到历史审批节点中. - if(StringUtils.isBlank(ocrTaskchildPictureAppro.getTasknamehis())){ + if (StringUtils.isBlank(ocrTaskchildPictureAppro.getTasknamehis())) { ocrTaskchildPictureAppro.setTasknamehis(ocrTaskchildPictureAppro.getTaskname()); } - if(ocrTaskchildPictureAppro.getStatshis() != null){ + if (ocrTaskchildPictureAppro.getStatshis() != null) { String stateText; switch (ocrTaskchildPictureAppro.getStatshis()) { case 1: @@ -1423,7 +1458,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask // 将中文状态赋值给 flowUnionVo 的状态属性 ocrTaskchildPictureAppro.setStatshisText(stateText); - }else { + } else { //暂定,后期修改 ocrTaskchildPictureAppro.setStatshisText("待审批"); } @@ -1437,28 +1472,28 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask * @param query 查询条件 * @return */ - public List getMyProcessInstances(Map query){ + public List getMyProcessInstances(Map query) { ParamterPage paramterPage = new ParamterPage(); paramterPage.setSortname("CREATEDATE"); paramterPage.setSortorder("DESC"); - query.put("page",paramterPage); + query.put("page", paramterPage); List list = flowableccMybatisDao.listMyCc(query); - for(FlowUnionVo flowUnionVo:list){ + for (FlowUnionVo flowUnionVo : list) { //查询对应的流程分类 Category category = categoryService.selectDtoById(flowUnionVo.getCategoryid()); flowUnionVo.setCategoryDto(category); - if(StringUtils.isNotBlank(flowUnionVo.getProcessdefinitionid())){ + if (StringUtils.isNotBlank(flowUnionVo.getProcessdefinitionid())) { - List taskList = this.nowRunTask(flowUnionVo.getProcessinstanceid(),flowUnionVo.getProcessdefinitionid()); - if(null != taskList && !taskList.isEmpty()){ + List taskList = this.nowRunTask(flowUnionVo.getProcessinstanceid(), flowUnionVo.getProcessdefinitionid()); + if (null != taskList && !taskList.isEmpty()) { flowUnionVo.setTaskId(taskList.get(0).getId()); - Task tasknow =taskService.createTaskQuery().taskId(flowUnionVo.getTaskId()).singleResult(); + Task tasknow = taskService.createTaskQuery().taskId(flowUnionVo.getTaskId()).singleResult(); BpmnModel bpmnModel = repositoryService.getBpmnModel(tasknow.getProcessDefinitionId()); // 获取节点定义id String taskDefinitionKey = tasknow.getTaskDefinitionKey(); @@ -1486,23 +1521,23 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask dto.setTaskId(taskHiInstance.getId()); dto.setTaskName(taskHiInstance.getName()); dto.setFinishTime(taskHiInstance.getEndTime()); - if(taskHiInstance.getDurationInMillis() != null){ - dto.setDuration(taskHiInstance.getDurationInMillis()/1000 + "秒"); + if (taskHiInstance.getDurationInMillis() != null) { + dto.setDuration(taskHiInstance.getDurationInMillis() / 1000 + "秒"); } dto.setTaskDefKey(taskHiInstance.getTaskDefinitionKey()); //Map variables = taskHiInstance.getTaskLocalVariables(); - Map variables = taskHiInstance.getProcessVariables(); + Map variables = taskHiInstance.getProcessVariables(); - if(null != variables && null != variables.get("approvd")){ + if (null != variables && null != variables.get("approvd")) { dto.setState(variables.get("approvd").toString()); } - if(StringUtils.isNotBlank(taskHiInstance.getAssignee())){ - if(SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())){ + if (StringUtils.isNotBlank(taskHiInstance.getAssignee())) { + if (SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())) { dto.setAssigneeName(taskHiInstance.getAssignee()); - }else{ + } else { User user1 = userService.findByLoginname(taskHiInstance.getAssignee()); dto.setAssigneeName(user1.getUsername()); @@ -1523,7 +1558,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask List processInstanceComments = taskService.getProcessInstanceComments(flowUnionVo.getProcessinstanceid()); for (Comment comment : processInstanceComments) { - if(comment.getTaskId().equals(taskHiInstance.getId())){ + if (comment.getTaskId().equals(taskHiInstance.getId())) { // 审批意见 String fullMessage = comment.getFullMessage(); dto.setComment(fullMessage); @@ -1537,31 +1572,32 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask return list; } + /** * 抄送给我的 * * @return */ - public IPage getMyListCc(Map query, UserToken userToken, ParamterPage paramterPage){ + public IPage getMyListCc(Map query, UserToken userToken, ParamterPage paramterPage) { //查询抄送给当前用户的fromid集合 QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.eq("USERID",userToken.getUserid()); + queryWrapper.eq("USERID", userToken.getUserid()); List listCc = flowableccMybatisDao.selectList(queryWrapper); - if(null == listCc || listCc.isEmpty()){ + if (null == listCc || listCc.isEmpty()) { return null; } List listFromid = new ArrayList<>(); - for(Flowablecc flowablecc:listCc){ + for (Flowablecc flowablecc : listCc) { listFromid.add(flowablecc.getFormid().toString()); } - query.put("listFlowCcUserid",listFromid); + query.put("listFlowCcUserid", listFromid); paramterPage.setSortname("CREATEDATE"); paramterPage.setSortorder("DESC"); - query.put("page",paramterPage); + query.put("page", paramterPage); Long count = flowableccMybatisDao.listMyCcCount(query); List list = flowableccMybatisDao.listMyCc(query); @@ -1572,21 +1608,20 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask flowableccIPage.setTotal(count); flowableccIPage.setCurrent(paramterPage.getStart()); - for(FlowUnionVo flowUnionVo:list){ + for (FlowUnionVo flowUnionVo : list) { //查询对应的流程分类 Category category = categoryService.selectDtoById(flowUnionVo.getCategoryid()); flowUnionVo.setCategoryDto(category); - if(StringUtils.isNotBlank(flowUnionVo.getProcessdefinitionid())){ + if (StringUtils.isNotBlank(flowUnionVo.getProcessdefinitionid())) { - List taskList = this.nowRunTask(flowUnionVo.getProcessinstanceid(),flowUnionVo.getProcessdefinitionid()); - if(null != taskList && !taskList.isEmpty()){ + List taskList = this.nowRunTask(flowUnionVo.getProcessinstanceid(), flowUnionVo.getProcessdefinitionid()); + if (null != taskList && !taskList.isEmpty()) { flowUnionVo.setTaskId(taskList.get(0).getId()); } - //查询历史 List historicTaskInstanceDtos = new ArrayList<>(); // 查询当前任务的流转信息 @@ -1600,14 +1635,14 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask dto.setTaskId(taskHiInstance.getId()); dto.setTaskName(taskHiInstance.getName()); dto.setFinishTime(taskHiInstance.getEndTime()); - if(taskHiInstance.getDurationInMillis() != null){ - dto.setDuration(taskHiInstance.getDurationInMillis()/1000 + "秒"); + if (taskHiInstance.getDurationInMillis() != null) { + dto.setDuration(taskHiInstance.getDurationInMillis() / 1000 + "秒"); } dto.setTaskDefKey(taskHiInstance.getTaskDefinitionKey()); - if(StringUtils.isNotBlank(taskHiInstance.getAssignee())){ - if(SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())){ + if (StringUtils.isNotBlank(taskHiInstance.getAssignee())) { + if (SystemConstantsOa.OA_TASK_SKIP_ASSIGINE.equals(taskHiInstance.getAssignee())) { dto.setAssigneeName(taskHiInstance.getAssignee()); - }else{ + } else { User user1 = userService.findByLoginname(taskHiInstance.getAssignee()); dto.setAssigneeName(user1.getUsername()); @@ -1618,7 +1653,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask // 还需要根据 HistoricTaskInstance 找到对应的 审批意见 List processInstanceComments = taskService.getProcessInstanceComments(flowUnionVo.getProcessinstanceid()); for (Comment comment : processInstanceComments) { - if(comment.getTaskId().equals(taskHiInstance.getId())){ + if (comment.getTaskId().equals(taskHiInstance.getId())) { // 审批意见 String fullMessage = comment.getFullMessage(); dto.setComment(fullMessage); @@ -1633,12 +1668,13 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask flowableccIPage.setRecords(list); return flowableccIPage; } + public void cancelTask(String taskId, String reason) { // 获取当前任务 Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); - if(null == processInstance){ + if (null == processInstance) { throw new RuntimeException("流程已经结束,无法撤回。"); } String businessKey = processInstance.getBusinessKey(); @@ -1646,9 +1682,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask Category category = this.categoryService.getById(busskey[1]); IFormCustomService iFormCustomService = null; - if(null != category){ + if (null != category) { iFormCustomService = SpringUtils.getBean(category.getServicename()); - iFormCustomService.editStatesForm(busskey[1],SystemConstantsOa.OA_STATUS_TYPE_CANCLE,""); + iFormCustomService.editStatesForm(busskey[1], SystemConstantsOa.OA_STATUS_TYPE_CANCLE, ""); } runtimeService.deleteProcessInstance(processInstance.getProcessInstanceId(), SystemMessage.SYS_OA_START_CANCLE); @@ -1659,14 +1695,14 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } - public ResultVo removeTask(String fromid,String taskid) { + public ResultVo removeTask(String fromid, String taskid) { // 获取当前任务 OcrTaskchildPicture ocrTaskchildPicture = this.ocrTaskchildPictureService.selectDtoById(Long.parseLong(fromid)); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(ocrTaskchildPicture.getProcessinstanceid()).singleResult(); - if(null == processInstance){ + if (null == processInstance) { //查询项目对象 Category category = this.categoryService.getById(ocrTaskchildPicture.getCategoryid()); @@ -1677,17 +1713,17 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask String historyProcessDefinitionId = terminatedInstances.get(0).getProcessDefinitionId(); - boolean isStart = iFlowInstanceService.startProcessInstanceById(historyProcessDefinitionId,ocrTaskchildPicture.getCreateusername(), - ocrTaskchildPicture.getCreateuser(),ocrTaskchildPicture.getId().toString(),category.getServicename()); + boolean isStart = iFlowInstanceService.startProcessInstanceById(historyProcessDefinitionId, ocrTaskchildPicture.getCreateusername(), + ocrTaskchildPicture.getCreateuser(), ocrTaskchildPicture.getId().toString(), category.getServicename()); - if(isStart){ + if (isStart) { ResultVoUtil.success(); - }else{ + } else { ResultVoUtil.error(); } - }else{ + } else { Task task = taskService.createTaskQuery().taskId(taskid).singleResult(); - taskService.addComment(task.getId(),task.getProcessInstanceId(),"流程重置。"); + taskService.addComment(task.getId(), task.getProcessInstanceId(), "流程重置。"); List flowNodeVOList = getReturnTaskList(task.getId()); @@ -1697,12 +1733,12 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask //查询项目对象 Category category = this.categoryService.getById(ocrTaskchildPicture.getCategoryid()); - boolean isStart = iFlowInstanceService.startProcessInstanceById(task.getProcessDefinitionId(),ocrTaskchildPicture.getCreateusername(), - ocrTaskchildPicture.getCreateuser(),ocrTaskchildPicture.getId().toString(),category.getServicename()); + boolean isStart = iFlowInstanceService.startProcessInstanceById(task.getProcessDefinitionId(), ocrTaskchildPicture.getCreateusername(), + ocrTaskchildPicture.getCreateuser(), ocrTaskchildPicture.getId().toString(), category.getServicename()); - if(isStart){ + if (isStart) { ResultVoUtil.success(); - }else{ + } else { ResultVoUtil.error(); } log.info("TaskId:{},流程跳到到:{}", task.getId().toString(), targetRealActivityId);