From b3bbc21a828f7bff14a7bb2ad3ef86a439905e63 Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Thu, 6 Apr 2023 16:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E7=94=B5=E6=A1=A9=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsowell/service/PileRemoteService.java | 6 ++-- .../controller/pile/PileRemoteController.java | 28 ++++++++++--------- .../test/java/SpringBootTestController.java | 2 +- ...ommand.java => UpdateFirmwareCommand.java} | 2 +- .../yunkuaichong/YKCPushCommandService.java | 2 +- .../impl/YKCPushCommandServiceImpl.java | 4 +-- jsowell-ui/src/api/pile/pileRemote.js | 10 +++++++ jsowell-ui/src/views/pile/basic/detail.vue | 26 +++++++++-------- 8 files changed, 47 insertions(+), 33 deletions(-) rename jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/{UpdateFileCommand.java => UpdateFirmwareCommand.java} (87%) create mode 100644 jsowell-ui/src/api/pile/pileRemote.js diff --git a/jsowell-admin/src/main/java/com/jsowell/service/PileRemoteService.java b/jsowell-admin/src/main/java/com/jsowell/service/PileRemoteService.java index 00474111e..e2ebe2538 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/PileRemoteService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/PileRemoteService.java @@ -9,7 +9,7 @@ import com.jsowell.netty.command.ykc.PublishPileBillingTemplateCommand; import com.jsowell.netty.command.ykc.RebootCommand; import com.jsowell.netty.command.ykc.StartChargingCommand; import com.jsowell.netty.command.ykc.StopChargingCommand; -import com.jsowell.netty.command.ykc.UpdateFileCommand; +import com.jsowell.netty.command.ykc.UpdateFirmwareCommand; import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService; import com.jsowell.pile.domain.PileBillingRelation; import com.jsowell.pile.domain.PileBillingTemplate; @@ -186,9 +186,9 @@ public class PileRemoteService { * * @param pileSns 前台传的桩号集合 */ - public void updateFile(List pileSns) { + public void updateFirmware(List pileSns) { // - UpdateFileCommand command = UpdateFileCommand.builder().pileSnList(pileSns).build(); + UpdateFirmwareCommand command = UpdateFirmwareCommand.builder().pileSnList(pileSns).build(); ykcPushCommandService.pushUpdateFileCommand(command); } } diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileRemoteController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileRemoteController.java index 14a9a2555..2a8caf97a 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileRemoteController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileRemoteController.java @@ -7,19 +7,18 @@ import com.jsowell.pile.dto.GenerateOrderDTO; import com.jsowell.pile.dto.QueryPileDTO; import com.jsowell.service.OrderService; import com.jsowell.service.PileRemoteService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.text.ParseException; - /** * 远程控制controller */ @RestController -@RequestMapping("/remote") +@RequestMapping("/pile/remote") public class PileRemoteController { @Autowired @@ -30,7 +29,7 @@ public class PileRemoteController { /** * 获取实时上传数据 - * http://localhost:8080/remote/getRealTimeMonitorData + * http://localhost:8080/pile/remote/getRealTimeMonitorData * @return */ @PostMapping("/getRealTimeMonitorData") @@ -41,7 +40,7 @@ public class PileRemoteController { /** * 远程重启 - * http://localhost:8080/remote/reboot + * http://localhost:8080/pile/remote/reboot * @return */ @PostMapping("/reboot") @@ -52,7 +51,7 @@ public class PileRemoteController { /** * 后管-远程启动充电 - * http://localhost:8080/remote/remoteStartChargingForWeb + * http://localhost:8080/pile/remote/remoteStartChargingForWeb */ @PostMapping("/remoteStartChargingForWeb") public AjaxResult remoteStartCharging(@RequestBody GenerateOrderDTO dto) { @@ -70,7 +69,7 @@ public class PileRemoteController { /** * 远程停止充电 - * http://localhost:8080/remote/remoteStopCharging + * http://localhost:8080/pile/remote/remoteStopCharging * @param dto * @return */ @@ -82,7 +81,7 @@ public class PileRemoteController { /** * 远程下发二维码 - * http://localhost:8080/remote/issueQRCode + * http://localhost:8080/pile/remote/issueQRCode */ @PostMapping("/issueQRCode") public AjaxResult issueQRCode(@RequestBody QueryPileDTO queryPileDTO) { @@ -92,7 +91,7 @@ public class PileRemoteController { /** * 对时 - * http://localhost:8080/remote/proofreadTime + * http://localhost:8080/pile/remote/proofreadTime */ @PostMapping("/proofreadTime") public AjaxResult proofreadTime(@RequestBody QueryPileDTO queryPileDTO) { @@ -102,12 +101,15 @@ public class PileRemoteController { /** * 远程升级 - * http://localhost:8080/remote/updateFile + * http://localhost:8080/pile/remote/updateFirmware * @return */ - @PostMapping("/updateFile") - public AjaxResult updateFile(@RequestBody QueryPileDTO queryPileDTO) { - pileRemoteService.updateFile(queryPileDTO.getPileSns()); + @PostMapping("/updateFirmware") + public AjaxResult updateFirmware(@RequestBody QueryPileDTO queryPileDTO) { + if (CollectionUtils.isEmpty(queryPileDTO.getPileSns())) { + return AjaxResult.error("参数不能为空"); + } + pileRemoteService.updateFirmware(queryPileDTO.getPileSns()); return AjaxResult.success(); } diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index 2256afb2a..2a40c2d3b 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -546,7 +546,7 @@ public class SpringBootTestController { public void testRemoteUpdate() { ArrayList list = new ArrayList<>(); list.add("88000000000001"); - pileRemoteService.updateFile(list); + pileRemoteService.updateFirmware(list); } @Test diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/UpdateFileCommand.java b/jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/UpdateFirmwareCommand.java similarity index 87% rename from jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/UpdateFileCommand.java rename to jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/UpdateFirmwareCommand.java index 9d1155ec9..6effe2e0f 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/UpdateFileCommand.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/UpdateFirmwareCommand.java @@ -11,6 +11,6 @@ import java.util.List; @NoArgsConstructor @AllArgsConstructor @Builder -public class UpdateFileCommand { +public class UpdateFirmwareCommand { List pileSnList; } diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/YKCPushCommandService.java b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/YKCPushCommandService.java index 62e9f4367..ea10106a9 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/YKCPushCommandService.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/YKCPushCommandService.java @@ -53,7 +53,7 @@ public interface YKCPushCommandService { * 发送远程更新命令 * @param command */ - void pushUpdateFileCommand(UpdateFileCommand command); + void pushUpdateFileCommand(UpdateFirmwareCommand command); /** * 发送充电桩设置命令 diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCPushCommandServiceImpl.java b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCPushCommandServiceImpl.java index 6460f44b3..f44426dd6 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCPushCommandServiceImpl.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCPushCommandServiceImpl.java @@ -69,7 +69,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService { // 通过桩编号获取channel Channel channel = PileChannelEntity.getChannelByPileSn(pileSn); if (Objects.isNull(channel)) { - log.error("push命令失败, 桩号:{}无法获取到长连接, 请检查充电桩连接状态!", pileSn); + log.error("push命令[{}]失败, 桩号:{}无法获取到长连接, 请检查充电桩连接状态!", ((YKCFrameTypeCode) frameTypeCode).getValue(), pileSn); return false; } /** @@ -284,7 +284,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService { } @Override - public void pushUpdateFileCommand(UpdateFileCommand command) { + public void pushUpdateFileCommand(UpdateFirmwareCommand command) { List pileSns = command.getPileSnList(); if (CollectionUtils.isEmpty(pileSns)) { return; diff --git a/jsowell-ui/src/api/pile/pileRemote.js b/jsowell-ui/src/api/pile/pileRemote.js new file mode 100644 index 000000000..0a91e3bc7 --- /dev/null +++ b/jsowell-ui/src/api/pile/pileRemote.js @@ -0,0 +1,10 @@ +import request from '@/utils/request' + +// 查询充电桩通讯日志 +export function updateFirmware(data) { + return request({ + url: '/pile/remote/updateFirmware', + method: 'post', + data: data + }) +} diff --git a/jsowell-ui/src/views/pile/basic/detail.vue b/jsowell-ui/src/views/pile/basic/detail.vue index 239b965e1..cb8198013 100644 --- a/jsowell-ui/src/views/pile/basic/detail.vue +++ b/jsowell-ui/src/views/pile/basic/detail.vue @@ -5,7 +5,6 @@ value="first" type="border-card" @tab-click="handleClick" - v-loading="loading" > @@ -23,7 +22,6 @@ @@ -238,6 +229,7 @@ import { import { queryConnectorListByParams } from "@/api/pile/connector"; // 二维码组件 import VueQr from "vue-qr"; +import {updateFirmware} from "@/api/pile/pileRemote"; export default { components: { VueQr }, @@ -296,6 +288,16 @@ export default { setTimeout(() => {}, 300); }, methods: { + // 远程升级固件 + updateFirmware() { + const data = { + pileSns: [this.pileSn], + }; + console.log("远程升级固件:", data); + updateFirmware(data).then((response) => { + console.log("updateFirmware结果:", response); + }); + }, //点击二维码事件 qrcodeClick(row) { if (this.flag) {