tf after reg; log rmv ost to debug at prod/test env

This commit is contained in:
ZZ 2021-08-18 11:39:31 +08:00
parent 261173783d
commit f2e711390c
2 changed files with 17 additions and 9 deletions

View File

@ -8,7 +8,6 @@ import com.xhpc.common.data.up.RealtimeData;
import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic; import com.xhpc.pp.tx.logic.ServiceLogic;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -117,11 +116,13 @@ public class RealtimeDataLogic implements ServiceLogic {
Long orderstarttime = (Long) cacheGun.get("orderstarttime"); Long orderstarttime = (Long) cacheGun.get("orderstarttime");
Long orderstoptime = (Long) cacheGun.get("orderstoptime"); Long orderstoptime = (Long) cacheGun.get("orderstoptime");
orderkey = (String) cacheGun.get("orderkey"); orderkey = (String) cacheGun.get("orderkey");
log.info("--0s order rtd--");
if (orderstarttime != null && orderkey != null && realtimeDataList == null && Calendar.getInstance().getTimeInMillis() - orderstarttime > 90 * 1000) { if (orderstarttime != null && orderkey != null && realtimeDataList == null && Calendar.getInstance().getTimeInMillis() - orderstarttime > 90 * 1000) {
pileOrderService.pileStartup(orderNo, 2, "终端90秒内没有响应"); pileOrderService.pileStartup(orderNo, 2, "终端90秒内没有响应");
cacheGun.remove("orderkey"); cacheGun.remove("orderkey");
cacheGun.remove("orderstarttime"); cacheGun.remove("orderstarttime");
REDIS.setCacheMap(gunkey, cacheGun); REDIS.setCacheMap(gunkey, cacheGun);
log.info("--rmv ost--");
} else if (orderstoptime != null && orderkey != null && Calendar.getInstance().getTimeInMillis() - orderstoptime > 90 * 1000) { } else if (orderstoptime != null && orderkey != null && Calendar.getInstance().getTimeInMillis() - orderstoptime > 90 * 1000) {
pileOrderService.pileStop(orderNo, 2, "终端90秒内没有响应"); pileOrderService.pileStop(orderNo, 2, "终端90秒内没有响应");
cacheGun.remove("orderstoptime"); cacheGun.remove("orderstoptime");

View File

@ -92,7 +92,10 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
ServiceResult result = servicemainLogic.process(sp); ServiceResult result = servicemainLogic.process(sp);
String resultCode = result.getCode(); String resultCode = result.getCode();
String pilekey = "pile:".concat(pileNo); String pilekey = "pile:".concat(pileNo);
Map<String, Object> cachePile = REDIS.getCacheMap(pilekey);
if (SERVICE_REGISTER.equals(serviceName) && OK.equals(resultCode)) { if (SERVICE_REGISTER.equals(serviceName) && OK.equals(resultCode)) {
cachePile.put("tf", false);
REDIS.setCacheMap(pilekey, cachePile);
regHandler(handler, pileNo, req); regHandler(handler, pileNo, req);
} else if (SERVICE_RMCR.equals(serviceName) && OK.equals(resultCode)) { } else if (SERVICE_RMCR.equals(serviceName) && OK.equals(resultCode)) {
setCachePileRM(pilekey); setCachePileRM(pilekey);
@ -102,14 +105,18 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
handler.sendClientBinary(result.getBinary()); handler.sendClientBinary(result.getBinary());
if (SERVICE_RMR.equals(serviceName) && OK.equals(resultCode)) { if (SERVICE_RMR.equals(serviceName) && OK.equals(resultCode)) {
setCachePileRM(pilekey); setCachePileRM(pilekey);
} else if (SERVICE_REGISTER.equals(serviceName) && OK.equals(resultCode)) { } else if (SERVICE_HB.equals(serviceName) && OK.equals(resultCode)) {
Date date = Calendar.getInstance().getTime(); Boolean timeconfigured = (Boolean) cachePile.get("tf");
String timebin = getTimeBin(seqHex(pilekey.concat("seqhex")), pileNo, date); if (!timeconfigured) {
Map<String, Object> cachePile = REDIS.getCacheMap(pilekey); Date date = Calendar.getInstance().getTime();
cachePile.put("configTime", DateUtil.format(date, UTC_SIMPLE_PATTERN)); String timebin = getTimeBin(seqHex(pilekey.concat("seqhex")), pileNo, date);
REDIS.setCacheMap(pilekey, cachePile); cachePile.put("configTime", DateUtil.format(date, UTC_SIMPLE_PATTERN));
log.info("server send time config msg >>>> ({}) |{}|", pileNo, timebin); REDIS.setCacheMap(pilekey, cachePile);
handler.sendClientBinary(HexUtils.toBytes(timebin)); log.info("server send time config msg >>>> ({}) |{}|", pileNo, timebin);
handler.sendClientBinary(HexUtils.toBytes(timebin));
cachePile.put("tf", true);
REDIS.setCacheMap(pilekey, cachePile);
}
} }
} }
} }