更新接口命名,新增批量执行命令接口
This commit is contained in:
parent
bfce06b561
commit
c7ac30363b
@ -187,13 +187,13 @@ public class XhpcChargingPileController extends BaseController {
|
|||||||
|
|
||||||
|
|
||||||
// 远程重启桩
|
// 远程重启桩
|
||||||
@GetMapping("/restart")
|
@GetMapping("/reboot")
|
||||||
public AjaxResult pileRestart(String serialNumber) {
|
public AjaxResult pileReboot(String serialNumber) {
|
||||||
|
|
||||||
if(serialNumber==null || "".equals(serialNumber)){
|
if(serialNumber==null || "".equals(serialNumber)){
|
||||||
return AjaxResult.error("桩号为空");
|
return AjaxResult.error("桩号为空");
|
||||||
}
|
}
|
||||||
R r = powerPileService.pileRestart(serialNumber);
|
R r = powerPileService.pileReboot(serialNumber);
|
||||||
if(r.getCode() !=200){
|
if(r.getCode() !=200){
|
||||||
return AjaxResult.error(r.getMsg());
|
return AjaxResult.error(r.getMsg());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,6 @@ public interface PowerPileService {
|
|||||||
R pileSoftwareUpgrade(@PathVariable("pileNo") String pileNo);
|
R pileSoftwareUpgrade(@PathVariable("pileNo") String pileNo);
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/pile/{pileNo}/restart")
|
@PostMapping("/pile/{pileNo}/reboot")
|
||||||
R pileRestart(@PathVariable("pileNo") String pileNo);
|
R pileReboot(@PathVariable("pileNo") String pileNo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,7 +71,7 @@ public class PowerPileFallbackFactory implements FallbackFactory<PowerPileServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R pileRestart(String pileNo) {
|
public R pileReboot(String pileNo) {
|
||||||
|
|
||||||
return R.fail("重启桩程序失败:" + cause.getMessage());
|
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.common.enums.StationDeviceEnum;
|
||||||
import com.xhpc.pp.domain.XhpcDeviceMessage;
|
import com.xhpc.pp.domain.XhpcDeviceMessage;
|
||||||
import com.xhpc.pp.logic.RateModelRequestLogic;
|
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.logic.RemoteUpgradeDataLogic;
|
||||||
import com.xhpc.pp.mapper.XhpcDeviceMessageMapper;
|
import com.xhpc.pp.mapper.XhpcDeviceMessageMapper;
|
||||||
import com.xhpc.pp.utils.HexUtils;
|
import com.xhpc.pp.utils.HexUtils;
|
||||||
@ -205,23 +205,23 @@ public class PileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("pile/{pileNo}/restart")
|
@PostMapping("pile/{pileNo}/reboot")
|
||||||
public R pileRestart(@PathVariable("pileNo") String pileNo) {
|
public R pileReboot(@PathVariable("pileNo") String pileNo) {
|
||||||
|
|
||||||
String pkey = "pile:".concat(pileNo);
|
String pkey = "pile:".concat(pileNo);
|
||||||
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
||||||
R<Object> r = checkPile(cachePile);
|
R<Object> r = checkPile(cachePile);
|
||||||
if (r.getCode() == 200) {
|
if (r.getCode() == 200) {
|
||||||
String svcSrv = (String) cachePile.get("svcSrv");
|
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);
|
r = getRR(response);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("native/pile/{pileNo}/restart")
|
@PostMapping("native/pile/{pileNo}/reboot")
|
||||||
public R nativePileRestart(@PathVariable("pileNo") String pileNo) {
|
public R nativePileReboot(@PathVariable("pileNo") String pileNo) {
|
||||||
|
|
||||||
ClientHandler handler = getHandler(pileNo);
|
ClientHandler handler = getHandler(pileNo);
|
||||||
|
|
||||||
@ -241,9 +241,9 @@ public class PileController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int runFlag = charging ? 2: 1;
|
int runFlag = charging ? 2 : 1;
|
||||||
try {
|
try {
|
||||||
String rsmsg = RemoteRestartDataLogic.translate(pileNo, runFlag);
|
String rsmsg = RemoteRebootDataLogic.translate(pileNo, runFlag);
|
||||||
|
|
||||||
handler.sendClientBinary(HexUtils.toBytes(rsmsg));
|
handler.sendClientBinary(HexUtils.toBytes(rsmsg));
|
||||||
r = R.ok("充电桩重启下发成功.");
|
r = R.ok("充电桩重启下发成功.");
|
||||||
@ -266,7 +266,6 @@ public class PileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("pile/{pileNo}/softwareUpgrade")
|
@PostMapping("pile/{pileNo}/softwareUpgrade")
|
||||||
public R pileSoftwareUpgrade(@PathVariable("pileNo") String pileNo) {
|
public R pileSoftwareUpgrade(@PathVariable("pileNo") String pileNo) {
|
||||||
|
|
||||||
@ -303,7 +302,7 @@ public class PileController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int runFlag = charging ? 2: 1;
|
int runFlag = charging ? 2 : 1;
|
||||||
try {
|
try {
|
||||||
String rsmsg = RemoteUpgradeDataLogic.translate(pileNo,
|
String rsmsg = RemoteUpgradeDataLogic.translate(pileNo,
|
||||||
"0", 0L,
|
"0", 0L,
|
||||||
@ -329,4 +328,78 @@ public class PileController {
|
|||||||
}
|
}
|
||||||
return r;
|
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;
|
import static com.xhpc.common.data.redis.StaticBeanUtil.seqHex;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component("RemoteRestartDataLogic")
|
@Component("RemoteRebootDataLogic")
|
||||||
public class RemoteRestartDataLogic implements ServiceLogic {
|
public class RemoteRebootDataLogic implements ServiceLogic {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(RemoteRestartDataLogic.class);
|
private static final Logger log = LoggerFactory.getLogger(RemoteRebootDataLogic.class);
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
XhpcDeviceMessageMapper deviceMessageMapper;
|
XhpcDeviceMessageMapper deviceMessageMapper;
|
||||||
@ -17,10 +17,10 @@ import javax.annotation.Resource;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component("RemoteRestartReplyDataLogic")
|
@Component("RemoteRebootReplyDataLogic")
|
||||||
public class RemoteRestartReplyDataLogic implements ServiceLogic {
|
public class RemoteRebootReplyDataLogic implements ServiceLogic {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(RemoteRestartReplyDataLogic.class);
|
private static final Logger log = LoggerFactory.getLogger(RemoteRebootReplyDataLogic.class);
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
XhpcDeviceMessageMapper deviceMessageMapper;
|
XhpcDeviceMessageMapper deviceMessageMapper;
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<entry key="51" value-ref="PileConfigReplyDataLogic"/>
|
<entry key="51" value-ref="PileConfigReplyDataLogic"/>
|
||||||
<entry key="55" value-ref="PileTimeConfigReplyDataLogic"/>
|
<entry key="55" value-ref="PileTimeConfigReplyDataLogic"/>
|
||||||
<entry key="57" value-ref="RateModelConfigReplyDataLogic"/>
|
<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="93" value-ref="RemoteUpgradeReplyDataLogic"/>
|
||||||
<entry key="94" value-ref="RemoteUpgradeDataLogic"/>
|
<entry key="94" value-ref="RemoteUpgradeDataLogic"/>
|
||||||
</util:map>
|
</util:map>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user