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:
@@ -97,4 +97,6 @@ public interface ICsLedgerService extends IService<CsLedger> {
|
||||
|
||||
List<DevDetailDTO> getEngineeringHaveDevs(List<String> list);
|
||||
|
||||
List<CsLedger> queryByPid(String pid);
|
||||
|
||||
}
|
||||
|
||||
@@ -348,76 +348,236 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
return list;
|
||||
}
|
||||
|
||||
// ... 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) {
|
||||
public Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm auditParm) {
|
||||
StringUtil.containsSpecialCharacters(auditParm.getNdid());
|
||||
// 校验ndid不重复
|
||||
long ndidCount = this.count(new LambdaQueryWrapper<CsEquipmentDeliveryPO>()
|
||||
.eq(CsEquipmentDeliveryPO::getNdid, auditParm.getNdid())
|
||||
.in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3))
|
||||
.ne(CsEquipmentDeliveryPO::getId, auditParm.getId()));
|
||||
if (ndidCount > 0) {
|
||||
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);
|
||||
// 查询原记录
|
||||
CsEquipmentDeliveryPO po = this.getById(auditParm.getId());
|
||||
if (Objects.isNull(po)) {
|
||||
throw new BusinessException("设备不存在");
|
||||
}
|
||||
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)) {
|
||||
// 校验设备名称不重复
|
||||
long nameCount = this.lambdaQuery()
|
||||
.ne(CsEquipmentDeliveryPO::getId, auditParm.getId())
|
||||
.ne(CsEquipmentDeliveryPO::getNdid, auditParm.getNdid())
|
||||
.eq(CsEquipmentDeliveryPO::getName, auditParm.getName())
|
||||
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
|
||||
.eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT")
|
||||
.count();
|
||||
if (nameCount > 0) {
|
||||
throw new BusinessException("设备名称不能重复");
|
||||
}
|
||||
BeanUtils.copyProperties(csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo);
|
||||
csEquipmentDeliveryPo.setMac(csEquipmentDeliveryAuditParm.getNdid().replaceAll("(.{2})", "$1:").substring(0, 17));
|
||||
result = this.updateById(csEquipmentDeliveryPo);
|
||||
//如果是已经接入的设备需要修改台账树中的设备名称
|
||||
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);
|
||||
CsEquipmentDeliveryPO updatePo = new CsEquipmentDeliveryPO();
|
||||
// 修改了ndid时的联动处理
|
||||
if (!Objects.equals(po.getNdid(), auditParm.getNdid())) {
|
||||
handleNdidChange(po, auditParm, updatePo);
|
||||
}
|
||||
return result;
|
||||
BeanUtils.copyProperties(auditParm, updatePo);
|
||||
updatePo.setMac(createPath(auditParm.getNdid()));
|
||||
// 更新台账树中的设备名称及工程/项目
|
||||
CsLedger csLedger = csLedgerService.findDataById(auditParm.getId());
|
||||
if (ObjectUtil.isNotNull(csLedger)) {
|
||||
csLedger.setName(auditParm.getName());
|
||||
updateLedger(csLedger);
|
||||
handleEngineeringProjectChange(po, auditParm, csLedger);
|
||||
}
|
||||
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
|
||||
public void updateStatusBynDid(String nDId, Integer status) {
|
||||
boolean result;
|
||||
@@ -633,6 +793,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response) {
|
||||
|
||||
@@ -1471,6 +1471,13 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsLedger> queryByPid(String pid) {
|
||||
return this.list(new LambdaQueryWrapper<CsLedger>()
|
||||
.eq(CsLedger::getPid, pid)
|
||||
.eq(CsLedger::getState, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子节点
|
||||
*/
|
||||
|
||||
@@ -184,7 +184,12 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
|
||||
, DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())));
|
||||
//排序
|
||||
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);
|
||||
|
||||
List<CsTerminalReply> records = csTerminalReplyPage.getRecords();
|
||||
@@ -202,19 +207,6 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
|
||||
cldLogsVo.setEngineeringName(ledgerMap.get(split[1]).getName());
|
||||
cldLogsVo.setProjectName(ledgerMap.get(split[2]).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.setLog(getLogDescription(item.getCode()));
|
||||
cldLogsVo.setLogTime(item.getCreateTime());
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.njcn.csharmonic.offline.mincfg.vo.CmnModeCfg;
|
||||
import com.njcn.csharmonic.offline.vo.Response;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.event.common.mapper.WlRmpEventDetailMapper;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.influx.imapper.*;
|
||||
import com.njcn.influx.pojo.po.*;
|
||||
@@ -115,6 +116,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
|
||||
private final EventCauseFeignClient eventCauseFeignClient;
|
||||
private final EventAnalysisService eventAnalysisService;
|
||||
|
||||
@Override
|
||||
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
|
||||
@@ -465,24 +467,6 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
}
|
||||
}
|
||||
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);
|
||||
@@ -539,6 +523,35 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
csEventPO.setPhase(entData.getEvtParamPhase());
|
||||
csEventPO.setPersistTime(entData.getEvtParamTm());
|
||||
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);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -568,6 +581,30 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
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) {
|
||||
RmpEventDetailPO rmpEventDetailPo = new RmpEventDetailPO();
|
||||
rmpEventDetailPo.setEventId(item.getId());
|
||||
@@ -577,11 +614,20 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
rmpEventDetailPo.setFeatureAmplitude(item.getAmplitude());
|
||||
rmpEventDetailPo.setDuration(item.getPersistTime());
|
||||
rmpEventDetailPo.setEventDescribe(getTag(item.getTag()));
|
||||
rmpEventDetailPo.setDealFlag(0);
|
||||
rmpEventDetailPo.setFileFlag(0);
|
||||
rmpEventDetailPo.setWavePath(item.getWavePath());
|
||||
if (!Objects.isNull(item.getWavePath())) {
|
||||
rmpEventDetailPo.setFileFlag(1);
|
||||
} else {
|
||||
rmpEventDetailPo.setFileFlag(0);
|
||||
}
|
||||
rmpEventDetailPo.setPhase(item.getPhase());
|
||||
rmpEventDetailPo.setAdvanceReason(item.getAdvanceReason());
|
||||
rmpEventDetailPo.setAdvanceType(item.getAdvanceType());
|
||||
if (!Objects.isNull(item.getAdvanceReason()) && !Objects.isNull(item.getAdvanceType())) {
|
||||
rmpEventDetailPo.setDealFlag(1);
|
||||
} else {
|
||||
rmpEventDetailPo.setDealFlag(0);
|
||||
}
|
||||
wlRmpEventDetailMapper.insert(rmpEventDetailPo);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,13 @@ spring:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
@@ -41,6 +45,7 @@ spring:
|
||||
|
||||
#项目日志的配置
|
||||
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
|
||||
level:
|
||||
root: warn
|
||||
|
||||
Reference in New Issue
Block a user