| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.stylefeng.guns.GunsApplication; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.common.constant.state.Order; |
| | |
| | | model.addAttribute("addressLon",map.get("addressLon")); |
| | | model.addAttribute("addressLat",map.get("addressLat")); |
| | | // 查询广东全区域数据 查询广东所有的代理商 |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | Wrapper<TAgent> status = new EntityWrapper<TAgent>().eq("status", 1); |
| | | if(null != agentId){ |
| | | status.eq("id", agentId); |
| | | } |
| | | List<TAgent> tAgentList = tAgentService.selectList(status); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | // 查询统计在线司机,待接单,服务中,已完成,已取消 |
| | | List<TDriver> onLineDriver = tDriverService.selectList(new EntityWrapper<TDriver>() |
| | |
| | | |
| | | @RequestMapping("/getMap") |
| | | @ResponseBody |
| | | public Object getMap(Integer agentId,Integer type,Model model) { |
| | | Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId(); |
| | | Integer roleType = ShiroKit.getUser().getRoleType(); |
| | | if(roleType == 3 && Objects.nonNull(objectId)){ |
| | | agentId = objectId; |
| | | public Object getMap(Integer agentId) { |
| | | Map<String, Object> maps = new HashMap<>(); |
| | | |
| | | Wrapper<TOrder> last = new EntityWrapper<TOrder>().eq("state", 301).eq("status", 1); |
| | | if(null != agentId){ |
| | | last.eq("agentId", agentId); |
| | | } |
| | | 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)){ |
| | | // 查询当前代理商 |
| | | TAgent tAgent = tAgentService.selectById(agentId); |
| | | Map<String, String> mapAddress = geocode(tAgent.getProvinceName()+tAgent.getCityName()); |
| | | map.put("addressLon",mapAddress.get("addressLon")); |
| | | map.put("addressLat",mapAddress.get("addressLat")); |
| | | // 查询统计在线司机,待接单,服务中,已完成,已取消 |
| | | List<TDriver> onLineDriver = tDriverService.selectList(new EntityWrapper<TDriver>() |
| | | .eq("agentId", agentId)); |
| | | List<TAgent> tAgentAllList = tAgentService.selectList(new EntityWrapper<TAgent>()); |
| | | List<Integer> allIds = tAgentAllList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | tOrderService.getDataStatisticsCountByIdsGetMap(allIds,map); |
| | | |
| | | // 查询服务中的订单列表 |
| | | List<TOrderServerResp> orderServerRespList = tOrderService.getDataStatisticsServerListByIds(allIds); |
| | | List<TOrder> orderList = tOrderService.selectList(new EntityWrapper<TOrder>()); |
| | | // 查询司机 |
| | | for (TOrderServerResp tOrderServerResp : orderServerRespList) { |
| | | TDriver tDriver = tDriverService.selectById(tOrderServerResp.getDriverId()); |
| | | tOrderServerResp.setAvatar(tDriver.getAvatar()); |
| | | tOrderServerResp.setDriverName(tDriver.getName()); |
| | | List<TOrder> collect = orderList.stream().filter(order -> tDriver.getId().equals(order.getDriverId()) && |
| | | (order.getState().equals(OrderStateEnum.WAIT_PAY.getCode()) |
| | | || order.getState().equals(OrderStateEnum.WAIT_EVALUATED.getCode()) |
| | | || order.getState().equals(OrderStateEnum.FINISH.getCode()))).collect(Collectors.toList()); |
| | | // 驾龄 |
| | | if(Objects.nonNull(tDriver.getFirstCertificateTime())){ |
| | | Period period = Period.between(LocalDate.now(), DateUtil.dateToLocalDate(tDriver.getFirstCertificateTime())); |
| | | tOrderServerResp.setDrivingExperience(Math.max(Math.abs(period.getYears()), 1)); |
| | | }else { |
| | | tOrderServerResp.setDrivingExperience(0); |
| | | } |
| | | // 代驾次数 |
| | | tOrderServerResp.setValetDrivingCount(collect.size()); |
| | | // 行驶时间 |
| | | long goTime = 0; |
| | | for (TOrder tOrder : collect) { |
| | | // 下车时间 |
| | | Date getoffTime = tOrder.getGetoffTime(); |
| | | // 上车时间 |
| | | Date boardingTime = tOrder.getBoardingTime(); |
| | | long minutes = Duration.between(DateUtil.dateToLocalDateTime(getoffTime), DateUtil.dateToLocalDateTime(boardingTime)).toMinutes(); |
| | | goTime += Math.abs(minutes); |
| | | } |
| | | tOrderServerResp.setGoTime(Long.valueOf(goTime).intValue()); |
| | | // 行驶里程 |
| | | if(CollectionUtils.isEmpty(collect)){ |
| | | tOrderServerResp.setMileageTraveled(0); |
| | | }else { |
| | | int sum = collect.stream().mapToInt(TOrder::getActualMileage).sum(); |
| | | tOrderServerResp.setMileageTraveled(sum/1000); |
| | | } |
| | | } |
| | | map.put("serverList",orderServerRespList); |
| | | // 查询今天所有订单 |
| | | 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<>(); |
| | | 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("onLineDriverCount",list1.size()); |
| | | // 拿到所有在线司机地址 |
| | | map.put("onLineDriver",list1); |
| | | }else { |
| | | 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)); |
| | | |
| | | Map<String, String> mapAddress = geocode("广东省广州市"); |
| | | map.put("addressLon",mapAddress.get("addressLon")); |
| | | map.put("addressLat",mapAddress.get("addressLat")); |
| | | |
| | | List<TAgent> tAgentAllList = tAgentService.selectList(new EntityWrapper<TAgent>()); |
| | | List<Integer> allIds = tAgentAllList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | tOrderService.getDataStatisticsCountByIdsGetMap(allIds,map); |
| | | |
| | | // 查询服务中的订单列表 |
| | | List<TOrderServerResp> orderServerRespList = tOrderService.getDataStatisticsServerListByIds(allIds); |
| | | List<TOrder> orderList = tOrderService.selectList(new EntityWrapper<TOrder>()); |
| | | // 查询司机 |
| | | for (TOrderServerResp tOrderServerResp : orderServerRespList) { |
| | | TDriver tDriver = tDriverService.selectById(tOrderServerResp.getDriverId()); |
| | | tOrderServerResp.setAvatar(tDriver.getAvatar()); |
| | | tOrderServerResp.setDriverName(tDriver.getName()); |
| | | List<TOrder> collect = orderList.stream().filter(order -> tDriver.getId().equals(order.getDriverId()) && |
| | | (order.getState().equals(OrderStateEnum.WAIT_PAY.getCode()) |
| | | || order.getState().equals(OrderStateEnum.WAIT_EVALUATED.getCode()) |
| | | || order.getState().equals(OrderStateEnum.FINISH.getCode()))).collect(Collectors.toList()); |
| | | // 驾龄 |
| | | if(Objects.nonNull(tDriver.getFirstCertificateTime())){ |
| | | Period period = Period.between(LocalDate.now(), DateUtil.dateToLocalDate(tDriver.getFirstCertificateTime())); |
| | | tOrderServerResp.setDrivingExperience(Math.max(Math.abs(period.getYears()), 1)); |
| | | }else { |
| | | tOrderServerResp.setDrivingExperience(0); |
| | | } |
| | | // 代驾次数 |
| | | tOrderServerResp.setValetDrivingCount(collect.size()); |
| | | // 行驶时间 |
| | | long goTime = 0; |
| | | for (TOrder tOrder : collect) { |
| | | // 下车时间 |
| | | Date getoffTime = tOrder.getGetoffTime(); |
| | | // 上车时间 |
| | | Date boardingTime = tOrder.getBoardingTime(); |
| | | long minutes = Duration.between(DateUtil.dateToLocalDateTime(getoffTime), DateUtil.dateToLocalDateTime(boardingTime)).toMinutes(); |
| | | goTime += Math.abs(minutes); |
| | | } |
| | | tOrderServerResp.setGoTime(Long.valueOf(goTime).intValue()); |
| | | // 行驶里程 |
| | | if(CollectionUtils.isEmpty(collect)){ |
| | | tOrderServerResp.setMileageTraveled(0); |
| | | }else { |
| | | int sum = collect.stream().mapToInt(TOrder::getActualMileage).sum(); |
| | | tOrderServerResp.setMileageTraveled(sum/1000); |
| | | } |
| | | } |
| | | map.put("serverList",orderServerRespList); |
| | | |
| | | // 查询今天所有订单 |
| | | List<TOrder> allList = tOrderService.getDataStatisticsAllListByIds(allIds,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<>(); |
| | | 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("onLineDriverCount",list1.size()); |
| | | // 拿到所有在线司机地址 |
| | | map.put("onLineDriver",list1); |
| | | List<TOrder> tOrders = tOrderService.selectList(last.last(" and UNIX_TIMESTAMP(createTime) + 7200 >= UNIX_TIMESTAMP(NOW())")); |
| | | List<Map<String, Object>> cancel = new ArrayList<>(); |
| | | for (TOrder order : tOrders) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("lonLat", order.getStartLng() + "," + order.getStartLat()); |
| | | cancel.add(map); |
| | | } |
| | | return map; |
| | | maps.put("cancel", cancel); |
| | | Wrapper<TDriver> eq = new EntityWrapper<TDriver>().eq("serverStatus", 1).eq("approvalStatus", 2).eq("status", 1); |
| | | if(null != agentId){ |
| | | eq.eq("agentId", agentId); |
| | | } |
| | | List<TDriver> tDrivers = tDriverService.selectList(eq); |
| | | List<Map<String, Object>> leisure = new ArrayList<>(); |
| | | for (TDriver tDriver : tDrivers) { |
| | | String value = redisUtil.getValue("DRIVER" + tDriver.getId()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", tDriver.getName()); |
| | | map.put("lonLat", value); |
| | | leisure.add(map); |
| | | } |
| | | maps.put("leisure", leisure); |
| | | |
| | | Wrapper<TOrder> en = new EntityWrapper<TOrder>().in("state", Arrays.asList(103, 104, 105, 106)).eq("status", 1); |
| | | if(null != agentId){ |
| | | en.eq("agentId", agentId); |
| | | } |
| | | List<TOrder> tOrders1 = tOrderService.selectList(en); |
| | | List<Map<String, Object>> receivedOrder = new ArrayList<>(); |
| | | for (TOrder order : tOrders1) { |
| | | String value = redisUtil.getValue("DRIVER" + order.getDriverId()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | TDriver tDriver = tDriverService.selectById(order.getDriverId()); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", tDriver.getName()); |
| | | map.put("lonLat", value); |
| | | receivedOrder.add(map); |
| | | } |
| | | maps.put("receivedOrder", receivedOrder); |
| | | |
| | | |
| | | Wrapper<TOrder> en1 = new EntityWrapper<TOrder>().eq("state", 102).eq("status", 1); |
| | | if(null != agentId){ |
| | | en1.eq("agentId", agentId); |
| | | } |
| | | List<TOrder> tOrders2 = tOrderService.selectList(en1); |
| | | List<Map<String, Object>> service = new ArrayList<>(); |
| | | for (TOrder order : tOrders2) { |
| | | TDriver tDriver = tDriverService.selectById(order.getDriverId()); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", tDriver.getName()); |
| | | map.put("lonLat", order.getStartLng() + "," + order.getStartLat()); |
| | | service.add(map); |
| | | } |
| | | maps.put("service", service); |
| | | |
| | | |
| | | List<TOrder> tOrders3 = tOrderService.selectList(new EntityWrapper<TOrder>().eq("state", 101).eq("hallOrder", 1).eq("status", 1)); |
| | | List<Map<String, Object>> lobby = new ArrayList<>(); |
| | | for (TOrder order : tOrders3) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("lonLat", order.getStartLng() + "," + order.getStartLat()); |
| | | lobby.add(map); |
| | | } |
| | | maps.put("lobby", lobby); |
| | | return maps; |
| | | } |
| | | |
| | | @RequestMapping("/getServerOrder") |