| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.GunsApplication; |
| | | 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.controller.util.HttpUtils; |
| | | 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.TDriverWork; |
| | | import com.stylefeng.guns.modular.system.model.TOrder; |
| | | import com.stylefeng.guns.modular.system.pojo.GaoDePoJo; |
| | | 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.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | |
| | | @RequestMapping("/tHomePage") |
| | | public class THomePageController extends BaseController { |
| | | |
| | | private final static Logger log = LoggerFactory.getLogger(THomePageController.class); |
| | | |
| | | @Autowired |
| | | private IUserService userService; |
| | | @Autowired |
| | |
| | | private ITRevenueService tRevenueService; |
| | | @Autowired |
| | | private ITDriverWorkService tDriverWorkService; |
| | | @Autowired |
| | | private GaoDePoJo gaoDePoJo; |
| | | @Autowired |
| | | private HttpUtils httpUtils; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | |
| | | .ne("status", StatusEnum.DELETE.getCode()) |
| | | .ne("principal","")); |
| | | model.addAttribute("agentList",agentList); |
| | | // 查询广东省广州市的地址解析 |
| | | Map<String, String> map = geocode("广东省广州市"); |
| | | model.addAttribute("addressLon",map.get("addressLon")); |
| | | model.addAttribute("addressLat",map.get("addressLat")); |
| | | // 查询广东全区域数据 查询广东所有的代理商 |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | |
| | | |
| | | 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<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()); |
| | |
| | | }else { |
| | | // 业绩排名 performanceTable |
| | | // 查询广东全区域数据 查询广东所有的代理商 |
| | | List<TAgent> tAgentList = tAgentService.selectList(new EntityWrapper<TAgent>() |
| | | .eq("provinceCode", "440000")); |
| | | List<TAgent> tAgentList = tAgentService.selectList(null); |
| | | List<Integer> ids = tAgentList.stream().map(TAgent::getId).collect(Collectors.toList()); |
| | | if (1 == type){ |
| | | // 单量 |
| | |
| | | return map; |
| | | } |
| | | |
| | | private Map<String,String> geocode(String address){ |
| | | Map<String,String> map = new HashMap<>(2); |
| | | try { |
| | | String url = "https://restapi.amap.com/v3/geocode/geo?address=" + address + "&key=" + gaoDePoJo.getKey(); |
| | | url = url.trim().replace("#", "").replace(" ", ""); |
| | | String result = httpUtils.get(url); |
| | | log.info("地址解析结果:{}", result); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | if (jsonObject.getString("status").equals("1")) { |
| | | String geocodes = jsonObject.getString("geocodes"); |
| | | JSONArray objects = JSONObject.parseArray(geocodes); |
| | | String string = objects.getString(0); |
| | | JSONObject geocodesObject = JSONObject.parseObject(string); |
| | | log.info("地址数据:{}", geocodesObject); |
| | | String location = geocodesObject.getString("location"); |
| | | String[] split = location.split(","); |
| | | map.put("addressLon",split[0]); |
| | | map.put("addressLat",split[1]); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("解析地址失败============:{}", e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | } |