refactor(device): 重构设备交付服务并更新Nacos配置

- 在多个模块的bootstrap.yml中添加Nacos用户名密码配置
- 注释掉日志配置中的用户名密码参数避免安全风险
- 重构CsEquipmentDeliveryServiceImpl中的updateEquipmentDelivery方法
- 添加NDID变更处理逻辑,包括设备注册表更新和Redis缓存迁移
- 实现设备名称重复校验功能
- 添加工程项目的变更处理和台账树更新
- 移除CsEventPO中的rms和uchg字段及JsonFormat注解
- 将getYzd方法从CsEventPOServiceImpl迁移到PortableOfflLogServiceImpl
- 添加事件严重度和落点计算功能
- 更新补召查询逻辑,使用SortBy参数区分不同类型
- 添加CsLedgerService的queryByPid接口实现
This commit is contained in:
xy
2026-06-25 15:53:10 +08:00
parent a27315075c
commit dbdf9ba000
13 changed files with 332 additions and 145 deletions

View File

@@ -97,4 +97,6 @@ public interface ICsLedgerService extends IService<CsLedger> {
List<DevDetailDTO> getEngineeringHaveDevs(List<String> list); List<DevDetailDTO> getEngineeringHaveDevs(List<String> list);
List<CsLedger> queryByPid(String pid);
} }

View File

