From e809f5955584e600d8612540ea814977c49774c2 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期三, 27 八月 2025 23:51:54 +0800 Subject: [PATCH] 修改bug --- ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/HomeController.java | 160 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 98 insertions(+), 62 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 a53827f..4ba0d90 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,18 +1,16 @@ 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.shiro.ShiroKit; +import com.stylefeng.guns.core.beetl.ShiroExtUtil; import com.stylefeng.guns.core.util.SinataUtil; import com.stylefeng.guns.core.util.ToolUtil; 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,9 +18,12 @@ 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.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; /** * 首页统计 @@ -36,28 +37,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 +67,39 @@ @Autowired private ITOrderPrivateCarService itOrderPrivateCarService; - + @Autowired private ITOrderCrossCityService itOrderCrossCityService; - + @Autowired private ITOrderLogisticsService itOrderLogisticsService; - + @Autowired private IDriverOnlineService driverOnlineService; + + @Autowired + private ShiroExtUtil shiroExtUtil; + @Autowired + private ITOrderPrivateCarService iTOrderPrivateCarService; @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 = ShiroKit.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 +108,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 +134,52 @@ 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); //新增用户 + redisTemplate.opsForValue().set("dache:DRIVER14", "123456", 30, TimeUnit.SECONDS); - Wrapper<TDriver> ne1 = new EntityWrapper<TDriver>().ne("state", 1).eq("authState", 2).ne("flag", 3); - if(companyId != null){ - ne1.eq("companyId", companyId).or().eq("franchiseeId", companyId); + Wrapper<TDriver> warpper = new EntityWrapper<TDriver>().eq("authState", 2).eq("state", 2).ne("flag", 3); + if (companyId != null) { + warpper.eq("companyId", companyId); } - List<TDriver> tDrivers = tDriverService.selectList(ne1); - String keys = ""; - for(TDriver driver : tDrivers){ - keys += "DRIVER" + driver.getId() + ","; + List<TDriver> tDrivers = tDriverService.selectList(warpper); + int count = 0; + for (TDriver tDriver : tDrivers) { + Boolean hasKey = redisTemplate.hasKey("dache:DRIVER" + tDriver.getId()); + if(hasKey){ + count++ ; + } } - 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); //在线司机 + 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 +228,7 @@ Double allIncomeMoney = tOrderTaxiService.getAllIncomeMoney(companyId, null, null); /// 购买打车卡产生的收益 - Double allCardMoney = taxiCardService.AllCardMoney(ShiroKit.getUser().getObjectId()); + Double allCardMoney = taxiCardService.AllCardMoney(shiroExtUtil.getUser().getObjectId()); if(allCardMoney==null){ allCardMoney=0.0; } @@ -390,23 +395,25 @@ @ResponseBody @PostMapping("/getDriverPosition") - public Object getDriverPosition(Integer companyId){ - Integer id = ShiroKit.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("dache:DRIVER" + tDriver.getId()); + System.out.println(value); + if (ToolUtil.isEmpty(value)) { continue; } d.put("driver", tDriver); @@ -416,12 +423,31 @@ } map.put("driver", list); + + Map<String, Object> map2 = new HashMap<>(); - Wrapper<TOrderTaxi> eq = new EntityWrapper<TOrderTaxi>().eq("state", 1).eq("isDelete", 1); + Wrapper<TOrderPrivateCar> eq = new EntityWrapper<TOrderPrivateCar>().eq("state", 1).eq("isDelete", 1); if(companyId != null){ eq.eq("companyId", companyId); } - List<TOrderTaxi> tOrderTaxis = tOrderTaxiService.selectList(eq); + List<TOrderPrivateCar> tOrderPrivateCars = iTOrderPrivateCarService.selectList(eq); + list = new ArrayList<>(); + for(TOrderPrivateCar t : tOrderPrivateCars){ + Map<String, Object> map1 = new HashMap<>(); + map1.put("start", t.getStartAddress()); + map1.put("end", t.getEndAddress()); + map1.put("travelTime", t.getTravelTime()); + map1.put("carModel", ""); + map1.put("num", 1); + list.add(map1); + } + map2.put("zhuanche", list); + + Wrapper<TOrderTaxi> eq1 = new EntityWrapper<TOrderTaxi>().eq("state", 1).eq("isDelete", 1); + if(companyId != null){ + eq1.eq("companyId", companyId); + } + List<TOrderTaxi> tOrderTaxis = tOrderTaxiService.selectList(eq1); list = new ArrayList<>(); for(TOrderTaxi t : tOrderTaxis){ Map<String, Object> map1 = new HashMap<>(); @@ -442,8 +468,18 @@ @ResponseBody @PostMapping("/getAllOrder") public Object getAllOrder(){ - List<TOrderTaxi> tOrderTaxis = tOrderTaxiService.selectList(new EntityWrapper<TOrderTaxi>().eq("isDelete", 1)); + List<TOrderPrivateCar> orderPrivateCars = itOrderPrivateCarService.selectList(new EntityWrapper<TOrderPrivateCar>().eq("isDelete", 1).in("state", Arrays.asList(8, 9))); List list = new ArrayList<>(); + for(TOrderPrivateCar t : orderPrivateCars){ + Map<String, Object> map = new HashMap<>(); + if(Objects.isNull(t.getStartLon()) || Objects.isNull(t.getStartLat())){ + continue; + } + map.put("lon", t.getStartLon()); + map.put("lat", t.getStartLat()); + list.add(map); + } + List<TOrderTaxi> tOrderTaxis = tOrderTaxiService.selectList(new EntityWrapper<TOrderTaxi>().eq("isDelete", 1).in("state", Arrays.asList(8, 9))); for(TOrderTaxi t : tOrderTaxis){ Map<String, Object> map = new HashMap<>(); if(Objects.isNull(t.getStartLon()) || Objects.isNull(t.getStartLat())){ @@ -459,15 +495,15 @@ @ResponseBody @PostMapping("/getCompanyInfoByUserId") - public Object getCompanyInfoByUserId(){ - Integer id = ShiroKit.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