From 9540084cf921673813d4d4685aaddebe628d1c1c Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期一, 30 六月 2025 15:21:05 +0800
Subject: [PATCH] 修改登录

---
 ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TIndexController.java |   58 +++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TIndexController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TIndexController.java
index 24bd61d..2931add 100644
--- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TIndexController.java
+++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TIndexController.java
@@ -29,6 +29,7 @@
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
+import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
@@ -141,7 +142,7 @@
             }
         } else {
             // 根据当前登录人查询部门
-            Long userId = tokenService.getLoginUser().getUserId();
+            Long userId = tokenService.getLoginUserApplet().getUserId();
             SysUser sysUser = sysUserService.selectUserById(userId);
             if (sysUser.getDeptType() == 1) {
                 TProjectDept projectDept = projectDeptService.getById(sysUser.getDeptId());
@@ -284,7 +285,7 @@
                 BeanUtils.copyProperties(projectDept, projectDeptListNoLimitVO1);
                 projectDeptListNoLimitVOS1.add(projectDeptListNoLimitVO1);
             }
-            projectDeptListNoLimitVO.setChildren(projectDeptListNoLimitVOS1);
+            projectDeptListNoLimitVO.setChildrenList(projectDeptListNoLimitVOS1);
             projectDeptListNoLimitVOS.add(projectDeptListNoLimitVO);
         }
         return R.ok(projectDeptListNoLimitVOS);
@@ -293,11 +294,11 @@
     @ApiOperation(value = "首页")
     @PostMapping(value = "/index")
     public R<IndexVO> index(@RequestBody IndexDTO dto) throws IOException {
-        if (!StringUtils.hasLength(dto.getLon()) || !StringUtils.hasLength(dto.getLat())) {
-            return R.fail("请上传经纬度");
-        }
+//        if (!StringUtils.hasLength(dto.getLon()) || !StringUtils.hasLength(dto.getLat())) {
+//            return R.fail("请上传经纬度");
+//        }
         IndexVO res = new IndexVO();
-        Long userId = tokenService.getLoginUser().getUserId();
+        Long userId = tokenService.getLoginUserApplet().getUserId();
         List<TLocation> locationList = locationService.list();
         List<TLocationType> locationTypeList = locationTypeService.list();
         List<TTask> taskAll = taskCleanerService.lambdaQuery().eq(TTask::getPatrolInspector, userId).list();
@@ -355,11 +356,12 @@
 
             }
         }
