| | |
| | | private final ProjectCategoryCalculator projectCategoryCalculator; |
| | | private final ClientParamMapper clientParamMapper; |
| | | private final DeviceMapper deviceMapper; |
| | | private final ErrorReviewMapper errorReviewMapper; |
| | | |
| | | @Override |
| | | public ClientDashboardVO getClientDashboard(ClientDashboardQuery query) { |
| | |
| | | .ne(Project::getType, 2) // 在建工程 |
| | | .and(wrapper -> wrapper |
| | | .eq(Project::getStatus, 1) // 在建项目 |
| | | .between(Project::getCreateTime, monthStart, monthEnd) |
| | | .or(w -> w |
| | | .eq(Project::getStatus, 2) // 已完成项目 |
| | | .between(Project::getSuccessTime, monthStart,monthEnd) // 完成时间 >= 开始日期// 完成时间 <= 结束日期 |
| | |
| | | .eq(Project::getType, 2) // 在建工程 |
| | | .and(wrapper -> wrapper |
| | | .eq(Project::getStatus, 1) // 在建项目 |
| | | .between(Project::getCreateTime, monthStart, monthEnd) |
| | | .or(w -> w |
| | | .eq(Project::getStatus, 2) // 已完成项目 |
| | | .between(Project::getSuccessTime, monthStart,monthEnd) // 完成时间 >= 开始日期// 完成时间 <= 结束日期 |
| | |
| | | vo.setMajorHazardTotal(majorHazards.size()); |
| | | |
| | | // 统计已整改和未整改数量 |
| | | long rectifiedCount = majorHazards.stream() |
| | | .filter(r -> r.getReformed() != null && r.getReformed()) |
| | | .count(); |
| | | long unrectifiedCount = majorHazards.stream() |
| | | .filter(r -> r.getReformed() == null || !r.getReformed()) |
| | | .count(); |
| | | // 1. 收集所有非空的 errorReviewId |
| | | List<Integer> errorReviewIds = majorHazards.stream() |
| | | .map(Record::getErrorReviewId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 2. 查询 ErrorReview 中 state=2 的记录 |
| | | long rectifiedCount = 0; |
| | | if (!errorReviewIds.isEmpty()) { |
| | | LambdaQueryWrapper<ErrorReview> reviewWrapper = new LambdaQueryWrapper<>(); |
| | | reviewWrapper.in(ErrorReview::getId, errorReviewIds) |
| | | .eq(ErrorReview::getState, 2) // state=2 表示已整改 |
| | | .eq(ErrorReview::getDeleted, false); |
| | | rectifiedCount = errorReviewMapper.selectCount(reviewWrapper); |
| | | } |
| | | |
| | | // 3. 未整改数量 = 总数 - 已整改数量 |
| | | long unrectifiedCount = majorHazards.size() - rectifiedCount; |
| | | |
| | | vo.setRectifiedHazardCount((int) rectifiedCount); |
| | | vo.setUnrectifiedHazardCount((int) unrectifiedCount); |
| | |
| | | vo.setMajorHazardTotal(majorHazards.size()); |
| | | |
| | | // 统计已整改和未整改数量 |
| | | long rectifiedCount = majorHazards.stream() |
| | | .filter(r -> r.getReformed() != null && r.getReformed()) |
| | | .count(); |
| | | long unrectifiedCount = majorHazards.stream() |
| | | .filter(r -> r.getReformed() == null || !r.getReformed()) |
| | | .count(); |
| | | // 1. 收集所有非空的 errorReviewId |
| | | List<Integer> errorReviewIds = majorHazards.stream() |
| | | .map(Record::getErrorReviewId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 2. 查询 ErrorReview 中 state=2 的记录 |
| | | long rectifiedCount = 0; |
| | | if (!errorReviewIds.isEmpty()) { |
| | | LambdaQueryWrapper<ErrorReview> reviewWrapper = new LambdaQueryWrapper<>(); |
| | | reviewWrapper.in(ErrorReview::getId, errorReviewIds) |
| | | .eq(ErrorReview::getState, 2) // state=2 表示已整改 |
| | | .eq(ErrorReview::getDeleted, false); |
| | | rectifiedCount = errorReviewMapper.selectCount(reviewWrapper); |
| | | } |
| | | |
| | | // 3. 未整改数量 = 总数 - 已整改数量 |
| | | long unrectifiedCount = majorHazards.size() - rectifiedCount; |
| | | |
| | | vo.setRectifiedHazardCount((int) rectifiedCount); |
| | | vo.setUnrectifiedHazardCount((int) unrectifiedCount); |
| | |
| | | // 解析 address_info JSON 字符串 |
| | | JSONObject addressJson = JSON.parseObject(p.getAddressInfo()); |
| | | JSONArray gps = addressJson.getJSONArray("gps"); |
| | | String lonLat = addressJson.getString("lonLat"); |
| | | |
| | | if (gps != null && gps.size() >= 2) { |
| | | ProjectMapPointVO vo = new ProjectMapPointVO(); |
| | |
| | | // gps 数组格式:[经度, 纬度] |
| | | vo.setLongitude(gps.getString(0)); |
| | | vo.setLatitude(gps.getString(1)); |
| | | //位置信息 |
| | | vo.setAddressInfo(addressJson); |
| | | // 设置项目类别 |
| | | vo.setCategory(categoryMap.get(p.getId())); |
| | | |
| | | result.add(vo); |
| | | }else if(org.apache.commons.lang3.StringUtils.isNotBlank(lonLat)){ |
| | | String[] split = lonLat.split(","); |
| | | ProjectMapPointVO vo = new ProjectMapPointVO(); |
| | | vo.setProjectId(p.getId()); |
| | | vo.setProjectName(p.getName()); |
| | | vo.setProjectType(p.getType()); |
| | | |
| | | // gps 数组格式:[经度, 纬度] |
| | | vo.setLongitude(split[0]); |
| | | vo.setLatitude(split[1]); |
| | | //位置信息 |
| | | vo.setAddressInfo(addressJson); |
| | | // 设置项目类别 |
| | | vo.setCategory(categoryMap.get(p.getId())); |
| | | |