超过两小时的订单结算数据丢弃

This commit is contained in:
ZZ 2021-10-20 18:51:11 +08:00
parent 4155b52a7f
commit d265735c52
2 changed files with 9 additions and 2 deletions

View File

@ -52,10 +52,14 @@ public class OrderDataLogic implements ServiceLogic {
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
cacheGun.put("orderstoptime", cacheOrderData.getEndTime());
cacheGun.put("orderkey", null);
REDIS.setCacheObject(gunkey, cacheGun);
Long rdtime = (Long) cacheOrder.get("rdtime");
String resultStr =
"6815".concat(req.get("seqhex").toString()).concat("0040").concat(orderNo).concat(ServiceResult.HEX_00);
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
pileOrderService.pileEndOrder(orderNo);
if (rdtime != null && (DateUtil.calendar().getTimeInMillis() - rdtime) < 3600000) {
pileOrderService.pileEndOrder(orderNo);
}
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK);
}

View File

@ -104,7 +104,7 @@ public class RealtimeDataLogic implements ServiceLogic {
REDIS.setCacheMap(stationTermStatusKey, cacheTerminalStatusMap);
Map<String, Object> cacheOrder = REDIS.getCacheMap(orderkey);
List<CacheRealtimeData> realtimeDataList = (List<CacheRealtimeData>) cacheOrder.get("realtimeDataList");
if (!orderNo.equals("00000000000000000000000000000000") && statusInt != 2) {
if (!orderNo.equals("00000000000000000000000000000000") && statusInt == 3) {
if (realtimeDataList == null) {
realtimeDataList = new ArrayList<>();
}
@ -129,6 +129,7 @@ public class RealtimeDataLogic implements ServiceLogic {
// cacheOrder.put("em", realtimeData.()); //todo 实时时段明细数据是否由桩直接上传?
cacheOrder.put("rbalance", balance);
cacheOrder.put("remainingTime", tr);
cacheOrder.put("rdtime", DateUtil.calendar().getTime().getTime());
cacheOrder.put("status", statusplain);
cacheOrder.put("totalPower", cacheRealtimeData.getChargingDegree() / 10000.0);
cacheOrder.put("totalMoney", cacheRealtimeData.getAmountCharged() / 10000.0);
@ -165,6 +166,8 @@ public class RealtimeDataLogic implements ServiceLogic {
REDIS.setCacheMap(orderkey, cacheOrder);
}
REDIS.setCacheMap(orderkey, cacheOrder);
} else {
//todo invoke 异常订单
}
return new ServiceResult(false);
}