feat(govern): 添加治理方案功能并重构相关数据模型
- 引入PqGovernPlan实体类及对应的数据库映射 - 实现治理方案的增删改查API接口和服务逻辑 - 集成治理方案与监测点、敏感用户的关联关系 - 更新设备交付数据传输对象和持久化对象结构 - 修改台账服务以支持治理方案数据展示 - 优化治理报告生成功能,基于治理方案进行数据查询 - 移除过时的设备治理类型字段,统一使用治理方案管理
This commit is contained in:
@@ -13,6 +13,8 @@ import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.CsMarketDataVO;
|
||||
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.csharmonic.api.PqGovernPlanFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
|
||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
@@ -42,6 +44,7 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
|
||||
private final CsMarketDataService csMarketDataService;
|
||||
private final ICsLedgerService csLedgerService;
|
||||
private final CsTouristDataPOService csTouristDataPOService;
|
||||
private final PqGovernPlanFeignClient pqGovernPlanFeignClient;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -65,15 +68,15 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
|
||||
@Override
|
||||
public List<String> getPqUserIdsByUser(String userId) {
|
||||
List<String> result = new ArrayList<>();
|
||||
List<String> devIds = commGetDevIds(userId);
|
||||
if (CollUtil.isEmpty(devIds)) {
|
||||
List<String> lineIds = getLineIdsByUser(userId);
|
||||
if (CollUtil.isEmpty(lineIds)) {
|
||||
return result;
|
||||
}
|
||||
List<CsEquipmentDeliveryPO> po = csEquipmentDeliveryService.listByIds(devIds);
|
||||
if (CollUtil.isEmpty(po)) {
|
||||
result = po.stream().map(CsEquipmentDeliveryPO::getMonitorUser).distinct().collect(Collectors.toList());
|
||||
List<PqGovernPlan> governPlans = pqGovernPlanFeignClient.getListByMonitorPoint(lineIds).getData();
|
||||
if (CollUtil.isEmpty(governPlans)) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
return governPlans.stream().map(PqGovernPlan::getPid).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,6 +191,7 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
|
||||
dto.setEquipmentName(equipmentLedger.getName());
|
||||
dto.setLineId(item.getId());
|
||||
dto.setLineName(item.getName());
|
||||
dto.setObjType(csLinePoMap.get(item.getId()).getMonitorObj());
|
||||
|
||||
if (Objects.isNull(csLinePoMap.get(item.getId()).getRunStatus())) {
|
||||
CsEquipmentDeliveryPO delivery = equipmentDeliveryMap.get(equipmentId);
|
||||
@@ -202,8 +206,6 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
|
||||
} else {
|
||||
dto.setRunStatus(csLinePoMap.get(item.getId()).getRunStatus());
|
||||
}
|
||||
dto.setObjType(csLinePoMap.get(item.getId()).getMonitorObj());
|
||||
dto.setGovernType(equipmentDeliveryMap.get(equipmentId).getGovernType());
|
||||
result.add(dto);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -5,12 +5,10 @@ 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.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.enums.LineBaseEnum;
|
||||
@@ -21,7 +19,9 @@ import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.csharmonic.api.PqGovernPlanFeignClient;
|
||||
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
|
||||
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
@@ -29,14 +29,12 @@ import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.user.pojo.constant.UserType;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -66,8 +64,8 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
private final ICsDataSetService csDataSetService;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
private final CsDeviceUserPOMapper csDeviceUserPOMapper;
|
||||
private final PqGovernPlanFeignClient pqGovernPlanFeignClient;
|
||||
private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final ICsUserPinsService csUserPinsService;
|
||||
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||
|
||||
@@ -164,12 +162,74 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
//获取治理方案
|
||||
List<PqGovernPlan> governPlan = pqGovernPlanFeignClient.getListExcludeNull().getData();
|
||||
Map<String, PqGovernPlan> beforeMap = Optional.ofNullable(governPlan)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.filter(p -> p.getGovernBefore() != null)
|
||||
.collect(Collectors.toMap(
|
||||
PqGovernPlan::getGovernBefore,
|
||||
Function.identity(),
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
Map<String, PqGovernPlan> afterMap = Optional.ofNullable(governPlan)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.filter(p -> p.getGovernAfter() != null)
|
||||
.collect(Collectors.toMap(
|
||||
PqGovernPlan::getGovernAfter,
|
||||
Function.identity(),
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
//获取治理用户
|
||||
// 1. governPlan 防 null + 过滤掉 pid 为 null 的数据
|
||||
List<String> sensitiveUser = Optional.ofNullable(governPlan)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.map(PqGovernPlan::getPid)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
// 2. 没有 id 就不调用远程接口,直接返回空 Map
|
||||
Map<String, PqSensitiveUser> sensitiveUserMap;
|
||||
if (CollectionUtils.isEmpty(sensitiveUser)) {
|
||||
sensitiveUserMap = Collections.emptyMap();
|
||||
} else {
|
||||
List<PqSensitiveUser> sensitiveUserList = pqSensitiveUserFeignClient
|
||||
.getListByIds(sensitiveUser)
|
||||
.getData();
|
||||
// 3. sensitiveUserList 防 null
|
||||
sensitiveUserMap = Optional.ofNullable(sensitiveUserList)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.filter(u -> u != null && u.getId() != null)
|
||||
.collect(Collectors.toMap(
|
||||
PqSensitiveUser::getId,
|
||||
Function.identity(),
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
}
|
||||
|
||||
List<CsLedgerVO> finalLineList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.peek(
|
||||
item -> {
|
||||
PqGovernPlan beforePlan = beforeMap.get(item.getId());
|
||||
PqGovernPlan afterPlan = afterMap.get(item.getId());
|
||||
if (beforePlan != null) {
|
||||
PqSensitiveUser user = sensitiveUserMap.get(beforePlan.getPid());
|
||||
item.setSensitiveUserId(beforePlan.getPid());
|
||||
item.setSensitiveUserName(Objects.isNull(user) ? null : user.getName());
|
||||
item.setGovernPlanName(beforePlan.getGovernName());
|
||||
}
|
||||
if (afterPlan != null) {
|
||||
PqSensitiveUser user = sensitiveUserMap.get(afterPlan.getPid());
|
||||
item.setSensitiveUserId(afterPlan.getPid());
|
||||
item.setSensitiveUserName(Objects.isNull(user) ? null : user.getName());
|
||||
item.setGovernPlanName(afterPlan.getGovernName());
|
||||
}
|
||||
item.setType("line");
|
||||
String index = item.getId().substring(item.getId().length() - 1);
|
||||
if (Objects.equals(index, "0")) {
|
||||
|
||||
@@ -29,9 +29,11 @@ import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.ICsDataSetService;
|
||||
import com.njcn.csharmonic.api.CsHarmonicPlanFeignClient;
|
||||
import com.njcn.csharmonic.api.CsHarmonicPlanLineFeignClient;
|
||||
import com.njcn.csharmonic.api.PqGovernPlanFeignClient;
|
||||
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
|
||||
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
|
||||
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
@@ -72,6 +74,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final CsTerminalLogsMapper csTerminalLogsMapper;
|
||||
private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient;
|
||||
private final PqGovernPlanFeignClient pqGovernPlanFeignClient;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final UserFeignClient userFeignClient;
|
||||
@@ -328,7 +331,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
@Override
|
||||
public List<CsEquipmentDeliveryPO> getDevBySensitiveUser(List<String> list) {
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(CsEquipmentDeliveryPO::getMonitorUser,list)
|
||||
lambdaQueryWrapper
|
||||
// .in(CsEquipmentDeliveryPO::getMonitorUser,list)
|
||||
.ne(CsEquipmentDeliveryPO::getRunStatus, DataStateEnum.DELETED.getCode());
|
||||
return csEquipmentDeliveryMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
@@ -358,13 +362,16 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return result;
|
||||
}
|
||||
List<String> devIds = records.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryMapper.selectBatchIds(devIds);
|
||||
Map<String, CsEquipmentDeliveryPO> devMap = devList.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, item -> item));
|
||||
|
||||
List<PqSensitiveUserLineVO> list = new ArrayList<>();
|
||||
List<String> sensitiveUserIds = list.stream().map(PqSensitiveUserLineVO::getSensitiveUser).distinct().collect(Collectors.toList());
|
||||
//获取用户id
|
||||
List<String> ids = records.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList());
|
||||
List<PqGovernPlan> governPlans = pqGovernPlanFeignClient.getListByMonitorPoint(ids).getData();
|
||||
if (CollUtil.isEmpty(governPlans)) {
|
||||
return result;
|
||||
}
|
||||
Map<String, PqGovernPlan> lineMap1 = governPlans.stream().collect(Collectors.toMap(PqGovernPlan::getGovernBefore, item -> item));
|
||||
Map<String, PqGovernPlan> lineMap2 = governPlans.stream().collect(Collectors.toMap(PqGovernPlan::getGovernAfter, item -> item));
|
||||
|
||||
List<String> sensitiveUserIds = governPlans.stream().map(PqGovernPlan::getPid).distinct().collect(Collectors.toList());
|
||||
Map<String, String> sensitiveUserNameMap = new HashMap<>();
|
||||
List<PqSensitiveUser> pqSensitiveUserList = pqSensitiveUserFeignClient.getListByIds(sensitiveUserIds).getData();
|
||||
if (CollUtil.isNotEmpty(pqSensitiveUserList)) {
|
||||
@@ -383,19 +390,26 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
List<DevDetailDTO> devDetailDTOList = csCommTerminal.getLedgerByLineId(lineIds).getData();
|
||||
Map<String, DevDetailDTO> devDetailDTOMap = devDetailDTOList.stream().collect(Collectors.toMap(DevDetailDTO::getLineId, item -> item));
|
||||
|
||||
List<PqSensitiveUserLineVO> list = new ArrayList<>();
|
||||
for (CsLinePO record : records) {
|
||||
sensitiveUserLineVO = new PqSensitiveUserLineVO();
|
||||
sensitiveUserLineVO.setEngineeringName(devDetailDTOMap.get(record.getLineId()).getEngineeringName());
|
||||
sensitiveUserLineVO.setProjectName(devDetailDTOMap.get(record.getLineId()).getProjectName());
|
||||
sensitiveUserLineVO.setDevName(devDetailDTOMap.get(record.getLineId()).getEquipmentName());
|
||||
// 治理对象
|
||||
sensitiveUserLineVO.setSensitiveUser(sensitiveUserNameMap.getOrDefault(devMap.get(record.getDeviceId()).getMonitorUser(), null));
|
||||
// 治理对象 && 是否治理
|
||||
PqGovernPlan plan1 = lineMap1.get(record.getLineId());
|
||||
if (!Objects.isNull(plan1)) {
|
||||
sensitiveUserLineVO.setSensitiveUser(sensitiveUserNameMap.getOrDefault(plan1.getPid(), null));
|
||||
sensitiveUserLineVO.setGovern(Objects.isNull(plan1.getGovernMethod()) ? "未治理" : plan1.getGovernMethod());
|
||||
}
|
||||
PqGovernPlan plan2 = lineMap2.get(record.getLineId());
|
||||
if (!Objects.isNull(plan2)) {
|
||||
sensitiveUserLineVO.setSensitiveUser(sensitiveUserNameMap.getOrDefault(plan2.getPid(), null));
|
||||
sensitiveUserLineVO.setGovern(Objects.isNull(plan2.getGovernMethod()) ? "未治理" : plan2.getGovernMethod());
|
||||
}
|
||||
// 测点名称
|
||||
sensitiveUserLineVO.setLineId(record.getLineId());
|
||||
sensitiveUserLineVO.setLineName(record.getName());
|
||||
// 是否治理
|
||||
String governMethod = devMap.get(record.getDeviceId()).getGovernMethod();
|
||||
sensitiveUserLineVO.setGovern(Objects.isNull(governMethod) ? "未治理" : governMethod);
|
||||
// 监测类型
|
||||
if (ObjectUtil.isNotNull(record.getPosition())) {
|
||||
sensitiveUserLineVO.setPosition(record.getPosition());
|
||||
|
||||
Reference in New Issue
Block a user