| | |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1000)); |
| | | Long finalOrderId = orderId; |
| | | Long finalOrderId1 = orderId; |
| | | threadPoolExecutor.execute(() -> { |
| | | //等待10秒后开始执行车子位移 |
| | | try { |
| | |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | | if (null == vehiclePosition) { |
| | | vehiclePosition = new VehiclePosition(); |
| | | } |
| | | vehiclePosition.setVin(vin); |
| | | vehiclePosition.setPoint(new GeoJsonPoint(longitude, latitude)); |
| | | vehiclePosition.setCourse(60D); |
| | | vehiclePosition.setAlt(100F); |
| | | //车辆动态信息 |
| | | vehiclePosition.setSpeed(50F); |
| | | vehiclePosition.setCurrentElectricity(80); |
| | | vehiclePosition.setMileageRange(300f); |
| | | vehiclePosition.setOrderId(finalOrderId); |
| | | vehiclePosition.setHasOrder(0); |
| | | vehiclePosition.setOrderId(finalOrderId1); |
| | | mongoTemplate.save(vehiclePosition); |
| | | }else{ |
| | | vehiclePosition.setOrderId(finalOrderId1); |
| | | Update update = new Update() |
| | | .set("point", new GeoJsonPoint(longitude, latitude)) |
| | | .set("course", 60D) |
| | | .set("alt", 100F) |
| | | .set("speed", 50F) |
| | | .set("currentElectricity", 80) |
| | | .set("mileageRange", 300f) |
| | | .set("hasOrder", 0) |
| | | .set("orderId", finalOrderId1); |
| | | mongoTemplate.updateFirst(new Query(Criteria.where("vin").is(vin)), update, VehiclePosition.class); |
| | | } |
| | | //调用推送服务接口 |
| | | if (null != finalOrderId) { |
| | | PushOrderRouteDTO dto = new PushOrderRouteDTO(); |
| | |
| | | |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1000)); |
| | | Long finalOrderId = orderId; |
| | | Long finalOrderId1 = orderId; |
| | | threadPoolExecutor.execute(() -> { |
| | | //等待10秒后开始执行车子位移 |
| | | try { |
| | |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | | if (null == vehiclePosition) { |
| | | vehiclePosition = new VehiclePosition(); |
| | | } |
| | | vehiclePosition.setVin(vin); |
| | | vehiclePosition.setPoint(new GeoJsonPoint(longitude, latitude)); |
| | | vehiclePosition.setCourse(60D); |
| | | vehiclePosition.setAlt(100F); |
| | | //车辆动态信息 |
| | | vehiclePosition.setSpeed(50F); |
| | | vehiclePosition.setCurrentElectricity(80); |
| | | vehiclePosition.setMileageRange(300f); |
| | | vehiclePosition.setOrderId(finalOrderId); |
| | | vehiclePosition.setHasOrder(0); |
| | | vehiclePosition.setOrderId(finalOrderId1); |
| | | mongoTemplate.save(vehiclePosition); |
| | | }else{ |
| | | vehiclePosition.setOrderId(finalOrderId1); |
| | | Update update = new Update() |
| | | .set("point", new GeoJsonPoint(longitude, latitude)) |
| | | .set("course", 60D) |
| | | .set("alt", 100F) |
| | | .set("speed", 50F) |
| | | .set("currentElectricity", 80) |
| | | .set("mileageRange", 300f) |
| | | .set("hasOrder", 0) |
| | | .set("orderId", finalOrderId1); |
| | | mongoTemplate.updateFirst(new Query(Criteria.where("vin").is(vin)), update, VehiclePosition.class); |
| | | } |
| | | //调用推送服务接口 |
| | | if (null != finalOrderId) { |
| | | PushOrderRouteDTO dto = new PushOrderRouteDTO(); |