工程用户查看设备逻辑修改

This commit is contained in:
hzj
2024-08-22 16:55:25 +08:00
parent 2e0d891eaf
commit 180bc26b72

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.service.impl; package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.csdevice.mapper.*; import com.njcn.csdevice.mapper.*;
@@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -119,7 +121,7 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
List<String> collect = new ArrayList<>(); List<String> collect = new ArrayList<>();
if( if(
Objects.equals(role,AppRoleEnum.APP_VIP_USER.getCode())||Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())){ Objects.equals(role,AppRoleEnum.APP_VIP_USER.getCode())){
csDeviceUserPOQueryWrapper.clear(); csDeviceUserPOQueryWrapper.clear();
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> { csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
wq.eq("primary_user_id", userIndex) wq.eq("primary_user_id", userIndex)
@@ -134,7 +136,45 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
return collect1; return collect1;
} }
else if ( Objects.equals(role,AppRoleEnum.MARKET_USER.getCode())) { //fix 新需求 工程用户可以看到关注工程的设备和对应的主用户和子用户的设备
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());
}
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
csMarketDataQueryWrapper.eq("user_id", userIndex);
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(csMarketDataQueryWrapper);
List<String> collect2 = csMarketData.stream().map(CsMarketData::getEngineerId).collect(Collectors.toList());
if(CollectionUtils.isEmpty(collect2)){
return sumDevId;
}
csLedgerQueryWrapper.clear();
csLedgerQueryWrapper.lambda().eq(CsLedger::getLevel, 1).eq(CsLedger::getState, 1).in(CsLedger::getPid, collect2);
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
List<String>collect1 = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList());
if(CollectionUtils.isEmpty(collect1)){
return sumDevId;
}
csLedgerQueryWrapper.clear();
csLedgerQueryWrapper.lambda().eq(CsLedger::getLevel, 2).eq(CsLedger::getState, 1).in(CsLedger::getPid, collect1);
List<CsLedger> csLedgers1 = csLedgerMapper.selectList(csLedgerQueryWrapper);
collect = csLedgers1.stream().map(CsLedger::getId).collect(Collectors.toList());
sumDevId.addAll(collect);
sumDevId = sumDevId.stream().distinct().collect(Collectors.toList());
return sumDevId;
} else if ( Objects.equals(role,AppRoleEnum.MARKET_USER.getCode())) {
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>(); QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
csMarketDataQueryWrapper.eq("user_id", userIndex); csMarketDataQueryWrapper.eq("user_id", userIndex);
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(csMarketDataQueryWrapper); List<CsMarketData> csMarketData = csMarketDataMapper.selectList(csMarketDataQueryWrapper);