| | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/history/{tableName}", method = RequestMethod.GET) |
| | | @RequestMapping(value = "/version/{tableName}", method = RequestMethod.GET) |
| | | public Result getHistory(@PathVariable String tableName) { |
| | | |
| | | Maintain nowVersion = maintainService.getNowVersion(tableName); |
| | | if (nowVersion == null) { |
| | | return Result.error(new CodeMsg(100001,"无当前版本")); |
| | | } |
| | | List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().eq("table_name", tableName).le("order_no",nowVersion.getOrderNo() - 1).orderBy("order_no",false)); |
| | | List<Maintain> maintainList = maintainService.selectList(new EntityWrapper<Maintain>().eq("table_name", tableName).orderBy("order_no",false)); |
| | | List<Maintain> result = new ArrayList<>(); |
| | | for (Maintain maintain : maintainList) { |
| | | String flowId = maintain.getFlowId(); |
| | | if (StringUtils.isEmpty(flowId)) { |
| | | continue; |
| | | } |
| | | |
| | | if (maintainList == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | | Flows flows = flowsService.selectById(maintain.getFlowId()); |
| | | if (flows.getStatus().equals(ActivitiStatus.close)) { |
| | | continue; |
| | | } |
| | | if (flows.getStatus().equals(ActivitiStatus.working) || flows.getStatus().equals(ActivitiStatus.refuse)) { |
| | | maintain.setMaintainType(-1); |
| | | }else if(flows.getStatus().equals(ActivitiStatus.open)){ |
| | | maintain.setMaintainType(1); |
| | | } |
| | | if (maintain.getId().equalsIgnoreCase(nowVersion.getId())) { |
| | | maintain.setMaintainType(0); |
| | | } |
| | | result.add(maintain); |
| | | } |
| | | |
| | | List<Maintain> result = maintainList.stream() |
| | | .filter(maintain -> !StringUtils.isEmpty(maintain.getFlowId())) |
| | | .filter(maintain -> flowsService.selectById(maintain.getFlowId()).getStatus().equals(ActivitiStatus.open)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | return Result.success(result); |
| | | } |