| | |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.common.constant.state.Order; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TOrderServerResp; |
| | | import com.stylefeng.guns.modular.system.enums.OrderStateEnum; |
| | | import com.stylefeng.guns.modular.system.enums.StatusEnum; |
| | | import com.stylefeng.guns.modular.system.model.TAgent; |
| | | import com.stylefeng.guns.modular.system.model.TDriver; |
| | | import com.stylefeng.guns.modular.system.model.TOrder; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.DateUtil; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | private ITOrderService tOrderService; |
| | | @Autowired |
| | | private ITRevenueService tRevenueService; |
| | | @Autowired |
| | | private ITDriverWorkService tDriverWorkService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | private String PREFIX = "/system/tHomePage/"; |
| | | |
| | |
| | | */ |
| | | @RequestMapping("/map") |
| | | public String map(Integer agentId,Integer type,Model model) { |
| | | // 查询所有代理商 |
| | | List<TAgent> agentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .ne("status", StatusEnum.DELETE.getCode()) |
| | | .ne("principal","")); |
| | | model.addAttribute("agentList",agentList); |
| | | // 查询广东全区域数据 查询广东所有的代理商 |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | // 查询统计在线司机,待接单,服务中,已完成,已取消 |
| | | List<TDriver> onLineDriver = tDriverService.selectList(new EntityWrapper<TDriver>() |
| | | .in("agentId", ids) |
| | | .eq("serverStatus", 2)); |
| | | |
| | | model.addAttribute("onLineDriverCount",onLineDriver.size()); |
| | | tOrderService.getDataStatisticsCountByIds(ids,model); |
| | | // 查询服务中的订单列表 |
| | | List<TOrderServerResp> orderServerRespList = tOrderService.getDataStatisticsServerListByIds(ids); |
| | | // 查询司机 |
| | | for (TOrderServerResp tOrderServerResp : orderServerRespList) { |
| | | TDriver tDriver = tDriverService.selectById(tOrderServerResp.getDriverId()); |
| | | tOrderServerResp.setAvatar(tDriver.getAvatar()); |
| | | tOrderServerResp.setDriverName(tDriver.getName()); |
| | | } |
| | | model.addAttribute("serverList",orderServerRespList); |
| | | // 查询今天所有订单 |
| | | List<TOrder> allList = tOrderService.getDataStatisticsAllListByIds(ids,type); |
| | | List<List<String>> list = new ArrayList<>(allList.size()); |
| | | for (TOrder tOrder : allList) { |
| | | List<String> obj = new ArrayList<>(3); |
| | | obj.add(tOrder.getStartLng()); |
| | | obj.add(tOrder.getStartLat()); |
| | | obj.add(String.valueOf(tOrder.getState())); |
| | | list.add(obj); |
| | | } |
| | | model.addAttribute("allList",list); |
| | | List<List<String>> list1 = new ArrayList<>(allList.size()); |
| | | for (TDriver tDriver : onLineDriver) { |
| | | List<String> obj = new ArrayList<>(3); |
| | | String value = redisUtil.getValue("DRIVER" + tDriver.getId()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | obj.add(value.split(",")[0]);// 经度 |
| | | obj.add(value.split(",")[1]);// 纬度 |
| | | obj.add(String.valueOf(tDriver.getServerStatus()));// 服务状态 |
| | | list1.add(obj); |
| | | } |
| | | // 拿到所有在线司机地址 |
| | | model.addAttribute("onLineDriver",list1); |
| | | return PREFIX + "tHomePageMap.html"; |
| | | } |
| | | |
| | | @RequestMapping("/getMap") |
| | | @ResponseBody |
| | | public Object getMap(Integer agentId,Integer type,Model model) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | // 查询所有代理商 |
| | | List<TAgent> agentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .ne("status", StatusEnum.DELETE.getCode()) |
| | | .ne("principal","")); |
| | | |
| | | map.put("agentList",agentList); |
| | | if(Objects.nonNull(agentId)){ |
| | | // 查询统计在线司机,待接单,服务中,已完成,已取消 |
| | | Map<String,Integer> map = new HashMap<>(4); |
| | | int serverCount = tDriverService.selectCount(new EntityWrapper<TDriver>() |
| | | List<TDriver> onLineDriver = tDriverService.selectList(new EntityWrapper<TDriver>() |
| | | .eq("agentId", agentId) |
| | | .eq("serverStatus", 2)); |
| | | tOrderService.getDataStatisticsCount(agentId,map); |
| | | model.addAttribute("map",map); |
| | | |
| | | map.put("onLineDriverCount",onLineDriver.size()); |
| | | tOrderService.getDataStatisticsCountGetMap(agentId,map); |
| | | // 查询服务中的订单列表 |
| | | List<TOrderServerResp> orderServerRespList = tOrderService.getDataStatisticsServerList(agentId); |
| | | model.addAttribute("serverList",orderServerRespList); |
| | | |
| | | // 查询司机 |
| | | for (TOrderServerResp tOrderServerResp : orderServerRespList) { |
| | | TDriver tDriver = tDriverService.selectById(tOrderServerResp.getDriverId()); |
| | | tOrderServerResp.setAvatar(tDriver.getAvatar()); |
| | | tOrderServerResp.setDriverName(tDriver.getName()); |
| | | } |
| | | map.put("serverList",orderServerRespList); |
| | | // 查询今天所有订单 |
| | | List<TOrder> allList = tOrderService.getDataStatisticsAllList(agentId); |
| | | |
| | | // TODO 拿到所有司机地址 |
| | | |
| | | List<TOrder> allList = tOrderService.getDataStatisticsAllList(agentId,type); |
| | | List<List<String>> list = new ArrayList<>(allList.size()); |
| | | for (TOrder tOrder : allList) { |
| | | List<String> obj = new ArrayList<>(3); |
| | | obj.add(tOrder.getStartLng()); |
| | | obj.add(tOrder.getStartLat()); |
| | | obj.add(String.valueOf(tOrder.getState())); |
| | | list.add(obj); |
| | | } |
| | | map.put("allList",list); |
| | | List<List<String>> list1 = new ArrayList<>(allList.size()); |
| | | for (TDriver tDriver : onLineDriver) { |
| | | List<String> obj = new ArrayList<>(3); |
| | | String value = redisUtil.getValue("DRIVER" + tDriver.getId()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | obj.add(value.split(",")[0]);// 经度 |
| | | obj.add(value.split(",")[1]);// 纬度 |
| | | obj.add(String.valueOf(tDriver.getServerStatus()));// 服务状态 |
| | | list1.add(obj); |
| | | } |
| | | // 拿到所有在线司机地址 |
| | | map.put("onLineDriver",list1); |
| | | }else { |
| | | // TODO 查询广东全区域数据 |
| | | } |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | // 查询统计在线司机,待接单,服务中,已完成,已取消 |
| | | List<TDriver> onLineDriver = tDriverService.selectList(new EntityWrapper<TDriver>() |
| | | .in("agentId", ids) |
| | | .eq("serverStatus", 2)); |
| | | |
| | | return PREFIX + "tHomePageMap.html"; |
| | | map.put("onLineDriverCount",onLineDriver.size()); |
| | | tOrderService.getDataStatisticsCountByIdsGetMap(ids,map); |
| | | // 查询服务中的订单列表 |
| | | List<TOrderServerResp> orderServerRespList = tOrderService.getDataStatisticsServerListByIds(ids); |
| | | // 查询司机 |
| | | for (TOrderServerResp tOrderServerResp : orderServerRespList) { |
| | | TDriver tDriver = tDriverService.selectById(tOrderServerResp.getDriverId()); |
| | | tOrderServerResp.setAvatar(tDriver.getAvatar()); |
| | | tOrderServerResp.setDriverName(tDriver.getName()); |
| | | } |
| | | map.put("serverList",orderServerRespList); |
| | | // 查询今天所有订单 |
| | | List<TOrder> allList = tOrderService.getDataStatisticsAllListByIds(ids,type); |
| | | List<List<String>> list = new ArrayList<>(allList.size()); |
| | | for (TOrder tOrder : allList) { |
| | | List<String> obj = new ArrayList<>(3); |
| | | obj.add(tOrder.getStartLng()); |
| | | obj.add(tOrder.getStartLat()); |
| | | obj.add(String.valueOf(tOrder.getState())); |
| | | list.add(obj); |
| | | } |
| | | map.put("allList",list); |
| | | List<List<String>> list1 = new ArrayList<>(allList.size()); |
| | | for (TDriver tDriver : onLineDriver) { |
| | | List<String> obj = new ArrayList<>(3); |
| | | String value = redisUtil.getValue("DRIVER" + tDriver.getId()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | obj.add(value.split(",")[0]);// 经度 |
| | | obj.add(value.split(",")[1]);// 纬度 |
| | | obj.add(String.valueOf(tDriver.getServerStatus()));// 服务状态 |
| | | list1.add(obj); |
| | | } |
| | | // 拿到所有在线司机地址 |
| | | map.put("onLineDriver",list1); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | @RequestMapping("/getServerOrder") |
| | | @ResponseBody |
| | | public Object getServerOrder(Integer agentId,Model model) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | if(Objects.nonNull(agentId)){ |
| | | // 查询服务中的订单列表 |
| | | List<TOrderServerResp> orderServerRespList = tOrderService.getDataStatisticsServerList(agentId); |
| | | // 查询司机 |
| | | for (TOrderServerResp tOrderServerResp : orderServerRespList) { |
| | | TDriver tDriver = tDriverService.selectById(tOrderServerResp.getDriverId()); |
| | | tOrderServerResp.setAvatar(tDriver.getAvatar()); |
| | | tOrderServerResp.setDriverName(tDriver.getName()); |
| | | } |
| | | map.put("serverList",orderServerRespList); |
| | | }else { |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | // 查询服务中的订单列表 |
| | | List<TOrderServerResp> orderServerRespList = tOrderService.getDataStatisticsServerListByIds(ids); |
| | | // 查询司机 |
| | | for (TOrderServerResp tOrderServerResp : orderServerRespList) { |
| | | TDriver tDriver = tDriverService.selectById(tOrderServerResp.getDriverId()); |
| | | tOrderServerResp.setAvatar(tDriver.getAvatar()); |
| | | tOrderServerResp.setDriverName(tDriver.getName()); |
| | | } |
| | | map.put("serverList",orderServerRespList); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RequestMapping("/statistics") |
| | | public String statistics(Integer agentId,String dayDate,String yearDate,String monthDate,Integer type,Model model) { |
| | | if(Objects.isNull(type)){ |
| | | type = 1; |
| | | } |
| | | model.addAttribute("txt",new SimpleDateFormat("yyyy年MM月dd日").format(new Date()) + DateUtil.getWeekDay(new Date()) + ",欢迎" + |
| | | Objects.requireNonNull(ShiroKit.getUser()).getName() + "登录"); |
| | | // 查询所有代理商 |
| | | List<TAgent> agentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .ne("status", StatusEnum.DELETE.getCode()) |
| | | .ne("principal","")); |
| | | model.addAttribute("agentList",agentList); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(Objects.nonNull(agentId)){ |
| | | // 统计代理商 |
| | | tAgentService.getDataStatistics(agentId,model); |
| | | tAgentService.getDataStatistics(agentId,model,map); |
| | | |
| | | // 统计司机数 |
| | | tDriverService.getDataStatistics(agentId,model); |
| | | tDriverService.getDataStatistics(agentId,model,map); |
| | | |
| | | // TODO 订单统计:按今天,昨天,本周,本月 |
| | | // 订单统计本月 |
| | | tOrderService.getStatisticsOrderByMonth(agentId,dayDate,model,map); |
| | | |
| | | // 订单统计,每年按月份 |
| | | tOrderService.getDataStatisticsByYear(agentId,yearDate,model); |
| | | tOrderService.getDataStatisticsByYear(agentId,yearDate,model,map); |
| | | |
| | | // 业绩排名 performanceTable |
| | | if (1 == type){ |
| | | // 单量 |
| | | tOrderService.getDataStatisticsOrderCount(agentId,monthDate,model); |
| | | tOrderService.getDataStatisticsOrderCount(agentId,monthDate,model,map); |
| | | }else { |
| | | // 收入、佣金 |
| | | tRevenueService.getDataStatisticsIncomeOrCommission(agentId,monthDate,type,model); |
| | | tRevenueService.getDataStatisticsIncomeOrCommission(agentId,monthDate,type,model,map); |
| | | } |
| | | |
| | | }else { |
| | | // TODO 查询广东全区域数据 |
| | | // 查询广东全区域数据 查询广东所有的代理商 |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | // 统计代理商 |
| | | tAgentService.getDataStatisticsByIds(ids,model,map); |
| | | |
| | | // 统计司机数 |
| | | tDriverService.getDataStatisticsByIds(ids,model,map); |
| | | |
| | | // 订单统计本月 |
| | | tOrderService.getStatisticsOrderByMonthIds(ids,dayDate,model,map); |
| | | |
| | | // 订单统计,每年按月份 |
| | | tOrderService.getDataStatisticsByYearByIds(ids,yearDate,model,map); |
| | | |
| | | // 业绩排名 performanceTable |
| | | if (1 == type){ |
| | | // 单量 |
| | | tOrderService.getDataStatisticsOrderCountByIds(ids,monthDate,model,map); |
| | | }else { |
| | | // 收入、佣金 |
| | | tRevenueService.getDataStatisticsIncomeOrCommissionByIds(ids,monthDate,type,model,map); |
| | | } |
| | | } |
| | | return PREFIX + "tHomePageStatistics.html"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 首页统计通过代理商查询 |
| | | */ |
| | | @RequestMapping("/statisticsByAgentId") |
| | | @ResponseBody |
| | | public Map<String, Object> statisticsByAgentId(Integer agentId, String dayDate, String yearDate, String monthDate, Integer type, Model model) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(Objects.nonNull(agentId)){ |
| | | // 统计代理商 |
| | | tAgentService.getDataStatistics(agentId,model,map); |
| | | |
| | | // 统计司机数 |
| | | tDriverService.getDataStatistics(agentId,model,map); |
| | | |
| | | // 订单统计本月 |
| | | tOrderService.getStatisticsOrderByMonth(agentId,dayDate,model,map); |
| | | |
| | | // 订单统计,每年按月份 |
| | | tOrderService.getDataStatisticsByYear(agentId,yearDate,model,map); |
| | | |
| | | // 业绩排名 performanceTable |
| | | if (1 == type){ |
| | | // 单量 |
| | | tOrderService.getDataStatisticsOrderCount(agentId,monthDate,model,map); |
| | | }else { |
| | | // 收入、佣金 |
| | | tRevenueService.getDataStatisticsIncomeOrCommission(agentId,monthDate,type,model,map); |
| | | } |
| | | |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 首页统计通过代理商查询订单量 今天,昨天,本周,本月 |
| | | */ |
| | | @RequestMapping("/statisticsMonthByAgentId") |
| | | @ResponseBody |
| | | public Map<String, Object> statisticsMonthByAgentId(Integer agentId, String dayDate,Model model) { |
| | | dayDate = new SimpleDateFormat("yyyy-MM").format(new Date()); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(Objects.nonNull(agentId)){ |
| | | // 订单统计本月 |
| | | tOrderService.getStatisticsOrderByMonth(agentId,dayDate,model,map); |
| | | }else { |
| | | // 查询广东全区域数据 查询广东所有的代理商 |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | // 订单统计本月 |
| | | tOrderService.getStatisticsOrderByMonthIds(ids,dayDate,model,map); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 首页统计通过代理商查询订单量 按年 |
| | | */ |
| | | @RequestMapping("/statisticsYearByAgentId") |
| | | @ResponseBody |
| | | public Map<String, Object> statisticsYearByAgentId(Integer agentId, String yearDate,Model model) { |
| | | if(!StringUtils.hasLength(yearDate)){ |
| | | yearDate = new SimpleDateFormat("yyyy").format(new Date()); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(Objects.nonNull(agentId)){ |
| | | // 订单统计,每年按月份 |
| | | tOrderService.getDataStatisticsByYear(agentId,yearDate,model,map); |
| | | }else { |
| | | // 查询广东全区域数据 查询广东所有的代理商 |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | tOrderService.getDataStatisticsByYearByIds(ids,yearDate,model,map); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 首页统计通过代理商查询订单量,收入,佣金 按年 |
| | | */ |
| | | @RequestMapping("/statisticsOrderByAgentId") |
| | | @ResponseBody |
| | | public Map<String, Object> statisticsOrderByAgentId(Integer agentId, String monthDate,Integer type,Model model) { |
| | | if(Objects.isNull(type)){ |
| | | type = 1; |
| | | } |
| | | if(!StringUtils.hasLength(monthDate)){ |
| | | monthDate = new SimpleDateFormat("yyyy-MM").format(new Date()); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(Objects.nonNull(agentId)){ |
| | | // 业绩排名 performanceTable |
| | | if (1 == type){ |
| | | // 单量 |
| | | tOrderService.getDataStatisticsOrderCount(agentId,monthDate,model,map); |
| | | }else { |
| | | // 收入、佣金 |
| | | tRevenueService.getDataStatisticsIncomeOrCommission(agentId,monthDate,type,model,map); |
| | | } |
| | | }else { |
| | | // 业绩排名 performanceTable |
| | | // 查询广东全区域数据 查询广东所有的代理商 |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | if (1 == type){ |
| | | // 单量 |
| | | tOrderService.getDataStatisticsOrderCountByIds(ids,monthDate,model,map); |
| | | }else { |
| | | // 收入、佣金 |
| | | tRevenueService.getDataStatisticsIncomeOrCommissionByIds(ids,monthDate,type,model,map); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 首页统计通过代理商查询司机数量 |
| | | */ |
| | | @RequestMapping("/statisticsDriverByAgentId") |
| | | @ResponseBody |
| | | public Map<String, Object> statisticsDriverByAgentId(Integer agentId,Model model) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(Objects.nonNull(agentId)){ |
| | | // 统计司机数 |
| | | tDriverService.getDataStatistics(agentId,model,map); |
| | | tAgentService.getDataStatistics(agentId,model,map); |
| | | }else { |
| | | // 统计司机数 |
| | | // 查询广东全区域数据 查询广东所有的代理商 |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | tDriverService.getDataStatisticsByIds(ids,model,map); |
| | | tAgentService.getDataStatisticsByIds(ids,model,map); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | } |