diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingPileController.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingPileController.java index c8bc8c69..cb48a7a6 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingPileController.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingPileController.java @@ -187,13 +187,13 @@ public class XhpcChargingPileController extends BaseController { // 远程重启桩 - @GetMapping("/restart") - public AjaxResult pileRestart(String serialNumber) { + @GetMapping("/reboot") + public AjaxResult pileReboot(String serialNumber) { if(serialNumber==null || "".equals(serialNumber)){ return AjaxResult.error("桩号为空"); } - R r = powerPileService.pileRestart(serialNumber); + R r = powerPileService.pileReboot(serialNumber); if(r.getCode() !=200){ return AjaxResult.error(r.getMsg()); } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/PowerPileService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/PowerPileService.java index daa476ba..ab6b2393 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/PowerPileService.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/PowerPileService.java @@ -48,6 +48,6 @@ public interface PowerPileService { R pileSoftwareUpgrade(@PathVariable("pileNo") String pileNo); - @PostMapping("/pile/{pileNo}/restart") - R pileRestart(@PathVariable("pileNo") String pileNo); + @PostMapping("/pile/{pileNo}/reboot") + R pileReboot(@PathVariable("pileNo") String pileNo); } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/PowerPileFallbackFactory.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/PowerPileFallbackFactory.java index 5ddc8a49..8daf7229 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/PowerPileFallbackFactory.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/PowerPileFallbackFactory.java @@ -71,7 +71,7 @@ public class PowerPileFallbackFactory implements FallbackFactory cachePile = REDIS.getCacheMap(pkey); R r = checkPile(cachePile); if (r.getCode() == 200) { String svcSrv = (String) cachePile.get("svcSrv"); - String response = HttpUtils.post(fmt(svcSrv).concat("/native/pile/").concat(pileNo).concat("/restart")); + String response = HttpUtils.post(fmt(svcSrv).concat("/native/pile/").concat(pileNo).concat("/reboot")); r = getRR(response); } return r; } - @PostMapping("native/pile/{pileNo}/restart") - public R nativePileRestart(@PathVariable("pileNo") String pileNo) { + @PostMapping("native/pile/{pileNo}/reboot") + public R nativePileReboot(@PathVariable("pileNo") String pileNo) { ClientHandler handler = getHandler(pileNo); @@ -241,9 +241,9 @@ public class PileController { break; } } - int runFlag = charging ? 2: 1; + int runFlag = charging ? 2 : 1; try { - String rsmsg = RemoteRestartDataLogic.translate(pileNo, runFlag); + String rsmsg = RemoteRebootDataLogic.translate(pileNo, runFlag); handler.sendClientBinary(HexUtils.toBytes(rsmsg)); r = R.ok("充电桩重启下发成功."); @@ -266,7 +266,6 @@ public class PileController { } - @PostMapping("pile/{pileNo}/softwareUpgrade") public R pileSoftwareUpgrade(@PathVariable("pileNo") String pileNo) { @@ -303,7 +302,7 @@ public class PileController { break; } } - int runFlag = charging ? 2: 1; + int runFlag = charging ? 2 : 1; try { String rsmsg = RemoteUpgradeDataLogic.translate(pileNo, "0", 0L, @@ -329,4 +328,78 @@ public class PileController { } return r; } + + + @PostMapping("pile/all/softwareUpgrade") + public R pileAllUpgrade() { + + Collection stationKeys = REDIS.keys("station:*"); + for (String stationKey : stationKeys) { + ChargingStationDto stationDto = REDIS.getCacheObject(stationKey); + Long rateModelIdStation = stationDto.getRateModelId(); + if (rateModelIdStation != null) { + Set pks = stationDto.getPiles(); + if (pks != null) for (String pileNo : pks) { + String gkPattern = ("gun:").concat(pileNo).concat("*"); + Collection gks = REDIS.keys(gkPattern); + boolean charging = false; + for (String gk : gks) { + if (gk.length() == 20 && isInteger(REDIS.getCacheMapValue(gk, "status"))) { + charging = true; + break; + } + } + + ClientHandler handler = getHandler(pileNo); + if (handler != null && handler.isOpen()) { + String rsmsg = RemoteUpgradeDataLogic.translate(pileNo, "0", 0L, "0", "0", "0", charging ? 2 : 1); + try { + handler.sendClientBinary(HexUtils.toBytes(rsmsg)); + log.info("pile[{}] soft upgrade sent ⚪ {}", pileNo, rsmsg); + } catch (IOException e) { + log.error("pile[{}] soft upgrade not sent ×", pileNo); + } + } + } + } + } + return R.ok(); + } + + + @PostMapping("pile/all/reboot") + public R pileAllReboot() { + + Collection stationKeys = REDIS.keys("station:*"); + for (String stationKey : stationKeys) { + ChargingStationDto stationDto = REDIS.getCacheObject(stationKey); + Long rateModelIdStation = stationDto.getRateModelId(); + if (rateModelIdStation != null) { + Set pks = stationDto.getPiles(); + if (pks != null) for (String pileNo : pks) { + String gkPattern = ("gun:").concat(pileNo).concat("*"); + Collection gks = REDIS.keys(gkPattern); + boolean charging = false; + for (String gk : gks) { + if (gk.length() == 20 && isInteger(REDIS.getCacheMapValue(gk, "status"))) { + charging = true; + break; + } + } + + ClientHandler handler = getHandler(pileNo); + if (handler != null && handler.isOpen()) { + String rsmsg = RemoteRebootDataLogic.translate(pileNo, charging ? 2 : 1); + try { + handler.sendClientBinary(HexUtils.toBytes(rsmsg)); + log.info("pile[{}] reboot sent ⚪ {}", pileNo, rsmsg); + } catch (IOException e) { + log.error("pile[{}] reboot not sent ×", pileNo); + } + } + } + } + } + return R.ok(); + } } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRebootDataLogic.java similarity index 95% rename from xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartDataLogic.java rename to xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRebootDataLogic.java index 755c179a..17e01204 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRebootDataLogic.java @@ -22,10 +22,10 @@ import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; import static com.xhpc.common.data.redis.StaticBeanUtil.seqHex; @Lazy -@Component("RemoteRestartDataLogic") -public class RemoteRestartDataLogic implements ServiceLogic { +@Component("RemoteRebootDataLogic") +public class RemoteRebootDataLogic implements ServiceLogic { - private static final Logger log = LoggerFactory.getLogger(RemoteRestartDataLogic.class); + private static final Logger log = LoggerFactory.getLogger(RemoteRebootDataLogic.class); @Resource XhpcDeviceMessageMapper deviceMessageMapper; diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRebootReplyDataLogic.java similarity index 91% rename from xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartReplyDataLogic.java rename to xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRebootReplyDataLogic.java index 891730bb..e05cf417 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRebootReplyDataLogic.java @@ -17,10 +17,10 @@ import javax.annotation.Resource; import java.util.Map; @Lazy -@Component("RemoteRestartReplyDataLogic") -public class RemoteRestartReplyDataLogic implements ServiceLogic { +@Component("RemoteRebootReplyDataLogic") +public class RemoteRebootReplyDataLogic implements ServiceLogic { - private static final Logger log = LoggerFactory.getLogger(RemoteRestartReplyDataLogic.class); + private static final Logger log = LoggerFactory.getLogger(RemoteRebootReplyDataLogic.class); @Resource XhpcDeviceMessageMapper deviceMessageMapper; diff --git a/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml b/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml index 6a29cbe2..b2414a07 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml +++ b/xhpc-modules/xhpc-power-pile/src/main/resources/svcmainlogic.xml @@ -32,7 +32,7 @@ - +