无关风月
6 天以前 53d014edd19f57125c355abe71ec5b478500e610
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TIndexController.java
@@ -66,6 +66,8 @@
    @Resource
    private TTaskDetailService taskDetailService;
    @Resource
    private TInspectorDetailService inspectorDetailService;
    @Resource
@@ -330,6 +332,7 @@
        IndexVO res = new IndexVO();
        res.setIsNotice(0);
        Long userId = tokenService.getLoginUserApplet().getUserId();
        List<TLocation> locations = locationService.lambdaQuery().eq(TLocation::getLocationLeader, userId).list();
        Long count = noticeService.lambdaQuery().eq(TNotice::getUserId, userId).eq(TNotice::getStatus, 1).count();
        if (count>0){
            res.setIsNotice(1);
@@ -340,6 +343,7 @@
        List<TLocationType> locationTypeList = locationTypeService.list();
        dto.setUserId(userId);
        List<TTask> taskAll = taskCleanerService.indexTask(dto);
        List<TInspector> inspectorAll = taskCleanerService.indexInspector(dto);
//        List<TTask> taskAll = taskCleanerService.lambdaQuery().eq(TTask::getPatrolInspector, userId).list();
        // 获取今天凌晨00:00:00 和今天23:59:59 类型为LocalDateTime
        LocalDateTime startOfToday = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
@@ -491,49 +495,57 @@
            if (taskDetailsStatus1!=null){
                taskTodayVO.setRemark(taskDetailsStatus1.getAuditRemark());
            }
            // 任务记录ids
            List<String> collect = taskAll.stream().map(TTask::getId).collect(Collectors.toList());
            if (!collect.isEmpty()){
                List<TInspector> list1 = inspectorService.lambdaQuery()
                        .in(TInspector::getTaskId, collect).eq(TInspector::getStatus, 2).list();
                for (TInspector tInspector : list1) {
                    TaskPendingVO taskTodayVOOne = new TaskPendingVO();
                    BeanUtils.copyProperties(tTask, taskTodayVOOne);
                    taskTodayVOOne.setId(tInspector.getId());
                    TLocation tLocationOne = locationList.stream().filter(e -> e.getId().equals(tTask.getLocationId())).findFirst().orElse(null);
                    if (tLocationOne != null) {
                        taskTodayVOOne.setLocationAddress(tLocationOne.getLocationAddress());
                        taskTodayVOOne.setLocationLon(tLocationOne.getLocationLon());
                        taskTodayVOOne.setLocationLat(tLocationOne.getLocationLat());
                        taskTodayVOOne.setLocationName(tLocationOne.getLocationName());
                        if(StringUtils.hasLength(dto.getLon())){
                            taskTodayVO.setDistance(tTask.getDistance().divide(new BigDecimal(1000),2, RoundingMode.HALF_DOWN));
                        }else {
                            taskTodayVO.setDistance(new BigDecimal("0"));
                        }
                        TLocationType tLocationType = locationTypeList.stream().filter(e -> e.getId().equals(tLocationOne.getLocationType())).findFirst().orElse(null);
                        if (tLocationType != null) {
                            taskTodayVOOne.setLocationTypeName(tLocationType.getLocationName());
                            taskTodayVOOne.setLocationTypeIcon(tLocationType.getLocationIcon());
                        }
                    }
                    taskTodayVOOne.setStatus(4);
                    taskTodayVOOne.setRemark(tInspector.getAuditRemark());
                    pendingTask.add(taskTodayVOOne);
            taskTodayVO.setIsInspector(0);
            pendingTask.add(taskTodayVO);
        }
        // 点位ids
        List<String> collect = locations.stream().map(TLocation::getId).collect(Collectors.toList());
        if (collect.isEmpty()){
            collect.add("-1");
        }
        List<TInspector> list1 = inspectorAll.stream().filter(e->collect.contains(e.getLocationId())).collect(Collectors.toList());
        for (TInspector tInspector : list1) {
            TInspectorDetail taskDetailsStatus1 = inspectorDetailService.lambdaQuery()
                    .eq(TInspectorDetail::getInspectorId, tInspector.getId())
                    .in(TInspectorDetail::getHandleType, Arrays.asList(3,6))
                    .orderByDesc(TInspectorDetail::getCreateTime).last("limit 1").one();
            TaskPendingVO taskTodayVOOne = new TaskPendingVO();
            BeanUtils.copyProperties(tInspector, taskTodayVOOne);
            taskTodayVOOne.setId(tInspector.getId());
            TLocation tLocationOne = locationList.stream().filter(e -> e.getId().equals(tInspector.getLocationId())).findFirst().orElse(null);
            if (tLocationOne != null) {
                taskTodayVOOne.setLocationAddress(tLocationOne.getLocationAddress());
                taskTodayVOOne.setLocationLon(tLocationOne.getLocationLon());
                taskTodayVOOne.setLocationLat(tLocationOne.getLocationLat());
                taskTodayVOOne.setLocationName(tLocationOne.getLocationName());
                if(StringUtils.hasLength(dto.getLon())){
                    taskTodayVOOne.setDistance(tInspector.getDistance().divide(new BigDecimal(1000),2, RoundingMode.HALF_DOWN));
                }else {
                    taskTodayVOOne.setDistance(new BigDecimal("0"));
                }
                TLocationType tLocationType = locationTypeList.stream().filter(e -> e.getId().equals(tLocationOne.getLocationType())).findFirst().orElse(null);
                if (tLocationType != null) {
                    taskTodayVOOne.setLocationTypeName(tLocationType.getLocationName());
                    taskTodayVOOne.setLocationTypeIcon(tLocationType.getLocationIcon());
                }
            }
            pendingTask.add(taskTodayVO);
            taskTodayVOOne.setStatus(4);
            if (taskDetailsStatus1!=null){
                taskTodayVOOne.setRemark(taskDetailsStatus1.getAuditRemark());
            }
            taskTodayVOOne.setIsInspector(1);
            pendingTask.add(taskTodayVOOne);
        }
        // 将pendingTask按照距离 从小到大排序
        pendingTask.sort(Comparator.comparing(TaskPendingVO::getDistance));
        res.setPendingTask(pendingTask);
        res.setLeaveList(leaveList);
        List<TaskTodayVO> todayTask = new ArrayList<>();
        List<String> collect = taskAll.stream().map(TTask::getId).collect(Collectors.toList());
        List<String> tasdids = taskAll.stream().map(TTask::getId).collect(Collectors.toList());
        for (TTask tTask : taskToday) {
            TaskTodayVO taskTodayVO = new TaskTodayVO();
            if(CollectionUtils.isEmpty(collect)){
            if(CollectionUtils.isEmpty(tasdids)){
                break;
            }
            TTaskDetail taskDetailsStatus1 = taskDetailService.lambdaQuery()