@@ -348,76 +348,236 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return list; return list;
} }
// ... existing code ...
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm) { public Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm auditParm) {
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid()); StringUtil.containsSpecialCharacters(auditParm.getNdid());
boolean result; // 校验ndid不重复
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); long ndidCount = this.count(new LambdaQueryWrapper<CsEquipmentDeliveryPO>()
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); .eq(CsEquipmentDeliveryPO::getNdid, auditParm.getNdid())
int countByAccount = this.count(lambdaQueryWrapper); .in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3))
//大于等于1个则表示重复 .ne(CsEquipmentDeliveryPO::getId, auditParm.getId()));
if (countByAccount >= 1) { if (ndidCount > 0) {
throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR); throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR);
} }
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>(); // 查询原记录
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); CsEquipmentDeliveryPO po = this.getById(auditParm.getId());
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2); if (Objects.isNull(po)) {
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO(); throw new BusinessException("设备不存在");
//修改了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()); long nameCount = this.lambdaQuery()
redisUtil.saveByKey(AppRedisKey.LINE_POSITION + csEquipmentDeliveryAuditParm.getNdid(), data2); .ne(CsEquipmentDeliveryPO::getId, auditParm.getId())
} .ne(CsEquipmentDeliveryPO::getNdid, auditParm.getNdid())
//3、修改设备状态设备应该是离线 已注册 .eq(CsEquipmentDeliveryPO::getName, auditParm.getName())
csEquipmentDeliveryPo.setRunStatus(1); .ne(CsEquipmentDeliveryPO::getRunStatus, 0)
csEquipmentDeliveryPo.setStatus(2); .eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT")
//4.清空老mac的数据模板 .count();
stringRedisTemplate.convertAndSend("model_cache_clear", "clear"); if (nameCount > 0) {
//5.修改二维码信息
String qr = this.createQr(csEquipmentDeliveryAuditParm.getNdid());
csEquipmentDeliveryPo.setQrPath(qr);
}
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("设备名称不能重复"); throw new BusinessException("设备名称不能重复");
} }
BeanUtils.copyProperties(csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo); CsEquipmentDeliveryPO updatePo = new CsEquipmentDeliveryPO();
csEquipmentDeliveryPo.setMac(csEquipmentDeliveryAuditParm.getNdid().replaceAll("(.{2})", "$1:").substring(0, 17)); // 修改了ndid时的联动处理
result = this.updateById(csEquipmentDeliveryPo); if (!Objects.equals(po.getNdid(), auditParm.getNdid())) {
//如果是已经接入的设备需要修改台账树中的设备名称 handleNdidChange(po, auditParm, updatePo);
CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId()); }
BeanUtils.copyProperties(auditParm, updatePo);
updatePo.setMac(createPath(auditParm.getNdid()));
// 更新台账树中的设备名称及工程/项目
CsLedger csLedger = csLedgerService.findDataById(auditParm.getId());
if (ObjectUtil.isNotNull(csLedger)) { if (ObjectUtil.isNotNull(csLedger)) {
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update(); csLedger.setName(auditParm.getName());
BeanUtils.copyProperties(csLedger, csLedgerParam); updateLedger(csLedger);
csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName()); handleEngineeringProjectChange(po, auditParm, csLedger);
csLedgerService.updateLedgerTree(csLedgerParam);
} }
return result; return this.updateById(updatePo);
} }
private void handleNdidChange(CsEquipmentDeliveryPO po, CsEquipmentDeliveryAuditParm auditParm, CsEquipmentDeliveryPO updatePo) {
String oldNdid = po.getNdid();
String newNdid = auditParm.getNdid();
// 1、更新设备注册表信息记录
List<CsDeviceRegistry> registryList = csDeviceRegistryService.queryByCurrentNdid(oldNdid);
List<CsDeviceRegistry> updateList = registryList.stream().map(item -> {
CsDeviceRegistry registry = new CsDeviceRegistry();
registry.setId(item.getId());
registry.setCurrentNdid(newNdid);
registry.setOldNdid(oldNdid);
registry.setClDid(item.getClDid());
registry.setFirstSeenTime(item.getFirstSeenTime());
registry.setIsAccess(0);
return registry;
}).collect(Collectors.toList());
csDeviceRegistryService.updateBatch(updateList);
// 2、迁移redis缓存
transferRedisCache(AppRedisKey.MODEL, oldNdid, newNdid);
transferRedisCache(AppRedisKey.LINE_POSITION, oldNdid, newNdid);
// 3、修改设备状态为离线、已注册
updatePo.setRunStatus(1);
updatePo.setStatus(2);
// 4、清空老mac的数据模板
stringRedisTemplate.convertAndSend("model_cache_clear", "clear");
// 5、修改二维码信息
updatePo.setQrPath(this.createQr(newNdid));
}
private void transferRedisCache(String keyPrefix, String oldNdid, String newNdid) {
Object data = redisUtil.getObjectByKey(keyPrefix + oldNdid);
if (data != null) {
redisUtil.delete(keyPrefix + oldNdid);
redisUtil.saveByKey(keyPrefix + newNdid, data);
}
}
private void handleEngineeringProjectChange(CsEquipmentDeliveryPO po, CsEquipmentDeliveryAuditParm auditParm, CsLedger csLedger) {
boolean engineeringChanged = !Objects.equals(po.getAssociatedEngineering(), auditParm.getAssociatedEngineering());
boolean projectChanged = !Objects.equals(po.getAssociatedProject(), auditParm.getAssociatedProject());
if (!engineeringChanged && !projectChanged) {
return;
}
// 已接入过的设备,工程和项目不能为空
if (!Objects.equals(po.getStatus(), 1)) {
if (StringUtils.isBlank(auditParm.getAssociatedEngineering()) || StringUtils.isBlank(auditParm.getAssociatedProject())) {
throw new BusinessException("装置已接入过,工程项目不可设置为空");
}
// 修改设备台账的pid和pids
csLedger.setPid(auditParm.getAssociatedProject());
String[] pidsParts = csLedger.getPids().split(",");
pidsParts[1] = auditParm.getAssociatedEngineering();
pidsParts[2] = auditParm.getAssociatedProject();
csLedger.setPids(String.join(",", pidsParts));
updateLedger(csLedger);
// 修改监测点的pids
List<CsLedger> lineLedgers = csLedgerService.queryByPid(po.getId());
lineLedgers.forEach(item -> {
String[] linePidsParts = item.getPids().split(",");
linePidsParts[1] = auditParm.getAssociatedEngineering();
linePidsParts[2] = auditParm.getAssociatedProject();
item.setPids(String.join(",", linePidsParts));
updateLedger(item);
});
}
}
private void updateLedger(CsLedger csLedger) {
CsLedgerParam.Update updateParam = new CsLedgerParam.Update();
BeanUtils.copyProperties(csLedger, updateParam);
csLedgerService.updateLedgerTree(updateParam);
}
// ... existing code ...
// @Override
// @Transactional(rollbackFor = Exception.class)
// public Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm) {
// StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid());
// boolean result;
// LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
// lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
// int countByAccount = this.count(lambdaQueryWrapper);
// //大于等于1个则表示重复
// if (countByAccount >= 1) {
// throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR);
// }
// 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");
// //5.修改二维码信息
// String qr = this.createQr(csEquipmentDeliveryAuditParm.getNdid());
// csEquipmentDeliveryPo.setQrPath(qr);
// }
// 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("设备名称不能重复");
// }
// BeanUtils.copyProperties(csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo);
// csEquipmentDeliveryPo.setMac(csEquipmentDeliveryAuditParm.getNdid().replaceAll("(.{2})", "$1:").substring(0, 17));
//
// //如果是已经接入的设备需要修改台账树中的设备名称
// CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
// if (ObjectUtil.isNotNull(csLedger)) {
// CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
// BeanUtils.copyProperties(csLedger, csLedgerParam);
// csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName());
// csLedgerService.updateLedgerTree(csLedgerParam);
// }
// //修改预设的工程和项目
// //判断设备状态如果已经接入过那么工程项目就不能设置为null如果没有接入过没有限制
// if (!Objects.equals(po.getAssociatedEngineering(), csEquipmentDeliveryAuditParm.getAssociatedEngineering())
// || !Objects.equals(po.getAssociatedProject(), csEquipmentDeliveryAuditParm.getAssociatedProject())) {
// if (po.getStatus() != 1) {
// if (Objects.isNull(csEquipmentDeliveryAuditParm.getAssociatedEngineering()) || Objects.isNull(csEquipmentDeliveryAuditParm.getAssociatedProject())) {
// throw new BusinessException("装置已接入过,工程项目不可设置为空");
// } else {
// //修改设备
// CsLedger csLedger2 = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
// csLedger2.setPid(csEquipmentDeliveryAuditParm.getAssociatedProject());
// String pidS = csLedger2.getPids();
// String[] parts = pidS.split(",");
// parts[1] = csEquipmentDeliveryAuditParm.getAssociatedEngineering();
// parts[2] = csEquipmentDeliveryAuditParm.getAssociatedProject();
// String newPidS = String.join(",", parts);
// csLedger2.setPids(newPidS);
// CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
// BeanUtils.copyProperties(csLedger2, csLedgerParam);
// csLedgerService.updateLedgerTree(csLedgerParam);
// csEquipmentDeliveryPo.setAssociatedEngineering(csEquipmentDeliveryAuditParm.getAssociatedEngineering());
// csEquipmentDeliveryPo.setAssociatedProject(csEquipmentDeliveryAuditParm.getAssociatedProject());
// //修改监测点
// List<CsLedger> csLedgers = csLedgerService.queryByPid(po.getId());
// csLedgers.forEach(item->{
// String linePidS = item.getPids();
// String[] lineParts = linePidS.split(",");
// lineParts[1] = csEquipmentDeliveryAuditParm.getAssociatedEngineering();
// lineParts[2] = csEquipmentDeliveryAuditParm.getAssociatedProject();
// String lineNewPidS = String.join(",", lineParts);
// item.setPids(lineNewPidS);
// CsLedgerParam.Update csLedgerParam2 = new CsLedgerParam.Update();
// BeanUtils.copyProperties(item, csLedgerParam2);
// csLedgerService.updateLedgerTree(csLedgerParam2);
// });
// }
// }
// }
// result = this.updateById(csEquipmentDeliveryPo);
// return result;
// }
@Override @Override
public void updateStatusBynDid(String nDId, Integer status) { public void updateStatusBynDid(String nDId, Integer status) {
boolean result; boolean result;
@@ -633,6 +793,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one(); return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response) { public List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response) {

View File

@@ -1471,6 +1471,13 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
return result; return result;
} }
@Override
public List<CsLedger> queryByPid(String pid) {
return this.list(new LambdaQueryWrapper<CsLedger>()
.eq(CsLedger::getPid, pid)
.eq(CsLedger::getState, 1));
}
/** /**
* 获取子节点 * 获取子节点
*/ */

