From 53d014edd19f57125c355abe71ec5b478500e610 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 05 八月 2025 09:57:40 +0800 Subject: [PATCH] 保洁巡检所有代码 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ReportController.java | 87 ++++++++++++++++++++++++++++++------------- 1 files changed, 61 insertions(+), 26 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ReportController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ReportController.java index 014a8f3..44317b3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ReportController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ReportController.java @@ -77,6 +77,8 @@ @Resource private ISysUserService sysUserService; @Resource + private TInspectorDetailService inspectorDetailService; + @Resource private TDictDataService dictDataService; @Resource private TokenService tokenService; @@ -838,7 +840,9 @@ if (tProjectDept1 != null) patrolInspectorVO.setDeptName(tProjectDept1.getProjectName() + ">" + tProjectDept.getProjectName()); } else { - patrolInspectorVO.setDeptName(tProjectDept.getProjectName()); + if (tProjectDept != null){ + patrolInspectorVO.setDeptName(tProjectDept.getProjectName()); + } } } else { TDept tDept = deptService.getById(sysUser.getDeptId()); @@ -1116,8 +1120,10 @@ @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 @@ -1186,7 +1192,6 @@ 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()); @@ -1198,16 +1203,22 @@ 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()); @@ -1225,22 +1236,25 @@ 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); @@ -1252,8 +1266,10 @@ 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 @@ -1295,6 +1311,19 @@ } } } + 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()) @@ -1307,10 +1336,8 @@ 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()); @@ -1322,16 +1349,21 @@ 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()); @@ -1350,22 +1382,25 @@ 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模板 -- Gitblit v1.7.1