| | |
| | | |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.dto.RemoteFileDto; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.RemoteUpdateTypeEnum; |
| | | import com.sandu.ximon.admin.param.RemotePrarm; |
| | | import com.sandu.ximon.admin.param.RemoteUpdateParam; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.service.RemoteUpdateService; |
| | | import com.sandu.ximon.admin.utils.HexUtils; |
| | | import com.sandu.ximon.admin.utils.StringUtil; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import static com.sandu.ximon.admin.manager.iot.rrpc.enums.RemoteUpdateTypeEnum.MQTT_MAIN; |
| | | |
| | | /** |
| | | * 固件升级Controller |
| | |
| | | private PermissionConfig permissionConfig; |
| | | |
| | | |
| | | @AnonymousAccess |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addRemoteUpdateFile(@RequestBody @Validated RemoteUpdateParam param) { |
| | | if (!permissionConfig.check(MenuEnum.REMOTE_UPDATE_FILE_ADD.getCode())) { |
| | |
| | | return ResponseUtil.success(flag); |
| | | } |
| | | |
| | | @AnonymousAccess |
| | | /** |
| | | * 修改固件升级文件名称 |
| | | * |
| | | * @param remoteFileId |
| | | * @param remoteFileName |
| | | * @return |
| | | */ |
| | | @GetMapping("/updateRemoteFileName") |
| | | public ResponseVO<Object> updateRemoteFileName(@RequestParam(required = false, value = "remoteFileId") String remoteFileId, |
| | | @RequestParam(required = false, value = "remoteFileName") String remoteFileName) { |
| | | if (!permissionConfig.check(MenuEnum.REMOTE_UPDATE_FILE_UPDATE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | String result = remoteUpdateService.updateRemoteFileName(remoteFileId, remoteFileName); |
| | | return ResponseUtil.success(result); |
| | | } |
| | | |
| | | @GetMapping("/getRemoteFileList") |
| | | public ResponseVO<Object> getRemoteFileList() { |
| | | if (!permissionConfig.check(MenuEnum.REMOTE_UPDATE_FILE_LIST.getCode())) { |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | //TODO |
| | | @AnonymousAccess |
| | | @PostMapping("/StartRemoteUpdate") |
| | | public ResponseVO<Object> startRemoteUpdate(@RequestBody @Validated RemotePrarm remotePrarm) { |
| | | if (!permissionConfig.check(MenuEnum.REMOTE_UPDATE_START.getCode())) { |
| | |
| | | String orderType; |
| | | boolean UpdateFlag = false; |
| | | |
| | | switch (remotePrarm.getDeviceType()) { |
| | | case "MQTT串口": |
| | | case "CAT1": |
| | | orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode(); |
| | | break; |
| | | case "大气": |
| | | orderType = A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(); |
| | | break; |
| | | case "C3充电桩": |
| | | orderType = A5OrderEnum.REQUEST_C3_DATA.getCode(); |
| | | break; |
| | | case "杆体倾斜": |
| | | orderType = A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode(); |
| | | break; |
| | | default: |
| | | throw new BusinessException("升级硬件设备类型指令有误,请确认!"); |
| | | if (RemoteUpdateTypeEnum.MQTT_MAIN.equals(remotePrarm.getDeviceType())) { |
| | | //MQTT主板 |
| | | orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode(); |
| | | } else if (RemoteUpdateTypeEnum.MQTT_CORE.equals(remotePrarm.getDeviceType())) { |
| | | //MQTT核心板 |
| | | orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode(); |
| | | } else if (RemoteUpdateTypeEnum.LIGHT.equals(remotePrarm.getDeviceType())) { |
| | | //单灯模块 |
| | | orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode(); |
| | | } else if (RemoteUpdateTypeEnum.C3_CHARGING.equals(remotePrarm.getDeviceType())) { |
| | | //C3充电桩模块 |
| | | orderType = A5OrderEnum.REQUEST_C3_DATA.getCode(); |
| | | } else if (RemoteUpdateTypeEnum.CAT1_MAIN.equals(remotePrarm.getDeviceType())) { |
| | | //Cat.1主板 |
| | | orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode(); |
| | | } else if (RemoteUpdateTypeEnum.LIGHT_POLE_HELING.equals(remotePrarm.getDeviceType())) { |
| | | //灯杆倾斜模块 |
| | | orderType = A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode(); |
| | | } else if (RemoteUpdateTypeEnum.AIR_EQUIPMENT.equals(remotePrarm.getDeviceType())) { |
| | | //大气设备模块 |
| | | orderType = A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(); |
| | | } else { |
| | | throw new BusinessException("升级硬件设备类型指令有误,请确认!"); |
| | | } |
| | | |
| | | //启动远程升级命令 |
| | |
| | | * @param remotePrarm |
| | | * @return |
| | | */ |
| | | @AnonymousAccess |
| | | @PostMapping("/searchUpdateResult") |
| | | public ResponseVO<Object> searchUpdateResult(@RequestBody RemotePrarm remotePrarm) { |
| | | if (!permissionConfig.check(MenuEnum.REMOTE_UPDATE_VERSION.getCode())) { |
| | |
| | | * @param remotePrarm |
| | | * @return |
| | | */ |
| | | @AnonymousAccess |
| | | @PostMapping("/stopUpdate") |
| | | public ResponseVO<Object> stopUpdate(@RequestBody RemotePrarm remotePrarm) { |
| | | if (!permissionConfig.check(MenuEnum.REMOTE_UPDATE_STOP.getCode())) { |