| | |
| | | import com.supersavedriving.driver.core.shiro.ShiroUser; |
| | | import com.supersavedriving.driver.core.util.JwtTokenUtil; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.dao.DriverMapper; |
| | | import com.supersavedriving.driver.modular.system.model.*; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.dao.DriverMapper; |
| | | import com.supersavedriving.driver.modular.system.util.*; |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.model.*; |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.util.TrhRequest; |
| | | import com.supersavedriving.driver.modular.system.util.*; |
| | | import com.supersavedriving.driver.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.driver.modular.system.util.rongyun.RongYunUtil; |
| | | import com.supersavedriving.driver.modular.system.util.weChat.WeChatUtil; |
| | |
| | | import java.net.InetAddress; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 司机 |
| | |
| | | driver.setApprovalUserId(null); |
| | | driver.setStatus(1); |
| | | driver.setSource(driverRegisterWarpper.getSource()); |
| | | driver.setName(driverRegisterWarpper.getName()); |
| | | driver.setIdcard(driverRegisterWarpper.getIdcard()); |
| | | driver.setCarAge(driverRegisterWarpper.getCarAge()); |
| | | return driver; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | public ResultUtil<List<String>> queryDriverPosition(Integer uid) throws Exception { |
| | | public ResultUtil< HashMap<String, Object> > queryDriverPosition(Integer uid) throws Exception { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1)); |
| | | if(null == driverWork){ |
| | | return ResultUtil.error("请先上班"); |
| | |
| | | // 构造query对象 |
| | | Query query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | List<Location> locations = mongoTemplate.find(query, Location.class); |
| | | List<Integer> collect = locations.stream().map(Location::getDriverId).collect(Collectors.toList()); |
| | | List<Driver> drivers = this.selectBatchIds(collect); |
| | | for (Driver driver : drivers) { |
| | | String value1 = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | if(ToolUtil.isEmpty(value1)){ |
| | | continue; |
| | | locations.forEach(s -> { |
| | | int i=0; |
| | | Driver driver = this.baseMapper.selectById(s.getDriverId()); |
| | | i = driver.getServerStatus(); |
| | | if(driver.getServerStatus()==2){ |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("driverId", s.getDriverId()).eq("state", 102)); |
| | | if(orders.size()>0){ |
| | | i = 3; |
| | | } |
| | | } |
| | | if(driver.getId().compareTo(uid) == 0){ |
| | | continue; |
| | | String value1 = redisUtil.getValue("DRIVER" + s.getDriverId()); |
| | | if(s.getDriverId().compareTo(uid) != 0 && ToolUtil.isNotEmpty(value1)){ |
| | | list.add(s.getLocation().getX() + "," + s.getLocation().getY()+","+i); |
| | | } |
| | | list.add(value1 + "," + driver.getServerStatus()); |
| | | } |
| | | }); |
| | | } |
| | | return ResultUtil.success(list); |
| | | |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("hallOrder",1).eq("state",101)); |
| | | |
| | | map.put("driver",list); |
| | | ArrayList<String> blue = new ArrayList<>(); |
| | | orders.forEach(e-> blue.add(e.getStartLng()+","+e.getStartLat())); |
| | | |
| | | map.put("orderList",blue); |
| | | List<Order> ordersOne = orderService.selectList(new EntityWrapper<Order>().eq("state",301)); |
| | | |
| | | ArrayList<String> red = new ArrayList<>(); |
| | | ordersOne.forEach(e-> red.add(e.getStartLng()+","+e.getStartLat())); |
| | | |
| | | map.put("cancelOrder",red); |
| | | return ResultUtil.success(map); |
| | | } |
| | | |
| | | |
| | |
| | | this.updateById(driver); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil<HashMap<String, Object>> queryDriverOrderNum(String time,Integer uid) { |
| | | String sTime = null; |
| | | String eTime =null; |
| | | EntityWrapper<Order> wrapper = new EntityWrapper<>(); |
| | | EntityWrapper<AppUser> wrapperOne = new EntityWrapper<>(); |
| | | if(ToolUtil.isNotEmpty(time)){ |
| | | sTime = time.split(" - ")[0]+" 00:00:00"; |
| | | eTime = time.split(" - ")[1]+" 23:59:59"; |
| | | wrapper.between("orderTakingTime",sTime,eTime); |
| | | wrapperOne.between("createTime",sTime,eTime); |
| | | } |
| | | ArrayList<Integer> objects = new ArrayList<>(); |
| | | objects.add(101); |
| | | objects.add(201); |
| | | objects.add(301); |
| | | objects.add(401); |
| | | wrapper.eq("driverId",uid); |
| | | wrapper.notIn("state",objects); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | int orderNum = orderService.selectCount(wrapper); |
| | | map.put("orderNum",orderNum); |
| | | // 有效时长 |
| | | int okTime = this.baseMapper.getTime(sTime,eTime,uid); |
| | | map.put("okTime",okTime); |
| | | wrapperOne.eq("inviterType",2); |
| | | wrapperOne.eq("inviterId",uid); |
| | | int userNum = appUserService.selectCount(wrapperOne); |
| | | |
| | | |
| | | map.put("userNum",userNum); |
| | | |
| | | |
| | | return ResultUtil.success(map); |
| | | } |
| | | } |