|
@@ -3,6 +3,7 @@ package com.tokheim.aifueling.communication.toInternalInterface;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.tokheim.aifueling.communication.entitys.BaseInfo;
|
|
|
+import com.tokheim.aifueling.communication.entitys.CardStatus;
|
|
|
import com.tokheim.aifueling.communication.toInternalInterface.entity.FuelResponse;
|
|
|
import com.tokheim.aifueling.communication.toMachine.MachineWriter;
|
|
|
import com.tokheim.aifueling.utils.BeanUtils;
|
|
@@ -10,11 +11,18 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
|
public class InterfaceUtils {
|
|
|
private static final InterfaceApi interfaceApi = BeanUtils.getBean(InterfaceApi.class);
|
|
|
|
|
|
+
|
|
|
+ private static Map<Integer, BaseInfo> cardCommMap = new HashMap<>();
|
|
|
+
|
|
|
|
|
|
* 发送数据到内部接口
|
|
|
* @param dataType 数据类型,用于确定 baseInfo 可转换的子类
|
|
@@ -22,12 +30,26 @@ public class InterfaceUtils {
|
|
|
*/
|
|
|
public static void sendDataToInternal(Integer dataType, BaseInfo baseInfo) {
|
|
|
try {
|
|
|
+ sortCardComm(dataType, baseInfo);
|
|
|
+ if (dataType == 1 && baseInfo.getEventType() == 3) log.info("无密码确认");
|
|
|
+
|
|
|
+ if (dataType == 1 && baseInfo.getEventType() == 7) return;
|
|
|
+
|
|
|
String response = interfaceApi.sendData(dataType, baseInfo);
|
|
|
log.info("收到内部接口响应:{}",response);
|
|
|
|
|
|
+
|
|
|
+ if (dataType == 6) {
|
|
|
+ response = interfaceApi.sendData(1, cardCommMap.get(baseInfo.getNozzleNum()));
|
|
|
+ log.info("发送卡最大可加金额,收到内部接口响应:{}",response);
|
|
|
+ }
|
|
|
+
|
|
|
FuelResponse fuelResponse = new Gson().fromJson(response, FuelResponse.class);
|
|
|
FuelResponse.Data data = fuelResponse.getData();
|
|
|
- if (data == null) return;
|
|
|
+ if (data == null){
|
|
|
+ if (dataType == 1 && baseInfo.getEventType() == 3) MachineWriter.sendCarNumber(baseInfo.getIp(),baseInfo.getFuelPoint(), baseInfo.getInternalNum(), "0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if (data.getLicensePlate() != null && !data.getLicensePlate().isEmpty()) {
|
|
@@ -63,4 +85,17 @@ public class InterfaceUtils {
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 整理卡命令顺序
|
|
|
+ */
|
|
|
+ private static void sortCardComm(Integer dataType, BaseInfo baseInfo) {
|
|
|
+
|
|
|
+ if (dataType == 1 && (baseInfo.getEventType() == 1 || baseInfo.getEventType() == 2)){
|
|
|
+ cardCommMap.remove(baseInfo.getNozzleNum());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (dataType == 1 && baseInfo.getEventType() == 7) cardCommMap.put(baseInfo.getNozzleNum(), baseInfo);
|
|
|
+ }
|
|
|
}
|