Commit 818b3b36 authored by 曹军's avatar 曹军

上传定时任务,优化代码

parent c6f65f1e
package com.bme.access.upload.module.enums;
import lombok.Getter;
import org.springframework.util.StringUtils;
import java.util.Objects;
/**
* description:
* <p></p>
*
* @author huanghao
* @since 2021/8/22 16:03
* Copyright: 2021, BME (Shanghai) Co., Ltd. All Rights Reserved.
*/
@Getter
public enum PlateColorEnums {
BLUE(1, "蓝牌"),
YELLOW(2, "黄牌"),
WHITE(3, "白牌"),
BLACK(4, "黑牌"),
GREEN(5, "绿牌"),
YELLOW_AND_GREEN(6, "黄绿牌"),
DEFAULT(0, "未知");
private Integer type;
private String color;
PlateColorEnums(int type, String color) {
this.type = type;
this.color = color;
}
public static String getColor(Integer type, String numberPlate) {
if (!StringUtils.isEmpty(numberPlate)){
if (numberPlate.length() == 8 && (!Objects.equals(type, PlateColorEnums.GREEN.type) && !Objects.equals(type, PlateColorEnums.YELLOW_AND_GREEN.type))){
return PlateColorEnums.YELLOW_AND_GREEN.color;
}
}
PlateColorEnums[] plateColorEnums = values();
for (PlateColorEnums plateColorEnum : plateColorEnums){
if (plateColorEnum.type.equals(type)){
return plateColorEnum.color;
}
}
return PlateColorEnums.DEFAULT.color;
}
public static Integer getType(String color) {
PlateColorEnums[] plateColorEnums = values();
for (PlateColorEnums plateColorEnum : plateColorEnums){
if (plateColorEnum.color.equals(color)){
return plateColorEnum.type;
}
}
return PlateColorEnums.DEFAULT.type;
}
public static void main(String[] args) {
System.out.println(getColor(1, "晋L02690D"));
}
}
...@@ -39,8 +39,10 @@ public class NoneRoadMovementInfoService { ...@@ -39,8 +39,10 @@ public class NoneRoadMovementInfoService {
} }
} }
for (NoneRoadMovementInfo noneRoadMovementInfo : noneRoadMovementInfos) { for (NoneRoadMovementInfo noneRoadMovementInfo : noneRoadMovementInfos) {
log.info("上传非道路数据编号={}", noneRoadMovementInfo.getHbCarNo());
String bodyJson = JSONObject.toJSONString(noneRoadMovementInfo); String bodyJson = JSONObject.toJSONString(noneRoadMovementInfo);
HttpUtils.sendPost(NON_WAY_URL, null, null, bodyJson); HttpUtils.sendPost(NON_WAY_URL, null, null, bodyJson);
Thread.sleep(1000);
} }
log.info("上传非道路电子台账共: {}条", noneRoadMovementInfoUrls.size()); log.info("上传非道路电子台账共: {}条", noneRoadMovementInfoUrls.size());
} }
......
...@@ -9,6 +9,7 @@ import com.bme.access.upload.model.InAndOutDateUrl; ...@@ -9,6 +9,7 @@ import com.bme.access.upload.model.InAndOutDateUrl;
import com.bme.access.upload.model.MaterialInfo; import com.bme.access.upload.model.MaterialInfo;
import com.bme.access.upload.model.TransportDate; import com.bme.access.upload.model.TransportDate;
import com.bme.access.upload.module.service.InFactoryTransportVehicleInfoService; import com.bme.access.upload.module.service.InFactoryTransportVehicleInfoService;
import com.bme.access.upload.module.service.NoneRoadMovementInfoService;
import com.bme.access.upload.module.service.TransportVehicleInfoService; import com.bme.access.upload.module.service.TransportVehicleInfoService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -37,6 +38,8 @@ public class TestController { ...@@ -37,6 +38,8 @@ public class TestController {
private InFactoryTransportVehicleInfoService inFactoryTransportVehicleInfoService; private InFactoryTransportVehicleInfoService inFactoryTransportVehicleInfoService;
@Resource @Resource
private TransportVehicleInfoService transportVehicleInfoService; private TransportVehicleInfoService transportVehicleInfoService;
@Resource
private NoneRoadMovementInfoService noneRoadMovementInfoService;
@GetMapping("/uploadInAndOutDate") @GetMapping("/uploadInAndOutDate")
public CommonResult uploadInAndOutDate() throws Exception { public CommonResult uploadInAndOutDate() throws Exception {
...@@ -140,5 +143,13 @@ public class TestController { ...@@ -140,5 +143,13 @@ public class TestController {
transportVehicleInfoService.updateVehicle(numberPlate); transportVehicleInfoService.updateVehicle(numberPlate);
} }
/**
* 上传非道路
*/
@GetMapping("/uploadNoWay")
public void uploadNoWay() throws Exception {
noneRoadMovementInfoService.getNoWayDate();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment