Commit a10905d539e56311824d2445e95a21b887bf14b4

Authored by lichao
1 parent ceb1e84e

调整04-02

trash-garbage/src/main/java/com/trash/garbage/controller/GarCarController.java
@@ -19,7 +19,9 @@ import com.trash.driver.service.IDriverService; @@ -19,7 +19,9 @@ import com.trash.driver.service.IDriverService;
19 import com.trash.enterprise.domain.TransportationEnterprise; 19 import com.trash.enterprise.domain.TransportationEnterprise;
20 import com.trash.garbage.global.Result; 20 import com.trash.garbage.global.Result;
21 import com.trash.garbage.pojo.dto.GarCarInfoVo; 21 import com.trash.garbage.pojo.dto.GarCarInfoVo;
  22 +import com.trash.garbage.pojo.domain.GarOrderMatchAsk;
22 import com.trash.garbage.service.GarCarServer; 23 import com.trash.garbage.service.GarCarServer;
  24 +import com.trash.garbage.service.GarOrderMatchAskService;
23 //import javafx.scene.controlra.SplitPane; 25 //import javafx.scene.controlra.SplitPane;
24 import com.trash.garbage.utils.HttpUtil; 26 import com.trash.garbage.utils.HttpUtil;
25 import lombok.extern.slf4j.Slf4j; 27 import lombok.extern.slf4j.Slf4j;
@@ -54,6 +56,8 @@ public class GarCarController { @@ -54,6 +56,8 @@ public class GarCarController {
54 private IDriverService driverService; 56 private IDriverService driverService;
55 @Autowired 57 @Autowired
56 private GarCarServer garCarServer; 58 private GarCarServer garCarServer;
  59 + @Autowired
  60 + private GarOrderMatchAskService garOrderMatchAskService;
57 61
58 public GarCarController(CarInfoServiceImpl carInfoServiceImpl) { 62 public GarCarController(CarInfoServiceImpl carInfoServiceImpl) {
59 this.carInfoServiceImpl = carInfoServiceImpl; 63 this.carInfoServiceImpl = carInfoServiceImpl;
@@ -119,8 +123,9 @@ public class GarCarController { @@ -119,8 +123,9 @@ public class GarCarController {
119 } 123 }
120 124
121 @GetMapping("/queryMileage") 125 @GetMapping("/queryMileage")
122 - public Result<?> queryMileage(String carNo , String startTime) { 126 + public Result<?> queryMileage(String carNo) {
123 String vehicleId = queryAllVehicleInfo(carNo); 127 String vehicleId = queryAllVehicleInfo(carNo);
  128 + String startTime = resolveStartTimeByCarNo(carNo);
124 Date currentDate = new Date(); 129 Date currentDate = new Date();
125 String currentTime = new SimpleDateFormat("yyyy-MM-dd+HH:mm:ss").format(currentDate); 130 String currentTime = new SimpleDateFormat("yyyy-MM-dd+HH:mm:ss").format(currentDate);
126 Map<String, Object> params = new HashMap<>(); 131 Map<String, Object> params = new HashMap<>();
@@ -162,6 +167,23 @@ public class GarCarController { @@ -162,6 +167,23 @@ public class GarCarController {
162 return Result.OK(result); 167 return Result.OK(result);
163 } 168 }
164 169
  170 + private String resolveStartTimeByCarNo(String carNo) {
  171 + String defaultStartTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
  172 + .format(new Date(System.currentTimeMillis() - 6 * 60 * 60 * 1000L));
  173 + if (StringUtils.isBlank(carNo)) {
  174 + return defaultStartTime;
  175 + }
  176 + GarOrderMatchAsk latestAsk = garOrderMatchAskService.lambdaQuery()
  177 + .eq(GarOrderMatchAsk::getGarHandlerCarCode, carNo)
  178 + .orderByDesc(GarOrderMatchAsk::getGarCreateTime)
  179 + .last("limit 1")
  180 + .one();
  181 + if (Objects.nonNull(latestAsk) && Objects.nonNull(latestAsk.getGarCreateTime())) {
  182 + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(latestAsk.getGarCreateTime());
  183 + }
  184 + return defaultStartTime;
  185 + }
  186 +
165 @GetMapping("/requestStrByEnergyType") 187 @GetMapping("/requestStrByEnergyType")
166 public Result<?> requestStrByEnergyType(String energyType) { 188 public Result<?> requestStrByEnergyType(String energyType) {
167 List<String> json = garCarServer.getAllCompanyNamesByEnergyType(energyType); 189 List<String> json = garCarServer.getAllCompanyNamesByEnergyType(energyType);