缓存加入桩协议版本;异常订单判定逻辑

This commit is contained in:
ZZ 2021-10-21 15:12:31 +08:00
parent 055edbc56b
commit c804922be3
5 changed files with 37 additions and 24 deletions

View File

@ -42,17 +42,17 @@ public class EquipChargeStatus {
@JsonProperty("ConnectorStatus")
private Integer connectorStatus = 1;
@JsonProperty("CurrentA")
private Double currentA = 15.0;
private Double currentA = 0.0;
@JsonProperty("CurrentB")
private Double currentB = 15.0;
private Double currentB = 0.0;
@JsonProperty("CurrentC")
private Double currentC = 15.0;
private Double currentC = 0.0;
@JsonProperty("VoltageA")
private Double voltageA = 220.0;
private Double voltageA = 0.0;
@JsonProperty("VoltageB")
private Double voltageB = 220.0;
private Double voltageB = 0.0;
@JsonProperty("VoltageC")
private Double voltageC = 220.0;
private Double voltageC = 0.0;
@JsonProperty("Soc")
private Double soc = 0.0;
@JsonProperty("StartTime")

View File

@ -27,8 +27,10 @@ public interface PowerPileService {
R stopCharging(@PathVariable("orderNo") String orderNo, @PathVariable("pileNo") String pileNo,
@PathVariable("gunId") String gunId, @PathVariable("version") String version);
@PostMapping("/pile/whitelist/add/{stationId}")
R addPileWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet);
@PostMapping("/pile/whitelist/add/{stationId}/{version}")
R addPileWhitelist(@PathVariable("stationId") Long stationId,
@PathVariable("version") String version,
@RequestBody Set<String> pileNoSet);
@DeleteMapping("/pile/whitelist/delete/{stationId}")
R deletePileWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet);

View File

