Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
68d1b2e4cd
@ -41,7 +41,7 @@ public class ChargingController {
|
||||
|
||||
@Autowired
|
||||
private PowerPileService powerPileService;
|
||||
private static List<String> etable = Arrays.asList((new String[]{"离线", "故障"}).clone());
|
||||
private static final List<String> etable = Arrays.asList((new String[]{"离线", "故障"}).clone());
|
||||
|
||||
@PostMapping("test/pile/charging/order")
|
||||
public R test(@Validated @RequestBody StartChargingData startChargingData) {
|
||||
@ -77,7 +77,7 @@ public class ChargingController {
|
||||
r = R.fail("Native服务调用失败");
|
||||
} else {
|
||||
int code = responseJson.getInteger("code");
|
||||
log.info(response);
|
||||
log.debug(response);
|
||||
if (code != 200) {//todo rat
|
||||
r = R.fail(code, responseJson.getString("msg"));
|
||||
} else {
|
||||
@ -204,7 +204,7 @@ public class ChargingController {
|
||||
r = R.fail("网络连接断开,无法刷新桩上余额");
|
||||
} else {
|
||||
try {
|
||||
log.info("native refresh balance >>> {}", refreshBalanceMsg);
|
||||
log.debug("native refresh balance >>> {}", refreshBalanceMsg);
|
||||
handler.sendClientBinary(HexUtils.toBytes(refreshBalanceMsg));
|
||||
r = R.ok("余额刷新指令已下发");
|
||||
} catch (IOException e) {
|
||||
@ -326,7 +326,7 @@ public class ChargingController {
|
||||
}
|
||||
String msg = HexUtils.toHex(data);
|
||||
msg = msg.concat(CRCCalculator.calcCrc(msg));
|
||||
log.info("start charging order[{}], send msg >>>> |{}|", startChargingData.getOrderNo(), msg);
|
||||
log.debug("start charging order[{}], send msg >>>> |{}|", startChargingData.getOrderNo(), msg);
|
||||
return HexUtils.toBytes(msg);
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ public class ChargingController {
|
||||
}
|
||||
String msg = HexUtils.toHex(data);
|
||||
msg = msg.concat(CRCCalculator.calcCrc(msg));
|
||||
log.info("stop charging, send msg to terminal ({}) >>>> {}", connectorId, msg);
|
||||
log.debug("stop charging, send msg to terminal ({}) >>>> {}", connectorId, msg);
|
||||
return HexUtils.toBytes(msg);
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ public class PileController {
|
||||
r = R.fail("充电桩连接已断开,请稍后再试");
|
||||
} else {
|
||||
try {
|
||||
log.info("[{}] - server send msg >>>> ({}) |{}|", handler.getName(), pileNo, msg);
|
||||
log.debug("[{}] - server send msg >>>> ({}) |{}|", handler.getName(), pileNo, msg);
|
||||
handler.sendClientBinary(HexUtils.toBytes(msg));
|
||||
r = R.ok(null, "网络延迟,请重试");
|
||||
} catch (IOException e) {
|
||||
|
||||
@ -16,7 +16,7 @@ import java.util.Map;
|
||||
@Component("BalanceUpdateReplyDataLogic")
|
||||
public class BalanceUpdateReplyDataLogic implements ServiceLogic {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(BalanceUpdateReplyDataLogic.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(BalanceUpdateReplyDataLogic.class);
|
||||
|
||||
@Override
|
||||
public ServiceResult service(ServiceParameter sp) throws Exception {
|
||||
@ -24,7 +24,7 @@ public class BalanceUpdateReplyDataLogic implements ServiceLogic {
|
||||
Map<String, Object> req = sp.getParameters();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
BalanceUpdateReplyData balanceUpdateReplyData = objectMapper.convertValue(req, BalanceUpdateReplyData.class);
|
||||
log.info("balanceUpdateResult({}) [{}]", balanceUpdateReplyData.getPileNo(), balanceUpdateReplyData.getModifyResult());
|
||||
log.debug("balanceUpdateResult({}) [{}]", balanceUpdateReplyData.getPileNo(), balanceUpdateReplyData.getModifyResult());
|
||||
return new ServiceResult(false);
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import static com.xhpc.pp.utils.security.CP56Time2a.cp56toDate;
|
||||
@Component("PileTimeConfigReplyDataLogic")
|
||||
public class PileTimeConfigReplyDataLogic implements ServiceLogic {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(PileTimeConfigReplyDataLogic.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(PileTimeConfigReplyDataLogic.class);
|
||||
|
||||
@Override
|
||||
public ServiceResult service(ServiceParameter sp) throws Exception {
|
||||
@ -35,7 +35,7 @@ public class PileTimeConfigReplyDataLogic implements ServiceLogic {
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pk);
|
||||
cachePile.put("configTime", configTime);
|
||||
REDIS.setCacheMap(pk, cachePile);
|
||||
log.info("({}) set time success√: [{}]", pileNo, configTime);
|
||||
log.debug("({}) set time success√: [{}]", pileNo, configTime);
|
||||
return new ServiceResult(false);
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ public class RegisterLogic implements ServiceLogic {
|
||||
|
||||
public static final String DISCONNECTED = "离线";
|
||||
public static final String REGISTERED = "已注册";
|
||||
private static Logger log = LoggerFactory.getLogger(RegisterLogic.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(RegisterLogic.class);
|
||||
|
||||
@Override
|
||||
public ServiceResult service(ServiceParameter sp) throws Exception {
|
||||
@ -36,11 +36,11 @@ public class RegisterLogic implements ServiceLogic {
|
||||
String pileNo = (String) req.get("pileNo");
|
||||
Set<String> whitelist = REDIS.getCacheSet("PILE_WHITELIST");
|
||||
if (!whitelist.contains(pileNo)) {
|
||||
log.info("pile not in whitelist ({}) ", pileNo);
|
||||
log.debug("pile not in whitelist ({}) ", pileNo);
|
||||
hexCode = ServiceResult.HEX_01;
|
||||
resultCode = ServiceResult.FAIL;
|
||||
// } else if (!EarlierBeanConf.ifcanreg(pileNo)) { // not a stable reliable method
|
||||
// log.info("pile already registered ({}) ", pileNo);
|
||||
// log.debug("pile already registered ({}) ", pileNo);
|
||||
// hexCode = ServiceResult.HEX_01;
|
||||
// resultCode = ServiceResult.FAIL;
|
||||
} else {
|
||||
@ -70,7 +70,7 @@ public class RegisterLogic implements ServiceLogic {
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("pile (re)registered ({}) ", pileNo);
|
||||
log.debug("pile (re)registered ({}) ", pileNo);
|
||||
}
|
||||
String skey = "pile:".concat(pileNo).concat(".seqhex");
|
||||
String seq = seqHex(skey);
|
||||
|
||||
@ -62,9 +62,9 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
||||
for (byte[] d : dataList) {
|
||||
String dataStr = toHex(d);
|
||||
String pileNo = ChargingPileServer.getPileNo(handler);
|
||||
log.info("received data <<<< |{}| from pile <- ({})", dataStr, pileNo);
|
||||
log.debug("received data <<<< |{}| from pile <- ({})", dataStr, pileNo);
|
||||
if (d.length <= 2 || !dataStr.startsWith("68")) {
|
||||
log.info("received invalid data <<<< |{}|, len[{}]", dataStr, d.length);
|
||||
log.debug("received invalid data <<<< |{}|, len[{}]", dataStr, d.length);
|
||||
continue;
|
||||
}
|
||||
int len = HexUtils.toInteger(d, 1, 2);
|
||||
@ -114,7 +114,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
||||
log.error("send message failed. [{}]({}) connection lost", handler.getName(), pileNo);
|
||||
removeHandler(pileNo);
|
||||
} else {
|
||||
log.info("server send msg >>>> ({}) |{}|", pileNo, toHex(result.getBinary()));
|
||||
log.debug("server send msg >>>> ({}) |{}|", pileNo, toHex(result.getBinary()));
|
||||
handler.sendClientBinary(result.getBinary());
|
||||
}
|
||||
if (SERVICE_HB.equals(serviceName) && OK.equals(resultCode)) {
|
||||
@ -126,7 +126,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
||||
String timebin = getTimeBin(seqHex(skey), pileNo, date);
|
||||
cachePile.put("configTime", DateUtil.format(date, NORM_DATETIME_FORMAT));
|
||||
REDIS.setCacheMap(pilekey, cachePile);
|
||||
log.info("server send time config msg >>>> ({}) |{}|", pileNo, timebin);
|
||||
log.debug("server send time config msg >>>> ({}) |{}|", pileNo, timebin);
|
||||
if (!handler.isOpen()) {
|
||||
log.error("send message failed. [{}]({}) connection lost", handler.getName(), pileNo);
|
||||
removeHandler(pileNo);
|
||||
@ -162,7 +162,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
||||
ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(cachePile.get("stationId").toString()));
|
||||
cachePile.put("rateModelId", cacheStation.getRateModelId());
|
||||
REDIS.setCacheMap(pilekey, cachePile);
|
||||
log.info("rate model responds success√");
|
||||
log.debug("rate model responds success√");
|
||||
}
|
||||
|
||||
private List<byte[]> parseDataList(byte[] data) {
|
||||
@ -173,8 +173,11 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
||||
int start = 0;
|
||||
while (start < data.length) {
|
||||
if (len > data.length) {
|
||||
log.error("incorrect input data|{}| len[{}]", toHex(data), data.length);
|
||||
break;
|
||||
String hex = toHex(data);
|
||||
if (!hex.startsWith("25", 10)) {
|
||||
log.error("incorrect input data|{}| len[{}]", hex, data.length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
dataList.add(ArrayUtils.subarray(data, start, start + len));
|
||||
processedLen += len;
|
||||
@ -182,7 +185,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
||||
len = HexUtils.toInteger(data, start + 1, start + 2) + 4;
|
||||
}
|
||||
if (dataList.size() > 1) {
|
||||
log.info("detected stick package size[{}]", dataList.size());
|
||||
log.debug("detected stick package size[{}]", dataList.size());
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
@Repository
|
||||
public class ChargingPileCommandHandler implements ClientCommandHandler {
|
||||
@ -19,9 +18,9 @@ public class ChargingPileCommandHandler implements ClientCommandHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(ClientHandler handler, String appData) throws SocketTimeoutException, IOException {
|
||||
public void handleCommand(ClientHandler handler, String appData) throws IOException {
|
||||
|
||||
log.info("handleCommand <====" + appData);
|
||||
log.debug("handleCommand <====" + appData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ public class ChargingPileEventHandler implements ClientEventHandler {
|
||||
@Override
|
||||
public void gotConnected(ClientHandler handler) {
|
||||
|
||||
log.info("-> [{}] - {} <-", handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
|
||||
log.debug("-> [{}] - {} <-", handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -35,7 +35,7 @@ public class ChargingPileEventHandler implements ClientEventHandler {
|
||||
// if (pileNo != null) {
|
||||
// ChargingPileServer.disconnPileNGuns(pileNo);
|
||||
// }
|
||||
log.info("<- ({}) - [{}] - {} ->",
|
||||
log.debug("<- ({}) - [{}] - {} ->",
|
||||
pileNo, handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public class ChargingPileEventHandler implements ClientEventHandler {
|
||||
cachePile.put("status", DISCONNECTED);
|
||||
REDIS.setCacheMap(pkey, cachePile);
|
||||
handler.closeConnection();
|
||||
log.info("<- ({}) - [{}] - {} ->", pileNo, handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
|
||||
log.debug("<- ({}) - [{}] - {} ->", pileNo, handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -33,9 +33,9 @@ public class ChargingPileServer {
|
||||
|
||||
public static final String default_version = "0A";
|
||||
private static final Logger log = LoggerFactory.getLogger(ChargingPileServer.class);
|
||||
private static Map<String, ClientHandler> handlerMap = new HashMap<>();
|
||||
private static Map<String, String> versionMapper = new HashMap<>();
|
||||
private static Map<String, String> pileMap = new HashMap<>();
|
||||
private static final Map<String, ClientHandler> handlerMap = new HashMap<>();
|
||||
private static final Map<String, String> versionMapper = new HashMap<>();
|
||||
private static final Map<String, String> pileMap = new HashMap<>();
|
||||
private QuickServer server;
|
||||
|
||||
@Autowired
|
||||
@ -62,7 +62,7 @@ public class ChargingPileServer {
|
||||
config.setTimeout(90 * 1000);
|
||||
server.initService(config);
|
||||
server.startServer();
|
||||
log.info("pp svc started at {}:{} ....", host, port);
|
||||
log.debug("pp svc started at {}:{} ....", host, port);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("pp svc start error: " + e);
|
||||
@ -79,7 +79,7 @@ public class ChargingPileServer {
|
||||
|
||||
ClientHandler handler = handlerMap.remove(pileNo);
|
||||
handler.closeConnection();
|
||||
log.info("handler [{}] for ({}) close connection", handler.getName(), pileNo);
|
||||
log.debug("handler [{}] for ({}) close connection", handler.getName(), pileNo);
|
||||
String pkey = "pile:".concat(pileNo);
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
||||
putemDisconn(pileNo, cachePile);
|
||||
@ -113,20 +113,20 @@ public class ChargingPileServer {
|
||||
|
||||
ClientHandler handler = handlerMap.remove(pileNo);
|
||||
// handler.closeConnection();
|
||||
// log.info("handler [{}] for ({}) close connection", handler.getName(), pileNo);
|
||||
// log.debug("handler [{}] for ({}) close connection", handler.getName(), pileNo);
|
||||
String pkey = "pile:".concat(pileNo);
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
||||
cachePile.put("status", DISCONNECTED);
|
||||
REDIS.setCacheMap(pkey, cachePile);
|
||||
putemDisconn(pileNo, cachePile);
|
||||
log.info("remove handler [{}] for ({})", handler.getName(), pileNo);
|
||||
log.debug("remove handler [{}] for ({})", handler.getName(), pileNo);
|
||||
pileMap.remove(handler.getName());
|
||||
versionMapper.remove(handler.getName());
|
||||
}
|
||||
|
||||
public static void sendClientMsg(String pileNo, byte[] msg) {
|
||||
|
||||
log.info("server send msg >>>> ({}) |{}|", pileNo, HexUtils.toHex(msg));
|
||||
log.debug("server send msg >>>> ({}) |{}|", pileNo, HexUtils.toHex(msg));
|
||||
if (pileNo.length() < 14) {
|
||||
pileNo = "0000000000000000" + pileNo;
|
||||
pileNo = pileNo.substring(pileNo.length() - 14);
|
||||
|
||||
@ -59,13 +59,13 @@
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.xhpc" level="info"/>
|
||||
<logger name="com.xhpc" level="debug"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
<!-- nacos -->
|
||||
<logger name="com.alibaba.nacos" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<root level="debug">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user