| | |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | |
| | | private RestTemplate internalRestTemplate; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Autowired |
| | | private IOrderTaxiService orderTaxiService; |
| | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("id", userId); |
| | | data.put("type", 1); |
| | | String str = redisUtil.getValue(orderId + "_" + orderType); |
| | | String str = (String) redisTemplate.opsForValue().get(orderId + "_" + orderType); |
| | | if(ToolUtil.isEmpty(str)){ |
| | | redisUtil.setStrValue(orderId + "_" + orderType, data.toJSONString()); |
| | | redisTemplate.opsForValue().set(orderId + "_" + orderType, data.toJSONString()); |
| | | createTask(orderId, orderType); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | //计算预计距离和剩余时间 |
| | | String value = redisUtil.getValue("DRIVER" + String.valueOf(driverId)); |
| | | String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(driverId)); |
| | | if(null == value || "".equals(value)){ |
| | | return; |
| | | } |
| | |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | String value1 = redisUtil.getValue(orderId + "_" + orderType); |
| | | String value1 = (String) redisTemplate.opsForValue().get(orderId + "_" + orderType); |
| | | if(ToolUtil.isEmpty(value1)){ |
| | | this.removeTask(orderId, orderType); |
| | | return; |
| | |
| | | if (null != timer){ |
| | | timer.cancel(); |
| | | taskMap.remove(orderId + "_" + orderType); |
| | | redisUtil.remove(orderId + "_" + orderType); |
| | | redisTemplate.delete(orderId + "_" + orderType); |
| | | } |
| | | } |
| | | } |