View File

@@ -184,7 +184,12 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
, DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()))); , DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())));
//排序 //排序
queryWrapper.orderBy(true, false, "cs_terminal_reply.create_time"); queryWrapper.orderBy(true, false, "cs_terminal_reply.create_time");
queryWrapper.in("cs_terminal_reply.code", Arrays.asList("allFile", "allEvent", "oneFile","harmonic")); //这边不想新建字段了用SortBy代替补召类型
if (Objects.equals(param.getSortBy(), "harmonic")) {
queryWrapper.in("cs_terminal_reply.code", Collections.singletonList("harmonic"));
} else {
queryWrapper.in("cs_terminal_reply.code", Arrays.asList("allFile", "allEvent", "oneFile"));
}
Page<CsTerminalReply> csTerminalReplyPage = this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper); Page<CsTerminalReply> csTerminalReplyPage = this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
List<CsTerminalReply> records = csTerminalReplyPage.getRecords(); List<CsTerminalReply> records = csTerminalReplyPage.getRecords();
@@ -202,19 +207,6 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
cldLogsVo.setEngineeringName(ledgerMap.get(split[1]).getName()); cldLogsVo.setEngineeringName(ledgerMap.get(split[1]).getName());
cldLogsVo.setProjectName(ledgerMap.get(split[2]).getName()); cldLogsVo.setProjectName(ledgerMap.get(split[2]).getName());
cldLogsVo.setDeviceName(ledgerMap.get(item.getDeviceId()).getName()); cldLogsVo.setDeviceName(ledgerMap.get(item.getDeviceId()).getName());
// String lineId = item.getLineId();
// String[] lineSplit = lineId.split(",");
// String result;
// if (lineSplit.length == 1) {
// result = ledgerMap.get(lineSplit[0]).getName();
// } else {
// result = Arrays.stream(lineSplit)
// .map(ledgerMap::get)
// .filter(Objects::nonNull)
// .map(CsLedgerVO::getName)
// .collect(Collectors.joining(","));
// }
// cldLogsVo.setLineName(result);
cldLogsVo.setLineName(ledgerMap.get(param.getSearchValue()).getName()); cldLogsVo.setLineName(ledgerMap.get(param.getSearchValue()).getName());
cldLogsVo.setLog(getLogDescription(item.getCode())); cldLogsVo.setLog(getLogDescription(item.getCode()));
cldLogsVo.setLogTime(item.getCreateTime()); cldLogsVo.setLogTime(item.getCreateTime());

