feat(service): 实现分页功能并优化设备权限管理

- 在控制器层添加分页支持,将返回类型从 List 修改为 Page
- 实现服务层分页逻辑,集成 MyBatis Plus 分页插件
- 重构设备权限管理逻辑,区分超级管理员、普通用户和游客权限
- 添加营销用户和工程用户的特殊权限处理机制
- 迁移事件查询逻辑到统一的事件用户服务中
- 移除过时的设备用户映射器接口和 XML 查询方法
- 为暂降事件报告添加动态文件名生成功能
- 修复时间范围计算中的日期边界问题
- 优化台账树结构以支持多层级权限过滤
- 统计未读事件数量的查询逻辑优化
This commit is contained in:
xy
2026-04-14 19:09:23 +08:00
parent 460a10f3b5
commit e77108ebf5
33 changed files with 778 additions and 231 deletions

View File

@@ -3,6 +3,8 @@ package com.njcn.csdevice.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* Description:
* Date: 2023/9/6 13:59【需求编号】
@@ -37,4 +39,7 @@ public class DevDetailDTO {
@ApiModelProperty(value = "设备MAC地址")
private String devMac;
@ApiModelProperty(value = "监测点id集合")
private List<String> lineList;
}

View File

@@ -1,8 +1,10 @@
package com.njcn.csdevice.pojo.dto;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
@@ -13,7 +15,7 @@ import java.util.List;
* @version V1.0.0
*/
@Data
public class LineParamDTO {
public class LineParamDTO extends BaseParam implements Serializable {
@ApiModelProperty(value = "工程id")
private String engineerId;

View File

@@ -6,12 +6,13 @@ 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.enums.DeviceOperate;
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
import com.njcn.csdevice.pojo.param.UserDevParam;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.vo.DevCountVO;
import com.njcn.csdevice.pojo.vo.DevUserVO;
import com.njcn.csdevice.service.CsDeviceUserPOService;
import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.web.advice.DeviceLog;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.RequestUtil;
@@ -41,7 +42,7 @@ import java.util.Objects;
public class DeviceUserController extends BaseController {
private final CsDeviceUserPOService csDeviceUserPOService;
private final CsDeviceUserPOMapper csDeviceUserPOMapper;
private final EventUserFeignClient eventUserFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/add")
@@ -187,10 +188,16 @@ public class DeviceUserController extends BaseController {
public HttpResult<List<String>> getIdList(@RequestParam("param") String param){
String methodDescribe = getMethodDescribe("getIdList");
List<String> list = new ArrayList<>();
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(null);
param1.setEndTime(null);
param1.setEventIds(null);
if (Objects.equals(param, "1")) {
list = csDeviceUserPOMapper.queryTempHarmonic(RequestUtil.getUserIndex(),null,null,null);
list = eventUserFeignClient.queryTempHarmonic(param1).getData();
} else if (Objects.equals(param, "3")) {
list = csDeviceUserPOMapper.queryAlarmEvent(RequestUtil.getUserIndex(),null,null,null);
list = eventUserFeignClient.queryAlarmEvent(param1).getData();
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}

View File

@@ -61,7 +61,7 @@ public class CsTouristDataPOController extends BaseController {
@PostMapping("/queryAll")
@ApiOperation("查询游客数据")
public HttpResult<List<CsTouristDataParmVO>> queryAll(){
String methodDescribe = getMethodDescribe("query");
String methodDescribe = getMethodDescribe("queryAll");
List<CsTouristDataParmVO> list = csTouristDataPOService.queryAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);

View File

@@ -2,9 +2,6 @@ package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
@@ -15,17 +12,4 @@ import java.util.List;
* @version V1.0.0
*/
public interface CsDeviceUserPOMapper extends BaseMapper<CsDeviceUserPO> {
//查询暂态事件(未读)
List<String> queryTempEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
//查询稳态事件(未读)
List<String> queryTempHarmonic(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
//查询告警事件(未读)
List<String> queryAlarmEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
//查询运行事件(未读)
List<String> queryRunEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
}

View File

@@ -16,72 +16,4 @@
<!--@mbg.generated-->
primary_user_id, sub_user_id, device_id, create_by, create_time, update_by, update_time
</sql>
<select id="queryTempEvent" resultType="java.lang.String">
SELECT
t1.event_id
FROM
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
WHERE
t1.user_id = #{userId}
and t1.`status`= 0
and t2.type = 0
<if test="ids != null and ids.size > 0">
and t2.line_id in
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="queryAlarmEvent" resultType="java.lang.String">
SELECT
t1.event_id
FROM
cs_event_user t1 right join cs_alarm t2 on t1.event_id = t2.id
WHERE
t1.user_id = #{userId}
and t1.`status`= 0
<if test="ids != null and ids.size > 0">
and (
<foreach collection="ids" item="tag" separator=" OR ">
FIND_IN_SET(#{tag}, t2.dev_list) > 0
</foreach>
)
</if>
</select>
<select id="queryRunEvent" resultType="java.lang.String">
SELECT
t1.event_id
FROM
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
WHERE
t1.user_id = #{userId}
and t1.`status`= 0
and t2.type = 2
<if test="ids != null and ids.size > 0">
and t2.device_id in
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="queryTempHarmonic" resultType="java.lang.String">
SELECT
t1.event_id
FROM
cs_event_user t1 right join cs_harmonic t2 on t1.event_id = t2.id
WHERE
t1.user_id = #{userId}
and t1.`status`= 0
<if test="ids != null and ids.size > 0">
and t2.line_id in
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
</mapper>

View File

@@ -93,27 +93,33 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
@Override
public List<String> commGetDevIds(String userId) {
UserVO userVO = userFeignClient.getUserById(userId).getData();
List<String> devIds;
List<String> devIds = new ArrayList<>();
if (userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) || userVO.getType().equals(UserType.ADMINISTRATOR)) {
devIds = csEquipmentDeliveryService.getAll().stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
} else {
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
.and(w -> w.eq(CsDeviceUserPO::getPrimaryUserId, userId).or().eq(CsDeviceUserPO::getSubUserId, userId))
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
//note 黄是在cs_market_data写入数据是用户和工程的关系
// 但是权限根据用户和设备来判断会有问题,还需要用户和工程的关系(针对营销 工程用户),所以这边还要添加用户和工程的关系
List<CsMarketDataVO> list = csMarketDataService.queryByUseId(userId);
if (CollUtil.isNotEmpty(list)) {
List<String> engineerIds = list.stream().map(CsMarketDataVO::getEngineerId).distinct().collect(Collectors.toList());
List<DevDetailDTO> devs = csLedgerService.getDevInfoByEngineerIds(engineerIds);
devIds.addAll(devs.stream().map(DevDetailDTO::getEquipmentId).distinct().collect(Collectors.toList()));
// 但是权限根据用户和设备来判断会有问题,还需要用户和工程的关系(针对营销 工程用户),所以这边还要添加用户和工程的关系
// 如果是营销 工程用户 没有配置相关工程,直接返回空的设备列表;如果有数据,也要判断下当前关注的工程里面是否包含主用户的设备,可能出现没有关注该工程,但是因为是设备的主用户导致数据统计错误
String roleString = RequestUtil.getUserRole();
if (roleString.contains(AppRoleEnum.MARKET_USER.getCode()) || roleString.contains(AppRoleEnum.ENGINEERING_USER.getCode())) {
List<CsMarketDataVO> list = csMarketDataService.queryByUseId(userId);
if (CollUtil.isNotEmpty(list)) {
List<String> engineerIds = list.stream().map(CsMarketDataVO::getEngineerId).distinct().collect(Collectors.toList());
List<DevDetailDTO> devs = csLedgerService.getDevInfoByEngineerIds(engineerIds);
devIds = devs.stream().map(DevDetailDTO::getEquipmentId).distinct().collect(Collectors.toList());
}
}
//note 如果是游客,则还需要加入系统配置的设备
String roleString = RequestUtil.getUserRole();
if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
else if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
devIds.addAll(csTouristDataPOService.queryAll().stream().map(CsTouristDataParmVO::getDeviceId).distinct().collect(Collectors.toList()));
}
//note 如果是普通用户,则需要根据用户权限来获取设备列表
else {
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
.and(w -> w.eq(CsDeviceUserPO::getPrimaryUserId, userId).or().eq(CsDeviceUserPO::getSubUserId, userId))
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
}
}
if (!CollUtil.isEmpty(devIds)) {
devIds = devIds.stream().distinct().collect(Collectors.toList());

View File

@@ -10,14 +10,16 @@ import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
import com.njcn.csdevice.mapper.CsMarketDataMapper;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.param.UserDevParam;
import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
import com.njcn.csdevice.pojo.vo.DevCountVO;
import com.njcn.csdevice.pojo.vo.DevUserVO;
import com.njcn.csdevice.service.*;
import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.cssystem.api.FeedBackFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.harmonic.utils.PublicDataUtils;
import com.njcn.user.api.UserFeignClient;
import com.njcn.user.enums.AppRoleEnum;
@@ -30,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -51,14 +54,12 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
private final CsDevModelRelationService csDevModelRelationService;
private final ICsLedgerService iCsLedgerService;
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final RoleEngineerDevService roleEngineerDevService;
private final AppLineTopologyDiagramService appLineTopologyDiagramService;
private final CsTouristDataPOService csTouristDataPOService;
private final CsLinePOService csLinePOService;
private final CsMarketDataMapper csMarketDataMapper;
private final EventUserFeignClient eventUserFeignClient;
private final UserFeignClient userFeignClient;
private final FeedBackFeignClient feedBackFeignClient;
private final IMqttUserService mqttUserService;
@Override
@@ -122,17 +123,61 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
DevCountVO vo = new DevCountVO();
//获取app用户的台账树包含四个层级 工程、项目、设备、监测点
List<CsLedgerVO> appLedger = iCsLedgerService.appLineTree();
//判断当前用户,如果是游客,则需要筛选数据,只保留游客的数据
String roleString = RequestUtil.getUserRole();
if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
List<CsTouristDataParmVO> csTouristDataParmVOList = csTouristDataPOService.queryAll();
if (CollectionUtil.isNotEmpty(csTouristDataParmVOList)) {
List<String> devList = csTouristDataParmVOList.stream().map(CsTouristDataParmVO::getDeviceId).collect(Collectors.toList());
// 保留游客有权限的工程、项目、设备、监测点数据
appLedger = appLedger.stream()
.filter(engineering -> {
boolean hasValidProject = false;
if (CollectionUtil.isNotEmpty(engineering.getChildren())) {
List<CsLedgerVO> validProjects = engineering.getChildren().stream()
.filter(project -> {
boolean hasValidDevice = false;
if (CollectionUtil.isNotEmpty(project.getChildren())) {
List<CsLedgerVO> validDevices = project.getChildren().stream()
.filter(device -> devList.contains(device.getId()))
.collect(Collectors.toList());
project.setChildren(validDevices);
hasValidDevice = CollectionUtil.isNotEmpty(validDevices);
}
return hasValidDevice;
})
.collect(Collectors.toList());
engineering.setChildren(validProjects);
hasValidProject = CollectionUtil.isNotEmpty(validProjects);
}
return hasValidProject;
})
.collect(Collectors.toList());
} else {
// 如果游客没有配置任何数据权限,返回空列表
appLedger = new ArrayList<>();
}
}
if (CollectionUtil.isNotEmpty(appLedger)) {
//获取第一层项目层级
List<CsLedgerVO> firstLevelList = new ArrayList<>();
//获取第三层设备层级
List<CsLedgerVO> thirdLevelList = new ArrayList<>();
//获取第四层设备层级
List<CsLedgerVO> forthLevelList = new ArrayList<>();
for (CsLedgerVO firstLevel : appLedger) {
firstLevelList.add(firstLevel);
if (CollectionUtil.isNotEmpty(firstLevel.getChildren())) {
for (CsLedgerVO secondLevel : firstLevel.getChildren()) {
if (CollectionUtil.isNotEmpty(secondLevel.getChildren())) {
thirdLevelList.addAll(secondLevel.getChildren());
for (CsLedgerVO threeLevel : secondLevel.getChildren()) {
if (CollectionUtil.isNotEmpty(threeLevel.getChildren())) {
forthLevelList.addAll(threeLevel.getChildren());
}
}
}
}
}
@@ -163,17 +208,30 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
return vo;
}
//获取未读事件数量
List<String> eventCount = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
vo.setEventCount(CollectionUtil.isNotEmpty(eventCount)?eventCount.size():0);
if (CollectionUtil.isNotEmpty(forthLevelList)) {
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(forthLevelList.stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
List<String> harmonicCount = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
vo.setHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount)?harmonicCount.size():0);
List<String> eventCount = eventUserFeignClient.queryTempEvent(param1).getData();
vo.setEventCount(CollectionUtil.isNotEmpty(eventCount)?eventCount.size():0);
List<String> harmonicCount = eventUserFeignClient.queryTempHarmonic(param1).getData();
vo.setHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount)?harmonicCount.size():0);
}
if (CollectionUtil.isNotEmpty(thirdLevelList)) {
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(thirdLevelList.stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
List<String> alarmCount = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
vo.setAlarmCount(CollectionUtil.isNotEmpty(alarmCount)?alarmCount.size():0);
List<String> runCount = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
vo.setRunCount(CollectionUtil.isNotEmpty(runCount)?runCount.size():0);
List<String> alarmCount = eventUserFeignClient.queryAlarmEvent(param1).getData();
vo.setAlarmCount(CollectionUtil.isNotEmpty(alarmCount)?alarmCount.size():0);
List<String> runCount = eventUserFeignClient.queryRunEvent(param1).getData();
vo.setRunCount(CollectionUtil.isNotEmpty(runCount)?runCount.size():0);
}
//note 当前工程数据
//当前工程id
@@ -228,17 +286,29 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
}
//获取未读事件数量
if (CollectionUtil.isNotEmpty(currentLineIds)) {
List<String> eventCount2 = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(currentLineIds);
List<String> eventCount2 = eventUserFeignClient.queryTempEvent(param1).getData();
vo.setCurrentEventCount(CollectionUtil.isNotEmpty(eventCount2)?eventCount2.size():0);
List<String> harmonicCount2 = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
List<String> harmonicCount2 = eventUserFeignClient.queryTempHarmonic(param1).getData();
vo.setCurrentHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount2)?harmonicCount2.size():0);
}
if (CollectionUtil.isNotEmpty(currentDevIds)) {
List<String> alarmCount2 = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(currentDevIds);
List<String> alarmCount2 = eventUserFeignClient.queryAlarmEvent(param1).getData();
vo.setCurrentAlarmCount(CollectionUtil.isNotEmpty(alarmCount2)?alarmCount2.size():0);
List<String> runCount2 = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
List<String> runCount2 = eventUserFeignClient.queryRunEvent(param1).getData();
vo.setCurrentRunCount(CollectionUtil.isNotEmpty(runCount2)?runCount2.size():0);
}
}
@@ -535,6 +605,21 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
if (CollectionUtil.isNotEmpty(list)){
result = list.stream().map(CsDeviceUserPO::getSubUserId).collect(Collectors.toList());
}
//获取关注设备的用户(工程用户、营销用户)
List<DevDetailDTO> ledger = iCsLedgerService.getInfoByIds(Collections.singletonList(devId));
if (CollectionUtil.isNotEmpty(ledger)) {
DevDetailDTO item = ledger.get(0);
LambdaQueryWrapper<CsMarketData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsMarketData::getEngineerId, item.getEngineeringid());
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(queryWrapper);
if (CollectionUtil.isNotEmpty(csMarketData)) {
List<String> collect = csMarketData.stream().map(CsMarketData::getUserId).collect(Collectors.toList());
result.addAll(collect);
}
}
if (CollectionUtil.isNotEmpty(result)) {
result = result.stream().distinct().collect(Collectors.toList());
}
return result;
}

View File

@@ -996,7 +996,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,id)
.in(ObjectUtil.isNotEmpty(state),CsEquipmentDeliveryPO::getUsageStatus,state);
.in(ObjectUtil.isNotEmpty(state),CsEquipmentDeliveryPO::getUsageStatus,state)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod,"CLD");
return this.list(lambdaQueryWrapper);
}

