| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.highdatas.mdm.entity.Flows; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MaintainField; |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.FlowsMapper; |
| | | import com.highdatas.mdm.pojo.*; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.service.act.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.TodoClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.activiti.engine.history.HistoricActivityInstance; |
| | | import org.activiti.engine.history.HistoricProcessInstance; |
| | | import org.activiti.engine.task.Task; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | TodoClient client; |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/list/{pageNo}", method = RequestMethod.GET) |
| | | public Result<List<Map<String, Object>>> list(@PathVariable Integer pageNo, HttpServletRequest request) { |
| | |
| | | List<Map<String, Object>> list = flowsMapper.selectVersion(filterSegment); |
| | | for (Map<String, Object> one : list) { |
| | | String newModelId = (String) one.get(Constant.ID); |
| | | String url = "act/img/" + newModelId; |
| | | one.put("imgurl",url); |
| | | String url = "act/img/" + newModelId; |
| | | one.put("imgurl", url); |
| | | } |
| | | Integer size; |
| | | if(StringUtils.isEmpty(pageSize)){ |
| | | if (StringUtils.isEmpty(pageSize)) { |
| | | size = 15; |
| | | }else { |
| | | } else { |
| | | size = Integer.valueOf(pageSize); |
| | | } |
| | | return fieldService.getPagedDataByList(list, pageNo, size); |
| | | } |
| | | @RequestMapping(value = "/img/{modelId}", method = RequestMethod.GET) |
| | | public void image(@PathVariable String modelId, HttpServletResponse response) { |
| | | InputStream is = repositoryService.getModelImg(modelId); |
| | | |
| | | @RequestMapping(value = "/img/{modelId}", method = RequestMethod.GET) |
| | | public void image(@PathVariable String modelId, HttpServletResponse response) { |
| | | InputStream is = repositoryService.getModelImg(modelId); |
| | | if (is == null) { |
| | | return; |
| | | } |
| | | response.setHeader("Content-Type", "image/png"); |
| | | try{ |
| | | try { |
| | | OutputStream outputStream = response.getOutputStream(); |
| | | byte[] b = new byte[1024]; |
| | | int len; |
| | | while ((len = is.read(b, 0, 1024)) != -1) { |
| | | outputStream.write(b, 0, len); |
| | | } |
| | | } |
| | | catch (Exception e) { |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | finally { |
| | | } finally { |
| | | if (is != null) { |
| | | try { |
| | | is.close(); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/deleteModel/{modelId}", method = RequestMethod.GET) |
| | | public Result deleteModel(@PathVariable String modelId) { |
| | | public Result deleteModel(@PathVariable String modelId) { |
| | | boolean b = repositoryService.deleteModel(modelId); |
| | | if (b) { |
| | | return Result.success(null); |
| | |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/processlist", method = RequestMethod.GET) |
| | | public Result<Result<JSONArray>> processlist(HttpServletRequest request) { |
| | | Result<JSONArray> processList = repositoryService.getProcessList(); |
| | | public Result<Result<JSONArray>> processlist(HttpServletRequest request) { |
| | | Result<JSONArray> processList = repositoryService.getProcessList(); |
| | | return Result.success(processList); |
| | | } |
| | | |
| | | @RequestMapping(value = "/modellist", method = RequestMethod.GET) |
| | | public Result<Result<JSONArray>> modellist(HttpServletRequest request) { |
| | | Result<JSONArray> processList = repositoryService.getProcessList(); |
| | | public Result<Result<JSONArray>> modellist(HttpServletRequest request) { |
| | | Result<JSONArray> processList = repositoryService.getProcessList(); |
| | | return Result.success(processList); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/start/{key}", method = RequestMethod.GET) |
| | | public Result<Object> start(@PathVariable String key,@RequestParam String businessId, HttpServletRequest request) { |
| | | if (StringUtils.isEmpty(key)) { |
| | | return Result.error(new CodeMsg(1000, "key is not found")); |
| | | @RequestMapping(value = "/started", method = RequestMethod.POST) |
| | | public Result<Object> startRun(@RequestBody JSONArray result) { |
| | | for (int i = 0; i < result.size(); i++) { |
| | | String flowId = result.getString(i); |
| | | log.info(flowId); |
| | | } |
| | | String desp = request.getParameter("desp"); |
| | | return Result.success(null); |
| | | } |
| | | |
| | | @RequestMapping(value = "/startRun/{key}", method = RequestMethod.GET) |
| | | public Result<Object> startRun(@PathVariable String key, @RequestParam String businessId, HttpServletRequest request) { |
| | | TUser user = DbUtils.getUser(request); |
| | | String businessType = request.getParameter("businessType"); |
| | | ActivitiBusinessType type; |
| | | if (StringUtils.isEmpty(businessType)) { |
| | |
| | | } else { |
| | | type = ActivitiBusinessType.valueOf(businessType); |
| | | } |
| | | String content; |
| | | if (type.equals(ActivitiBusinessType.maintain)) { |
| | | Maintain maintain = maintainService.selectById(businessId); |
| | | SysMenu menuByTableName = menuMappingService.getMenuByTableName(maintain.getTableName()); |
| | | content = menuByTableName.getName() + "主题新增版本需要审批"; |
| | | } else { |
| | | MaintainField maintainField = maintainFieldService.selectById(businessId); |
| | | SysMenu menuByTableName = menuMappingService.getMenuByTableName(maintainField.getTableName()); |
| | | content = menuByTableName.getName() + "主题修改字段需要审批"; |
| | | } |
| | | boolean open = client.open(key, businessId, content, user.getUserId(), type); |
| | | if (open) { |
| | | return Result.success(CodeMsg.SUCCESS); |
| | | } else { |
| | | return Result.error(CodeMsg.Client_fail); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/start/{key}", method = RequestMethod.POST) |
| | | public Result<Object> start(@PathVariable String key, @RequestBody JSONObject reqObj, HttpServletRequest request) { |
| | | log.info("process start.."); |
| | | if (StringUtils.isEmpty(key)) { |
| | | return Result.error(new CodeMsg(1000, "key is not found")); |
| | | } |
| | | |
| | | String businessId = reqObj.getString("businessId"); |
| | | if (StringUtils.isEmpty(businessId)) { |
| | | return Result.error(new CodeMsg(1000, "businessId is not found")); |
| | | } |
| | | String businessType = reqObj.getString("businessType"); |
| | | JSONObject variableObj = reqObj.getJSONObject("variableMap"); |
| | | Map<String, Object> variableMap = new HashMap<>(); |
| | | if (variableObj != null) { |
| | | variableMap = DbUtils.JsonObjectToHashMap(variableObj); |
| | | } |
| | | ActivitiBusinessType type; |
| | | if (StringUtils.isEmpty(businessType)) { |
| | | type = ActivitiBusinessType.maintain; |
| | | } else { |
| | | type = ActivitiBusinessType.valueOf(businessType); |
| | | } |
| | | Object descObj = variableMap.get("desc"); |
| | | String desc; |
| | | if (descObj == null) { |
| | | desc = "创建新版本"; |
| | | } else { |
| | | desc = descObj.toString(); |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | Flows flows = activitiService.start(key, session, businessId, type); |
| | | Date startDate = new Date(); |
| | | Flows flows = activitiService.start(key, session, businessId, type, variableMap); |
| | | Date endDate = new Date(); |
| | | log.info("process start:" + (endDate.getTime() - startDate.getTime()) + "ms"); |
| | | if (flows == null) { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } else { |
| | | } else { |
| | | if (type.equals(ActivitiBusinessType.field)) { |
| | | MaintainField maintainField = maintainFieldService.selectById(businessId); |
| | | maintainField.setFlowId(flows.getId()); |
| | | maintainField.setDesp(desp); |
| | | maintainField.setDesp(desc); |
| | | maintainField.updateById(); |
| | | return Result.success(flows.getId()); |
| | | } |
| | | else if (type.equals(ActivitiBusinessType.maintain)) { |
| | | } else if (type.equals(ActivitiBusinessType.maintain)) { |
| | | Maintain maintain = maintainService.selectById(businessId); |
| | | maintain.setFlowId(flows.getId()); |
| | | maintain.setDesp(desp); |
| | | maintain.setDesp(desc); |
| | | maintain.updateById(); |
| | | return Result.success(flows.getId()); |
| | | }else if (type.equals(ActivitiBusinessType.exists)) { |
| | | HashMap<String, Object> body=new HashMap(); |
| | | NextTaskUserInfo nestTaskAssignee = taskService.getNestTaskAssignee(flows.getWorkflowId()); |
| | | |
| | | body.put("activitiId", flows.getId()); |
| | | if (nestTaskAssignee == null) { |
| | | body.put("roleIdList", null); |
| | | body.put("userIdList", null); |
| | | } else { |
| | | body.put("roleIdList", nestTaskAssignee.getRoleIdList()); |
| | | body.put("userIdList", nestTaskAssignee.getUserIdList()); |
| | | } |
| | | return Result.success(body); |
| | | } |
| | | startDate = new Date(); |
| | | log.info("process save status:" + (startDate.getTime() - endDate.getTime()) + "ms"); |
| | | HashMap<String, Object> body = new HashMap(); |
| | | NextTaskUserInfo nestTaskAssignee = taskService.getNestTaskAssignee(flows.getWorkflowId()); |
| | | endDate = new Date(); |
| | | log.info("process find user info:" + (endDate.getTime() - startDate.getTime()) + "ms"); |
| | | body.put("activitiId", flows.getId()); |
| | | if (nestTaskAssignee == null) { |
| | | body.put("roleIdList", null); |
| | | body.put("userIdList", null); |
| | | } else { |
| | | body.put("roleIdList", nestTaskAssignee.getRoleIdList()); |
| | | body.put("userIdList", nestTaskAssignee.getUserIdList()); |
| | | } |
| | | return Result.success(body); |
| | | } |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | |
| | | @RequestMapping(value = "/status/{flowid}", method = RequestMethod.GET) |
| | | public ArrayList<HistoricActivityInstance> status(@PathVariable String flowid, HttpServletRequest request) { |
| | | public ArrayList<HistoricActivityInstance> status(@PathVariable String flowid, HttpServletRequest request) { |
| | | if (StringUtils.isEmpty(flowid)) { |
| | | return null; |
| | | } |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "{tableName}/history/{pageNo}", method = RequestMethod.GET) |
| | | public Result history(@PathVariable String tableName, @PathVariable Integer pageNo, HttpServletRequest request) { |
| | | public Result history(@PathVariable String tableName, @PathVariable Integer pageNo, HttpServletRequest request) { |
| | | historyService.setSession(request.getSession()); |
| | | String pageSizeStr = request.getParameter("pageSize"); |
| | | |
| | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("passiveQueueSize", page.getPageSize()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("record", result); |
| | |
| | | |
| | | |
| | | @RequestMapping(value = "/diagram/{flowid}", method = RequestMethod.GET) |
| | | public void getDiagram(@PathVariable String flowid, HttpServletResponse response) { |
| | | public void getDiagram(@PathVariable String flowid, HttpServletResponse response) { |
| | | if (StringUtils.isEmpty(flowid)) { |
| | | return; |
| | | } |
| | |
| | | String workflowid = flows.getWorkflowId(); |
| | | runtimeService.getDiagram(workflowid, response); |
| | | } |
| | | |
| | | @RequestMapping(value = "/run", method = RequestMethod.GET) |
| | | public List<Map<String, String>> runTask(HttpServletRequest request){ |
| | | public List<Map<String, String>> runTask(HttpServletRequest request) { |
| | | historyService.setSession(request.getSession()); |
| | | List<Map<String, String>> myRunTask = historyService.getMyRunTask(); |
| | | return myRunTask; |
| | | } |
| | | |
| | | @RequestMapping(value = "/todo", method = RequestMethod.GET) |
| | | public Result todoTask(HttpServletRequest request){ |
| | | public Result todoTask(HttpServletRequest request) { |
| | | String pageNo = request.getParameter("pageNo"); |
| | | String pageSize = request.getParameter("pageSize"); |
| | | if (StringUtils.isEmpty(pageNo)) { |
| | |
| | | return activitiService.todoTask(request.getSession(), request.getParameter(Constant.tableName), Integer.valueOf(pageNo), Integer.valueOf(pageSize)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/deal/{flowid}", method = RequestMethod.GET) |
| | | public Result doTask(@PathVariable String flowid, @RequestParam boolean pass, HttpServletRequest request) { |
| | | @RequestMapping(value = "/deal/{flowid}", method = RequestMethod.POST) |
| | | @Transactional(rollbackFor = {RuntimeException.class, Error.class}) |
| | | public Result doTask(@PathVariable String flowid, @RequestBody JSONObject reqObj, HttpServletRequest request) { |
| | | if (StringUtils.isEmpty(flowid)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | |
| | | if (flows == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | //todo 判断当前task是否是当前人能审批的 |
| | | Boolean pass; |
| | | try { |
| | | pass = (boolean) reqObj.get("pass"); |
| | | if (pass == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | HashMap<String, Object> vailableMap = DbUtils.JsonObjectToHashMap(reqObj); |
| | | |
| | | HttpSession session = request.getSession(); |
| | | taskService.setSession(session); |
| | | ActivitiStatus status = flows.getStatus(); |
| | | |
| | | String workflowId = flows.getWorkflowId(); |
| | | // Task task = TimeTaskService.geTask(workflowId); |
| | | // String id = task.getId(); |
| | |
| | | } |
| | | |
| | | String reason; |
| | | reason = request.getParameter("reason"); |
| | | if (StringUtils.isEmpty(reason)) { |
| | | Object reasonObj = vailableMap.get("reason"); |
| | | if (reasonObj == null) { |
| | | reason = "确认处理"; |
| | | }else { |
| | | reason = reasonObj.toString(); |
| | | } |
| | | if (taskId == null) { |
| | | Task task = taskService.geTask(workflowId); |
| | |
| | | taskId = task.getId(); |
| | | } |
| | | |
| | | boolean completed = taskService.completeTask(taskId, pass, reason); |
| | | boolean completed = taskService.completeTask(taskId, pass, reason, vailableMap); |
| | | |
| | | if (completed) { |
| | | NextTaskUserInfo nextTaskDefinition = null; |
| | | boolean taskFinished = historyService.isTaskFinished(workflowId); |
| | | if (taskFinished) { |
| | | if (ActivitiStatus.refuse.equals(status)) { |
| | | flows.setStatus(ActivitiStatus.close); |
| | | } else { |
| | | flows.setStatus(ActivitiStatus.open); |
| | | } |
| | | |
| | | if (!pass) { |
| | | flows.setStatus(ActivitiStatus.close); |
| | | } |
| | | |
| | | |
| | | flowsService.aduitFinish(flows); |
| | | |
| | | NextTaskUserInfo nextTaskDefinition = null; |
| | | boolean taskFinished = historyService.isTaskFinished(workflowId); |
| | | if (taskFinished) { |
| | | if (ActivitiStatus.refuse.equals(status)) { |
| | | flows.setStatus(ActivitiStatus.close); |
| | | } else { |
| | | if (pass && flows.getStatus().equals(ActivitiStatus.refuse)) { |
| | | flows.setStatus(ActivitiStatus.working); |
| | | } else if(!pass && flows.getStatus().equals(ActivitiStatus.working)){ |
| | | flows.setStatus(ActivitiStatus.refuse); |
| | | } |
| | | nextTaskDefinition = taskService.getNestTaskAssignee(workflowId); |
| | | flows.setStatus(ActivitiStatus.open); |
| | | } |
| | | |
| | | if (!pass) { |
| | | flows.setStatus(ActivitiStatus.close); |
| | | } |
| | | HashMap<String, Object> body=new HashMap(); |
| | | if (flows.getBusinessType().equals(ActivitiBusinessType.exists)){ |
| | | body.put("status", flows.getStatus().name()); |
| | | if (nextTaskDefinition == null) { |
| | | body.put("roleIdList", null); |
| | | body.put("userIdList", null); |
| | | } else { |
| | | body.put("roleIdList", nextTaskDefinition.getRoleIdList()); |
| | | body.put("userIdList", nextTaskDefinition.getUserIdList()); |
| | | |
| | | flowsService.aduitFinish(flows); |
| | | |
| | | } else { |
| | | if (pass && flows.getStatus().equals(ActivitiStatus.refuse)) { |
| | | flows.setStatus(ActivitiStatus.working); |
| | | } else if (!pass && flows.getStatus().equals(ActivitiStatus.working)) { |
| | | flows.setStatus(ActivitiStatus.refuse); |
| | | } |
| | | nextTaskDefinition = taskService.getNestTaskAssignee(workflowId); |
| | | |
| | | } |
| | | HashMap<String, Object> body = new HashMap(); |
| | | |
| | | body.put("status", flows.getStatus().name()); |
| | | if (nextTaskDefinition == null) { |
| | | body.put("roleIdList", null); |
| | | body.put("userIdList", null); |
| | | } else { |
| | | body.put("roleIdList", nextTaskDefinition.getRoleIdList()); |
| | | body.put("userIdList", nextTaskDefinition.getUserIdList()); |
| | | } |
| | | |
| | | flows.setUpdateTime(new Date()); |
| | | flowsService.updateById(flows); |
| | | return Result.success(body); |
| | | }else { |
| | | } else { |
| | | return Result.success(CodeMsg.INSERT_ERROR); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/addActUser") |
| | | public Result addActUser(@RequestParam String userId){ |
| | | public Result addActUser(@RequestParam String userId) { |
| | | return identityService.addUser(userId); |
| | | } |
| | | |
| | | @RequestMapping(value = "/addActRole") |
| | | public Result addActRole(@RequestParam String roleId){ |
| | | public Result addActRole(@RequestParam String roleId) { |
| | | return identityService.addRole(roleId); |
| | | } |
| | | |
| | | @RequestMapping(value = "/addActUserRole") |
| | | public Result addActUserRole(@RequestParam String roleId, @RequestParam String userId){ |
| | | return identityService.addUserRole(roleId,userId); |
| | | public Result addActUserRole(@RequestParam String roleId, @RequestParam String userId) { |
| | | return identityService.addUserRole(roleId, userId); |
| | | } |
| | | |
| | | @RequestMapping(value = "/deleteActUserRole") |
| | | public Result deleteActUserRole(@RequestParam String roleId, @RequestParam String userId){ |
| | | return identityService.deleteUserRole(roleId,userId); |
| | | public Result deleteActUserRole(@RequestParam String roleId, @RequestParam String userId) { |
| | | return identityService.deleteUserRole(roleId, userId); |
| | | } |
| | | |
| | | @RequestMapping(value = "/deleteActRole") |
| | | public Result deleteActRole(@RequestParam String roleId){ |
| | | public Result deleteActRole(@RequestParam String roleId) { |
| | | return identityService.deleteRole(roleId); |
| | | } |
| | | |
| | | @RequestMapping(value = "/deleteActUser") |
| | | public Result deleteActUser(@RequestParam String userId){ |
| | | public Result deleteActUser(@RequestParam String userId) { |
| | | return identityService.deleteUser(userId); |
| | | } |
| | | |