View File

@@ -37,6 +37,7 @@ import com.njcn.csharmonic.offline.mincfg.vo.CmnModeCfg;
import com.njcn.csharmonic.offline.vo.Response; import com.njcn.csharmonic.offline.vo.Response;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.event.common.mapper.WlRmpEventDetailMapper; import com.njcn.event.common.mapper.WlRmpEventDetailMapper;
import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.influx.imapper.*; import com.njcn.influx.imapper.*;
import com.njcn.influx.pojo.po.*; import com.njcn.influx.pojo.po.*;
@@ -115,6 +116,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
private final CsLinePOService csLinePOService; private final CsLinePOService csLinePOService;
private final WlRmpEventDetailMapper wlRmpEventDetailMapper; private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
private final EventCauseFeignClient eventCauseFeignClient; private final EventCauseFeignClient eventCauseFeignClient;
private final EventAnalysisService eventAnalysisService;
@Override @Override
public Page<PortableOfflLog> queryPage(BaseParam baseParam) { public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
@@ -465,24 +467,6 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
} }
} }
csEventPO.setWavePath(wavePath); csEventPO.setWavePath(wavePath);
if (Objects.equals(csEventPO.getTag(),DataParam.dipStrName)) {
EventAnalysisDTO var1 = new EventAnalysisDTO();
var1.setWlFilePath(wavePath);
EventAnalysisDTO dto = eventCauseFeignClient.analysisCauseAndType(var1).getData();
String id1 = list1.stream()
.filter(item -> Objects.equals(item.getAlgoDescribe(), dto.getCause()))
.map(DictData::getId)
.findFirst()
.orElse(null);
csEventPO.setAdvanceReason(id1);
String id2 = list2.stream()
.filter(item -> Objects.equals(item.getAlgoDescribe(), dto.getType()))
.map(DictData::getId)
.findFirst()
.orElse(null);
csEventPO.setAdvanceType(id2);
}
//默认暂态事件 //默认暂态事件
csEventPO.setType(0); csEventPO.setType(0);
@@ -539,6 +523,35 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
csEventPO.setPhase(entData.getEvtParamPhase()); csEventPO.setPhase(entData.getEvtParamPhase());
csEventPO.setPersistTime(entData.getEvtParamTm()); csEventPO.setPersistTime(entData.getEvtParamTm());
csEventPO.setAmplitude(entData.getEvtParamVVaDepth()); csEventPO.setAmplitude(entData.getEvtParamVVaDepth());
if (Objects.equals(csEventPO.getTag(),DataParam.dipStrName)) {
//计算暂降原因和类型
EventAnalysisDTO var1 = new EventAnalysisDTO();
var1.setWlFilePath(wavePath);
EventAnalysisDTO dto = eventCauseFeignClient.analysisCauseAndType(var1).getData();
String id1 = list1.stream()
.filter(item -> Objects.equals(item.getAlgoDescribe(), dto.getCause()))
.map(DictData::getId)
.findFirst()
.orElse(null);
csEventPO.setAdvanceReason(id1);
String id2 = list2.stream()
.filter(item -> Objects.equals(item.getAlgoDescribe(), dto.getType()))
.map(DictData::getId)
.findFirst()
.orElse(null);
csEventPO.setAdvanceType(id2);
if (!Objects.isNull(csEventPO.getAmplitude()) && !Objects.isNull(csEventPO.getPersistTime())) {
//计算暂降严重度
csEventPO.setSeverity(Double.valueOf(getYzd(csEventPO.getPersistTime()*1000,csEventPO.getAmplitude())));
}
}
if (!Objects.isNull(csEventPO.getAmplitude()) && !Objects.isNull(csEventPO.getPersistTime())) {
//计算落点
String dropZone = eventAnalysisService.determineDropZone(String.valueOf(csEventPO.getAmplitude()),String.valueOf(csEventPO.getPersistTime()));
csEventPO.setLandPoint(dropZone);
}
csEventPOS.add(csEventPO); csEventPOS.add(csEventPO);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -568,6 +581,30 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
portableOffMainLogService.save(portableOffMainLog); portableOffMainLogService.save(portableOffMainLog);
} }
/**
* 获取该事件的严重度
*
* @param persistTime 持续时间 ms单位
* @param eventValue 暂降、暂升幅值
*/
public String getYzd(Double persistTime, Double eventValue) {
Double yzd;
// 格式化小数
DecimalFormat df = new DecimalFormat("0.000");
if (persistTime <= 20) {
yzd = 1.0 - eventValue;
} else if (persistTime > 20 && persistTime <= 200) {
yzd = 2.0 * (1 - eventValue);
} else if (persistTime > 200 && persistTime <= 500) {
yzd = 3.3 * (1 - eventValue);
} else if (persistTime > 500 && persistTime <= 10000) {
yzd = 5.0 * (1 - eventValue);
} else {
yzd = 10.0 * (1 - eventValue);
}
return df.format(yzd);
}
public void insertEvent(CsEventPO item) { public void insertEvent(CsEventPO item) {
RmpEventDetailPO rmpEventDetailPo = new RmpEventDetailPO(); RmpEventDetailPO rmpEventDetailPo = new RmpEventDetailPO();
rmpEventDetailPo.setEventId(item.getId()); rmpEventDetailPo.setEventId(item.getId());
@@ -577,11 +614,20 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
rmpEventDetailPo.setFeatureAmplitude(item.getAmplitude()); rmpEventDetailPo.setFeatureAmplitude(item.getAmplitude());
rmpEventDetailPo.setDuration(item.getPersistTime()); rmpEventDetailPo.setDuration(item.getPersistTime());
rmpEventDetailPo.setEventDescribe(getTag(item.getTag())); rmpEventDetailPo.setEventDescribe(getTag(item.getTag()));
rmpEventDetailPo.setDealFlag(0); rmpEventDetailPo.setWavePath(item.getWavePath());
if (!Objects.isNull(item.getWavePath())) {
rmpEventDetailPo.setFileFlag(1);
} else {
rmpEventDetailPo.setFileFlag(0); rmpEventDetailPo.setFileFlag(0);
}
rmpEventDetailPo.setPhase(item.getPhase()); rmpEventDetailPo.setPhase(item.getPhase());
rmpEventDetailPo.setAdvanceReason(item.getAdvanceReason()); rmpEventDetailPo.setAdvanceReason(item.getAdvanceReason());
rmpEventDetailPo.setAdvanceType(item.getAdvanceType()); rmpEventDetailPo.setAdvanceType(item.getAdvanceType());
if (!Objects.isNull(item.getAdvanceReason()) && !Objects.isNull(item.getAdvanceType())) {
rmpEventDetailPo.setDealFlag(1);
} else {
rmpEventDetailPo.setDealFlag(0);
}
wlRmpEventDetailMapper.insert(rmpEventDetailPo); wlRmpEventDetailMapper.insert(rmpEventDetailPo);
} }

