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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.njcn.csdevice.controller.equipment;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
import com.njcn.csdevice.service.ICsDeviceRegistryService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/csDeviceRegistry")
|
||||
@Api(tags = "设备注册台账记录表")
|
||||
@AllArgsConstructor
|
||||
public class CsDeviceRegistryController extends BaseController {
|
||||
|
||||
private final ICsDeviceRegistryService csDeviceRegistryService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("批量新增设备注册记录")
|
||||
@ApiImplicitParam(name = "list", value = "设备注册信息列表", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated List<CsDeviceRegistry> list) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
boolean result = csDeviceRegistryService.add(list);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改设备注册记录")
|
||||
@ApiImplicitParam(name = "csDeviceRegistry", value = "设备注册信息", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated CsDeviceRegistry csDeviceRegistry) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
boolean result = csDeviceRegistryService.update(csDeviceRegistry);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateBatch")
|
||||
@ApiOperation("批量修改设备注册记录")
|
||||
@ApiImplicitParam(name = "list", value = "设备注册信息列表", required = true)
|
||||
public HttpResult<Boolean> updateBatch(@RequestBody @Validated List<CsDeviceRegistry> list) {
|
||||
String methodDescribe = getMethodDescribe("updateBatch");
|
||||
boolean result = csDeviceRegistryService.updateBatch(list);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除设备注册记录")
|
||||
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
boolean result = csDeviceRegistryService.delete(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateIsAccessByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid修改isAccess")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "currentNdid", value = "当前设备NDID", required = true),
|
||||
@ApiImplicitParam(name = "isAccess", value = "接入状态(0:未接入 1:已接入)", required = true)
|
||||
})
|
||||
public HttpResult<Boolean> updateIsAccessByCurrentNdid(
|
||||
@RequestParam("currentNdid") String currentNdid,
|
||||
@RequestParam("isAccess") Integer isAccess) {
|
||||
String methodDescribe = getMethodDescribe("updateIsAccessByCurrentNdid");
|
||||
boolean result = csDeviceRegistryService.updateIsAccessByCurrentNdid(currentNdid, isAccess);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/deleteByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid删除设备注册记录")
|
||||
@ApiImplicitParam(name = "currentNdid", value = "当前设备NDID", required = true)
|
||||
public HttpResult<List<CsDeviceRegistry>> deleteByCurrentNdid(@RequestParam("currentNdid") String currentNdid) {
|
||||
String methodDescribe = getMethodDescribe("deleteByCurrentNdid");
|
||||
csDeviceRegistryService.deleteByCurrentNdid(currentNdid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid查询设备注册记录")
|
||||
@ApiImplicitParam(name = "currentNdid", value = "当前设备NDID", required = true)
|
||||
public HttpResult<List<CsDeviceRegistry>> queryByCurrentNdid(@RequestParam("currentNdid") String currentNdid) {
|
||||
String methodDescribe = getMethodDescribe("queryByCurrentNdid");
|
||||
List<CsDeviceRegistry> list = csDeviceRegistryService.queryByCurrentNdid(currentNdid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据id查询设备注册记录")
|
||||
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
|
||||
public HttpResult<CsDeviceRegistry> getById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getById");
|
||||
CsDeviceRegistry csDeviceRegistry = csDeviceRegistryService.getById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDeviceRegistry, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryByCurrentNdidAndClDid")
|
||||
@ApiOperation("根据currentNdid和clDid查询设备注册记录")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "currentNdid", value = "当前设备NDID", required = true),
|
||||
@ApiImplicitParam(name = "clDid", value = "逻辑子设备编号", required = true)
|
||||
})
|
||||
public HttpResult<CsDeviceRegistry> queryByCurrentNdidAndClDid(
|
||||
@RequestParam("currentNdid") String currentNdid,
|
||||
@RequestParam("clDid") Integer clDid) {
|
||||
String methodDescribe = getMethodDescribe("queryByCurrentNdidAndClDid");
|
||||
CsDeviceRegistry pojo = csDeviceRegistryService.queryByCurrentNdidAndClDid(currentNdid, clDid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pojo, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-06-17
|
||||
*/
|
||||
public interface CsDeviceRegistryMapper extends BaseMapper<CsDeviceRegistry> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.csdevice.mapper.CsDeviceRegistryMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-06-17
|
||||
*/
|
||||
public interface ICsDeviceRegistryService extends IService<CsDeviceRegistry> {
|
||||
|
||||
boolean add(List<CsDeviceRegistry> list);
|
||||
|
||||
boolean update(CsDeviceRegistry csDeviceRegistry);
|
||||
|
||||
boolean updateBatch(List<CsDeviceRegistry> list);
|
||||
|
||||
boolean delete(String id);
|
||||
|
||||
boolean updateIsAccessByCurrentNdid(String currentNdid, Integer isAccess);
|
||||
|
||||
void deleteByCurrentNdid(String currentNdid);
|
||||
|
||||
List<CsDeviceRegistry> queryByCurrentNdid(String currentNdid);
|
||||
|
||||
CsDeviceRegistry queryByCurrentNdidAndClDid(String currentNdid, Integer clDid);
|
||||
}
|
||||
@@ -60,7 +60,10 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
|
||||
if (Objects.equals(eleEpdPqd.getPhase(),"T")){
|
||||
vo.setPhasic("/");
|
||||
} else {
|
||||
vo.setPhasic(entry.getValue().stream().map(EleEpdPqd::getPhase).collect(Collectors.joining(",")));
|
||||
vo.setPhasic(entry.getValue().stream()
|
||||
.map(EleEpdPqd::getPhase)
|
||||
.map(phase -> "T".equals(phase) ? "总" : phase)
|
||||
.collect(Collectors.joining(",")));
|
||||
}
|
||||
vo.setName(entry.getKey());
|
||||
vo.setType(eleEpdPqd.getType());
|
||||
|
||||
@@ -64,6 +64,7 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
|
||||
.eq(CsDataSet::getPid,modelId)
|
||||
.eq(CsDataSet::getClDev,clDev)
|
||||
.and(i->i.eq(CsDataSet::getDataType,"Rt").or().isNull(CsDataSet::getDataType))
|
||||
.eq(CsDataSet::getStoreFlag,0)
|
||||
.list();
|
||||
return list.stream().min(Comparator.comparingInt(CsDataSet::getIdx)).get();
|
||||
}
|
||||
@@ -73,7 +74,8 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
|
||||
LambdaQueryWrapper<CsDataSet> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CsDataSet::getPid,modelId)
|
||||
.eq(CsDataSet::getClDev,clDev)
|
||||
.and(i->i.eq(CsDataSet::getDataType,"Rt").or().isNull(CsDataSet::getDataType));
|
||||
.and(i->i.eq(CsDataSet::getDataType,"Rt").or().isNull(CsDataSet::getDataType))
|
||||
.eq(CsDataSet::getStoreFlag,0);
|
||||
//谐波电压含有率
|
||||
if (target == 0) {
|
||||
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$HarmV$0".concat(clDev.toString()));
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsDeviceRegistryMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
import com.njcn.csdevice.service.ICsDeviceRegistryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
@Service
|
||||
public class CsDeviceRegistryServiceImpl extends ServiceImpl<CsDeviceRegistryMapper, CsDeviceRegistry> implements ICsDeviceRegistryService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean add(List<CsDeviceRegistry> list) {
|
||||
return this.saveBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(CsDeviceRegistry csDeviceRegistry) {
|
||||
return this.updateById(csDeviceRegistry);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateBatch(List<CsDeviceRegistry> list) {
|
||||
return this.updateBatchById(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByCurrentNdid(String currentNdid) {
|
||||
LambdaQueryWrapper<CsDeviceRegistry> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsDeviceRegistry::getCurrentNdid, currentNdid);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(String id) {
|
||||
return this.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateIsAccessByCurrentNdid(String currentNdid, Integer isAccess) {
|
||||
LambdaUpdateWrapper<CsDeviceRegistry> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(CsDeviceRegistry::getCurrentNdid, currentNdid)
|
||||
.set(CsDeviceRegistry::getIsAccess, isAccess);
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsDeviceRegistry> queryByCurrentNdid(String currentNdid) {
|
||||
LambdaQueryWrapper<CsDeviceRegistry> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsDeviceRegistry::getCurrentNdid, currentNdid);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsDeviceRegistry queryByCurrentNdidAndClDid(String currentNdid, Integer clDid) {
|
||||
LambdaQueryWrapper<CsDeviceRegistry> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsDeviceRegistry::getCurrentNdid, currentNdid)
|
||||
.eq(CsDeviceRegistry::getClDid, clDid);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,7 +48,6 @@ import com.njcn.csharmonic.api.CsHarmonicPlanLineFeignClient;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.cssystem.api.CsLogsFeignClient;
|
||||
import com.njcn.device.biz.mapper.OverLimitWlMapper;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
@@ -68,7 +67,10 @@ import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -96,7 +98,8 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliveryMapper, CsEquipmentDeliveryPO> implements CsEquipmentDeliveryService {
|
||||
public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliveryMapper, CsEquipmentDeliveryPO> implements CsEquipmentDeliveryService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CsEquipmentDeliveryServiceImpl.class);
|
||||
private final CsDevModelRelationService csDevModelRelationService;
|
||||
private final ICsDataSetService csDataSetService;
|
||||
private final ICsLedgerService csLedgerService;
|
||||
@@ -113,7 +116,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
private final RedisUtil redisUtil;
|
||||
private final CsSoftInfoMapper csSoftInfoMapper;
|
||||
private final MqttUtil mqttUtil;
|
||||
private final CsLogsFeignClient csLogsFeignClient;
|
||||
private final INodeService nodeService;
|
||||
private final CsDevModelService csDevModelService;
|
||||
private final CsLedgerMapper csLedgerMapper;
|
||||
@@ -129,6 +131,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
private final OverLimitWlMapper overLimitWlMapper;
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
private final CsHarmonicPlanLineFeignClient csHarmonicPlanLineFeignClient;
|
||||
private final ICsDeviceRegistryService csDeviceRegistryService;
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Override
|
||||
public void refreshDeviceDataCache() {
|
||||
@@ -217,7 +221,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
overLimitWlMapper.deleteBatchIds(collect);
|
||||
//删除配置
|
||||
csHarmonicPlanLineFeignClient.deleteByLineIds(collect);
|
||||
|
||||
QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>();
|
||||
appLineTopologyDiagramPOQueryWrapper.clear();
|
||||
appLineTopologyDiagramPOQueryWrapper.in("line_id", collect);
|
||||
@@ -245,6 +248,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
QueryWrapper<CsTouristDataPO> queryWrap = new QueryWrapper<>();
|
||||
queryWrap.eq("device_id", id);
|
||||
csTouristDataPOService.getBaseMapper().delete(queryWrap);
|
||||
//删除设备注册表
|
||||
if (po != null) {
|
||||
csDeviceRegistryService.deleteByCurrentNdid(po.getNdid());
|
||||
}
|
||||
if (update) {
|
||||
refreshDeviceDataCache();
|
||||
}
|
||||
@@ -314,7 +321,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
//判断设备是否存在告警
|
||||
temp.setIsAlarm(CollectionUtil.isNotEmpty(eventMap.get(temp.getEquipmentId())));
|
||||
});
|
||||
|
||||
//获取用户置顶的设备
|
||||
List<CsUserPins> topList = csUserPinsService.getPinToTopList();
|
||||
List<String> targetIdList = topList.stream().filter(item -> Objects.equals(item.getTargetType(), 1)).map(CsUserPins::getTargetId).collect(Collectors.toList());
|
||||
@@ -357,12 +363,46 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
|
||||
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
|
||||
//修改了mac地址
|
||||
if (!Objects.equals(po.getNdid(), csEquipmentDeliveryAuditParm.getNdid())) {
|
||||
List<CsDeviceRegistry> updateList = new ArrayList<>();
|
||||
//1、更新设备注册表信息记录
|
||||
List<CsDeviceRegistry> list = csDeviceRegistryService.queryByCurrentNdid(po.getNdid());
|
||||
list.forEach(item->{
|
||||
CsDeviceRegistry csDeviceRegistry = new CsDeviceRegistry();
|
||||
csDeviceRegistry.setId(item.getId());
|
||||
csDeviceRegistry.setCurrentNdid(csEquipmentDeliveryAuditParm.getNdid());
|
||||
csDeviceRegistry.setOldNdid(po.getNdid());
|
||||
csDeviceRegistry.setClDid(item.getClDid());
|
||||
csDeviceRegistry.setFirstSeenTime(item.getFirstSeenTime());
|
||||
csDeviceRegistry.setIsAccess(0);
|
||||
updateList.add(csDeviceRegistry);
|
||||
});
|
||||
csDeviceRegistryService.updateBatch(updateList);
|
||||
//2、修改redis的缓存信息
|
||||
Object data1 = redisUtil.getObjectByKey(AppRedisKey.MODEL + po.getNdid());
|
||||
Object data2 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION + po.getNdid());
|
||||
if (data1 != null) {
|
||||
redisUtil.delete(AppRedisKey.MODEL + po.getNdid());
|
||||
redisUtil.saveByKey(AppRedisKey.MODEL + csEquipmentDeliveryAuditParm.getNdid(), data1);
|
||||
}
|
||||
if (data2 != null) {
|
||||
redisUtil.delete(AppRedisKey.LINE_POSITION + po.getNdid());
|
||||
redisUtil.saveByKey(AppRedisKey.LINE_POSITION + csEquipmentDeliveryAuditParm.getNdid(), data2);
|
||||
}
|
||||
//3、修改设备状态,设备应该是离线 已注册
|
||||
csEquipmentDeliveryPo.setRunStatus(1);
|
||||
csEquipmentDeliveryPo.setStatus(2);
|
||||
//4.清空老mac的数据模板
|
||||
stringRedisTemplate.convertAndSend("model_cache_clear", "clear");
|
||||
}
|
||||
List<CsEquipmentDeliveryPO> list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()).ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
throw new BusinessException("设备名称不能重复");
|
||||
}
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
|
||||
BeanUtils.copyProperties(csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo);
|
||||
csEquipmentDeliveryPo.setMac(csEquipmentDeliveryAuditParm.getNdid().replaceAll("(.{2})", "$1:").substring(0, 17));
|
||||
result = this.updateById(csEquipmentDeliveryPo);
|
||||
//如果是已经接入的设备需要修改台账树中的设备名称
|
||||
CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
|
||||
@@ -394,6 +434,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
queryParam.setPageNum((queryParam.getPageNum() - 1) * queryParam.getPageSize());
|
||||
int total = this.baseMapper.getCounts(queryParam);
|
||||
if (total > 0) {
|
||||
//获取设备注册信息表数据
|
||||
List<CsDeviceRegistry> list = csDeviceRegistryService.list();
|
||||
Map<String, List<CsDeviceRegistry>> groupedMap;
|
||||
if (list == null || list.isEmpty()) {
|
||||
groupedMap = Collections.emptyMap();
|
||||
} else {
|
||||
groupedMap = list.stream().collect(Collectors.groupingBy(CsDeviceRegistry::getCurrentNdid));
|
||||
}
|
||||
List<CsEquipmentDeliveryVO> recordList = this.baseMapper.getList(queryParam);
|
||||
//新增逻辑(针对便携式设备、监测设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
|
||||
for (CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList) {
|
||||
@@ -413,6 +461,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
} else {
|
||||
csEquipmentDeliveryVO.setConnectStatus("未连接");
|
||||
}
|
||||
List<CsDeviceRegistry> data = groupedMap.get(csEquipmentDeliveryVO.getNdid());
|
||||
if (data != null && !data.isEmpty()) {
|
||||
csEquipmentDeliveryVO.setIsAccess(data.get(0).getIsAccess());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(queryParam.getConnectStatus())) {
|
||||
recordList = recordList.stream().filter(item -> queryParam.getConnectStatus() == 0 ? "未连接".equals(item.getConnectStatus()) : "已连接".equals(item.getConnectStatus())).collect(Collectors.toList());
|
||||
@@ -524,21 +576,20 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
addDataSet(dataSetList, item, "暂态数据", "event",4);
|
||||
addDataSet(dataSetList, item, "运行数据", "devRunTrend",5);
|
||||
} else {
|
||||
addDataSet(dataSetList, item, "实时数据", "realtimedata",1);
|
||||
addDataSet(dataSetList, item, "历史数据", "trenddata",2);
|
||||
addDataSet(dataSetList, item, "暂态数据", "event",4);
|
||||
addDataSet(dataSetList, item, "运行数据", "devRunTrend",5);
|
||||
addDataSet(dataSetList, item, "电度数据", "kilowattHour",6);
|
||||
}
|
||||
if (isPortableDevice) {
|
||||
addDataSet(dataSetList, item, "实时数据", "realtimedata",1);
|
||||
// 便携式设备特有的数据集
|
||||
addDataSet(dataSetList, item, "测试项数据", "items",7);
|
||||
}
|
||||
// if (isCLdDevice) {
|
||||
// // 云前置数据集
|
||||
// addDataSet(dataSetList, item, "实时数据", "realtimedata");
|
||||
// addDataSet(dataSetList, item, "暂态数据", "event");
|
||||
// }
|
||||
if (isCLdDevice) {
|
||||
// 云前置数据集
|
||||
addDataSet(dataSetList, item, "实时数据", "realtimedata",1);
|
||||
}
|
||||
|
||||
deviceManagerVo.setDataLevel(item.getDataLevel());
|
||||
}
|
||||
@@ -952,22 +1003,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
csTerminalLogs.setNodeProcess(one.getNodeProcess());
|
||||
csTerminalLogs.setDeviceName(one.getName());
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
//删除设备注册表
|
||||
csDeviceRegistryService.deleteByCurrentNdid(one.getNdid());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateCldDev(CsEquipmentDeliveryAuditParm param) {
|
||||
// //云前置设备判断,修改云前置判断设备是否达到上限
|
||||
// if(ObjectUtil.isNotNull(param.getNodeId())){
|
||||
// Node node = nodeService.getNodeById(param.getNodeId());
|
||||
// List<CsEquipmentDeliveryPO> devList = getListByNodeId(param.getNodeId());
|
||||
// if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) {
|
||||
// throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT);
|
||||
// }
|
||||
// //自动分配进程号
|
||||
// int process = findLeastFrequentProcess(devList,node.getMaxProcessNum());
|
||||
// param.setNodeProcess(process);
|
||||
// }
|
||||
StringUtil.containsSpecialCharacters(param.getNdid());
|
||||
boolean result;
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -980,14 +1022,28 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDe
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, param.getId());
|
||||
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
|
||||
if (!Objects.equals(po.getNdid(), param.getNdid())) {
|
||||
List<CsDeviceRegistry> updateList = new ArrayList<>();
|
||||
//修改了mac地址
|
||||
List<CsDeviceRegistry> list = csDeviceRegistryService.queryByCurrentNdid(po.getNdid());
|
||||
list.forEach(item->{
|
||||
CsDeviceRegistry csDeviceRegistry = new CsDeviceRegistry();
|
||||
csDeviceRegistry.setId(item.getId());
|
||||
csDeviceRegistry.setCurrentNdid(param.getNdid());
|
||||
csDeviceRegistry.setOldNdid(po.getNdid());
|
||||
csDeviceRegistry.setClDid(item.getClDid());
|
||||
csDeviceRegistry.setFirstSeenTime(item.getFirstSeenTime());
|
||||
updateList.add(csDeviceRegistry);
|
||||
});
|
||||
csDeviceRegistryService.updateBatch(updateList);
|
||||
}
|
||||
List<CsEquipmentDeliveryPO> list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, param.getId()).ne(CsEquipmentDeliveryPO::getNdid, param.getNdid()).eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
throw new BusinessException("设备名称不能重复");
|
||||
}
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
|
||||
BeanUtils.copyProperties(param, csEquipmentDeliveryPo);
|
||||
String path = this.createPath(param.getNdid());
|
||||
csEquipmentDeliveryPo.setMac(path);
|
||||
csEquipmentDeliveryPo.setMac(param.getNdid().replaceAll("(.{2})", "$1:").substring(0, 17));
|
||||
result = this.updateById(csEquipmentDeliveryPo);
|
||||
//修改台账树中的设备名称
|
||||
CsLedger csLedger = csLedgerService.findDataById(param.getId());
|
||||
|
||||
@@ -210,9 +210,17 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
}
|
||||
|
||||
//获取监测点数据
|
||||
Integer targetLevel = LineBaseEnum.LINE_LEVEL.getCode();
|
||||
List<String> lineIds = allList.stream()
|
||||
.filter(item -> item != null && targetLevel.equals(item.getLevel()))
|
||||
.map(CsLedgerVO::getId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
List<CsLinePO> poList = csLinePOService.listByIds(lineIds);
|
||||
Map<String, CsLinePO> lineMap = poList.stream().collect(Collectors.toMap(CsLinePO::getLineId,Function.identity(),(v1, v2) -> v1));
|
||||
List<CsLedgerVO> finalLineList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()))
|
||||
.filter(item -> item.getLevel().equals(targetLevel))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.peek(
|
||||
item -> {
|
||||
@@ -231,16 +239,10 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
item.setGovernPlanName(afterPlan.getGovernName());
|
||||
}
|
||||
item.setType("line");
|
||||
String index = item.getId().substring(item.getId().length() - 1);
|
||||
if (Objects.equals(index, "0")) {
|
||||
item.setLineType(0);
|
||||
} else {
|
||||
item.setLineType(1);
|
||||
}
|
||||
LambdaQueryWrapper<CsLinePO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsLinePO::getLineId, item.getId()).eq(CsLinePO::getStatus, 1);
|
||||
CsLinePO po = csLinePOService.getOne(queryWrapper);
|
||||
CsLinePO po = lineMap.get(item.getId());
|
||||
item.setConType(po.getConType());
|
||||
item.setSort(po.getLineNo());
|
||||
item.setLineType(Objects.equals(po.getClDid(), 0) ? 0 : 1);
|
||||
}
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.csdevice.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -27,6 +28,7 @@ import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO;
|
||||
import com.njcn.csdevice.service.CsDevModelService;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.ICsDataSetService;
|
||||
import com.njcn.csdevice.service.ICsDeviceRegistryService;
|
||||
import com.njcn.csharmonic.api.CsHarmonicPlanFeignClient;
|
||||
import com.njcn.csharmonic.api.CsHarmonicPlanLineFeignClient;
|
||||
import com.njcn.csharmonic.api.PqGovernPlanFeignClient;
|
||||
@@ -53,6 +55,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -75,7 +78,6 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
private final CsTerminalLogsMapper csTerminalLogsMapper;
|
||||
private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient;
|
||||
private final PqGovernPlanFeignClient pqGovernPlanFeignClient;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
|
||||
@@ -85,7 +87,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
private final CsHarmonicPlanLineFeignClient csHarmonicPlanLineFeignClient;
|
||||
private final CsLineLatestDataFeignClient csLineLatestDataFeignClient;
|
||||
private final CsCommTerminalFeignClient csCommTerminal;
|
||||
|
||||
private final ICsDeviceRegistryService csDeviceRegistryService;
|
||||
|
||||
@Override
|
||||
public List<CsLinePO> getLineByDev(List<String> list) {
|
||||
@@ -151,13 +153,23 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CsLinePO addCldLine(CsLineParam param) {
|
||||
String lineId = param.getDevMac().replace(":","") + param.getLineNo();
|
||||
String lineId = IdUtil.fastSimpleUUID();
|
||||
List<CsDeviceRegistry> data = csDeviceRegistryService.queryByCurrentNdid(param.getDevMac().replace(":", ""));
|
||||
Map<Integer, String> clDidToIdMap;
|
||||
if (CollUtil.isNotEmpty(data)) {
|
||||
clDidToIdMap = data.stream().collect(Collectors.toMap(CsDeviceRegistry::getClDid, CsDeviceRegistry::getId, (a, b) -> a));
|
||||
} else {
|
||||
clDidToIdMap = new HashMap<>();
|
||||
}
|
||||
if (!Objects.isNull(clDidToIdMap.get(param.getLineNo()))) {
|
||||
lineId = clDidToIdMap.get(param.getLineNo());
|
||||
}
|
||||
CsLinePO po = new CsLinePO();
|
||||
//1.新增监测点信息
|
||||
BeanUtils.copyProperties(param,po);
|
||||
po.setStatus(1);
|
||||
po.setRunStatus(param.getRunStatus());
|
||||
po.setLineId(param.getDevMac().replace(":","") + param.getLineNo());
|
||||
po.setLineId(lineId);
|
||||
//模板id
|
||||
CsDevModelPO po1 = csDevModelService.getCldModel();
|
||||
po.setDataModelId(po1.getId());
|
||||
@@ -170,10 +182,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
}
|
||||
po.setClDid(param.getLineNo());
|
||||
//监测位置
|
||||
//DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData();
|
||||
po.setPosition(param.getPosition().isEmpty()?null:param.getPosition());
|
||||
this.save(po);
|
||||
|
||||
//2.新增台账树信息
|
||||
CsLedger csLedger = new CsLedger();
|
||||
csLedger.setId(lineId);
|
||||
@@ -184,7 +194,6 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
csLedger.setState(1);
|
||||
csLedger.setSort(0);
|
||||
csLedgerMapper.insert(csLedger);
|
||||
|
||||
//3.新增稳态事件指标配置
|
||||
csHarmonicPlanLineFeignClient.deleteByLineIds(Collections.singletonList(lineId));
|
||||
List<CsHarmonicPlan> planList = csHarmonicPlanFeignClient.getByName("通用方案").getData();
|
||||
@@ -195,6 +204,16 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
param1.setLineIds(Collections.singletonList(lineId));
|
||||
csHarmonicPlanLineFeignClient.savePlanLines(param1);
|
||||
}
|
||||
//4.新增装置注册表数据
|
||||
if (Objects.isNull(clDidToIdMap.get(param.getLineNo()))) {
|
||||
CsDeviceRegistry registry = new CsDeviceRegistry();
|
||||
registry.setId(lineId);
|
||||
registry.setCurrentNdid(param.getDevMac());
|
||||
registry.setOldNdid(param.getDevMac());
|
||||
registry.setClDid(param.getLineNo());
|
||||
registry.setFirstSeenTime(LocalDateTime.now());
|
||||
csDeviceRegistryService.add(Collections.singletonList(registry));
|
||||
}
|
||||
return po;
|
||||
}
|
||||
|
||||
@@ -253,12 +272,12 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteCldLine(String id) {
|
||||
CsLinePO po = this.getById(id);
|
||||
|
||||
this.removeById(id);
|
||||
csLedgerMapper.deleteById(id);
|
||||
//删除稳态事件指标配置
|
||||
csHarmonicPlanLineFeignClient.deleteByLineIds(Collections.singletonList(id));
|
||||
|
||||
//删除装置注册表数据
|
||||
csDeviceRegistryService.delete(id);
|
||||
//新增台账日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(po.getDeviceId());
|
||||
|
||||
@@ -618,6 +618,8 @@ class IcdServiceImpl implements IcdService {
|
||||
}
|
||||
});
|
||||
}
|
||||
list.sort(Comparator.comparingInt((CsLinePO cs) -> cs.getLineNo() == null ? Integer.MAX_VALUE : cs.getLineNo())
|
||||
.thenComparingInt(cs -> cs.getClDid() == null ? Integer.MAX_VALUE : cs.getClDid()));
|
||||
vo.setLineInfoList(list);
|
||||
}
|
||||
|
||||
@@ -657,17 +659,17 @@ class IcdServiceImpl implements IcdService {
|
||||
// 设置线路信息
|
||||
List<CsLinePO> line = csLinePOService.listByIds(Collections.singletonList(id));
|
||||
if (CollectionUtil.isNotEmpty(line)) {
|
||||
line.forEach(item->{
|
||||
if (Objects.isNull(item.getPt2Ratio())) {
|
||||
for (CsLinePO item : line) {
|
||||
if (item.getPt2Ratio() == null) {
|
||||
item.setPt2Ratio(1.0);
|
||||
}
|
||||
if (Objects.isNull(item.getCt2Ratio())) {
|
||||
if (item.getCt2Ratio() == null) {
|
||||
item.setCt2Ratio(1.0);
|
||||
}
|
||||
if (Objects.isNull(item.getLineNo())) {
|
||||
item.setLineNo(item.getClDid() == 0 ? null:item.getClDid());
|
||||
if (item.getLineNo() == null && item.getClDid() != null && item.getClDid() != 0) {
|
||||
item.setLineNo(item.getClDid());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
vo.setLineInfoList(line);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,8 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
LambdaQueryWrapper<CsLinePO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsLinePO::getLineId,lineId).eq(CsLinePO::getStatus,1);
|
||||
CsLinePO po = csLinePOService.getOne(queryWrapper);
|
||||
String cdid = uploadDataParam.getLineId().substring(uploadDataParam.getLineId().length() - 1);
|
||||
//String cdid = uploadDataParam.getLineId().substring(uploadDataParam.getLineId().length() - 1);
|
||||
Integer cdid = po.getClDid();
|
||||
//第一步解析redcord.bin文件获取监测点序号做校验
|
||||
List<MultipartFile> record = uploadDataParam.getFiles().stream().filter(
|
||||
temp -> temp.getOriginalFilename().contains("record.bin"))
|
||||
@@ -213,7 +214,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
//监测点序号
|
||||
int lineIdx = cmnModeCfg.line_idx;
|
||||
|
||||
if(lineIdx!=Integer.valueOf(cdid)){
|
||||
if(lineIdx != cdid){
|
||||
throw new BusinessException(AlgorithmResponseEnum.LINE_NUM_MISMATCH);
|
||||
}
|
||||
|
||||
@@ -313,7 +314,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
|
||||
List<PqdData> pqdData = (List<PqdData>) response.getObj();
|
||||
pqdData.forEach(temp->{
|
||||
temp.setClDid(cdid);
|
||||
temp.setClDid(String.valueOf(cdid));
|
||||
temp.setIsAbnormal(0);
|
||||
temp.setProcess(data1.get(0).getProcess()+"");
|
||||
temp.setLineId(uploadDataParam.getLineId());
|
||||
|
||||
Reference in New Issue
Block a user