From 5989fe7ff0414176ebf2a72aa610cb76b44ea128 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 24 七月 2025 19:22:11 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/QianYunTong --- DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java | 232 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 222 insertions(+), 10 deletions(-) diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java index 354d01b..7c0e5cc 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java @@ -1,15 +1,21 @@ package com.stylefeng.guns.modular.system.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.stylefeng.guns.core.common.constant.JwtConstants; import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.shiro.ShiroUser; import com.stylefeng.guns.core.util.JwtTokenUtil; import com.stylefeng.guns.core.util.ToolUtil; +import com.stylefeng.guns.modular.crossCity.dao.OrderCrossCityMapper; +import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; +import com.stylefeng.guns.modular.specialTrain.dao.OrderPrivateCarMapper; +import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; import com.stylefeng.guns.modular.system.dao.*; import com.stylefeng.guns.modular.system.model.*; +import com.stylefeng.guns.modular.system.model.vo.*; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.*; import com.stylefeng.guns.modular.system.util.qianyuntong.SMSUtil; @@ -20,6 +26,8 @@ import com.stylefeng.guns.modular.system.warpper.BaseWarpper; import com.stylefeng.guns.modular.system.warpper.LoginWarpper; import com.stylefeng.guns.modular.system.warpper.RegisteredWarpper; +import com.stylefeng.guns.modular.taxi.dao.OrderTaxiMapper; +import com.stylefeng.guns.modular.taxi.model.OrderTaxi; import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; import io.rong.models.response.TokenResult; import org.apache.shiro.authc.SimpleAuthenticationInfo; @@ -36,6 +44,7 @@ import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.TimeUnit; @@ -46,8 +55,6 @@ @Resource private DriverMapper driverMapper; - @Resource - private CompanyCityMapper companyCityMapper; @Resource private UserActivityInviteMapper userActivityInviteMapper; @@ -87,9 +94,6 @@ @Resource private RedisTemplate<String, Object> redisTemplate; - - @Autowired - private ALiSendSms aLiSendSms; @Autowired private ICompanyCityService companyCityService; @@ -137,6 +141,52 @@ + @Autowired + private OrderPrivateCarMapper orderPrivateCarMapper; + + @Autowired + private OrderCrossCityMapper orderCrossCityMapper; + + @Autowired + private OrderTaxiMapper orderTaxiMapper; + + @Autowired + private GeodesyUtil geodesyUtil; + + + @Override + public List<Driver> queryIdleDriver(Integer type, Double lon, Double lat, Double distance, Integer companyId) throws Exception { + List<Driver> drivers = driverMapper.queryIdleDriver(type, companyId); + List<Driver> list = new ArrayList<>(); + for(Driver driver : drivers){ + String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(driver.getId())); + if(null != value){ + Map<String, Double> distance1 = geodesyUtil.getDistance(lon + "," + lat, value); + double d = Double.valueOf(distance1.get("WGS84")).doubleValue(); + if(d < (distance * 1000)){ + list.add(driver); + } + } + } + return list; + } + + @Override + public List<Driver> queryIdleDriver(Integer type, Integer serverCarModelId, Double lon, Double lat, Double distance, Integer companyId) throws Exception { + List<Driver> drivers = driverMapper.queryIdleDriver_(type, serverCarModelId, companyId); + List<Driver> list = new ArrayList<>(); + for(Driver driver : drivers){ + String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(driver.getId())); + if(null != value){ + Map<String, Double> distance1 = geodesyUtil.getDistance(lon + "," + lat, value); + double d = Double.valueOf(distance1.get("WGS84")).doubleValue(); + if(d < (distance * 1000)){ + list.add(driver); + } + } + } + return list; + } /** * 获取短信验证码 @@ -486,10 +536,10 @@ } Company company = companyMapper.selectById(driver.getCompanyId()); //查询中台员工数据 - List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(driver.getPhone(), company.getEnterCode()); - if (null == userInfoByPhone || userInfoByPhone.size() == 0) { - return ResultUtil.error("账号未注册"); - } +// List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(driver.getPhone(), company.getEnterCode()); +// if (null == userInfoByPhone || userInfoByPhone.size() == 0) { +// return ResultUtil.error("账号未注册"); +// } if (ToolUtil.isNotEmpty(driver.getIdCard()) && driver.getAuthState() == 1) { return ResultUtil.error("账号正在审核中,请耐心等待"); @@ -1555,7 +1605,169 @@ redisTemplate.delete("DEVICE_" + id);//清除车载端登录的标识 return ResultUtil.success(); } - + + @Override + public DriverIndexVo queryHomeDataFromDriver(Integer uid) { + DriverIndexVo driverIndexVo = new DriverIndexVo(); + // 获取快车订单 + List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.selectList(new EntityWrapper<OrderPrivateCar>().ne("state", 10).eq("driverId", uid).like("insertTime", LocalDateTime.now().toString())); + // 跨城订单 + List<OrderCrossCity> orderCrossCities = orderCrossCityMapper.selectList(new EntityWrapper<OrderCrossCity>().ne("state", 10).eq("driverId", uid).like("insertTime", LocalDateTime.now().toString())); + // 出租车订单 + List<OrderTaxi> orderTaxis = orderTaxiMapper.selectList(new EntityWrapper<OrderTaxi>().ne("state", 10).eq("driverId", uid).like("insertTime", LocalDateTime.now().toString())); + driverIndexVo.setTodayOrderNum(orderPrivateCars.size() + orderCrossCities.size() + orderTaxis.size()); + + + double sum = orderPrivateCars.stream().mapToDouble(OrderPrivateCar::getOrderMoney).sum(); + double sum1 = orderCrossCities.stream().mapToDouble(OrderCrossCity::getOrderMoney).sum(); + double sum2 = orderTaxis.stream().mapToDouble(OrderTaxi::getOrderMoney).sum(); + driverIndexVo.setTodayOrderMoney(new BigDecimal(sum +sum1+sum2)); + + + BigDecimal reduce = orderPrivateCarMapper.selectList(new EntityWrapper<OrderPrivateCar>().eq("promotionDriverId", uid).like("insertTime", LocalDateTime.now().toString())).stream().map(OrderPrivateCar::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal reduce1 = orderCrossCityMapper.selectList(new EntityWrapper<OrderCrossCity>().eq("promotionDriverId", uid).like("insertTime", LocalDateTime.now().toString())).stream().map(OrderCrossCity::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal reduce2 = orderTaxiMapper.selectList(new EntityWrapper<OrderTaxi>().eq("promotionDriverId", uid).like("insertTime", LocalDateTime.now().toString())).stream().map(OrderTaxi::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + driverIndexVo.setTodayPromotionMoney(reduce.add(reduce1).add(reduce2)); + return driverIndexVo; + }; + + + + @Override + public DriverOrderDataVo queryOrderDataFromDriver(String time, Page<DriverOrderDataNextVo> driverOrderDataVoPage, Integer uid) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM"); + // 总的订单数 + List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.selectList(new EntityWrapper<OrderPrivateCar>().ne("state", 10).eq("driverId", uid)); + // 跨城订单 + List<OrderCrossCity> orderCrossCities = orderCrossCityMapper.selectList(new EntityWrapper<OrderCrossCity>().ne("state", 10).eq("driverId", uid)); + // 出租车订单 + List<OrderTaxi> orderTaxis = orderTaxiMapper.selectList(new EntityWrapper<OrderTaxi>().ne("state", 10).eq("driverId", uid)); + DriverOrderDataVo driverOrderDataVo = new DriverOrderDataVo(); + driverOrderDataVo.setAllOrderNum(orderPrivateCars.size() + orderCrossCities.size() + orderTaxis.size()); + long count = orderPrivateCars.stream().filter(e -> simpleDateFormat.format(e.getInsertTime()).equals(LocalDateTime.now().toString())).count(); + long count1 = orderCrossCities.stream().filter(e -> simpleDateFormat.format(e.getInsertTime()).equals(LocalDateTime.now().toString())).count(); + long count2 = orderTaxis.stream().filter(e -> simpleDateFormat.format(e.getInsertTime()).equals(LocalDateTime.now().toString())).count(); + driverOrderDataVo.setTodayOrderNum((int) (count+count1+count2)); + + Date date = new Date(); + String month = simpleDateFormat1.format(date); + long count3 = orderPrivateCars.stream().filter(e -> simpleDateFormat1.format(e.getInsertTime()).equals(month)).count(); + long count4 = orderCrossCities.stream().filter(e -> simpleDateFormat1.format(e.getInsertTime()).equals(month)).count(); + long count5 = orderTaxis.stream().filter(e -> simpleDateFormat1.format(e.getInsertTime()).equals(month)).count(); + driverOrderDataVo.setMonthOrderNum((int) (count3+count4+count5)); + + String sTime=null; + String eTime=null; + if(ToolUtil.isNotEmpty( time)){ + sTime=time.split(" - ")[0]+" 00:00:00"; + eTime=time.split(" - ")[1]+" 23:59:59"; + } + List<DriverOrderDataNextVo> driverOrderDataNextVoPage = driverServiceMapper.queryOrderDataFromDriver(sTime, eTime, driverOrderDataVoPage, uid); + driverOrderDataVoPage.setRecords(driverOrderDataNextVoPage); + driverOrderDataVo.setDriverOrderDataNextVos(driverOrderDataVoPage); + return driverOrderDataVo; + } + + + + @Override + public DriverOrderMoneyDataVo queryOrderMoneyFromDriver(String time, Page<DriverOrderDataNextVo> driverOrderDataVoPage, Integer uid) { + DriverOrderMoneyDataVo driverOrderDataVo = new DriverOrderMoneyDataVo(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM"); + // 总的订单数 + List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.selectList(new EntityWrapper<OrderPrivateCar>().in("state",Arrays.asList(8,9)).eq("driverId", uid)); + // 跨城订单 + List<OrderCrossCity> orderCrossCities = orderCrossCityMapper.selectList(new EntityWrapper<OrderCrossCity>().in("state",Arrays.asList(8,9)).eq("driverId", uid)); + // 出租车订单 + List<OrderTaxi> orderTaxis = orderTaxiMapper.selectList(new EntityWrapper<OrderTaxi>().in("state",Arrays.asList(8,9)).eq("driverId", uid)); + + + double sum = orderPrivateCars.stream().mapToDouble(OrderPrivateCar::getOrderMoney).sum(); + double sum1 = orderCrossCities.stream().mapToDouble(OrderCrossCity::getOrderMoney).sum(); + double sum2 = orderTaxis.stream().mapToDouble(OrderTaxi::getOrderMoney).sum(); + driverOrderDataVo.setAllOrderMoney(new BigDecimal(sum +sum1+sum2)); + + + + double count = orderPrivateCars.stream().filter(e -> simpleDateFormat.format(e.getInsertTime()).equals(LocalDateTime.now().toString())).mapToDouble(OrderPrivateCar::getOrderMoney).sum(); + double count1 = orderCrossCities.stream().filter(e -> simpleDateFormat.format(e.getInsertTime()).equals(LocalDateTime.now().toString())).mapToDouble(OrderCrossCity::getOrderMoney).sum(); + double count2 = orderTaxis.stream().filter(e -> simpleDateFormat.format(e.getInsertTime()).equals(LocalDateTime.now().toString())).mapToDouble(OrderTaxi::getOrderMoney).sum(); + driverOrderDataVo.setTodayOrderMoney(new BigDecimal(count+count1+count2)); + + + Date date = new Date(); + String month = simpleDateFormat1.format(date); + double count3 = orderPrivateCars.stream().filter(e -> simpleDateFormat1.format(e.getInsertTime()).equals(month)).mapToDouble(OrderPrivateCar::getOrderMoney).sum(); + double count4 = orderCrossCities.stream().filter(e -> simpleDateFormat1.format(e.getInsertTime()).equals(month)).mapToDouble(OrderCrossCity::getOrderMoney).sum(); + double count5 = orderTaxis.stream().filter(e -> simpleDateFormat1.format(e.getInsertTime()).equals(month)).mapToDouble(OrderTaxi::getOrderMoney).sum(); + driverOrderDataVo.setMonthOrderMoney(new BigDecimal(count3+count4+count5)); + + String sTime=null; + String eTime=null; + if(ToolUtil.isNotEmpty( time)){ + sTime=time.split(" - ")[0]+" 00:00:00"; + eTime=time.split(" - ")[1]+" 23:59:59"; + } + List<DriverOrderDataNextVo> driverOrderDataNextVoPage = driverServiceMapper.queryOrderMoneyDataFromDriver(sTime, eTime, driverOrderDataVoPage, uid); + List<DriverOrderDataNextVo> driverOrderDataNextVoPage1 = driverServiceMapper.queryOrderMoneyDataFromDriverAll(sTime, eTime, uid); + double sum3 = driverOrderDataNextVoPage1.stream().mapToDouble(DriverOrderDataNextVo::getOrderMoney).sum(); + driverOrderDataVo.setSearchMoney(new BigDecimal(sum3)); + driverOrderDataVoPage.setRecords(driverOrderDataNextVoPage); + driverOrderDataVo.setDriverOrderDataNextVos(driverOrderDataVoPage); + return driverOrderDataVo; + } + @Override + public DriverOrderPromotionDataVo queryOrderPromotionFromDriver(String time, Page<DriverOrderDataNextVo> driverOrderDataVoPage, Integer uid) { + DriverOrderPromotionDataVo driverOrderDataVo = new DriverOrderPromotionDataVo(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM"); + // 总的订单数 + List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.selectList(new EntityWrapper<OrderPrivateCar>().in("state",Arrays.asList(8,9)).eq("promotionDriverId", uid)); + // 跨城订单 + List<OrderCrossCity> orderCrossCities = orderCrossCityMapper.selectList(new EntityWrapper<OrderCrossCity>().in("state",Arrays.asList(8,9)).eq("promotionDriverId", uid)); + // 出租车订单 + List<OrderTaxi> orderTaxis = orderTaxiMapper.selectList(new EntityWrapper<OrderTaxi>().in("state",Arrays.asList(8,9)).eq("promotionDriverId", uid)); + + + BigDecimal sum = orderPrivateCars.stream().map(OrderPrivateCar::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal sum1 = orderCrossCities.stream().map(OrderCrossCity::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal sum2 = orderTaxis.stream().map(OrderTaxi::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + driverOrderDataVo.setAllOrderMoney(sum.add(sum1).add(sum2)); + + + + BigDecimal count = orderPrivateCars.stream().filter(e -> simpleDateFormat.format(e.getInsertTime()).equals(LocalDateTime.now().toString())).map(OrderPrivateCar::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal count1 = orderCrossCities.stream().filter(e -> simpleDateFormat.format(e.getInsertTime()).equals(LocalDateTime.now().toString())).map(OrderCrossCity::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal count2 = orderTaxis.stream().filter(e -> simpleDateFormat.format(e.getInsertTime()).equals(LocalDateTime.now().toString())).map(OrderTaxi::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + driverOrderDataVo.setTodayOrderMoney(count.add(count1).add(count2)); + + + Date date = new Date(); + String month = simpleDateFormat1.format(date); + BigDecimal count3 = orderPrivateCars.stream().filter(e -> simpleDateFormat1.format(e.getInsertTime()).equals(month)).map(OrderPrivateCar::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal count4 = orderCrossCities.stream().filter(e -> simpleDateFormat1.format(e.getInsertTime()).equals(month)).map(OrderCrossCity::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal count5 = orderTaxis.stream().filter(e -> simpleDateFormat1.format(e.getInsertTime()).equals(month)).map(OrderTaxi::getPromotionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + driverOrderDataVo.setMonthOrderMoney(count3.add(count4).add(count5)); + + String sTime=null; + String eTime=null; + if(ToolUtil.isNotEmpty( time)){ + sTime=time.split(" - ")[0]+" 00:00:00"; + eTime=time.split(" - ")[1]+" 23:59:59"; + } + List<DriverOrderDataNextVo> driverOrderDataNextVoPage = driverServiceMapper.queryOrderPromotionFromDriver(sTime, eTime, driverOrderDataVoPage, uid); + List<DriverOrderDataNextVo> driverOrderDataNextVoPage1 =driverServiceMapper.queryOrderPromotionFromDriverAll(sTime, eTime, uid); + double sum3 = driverOrderDataNextVoPage1.stream().mapToDouble(DriverOrderDataNextVo::getOrderMoney).sum(); + driverOrderDataVo.setSearchMoney(new BigDecimal(sum3)); + + driverOrderDataVoPage.setRecords(driverOrderDataNextVoPage); + driverOrderDataVo.setDriverOrderDataNextVos(driverOrderDataVoPage); + return driverOrderDataVo; + } + + /** * 单点登录 * -- Gitblit v1.7.1