From 5dacdee9b54c78372b68140e2b068d03a620eab9 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 02 七月 2025 19:00:52 +0800
Subject: [PATCH] 修改bug

---
 ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/HomeController.java |  115 +++++++++++++++++++++++++++------------------------------
 1 files changed, 55 insertions(+), 60 deletions(-)

diff --git a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/HomeController.java b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/HomeController.java
index c6a7ec9..fd73770 100644
--- a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/HomeController.java
+++ b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/HomeController.java
@@ -1,7 +1,5 @@
 package com.stylefeng.guns.modular.system.controller.general;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.stylefeng.guns.core.beetl.ShiroExtUtil;
@@ -10,9 +8,9 @@
 import com.stylefeng.guns.modular.system.model.*;
 import com.stylefeng.guns.modular.system.service.*;
 import com.stylefeng.guns.modular.system.util.DateUtil;
-import com.stylefeng.guns.modular.system.util.RedisUtil;
 import com.stylefeng.guns.modular.system.util.ResultUtil;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -20,6 +18,7 @@
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
@@ -36,28 +35,28 @@
 
     @Autowired
     private ITDriverService tDriverService;
-
+    
     @Autowired
     private ITOrderTaxiService tOrderTaxiService;
-
+    
     @Autowired
     private ITCarService tCarService;
-
+    
     @Autowired
     private ITTaxiCardService taxiCardService;
-
-    @Autowired
-    private RedisUtil redisUtil;
-
+    
+    @Resource
+    private RedisTemplate<String, Object> redisTemplate;
+    
     @Autowired
     private IUserService userService;
-
+    
     @Autowired
     private ITCompanyService tCompanyService;
-
+    
     @Autowired
     private ITCarBrandService carBrandService;
-
+    
     @Autowired
     private ITCarModelService carModelService;
 
@@ -66,36 +65,37 @@
 
     @Autowired
     private ITOrderPrivateCarService itOrderPrivateCarService;
-
+    
     @Autowired
     private ITOrderCrossCityService itOrderCrossCityService;
-
+    
     @Autowired
     private ITOrderLogisticsService itOrderLogisticsService;
-
+    
     @Autowired
     private IDriverOnlineService driverOnlineService;
-
+    
+    @Resource
+    private ShiroExtUtil shiroExtUtil;
+    
     @RequestMapping("/openNetCarInfo")
