| | |
| | | @Resource |
| | | private ISysUserService sysUserService; |
| | | @Resource |
| | | private TInspectorDetailService inspectorDetailService; |
| | | @Resource |
| | | private TDictDataService dictDataService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | |
| | | if (tProjectDept1 != null) |
| | | patrolInspectorVO.setDeptName(tProjectDept1.getProjectName() + ">" + tProjectDept.getProjectName()); |
| | | } else { |
| | | if (tProjectDept != null){ |
| | | patrolInspectorVO.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | } |
| | | } else { |
| | | TDept tDept = deptService.getById(sysUser.getDeptId()); |
| | |
| | | @PostMapping(value = "/inspectorList") |
| | | public R<List<InspectorVO>> inspectorList(@RequestBody InspectorQuery query) { |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | List<TInspectorDetail> list2 = inspectorDetailService.list(); |
| | | |
| | | List<TTask> listAll = taskCleanerService.list(); |
| | | List<String> listAllTaskIds = listAll.stream().map(TTask::getId).collect(Collectors.toList()); |
| | | List<TLocation> locations = locationService.list(); |
| | | if (StringUtils.hasLength(query.getDeptName())) { |
| | | List<TProjectDept> list = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list(); |
| | | List<String> projectIds = list |
| | |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | } |
| | | LambdaQueryWrapper<TInspector> tTaskLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | tTaskLambdaQueryWrapper.eq(TInspector::getAuditStatus, 1); |
| | | tTaskLambdaQueryWrapper.isNotNull(TInspector::getClearStatus); |
| | | if (StringUtils.hasLength(query.getStartTime())) { |
| | | tTaskLambdaQueryWrapper.ge(TInspector::getCreateTime, query.getStartTime()); |
| | |
| | | patrolInspectorIds.add(0L); |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | } |
| | | tTaskLambdaQueryWrapper.in(TInspector::getCommitPerson, query.getPatrolInspectorIds()); |
| | | List<String> collect = locations.stream().filter(e -> query.getPatrolInspectorIds().contains(Long.valueOf(e.getLocationLeader()))) |
| | | .map(TLocation::getId).collect(Collectors.toList()); |
| | | tTaskLambdaQueryWrapper.in(TInspector::getLocationId, collect); |
| | | sysUsers = sysUsers.stream().filter(sysUser -> query.getPatrolInspectorIds().contains(sysUser.getUserId())).collect(Collectors.toList()); |
| | | } |
| | | List<InspectorVO> res = new ArrayList<>(); |
| | | List<TInspector> inspectors = inspectorService.list(tTaskLambdaQueryWrapper); |
| | | List<String> users = inspectors.stream().map(TInspector::getCommitPerson).collect(Collectors.toList()); |
| | | if (users.isEmpty()){ |
| | | users.add("0"); |
| | | List<String> locationIds = inspectors.stream().map(TInspector::getLocationId).collect(Collectors.toList()); |
| | | if (locationIds.isEmpty()){ |
| | | locationIds.add("0"); |
| | | } |
| | | sysUsers = sysUsers.stream().filter(e -> e.getUserId() != 1&&users.contains(e.getUserId()+"")).collect(Collectors.toList()); for (SysUser sysUser : sysUsers) { |
| | | List<String> userIds = locations.stream().filter(e -> locationIds.contains(e.getId())).map(TLocation::getLocationLeader) |
| | | .collect(Collectors.toList()); |
| | | |
| | | sysUsers = sysUsers.stream().filter(e -> e.getUserId() != 1&&userIds.contains(e.getUserId()+"")).collect(Collectors.toList()); |
| | | for (SysUser sysUser : sysUsers) { |
| | | InspectorVO inspectorVO = new InspectorVO(); |
| | | inspectorVO.setNickName(sysUser.getNickName()); |
| | | inspectorVO.setPhonenumber(sysUser.getPhonenumber()); |
| | |
| | | if (tDept != null) |
| | | inspectorVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | List<String> collect1 = listAll.stream().filter(e -> e.getPatrolInspector().equals(sysUser.getUserId() + "")).map(TTask::getId).collect(Collectors.toList()); |
| | | List<TInspector> collect = inspectors.stream().filter(e -> collect1.contains(e.getTaskId())).collect(Collectors.toList()); |
| | | List<String> collect1 = locations.stream().filter(e -> e.getLocationLeader().equals(sysUser.getUserId() + "")).map(TLocation::getId).collect(Collectors.toList()); |
| | | List<TInspector> collect = inspectors.stream().filter(e -> collect1.contains(e.getLocationId())).collect(Collectors.toList()); |
| | | List<String> collect3 = collect.stream().map(TInspector::getId).collect(Collectors.toList()); |
| | | List<TInspectorDetail> collect2 = list2.stream().filter(e -> collect3.contains(e.getInspectorId())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | inspectorVO.setTotal(collect.size()); |
| | | List<TInspector> status1 = collect.stream().filter(e -> e.getClearStatus() == 1).collect(Collectors.toList()); |
| | | List<TInspector> status2 = collect.stream().filter(e -> e.getClearStatus() == 2).collect(Collectors.toList()); |
| | | List<TInspector> status4 = collect.stream().filter(e -> e.getStatus() == 1).collect(Collectors.toList()); |
| | | List<TInspector> status5 = collect.stream().filter(e -> e.getStatus() == 2).collect(Collectors.toList()); |
| | | List<TInspector> status6 = collect.stream().filter(e -> e.getStatus() == 3).collect(Collectors.toList()); |
| | | |
| | | inspectorVO.setNum1(status1.size()); |
| | | inspectorVO.setNum2(status2.size()); |
| | | inspectorVO.setNum3(!status1.isEmpty() || !status2.isEmpty() ? new BigDecimal(status1.size()).divide(new BigDecimal(status2.size() + status1.size()), 2, RoundingMode.HALF_DOWN).multiply(new BigDecimal(100)) : BigDecimal.ZERO); |
| | | inspectorVO.setNum3(!status1.isEmpty() ? new BigDecimal(status1.size()).divide(new BigDecimal(status2.size() + status1.size()), 2, RoundingMode.HALF_DOWN) : BigDecimal.ZERO); |
| | | inspectorVO.setNum4(status4.size()); |
| | | inspectorVO.setNum5(status5.size()); |
| | | inspectorVO.setNum6(status6.size()); |
| | | inspectorVO.setNum7(!status6.isEmpty() || !status5.isEmpty() ? new BigDecimal(status6.size()).divide(new BigDecimal(status5.size() + status6.size()), 2, RoundingMode.HALF_DOWN).multiply(new BigDecimal(100)) : new BigDecimal(0)); |
| | | inspectorVO.setNum7(!status6.isEmpty() ? new BigDecimal(status6.size()).divide(new BigDecimal(status5.size() + status6.size()), 2, RoundingMode.HALF_DOWN) : new BigDecimal(0)); |
| | | res.add(inspectorVO); |
| | | } |
| | | return R.ok(res); |
| | |
| | | public void inspectorListExport(@RequestBody InspectorQuery query) { |
| | | query.setPatrolInspectorIds(null); |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | List<TInspectorDetail> list2 = inspectorDetailService.list(); |
| | | |
| | | List<TTask> listAll = taskCleanerService.list(); |
| | | List<String> listAllTaskIds = listAll.stream().map(TTask::getId).collect(Collectors.toList()); |
| | | List<TLocation> locations = locationService.list(); |
| | | if (StringUtils.hasLength(query.getDeptName())) { |
| | | List<TProjectDept> list = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list(); |
| | | List<String> projectIds = list |
| | |
| | | } |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(query.getNickName())){ |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getNickName().contains(query.getNickName()) |
| | | ).map(SysUser::getUserId).collect(Collectors.toList()); |
| | | if (query.getPatrolInspectorIds()!=null&&!query.getPatrolInspectorIds().isEmpty()){ |
| | | // 取交集 |
| | | patrolInspectorIds = patrolInspectorIds.stream().filter(query.getPatrolInspectorIds()::contains).collect(Collectors.toList()); |
| | | } |
| | | if (patrolInspectorIds.isEmpty()){ |
| | | patrolInspectorIds.add(-1L); |
| | | } |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | } |
| | | if (StringUtils.hasLength(query.getPhonenumber())){ |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getPhonenumber().contains(query.getPhonenumber()) |
| | |
| | | patrolInspectorIds.add(-1L); |
| | | } |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | |
| | | } |
| | | LambdaQueryWrapper<TInspector> tTaskLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | tTaskLambdaQueryWrapper.eq(TInspector::getAuditStatus, 1); |
| | | tTaskLambdaQueryWrapper.isNotNull(TInspector::getClearStatus); |
| | | if (StringUtils.hasLength(query.getStartTime())) { |
| | | tTaskLambdaQueryWrapper.ge(TInspector::getCreateTime, query.getStartTime()); |
| | |
| | | patrolInspectorIds.add(0L); |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | } |
| | | tTaskLambdaQueryWrapper.in(TInspector::getCommitPerson, query.getPatrolInspectorIds()); |
| | | List<String> collect = locations.stream().filter(e -> query.getPatrolInspectorIds().contains(Long.valueOf(e.getLocationLeader()))) |
| | | .map(TLocation::getId).collect(Collectors.toList()); |
| | | tTaskLambdaQueryWrapper.in(TInspector::getLocationId, collect); |
| | | sysUsers = sysUsers.stream().filter(sysUser -> query.getPatrolInspectorIds().contains(sysUser.getUserId())).collect(Collectors.toList()); |
| | | } |
| | | List<InspectorVO> res = new ArrayList<>(); |
| | | List<TInspector> inspectors = inspectorService.list(tTaskLambdaQueryWrapper); |
| | | List<String> users = inspectors.stream().map(TInspector::getCommitPerson).collect(Collectors.toList()); |
| | | if (users.isEmpty()){ |
| | | users.add("0"); |
| | | List<String> locationIds = inspectors.stream().map(TInspector::getLocationId).collect(Collectors.toList()); |
| | | if (locationIds.isEmpty()){ |
| | | locationIds.add("0"); |
| | | } |
| | | sysUsers = sysUsers.stream().filter(e -> e.getUserId() != 1&&users.contains(e.getUserId()+"")).collect(Collectors.toList()); |
| | | List<String> userIds = locations.stream().filter(e -> locationIds.contains(e.getId())).map(TLocation::getLocationLeader) |
| | | .collect(Collectors.toList()); |
| | | |
| | | sysUsers = sysUsers.stream().filter(e -> e.getUserId() != 1&&userIds.contains(e.getUserId()+"")).collect(Collectors.toList()); |
| | | for (SysUser sysUser : sysUsers) { |
| | | InspectorVO inspectorVO = new InspectorVO(); |
| | | inspectorVO.setNickName(sysUser.getNickName()); |
| | |
| | | if (tDept != null) |
| | | inspectorVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | List<String> collect1 = listAll.stream().filter(e -> e.getPatrolInspector().equals(sysUser.getUserId() + "")).map(TTask::getId).collect(Collectors.toList()); |
| | | List<TInspector> collect = inspectors.stream().filter(e -> collect1.contains(e.getTaskId())).collect(Collectors.toList()); |
| | | List<String> collect1 = locations.stream().filter(e -> e.getLocationLeader().equals(sysUser.getUserId() + "")).map(TLocation::getId).collect(Collectors.toList()); |
| | | List<TInspector> collect = inspectors.stream().filter(e -> collect1.contains(e.getLocationId())).collect(Collectors.toList()); |
| | | List<String> collect3 = collect.stream().map(TInspector::getId).collect(Collectors.toList()); |
| | | List<TInspectorDetail> collect2 = list2.stream().filter(e -> collect3.contains(e.getInspectorId())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | inspectorVO.setTotal(collect.size()); |
| | | List<TInspector> status1 = collect.stream().filter(e -> e.getClearStatus() == 1).collect(Collectors.toList()); |
| | | List<TInspector> status2 = collect.stream().filter(e -> e.getClearStatus() == 2).collect(Collectors.toList()); |
| | | List<TInspector> status4 = collect.stream().filter(e -> e.getStatus() == 1).collect(Collectors.toList()); |
| | | List<TInspector> status5 = collect.stream().filter(e -> e.getStatus() == 2).collect(Collectors.toList()); |
| | | List<TInspector> status6 = collect.stream().filter(e -> e.getStatus() == 3).collect(Collectors.toList()); |
| | | |
| | | inspectorVO.setNum1(status1.size()); |
| | | inspectorVO.setNum2(status2.size()); |
| | | inspectorVO.setNum3(!status1.isEmpty() || !status2.isEmpty() ? new BigDecimal(status1.size()).divide(new BigDecimal(status2.size() + status1.size()), 2, RoundingMode.HALF_DOWN).multiply(new BigDecimal(100)) : BigDecimal.ZERO); |
| | | inspectorVO.setNum3(!status1.isEmpty() ? new BigDecimal(status1.size()).divide(new BigDecimal(status2.size() + status1.size()), 2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100")) : BigDecimal.ZERO); |
| | | inspectorVO.setNum4(status4.size()); |
| | | inspectorVO.setNum5(status5.size()); |
| | | inspectorVO.setNum6(status6.size()); |
| | | inspectorVO.setNum7(!status6.isEmpty() || !status5.isEmpty() ? new BigDecimal(status6.size()).divide(new BigDecimal(status5.size() + status6.size()), 2, RoundingMode.HALF_DOWN).multiply(new BigDecimal(100)) : new BigDecimal(0)); |
| | | inspectorVO.setNum7(!status6.isEmpty() ? new BigDecimal(status6.size()).divide(new BigDecimal(status5.size() + status6.size()), 2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100")) : new BigDecimal(0)); |
| | | res.add(inspectorVO); |
| | | } |
| | | //1.获取excel模板 |