-        List<TaskTodayVO> pendingTask = new ArrayList<>();
+        List<TaskPendingVO> pendingTask = new ArrayList<>();
 
         res.setTotalUserCount(users.size());
         if (!users.isEmpty()) {
-            List<TTask> tasks = taskCleanerService.lambdaQuery().in(TTask::getPatrolInspector, users).list();
+            List<Long> userIds = users.stream().map(SysUser::getUserId).collect(Collectors.toList());
+            List<TTask> tasks = taskCleanerService.lambdaQuery().in(TTask::getPatrolInspector, userIds).list();
             List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
             if (!tasks.isEmpty()) {
                 List<TTask> status1 = tasks.stream().filter(e -> e.getStatus() == 5 || e.getStatus() == 6).collect(Collectors.toList());
@@ -419,7 +421,7 @@
                     .eq(TTaskDetail::getClearStatus, 2)
                     .groupBy(TTaskDetail::getTaskId)
                     .orderByDesc(TTaskDetail::getCreateTime).list();
-            TaskTodayVO taskTodayVO = new TaskTodayVO();
+            TaskPendingVO taskTodayVO = new TaskPendingVO();
             BeanUtils.copyProperties(tTask, taskTodayVO);
             TLocation tLocation = locationList.stream().filter(e -> e.getId().equals(tTask.getLocationId())).findFirst().orElse(null);
             if (tLocation != null) {
@@ -428,10 +430,14 @@
                 taskTodayVO.setLocationLat(tLocation.getLocationLat());
                 taskTodayVO.setLocationName(tLocation.getLocationName());
                 // todo
-                Map<String, String> distance = amapApiClient.getDistance(dto.getLon() + "," + dto.getLat(), tLocation.getLocationLon() + "," + tLocation.getLocationLat(), 1);
-                if (distance != null) {
-                    taskTodayVO.setDistance(new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN));
-                } else {
+                if(StringUtils.hasLength(dto.getLon())){
+                    Map<String, String> distance = amapApiClient.getDistance(dto.getLon() + "," + dto.getLat(), tLocation.getLocationLon() + "," + tLocation.getLocationLat(), 1);
+                    if (distance != null) {
+                        taskTodayVO.setDistance(new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN));
+                    } else {
+                        taskTodayVO.setDistance(new BigDecimal("0"));
+                    }
+                }else {
                     taskTodayVO.setDistance(new BigDecimal("0"));
                 }
                 TLocationType tLocationType = locationTypeList.stream().filter(e -> e.getId().equals(tLocation.getLocationType())).findFirst().orElse(null);
@@ -453,10 +459,14 @@
         res.setPendingTask(pendingTask);
         res.setLeaveList(leaveList);
         List<TaskTodayVO> todayTask = new ArrayList<>();
+        List<String> collect = taskAll.stream().map(TTask::getId).collect(Collectors.toList());
         for (TTask tTask : taskToday) {
             TaskTodayVO taskTodayVO = new TaskTodayVO();
+            if(CollectionUtils.isEmpty(collect)){
+                break;
+            }
             List<TTaskDetail> taskDetailsStatus1 = taskDetailService.lambdaQuery()
-                    .eq(TTaskDetail::getAuditStatus, 1).in(TTaskDetail::getTaskId, taskIds)
+                    .eq(TTaskDetail::getAuditStatus, 1).in(TTaskDetail::getTaskId, collect)
                     .eq(TTaskDetail::getClearStatus, 2)
                     .groupBy(TTaskDetail::getTaskId)
                     .orderByDesc(TTaskDetail::getCreateTime).list();
@@ -467,10 +477,14 @@
                 taskTodayVO.setLocationLon(tLocation.getLocationLon());
                 taskTodayVO.setLocationLat(tLocation.getLocationLat());
                 taskTodayVO.setLocationName(tLocation.getLocationName());
-                Map<String, String> distance = amapApiClient.getDistance(dto.getLon() + "," + dto.getLat(), tLocation.getLocationLon() + "," + tLocation.getLocationLat(), 1);
-                if (distance != null) {
-                    taskTodayVO.setDistance(new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN));
-                } else {
+                if(StringUtils.hasLength(dto.getLon())){
+                    Map<String, String> distance = amapApiClient.getDistance(dto.getLon() + "," + dto.getLat(), tLocation.getLocationLon() + "," + tLocation.getLocationLat(), 1);
+                    if (distance != null) {
+                        taskTodayVO.setDistance(new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN));
+                    } else {
+                        taskTodayVO.setDistance(new BigDecimal("0"));
+                    }
+                }else {
                     taskTodayVO.setDistance(new BigDecimal("0"));
                 }
                 TLocationType tLocationType = locationTypeList.stream().filter(e -> e.getId().equals(tLocation.getLocationType())).findFirst().orElse(null);
@@ -490,7 +504,13 @@
             todayTask.add(taskTodayVO);
         }
         res.setTodayTask(todayTask);
-        List<TaskTodayVO> tomorrowTask = new ArrayList<>(todayTask);
+        List<TaskTomorrowVO> tomorrowTask = new ArrayList<>();
+
+        for (TaskTodayVO taskTodayVO : todayTask) {
+            TaskTomorrowVO taskTomorrowVO = new TaskTomorrowVO();
+            BeanUtils.copyProperties(taskTodayVO, taskTomorrowVO);
+            tomorrowTask.add(taskTomorrowVO);
+        }
         Collections.shuffle(tomorrowTask);
         res.setTomorrowTask(tomorrowTask);
         return R.ok(res);

--
Gitblit v1.7.1