feat(device): 新增设备注册台账功能并优化数据查询
- 添加设备注册台账实体类CsDeviceRegistry及相关数据库映射 - 实现设备注册台账的增删改查控制器及服务接口 - 集成Feign客户端用于跨服务调用设备注册功能 - 修复设备交付服务中的空指针异常问题 - 优化相位数据显示,将"T"相位转换为"总" - 在数据集查询中添加存储标志过滤条件 - 实现设备MAC地址变更时的注册信息同步更新 - 添加设备注册状态字段到设备交付视图对象 - 完善事件处理中的逻辑子设备ID设置逻辑 - 重构线路台账服务中的线路类型判断逻辑 - 实现云前置线路创建时的唯一标识符生成机制
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsDeviceRegistryFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csDeviceRegistry", fallbackFactory = CsDeviceRegistryFallbackFactory.class,contextId = "csDeviceRegistry")
|
||||
public interface CsDeviceRegistryFeignClient {
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("批量新增设备注册记录")
|
||||
HttpResult<Boolean> add(@RequestBody @Validated List<CsDeviceRegistry> list);
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改设备注册记录")
|
||||
HttpResult<Boolean> update(@RequestBody @Validated CsDeviceRegistry csDeviceRegistry);
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除设备注册记录")
|
||||
HttpResult<Boolean> delete(@RequestParam("id") String id);
|
||||
|
||||
@PostMapping("/queryByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid查询设备注册记录")
|
||||
HttpResult<List<CsDeviceRegistry>> queryByCurrentNdid(@RequestParam("currentNdid") String currentNdid);
|
||||
|
||||
@PostMapping("/queryByCurrentNdidAndClDid")
|
||||
@ApiOperation("根据currentNdid和clDid查询设备注册记录")
|
||||
HttpResult<CsDeviceRegistry> queryByCurrentNdidAndClDid(@RequestParam("currentNdid") String currentNdid, @RequestParam("clDid") Integer clDid);
|
||||
|
||||
@PostMapping("/updateIsAccessByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid修改isAccess")
|
||||
HttpResult<Boolean> updateIsAccessByCurrentNdid(@RequestParam("currentNdid") String currentNdid, @RequestParam("isAccess") Integer isAccess);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.CsDeviceRegistryFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsDeviceRegistryFallbackFactory implements FallbackFactory<CsDeviceRegistryFeignClient> {
|
||||
@Override
|
||||
public CsDeviceRegistryFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsDeviceRegistryFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> add(List<CsDeviceRegistry> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","批量新增设备注册记录异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> update(CsDeviceRegistry csDeviceRegistry) {
|
||||
log.error("{}异常,降级处理,异常为:{}","修改设备注册记录异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> delete(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","删除设备注册记录异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsDeviceRegistry>> queryByCurrentNdid(String currentNdid) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据currentNdid查询设备注册记录异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<CsDeviceRegistry> queryByCurrentNdidAndClDid(String currentNdid, Integer clDid) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据currentNdid和clDid查询设备注册记录数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> updateIsAccessByCurrentNdid(String currentNdid, Integer isAccess) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据currentNdid修改isAccess异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-06-17
|
||||
*/
|
||||
@Data
|
||||
@TableName("cs_device_registry")
|
||||
public class CsDeviceRegistry implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 当前设备NDID
|
||||
*/
|
||||
private String currentNdid;
|
||||
|
||||
/**
|
||||
* 老的设备NDID
|
||||
*/
|
||||
private String oldNdid;
|
||||
|
||||
/**
|
||||
* 逻辑子设备编号
|
||||
*/
|
||||
private Integer clDid;
|
||||
|
||||
/**
|
||||
* 首次接入时间
|
||||
*/
|
||||
private LocalDateTime firstSeenTime;
|
||||
|
||||
/**
|
||||
* 修改完mac是否完成首次接入(0:未接入 1:已接入)
|
||||
*/
|
||||
private Integer isAccess;
|
||||
|
||||
|
||||
}
|
||||
@@ -106,13 +106,7 @@ public class CsEquipmentDeliveryVO extends BaseEntity {
|
||||
@ApiModelProperty(value="所属项目名称")
|
||||
private String associatedProjectName;
|
||||
|
||||
@ApiModelProperty(value="治理方法")
|
||||
private String governMethod;
|
||||
|
||||
@ApiModelProperty(value="敏感用户id")
|
||||
private String monitorUser;
|
||||
|
||||
@ApiModelProperty(value="治理类型(稳态:harmonic 暂态:event)")
|
||||
private String governType;
|
||||
@ApiModelProperty(value="修改完mac是否完成首次接入(0:未接入 1:已接入)")
|
||||
private Integer isAccess;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user