Merge branch 'tmp.zz'
This commit is contained in:
commit
1d1a716e04
@ -207,7 +207,7 @@ public class ChargingController {
|
|||||||
refreshBalanceMsg = refreshBalanceMsg.concat(CRCCalculator.calcCrc(refreshBalanceMsg));
|
refreshBalanceMsg = refreshBalanceMsg.concat(CRCCalculator.calcCrc(refreshBalanceMsg));
|
||||||
ClientHandler handler = getHandler(pileNo);
|
ClientHandler handler = getHandler(pileNo);
|
||||||
R<Object> r;
|
R<Object> r;
|
||||||
if (handler != null) { //todo 余额下发重试机制
|
if (handler != null && handler.isOpen()) { //todo 余额下发重试机制
|
||||||
if (!handler.isOpen()) {
|
if (!handler.isOpen()) {
|
||||||
log.error("[{}]({}) connection lost", handler.getName(), pileNo);
|
log.error("[{}]({}) connection lost", handler.getName(), pileNo);
|
||||||
removeHandler(pileNo);
|
removeHandler(pileNo);
|
||||||
@ -235,6 +235,11 @@ public class ChargingController {
|
|||||||
String pileNo = startChargingData.getPileNo();
|
String pileNo = startChargingData.getPileNo();
|
||||||
ClientHandler handler = ChargingPileServer.getHandler(pileNo);
|
ClientHandler handler = ChargingPileServer.getHandler(pileNo);
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
|
try {
|
||||||
|
handler.closeConnection();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("invalid conn [{}]", handler.getName());
|
||||||
|
}
|
||||||
return R.fail("充电桩没有连接到上次注册的服务器,请稍后再试一次");
|
return R.fail("充电桩没有连接到上次注册的服务器,请稍后再试一次");
|
||||||
} else if (!handler.isOpen()) {
|
} else if (!handler.isOpen()) {
|
||||||
log.error("[{}]({}) connection lost", handler.getName(), pileNo);
|
log.error("[{}]({}) connection lost", handler.getName(), pileNo);
|
||||||
@ -290,7 +295,11 @@ public class ChargingController {
|
|||||||
|
|
||||||
ClientHandler handler = ChargingPileServer.getHandler(pileNo);
|
ClientHandler handler = ChargingPileServer.getHandler(pileNo);
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
// ChargingPileServer.removeHandler(pileNo);
|
try {
|
||||||
|
handler.closeConnection();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("invalid conn [{}]", handler.getName());
|
||||||
|
}
|
||||||
return R.fail("充电桩没有连接到上次注册的服务器,请稍后再试一次");
|
return R.fail("充电桩没有连接到上次注册的服务器,请稍后再试一次");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -321,9 +330,9 @@ public class ChargingController {
|
|||||||
|
|
||||||
String pileNo = orderNo.substring(0, 14);
|
String pileNo = orderNo.substring(0, 14);
|
||||||
ClientHandler handler = ChargingPileServer.getHandler(pileNo);
|
ClientHandler handler = ChargingPileServer.getHandler(pileNo);
|
||||||
if (handler != null) {
|
if (handler != null && handler.isOpen()) {
|
||||||
try {
|
try {
|
||||||
String connectorId = pileNo.substring(0, 16);
|
String connectorId = orderNo.substring(0, 16);
|
||||||
String gunkey = "gun:".concat(connectorId);
|
String gunkey = "gun:".concat(connectorId);
|
||||||
String skey = gunkey.concat(".seqhex");
|
String skey = gunkey.concat(".seqhex");
|
||||||
String seq = seqHex(skey);
|
String seq = seqHex(skey);
|
||||||
@ -333,16 +342,22 @@ public class ChargingController {
|
|||||||
removeHandler(pileNo);
|
removeHandler(pileNo);
|
||||||
} else {
|
} else {
|
||||||
String orderkey = REDIS.getCacheMapValue(gunkey, "orderkey");
|
String orderkey = REDIS.getCacheMapValue(gunkey, "orderkey");
|
||||||
Integer sts = REDIS.getCacheMapValue(orderkey, "sts");
|
// Integer sts = REDIS.getCacheMapValue(orderkey, "sts");
|
||||||
if (orderkey != null && orderNo.equals(orderkey.substring(6)) && (sts == null)) {
|
if (orderkey != null && orderNo.equals(orderkey.substring(6))) {// && (sts == null)) {
|
||||||
handler.sendClientBinary(msg);
|
handler.sendClientBinary(msg);
|
||||||
log.error("invalid orderNo [{}], stop msg sent to pile |{}|", pileNo, HexUtils.toHex(msg));
|
log.error("invalid orderNo [{}], stop msg sent to pile |{}|", orderNo, HexUtils.toHex(msg));
|
||||||
REDIS.setCacheMapValue(orderkey, "sts", 1);
|
// REDIS.setCacheMapValue(orderkey, "sts", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("send message failed. " + e.getMessage(), e);
|
try {
|
||||||
|
handler.closeConnection();
|
||||||
|
} catch (Exception e1) {
|
||||||
|
log.error("invalid conn [{}]", handler.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if (handler != null) {
|
||||||
|
handler.closeConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -69,7 +69,7 @@ public class PileController {
|
|||||||
|
|
||||||
ClientHandler handler = getHandler(pileNo);
|
ClientHandler handler = getHandler(pileNo);
|
||||||
R r;
|
R r;
|
||||||
if (handler != null) {
|
if (handler != null && handler.isOpen()) {
|
||||||
if (!handler.isOpen()) {
|
if (!handler.isOpen()) {
|
||||||
log.error("send message failed. [{}]({}) connection lost", handler.getName(), pileNo);
|
log.error("send message failed. [{}]({}) connection lost", handler.getName(), pileNo);
|
||||||
removeHandler(pileNo);
|
removeHandler(pileNo);
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.xhpc.common.api.PileOrderService;
|
|||||||
import com.xhpc.common.core.domain.R;
|
import com.xhpc.common.core.domain.R;
|
||||||
import com.xhpc.common.data.redis.CacheOrderData;
|
import com.xhpc.common.data.redis.CacheOrderData;
|
||||||
import com.xhpc.common.data.up.OrderData;
|
import com.xhpc.common.data.up.OrderData;
|
||||||
|
import com.xhpc.pp.controller.ChargingController;
|
||||||
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;
|
||||||
@ -33,6 +34,8 @@ public class OrderDataLogic implements ServiceLogic {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileOrderService pileOrderService;
|
private PileOrderService pileOrderService;
|
||||||
|
@Autowired
|
||||||
|
private ChargingController chargingController;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServiceResult service(ServiceParameter sp) throws Exception {
|
public ServiceResult service(ServiceParameter sp) throws Exception {
|
||||||
@ -70,14 +73,11 @@ public class OrderDataLogic implements ServiceLogic {
|
|||||||
String resultStr =
|
String resultStr =
|
||||||
"6815".concat(req.get("seqhex").toString()).concat("0040").concat(orderNo).concat(ServiceResult.HEX_00);
|
"6815".concat(req.get("seqhex").toString()).concat("0040").concat(orderNo).concat(ServiceResult.HEX_00);
|
||||||
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
|
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
|
||||||
if (orderNo.equals("00000000000000000000000000000000")) {
|
|
||||||
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK);
|
|
||||||
}
|
|
||||||
final R r = pileOrderService.pileEndOrder(orderNo);
|
final R r = pileOrderService.pileEndOrder(orderNo);
|
||||||
if (r.getCode() == 200)
|
if (orderNo.equals("00000000000000000000000000000000") || (r.getMsg() != null && r.getMsg().contains("无效订单"))) {
|
||||||
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK);
|
log.error(">>INVALID order [{}] detected. MUST check the system.<<", orderNo);
|
||||||
else
|
}
|
||||||
return new ServiceResult(ServiceResult.FAIL);
|
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CacheOrderData translate(OrderData orderData) throws InvocationTargetException, IllegalAccessException, InstantiationException {
|
private CacheOrderData translate(OrderData orderData) throws InvocationTargetException, IllegalAccessException, InstantiationException {
|
||||||
|
|||||||
@ -150,7 +150,7 @@ public class RealtimeDataLogic implements ServiceLogic {
|
|||||||
R r1 = pileOrderService.pileRimeOrder(orderNo);
|
R r1 = pileOrderService.pileRimeOrder(orderNo);
|
||||||
String msg = r1.getMsg();
|
String msg = r1.getMsg();
|
||||||
if (msg!=null && msg.contains("无效订单")) {
|
if (msg!=null && msg.contains("无效订单")) {
|
||||||
chargingController.stopInvalidOrder(pileNo);
|
chargingController.stopInvalidOrder(orderNo);
|
||||||
} else {
|
} else {
|
||||||
Integer vul = (Integer) cachePile.get("voltageUpperLimits");
|
Integer vul = (Integer) cachePile.get("voltageUpperLimits");
|
||||||
Integer cul = (Integer) cachePile.get("currentLimit");
|
Integer cul = (Integer) cachePile.get("currentLimit");
|
||||||
|
|||||||
@ -32,11 +32,11 @@ public class ChargingPileEventHandler implements ClientEventHandler {
|
|||||||
public void lostConnection(ClientHandler handler) {
|
public void lostConnection(ClientHandler handler) {
|
||||||
|
|
||||||
String pileNo = ChargingPileServer.getPileNo(handler);
|
String pileNo = ChargingPileServer.getPileNo(handler);
|
||||||
// if (pileNo != null) {
|
if (pileNo != null) {
|
||||||
// ChargingPileServer.disconnPileNGuns(pileNo);
|
ChargingPileServer.disconnPileNGuns(pileNo);
|
||||||
// }
|
log.debug("<- ({}) -disconn- [{}] - {} ->", pileNo, handler.getName(),
|
||||||
log.debug("<- ({}) - [{}] - {} ->",
|
handler.getSocket().getRemoteSocketAddress().toString());
|
||||||
pileNo, handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user