-    public Object openNetCarInfo(Integer id, Model model){
+    public Object openNetCarInfo(Integer id, Model model) {
         model.addAttribute("id", id);
         return "/netCarInfo.html";
     }
-
+    
     @RequestMapping("/showDriverOnline")
-    public String showDriverOnline(){
+    public String showDriverOnline() {
         return "/driverOnline.html";
     }
-
-
-
-
+    
+    
     @ResponseBody
     @PostMapping("/getSumData")
-    public Object getSumData(Integer companyId, Date addDate, Date start, Date end){
-        Integer id = ShiroExtUtil.getUser().getId();
+    public Object getSumData(Integer companyId, Date addDate, Date start, Date end) {
+        Integer id = shiroExtUtil.getUser().getId();
         User user = userService.selectById(id);
-        if(companyId == null && user.getRoleType() != 1){
+        if (companyId == null && user.getRoleType() != 1) {
             companyId = user.getObjectId();
         }
         Map<String, Object> map = new HashMap<>();
@@ -104,7 +104,7 @@
         Calendar calendar2 = Calendar.getInstance();
         Calendar calendar3 = Calendar.getInstance();
         Calendar calendar4 = Calendar.getInstance();
-        if(addDate == null){
+        if (addDate == null) {
             calendar1.setTime(date);
             calendar2.setTime(date);
         }else{
@@ -130,51 +130,44 @@
         calendar4.set(Calendar.HOUR_OF_DAY, 23);
         calendar4.set(Calendar.MINUTE, 59);
         calendar4.set(Calendar.SECOND, 59);
-
+        
         //【今日运行情况】
         Map<String, Object> map1 = new HashMap<>();
         Wrapper<TUser> ne = new EntityWrapper<TUser>().between("insertTime", calendar1.getTime(), calendar2.getTime()).ne("flag", 3);
-        if(companyId != null){
+        if (companyId != null) {
             ne.eq("companyId", companyId);
         }
         int i = tUserService.selectCount(ne);
         map1.put("passengerInfo", i);  //新增用户
-
+        
         Wrapper<TDriver> ne1 = new EntityWrapper<TDriver>().ne("state", 1).eq("authState", 2).ne("flag", 3);
-        if(companyId != null){
+        if (companyId != null) {
             ne1.eq("companyId", companyId).or().eq("franchiseeId", companyId);
         }
-        List<TDriver> tDrivers = tDriverService.selectList(ne1);
-        String keys = "";
-        for(TDriver driver : tDrivers){
-            keys += "DRIVER" + driver.getId() + ",";
-        }
-        String value = redisUtil.getValues(keys.substring(0, keys.length() - 1));
-        JSONArray jsonArray = JSON.parseArray(value);
-        int size = driverOnlineService.queryOnlineDriverCount(null, null);
-        map1.put("netcardriver", size);  //在线司机
-
+        int count = tDriverService.selectCount(new EntityWrapper<TDriver>().ne("state", 1).eq("authState", 2).ne("flag", 3));
+        map1.put("netcardriver", count);  //在线司机
+        
         Wrapper<TOrderTaxi> travelTime1 = new EntityWrapper<TOrderTaxi>().between("insertTime", calendar1.getTime(), calendar2.getTime());
-        if(companyId != null){
+        if (companyId != null) {
             travelTime1.eq("companyId", companyId);
         }
         int i1 = tOrderTaxiService.selectCount(travelTime1);
         map1.put("orderDetail2", i1);  //出租车订单
-
+        
         Wrapper<TOrderPrivateCar> zcTodayTme = new EntityWrapper<TOrderPrivateCar>().between("insertTime", calendar1.getTime(), calendar2.getTime());
-        if(companyId != null){
+        if (companyId != null) {
             zcTodayTme.eq("companyId", companyId);
         }
         int zcTodayNum = itOrderPrivateCarService.selectCount(zcTodayTme);
         map1.put("orderDetail1", zcTodayNum);  //快车订单
-
+        
         Wrapper<TOrderCrossCity> kcTodayTme = new EntityWrapper<TOrderCrossCity>().between("insertTime", calendar1.getTime(), calendar2.getTime());
-        if(companyId != null){
+        if (companyId != null) {
             kcTodayTme.eq("companyId", companyId);
         }
         int kcTodayNum = itOrderCrossCityService.selectCount(kcTodayTme);
         map1.put("orderDetail3", kcTodayNum);  //跨城订单
-
+        
         Wrapper<TOrderLogistics> tcxTodayTme = new EntityWrapper<TOrderLogistics>().between("insertTime", calendar1.getTime(), calendar2.getTime());
         if(companyId != null){
             tcxTodayTme.eq("companyId", companyId);
@@ -223,7 +216,7 @@
         Double allIncomeMoney = tOrderTaxiService.getAllIncomeMoney(companyId, null, null);
 
         ///   购买打车卡产生的收益
-        Double allCardMoney = taxiCardService.AllCardMoney(ShiroExtUtil.getUser().getObjectId());
+        Double allCardMoney = taxiCardService.AllCardMoney(shiroExtUtil.getUser().getObjectId());
         if(allCardMoney==null){
             allCardMoney=0.0;
         }
@@ -390,23 +383,25 @@
 
     @ResponseBody
     @PostMapping("/getDriverPosition")
-    public Object getDriverPosition(Integer companyId){
-        Integer id = ShiroExtUtil.getUser().getId();
+    public Object getDriverPosition(Integer companyId) {
+        Integer id = shiroExtUtil.getUser().getId();
         User user = userService.selectById(id);
-        if(companyId == null && user.getRoleType() != 1){
+        if (companyId == null && user.getRoleType() != 1) {
             companyId = user.getObjectId();
         }
         Wrapper<TDriver> ne = new EntityWrapper<TDriver>().eq("authState", 2).eq("state", 2).ne("flag", 3);
-        if(companyId != null){
+        if (companyId != null) {
             ne.eq("companyId", companyId).or().eq("franchiseeId", companyId);
         }
         List<TDriver> tDrivers = tDriverService.selectList(ne);
         Map<String, Object> map = new HashMap<>();
         List<Object> list = new ArrayList<>();
-        for(TDriver tDriver : tDrivers){
+        System.out.println(tDrivers.toString());
+        for (TDriver tDriver : tDrivers) {
             Map<String, Object> d = new HashMap<>();
-            String value = redisUtil.getValue("DRIVER" + tDriver.getId());
-            if(ToolUtil.isEmpty(value)){
+            String value = (String) redisTemplate.opsForValue().get("DRIVER" + tDriver.getId());
+            System.out.println(value);
+            if (ToolUtil.isEmpty(value)) {
                 continue;
             }
             d.put("driver", tDriver);
@@ -459,15 +454,15 @@
 
     @ResponseBody
     @PostMapping("/getCompanyInfoByUserId")
-    public Object getCompanyInfoByUserId(){
-        Integer id = ShiroExtUtil.getUser().getId();
+    public Object getCompanyInfoByUserId() {
+        Integer id = shiroExtUtil.getUser().getId();
         User user = userService.selectById(id);
         companys = new ArrayList<>();
         List<TCompany> ids = new ArrayList<>();
         TCompany tCompany = null;
-        if(user.getRoleType() == 1 && user.getObjectId() == null){
+        if (user.getRoleType() == 1 && user.getObjectId() == null) {
             tCompany = tCompanyService.selectById(1);
-        }else{
+        } else {
             tCompany = tCompanyService.selectById(user.getObjectId());
         }
         ids.add(tCompany);

--
Gitblit v1.7.1