xuhy
2025-07-03 380870fb248f5690baa134a7d2b0b883a8aae025
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TIndexController.java
@@ -181,8 +181,19 @@
        List<TTask> tasks = taskCleanerService.list(tTaskLambdaQueryWrapper);
        HashMap<String, Integer> taskMap = new HashMap<>();
        HashMap<String, Integer> statusMap = new HashMap<>();
        statusMap.put("未执行", 0);
        statusMap.put("超时", 0);
        statusMap.put("待确认", 0);
        statusMap.put("已驳回", 0);
        statusMap.put("已完成", 0);
        HashMap<String, Integer> clearMap = new HashMap<>();
        clearMap.put("合格", 0);
        clearMap.put("不合格", 0);
        HashMap<String, Integer> unqualifiedMap = new HashMap<>();
        List<TDictData> dictData = dataList.stream().filter(e -> e.getDataType() == 2).collect(Collectors.toList());
        for (TDictData dictDatum : dictData) {
            unqualifiedMap.put(dictDatum.getDataContent(), 0);
        }
        for (TTask task : tasks) {
            TProjectDept tProjectDept = projectDepts.stream().filter(e -> e.getId().equals(task.getProjectId())).findFirst().orElse(null);
            if (tProjectDept == null) continue;
@@ -221,7 +232,7 @@
                        temp1.append("不合格");
                        TDictData tDictData = dataList.stream().filter(e -> e.getId().equals(tTaskDetail.getUnqualified())).findFirst().orElse(null);
                        if (tDictData != null){
                            unqualifiedMap.put(tTaskDetail.getUnqualifiedName(), unqualifiedMap.getOrDefault(tDictData.getDataContent(), 0) + 1);
                            unqualifiedMap.put(tDictData.getDataContent(), unqualifiedMap.getOrDefault(tDictData.getDataContent(), 0) + 1);
                        }
                        break;
                }
@@ -290,7 +301,8 @@
        }
        return R.ok(projectDeptListNoLimitVOS);
    }
@Resource
private TNoticeService noticeService;
    @ApiOperation(value = "首页")
    @PostMapping(value = "/index")
    public R<IndexVO> index(@RequestBody IndexDTO dto) throws IOException {
@@ -298,7 +310,12 @@
//            return R.fail("请上传经纬度");
//        }
        IndexVO res = new IndexVO();
        res.setIsNotice(0);
        Long userId = tokenService.getLoginUserApplet().getUserId();
        Long count = noticeService.lambdaQuery().eq(TNotice::getUserId, userId).eq(TNotice::getStatus, 1).count();
        if (count>0){
            res.setIsNotice(1);
        }
        List<TLocation> locationList = locationService.list();
        List<TLocationType> locationTypeList = locationTypeService.list();
        List<TTask> taskAll = taskCleanerService.lambdaQuery().eq(TTask::getPatrolInspector, userId).list();
@@ -319,7 +336,7 @@
                TProjectDept projectDept = projectDeptService.getById(sysUser.getDeptId());
                if (projectDept != null) {
                    if (!"0".equals(projectDept.getParentId())) {
                    if ("0".equals(projectDept.getParentId())) {
                        // 查询片区下的所有人员
                        users = sysUsers.stream().filter(e -> e.getDeptId()
                                .equals(projectDept.getId())
@@ -379,7 +396,7 @@
                List<TTaskDetail> status3 = taskDetails.stream().filter(e -> e.getClearStatus() == 1).collect(Collectors.toList());
                List<TTaskDetail> status4 = taskDetails.stream().filter(e -> e.getClearStatus() == 2).collect(Collectors.toList());
                if (status3.size() + status4.size() != 0) {
                if (!status3.isEmpty()) {
                    BigDecimal divide = new BigDecimal(status3.size() + status4.size())
                            .divide(new BigDecimal(status3.size()), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100));
                    res.setRate(divide);
@@ -412,6 +429,7 @@
            leaveUserListVO.setCreateTime1(tLeave.getCreateTime());
            leaveUserListVO.setStartTime1(tLeave.getStartTime());
            leaveUserListVO.setEndTime1(tLeave.getEndTime());
            leaveList.add(leaveUserListVO);
        }
        List<TTask> taskList = taskAll.stream().filter(e -> e.getPatrolInspector().equals(userId + "") && e.getStatus() == 4).collect(Collectors.toList());
        List<String> taskIds = taskList.stream().map(TTask::getId).collect(Collectors.toList());
@@ -513,6 +531,21 @@
        }
        Collections.shuffle(tomorrowTask);
        res.setTomorrowTask(tomorrowTask);
        res.setIsLeave(0);
        // 查询请假状态
        List<TLeave> list2 = leaveService.lambdaQuery().eq(TLeave::getLeavePerson, userId)
                .eq(TLeave::getAuditStatus, 2)
                .list();
        for (TLeave tLeave : list2) {
            LocalDate now = LocalDate.now();
            LocalDate startDate = tLeave.getStartTime().toLocalDate();
            LocalDate endDate = tLeave.getStartTime().toLocalDate();
            if (now.isAfter(startDate) && now.isBefore(endDate)) {
                res.setIsLeave(1);
            } else if (now.isEqual(startDate) || now.isEqual(endDate)) {
                res.setIsLeave(1);
            }
        }
        return R.ok(res);
    }
}