订单启停状态
This commit is contained in:
parent
7bfc31e2a0
commit
8a49b1da68
@ -40,7 +40,10 @@ public class ChargingController {
|
|||||||
@PostMapping("test/pile/charging/order")
|
@PostMapping("test/pile/charging/order")
|
||||||
public Object test(@Validated @RequestBody StartChargingData startChargingData) {
|
public Object test(@Validated @RequestBody StartChargingData startChargingData) {
|
||||||
|
|
||||||
R r = powerPileService.startCharging(startChargingData);
|
R r = R.ok();
|
||||||
|
for (int i = 0; i < startChargingData.getBalance(); i++) {
|
||||||
|
r = powerPileService.startCharging(startChargingData);
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,6 +210,8 @@ public class ChargingController {
|
|||||||
cacheOrder.put("balance", balance);
|
cacheOrder.put("balance", balance);
|
||||||
cacheOrder.put("tel", startChargingData.getTel());
|
cacheOrder.put("tel", startChargingData.getTel());
|
||||||
REDIS.setCacheMap(orderkey, cacheOrder);
|
REDIS.setCacheMap(orderkey, cacheOrder);
|
||||||
|
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||||
|
cacheGun.put("orderkey", orderkey);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("send message failed. " + e.getMessage(), e);
|
log.error("send message failed. " + e.getMessage(), e);
|
||||||
|
|||||||
@ -38,10 +38,6 @@ public class PileController {
|
|||||||
cacheStation.getPiles().addAll(pileNoSet);
|
cacheStation.getPiles().addAll(pileNoSet);
|
||||||
}
|
}
|
||||||
REDIS.setCacheObject(stationKey, cacheStation);
|
REDIS.setCacheObject(stationKey, cacheStation);
|
||||||
String rmskey = "rateModelStation:".concat(stationId.toString());
|
|
||||||
Set<String> cacheSettingRateModelSet = REDIS.getCacheSet(rmskey);
|
|
||||||
cacheSettingRateModelSet.addAll(pileNoSet);
|
|
||||||
REDIS.setCacheSet(rmskey, cacheSettingRateModelSet);
|
|
||||||
for (String pileNo : pileNoSet) {
|
for (String pileNo : pileNoSet) {
|
||||||
String pkey = "pile:".concat(pileNo);
|
String pkey = "pile:".concat(pileNo);
|
||||||
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
||||||
@ -61,10 +57,6 @@ public class PileController {
|
|||||||
ChargingStationDto cacheStation = REDIS.getCacheObject(stationKey);
|
ChargingStationDto cacheStation = REDIS.getCacheObject(stationKey);
|
||||||
cacheStation.getPiles().removeAll(pileNoSet);
|
cacheStation.getPiles().removeAll(pileNoSet);
|
||||||
REDIS.setCacheObject(stationKey, cacheStation);
|
REDIS.setCacheObject(stationKey, cacheStation);
|
||||||
String rmskey = "rateModelStation:".concat(stationId.toString());
|
|
||||||
Set<String> cacheSettingRateModelSet = REDIS.getCacheSet(rmskey);
|
|
||||||
cacheSettingRateModelSet.removeAll(pileNoSet);
|
|
||||||
REDIS.setCacheSet(rmskey, cacheSettingRateModelSet);
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -25,11 +23,6 @@ public class StationController {
|
|||||||
REDIS.setCacheObject(skey, cacheStation);
|
REDIS.setCacheObject(skey, cacheStation);
|
||||||
String rkey = "rateModel:".concat(rateModelId.toString());
|
String rkey = "rateModel:".concat(rateModelId.toString());
|
||||||
REDIS.setCacheObject(rkey, rateModel);
|
REDIS.setCacheObject(rkey, rateModel);
|
||||||
Set<String> piles = cacheStation.getPiles();
|
|
||||||
if (piles!=null) {
|
|
||||||
String rmskey = "rateModelStation:".concat(stationId.toString());
|
|
||||||
REDIS.setCacheSet(rmskey, piles);
|
|
||||||
}
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package com.xhpc.pp.logic;
|
package com.xhpc.pp.logic;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.xhpc.common.data.up.PileStartChargingData;
|
import com.xhpc.common.data.up.RemoteStartReplyData;
|
||||||
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;
|
||||||
@ -12,6 +12,8 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component("RemoteStartReplyDataLogic")
|
@Component("RemoteStartReplyDataLogic")
|
||||||
public class RemoteStartReplyDataLogic implements ServiceLogic {
|
public class RemoteStartReplyDataLogic implements ServiceLogic {
|
||||||
@ -23,8 +25,13 @@ public class RemoteStartReplyDataLogic implements ServiceLogic {
|
|||||||
|
|
||||||
Map<String, Object> req = sp.getParameters();
|
Map<String, Object> req = sp.getParameters();
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
PileStartChargingData pileStartChargingData = objectMapper.convertValue(req, PileStartChargingData.class);
|
RemoteStartReplyData remoteStartReplyData = objectMapper.convertValue(req, RemoteStartReplyData.class);
|
||||||
//todo
|
String orderNo = remoteStartReplyData.getOrderNo();
|
||||||
|
String orderkey = "order:".concat(orderNo);
|
||||||
|
Map<String, Object> cacheOrder = REDIS.getCacheMap(orderkey);
|
||||||
|
String startResult = remoteStartReplyData.getStartResult();
|
||||||
|
cacheOrder.put("startResult", startResult);
|
||||||
|
REDIS.setCacheMap(orderkey, cacheOrder);
|
||||||
return new ServiceResult(false);
|
return new ServiceResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component("RemoteStopReplyDataLogic")
|
@Component("RemoteStopReplyDataLogic")
|
||||||
public class RemoteStopReplyDataLogic implements ServiceLogic {
|
public class RemoteStopReplyDataLogic implements ServiceLogic {
|
||||||
@ -24,7 +26,13 @@ public class RemoteStopReplyDataLogic implements ServiceLogic {
|
|||||||
Map<String, Object> req = sp.getParameters();
|
Map<String, Object> req = sp.getParameters();
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
RemoteStopReplyData remoteStopReplyData = objectMapper.convertValue(req, RemoteStopReplyData.class);
|
RemoteStopReplyData remoteStopReplyData = objectMapper.convertValue(req, RemoteStopReplyData.class);
|
||||||
//todo
|
String gunkey = "gun:".concat(remoteStopReplyData.getPileNo()).concat(remoteStopReplyData.getGunId());
|
||||||
|
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||||
|
String orderkey = (String) cacheGun.get("orderkey");
|
||||||
|
Map<String, Object> cacheOrder = REDIS.getCacheMap(orderkey);
|
||||||
|
String stopResult = remoteStopReplyData.getStopResult();
|
||||||
|
cacheOrder.put("stopResult", stopResult);
|
||||||
|
REDIS.setCacheMap(orderkey, cacheOrder);
|
||||||
return new ServiceResult(false);
|
return new ServiceResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -94,9 +94,6 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
|||||||
} else if (SERVICE_RMCR.equals(serviceName) && OK.equals(resultCode)) {
|
} else if (SERVICE_RMCR.equals(serviceName) && OK.equals(resultCode)) {
|
||||||
setCachePileRM(pilekey);
|
setCachePileRM(pilekey);
|
||||||
}
|
}
|
||||||
// } else if (SERVICE_HB.equals(serviceName)) {
|
|
||||||
// TODO
|
|
||||||
// }
|
|
||||||
if (result.getBinary() != null) {
|
if (result.getBinary() != null) {
|
||||||
log.info("server send msg >>>> ({}) |{}|", pileNo, HexUtils.toHex(result.getBinary()));
|
log.info("server send msg >>>> ({}) |{}|", pileNo, HexUtils.toHex(result.getBinary()));
|
||||||
handler.sendClientBinary(result.getBinary());
|
handler.sendClientBinary(result.getBinary());
|
||||||
@ -106,7 +103,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void regHandler(ClientHandler handler, String pileNo, Map<String, Object> req) throws NacosException {
|
private void regHandler(ClientHandler handler, String pileNo, Map<String, Object> req) {
|
||||||
|
|
||||||
ChargingPileServer.putHandler(pileNo, handler);
|
ChargingPileServer.putHandler(pileNo, handler);
|
||||||
ChargingPileServer.putVersion(handler.getName(), (String) req.get("version"));
|
ChargingPileServer.putVersion(handler.getName(), (String) req.get("version"));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user