| | |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/rejectionOrder") |
| | | @ServiceLog(name = "司机拒绝接单", url = "/api/order/rejectionOrder") |
| | | @ApiOperation(value = "司机拒绝接单", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper rejectionOrder(Long orderId, HttpServletRequest request){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil resultUtil = orderService.rejectionOrder(uid, orderId); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/receiveOrder") |
| | | @ServiceLog(name = "司机接单操作", url = "/api/order/receiveOrder") |
| | | @ApiOperation(value = "司机接单操作", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper receiveOrder(Long orderId, HttpServletRequest request){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil resultUtil = orderService.receiveOrder(uid, orderId); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public ResponseWarpper<> queryOrderInfo(Long orderId, HttpServletRequest request){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | } |
| | | ResultUtil resultUtil = orderService.receiveOrder(uid, orderId); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.OrderRefusal; |
| | | |
| | | public interface OrderRefusalMapper extends BaseMapper<OrderRefusal> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.YouTuiDriver; |
| | | |
| | | public interface YouTuiDriverMapper extends BaseMapper<YouTuiDriver> { |
| | | } |
| | |
| | | <result column="emergencyPhone" property="emergencyPhone"/> |
| | | <result column="driverLicenseNumber" property="driverLicenseNumber"/> |
| | | <result column="driverLicense" property="driverLicense"/> |
| | | <result column="firstCertificateTime" property="firstCertificateTime"/> |
| | | <result column="idcard" property="idcard"/> |
| | | <result column="idcardFront" property="idcardFront"/> |
| | | <result column="idcardBack" property="idcardBack"/> |
| | |
| | | <result column="agentId" property="agentId"/> |
| | | <result column="branchOfficeId" property="branchOfficeId"/> |
| | | <result column="balance" property="balance"/> |
| | | <result column="backgroundBalance" property="backgroundBalance"/> |
| | | <result column="approvalStatus" property="approvalStatus"/> |
| | | <result column="approvalNotes" property="approvalNotes"/> |
| | | <result column="approvalUserId" property="approvalUserId"/> |
| | | <result column="approvalTime" property="approvalTime"/> |
| | | <result column="serverStatus" property="serverStatus"/> |
| | | <result column="integral" property="integral"/> |
| | | <result column="score" property="score"/> |
| | | <result column="status" property="status"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="isException" property="isException"/> |
| | | <result column="createTime" property="createTime"/> |
| | | </resultMap> |
| | | </mapper> |
| | |
| | | <result column="badWeatherPrice" property="badWeatherPrice" /> |
| | | <result column="overBadWeatherDistance" property="overBadWeatherDistance" /> |
| | | <result column="overBadWeatherPrice" property="overBadWeatherPrice" /> |
| | | <result column="weather" property="weather"/> |
| | | <result column="estimatedPrice" property="estimatedPrice" /> |
| | | <result column="estimatedMileage" property="estimatedMileage"/> |
| | | <result column="orderMoney" property="orderMoney" /> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.driver.modular.system.dao.OrderRefusalMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.driver.modular.system.model.OrderRefusal"> |
| | | <id column="id" property="id" /> |
| | | <result column="order_id" property="orderId" /> |
| | | <result column="driver_id" property="driverId" /> |
| | | <result column="startAddress" property="startAddress" /> |
| | | <result column="endAddress" property="endAddress" /> |
| | | <result column="code" property="code" /> |
| | | <result column="createTime" property="createTime" /> |
| | | </resultMap> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.driver.modular.system.dao.YouTuiDriverMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.driver.modular.system.model.YouTuiDriver"> |
| | | <id column="id" property="id" /> |
| | | <result column="driverId" property="driverId" /> |
| | | <result column="youTuiId" property="youTuiId" /> |
| | | <result column="integral" property="integral" /> |
| | | <result column="failureTime" property="failureTime" /> |
| | | <result column="createTime" property="createTime" /> |
| | | </resultMap> |
| | | </mapper> |
| | |
| | | @TableField("driverLicense") |
| | | private String driverLicense; |
| | | /** |
| | | * 驾驶证初次领证时间 |
| | | */ |
| | | @TableField("firstCertificateTime") |
| | | private Date firstCertificateTime; |
| | | /** |
| | | * 身份证号码 |
| | | */ |
| | | @TableField("idcard") |
| | |
| | | @TableField("balance") |
| | | private Double balance; |
| | | /** |
| | | * 后台充值余额 |
| | | */ |
| | | @TableField("backgroundBalance") |
| | | private Double backgroundBalance; |
| | | /** |
| | | * 审核状态(1=待审核,2=已同意,3=已拒绝) |
| | | */ |
| | | @TableField("approvalStatus") |
| | |
| | | @TableField("integral") |
| | | private Integer integral; |
| | | /** |
| | | * 评分 |
| | | */ |
| | | @TableField("score") |
| | | private Double score; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 启用冻结理由 |
| | | */ |
| | | @TableField("remark") |
| | | private String remark; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | |
| | | @TableField("overBadWeatherPrice") |
| | | private Double overBadWeatherPrice; |
| | | /** |
| | | * 天气 |
| | | */ |
| | | @TableField("weather") |
| | | private String weather; |
| | | /** |
| | | * 预估价 |
| | | */ |
| | | @TableField("estimatedPrice") |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 司机拒单记录 |
| | | * @author pzb |
| | | * @Date 2023/2/22 10:21 |
| | | */ |
| | | @Data |
| | | @TableName("t_order_refusal") |
| | | public class OrderRefusal { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 订单id |
| | | */ |
| | | @TableField("order_id") |
| | | private Long orderId; |
| | | /** |
| | | * 司机id |
| | | */ |
| | | @TableField("driver_id") |
| | | private Integer driverId; |
| | | /** |
| | | * 起点地址 |
| | | */ |
| | | @TableField("startAddress") |
| | | private String startAddress; |
| | | /** |
| | | * 终点地址 |
| | | */ |
| | | @TableField("endAddress") |
| | | private String endAddress; |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableField("code") |
| | | private String code; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 司机优推数据 |
| | | * @author pzb |
| | | * @Date 2023/2/22 14:01 |
| | | */ |
| | | @Data |
| | | @TableName("t_you_tui_driver") |
| | | public class YouTuiDriver { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 司机id |
| | | */ |
| | | @TableField("driverId") |
| | | private Integer driverId; |
| | | /** |
| | | * 优推id |
| | | */ |
| | | @TableField("youTuiId") |
| | | private Integer youTuiId; |
| | | /** |
| | | * 积分 |
| | | */ |
| | | @TableField("integral") |
| | | private Integer integral; |
| | | /** |
| | | * 失效时间 |
| | | */ |
| | | @TableField("failureTime") |
| | | private Date failureTime; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.OrderRefusal; |
| | | |
| | | public interface IOrderRefusalService extends IService<OrderRefusal> { |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | List<HallOrderList> queryOrderHall(Integer uid, Integer pageNum, Integer pageSize) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 司机拒单 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil rejectionOrder(Integer uid, Long orderId) throws Exception; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 司机接单操作 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil receiveOrder(Integer uid, Long orderId) throws Exception; |
| | | |
| | | |
| | | |
| | | queryOrderInfo(Long orderId) throws Exception; |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | void readSystems(Integer uid, String ids) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 添加系统消息 |
| | | * @param userId 接收用户id |
| | | * @param userType 接收用户类型 |
| | | * @param title 标题 |
| | | * @param content 消息内容 |
| | | * @throws Exception |
| | | */ |
| | | void addSystemMessage(Integer userId, Integer userType, String title, String content) ; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.YouTuiDriver; |
| | | |
| | | public interface IYouTuiDriverService extends IService<YouTuiDriver> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.OrderRefusalMapper; |
| | | import com.supersavedriving.driver.modular.system.model.OrderRefusal; |
| | | import com.supersavedriving.driver.modular.system.service.IOrderRefusalService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 司机拒单 |
| | | * @author pzb |
| | | * @Date 2023/2/22 10:28 |
| | | */ |
| | | @Service |
| | | public class OrderRefusalServiceImpl extends ServiceImpl<OrderRefusalMapper, OrderRefusal> implements IOrderRefusalService { |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.dao.OrderMapper; |
| | | import com.supersavedriving.driver.modular.system.model.*; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.util.*; |
| | | import com.supersavedriving.driver.modular.system.util.GaoDe.MapUtil; |
| | | import com.supersavedriving.driver.modular.system.util.GeodesyUtil; |
| | | import com.supersavedriving.driver.modular.system.util.PushUtil; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.util.UUIDUtil; |
| | | import com.supersavedriving.driver.modular.system.util.juhe.WeatherUtil; |
| | | import com.supersavedriving.driver.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.driver.modular.system.warpper.AddOrderWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.HallOrderList; |
| | |
| | | |
| | | @Autowired |
| | | private IAppUserService appUserService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Autowired |
| | | private ISystemMessageService systemMessageService; |
| | | |
| | | @Autowired |
| | | private IOrderRefusalService orderRefusalService; |
| | | |
| | | @Autowired |
| | | private IYouTuiDriverService youTuiDriverService; |
| | | |
| | | |
| | | |
| | |
| | | order.setEndAddress(addOrderWarpper.getEndAddress()); |
| | | order.setEndLat(addOrderWarpper.getEndLat()); |
| | | order.setEndLng(addOrderWarpper.getEndLng()); |
| | | Map<String, String> distance = MapUtil.getDistance(order.getStartLng() + "," + order.getStartLat(), order.getEndLng() + "," + order.getEndLat(), 1); |
| | | if(null == distance){ |
| | | return ResultUtil.error("获取预估距离出错"); |
| | | Double d = 0D; |
| | | if(ToolUtil.isNotEmpty(addOrderWarpper.getEndAddress())){ |
| | | Map<String, String> distance = MapUtil.getDistance(order.getStartLng() + "," + order.getStartLat(), order.getEndLng() + "," + order.getEndLat(), 1); |
| | | if(null == distance){ |
| | | return ResultUtil.error("获取预估距离出错"); |
| | | } |
| | | d = Double.valueOf(distance.get("distance")) / 1000; |
| | | order.setEstimatedMileage(d); |
| | | } |
| | | Double d = Double.valueOf(distance.get("distance")) / 1000; |
| | | order.setEstimatedMileage(d); |
| | | order = getOrderPrice(1, d, 0, order); |
| | | order = getOrderPrice(1, d, 0, order, ""); |
| | | order.setHallOrder(0); |
| | | order.setState(null == order.getDriverId() ? 101 : 102); |
| | | order.setStatus(1); |
| | |
| | | |
| | | /** |
| | | * 获取订单价格 |
| | | * @param type |
| | | * @param distance |
| | | * @param waitTime |
| | | * @param order |
| | | * @param type 计算类型(1=预估价,2=订单费) |
| | | * @param distance 行驶公里 |
| | | * @param waitTime 等待时长 |
| | | * @param order 订单数据 |
| | | * @param city 查询天气的城市 |
| | | * @return |
| | | */ |
| | | public Order getOrderPrice(Integer type, Double distance, Integer waitTime, Order order){ |
| | | public Order getOrderPrice(Integer type, Double distance, Integer waitTime, Order order, String city){ |
| | | order = getOrderInitialPrice(order); |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5)); |
| | | if(null == systemConfig){ |
| | |
| | | } |
| | | |
| | | //恶劣天气 |
| | | if(true){ |
| | | boolean badWeather = WeatherUtil.isBadWeather(city); |
| | | if(badWeather){ |
| | | order.setBadWeatherDistance(num5);//恶劣天气公里 |
| | | order.setBadWeatherPrice(num6);//恶劣天气费 |
| | | if(distance.compareTo(num7) > 0){ |
| | |
| | | */ |
| | | public void pushOrder(Order order){ |
| | | /** |
| | | * 系统根据配置进行三轮的范围查找司机。 |
| | | * 只要找到司机就直接推出去。 |
| | | * 当推出去的司机都没有接单,直接将订单放入大厅,不再去更大范围找司机。 |
| | | * 1.先找最大推单范围内的优推司机 -》 距离最近 |
| | | * 没有1 - 》 |
| | | * 2.按照后台推送配置在范围内查找合适司机 |
| | | * 合适司:积分 > 评分 > 距离 |
| | | * 3.司机没有接单直接将订单置入大厅 |
| | | */ |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 1)); |
| | | if(null != systemConfig){ |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | Integer num4 = jsonObject.getInteger("num4");//接单时间 |
| | | String startLat = order.getStartLat(); |
| | | String startLng = order.getStartLng(); |
| | | if(null == systemConfig){ |
| | | return; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | Double num3 = jsonObject.getDouble("num3");//推单最大范围 |
| | | Integer num4 = jsonObject.getInteger("num4");//接单时间 |
| | | String startLat = order.getStartLat(); |
| | | String startLng = order.getStartLng(); |
| | | |
| | | //找到中心点 |
| | | GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(startLat), Double.valueOf(startLng)); |
| | | //1 |
| | | //找到中心点 |
| | | GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(startLat), Double.valueOf(startLng)); |
| | | Double num = num3 / 1000;//范围公里 |
| | | //构造半径 |
| | | Distance distanceR = new Distance(num, Metrics.KILOMETERS); |
| | | //画圆 |
| | | Circle circle = new Circle(geoJsonPoint, distanceR); |
| | | // 构造query对象 |
| | | Query query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | List<Location> locations = mongoTemplate.find(query, Location.class); |
| | | List<Integer> driverIds = locations.stream().map(Location::getDriverId).collect(Collectors.toList()); |
| | | Integer driver = null; |
| | | if(driverIds.size() > 0){ |
| | | List<YouTuiDriver> youTuiDrivers = youTuiDriverService.selectList(new EntityWrapper<YouTuiDriver>().in("driverId", driverIds).last(" and now() < failureTime")); |
| | | Double d = null; |
| | | for (YouTuiDriver youTuiDriver : youTuiDrivers) { |
| | | String value = redisUtil.getValue("DRIVER" + youTuiDriver.getDriverId()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat()); |
| | | Double wgs84 = distance.get("WGS84"); |
| | | if(d == null || d.compareTo(wgs84) > 0){ |
| | | d = wgs84; |
| | | driver = youTuiDriver.getDriverId(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //开始范围查找 |
| | | if(null == driver){ |
| | | for (int i = 1; i < 4; i++) { |
| | | Double num = jsonObject.getDouble("num" + i) / 1000;//范围公里 |
| | | num = jsonObject.getDouble("num" + i) / 1000;//范围公里 |
| | | //构造半径 |
| | | Distance distanceR = new Distance(num, Metrics.KILOMETERS); |
| | | distanceR = new Distance(num, Metrics.KILOMETERS); |
| | | //画圆 |
| | | Circle circle = new Circle(geoJsonPoint, distanceR); |
| | | circle = new Circle(geoJsonPoint, distanceR); |
| | | // 构造query对象 |
| | | Query query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | List<Location> locations = mongoTemplate.find(query, Location.class); |
| | | query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | locations = mongoTemplate.find(query, Location.class); |
| | | |
| | | List<Integer> driverIds = locations.stream().map(Location::getDriverId).collect(Collectors.toList()); |
| | | driverIds = locations.stream().map(Location::getDriverId).collect(Collectors.toList()); |
| | | if(driverIds.size() > 0){ |
| | | List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2).eq("serverStatus", 1).eq("status", 1).in("id", driverIds)); |
| | | if(drivers.size() == 0){ |
| | | continue; |
| | | } |
| | | |
| | | for (Driver driver : drivers) { |
| | | pushUtil.pushGrabOrder(driver.getId(), 2, order.getId(), num4); |
| | | } |
| | | |
| | | //创建定时任务处理订单到大厅 |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | Order order1 = OrderServiceImpl.this.selectById(order.getId()); |
| | | if(order1.getState() == 101){ |
| | | order1.setHallOrder(1); |
| | | OrderServiceImpl.this.updateById(order1); |
| | | Integer integral = null; |
| | | Double score = null; |
| | | Double d = null; |
| | | for (Driver driver1 : drivers) { |
| | | if(integral == null || integral.compareTo(driver1.getIntegral()) < 0){//积分大 |
| | | integral = driver1.getIntegral(); |
| | | score = driver1.getScore(); |
| | | driver = driver1.getId(); |
| | | continue; |
| | | } |
| | | if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) < 0){//积分相同对比评分 |
| | | integral = driver1.getIntegral(); |
| | | score = driver1.getScore(); |
| | | driver = driver1.getId(); |
| | | continue; |
| | | } |
| | | if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) == 0){//积分相同/评分相同对比距离 |
| | | String value = redisUtil.getValue("DRIVER" + driver1.getId()); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat()); |
| | | Double wgs84 = distance.get("WGS84"); |
| | | if(d == null || d.compareTo(wgs84) > 0){ |
| | | d = wgs84; |
| | | driver = driver1.getId(); |
| | | continue; |
| | | } |
| | | } |
| | | }, num4 * 1000); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(null != driver){ |
| | | pushUtil.pushGrabOrder(driver, 2, order.getId(), num4); |
| | | //创建定时任务处理订单到大厅 |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | Order order1 = OrderServiceImpl.this.selectById(order.getId()); |
| | | if(order1.getState() == 101){ |
| | | order1.setHallOrder(1); |
| | | OrderServiceImpl.this.updateById(order1); |
| | | } |
| | | } |
| | | }, num4 * 1000); |
| | | }else{ |
| | | order.setHallOrder(1); |
| | | this.updateById(order); |
| | | } |
| | | } |
| | | |
| | |
| | | }); |
| | | return hallOrderLists; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 司机拒单 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil rejectionOrder(Integer uid, Long orderId) throws Exception { |
| | | Order order = this.selectById(orderId); |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1)); |
| | | if(null == driverWork){ |
| | | return ResultUtil.error("请先上班"); |
| | | } |
| | | OrderRefusal orderRefusal = new OrderRefusal(); |
| | | orderRefusal.setCode(order.getCode()); |
| | | orderRefusal.setCreateTime(new Date()); |
| | | orderRefusal.setDriverId(uid); |
| | | orderRefusal.setEndAddress(order.getEndAddress()); |
| | | orderRefusal.setStartAddress(order.getStartAddress()); |
| | | orderRefusal.setOrderId(orderId); |
| | | orderRefusalService.insert(orderRefusal); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | /** |
| | | * 司机接单操作 |
| | | * @param uid |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil receiveOrder(Integer uid, Long orderId) throws Exception { |
| | | try { |
| | | Driver driver = driverService.selectById(uid); |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1)); |
| | | if(null == driverWork){ |
| | | return ResultUtil.error("请先上班"); |
| | | } |
| | | boolean lock = redisUtil.lock(5); |
| | | if(!lock){ |
| | | int num1 = 1; |
| | | while (num1 <= 10){ |
| | | Thread.sleep(3000);//等待3秒 |
| | | lock = redisUtil.lock(5); |
| | | if(lock){ |
| | | break; |
| | | }else{ |
| | | num1++; |
| | | } |
| | | } |
| | | } |
| | | Order order = this.selectById(orderId); |
| | | if(order.getState() != 301){ |
| | | redisUtil.unlock(); |
| | | return ResultUtil.error("订单已被取消"); |
| | | } |
| | | if(order.getState() != 101){ |
| | | redisUtil.unlock(); |
| | | return ResultUtil.error("手速慢了哦"); |
| | | } |
| | | order.setDriverId(uid); |
| | | order.setAgentId(driver.getAgentId()); |
| | | order.setBranchOfficeId(driver.getBranchOfficeId()); |
| | | order.setState(102); |
| | | this.updateById(order); |
| | | redisUtil.unlock(); |
| | | |
| | | driver.setServerStatus(2); |
| | | driverService.updateById(driver); |
| | | |
| | | //推动订单数据 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //发送系统消息 |
| | | systemMessageService.addSystemMessage(uid, 2, "接单成功", "您已成功接到用户订单,请尽快联系客户!"); |
| | | pushUtil.pushOrderStatus(order.getDriverId(), 2, order.getId(), order.getState()); |
| | | if(null != order.getUserId()){ |
| | | systemMessageService.addSystemMessage(order.getUserId(), 1, "接单成功", driver.getName() + "师傅已成功接到您的订单,请保持电话畅通!"); |
| | | pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getState()); |
| | | } |
| | | } |
| | | }).start(); |
| | | }catch (Exception e){ |
| | | redisUtil.unlock(); |
| | | e.printStackTrace(); |
| | | throw e; |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | } |
| | |
| | | import com.supersavedriving.driver.modular.system.warpper.SystemMessageWarpper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | } |
| | | this.updateBatchById(systemMessages); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void addSystemMessage(Integer userId, Integer userType, String title, String content) { |
| | | SystemMessage systemMessage = new SystemMessage(); |
| | | systemMessage.setIsRead(0); |
| | | systemMessage.setContent(content); |
| | | systemMessage.setCreateTime(new Date()); |
| | | systemMessage.setStatus(1); |
| | | systemMessage.setTitle(title); |
| | | systemMessage.setUserId(userId); |
| | | systemMessage.setUserType(userType); |
| | | this.insert(systemMessage); |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.YouTuiDriverMapper; |
| | | import com.supersavedriving.driver.modular.system.model.YouTuiDriver; |
| | | import com.supersavedriving.driver.modular.system.service.IYouTuiDriverService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 用户优推数据 |
| | | * @author pzb |
| | | * @Date 2023/2/22 14:06 |
| | | */ |
| | | @Service |
| | | public class YouTuiDriverServiceImpl extends ServiceImpl<YouTuiDriverMapper, YouTuiDriver> implements IYouTuiDriverService { |
| | | } |
| | |
| | | package com.supersavedriving.driver.modular.system.util; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.springframework.util.StringUtils; |
| | | import redis.clients.jedis.Jedis; |
| | | import redis.clients.jedis.JedisPool; |
| | | import redis.clients.jedis.Pipeline; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | |
| | | /** |
| | |
| | | public class RedisUtil { |
| | | |
| | | @Autowired |
| | | private RestTemplate internalRestTemplate; |
| | | private JedisPool jedisPool; |
| | | |
| | | private Timer timer; |
| | | |
| | | |
| | | /** |
| | |
| | | * @param value |
| | | */ |
| | | public void setStrValue(String key, String value){ |
| | | if(ToolUtil.isNotEmpty(key)){ |
| | | //发送验证码短信 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("key", key); |
| | | params.add("value", value); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/redis/setValue_", requestEntity, String.class); |
| | | JSONObject jsonObject = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject.getIntValue("code") != 200){ |
| | | System.err.println("调用redis出错了"); |
| | | } |
| | | if(ToolUtil.isNotEmpty(key) && ToolUtil.isNotEmpty(value)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | String set = resource.set(key, value); |
| | | closeJedis(resource); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | * @param time 秒 |
| | | */ |
| | | public void setStrValue(String key, String value, int time){ |
| | | if(ToolUtil.isNotEmpty(key)){ |
| | | //发送验证码短信 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); |
| | | params.add("key", key); |
| | | params.add("value", value); |
| | | params.add("time", String.valueOf(time)); |
| | | HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/redis/setValue", requestEntity, String.class); |
| | | JSONObject jsonObject = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject.getIntValue("code") != 200){ |
| | | System.err.println("调用redis出错了"); |
| | | } |
| | | if(ToolUtil.isNotEmpty(key) && ToolUtil.isNotEmpty(value)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | String setex = resource.setex(key, time, value); |
| | | closeJedis(resource); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public String getValue(String key){ |
| | | if(ToolUtil.isNotEmpty(key)){ |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("key", key); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/redis/getValue",requestEntity , String.class); |
| | | JSONObject jsonObject = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject.getIntValue("code") != 200){ |
| | | System.err.println("调用redis出错了"); |
| | | Jedis resource = jedisPool.getResource(); |
| | | String data = resource.get(key); |
| | | closeJedis(resource); |
| | | return data; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量获取 |
| | | * @param kes |
| | | * @return |
| | | */ |
| | | public List<Object> getValues(List<String> kes){ |
| | | if(null != kes){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | Pipeline pipelined = resource.pipelined(); |
| | | for(String key : kes){ |
| | | pipelined.get(key); |
| | | } |
| | | return jsonObject.getString("data"); |
| | | List<Object> list = pipelined.syncAndReturnAll(); |
| | | |
| | | closeJedis(resource); |
| | | pipelined.clear(); |
| | | try { |
| | | pipelined.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | List<Object> data = new ArrayList<>(); |
| | | for(Object o : list){ |
| | | if(null != o){ |
| | | data.add(o); |
| | | } |
| | | } |
| | | return data; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | * 删除key |
| | | * @param key |
| | | */ |
| | | public String remove(String key){ |
| | | public void remove(String key){ |
| | | if(ToolUtil.isNotEmpty(key)){ |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("key", key); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/redis/remove",requestEntity , String.class); |
| | | JSONObject jsonObject = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject.getIntValue("code") != 200){ |
| | | System.err.println("调用redis出错了"); |
| | | } |
| | | return jsonObject.getString("data"); |
| | | Jedis resource = jedisPool.getResource(); |
| | | Long del = resource.del(key); |
| | | closeJedis(resource); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 向集合key添加数据 |
| | | * @param key |
| | | * @param members |
| | | */ |
| | | public void addSetValue(String key, String...members){ |
| | | if(ToolUtil.isNotEmpty(key) && ToolUtil.isNotEmpty(members)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | Long sadd = resource.sadd(key, members); |
| | | resource.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 返回Set集合数据 |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public Set<String> getSetAllValue(String key){ |
| | | Set<String> smembers = new HashSet<>(); |
| | | if(ToolUtil.isNotEmpty(key)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | smembers = resource.smembers(key); |
| | | resource.close(); |
| | | } |
| | | return smembers; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除Set集合中的值 |
| | | * @param key |
| | | * @param members |
| | | */ |
| | | public void delSetValue(String key, String...members){ |
| | | if(ToolUtil.isNotEmpty(key) && ToolUtil.isNotEmpty(members)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | Long sadd = resource.srem(key, members); |
| | | resource.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除资源 |
| | | * @param jedis |
| | | */ |
| | | public void closeJedis(Jedis jedis){ |
| | | if(null != jedis){ |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * redis加锁 |
| | | * @param key |
| | | * @param value |
| | | * @param time |
| | | * @return |
| | | */ |
| | | public boolean lock(String key, String value, int time){ |
| | | if(!StringUtils.isEmpty(key)){ |
| | | key += "_lock"; |
| | | Jedis resource = jedisPool.getResource(); |
| | | String set = resource.set(key, value, "nx", "ex", time); |
| | | if("OK".equals(set)){ |
| | | String finalKey = key; |
| | | timer = new Timer(); |
| | | timer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | System.err.println("定时任务启动"); |
| | | Jedis resource = jedisPool.getResource(); |
| | | resource.setex(finalKey, time, value); |
| | | resource.close(); |
| | | } |
| | | }, 1000, 500); |
| | | } |
| | | resource.close(); |
| | | return "OK".equals(set) ? true : false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 获取redis锁 |
| | | * @param time |
| | | * @return |
| | | */ |
| | | public boolean lock(int time){ |
| | | String uuid = UUID.randomUUID().toString(); |
| | | return lock("redis", uuid, time); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * redis释放锁 |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public boolean unlock(String key){ |
| | | if(!StringUtils.isEmpty(key)){ |
| | | key += "_lock"; |
| | | Jedis resource = jedisPool.getResource(); |
| | | timer.cancel();//取消定时任务 |
| | | Long del = resource.del(key); |
| | | resource.close(); |
| | | return del != 0 ? true : false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 删除锁 |
| | | * @return |
| | | */ |
| | | public boolean unlock(){ |
| | | return unlock("redis"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.util.juhe; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 天气实况 |
| | | * @author pzb |
| | | * @Date 2023/2/20 11:38 |
| | | */ |
| | | @Data |
| | | public class Realtime { |
| | | /** |
| | | * 天气情况,如:晴、多云 |
| | | */ |
| | | private String info; |
| | | /** |
| | | * 天气标识id,可参考小接口2 |
| | | */ |
| | | private String wid; |
| | | /** |
| | | * 温度,可能为空 |
| | | */ |
| | | private String temperature; |
| | | /** |
| | | * 湿度,可能为空 |
| | | */ |
| | | private String humidity; |
| | | /** |
| | | * 风向,可能为空 |
| | | */ |
| | | private String direct; |
| | | /** |
| | | * 风力,可能为空 |
| | | */ |
| | | private String power; |
| | | /** |
| | | * 空气质量指数,可能为空 |
| | | */ |
| | | private String aqi; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.util.juhe; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 天气返回结果 |
| | | */ |
| | | @Data |
| | | public class WeatherRes { |
| | | /** |
| | | * 返回码,0为查询成功 |
| | | */ |
| | | private Integer error_code; |
| | | /** |
| | | * 返回说明 |
| | | */ |
| | | private String reason; |
| | | /** |
| | | * 返回结果集 |
| | | */ |
| | | private result; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.util.juhe; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.util.httpClinet.HttpClientUtil; |
| | | import com.supersavedriving.driver.modular.system.util.httpClinet.HttpResult; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | |
| | | /** |
| | | * 天气工具类 |
| | | * @author pzb |
| | | * @Date 2023/2/18 16:54 |
| | | */ |
| | | public class WeatherUtil { |
| | | |
| | | static Logger logger = LoggerFactory.getLogger("ServiceLog"); |
| | | |
| | | private final static String weather_type = "[{\"wid\":\"00\",\"weather\":\"晴\"},{\"wid\":\"01\",\"weather\":\"多云\"},{\"wid\":\"02\",\"weather\":\"阴\"},{\"wid\":\"03\",\"weather\":\"阵雨\"},{\"wid\":\"04\",\"weather\":\"雷阵雨\"},{\"wid\":\"05\",\"weather\":\"雷阵雨伴有冰雹\"},{\"wid\":\"06\",\"weather\":\"雨夹雪\"},{\"wid\":\"07\",\"weather\":\"小雨\"},{\"wid\":\"08\",\"weather\":\"中雨\"},{\"wid\":\"09\",\"weather\":\"大雨\"},{\"wid\":\"10\",\"weather\":\"暴雨\"},{\"wid\":\"11\",\"weather\":\"大暴雨\"},{\"wid\":\"12\",\"weather\":\"特大暴雨\"},{\"wid\":\"13\",\"weather\":\"阵雪\"},{\"wid\":\"14\",\"weather\":\"小雪\"},{\"wid\":\"15\",\"weather\":\"中雪\"},{\"wid\":\"16\",\"weather\":\"大雪\"},{\"wid\":\"17\",\"weather\":\"暴雪\"},{\"wid\":\"18\",\"weather\":\"雾\"},{\"wid\":\"19\",\"weather\":\"冻雨\"},{\"wid\":\"20\",\"weather\":\"沙尘暴\"},{\"wid\":\"21\",\"weather\":\"小到中雨\"},{\"wid\":\"22\",\"weather\":\"中到大雨\"},{\"wid\":\"23\",\"weather\":\"大到暴雨\"},{\"wid\":\"24\",\"weather\":\"暴雨到大暴雨\"},{\"wid\":\"25\",\"weather\":\"大暴雨到特大暴雨\"},{\"wid\":\"26\",\"weather\":\"小到中雪\"},{\"wid\":\"27\",\"weather\":\"中到大雪\"},{\"wid\":\"28\",\"weather\":\"大到暴雪\"},{\"wid\":\"29\",\"weather\":\"浮尘\"},{\"wid\":\"30\",\"weather\":\"扬沙\"},{\"wid\":\"31\",\"weather\":\"强沙尘暴\"},{\"wid\":\"53\",\"weather\":\"霾\"}]"; |
| | | |
| | | private final static String bad_weather = "[{\"wid\":\"03\",\"weather\":\"阵雨\"},{\"wid\":\"04\",\"weather\":\"雷阵雨\"},{\"wid\":\"05\",\"weather\":\"雷阵雨伴有冰雹\"},{\"wid\":\"06\",\"weather\":\"雨夹雪\"},{\"wid\":\"07\",\"weather\":\"小雨\"},{\"wid\":\"08\",\"weather\":\"中雨\"},{\"wid\":\"09\",\"weather\":\"大雨\"},{\"wid\":\"10\",\"weather\":\"暴雨\"},{\"wid\":\"11\",\"weather\":\"大暴雨\"},{\"wid\":\"12\",\"weather\":\"特大暴雨\"},{\"wid\":\"13\",\"weather\":\"阵雪\"},{\"wid\":\"14\",\"weather\":\"小雪\"},{\"wid\":\"15\",\"weather\":\"中雪\"},{\"wid\":\"16\",\"weather\":\"大雪\"},{\"wid\":\"17\",\"weather\":\"暴雪\"},{\"wid\":\"19\",\"weather\":\"冻雨\"},{\"wid\":\"20\",\"weather\":\"沙尘暴\"},{\"wid\":\"21\",\"weather\":\"小到中雨\"},{\"wid\":\"22\",\"weather\":\"中到大雨\"},{\"wid\":\"23\",\"weather\":\"大到暴雨\"},{\"wid\":\"24\",\"weather\":\"暴雨到大暴雨\"},{\"wid\":\"25\",\"weather\":\"大暴雨到特大暴雨\"},{\"wid\":\"26\",\"weather\":\"小到中雪\"},{\"wid\":\"27\",\"weather\":\"中到大雪\"},{\"wid\":\"28\",\"weather\":\"大到暴雪\"},{\"wid\":\"30\",\"weather\":\"扬沙\"},{\"wid\":\"31\",\"weather\":\"强沙尘暴\"},{\"wid\":\"53\",\"weather\":\"霾\"}]"; |
| | | |
| | | private final static String key = "aaebb3e5c18fd371257a2ab6b5670efe"; |
| | | |
| | | private static HttpClientUtil httpClientUtil = new HttpClientUtil(); |
| | | |
| | | |
| | | /** |
| | | * 获取天气实况数据 |
| | | * @param city 要查询的城市名称/id,城市名称如:温州、上海、北京,需要utf8 urlencode |
| | | * @return |
| | | */ |
| | | public static Realtime queryNowWeather(String city){ |
| | | if(ToolUtil.isEmpty(city)){ |
| | | return null; |
| | | } |
| | | String url = "http://apis.juhe.cn/simpleWeather/query?city=" + city + "&key=" + key; |
| | | HttpResult httpResult = null; |
| | | try { |
| | | httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(httpResult.getCode() != 200){ |
| | | logger.debug("查询天气失败:" + httpResult.getData()); |
| | | return null; |
| | | } |
| | | String data = httpResult.getData(); |
| | | JSONObject jsonObject = JSON.parseObject(data); |
| | | Integer error_code = jsonObject.getInteger("error_code"); |
| | | if(0 != error_code){ |
| | | logger.debug("查询天气失败:" + jsonObject.getString("reason")); |
| | | return null; |
| | | } |
| | | Realtime realtime = jsonObject.getObject("realtime", Realtime.class); |
| | | return realtime; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询是否是恶劣天气 |
| | | * @param city |
| | | * @return |
| | | */ |
| | | public static boolean isBadWeather(String city){ |
| | | if(null == city){ |
| | | return false; |
| | | } |
| | | Realtime realtime = queryNowWeather(city); |
| | | if(null == realtime){ |
| | | return false; |
| | | } |
| | | String wid = realtime.getWid(); |
| | | JSONArray badWeather = JSON.parseArray(bad_weather); |
| | | for (int i = 0; i < badWeather.size(); i++) { |
| | | JSONObject jsonObject = badWeather.getJSONObject(i); |
| | | String wid1 = jsonObject.getString("wid"); |
| | | if(wid.equals(wid1)){ |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | |
| | | private String startLng; |
| | | @ApiModelProperty(value = "起点纬度", required = true, dataType = "string") |
| | | private String startLat; |
| | | @ApiModelProperty(value = "终点地址", required = true, dataType = "string") |
| | | @ApiModelProperty(value = "终点地址", required = false, dataType = "string") |
| | | private String endAddress; |
| | | @ApiModelProperty(value = "终点经度", required = true, dataType = "string") |
| | | @ApiModelProperty(value = "终点经度", required = false, dataType = "string") |
| | | private String endLng; |
| | | @ApiModelProperty(value = "终点纬度", required = true, dataType = "string") |
| | | @ApiModelProperty(value = "终点纬度", required = false, dataType = "string") |
| | | private String endLat; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.warpper; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel |
| | | public class OrderInfoWarpper { |
| | | @ApiModelProperty("订单id") |
| | | private Long id; |
| | | @ApiModelProperty("用户头像") |
| | | private String avatar; |
| | | @ApiModelProperty("用户名称") |
| | | private String userName; |
| | | @ApiModelProperty("用户电话") |
| | | private String userPhone; |
| | | @ApiModelProperty("下单次数") |
| | | private Integer orderTimes; |
| | | @ApiModelProperty("取消次数") |
| | | private Integer cancelTimes; |
| | | @ApiModelProperty("与用户距离") |
| | | private Double currentDistance; |
| | | @ApiModelProperty("订单来源(1=用户创建,2=司机创建)") |
| | | private Integer source; |
| | | @ApiModelProperty("下单时间") |
| | | private Long createTime; |
| | | @ApiModelProperty("起点") |
| | | private String startAddress; |
| | | @ApiModelProperty("起点纬度") |
| | | private String startLat; |
| | | @ApiModelProperty("起点经度") |
| | | private String startLng; |
| | | @ApiModelProperty("终点") |
| | | private String endAddress; |
| | | @ApiModelProperty("终点纬度") |
| | | private String endLat; |
| | | @ApiModelProperty("终点经度") |
| | | private String endLng; |
| | | @ApiModelProperty("预估费") |
| | | private Double estimatedPrice; |
| | | @ApiModelProperty("预估里程") |
| | | private Double estimatedMileage; |
| | | @ApiModelProperty("起步价") |
| | | private Double startPrice; |
| | | @ApiModelProperty("订单状态(101=待接单,102=已接单,103=前往预约点,104=到达预约点,105=开始服务,106=到达目的地,107=待评价,108=已完成,201=转单中,301=已取消)") |
| | | private Integer state; |
| | | } |