缓存枪状态字段处理逻辑完善
This commit is contained in:
parent
6aec7b24dd
commit
ec40bfde74
@ -23,7 +23,9 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMAT;
|
import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMAT;
|
||||||
@ -39,6 +41,7 @@ public class ChargingController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PowerPileService powerPileService;
|
private PowerPileService powerPileService;
|
||||||
|
private static List<String> etable = Arrays.asList((new String[]{"离线", "故障"}).clone());
|
||||||
|
|
||||||
@PostMapping("test/pile/charging/order")
|
@PostMapping("test/pile/charging/order")
|
||||||
public R test(@Validated @RequestBody StartChargingData startChargingData) {
|
public R test(@Validated @RequestBody StartChargingData startChargingData) {
|
||||||
@ -98,7 +101,6 @@ public class ChargingController {
|
|||||||
Long pileRateModelId = (Long) cachePile.get("rateModelId");
|
Long pileRateModelId = (Long) cachePile.get("rateModelId");
|
||||||
cachePile.put("rateModelId", pileRateModelId);
|
cachePile.put("rateModelId", pileRateModelId);
|
||||||
if (!stationRateModelId.equals(pileRateModelId)) {
|
if (!stationRateModelId.equals(pileRateModelId)) {
|
||||||
if (cachePile.get("status").toString().equals(REGISTERED)) {
|
|
||||||
CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(stationRateModelId.toString()));
|
CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(stationRateModelId.toString()));
|
||||||
String rateModel = RateModelRequestLogic.translate(cacheRateModel);
|
String rateModel = RateModelRequestLogic.translate(cacheRateModel);
|
||||||
String gunkey = "gun:".concat(pileNo).concat(startChargingData.getGunId());
|
String gunkey = "gun:".concat(pileNo).concat(startChargingData.getGunId());
|
||||||
@ -117,9 +119,6 @@ public class ChargingController {
|
|||||||
} else {
|
} else {
|
||||||
r = R.fail(responseJson.get("data"), responseJson.getString("msg"));
|
r = R.fail(responseJson.get("data"), responseJson.getString("msg"));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
r = R.fail("充电桩离线,费率模型未更新或下发");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
JSONObject json = (JSONObject) JSON.toJSON(startChargingData);
|
JSONObject json = (JSONObject) JSON.toJSON(startChargingData);
|
||||||
String response = HttpUtils.post(fmt(svcSrv).concat("/native/charging/start"), json);
|
String response = HttpUtils.post(fmt(svcSrv).concat("/native/charging/start"), json);
|
||||||
@ -135,8 +134,8 @@ public class ChargingController {
|
|||||||
return R.fail("充电桩未注册");
|
return R.fail("充电桩未注册");
|
||||||
}
|
}
|
||||||
String status = cachePile.get("status").toString();
|
String status = cachePile.get("status").toString();
|
||||||
if (!REGISTERED.equals(status)) {
|
if (etable.contains(status)) {
|
||||||
return R.fail("充电桩离线");
|
return R.fail("充电桩无法响应,状态:".concat(status));
|
||||||
}
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public class RealtimeDataLogic implements ServiceLogic {
|
|||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(RealtimeDataLogic.class);
|
private static Logger log = LoggerFactory.getLogger(RealtimeDataLogic.class);
|
||||||
|
|
||||||
public static final String[] stable = {"离线", "故障", "空闲", "充电"};
|
public static final String[] stable = {"离线", "故障", "空闲", "充电中"};
|
||||||
public static final String[] pvgstable = {"否", "是", "未知"};
|
public static final String[] pvgstable = {"否", "是", "未知"};
|
||||||
private static final String[] hftable = {"急停按钮动作故障", "无可用整流模块", "出风口温度过高", "交流防雷故障", "交直流模块DC20通信中断", "绝缘检测模块FC08通信中断", "电度表通信中断", "读卡器通信中断", "RC10通信中断", "风扇调速板故障", "直流熔断器故障", "高压接触器故障", "门打开"};
|
private static final String[] hftable = {"急停按钮动作故障", "无可用整流模块", "出风口温度过高", "交流防雷故障", "交直流模块DC20通信中断", "绝缘检测模块FC08通信中断", "电度表通信中断", "读卡器通信中断", "RC10通信中断", "风扇调速板故障", "直流熔断器故障", "高压接触器故障", "门打开"};
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class RealtimeDataLogic implements ServiceLogic {
|
|||||||
String stationTermStatusKey = "stationTerminalStatus:".concat(cachePile.get("stationId").toString());
|
String stationTermStatusKey = "stationTerminalStatus:".concat(cachePile.get("stationId").toString());
|
||||||
String statusOrSOC;
|
String statusOrSOC;
|
||||||
Integer socInt = Integer.parseInt(soc, 16);
|
Integer socInt = Integer.parseInt(soc, 16);
|
||||||
if (statusplain.equals("充电")) {
|
if (statusplain.equals("充电中")) {
|
||||||
statusOrSOC = socInt.toString();
|
statusOrSOC = socInt.toString();
|
||||||
} else {
|
} else {
|
||||||
statusOrSOC = statusplain;
|
statusOrSOC = statusplain;
|
||||||
|
|||||||
@ -22,8 +22,8 @@ import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
|||||||
@Component("RegisterLogic")
|
@Component("RegisterLogic")
|
||||||
public class RegisterLogic implements ServiceLogic {
|
public class RegisterLogic implements ServiceLogic {
|
||||||
|
|
||||||
public static final String DISCONNECTED = "Disconnected";
|
public static final String DISCONNECTED = "离线";
|
||||||
public static final String REGISTERED = "Registered";
|
public static final String REGISTERED = "已注册";
|
||||||
private static Logger log = LoggerFactory.getLogger(RegisterLogic.class);
|
private static Logger log = LoggerFactory.getLogger(RegisterLogic.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.xhpc.pp.server;
|
package com.xhpc.pp.server;
|
||||||
|
|
||||||
import com.xhpc.pp.logic.RegisterLogic;
|
|
||||||
import org.quickserver.net.server.ClientEventHandler;
|
import org.quickserver.net.server.ClientEventHandler;
|
||||||
import org.quickserver.net.server.ClientHandler;
|
import org.quickserver.net.server.ClientHandler;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -10,6 +9,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.xhpc.pp.logic.RegisterLogic.DISCONNECTED;
|
||||||
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||||
|
|
||||||
@Lazy(false)
|
@Lazy(false)
|
||||||
@ -46,7 +46,7 @@ public class ChargingPileEventHandler implements ClientEventHandler {
|
|||||||
ChargingPileServer.removeHandler(pileNo);
|
ChargingPileServer.removeHandler(pileNo);
|
||||||
String pkey = "pile:".concat(pileNo);
|
String pkey = "pile:".concat(pileNo);
|
||||||
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
||||||
cachePile.put("status", RegisterLogic.DISCONNECTED);
|
cachePile.put("status", DISCONNECTED);
|
||||||
REDIS.setCacheMap(pkey, cachePile);
|
REDIS.setCacheMap(pkey, cachePile);
|
||||||
handler.closeConnection();
|
handler.closeConnection();
|
||||||
log.info("-> ({}) - [{}] <- {}", pileNo, handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
|
log.info("-> ({}) - [{}] <- {}", pileNo, handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
|
||||||
|
|||||||
@ -95,7 +95,7 @@ public class ChargingPileServer {
|
|||||||
String gunkey = "gun:".concat(pileNo).concat(String.format("%02d", i));
|
String gunkey = "gun:".concat(pileNo).concat(String.format("%02d", i));
|
||||||
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||||
if (cacheGun != null) {
|
if (cacheGun != null) {
|
||||||
cacheGun.put("status", "离线");
|
cacheGun.put("status", DISCONNECTED);
|
||||||
REDIS.setCacheMap(gunkey, cacheGun);
|
REDIS.setCacheMap(gunkey, cacheGun);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user