| | |
| | | |
| | | @Autowired |
| | | RuntimeService runtimeService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | |
| | | private TUser user; |
| | | |
| | | @Override |
| | | public Flows start(String key, HttpSession session, String maintainId, ActivitiBusinessType type) { |
| | | |
| | | identityService.setSession( session); |
| | | Flows flows = new Flows(); |
| | | String id = UUID.randomUUID().toString().replaceAll("-", ""); |
| | |
| | | flows.setStatus(ActivitiStatus.working); |
| | | HashMap<String, Object> variableMap = new HashMap<>(); |
| | | variableMap.put("reasson", "申请审批"); |
| | | |
| | | String workflowId = identityService.startProcess(id, key, null, variableMap); |
| | | flows.setWorkflowId(workflowId); |
| | | flows.setCreateTime(new Date()); |
| | | TUser user = (TUser) session.getAttribute("user"); |
| | | TUser user = null; |
| | | if (session != null) { |
| | | user = (TUser) session.getAttribute("user"); |
| | | }else { |
| | | user = this.user; |
| | | } |
| | | if (user == null) { |
| | | return null; |
| | | } |
| | | |
| | | String user_id = user.getUserId(); |
| | | flows.setUserId(user_id); |
| | | boolean inserted = flowsService.insert(flows); |
| | |
| | | return Result.success(null); |
| | | } |
| | | |
| | | Wrapper<Flows> flowsWrapper = new EntityWrapper<Flows>().in("workflow_id", todoTask).eq("business_type", ActivitiBusinessType.maintain); |
| | | Wrapper<Flows> flowsWrapper = new EntityWrapper<Flows>().in("workflow_id", todoTask).ne("business_type", ActivitiBusinessType.exists); |
| | | flowsWrapper.orderBy("create_time desc"); |
| | | List<Flows> records = flowsService.selectList(flowsWrapper); |
| | | |
| | | List<Flows> result = new ArrayList<>(); |
| | | |
| | | if (!StringUtils.isEmpty(tableName)) { |
| | | records = records.stream() |
| | | |
| | | List<Flows> maintainList = records.stream() |
| | | .filter(flows -> flows.getBusinessType().equals(ActivitiBusinessType.maintain)) |
| | | .filter(flows -> (!flows.getStatus().equals(ActivitiStatus.open) || !flows.getStatus().equals(ActivitiStatus.close))) |
| | | .filter(flows -> maintainService.selectById(flows.getBusinessId()) != null) |
| | | .filter(flows -> maintainService.selectById(flows.getBusinessId()).getTableName().equalsIgnoreCase(tableName)).collect(Collectors.toList()); |
| | | List<Flows> collect = records.stream() |
| | | .filter(flows -> flows.getBusinessType().equals(ActivitiBusinessType.field)) |
| | | .filter(flows -> (!flows.getStatus().equals(ActivitiStatus.open) || !flows.getStatus().equals(ActivitiStatus.close))) |
| | | .filter(flows -> maintainFieldService.selectById(flows.getBusinessId()) != null) |
| | | .filter(flows -> maintainFieldService.selectById(flows.getBusinessId()).getTableName().equalsIgnoreCase(tableName)).collect(Collectors.toList()); |
| | | records = new ArrayList<>(); |
| | | |
| | | records.addAll(maintainList); |
| | | records.addAll(collect); |
| | | } |
| | | Page page = new Page(records.size()); |
| | | page.setPageNo(pageNo); |
| | |
| | | flowPages.setTotal(page.getRecordCount()); |
| | | return Result.success(flowPages); |
| | | } |
| | | |
| | | @Override |
| | | public void setUser(TUser user) { |
| | | this.user = user; |
| | | identityService.setUser(user); |
| | | taskService.setUser(user); |
| | | historyService.setUser(user); |
| | | runtimeService.setUser(user); |
| | | repositoryService.setUser(user); |
| | | } |
| | | |
| | | @Override |
| | | public TUser getUser() { |
| | | return this.user; |
| | | } |
| | | } |