更新接口命名,新增批量执行命令接口
This commit is contained in:
parent
bfce06b561
commit
c7ac30363b
@ -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());
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public class PowerPileFallbackFactory implements FallbackFactory<PowerPileServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public R pileRestart(String pileNo) {
|
||||
public R pileReboot(String pileNo) {
|
||||
|
||||
return R.fail("重启桩程序失败:" + cause.getMessage());
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import com.xhpc.common.core.utils.HttpUtils;
|
||||
import com.xhpc.common.enums.StationDeviceEnum;
|
||||
import com.xhpc.pp.domain.XhpcDeviceMessage;
|
||||
import com.xhpc.pp.logic.RateModelRequestLogic;
|
||||
import com.xhpc.pp.logic.RemoteRestartDataLogic;
|
||||
import com.xhpc.pp.logic.RemoteRebootDataLogic;
|
||||
import com.xhpc.pp.logic.RemoteUpgradeDataLogic;
|
||||
import com.xhpc.pp.mapper.XhpcDeviceMessageMapper;
|
||||
import com.xhpc.pp.utils.HexUtils;
|
||||
@ -205,23 +205,23 @@ public class PileController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("pile/{pileNo}/restart")
|
||||
public R pileRestart(@PathVariable("pileNo") String pileNo) {
|
||||
@PostMapping("pile/{pileNo}/reboot")
|
||||
public R pileReboot(@PathVariable("pileNo") String pileNo) {
|
||||
|
||||
String pkey = "pile:".concat(pileNo);
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
||||
R<Object> 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);
|
||||
|
||||
@ -243,7 +243,7 @@ public class PileController {
|
||||
}
|
||||
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) {
|
||||
|
||||
@ -329,4 +328,78 @@ public class PileController {
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("pile/all/softwareUpgrade")
|
||||
public R pileAllUpgrade() {
|
||||
|
||||
Collection<String> stationKeys = REDIS.keys("station:*");
|
||||
for (String stationKey : stationKeys) {
|
||||
ChargingStationDto stationDto = REDIS.getCacheObject(stationKey);
|
||||
Long rateModelIdStation = stationDto.getRateModelId();
|
||||
if (rateModelIdStation != null) {
|
||||
Set<String> pks = stationDto.getPiles();
|
||||
if (pks != null) for (String pileNo : pks) {
|
||||
String gkPattern = ("gun:").concat(pileNo).concat("*");
|
||||
Collection<String> 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<String> stationKeys = REDIS.keys("station:*");
|
||||
for (String stationKey : stationKeys) {
|
||||
ChargingStationDto stationDto = REDIS.getCacheObject(stationKey);
|
||||
Long rateModelIdStation = stationDto.getRateModelId();
|
||||
if (rateModelIdStation != null) {
|
||||
Set<String> pks = stationDto.getPiles();
|
||||
if (pks != null) for (String pileNo : pks) {
|
||||
String gkPattern = ("gun:").concat(pileNo).concat("*");
|
||||
Collection<String> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -32,7 +32,7 @@
|
||||
<entry key="51" value-ref="PileConfigReplyDataLogic"/>
|
||||
<entry key="55" value-ref="PileTimeConfigReplyDataLogic"/>
|
||||
<entry key="57" value-ref="RateModelConfigReplyDataLogic"/>
|
||||
<entry key="91" value-ref="RemoteRestartReplyDataLogic"/>
|
||||
<entry key="91" value-ref="RemoteRebootReplyDataLogic"/>
|
||||
<entry key="93" value-ref="RemoteUpgradeReplyDataLogic"/>
|
||||
<entry key="94" value-ref="RemoteUpgradeDataLogic"/>
|
||||
</util:map>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user