feat: 参数树浏览

master
李小林 7 months ago
parent af16f70943
commit b45f519c25
  1. 6
      src/main/java/com/bellmann/common/constant/SystemConstants.java
  2. 45
      src/main/java/com/bellmann/common/model/OptionTree.java
  3. 4
      src/main/java/com/bellmann/common/result/ResultCode.java
  4. 178
      src/main/java/com/bellmann/controller/DeviceStaticController.java
  5. 18
      src/main/java/com/bellmann/service/DeviceStaticService.java
  6. 660
      src/main/java/com/bellmann/service/impl/DeviceStaticServiceImpl.java

@ -34,14 +34,18 @@ public interface SystemConstants {
public static final String CONN_TYPE_PPPOE_BRIDGE = "桥接";
public static final String CONN_TYPE_IP_ROUTED = "路由";
public static final String CONN_TYPE = "LAST_rg_mode";
public static final String STATUS = "STATUS";
public static final long TASK_TIME_OUT_CONST = 60 * 1000;
public static final long TASK_TIME_OUT_CONST1 = 4 * 1000;
public static final long TASK_TIME_OUT_CONST3 = 6 * 1000;
public static final long TASK_TIME_OUT_CONST2 = 2 * 1000;
public static final long TASK_TIME_OUT_CONST4 = 1000;
public static final String NULL_RESULT = "操作进行中...";
public static final String CONN_TYPE_REGEX = "connectionType = (\\w+)";
public static final String TREE_VALUE_REGEX = "parameter values :\\s*(.*)";
public static final String DOWNLOAD_INFO_REGEX = "DownloadInfo = (.*)";
public static final String SPEED_FAIL = "测速失败,请查看操作日志";
public static final String HOME = "/home/";

@ -0,0 +1,45 @@
package com.bellmann.common.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.List;
@Schema(description ="tree")
@Data
@NoArgsConstructor
@ToString
public class OptionTree<T> {
public OptionTree(T value, String label,boolean childNode) {
this.value = value;
this.label = label;
this.childNode = childNode;
}
public OptionTree(T value, String label, List<OptionTree> children,boolean childNode) {
this.value = value;
this.label = label;
this.children= children;
this.childNode = childNode;
}
@Schema(description="参数值")
private T value;
@Schema(description="树显示名称")
private String label;
@Schema(description="是否存在子节点")
private boolean childNode;
@Schema(description = "当前节点的路径")
private String nodePath;
@Schema(description="子节点")
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private List<OptionTree> children;
}

@ -125,7 +125,9 @@ public enum ResultCode implements IResultCode, Serializable {
TASK_NOT_EXE("F0034", "任务未执行"),
UPDATE_ACCOUNT_PWD_ERROR("F0035","更新设备维护密码失败"),
PLEASE_SELECT_A_CUSTOMER_TYPE("F0036","请选择客户类型!"),
NUll_ERROR("F0037", "未查询到相关数据");
NUll_ERROR("F0037", "未查询到相关数据"),
TASK_EXE_FAIL("F0038", "任务执行失败"),
THE_DEVICE_IS_NOT_ONLINE("F0039","设备不在线");
@Override
public String getCode() {

@ -5,6 +5,7 @@ import com.bellmann.common.constant.SystemConstants;
import com.bellmann.common.enums.OperateTaskStateEnum;
import com.bellmann.common.enums.RemoteOperateMsgEnum;
import com.bellmann.common.exception.BusinessException;
import com.bellmann.common.model.OptionTree;
import com.bellmann.common.result.PageResult;
import com.bellmann.common.result.Result;
import com.bellmann.common.result.ResultCode;
@ -24,6 +25,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -134,7 +136,6 @@ public class DeviceStaticController {
@PreventDuplicateSubmit
public Result<RemoteOperateResult> checkDevOnline(@PathVariable Long devId) {
Long count = remoteOperateTaskService.sendTaskByDevId(devId, SecurityUtils.getUsername(), RemoteOperateMsgEnum.TOUCH_DEVICE.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.TOUCH_DEVICE.getLabel(), count);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
RemoteOperateResult result = remoteOperateTaskService.findDevInfoArgsByDevIdIsTimeOut(devId, RemoteOperateMsgEnum.TOUCH_DEVICE.getValue());
@ -148,82 +149,62 @@ public class DeviceStaticController {
@Operation(summary = "远程操作-获取设备链路信息")
@PreventDuplicateSubmit
public Result<List<DeviceLinkVO>> remoteDeviceLinkInfo(@PathVariable Long devId) {
Long count = remoteOperateTaskService.sendTaskByDevId(devId, SecurityUtils.getUsername(), RemoteOperateMsgEnum.BASIC_PARAMETER.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.BASIC_PARAMETER.getLabel(), count);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
Long taskId = remoteOperateTaskService.sendTaskByDevId(devId, SecurityUtils.getUsername(), RemoteOperateMsgEnum.BASIC_PARAMETER.getValue());
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
if (isSuccess){
List<DeviceLinkVO> result = operateResultArgsService.getDeviceLinkInfo(devId);
return Result.success(result);
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
return Result.success();
}
@GetMapping("/remote/compare-parameter/{devId}/{serviceId}/{serviceVerName}/{serviceName}")
@Operation(summary = "远程操作-业务参数对照")
@PreventDuplicateSubmit
public Result<List<ServiceCompareVO>> compareParameter(@PathVariable Long devId, @PathVariable String serviceName, @PathVariable Long serviceId, @PathVariable String serviceVerName){
int result = deviceStaticService.compareParameter(devId,serviceName,serviceId,serviceVerName);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
Long taskId = deviceStaticService.compareParameter(devId,serviceName,serviceId,serviceVerName);
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
if (isSuccess) {
List<ServiceCompareVO> list = operateResultArgsService.getServiceInfo(devId, serviceName);
return Result.success(list);
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
return Result.success(new ArrayList<>());
}
@GetMapping("/remote/fttp-primary-gateway/{devId}")
@Operation(summary = "远程操作-刷新设备主网关信息")
@PreventDuplicateSubmit
public Result<List<FTTRInfoVO>> remoteFTTRPrimaryGateway(@PathVariable Long devId) {
Long count = remoteOperateTaskService.sendTaskByDevId(devId, SecurityUtils.getUsername(), RemoteOperateMsgEnum.FTTR_CONFIG.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.FTTR_CONFIG.getLabel(), count);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
Long taskId = remoteOperateTaskService.sendTaskByDevId(devId, SecurityUtils.getUsername(), RemoteOperateMsgEnum.FTTR_CONFIG.getValue());
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
if (isSuccess) {
List<FTTRInfoVO> result = operateResultArgsService.getFTTRPrimaryGateway(devId);
return Result.success(result);
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
return Result.success(new ArrayList<>());
}
@GetMapping("/remote/fttp-sub-gateway/{devId}")
@Operation(summary = "远程操作-刷新设备子网关信息")
@PreventDuplicateSubmit
public Result<String> remoteFTTRSubGateway(@PathVariable Long devId) {
Long count = remoteOperateTaskService.sendTaskByDevId(devId, SecurityUtils.getUsername(), RemoteOperateMsgEnum.FTTR_STATS.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.FTTR_STATS.getLabel(), count);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
return Result.success();
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
Long taskId = remoteOperateTaskService.sendTaskByDevId(devId, SecurityUtils.getUsername(), RemoteOperateMsgEnum.FTTR_STATS.getValue());
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@PostMapping("/remote/ip-ping")
@Operation(summary = "远程操作-设备Ping测试")
@PreventDuplicateSubmit
public Result<String> remoteIpPing(@RequestBody @Valid PingForm form) {
Long taskId = deviceStaticService.remoteIpPing(form);
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.IP_PING.getLabel(), taskId);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
return Result.success();
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@GetMapping("/remote/upload-log/{devId}")
@Operation(summary = "远程操作-获取设备日志文件")
@PreventDuplicateSubmit
public Result<String> remoteUploadLog(@PathVariable Long devId) {
Long taskId = remoteOperateTaskService.sendTaskByDevId(devId,SecurityUtils.getUsername(),RemoteOperateMsgEnum.UPLOAD_LOG.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.UPLOAD_LOG.getLabel(), taskId);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
return Result.success();
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@GetMapping("/remote/upload-config/{devId}")
@ -231,39 +212,24 @@ public class DeviceStaticController {
@PreventDuplicateSubmit
public Result<String> remoteUploadConfig(@PathVariable Long devId) {
Long taskId = remoteOperateTaskService.sendTaskByDevId(devId,SecurityUtils.getUsername(),RemoteOperateMsgEnum.UPLOAD_CONFIG.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.UPLOAD_CONFIG.getLabel(), taskId);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
return Result.success();
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@GetMapping("/remote/factory-reset/{devId}")
@Operation(summary = "远程操作-恢复设备出厂设置")
@PreventDuplicateSubmit
public Result<String> remoteFactoryReset(@PathVariable Long devId) {
Long taskId = remoteOperateTaskService.sendTaskByDevId(devId,SecurityUtils.getUsername(),RemoteOperateMsgEnum.FACTORY_RESET.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.FACTORY_RESET.getLabel(), taskId);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
return Result.success();
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@GetMapping("/remote/reboot/{devId}")
@Operation(summary = "远程操作-远程重启")
@PreventDuplicateSubmit
public Result<String> remoteReboot(@PathVariable Long devId) {
Long taskId = remoteOperateTaskService.sendTaskByDevId(devId,SecurityUtils.getUsername(),RemoteOperateMsgEnum.REBOOT.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.REBOOT.getLabel(), taskId);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
return Result.success();
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@PostMapping("/remote/device-monitor")
@ -271,13 +237,8 @@ public class DeviceStaticController {
@PreventDuplicateSubmit
public Result<String> remoteDeviceMonitor(@RequestBody @Valid DeviceMonitorForm form) {
Long taskId = deviceStaticService.remoteDeviceMonitor(form);
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.IP_PING.getLabel(), taskId);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST1);
return Result.success();
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@GetMapping("/remote/check-conn-type/{devId}")
@Operation(summary = "远程操作-测速-上网方式")
@ -285,13 +246,12 @@ public class DeviceStaticController {
public Result<String> remoteCheckConnType(@PathVariable Long devId) {
Long taskId = deviceStaticService.remoteCheckConnType(devId);
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.REBOOT.getLabel(), taskId);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST2);
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
if (isSuccess) {
String connType = deviceStaticService.remoteConnType(taskId, devId);
return Result.success(connType);
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
return Result.failed();
}
@GetMapping("/remote/tr143-speed/{devId}")
@Operation(summary = "远程操作-测速")
@ -318,37 +278,35 @@ public class DeviceStaticController {
@PreventDuplicateSubmit
public Result<String> remoteSoftVerUpgrade(@PathVariable Long devId,@PathVariable Long fileId){
Long taskId = remoteOperateTaskService.sendTaskByDevIdByFileId(devId, SecurityUtils.getUsername(), fileId, RemoteOperateMsgEnum.DOWNLOAD_SOFT_VER_FILE.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.DOWNLOAD_SOFT_VER_FILE.getLabel(), taskId);
return Result.success();
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@GetMapping("/remote/register/{devId}")
@Operation(summary = "远程操作-开启终端注册页面")
@PreventDuplicateSubmit
public Result<String> remoteOpenRegister(@PathVariable Long devId){
Long taskId = deviceStaticService.remoteOpenRegister(devId);
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.X_REGISTER.getLabel(), taskId);
return Result.success();
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@GetMapping("/remote/account-password/{devId}")
@Operation(summary = "远程操作-设备设置电信帐户密码")
@PreventDuplicateSubmit
public Result<String> setAccountPassword(@PathVariable Long devId){
Long taskId = deviceStaticService.setAccountPassword(devId);
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.SET_TELEPHONE_COM_ACCOUNT_PASSWORD.getLabel(), taskId);
try {
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST2);
} catch (InterruptedException e) {
throw new BusinessException(ResultCode.LINK_INFO_ERROR);
}
return Result.success();
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@GetMapping("/remote/vendor-profile/{devId}/{fileId}")
@Operation(summary = "远程操作-厂商配置文件下发")
@PreventDuplicateSubmit
public Result<String> remoteVendorProfile(@PathVariable Long devId,@PathVariable Long fileId){
Long taskId = remoteOperateTaskService.sendTaskByDevIdByFileId(devId,SecurityUtils.getUsername(),fileId,RemoteOperateMsgEnum.DOWNLOAD_CONFIG.getValue());
log.info("{}任务执行中: {}", RemoteOperateMsgEnum.DOWNLOAD_CONFIG.getLabel(), taskId);
return Result.success();
boolean isSuccess = deviceStaticService.taskIsSuccess(taskId);
return Result.judge(isSuccess);
}
@GetMapping("/remote/reset-service/{devId}/{serviceName}")
@Operation(summary = "远程操作-业务重置")
@ -363,4 +321,54 @@ public class DeviceStaticController {
return Result.success();
}
@GetMapping("/remote/tree/infos/{devId}")
@Operation(summary = "远程操作-当前节点的所有子节点")
@PreventDuplicateSubmit()
public Result<List<OptionTree<String>>> getNodeChildNodes(@PathVariable Long devId,@RequestParam String nodePath){
List<OptionTree<String>> nodeChildNodes = deviceStaticService.getNodeChildNodes(devId, nodePath);
return Result.success(nodeChildNodes);
}
@GetMapping("/remote/tree/param-value/{devId}")
@Operation(summary = "远程操作-获取参数")
@PreventDuplicateSubmit()
public Result<OptionTree<String>> getParameterValues(@PathVariable Long devId,@RequestParam String nodePath){
OptionTree<String> node = deviceStaticService.getParameterValues(devId, nodePath);
return Result.success(node);
}
@PutMapping("/remote/tree/set-param-value/{devId}")
@Operation(summary = "远程操作-设置参数")
@PreventDuplicateSubmit()
public Result<String> setParameterValues(@PathVariable Long devId,@RequestParam String nodePath,@RequestParam String argValue){
boolean result = deviceStaticService.setParameterValues(devId, nodePath,argValue);
return Result.judge(result);
}
@GetMapping("/remote/tree/param-attribute/{devId}")
@Operation(summary = "远程操作-获取参数属性")
@PreventDuplicateSubmit()
public Result<OptionTree<String>> getParameterAttributes(@PathVariable Long devId,@RequestParam String nodePath){
OptionTree<String> node = deviceStaticService.getParameterAttributes(devId, nodePath);
return Result.success(node);
}
@PutMapping("/remote/tree/set-param-attribute/{devId}")
@Operation(summary = "远程操作-设置参数属性")
@PreventDuplicateSubmit()
public Result<String> setParameterAttributes(@PathVariable Long devId,@RequestParam String nodePath,@RequestParam String argValue){
deviceStaticService.setParameterAttributes(devId, nodePath,argValue);
return Result.success();
}
@GetMapping("/remote/tree/add-instance-node/{devId}")
@Operation(summary = "远程操作-增加实例")
@PreventDuplicateSubmit()
public Result<OptionTree<String>> remoteAddInstanceNode(@PathVariable Long devId,@RequestParam String nodePath){
OptionTree<String> node = deviceStaticService.addInstanceNode(devId, nodePath);
return Result.success(node);
}
@GetMapping("/remote/tree/delete-instance-node/{devId}")
@Operation(summary = "远程操作-删除实例")
@PreventDuplicateSubmit()
public Result<String> remoteDeleteInstanceNode(@PathVariable Long devId,@RequestParam String nodePath){
boolean result = deviceStaticService.deleteInstanceNode(devId, nodePath);
return Result.judge(result);
}
}

@ -1,6 +1,7 @@
package com.bellmann.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bellmann.common.model.OptionTree;
import com.bellmann.common.result.PageResult;
import com.bellmann.common.result.Result;
import com.bellmann.model.form.*;
@ -41,7 +42,7 @@ public interface DeviceStaticService {
Result<String> deleteProfile(Long devId, Long fileId);
int compareParameter(Long devId, String serviceName, Long serviceId, String serviceVerName);
Long compareParameter(Long devId, String serviceName, Long serviceId, String serviceVerName);
Long remoteIpPing(PingForm form);
@ -66,4 +67,19 @@ public interface DeviceStaticService {
void remoteResetService(Long devId, String serviceName);
List<OptionTree<String>> getNodeChildNodes(Long devId, String nodePath);
OptionTree<String> getParameterValues(Long devId, String nodePath);
boolean setParameterValues(Long devId, String nodePath, String argValue);
OptionTree<String> getParameterAttributes(Long devId, String nodePath);
void setParameterAttributes(Long devId, String nodePath, String argValue);
OptionTree<String> addInstanceNode(Long devId, String nodePath);
boolean deleteInstanceNode(Long devId, String nodePath);
boolean taskIsSuccess(Long taskId);
}

Loading…
Cancel
Save