| | |
| | | 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.mapper.FlowsMapper; |
| | | import com.highdatas.mdm.pojo.*; |
| | | import com.highdatas.mdm.service.ActivitiService; |
| | | import com.highdatas.mdm.service.IFlowsService; |
| | | import com.highdatas.mdm.service.IMaintainService; |
| | | import com.highdatas.mdm.service.ITUserService; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.service.act.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.activiti.engine.task.Task; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.*; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | ITUserService userService; |
| | | @Autowired |
| | | IMasterModifiedService masterModifiedService; |
| | | |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Value("${img.url}") |
| | | String basePath; |
| | | |
| | | @RequestMapping(value = "/list", method = RequestMethod.GET) |
| | | public Result<List<Map<String, Object>>> list(HttpServletRequest request) throws FileNotFoundException { |
| | |
| | | List<Map<String, Object>> list = flowsMapper.selectVersion(filterSegment); |
| | | for (Map<String, Object> one : list) { |
| | | String newModelId = (String) one.get(Constant.ID); |
| | | String url = "processes/" + newModelId + "/" + newModelId + ".png"; |
| | | String url = "act/img/" + newModelId; |
| | | one.put("imgurl",url); |
| | | } |
| | | return Result.success(list); |
| | | } |
| | | @RequestMapping(value = "/img/{modelId}", method = RequestMethod.GET) |
| | | public void image(@PathVariable String modelId, HttpServletResponse response) { |
| | | String filePath = basePath + modelId +"/"+ modelId + ".png"; |
| | | File file = new File(filePath); |
| | | FileInputStream fileInputStream = null; |
| | | response.setHeader("Content-Type", "image/png"); |
| | | try{ |
| | | fileInputStream = new FileInputStream(file); |
| | | OutputStream outputStream = response.getOutputStream(); |
| | | byte[] b = new byte[1024]; |
| | | int len; |
| | | while ((len = fileInputStream.read(b, 0, 1024)) != -1) { |
| | | outputStream.write(b, 0, len); |
| | | } |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | finally { |
| | | if (fileInputStream != null) { |
| | | try { |
| | | fileInputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | @RequestMapping(value = "/deleteModel/{modelId}", method = RequestMethod.GET) |
| | | public Result deleteModel(@PathVariable String modelId) { |
| | | boolean b = repositoryService.deleteModel(modelId); |
| | | if (b) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | | } |
| | | } |
| | | @RequestMapping(value = "/processlist", method = RequestMethod.GET) |
| | | public Result<Result<JSONArray>> processlist(HttpServletRequest request) { |
| | | Result<JSONArray> processList = repositoryService.getProcessList(); |
| | |
| | | @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")); |
| | | return Result.error(new CodeMsg(1000, "key is not found")); |
| | | } |
| | | String desp = request.getParameter("desp"); |
| | | String businessType = request.getParameter("businessType"); |
| | | ActivitiBusinessType type; |
| | | if (StringUtils.isEmpty(businessType)) { |
| | | type = ActivitiBusinessType.maintain; |
| | | } else { |
| | | type = ActivitiBusinessType.valueOf(businessType); |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | Flows flows = activitiService.start(key, session, businessId, type); |
| | | if (flows == null) { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } else { |
| | | if (type.equals(ActivitiBusinessType.field)) { |
| | | MaintainField maintainField = maintainFieldService.selectById(businessId); |
| | | maintainField.setFlowId(flows.getId()); |
| | | maintainField.setDesp(desp); |
| | | maintainField.updateById(); |
| | | return Result.success(flows.getId()); |
| | | } |
| | | String desp = request.getParameter("desp"); |
| | | String businessType = request.getParameter("businessType"); |
| | | ActivitiBusinessType type; |
| | | if (StringUtils.isEmpty(businessType)) { |
| | | type = ActivitiBusinessType.maintain; |
| | | } else { |
| | | type = ActivitiBusinessType.valueOf(businessType); |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | Flows flows = activitiService.start(key, session, businessId, type); |
| | | if (flows == null) { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } else { |
| | | |
| | | if (type.equals(ActivitiBusinessType.maintain)) { |
| | | else if (type.equals(ActivitiBusinessType.maintain)) { |
| | | Maintain maintain = maintainService.selectById(businessId); |
| | | maintain.setFlowId(flows.getId()); |
| | | maintain.setDesp(desp); |
| | |
| | | if (!StringUtils.isEmpty(pageSizeStr)) { |
| | | page.setPageSize(Integer.valueOf(pageSizeStr)); |
| | | } |
| | | |
| | | subList = subList.stream().skip(page.getBeginRecordNo_1()).limit(page.getPageSize()).collect(Collectors.toList()); |
| | | ArrayList<Map<String, Object>> result = new ArrayList<>(); |
| | | for (HistoricProcessInstance historicProcessInstance : subList) { |
| | |
| | | one.put("createTime", flows.getCreateTime()); |
| | | result.add(one); |
| | | } |
| | | |
| | | Collections.sort(result, new Comparator<Map<String, Object>>() { |
| | | @Override |
| | | public int compare(Map<String, Object> o1, Map<String, Object> o2) { |
| | | Date o1Date = (Date) o1.get("createTime"); |
| | | Date o2Date = (Date) o2.get("createTime"); |
| | | return o2Date.compareTo(o1Date); |
| | | } |
| | | }); |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | |
| | | ActivitiStatus status = flows.getStatus(); |
| | | |
| | | String workflowId = flows.getWorkflowId(); |
| | | // Task task = taskService.geTask(workflowId); |
| | | // Task task = TimeTaskService.geTask(workflowId); |
| | | // String id = task.getId(); |
| | | String taskId = null; |
| | | if (taskService.checkClaim(workflowId)) { |
| | |
| | | } else { |
| | | flows.setStatus(ActivitiStatus.open); |
| | | } |
| | | if (flows.getBusinessType().equals(ActivitiBusinessType.maintain)){ |
| | | String maintainId = flows.getBusinessId(); |
| | | maintainService.dealFlow(maintainId, flows.getStatus()); |
| | | |
| | | if (!pass) { |
| | | flows.setStatus(ActivitiStatus.close); |
| | | } |
| | | |
| | | |
| | | flowsService.aduitFinish(flows); |
| | | |
| | | } else { |
| | | if (pass && flows.getStatus().equals(ActivitiStatus.refuse)) { |
| | |
| | | return Result.success(CodeMsg.INSERT_ERROR); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |