wang-hao-jie
2022-01-18 d9da603305a2b94bde78483fa8777a43ee352548
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/pc/StatisticController.java
@@ -8,7 +8,11 @@
import cn.exrick.xboot.your.entity.*;
import cn.exrick.xboot.your.service.*;
import cn.exrick.xboot.your.util.HaiKangPost;
import cn.exrick.xboot.your.vo.AlarmVo;
import cn.exrick.xboot.your.vo.PreviewURLsVo;
import cn.exrick.xboot.your.vo.TalkURLsVo;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -52,6 +56,12 @@
    @Autowired
    private IAreaSectionService iAreaSectionService;
    @Autowired
    private IEquipmentService iEquipmentService;
    @Autowired
    private IAlarmService iAlarmService;
    @RequestMapping(value = "/getIndex1", method = RequestMethod.GET)
    @ApiOperation(value = "获取首页数据")
    public Result<Object> getIndex1() {
@@ -91,10 +101,17 @@
    @ApiOperation(value = "获取车辆定位信息")
    public Result<Object> getCars() {
        List<Car> list = iCarService.list();
        String codes[] = new String[list.size()];
        List<String> list2 = new ArrayList<>();
        for(int i=0;i<list.size();i++){
            codes[i] = list.get(i).getCode();
            if(!StrUtil.isEmpty(list.get(i).getCode())){
                list2.add(list.get(i).getCode());
            }
        }
        String codes[] = new String[list2.size()];
        for(int i=0;i<list2.size();i++){
            codes[i] = list2.get(i);
        }
        String latestGps = haiKangPost.findLatestGps(codes);
        return new ResultUtil<Object>().setData(JSONUtil.parseObj(latestGps));
@@ -153,6 +170,94 @@
        return new ResultUtil<Object>().setData(map);
    }
    @RequestMapping(value = "/getOrderStatus", method = RequestMethod.GET)
    @ApiOperation(value = "获取某辆车的配送情况")
    public Result<Object> getOrderStatus(String carNo) {
        QueryWrapper<Car> wrapper = new QueryWrapper<>();
        wrapper.eq("car_no",carNo);
        Car car = iCarService.getOne(wrapper);
        if(car==null){
           return ResultUtil.error("车辆不存在,请先添加车辆信息");
        }
        QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>();
        String format = DateUtil.format(new Date(), "yyyy-MM-dd");
        wrapper2.eq("a.send_date",format);
        wrapper2.eq("a.car_id",car.getId());
        List<OrderTask> list = iOrderTaskService.list4(wrapper2);
        return new ResultUtil<Object>().setData(list);
    }
    @RequestMapping(value = "/getVideoByCarId", method = RequestMethod.GET)
    @ApiOperation(value = "获取视频信息 1:前置 4:车内")
    public Result<Object> getVideoByCarId(String carCode,int type) {
        QueryWrapper<Car> wrapper = new QueryWrapper<Car>();
        wrapper.eq("code",carCode);
        Car car = iCarService.getOne(wrapper);
        if(car==null){
            return ResultUtil.error("车辆编号错误");
        }
        QueryWrapper<Equipment> wrapper1 = new QueryWrapper<>();
        wrapper1.eq("car_id",car.getId());
        wrapper1.eq("type",type);
        Equipment one = iEquipmentService.getOne(wrapper1);
        if(one==null){
            return ResultUtil.error("设备未找到");
        }
        PreviewURLsVo previewURLsVo = new PreviewURLsVo();
      previewURLsVo.setCameraIndexCode(one.getCode());
        String s = haiKangPost.previewURLs(previewURLsVo);
        return new ResultUtil<Object>().setData(JSONUtil.parseObj(s));
    }
    @RequestMapping(value = "/getYuYinByCarId", method = RequestMethod.GET)
    @ApiOperation(value = "获取对讲信息")
    public Result<Object> getYuYinByCarId(String carCode,int type,int transmode) {
        QueryWrapper<Car> wrapper = new QueryWrapper<Car>();
        wrapper.eq("code",carCode);
        Car car = iCarService.getOne(wrapper);
        if(car==null){
            return ResultUtil.error("车辆编号错误");
        }
        QueryWrapper<Equipment> wrapper1 = new QueryWrapper<>();
        wrapper1.eq("car_id",car.getId());
        wrapper1.eq("type",type);
        Equipment one = iEquipmentService.getOne(wrapper1);
        if(one==null){
            return ResultUtil.error("设备未找到");
        }
        TalkURLsVo talkURLsVo =new TalkURLsVo();
        talkURLsVo.setCameraIndexCode(one.getCode());
        talkURLsVo.setTransmode(transmode);
        String s = haiKangPost.talkURLs(talkURLsVo);
        return new ResultUtil<Object>().setData(JSONUtil.parseObj(s));
    }
    @RequestMapping(value = "/getAlarmByCarId", method = RequestMethod.GET)
    @ApiOperation(value = "获取报警图片")
    public Result<Object> getAlarmByCarId(String alarmId) {
        QueryWrapper<Alarm> wrapper = new QueryWrapper<Alarm>();
        wrapper.eq("alarm_id",alarmId);
        Alarm alarm = iAlarmService.getOne(wrapper);
        if(alarm==null){
            return ResultUtil.error("报警id错误");
        }
        AlarmVo alarmVo = new AlarmVo();
        alarmVo.setAlarmId(alarm.getAlarmId());
        String[] s1 = alarm.getAlarmTime().split(" ");
        alarmVo.setAlarmTime(s1[0]+"T"+s1[1]+".000+08:00");
        String s = haiKangPost.findPicturesByAlarmId(alarmVo);
        return new ResultUtil<Object>().setData(JSONUtil.parseObj(s));
    }
    public double trans2(double v2){
        return (double) Math.round(v2 * 100) / 100;
    }