View File

@@ -1341,11 +1341,25 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
if (CollUtil.isNotEmpty(dev)) {
List<String> devIds = dev.stream().map(CsLedger::getId).collect(Collectors.toList());
//监测点
LambdaQueryWrapper<CsLedger> queryWrapper3 = new LambdaQueryWrapper<>();
queryWrapper3.in(CsLedger::getPid, devIds);
List<CsLedger> line = this.list(queryWrapper3);
Map<String,List<CsLedger>> lineMap = line.stream().collect(Collectors.groupingBy(CsLedger::getPid));
List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devIds);
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, item -> item));
dev.forEach(item -> {
DevDetailDTO detail = new DevDetailDTO();
//监测点
List<CsLedger> lines = lineMap.get(item.getId());
if (CollUtil.isNotEmpty(lines)) {
detail.setLineList(lines.stream().map(CsLedger::getId).collect(Collectors.toList()));
}
detail.setEquipmentName(item.getName());
detail.setEquipmentId(item.getId());

View File

@@ -132,18 +132,19 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
}
//fix 新需求 工程用户可以看到关注工程的设备和对应的主用户和子用户的设备
//note 这边工程用户不查询主设备,只看关注的工程,做下调整,不然会出现工程用户未关注任何工程,但是有一台主设备,导致界面有数据
else if (Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
List<String> sumDevId = new ArrayList<>();
csDeviceUserPOQueryWrapper.clear();
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
wq.eq("primary_user_id", userIndex)
.or()
.eq("sub_user_id",userIndex);
});
List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
if(!CollectionUtils.isEmpty(csDeviceUserPOS)){
sumDevId = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
}
// csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
// wq.eq("primary_user_id", userIndex)
// .or()
// .eq("sub_user_id",userIndex);
// });
// List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
// if(!CollectionUtils.isEmpty(csDeviceUserPOS)){
// sumDevId = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
// }
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
csMarketDataQueryWrapper.eq("user_id", userIndex);