| | |
| | | import cn.exrick.xboot.core.common.utils.ResultUtil; |
| | | import cn.exrick.xboot.core.common.vo.PageVo; |
| | | import cn.exrick.xboot.core.common.vo.Result; |
| | | import cn.exrick.xboot.your.entity.Car; |
| | | import cn.exrick.xboot.your.entity.EventLog; |
| | | import cn.exrick.xboot.your.entity.OrderTask; |
| | | import cn.exrick.xboot.your.service.ICarService; |
| | | import cn.exrick.xboot.your.service.IEventLogService; |
| | | import cn.exrick.xboot.your.service.IOrderTaskService; |
| | | import cn.exrick.xboot.your.entity.*; |
| | | import cn.exrick.xboot.your.service.*; |
| | | import cn.exrick.xboot.your.util.HaiKangPost; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | |
| | | |
| | | @Autowired |
| | | private HaiKangPost haiKangPost; |
| | | |
| | | @Autowired |
| | | private IAreaService iAreaService; |
| | | |
| | | @Autowired |
| | | private IAreaSectionService iAreaSectionService; |
| | | |
| | | @RequestMapping(value = "/getIndex1", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取首页数据") |
| | |
| | | String latestGps = haiKangPost.findLatestGps(codes); |
| | | return new ResultUtil<Object>().setData(JSONUtil.parseObj(latestGps)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getAnalysis", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取配送分析") |
| | | public Result<Object> getAnalysis() { |
| | | List<Area> list = iAreaService.list2(); |
| | | for(Area area:list){ |
| | | double sum = 0; |
| | | int flag = 0; |
| | | for(AreaSection areaSection: area.getChildren()){ |
| | | sum+=areaSection.getStability(); |
| | | flag++; |
| | | } |
| | | if(flag>0){ |
| | | double v = sum / flag; |
| | | area.setVariance(trans2(v)); |
| | | } |
| | | } |
| | | return new ResultUtil<Object>().setData(list); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getAnalysisDetail", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取配送分析详情") |
| | | public Result<Object> getAnalysisDetail(String areaName,String selectName) { |
| | | QueryWrapper<Area> wrapper = new QueryWrapper<Area>(); |
| | | wrapper.eq("name",areaName); |
| | | Area one = iAreaService.getOne(wrapper); |
| | | |
| | | QueryWrapper<AreaSection> wrapper2 = new QueryWrapper<AreaSection>(); |
| | | wrapper2.eq("area_id",one.getId()); |
| | | wrapper2.eq("name",selectName); |
| | | AreaSection one1 = iAreaSectionService.getOne(wrapper2); |
| | | |
| | | List<OrderTask> list = iOrderTaskService.groupByTime(one.getId(),one1.getId()); |
| | | |
| | | List<String> list1 = new ArrayList<>(); |
| | | List<Integer> list2 = new ArrayList<>(); |
| | | List<Integer> list3 = new ArrayList<>(); |
| | | List<Integer> list4 = new ArrayList<>(); |
| | | |
| | | for(OrderTask obj:list){ |
| | | list1.add(obj.getCustomerName()); |
| | | list2.add(Integer.valueOf(obj.getTime()/60000)); |
| | | list3.add(Integer.valueOf(obj.getNum()/60000)); |
| | | list4.add(Integer.valueOf(obj.getLevel()/60000)); |
| | | } |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("name",list1); |
| | | map.put("avg",list2); |
| | | map.put("min",list3); |
| | | map.put("max",list4); |
| | | |
| | | return new ResultUtil<Object>().setData(map); |
| | | } |
| | | |
| | | public double trans2(double v2){ |
| | | return (double) Math.round(v2 * 100) / 100; |
| | | } |
| | | } |