| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.global.api.model.Result; |
| | | import com.alipay.global.api.model.ResultStatusType; |
| | | import com.alipay.global.api.request.ams.notify.AlipayPayResultNotify; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.MD5Util; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.*; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryMyAllOrder") |
| | | @ApiOperation(value = "获取我的订单列表【2.0】", tags = {"司机端-首页"}, notes = "") |
| | | @ApiOperation(value = "获取我的订单列表", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "数据类型(1=全部,2=待支付,3=已取消,4=已完成)", name = "state", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryPushOrder") |
| | | @ApiOperation(value = "获取抢单界面的订单详情【1.0】", tags = {"司机端-首页"}, notes = "") |
| | | @ApiOperation(value = "获取抢单界面的订单详情", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型(1=专车,4=小件物流-同城)", name = "orderType", required = true, dataType = "int"), |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderInfo") |
| | | @ApiOperation(value = "获取服务中页面订单详情【2.0】", tags = {"司机端-服务中"}, notes = "",response = OrderInfoWarpper.class) |
| | | @ApiOperation(value = "获取服务中页面订单详情", tags = {"司机端-服务中"}, notes = "",response = OrderInfoWarpper.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型(1=专车,4=小件物流-同城)", name = "orderType", required = true, dataType = "int"), |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryMoneyInfo") |
| | | @ApiOperation(value = "获取订单费用明细【2.0】", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiOperation(value = "获取订单费用明细", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型(1=专车,4=同城小件物流)", name = "orderType", required = true, dataType = "int"), |
| | |
| | | } |
| | | return callbackResponse; |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/wxPayOrderTaxiAntom") |
| | | public void wxPayOrderTaxiAntom(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | ResultUtil<AlipayPayResultNotify> resultUtil = AntomPaymentUtil.receivePaymentNotify(request); |
| | | Integer code = resultUtil.getCode(); |
| | | if(200 == code){ |
| | | AlipayPayResultNotify alipayPayResultNotify = resultUtil.getData(); |
| | | Result result = alipayPayResultNotify.getResult(); |
| | | ResultStatusType resultStatus = result.getResultStatus(); |
| | | if(resultStatus.equals(ResultStatusType.S)){ |
| | | String out_trade_no = alipayPayResultNotify.getPaymentRequestId(); |
| | | String order_id = alipayPayResultNotify.getPaymentId(); |
| | | Integer orderType = Integer.valueOf(out_trade_no.substring(17, 18)); |
| | | Integer language = Integer.valueOf(out_trade_no.substring(18, 19)); |
| | | Integer id = Integer.valueOf(out_trade_no.substring(19)); |
| | | switch (orderType){ |
| | | case 1: |
| | | orderPrivateCarService.payOrderPrivateCarCallback(id, order_id, language); |
| | | break; |
| | | case 4: |
| | | orderLogisticsService.payOrderLogisticsCallback(id, order_id, language); |
| | | break; |
| | | } |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("{\n" + |
| | | " \"result\": {\n" + |
| | | " \"resultCode\": \"SUCCESS\",\n" + |
| | | " \"resultMessage\": \"success\",\n" + |
| | | " \"resultStatus\": \"S\"\n" + |
| | | " }\n" + |
| | | "}"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/taxi/updateEndAddress") |
| | | @ApiOperation(value = "处理乘客修改目的地【2.0】", tags = {"用户端-专车", "用户端-小件物流"}, notes = "") |
| | | @ApiOperation(value = "处理乘客修改目的地", tags = {"用户端-专车", "用户端-小件物流"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型", name = "orderType", required = true, dataType = "int"), |
| | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/taxi/getTripInfo") |
| | | @ApiOperation(value = "获取google行程详情【2.0】", tags = {"用户端-专车", "用户端-小件物流"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型", name = "orderType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<String> getTripInfo(Integer orderId, Integer orderType){ |
| | | try { |
| | | String tripId = null; |
| | | switch (orderType){ |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); |
| | | tripId = orderPrivateCar.getTripId(); |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); |
| | | tripId = orderLogistics.getTripId(); |
| | | break; |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(tripId); |
| | | return ResultUtil.success(trip); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | // @ResponseBody |
| | | // @PostMapping("/api/taxi/getTripInfo") |
| | | // @ApiOperation(value = "获取google行程详情", tags = {"用户端-专车", "用户端-小件物流"}, notes = "") |
| | | // @ApiImplicitParams({ |
| | | // @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | // @ApiImplicitParam(value = "订单类型", name = "orderType", required = true, dataType = "int"), |
| | | // @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | // }) |
| | | // public ResultUtil<String> getTripInfo(Integer orderId, Integer orderType){ |
| | | // try { |
| | | // String tripId = null; |
| | | // switch (orderType){ |
| | | // case 1: |
| | | // OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); |
| | | // tripId = orderPrivateCar.getTripId(); |
| | | // break; |
| | | // case 4: |
| | | // OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); |
| | | // tripId = orderLogistics.getTripId(); |
| | | // break; |
| | | // } |
| | | // String trip = fleetEngineUtil.getTrip(tripId); |
| | | // return ResultUtil.success(trip); |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/getTripInfo") |
| | | public ResultUtil getTripInfo(String tripId){ |
| | | return ResultUtil.success(fleetEngineUtil.getTrip(tripId)); |
| | | } |
| | | // @ResponseBody |
| | | // @PostMapping("/base/taxi/getTripInfo") |
| | | // public ResultUtil getTripInfo(String tripId){ |
| | | // return ResultUtil.success(fleetEngineUtil.getTrip(tripId)); |
| | | // } |
| | | |
| | | |
| | | |
| | |
| | | * @param tripId |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/editTripStatus") |
| | | public ResultUtil editTripStatus(String tripStatus, String tripId){ |
| | | boolean b = fleetEngineUtil.updateTrip(tripStatus, null, null, tripId, null, null, null, null, null, null); |
| | | if(b){ |
| | | return ResultUtil.success(); |
| | | } |
| | | return ResultUtil.error("更新失败"); |
| | | } |
| | | // @ResponseBody |
| | | // @PostMapping("/base/taxi/editTripStatus") |
| | | // public ResultUtil editTripStatus(String tripStatus, String tripId){ |
| | | // boolean b = fleetEngineUtil.updateTrip(tripStatus, null, null, tripId, null, null, null, null, null, null); |
| | | // if(b){ |
| | | // return ResultUtil.success(); |
| | | // } |
| | | // return ResultUtil.error("更新失败"); |
| | | // } |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | |
| | | // @ResponseBody |
| | | // @PostMapping("/base/taxi/editGoogleTripStatus") |
| | | // public ResultUtil editGoogleTripStatus(){ |
| | | // List<OrderPrivateCar> privateCars = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().isNotNull("tripId")); |
| | | // for (OrderPrivateCar privateCar : privateCars) { |
| | | // Integer state = privateCar.getState(); |
| | | // String tripId = privateCar.getTripId(); |
| | | // String trip = fleetEngineUtil.getTrip(tripId); |
| | | // if(ToolUtil.isNotEmpty(trip)){ |
| | | // JSONObject jsonObject = JSON.parseObject(trip); |
| | | // String tripStatus = jsonObject.getString("tripStatus"); |
| | | // Car car = carService.selectById(privateCar.getCarId()); |
| | | // if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){ |
| | | // //修改行程信息 |
| | | // boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | // if(!updateTrip){ |
| | | // for (int i = 0; i < 5; i++) { |
| | | // updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | // if(updateTrip){ |
| | | // privateCar.setIsover(1); |
| | | // orderPrivateCarService.updateById(privateCar); |
| | | // break; |
| | | // } |
| | | // try { |
| | | // Thread.sleep(3000L); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }else{ |
| | | // privateCar.setIsover(1); |
| | | // orderPrivateCarService.updateById(privateCar); |
| | | // } |
| | | // } |
| | | // if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){ |
| | | // //修改行程信息 |
| | | // boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | // if(!updateTrip){ |
| | | // for (int i = 0; i < 5; i++) { |
| | | // updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | // if(updateTrip){ |
| | | // privateCar.setIsover(1); |
| | | // orderPrivateCarService.updateById(privateCar); |
| | | // break; |
| | | // } |
| | | // try { |
| | | // Thread.sleep(3000L); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }else{ |
| | | // privateCar.setIsover(1); |
| | | // orderPrivateCarService.updateById(privateCar); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // List<OrderLogistics> orderLogisticsList = orderLogisticsService.selectList(new EntityWrapper<OrderLogistics>().isNotNull("tripId")); |
| | | // for (OrderLogistics orderLogistics : orderLogisticsList) { |
| | | // Integer state = orderLogistics.getState(); |
| | | // String tripId = orderLogistics.getTripId(); |
| | | // String trip = fleetEngineUtil.getTrip(tripId); |
| | | // if(ToolUtil.isNotEmpty(trip)){ |
| | | // JSONObject jsonObject = JSON.parseObject(trip); |
| | | // String tripStatus = jsonObject.getString("tripStatus"); |
| | | // Car car = carService.selectById(orderLogistics.getCarId()); |
| | | // if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){ |
| | | // //修改行程信息 |
| | | // boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | // if(!updateTrip){ |
| | | // for (int i = 0; i < 5; i++) { |
| | | // updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | // if(updateTrip){ |
| | | // orderLogistics.setIsover(1); |
| | | // orderLogisticsService.updateById(orderLogistics); |
| | | // break; |
| | | // } |
| | | // try { |
| | | // Thread.sleep(3000L); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }else{ |
| | | // orderLogistics.setIsover(1); |
| | | // orderLogisticsService.updateById(orderLogistics); |
| | | // } |
| | | // } |
| | | // if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){ |
| | | // //修改行程信息 |
| | | // boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | // if(!updateTrip){ |
| | | // for (int i = 0; i < 5; i++) { |
| | | // updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | // if(updateTrip){ |
| | | // orderLogistics.setIsover(1); |
| | | // orderLogisticsService.updateById(orderLogistics); |
| | | // break; |
| | | // } |
| | | // try { |
| | | // Thread.sleep(3000L); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }else{ |
| | | // orderLogistics.setIsover(1); |
| | | // orderLogisticsService.updateById(orderLogistics); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // return ResultUtil.success(); |
| | | // } |
| | | |
| | | |
| | | // @ResponseBody |
| | | // @PostMapping("/base/taxi/getTrips") |
| | | // public String getTrips(String vehicleId, Integer pageSize, String pageToken){ |
| | | // return fleetEngineUtil.getTrips(vehicleId, pageSize, pageToken); |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | // @ResponseBody |
| | | // @GetMapping("/base/taxi/getTripsStatus") |
| | | // public ResultUtil<List<Map<String, String>>> getTripsStatus(){ |
| | | // String pageToken = null; |
| | | // List<Map<String, String>> list = new ArrayList<>(); |
| | | // while (true){ |
| | | // String trips = fleetEngineUtil.getTrips(null, 50, pageToken); |
| | | // if(ToolUtil.isEmpty(trips)){ |
| | | // break; |
| | | // } |
| | | // JSONObject jsonObject = JSON.parseObject(trips); |
| | | // JSONArray array = jsonObject.getJSONArray("trips"); |
| | | // if(null == array){ |
| | | // break; |
| | | // } |
| | | // for (int i = 0; i < array.size(); i++) { |
| | | // JSONObject trip = array.getJSONObject(i); |
| | | // String tripStatus = trip.getString("tripStatus"); |
| | | // String name = trip.getString("name"); |
| | | // Integer index = name.lastIndexOf("/") + 1; |
| | | // String tripId = name.substring(index); |
| | | // |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put(tripId, tripStatus); |
| | | // list.add(map); |
| | | // } |
| | | // |
| | | // pageToken = jsonObject.getString("nextPageToken"); |
| | | // if(null == pageToken){ |
| | | // break; |
| | | // } |
| | | // } |
| | | // return ResultUtil.success(list); |
| | | // } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/editGoogleTripStatus") |
| | | public ResultUtil editGoogleTripStatus(){ |
| | | List<OrderPrivateCar> privateCars = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().isNotNull("tripId")); |
| | | for (OrderPrivateCar privateCar : privateCars) { |
| | | Integer state = privateCar.getState(); |
| | | String tripId = privateCar.getTripId(); |
| | | String trip = fleetEngineUtil.getTrip(tripId); |
| | | if(ToolUtil.isNotEmpty(trip)){ |
| | | JSONObject jsonObject = JSON.parseObject(trip); |
| | | String tripStatus = jsonObject.getString("tripStatus"); |
| | | Car car = carService.selectById(privateCar.getCarId()); |
| | | if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | privateCar.setIsover(1); |
| | | orderPrivateCarService.updateById(privateCar); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | privateCar.setIsover(1); |
| | | orderPrivateCarService.updateById(privateCar); |
| | | } |
| | | } |
| | | if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, privateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | privateCar.setIsover(1); |
| | | orderPrivateCarService.updateById(privateCar); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | privateCar.setIsover(1); |
| | | orderPrivateCarService.updateById(privateCar); |
| | | } |
| | | } |
| | | @PostMapping("/api/order/getDriverOrderMessage") |
| | | @ApiOperation(value = "司机定时任务获取订单相关socket消息【1.0】", tags = {"用户端-专车", "用户端-小件物流"}, notes = "消息数据结构和socket推送一样") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil getDriverOrderMessage(HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String value = redisUtil.getValue("DRIVER_ORDER_MESSAGE:" + uid); |
| | | JSONObject jsonObject = JSON.parseObject(value); |
| | | redisUtil.remove("DRIVER_ORDER_MESSAGE:" + uid); |
| | | return ResultUtil.success(jsonObject); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | List<OrderLogistics> orderLogisticsList = orderLogisticsService.selectList(new EntityWrapper<OrderLogistics>().isNotNull("tripId")); |
| | | for (OrderLogistics orderLogistics : orderLogisticsList) { |
| | | Integer state = orderLogistics.getState(); |
| | | String tripId = orderLogistics.getTripId(); |
| | | String trip = fleetEngineUtil.getTrip(tripId); |
| | | if(ToolUtil.isNotEmpty(trip)){ |
| | | JSONObject jsonObject = JSON.parseObject(trip); |
| | | String tripStatus = jsonObject.getString("tripStatus"); |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | if(updateTrip){ |
| | | orderLogistics.setIsover(1); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | orderLogistics.setIsover(1); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | } |
| | | } |
| | | if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null, orderLogistics.getId(), 4); |
| | | if(updateTrip){ |
| | | orderLogistics.setIsover(1); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | orderLogistics.setIsover(1); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/getTrips") |
| | | public String getTrips(String vehicleId, Integer pageSize, String pageToken){ |
| | | return fleetEngineUtil.getTrips(vehicleId, pageSize, pageToken); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/base/taxi/getTripsStatus") |
| | | public ResultUtil<List<Map<String, String>>> getTripsStatus(){ |
| | | String pageToken = null; |
| | | List<Map<String, String>> list = new ArrayList<>(); |
| | | while (true){ |
| | | String trips = fleetEngineUtil.getTrips(null, 50, pageToken); |
| | | if(ToolUtil.isEmpty(trips)){ |
| | | break; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(trips); |
| | | JSONArray array = jsonObject.getJSONArray("trips"); |
| | | if(null == array){ |
| | | break; |
| | | } |
| | | for (int i = 0; i < array.size(); i++) { |
| | | JSONObject trip = array.getJSONObject(i); |
| | | String tripStatus = trip.getString("tripStatus"); |
| | | String name = trip.getString("name"); |
| | | Integer index = name.lastIndexOf("/") + 1; |
| | | String tripId = name.substring(index); |
| | | |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put(tripId, tripStatus); |
| | | list.add(map); |
| | | } |
| | | |
| | | pageToken = jsonObject.getString("nextPageToken"); |
| | | if(null == pageToken){ |
| | | break; |
| | | } |
| | | } |
| | | return ResultUtil.success(list); |
| | | } |
| | | |
| | | |
| | | } |