@ -41,7 +41,7 @@ public class PowerPileFallbackFactory implements FallbackFactory<PowerPileServic
}
@Override
public R addPileWhitelist(Long stationId, Set<String> pileNoSet) {
public R addPileWhitelist(Long stationId, String version, Set<String> pileNoSet) {
return R.fail("增加充电桩白名单失败:" + cause.getMessage());
}

View File

@ -19,8 +19,10 @@ import static com.xhpc.pp.server.ChargingPileServer.removeHandler;
@Slf4j
public class PileController {
@PostMapping("pile/whitelist/add/{stationId}")
public Object addWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet) {
@PostMapping("pile/whitelist/add/{stationId}/{version}")
public Object addWhitelist(@PathVariable("stationId") Long stationId,
@PathVariable("version") String version,
@RequestBody Set<String> pileNoSet) {
Set<String> pileWhitelist = REDIS.getCacheSet("PILE_WHITELIST");
pileWhitelist.addAll(pileNoSet);
@ -42,6 +44,7 @@ public class PileController {
String pkey = "pile:".concat(pileNo);
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
cachePile.put("stationId", stationId);
cachePile.put("version", version);
REDIS.setCacheMap(pkey, cachePile);
}
return R.ok();

View File

@ -26,8 +26,7 @@ import java.util.Map;
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
import static com.xhpc.pp.server.ChargingPileServer.default_version;
import static com.xhpc.pp.utils.HexUtils.reverseHexInt;
import static com.xhpc.pp.utils.HexUtils.toBits;
import static com.xhpc.pp.utils.HexUtils.*;
import static com.xhpc.pp.utils.security.CacheDataUtils.reflectTranslate;
@Lazy
@ -37,17 +36,18 @@ public class RealtimeDataLogic implements ServiceLogic {
@Autowired
private SmsService smsService;
@Autowired
private PileOrderService pileOrderService;
@Autowired
private ChargingController chargingController;
private static Logger log = LoggerFactory.getLogger(RealtimeDataLogic.class);
public static final String[] stable = {"离线", "故障", "空闲", "充电中"};
public static final String[] pvgstable = {"", "", "未知"};
private static final String[] hftable = {"急停按钮动作故障", "无可用整流模块", "出风口温度过高", "交流防雷故障", "交直流模块DC20通信中断", "绝缘检测模块FC08通信中断", "电度表通信中断", "读卡器通信中断", "RC10通信中断", "风扇调速板故障", "直流熔断器故障", "高压接触器故障", "门打开"};
private static final String[] hftable = {"急停按钮动作故障", "无可用整流模块", "出风口温度过高", "交流防雷故障", "交直流模块DC20通信中断", "绝缘检测模块FC08通信中断",
"电度表通信中断", "读卡器通信中断", "RC10通信中断", "风扇调速板故障", "直流熔断器故障", "高压接触器故障", "门打开"};
@Autowired
private PileOrderService pileOrderService;
@Autowired
private ChargingController chargingController;
@Override
public ServiceResult service(ServiceParameter sp) throws Exception {
@ -97,7 +97,6 @@ public class RealtimeDataLogic implements ServiceLogic {
cacheGun.put("statusInt", statusInt);
cacheGun.put("status", statusOrSOC);
cacheGun.put("remainingTime", tr);
REDIS.setCacheMap(gunkey, cacheGun);
String stationTermStatusKey = "stationTerminalStatus:".concat(cachePile.get("stationId").toString());
Map<String, Object> cacheTerminalStatusMap = REDIS.getCacheMap(stationTermStatusKey);
cacheTerminalStatusMap.put(terminalId, statusOrSOC);
@ -134,7 +133,6 @@ public class RealtimeDataLogic implements ServiceLogic {
cacheOrder.put("totalPower", cacheRealtimeData.getChargingDegree() / 10000.0);
cacheOrder.put("totalMoney", cacheRealtimeData.getAmountCharged() / 10000.0);
cacheOrder.put("realtimeDataList", realtimeDataList);
REDIS.setCacheMap(orderkey, cacheOrder);
pileOrderService.pileRimeOrder(orderNo);
Integer stopSoc = (Integer) cacheOrder.get("stopSoc");
if (stopSoc != null && socInt >= stopSoc) {
@ -147,7 +145,6 @@ public class RealtimeDataLogic implements ServiceLogic {
.concat(stopSoc.toString())
.concat("%)已自动停止充电,请您尽快将车辆挪走以方便他人使用充电桩,谢谢合作。"));
cacheOrder.put("socalerted", "true");
REDIS.setCacheMap(orderkey, cacheOrder);
}
}
}
@ -157,18 +154,29 @@ public class RealtimeDataLogic implements ServiceLogic {
if (alerted == null && tel != null) {
smsService.sendNotice(tel, "【小华充电】尊敬的用户你的账户余额小于5元,为不影响您的正常充电,请您尽快充值交费,谢谢。");
cacheOrder.put("lt5alerted", "true");
REDIS.setCacheMap(orderkey, cacheOrder);
}
}
if ("true".equals(cacheOrder.get("lordiss"))) {
cacheOrder.put("lordiss", "false");
pileOrderService.pileStop(orderNo, 4, "订单实时数据恢复");
REDIS.setCacheMap(orderkey, cacheOrder);
}
REDIS.setCacheMap(orderkey, cacheOrder);
} else {
//todo invoke 异常订单
Integer idleCnt = (Integer) cacheGun.get("idleCnt");
idleCnt = idleCnt == null ? 0 : idleCnt;
idleCnt++;
orderkey = (String) cacheGun.get("orderkey");
if (idleCnt > 3 && orderkey != null) {
Map<String, Object> problematicOrder = REDIS.getCacheMap(orderkey);
Object orderData = problematicOrder.get("orderData");
String status = (String) problematicOrder.get("status");
if (!isInteger(status) && !status.equals("充电中") && orderData == null) {
pileOrderService.abnormalOrder(orderNo);
}
}
cacheGun.put("idleCnt", idleCnt);
}
REDIS.setCacheMap(gunkey, cacheGun);
return new ServiceResult(false);
}