# Conflicts: # hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java # hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.javamaster
parent
bd6790acfa
commit
a7c82de2c4
File diff suppressed because one or more lines are too long
@ -0,0 +1,101 @@ |
||||
package com.hai.schedule; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.config.EtcService; |
||||
import com.hai.entity.EtcCarMsg; |
||||
import com.hai.entity.OutRechargeOrder; |
||||
import com.hai.enum_type.CarTypeEnum; |
||||
import com.hai.etc.EtcCarMsgService; |
||||
import com.hai.service.OutRechargeOrderService; |
||||
import com.hai.service.impl.OutRechargeOrderServiceImpl; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.*; |
||||
|
||||
|
||||
/** |
||||
* @serviceName HighRechargeOrderSchedule.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 充值订单定时任务
|
||||
* @createTime 09:57 2023/1/13 |
||||
**/ |
||||
@Configuration |
||||
public class EtcSchedule { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); |
||||
|
||||
@Resource |
||||
private EtcCarMsgService etcCarMsgService; |
||||
|
||||
|
||||
/** |
||||
* @return void |
||||
* @Author Sum1Dream |
||||
* @name cancelOrder.java |
||||
* @Description // 定时发起
|
||||
* @Date 14:18 2022/5/31 |
||||
* @Param [] |
||||
*/ |
||||
@Scheduled(cron = "0 0/10 * * * ?") //每10分钟执行一次
|
||||
public void getEtcCarList() { |
||||
try { |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("status" , "11,12,13,15"); |
||||
|
||||
List<EtcCarMsg> list = etcCarMsgService.getEtcCarList(map); |
||||
|
||||
for (EtcCarMsg carMsg : list) { |
||||
JSONObject object = EtcService.getVehStatus(carMsg); |
||||
|
||||
if (Objects.equals(object.getString("errCode"), "0") && object.getJSONObject("result") != null) { |
||||
carMsg.setVehStatus(object.getJSONObject("result").getInteger("vehStatus")); |
||||
carMsg.setUpdateTime(object.getJSONObject("result").getDate("activeTime")); |
||||
} |
||||
etcCarMsgService.updateEtcCar(carMsg); |
||||
|
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighUserController --> findByUserId() error!", e); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Scheduled(cron = "0 0/60 * * * ?") //每60分钟执行一次
|
||||
public void etcCarMsg() { |
||||
try { |
||||
|
||||
JSONObject object = EtcService.queryActivateVehicleInfoPage(DateUtil.format(DateUtil.reduceDate(new Date() , 2) , "yyyy-MM-dd HH:mm:ss") , DateUtil.format(new Date() , "yyyy-MM-dd HH:mm:ss") ); |
||||
if (Objects.equals(object.getString("errCode"), "0") && object.getJSONObject("result").getJSONArray("records") != null) { |
||||
JSONArray jsonArray = object.getJSONObject("result").getJSONArray("records"); |
||||
|
||||
for (int i = 0; i < jsonArray.size(); i++) { |
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("vehPlateNo" , jsonArray.getJSONObject(i).getString("vehPlateNo")); |
||||
map.put("vehPlateColor" , CarTypeEnum.getNameByName(jsonArray.getJSONObject(i).getString("vehPlateColor"))); |
||||
|
||||
EtcCarMsg carMsg = etcCarMsgService.findEtcCarByMap(map); |
||||
carMsg.setCardNo(jsonArray.getJSONObject(i).getString("cardNo")); |
||||
carMsg.setObuNo(jsonArray.getJSONObject(i).getString("obuNo")); |
||||
|
||||
etcCarMsgService.updateEtcCar(carMsg); |
||||
|
||||
} |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighUserController --> findByUserId() error!", e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,52 @@ |
||||
package com.hai.enum_type; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
public enum CarTypeEnum { |
||||
CarType0(0 , "蓝;"), |
||||
CarType1(1 , "黄"), |
||||
CarType2(2 , "黑"), |
||||
CarType3(3 , "白"), |
||||
CarType4(4 , "渐变绿"), |
||||
CarType5(5 , "黄绿双拼"), |
||||
CarType6(6 ,"蓝白渐变"), |
||||
; |
||||
|
||||
private Integer type; |
||||
private String name; |
||||
|
||||
|
||||
CarTypeEnum(int type , String name) { |
||||
this.type = type; |
||||
this.name = name; |
||||
} |
||||
|
||||
public static String getNameByType(Integer type) { |
||||
for (CarTypeEnum ele : values()) { |
||||
if(Objects.equals(type,ele.getType())) return ele.getName(); |
||||
} |
||||
return null; |
||||
} |
||||
public static Integer getNameByName(String name) { |
||||
for (CarTypeEnum ele : values()) { |
||||
if(Objects.equals(name,ele.getName())) return ele.getType(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public Integer getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(Integer type) { |
||||
this.type = type; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
Loading…
Reference in new issue