修复QueryStopCharge接口的pushOrder逻辑

This commit is contained in:
wen 2021-11-10 17:32:19 +08:00
parent 24a1d74cf2
commit 1917760e11

View File

@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
@ -82,16 +81,15 @@ public class QueryStopChargeController {
String pileNum = connectorId.substring(0, connectorId.length() - 2); String pileNum = connectorId.substring(0, connectorId.length() - 2);
//从数据库中查询对应的桩的版本信息 //从数据库中查询对应的桩的版本信息
XhpcChargingPile pileInfo = XhpcChargingPileRepository.findBySerialNumber(pileNum).orElse(null); XhpcChargingPile pileInfo = XhpcChargingPileRepository.findBySerialNumber(pileNum).orElse(null);
String versionNum = null; String versionNum = pileInfo.getCommunicationProtocolVersion() != null ? pileInfo.getCommunicationProtocolVersion() : "0A";
if (pileInfo != null) {
versionNum = pileInfo.getCommunicationProtocolVersion();
}
//给对应的枪发送停止充电指令 //给对应的枪发送停止充电指令
R r = powerPileService.stopCharging(xhOrderNo, pileNum, connectorId, versionNum); R r = powerPileService.stopCharging(xhOrderNo, pileNum, connectorId, versionNum);
// 判断停止指令发送是否成功 // 判断停止指令发送是否成功
if (r.getCode() != 200) { if (r.getCode() != 200) {
//向redis中放入停止充电指令没有下发成功的标识
Map<String, Object> pushOrder = REDIS.getCacheMap("pushOrder:".concat(xhOrderNo));
pushOrder.put("stopCommandSent", false);
REDIS.setCacheMap("pushOrder:".concat(xhOrderNo), pushOrder);
//充电订单状态 //充电订单状态
queryStopChargeResponse.setStartChargeSeqStat(5); queryStopChargeResponse.setStartChargeSeqStat(5);
//操作结果 //操作结果
@ -128,14 +126,17 @@ public class QueryStopChargeController {
commonResponse.setRet("1"); commonResponse.setRet("1");
commonResponse.setMsg("请求停止充电失败"); commonResponse.setMsg("请求停止充电失败");
commonResponse.setData(data); commonResponse.setData(data);
} }
//设置该订单已经被停止的标识 //设置该订单已经被停止的标识
Map<String, Object> order = REDIS.getCacheMap("order:" + xhOrderNo); Map<String, Object> order = REDIS.getCacheMap("order:" + xhOrderNo);
order.replace("status", "已结束"); order.replace("status", "已结束");
REDIS.setCacheMap("order:" + xhOrderNo, order); REDIS.setCacheMap("order:" + xhOrderNo, order);
HashMap<String, Object> pushOrder = new HashMap<>(16);
Map<String, Object> pushOrder = REDIS.getCacheMap("pushOrder:".concat(xhOrderNo));
pushOrder.put("stopCommandSent", true); pushOrder.put("stopCommandSent", true);
pushOrder.put("operatorId3rdpty", startChargeSeq.substring(0, 9));
REDIS.setCacheMap("pushOrder:".concat(xhOrderNo), pushOrder); REDIS.setCacheMap("pushOrder:".concat(xhOrderNo), pushOrder);
//充电订单状态 //充电订单状态