Browse Source

解决物联设备分页列表数据权限问题

tags/V1.3.3^2
wanjing 11 months ago
parent
commit
1237cc1b2d
2 changed files with 9 additions and 25 deletions
  1. +0
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/iotequipment/QueryIotEquipmentPageListRequest.java
  2. +9
    -20
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/iotequipment/query/QueryEditIotEquipmentPageListService.java

+ 0
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/iotequipment/QueryIotEquipmentPageListRequest.java View File

*/ */
private String tenantId; private String tenantId;


/**
* 部门Id
*/
private String deptId;

/** /**
* 公路名称 * 公路名称
*/ */

+ 9
- 20
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/iotequipment/query/QueryEditIotEquipmentPageListService.java View File

import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.IotEquipmentVo; import com.tuoheng.admin.vo.IotEquipmentVo;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
} }


// 获取部门Id的查询范围 // 获取部门Id的查询范围
List<String> deptIdList = this.getDeptIdList(user, user.getDeptId());
List<String> deptIdList = this.getDeptIdList(user);
request.setDeptIdList(deptIdList); request.setDeptIdList(deptIdList);
request.setTenantId(user.getTenantId()); request.setTenantId(user.getTenantId());


/** /**
* 获取部门Id的查询范围 * 获取部门Id的查询范围
* *
* @param deptId
* @return * @return
*/ */
private List<String> getDeptIdList(User user, String deptId) {
private List<String> getDeptIdList(User user) {
List<String> deptIdList = new ArrayList<>(); List<String> deptIdList = new ArrayList<>();
if (!StringUtils.isEmpty(deptId)) {
deptIdList.add(deptId);
return deptIdList;
}
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return null;
} else {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId());
return deptIdList; return deptIdList;
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId());
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
deptIdList.add(user.getDeptId());
} }
return deptIdList;
} }


private List<IotEquipmentVo> buildIotEquipmentVoList(List<IotEquipment> iotEquipmentList) { private List<IotEquipmentVo> buildIotEquipmentVoList(List<IotEquipment> iotEquipmentList) {
return null; return null;
} }
List<IotEquipmentVo> iotEquipmentVoList = IotEquipmentConverMapper.INSTANCE.fromIotEquipmentToIotEquipmentVoList(iotEquipmentList); List<IotEquipmentVo> iotEquipmentVoList = IotEquipmentConverMapper.INSTANCE.fromIotEquipmentToIotEquipmentVoList(iotEquipmentList);

Map<String, Dept> deptMap = this.getDeptMap(iotEquipmentList); Map<String, Dept> deptMap = this.getDeptMap(iotEquipmentList);
Map<String, RoadInformation> roadInformationMap = this.getRoadInformationMap(iotEquipmentList); Map<String, RoadInformation> roadInformationMap = this.getRoadInformationMap(iotEquipmentList);
Map<String, Section> sectionMap = this.getSectionMap(iotEquipmentList); Map<String, Section> sectionMap = this.getSectionMap(iotEquipmentList);
Map<String, User> userMap = this.getUserMap(iotEquipmentList); Map<String, User> userMap = this.getUserMap(iotEquipmentList);

Dept dept; Dept dept;
RoadInformation roadInformation; RoadInformation roadInformation;
Section section; Section section;
User user; User user;

for (IotEquipmentVo iotEquipmentVo : iotEquipmentVoList) { for (IotEquipmentVo iotEquipmentVo : iotEquipmentVoList) {
if (ObjectUtil.isNotEmpty(deptMap)) { if (ObjectUtil.isNotEmpty(deptMap)) {
dept = deptMap.get(iotEquipmentVo.getDeptId()); dept = deptMap.get(iotEquipmentVo.getDeptId());
} }
} }
} }

return iotEquipmentVoList; return iotEquipmentVoList;
} }


/** /**
* 获取用户列表,放到map,减少循环次数 * 获取用户列表,放到map,减少循环次数
*
* @param iotEquipmentList * @param iotEquipmentList
* @return * @return
*/ */
.eq(User::getMark, MarkEnum.VALID.getCode())); .eq(User::getMark, MarkEnum.VALID.getCode()));
Map<String, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, Function.identity())); Map<String, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, Function.identity()));
return userMap; return userMap;

} }


/** /**
* 获取路段列表,放到map,减少循环次数 * 获取路段列表,放到map,减少循环次数
*
* @param iotEquipmentList * @param iotEquipmentList
* @return * @return
*/ */
.eq(Section::getMark, MarkEnum.VALID.getCode())); .eq(Section::getMark, MarkEnum.VALID.getCode()));
Map<String, Section> sectionMap = sectionList.stream().collect(Collectors.toMap(Section::getId, Function.identity())); Map<String, Section> sectionMap = sectionList.stream().collect(Collectors.toMap(Section::getId, Function.identity()));
return sectionMap; return sectionMap;


} }


/** /**
} }


/** /**
*
* 获取公路列表,放到map,减少循环次数 * 获取公路列表,放到map,减少循环次数
* *
* @param iotEquipmentList * @param iotEquipmentList

Loading…
Cancel
Save