View File

@@ -21,9 +21,13 @@ spring:
discovery: discovery:
ip: @service.server.url@ ip: @service.server.url@
server-addr: @nacos.url@ server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@ namespace: @nacos.namespace@
config: config:
server-addr: @nacos.url@ server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@ namespace: @nacos.namespace@
file-extension: yaml file-extension: yaml
shared-configs: shared-configs:
@@ -41,6 +45,7 @@ spring:
#项目日志的配置 #项目日志的配置
logging: logging:
# config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&username=@nacos.username@&password=@nacos.password@&group=DEFAULT_GROUP&dataId=logback.xml
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level: level:
root: warn root: warn

View File

@@ -1,19 +1,25 @@
package com.njcn.csharmonic.offline.log.vo; package com.njcn.csharmonic.offline.log.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
@Data @Data
public class NewTaglogbuffer implements Serializable { public class NewTaglogbuffer implements Serializable {
private NewHeadTaglogbuffer newHeadTaglogbuffer; private NewHeadTaglogbuffer newHeadTaglogbuffer;
private List<NewBodyTaglogbuffer> newBodyTaglogbuffers; private List<NewBodyTaglogbuffer> newBodyTaglogbuffers;
private LocalDateTime start, end; //事件起始和结束时间 //事件起始事件
private String path = ""; //事件对应波形文件名称 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime start;
//事件结束时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime end;
//事件对应波形文件名称
private String path = "";
public NewTaglogbuffer(NewHeadTaglogbuffer head, ArrayList<NewBodyTaglogbuffer> body) { public NewTaglogbuffer(NewHeadTaglogbuffer head, ArrayList<NewBodyTaglogbuffer> body) {
newHeadTaglogbuffer = head; newHeadTaglogbuffer = head;

View File

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.njcn.db.bo.BaseEntity; import com.njcn.db.bo.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -44,7 +43,7 @@ public class CsEventPO extends BaseEntity {
/** /**
* 事件时间 * 事件时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "start_time") @TableField(value = "start_time")
private LocalDateTime startTime; private LocalDateTime startTime;
@@ -154,18 +153,6 @@ public class CsEventPO extends BaseEntity {
@TableField(value = "sag_source") @TableField(value = "sag_source")
private String sagSource; private String sagSource;
/**
* 瞬态-有效值
*/
@TableField(value = "rms")
private Double rms;
/**
* 瞬态-电压变化
*/
@TableField(value = "uchg")
private Double uchg;
/** /**
* 暂降严重度 * 暂降严重度
*/ */

View File

@@ -768,29 +768,6 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
return vo; return vo;
} }
/**
* 获取该事件的严重度
*
* @param persisttime 持续时间 ms单位
* @param eventvaule 暂降、暂升幅值
*/
public static String getYzd(Float persisttime, Float eventvaule) {
float yzd;
DecimalFormat df = new DecimalFormat("0.000");// 格式化小数
if (persisttime <= 20) {
yzd = 1 - eventvaule;
} else if (persisttime > 20 && persisttime <= 200) {
yzd = 2 * (1 - eventvaule);
} else if (persisttime > 200 && persisttime <= 500) {
yzd = 3.3f * (1 - eventvaule);
} else if (persisttime > 500 && persisttime <= 10000) {
yzd = 5 * (1 - eventvaule);
} else {
yzd = 10 * (1 - eventvaule);
}
return df.format(yzd);
}
public String getTag(Integer type) { public String getTag(Integer type) {
String tag; String tag;
switch (type) { switch (type) {

View File

@@ -5,20 +5,15 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.github.tocrhz.mqtt.publisher.MqttPublisher; import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.access.api.CsTopicFeignClient;
import com.njcn.access.enums.AccessEnum; import com.njcn.access.enums.AccessEnum;
import com.njcn.access.enums.TypeEnum; import com.njcn.access.enums.TypeEnum;
import com.njcn.access.pojo.RspDataDto; import com.njcn.access.pojo.RspDataDto;
import com.njcn.access.pojo.dto.ReqAndResDto; import com.njcn.access.pojo.dto.ReqAndResDto;
import com.njcn.access.pojo.dto.file.FileDto; import com.njcn.access.pojo.dto.file.FileDto;
import com.njcn.access.utils.ChannelObjectUtil; import com.njcn.access.utils.ChannelObjectUtil;
import com.njcn.access.utils.MqttUtil;
import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.api.DeviceFtpFeignClient;
import com.njcn.csdevice.api.EquipmentFeignClient; import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.api.PortableOffLogFeignClient;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
@@ -75,15 +70,9 @@ import static com.njcn.access.enums.TypeEnum.DATA_48;
public class OfflineDataUploadServiceImpl implements OfflineDataUploadService { public class OfflineDataUploadServiceImpl implements OfflineDataUploadService {
private final MqttPublisher publisher; private final MqttPublisher publisher;
private final CsTopicFeignClient csTopicFeignClient;
private final RedisUtil redisUtil; private final RedisUtil redisUtil;
private final ChannelObjectUtil channelObjectUtil; private final ChannelObjectUtil channelObjectUtil;
private final MqttUtil mqttUtil;
private static Integer mid = 1;
private final DeviceFtpFeignClient deviceFtpFeignClient;
private final FileStorageUtil fileStorageUtil; private final FileStorageUtil fileStorageUtil;
private final GeneralInfo generalInfo;
private final PortableOffLogFeignClient portableOffLogFeignClient;
private final EquipmentFeignClient equipmentFeignClient; private final EquipmentFeignClient equipmentFeignClient;
private final CsLineFeignClient csLineFeignClient; private final CsLineFeignClient csLineFeignClient;

View File

@@ -21,9 +21,13 @@ spring:
discovery: discovery:
ip: @service.server.url@ ip: @service.server.url@
server-addr: @nacos.url@ server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@ namespace: @nacos.namespace@
config: config:
server-addr: @nacos.url@ server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@ namespace: @nacos.namespace@
file-extension: yaml file-extension: yaml
shared-configs: shared-configs:
@@ -41,6 +45,7 @@ spring:
#项目日志的配置 #项目日志的配置
logging: logging:
# config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&username=@nacos.username@&password=@nacos.password@&group=DEFAULT_GROUP&dataId=logback.xml
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level: level:
root: warn root: warn

View File

@@ -21,9 +21,13 @@ spring:
discovery: discovery:
ip: @service.server.url@ ip: @service.server.url@
server-addr: @nacos.url@ server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@ namespace: @nacos.namespace@
config: config:
server-addr: @nacos.url@ server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@ namespace: @nacos.namespace@
file-extension: yaml file-extension: yaml
shared-configs: shared-configs:
@@ -37,6 +41,7 @@ spring:
#项目日志的配置 #项目日志的配置
logging: logging:
# config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&username=@nacos.username@&password=@nacos.password@&group=DEFAULT_GROUP&dataId=logback.xml
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level: level:
root: warn root: warn

View File

@@ -21,9 +21,13 @@ spring:
discovery: discovery:
ip: @service.server.url@ ip: @service.server.url@
server-addr: @nacos.url@ server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@ namespace: @nacos.namespace@
config: config:
server-addr: @nacos.url@ server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@ namespace: @nacos.namespace@
file-extension: yaml file-extension: yaml
shared-configs: shared-configs:
@@ -37,6 +41,7 @@ spring:
#项目日志的配置 #项目日志的配置
logging: logging:
# config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&username=@nacos.username@&password=@nacos.password@&group=DEFAULT_GROUP&dataId=logback.xml
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level: level:
root: warn root: warn