diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java index 3f0e102b..05a204e4 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java @@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*; import java.io.IOException; import java.util.*; +import java.util.concurrent.TimeUnit; import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMAT; import static cn.hutool.core.util.NumberUtil.isInteger; @@ -123,6 +124,8 @@ public class PileController { try { handler.sendClientBinary(HexUtils.toBytes(rsmsg)); log.info("pile[{}] rate model[{}] sent ⚪ {}", pileNo, rateModelIdStation, rsmsg); + String configRmReply = pk.concat(".configRmReply"); + REDIS.setCacheObject(configRmReply, "已下发", 30L, TimeUnit.MINUTES); String skey = pk.concat(".seqhex"); Thread.sleep(500); Date date = Calendar.getInstance().getTime(); @@ -130,6 +133,8 @@ public class PileController { handler.sendClientBinary(HexUtils.toBytes(timebin)); REDIS.setCacheMapValue(pk, "manConfTime", DateUtil.format(date, NORM_DATETIME_FORMAT)); + String configTimeReply = pk.concat(".configTimeReply"); + REDIS.setCacheObject(configTimeReply, "已下发", 30L, TimeUnit.MINUTES); r = R.fail("校时校费下发成功."); } catch (IOException | InterruptedException e) { r = R.fail("校时|校费下发失败,请重试."); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileTimeConfigReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileTimeConfigReplyDataLogic.java index f8859d4c..c163c73c 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileTimeConfigReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileTimeConfigReplyDataLogic.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.Map; +import java.util.concurrent.TimeUnit; import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMAT; import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; @@ -39,9 +40,8 @@ public class PileTimeConfigReplyDataLogic implements ServiceLogic { String pileNo = (String) req.get("pileNo"); String pk = "pile:".concat(pileNo); String configTime = DateUtil.format(cp56toDate(pileTimeConfigReplyData.getSetTime()), NORM_DATETIME_FORMAT); - Map cachePile = REDIS.getCacheMap(pk); - cachePile.put("configTimeReply", configTime); - REDIS.setCacheMap(pk, cachePile); + String configTimeReply = pk.concat(".configTimeReply"); + REDIS.setCacheObject(configTimeReply, "校时设置成功:".concat(configTime), 30L, TimeUnit.MINUTES); log.debug("({}) set time success√: [{}]", pileNo, configTime); String remark = "充电桩同步时钟"; XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java index 812f430b..3d8d9d24 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java @@ -1,6 +1,5 @@ package com.xhpc.pp.logic; -import cn.hutool.core.date.DateUtil; import com.fasterxml.jackson.databind.ObjectMapper; import com.xhpc.common.api.dto.ChargingStationDto; import com.xhpc.common.data.up.PileConfigReplyData; @@ -16,10 +15,9 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.util.Calendar; import java.util.Map; +import java.util.concurrent.TimeUnit; -import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMAT; import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; import static com.xhpc.pp.tx.ServiceResult.*; @@ -42,13 +40,14 @@ public class RateModelConfigReplyDataLogic implements ServiceLogic { String result = FAIL; if (HEX_01.equals(configResult)) { - final String pkey = "pile:".concat(pileRateModelConfigReplyData.getPileNo()); - Map cachePile = REDIS.getCacheMap(pkey); + final String pk = "pile:".concat(pileRateModelConfigReplyData.getPileNo()); + Map cachePile = REDIS.getCacheMap(pk); ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(cachePile.get("stationId").toString())); String version = (String) cachePile.get("version"); + Integer rateModelId = pileRateModelConfigReplyData.getRateModelId(); if (!"0A".equals(version) && !"0B".equals(version)) { Long stationRateModelId = cacheStation.getRateModelId(); - if (stationRateModelId.intValue() == pileRateModelConfigReplyData.getRateModelId()) { + if (stationRateModelId.intValue() == rateModelId) { cachePile.put("rateModelId", cacheStation.getRateModelId()); result = OK; } @@ -56,9 +55,9 @@ public class RateModelConfigReplyDataLogic implements ServiceLogic { cachePile.put("rateModelId", cacheStation.getRateModelId()); result = OK; } - String configTime = DateUtil.format(Calendar.getInstance().getTime(), NORM_DATETIME_FORMAT); - cachePile.put("configRmReply", configTime); - REDIS.setCacheMap(pkey, cachePile); + REDIS.setCacheMap(pk, cachePile); + String configTimeReply = pk.concat(".configTimeReply"); + REDIS.setCacheObject(configTimeReply, "校费设置成功,费率模型:".concat(String.valueOf(rateModelId)), 30L, TimeUnit.MINUTES); } String remark = "充电桩收到计费模型应答";