| | |
| | | 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.Area; |
| | | 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.core.entity.User; |
| | | import cn.exrick.xboot.core.service.UserService; |
| | | 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.bean.BeanUtil; |
| | | 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; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private IAreaSectionService iAreaSectionService; |
| | | |
| | | @Autowired |
| | | private IEquipmentService iEquipmentService; |
| | | |
| | | @Autowired |
| | | private IAlarmService iAlarmService; |
| | | |
| | | @Autowired |
| | | private ICustomerService iCustomerService; |
| | | |
| | | @Autowired |
| | | private IOrderTask2Service iOrderTask2Service; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private IDuoZhengService iDuoZhengService; |
| | | |
| | | @RequestMapping(value = "/getIndex1", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取首页数据") |
| | | public Result<Object> getIndex1() { |
| | |
| | | for (String str : scan) { |
| | | map.put(str.substring(12),redisTemplateHelper.get(str)); |
| | | } |
| | | QueryWrapper<Customer> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("kstatus",0); |
| | | map.put("taKan",iCustomerService.count(wrapper)); |
| | | return new ResultUtil<Object>().setData(map); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getTaKanList", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取踏勘商户列表") |
| | | public Result<Object> getTaKanList() { |
| | | QueryWrapper<Customer> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("kstatus",0); |
| | | return new ResultUtil<Object>().setData(iCustomerService.list(wrapper)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getTodayTask", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取今日配送任务") |
| | | public Result<Object> getTodayTask() { |
| | | QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); |
| | | String format = DateUtil.format(new Date(), "yyyy-MM-dd"); |
| | | wrapper2.eq("a.send_date",format); |
| | | // wrapper2.orderByAsc("a.seq"); |
| | | public Result<Object> getTodayTask(String sendTime) { |
| | | //QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); |
| | | String format = ""; |
| | | if(StrUtil.isNotEmpty(sendTime)){ |
| | | format = sendTime; |
| | | }else{ |
| | | format = DateUtil.format(new Date(), "yyyy-MM-dd"); |
| | | } |
| | | //wrapper2.eq("a.send_date",format); |
| | | //wrapper2.orderByAsc("a.seq"); |
| | | List<OrderTask> list = iOrderTaskService.list3(format); |
| | | return new ResultUtil<Object>().setData(list); |
| | | } |
| | |
| | | @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)); |
| | |
| | | @RequestMapping(value = "/getAnalysis", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取配送分析") |
| | | public Result<Object> getAnalysis() { |
| | | List<Area> list = iAreaService.list(); |
| | | 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); |
| | | } |
| | | |
| | | @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; |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/getYiHuDuoZheng", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取配送分析详情") |
| | | public Result<Object> getYiHuDuoZheng() { |
| | | |
| | | // List<Customer> list = iCustomerService.getYiHuDuoZheng(); |
| | | // Map<String,Object> map = new HashMap<>(); |
| | | // map.put("name","一户多证"); |
| | | // List<Object> childrens = new ArrayList<>(); |
| | | // for(Customer c:list){ |
| | | // Map<String,Object> map2 = new HashMap<>(); |
| | | // map2.put("name",c.getName()); |
| | | // |
| | | // List<Object> names = new ArrayList<>(); |
| | | // Map<String,Object> map3 = new HashMap<>(); |
| | | // map3.put("name",c.getCode()); |
| | | // names.add(map3); |
| | | // |
| | | // map2.put("children",names); |
| | | // |
| | | // childrens.add(map2); |
| | | // } |
| | | // map.put("children",childrens); |
| | | |
| | | |
| | | List<String> list = iDuoZhengService.getNames(); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("name","一户多证"); |
| | | List<Object> childrens = new ArrayList<>(); |
| | | for(String c:list){ |
| | | Map<String,Object> map2 = new HashMap<>(); |
| | | map2.put("name",c); |
| | | |
| | | List<Object> names = new ArrayList<>(); |
| | | |
| | | QueryWrapper<DuoZheng> wp = new QueryWrapper<>(); |
| | | wp.eq("name",c); |
| | | List<DuoZheng> list1 = iDuoZhengService.list(wp); |
| | | for(DuoZheng dz:list1){ |
| | | Map<String,Object> map3 = new HashMap<>(); |
| | | map3.put("name",dz.getCustomerName()); |
| | | names.add(map3); |
| | | } |
| | | |
| | | map2.put("children",names); |
| | | |
| | | childrens.add(map2); |
| | | } |
| | | map.put("children",childrens); |
| | | return new ResultUtil<Object>().setData(map); |
| | | } |
| | | |
| | | @RequestMapping(value = "/test", method = RequestMethod.GET) |
| | | @ApiOperation(value = "测试接口,没用") |
| | | public String test(){ |
| | | List<OrderTask> list = iOrderTaskService.list(); |
| | | |
| | | List<OrderTask2> list2 = new ArrayList<>(); |
| | | for(OrderTask orderTask:list){ |
| | | OrderTask2 orderTask2 = new OrderTask2(); |
| | | BeanUtil.copyProperties(orderTask,orderTask2); |
| | | |
| | | if(StrUtil.isNotEmpty(orderTask.getUserId())){ |
| | | orderTask2.setUserName(getUser(orderTask.getUserId())); |
| | | } |
| | | if(StrUtil.isNotEmpty(orderTask.getCustomerId())){ |
| | | orderTask2.setCustomerName(getCustomer(orderTask.getCustomerId())); |
| | | } |
| | | list2.add(orderTask2); |
| | | } |
| | | iOrderTask2Service.saveBatch(list2); |
| | | return list.size()+"ok"; |
| | | } |
| | | |
| | | private String getUser(String id){ |
| | | User user = userService.get(id); |
| | | if(user!=null){ |
| | | return user.getNickname(); |
| | | }else{ |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private String getCustomer(String id){ |
| | | Customer customer = iCustomerService.getById(id); |
| | | if(customer!=null){ |
| | | return customer.getName(); |
| | | }else{ |
| | | return null; |
| | | } |
| | | } |
| | | } |