This commit is contained in:
hayu 2025-09-19 14:50:17 +08:00
parent cadfdc6cdc
commit 0ae0d50578
1 changed files with 85 additions and 24 deletions

View File

@ -590,34 +590,53 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
@Override @Override
public List<MaterialRetainedTeamTotalVo> getTeamNumList(MaterialRetainedEquipmentInfo bean) { public List<MaterialRetainedTeamTotalVo> getTeamNumList(MaterialRetainedEquipmentInfo bean) {
String username = SecurityUtils.getLoginUser().getUsername(); String username = SecurityUtils.getLoginUser().getUsername();
// 根据用户名查询项目部信息 Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
List<String> departId = mapper.getDepartId(username); List<IwsTeamUserVo> iwsTeamUserVos = new ArrayList<>();
// 根据项目部id查询工程信息 BmTeam teamData = new BmTeam();
List<MaterialRetainedTeamTotalVo> teamNumList = materialMachineMapper.getTeamNumList(bean); // 检查用户是否具有特殊角色
if (!CollectionUtils.isEmpty(departId)) { boolean hasSpecialRole = hasSpecialRole(userRoles);
List<String> projectIdList = mapper.getProjectId(departId); if (!hasSpecialRole) {
List<BmProject> list = mapper.getProjectInfo(new BmProject()); // 根据用户名判断用户是否为班组长
if (CollectionUtils.isNotEmpty(list) && CollectionUtils.isNotEmpty(projectIdList)) { teamData = materialMachineMapper.getTeamData(username);
// 找出list中projectId与projectIdList中相同的数据 if (teamData == null) {
list = list.stream().filter(info -> projectIdList.contains(info.getProjectId())).collect(Collectors.toList()); // 根据用户名查询项目部信息
if (CollectionUtils.isNotEmpty(list)) { List<String> departId = mapper.getDepartId(username);
// 获取list中的projectId // 根据项目部id查询工程信息
List<String> collect = list.stream().map(BmProject::getProjectId).distinct().collect(Collectors.toList()); List<String> projectIdList = mapper.getAllProjectList(departId);
// 根据i8工程id查询班组信息 List<BmProject> list = mapper.getProjectInfo(new BmProject());
List<IwsTeamUserVo> iwsTeamUserVos = iwsTeamUserMapper.selectProjectTeamInfoByProjectIds(collect); if (CollectionUtils.isNotEmpty(list) && CollectionUtils.isNotEmpty(projectIdList)) {
if (CollectionUtil.isNotEmpty(iwsTeamUserVos)) { // 找出list中projectId与projectIdList中相同的数据
if (CollectionUtil.isNotEmpty(teamNumList)) { list = list.stream().filter(info -> projectIdList.contains(info.getProjectId())).collect(Collectors.toList());
// 筛选出teamNumList中班组名称和iwsTeamUserVos中班组名称相同的数据 if (CollectionUtils.isNotEmpty(list)) {
teamNumList = teamNumList.stream().filter(item -> iwsTeamUserVos.stream().anyMatch(info -> info.getTeamName().equals(item.getTeamName()))).collect(Collectors.toList()); // 获取list中的projectId
} List<String> collect = list.stream().map(BmProject::getProjectId).distinct().collect(Collectors.toList());
// 根据i8工程id查询班组信息
iwsTeamUserVos = iwsTeamUserMapper.selectProjectTeamInfoByProjectIds(collect);
} }
} }
} }
} }
// 根据用户名判断用户是否为班组长 List<MaterialRetainedTeamTotalVo> teamNumList = materialMachineMapper.getTeamNumList(bean);
BmTeam teamData = materialMachineMapper.getTeamData(username); for (MaterialRetainedTeamTotalVo materialRetainedEquipmentInfo : teamNumList) {
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); // 根据班组名称查询分包单位
if (CollectionUtils.isNotEmpty(teamNumList)) { String subUnitName = iwsTeamUserMapper.getTeamName(materialRetainedEquipmentInfo.getTeamName());
materialRetainedEquipmentInfo.setSubUnitName(subUnitName);
}
if(bean.getSubUnitName()!=null && !bean.getSubUnitName().equals("") && !teamNumList.isEmpty()){
// 根据传入的SubUnitName过滤列表
teamNumList = teamNumList.stream()
.filter(item -> StringUtils.equals(item.getSubUnitName(), bean.getSubUnitName()))
.collect(Collectors.toList());
}
if (!hasSpecialRole) {
if (CollectionUtil.isNotEmpty(iwsTeamUserVos)) {
if (CollectionUtil.isNotEmpty(teamNumList)) {
// 筛选出teamNumList中班组名称和iwsTeamUserVos中班组名称相同的数据
List<IwsTeamUserVo> finalIwsTeamUserVos = iwsTeamUserVos;
teamNumList = teamNumList.stream().filter(item -> finalIwsTeamUserVos.stream().anyMatch(info -> info.getTeamName().equals(item.getTeamName()))).collect(Collectors.toList());
}
}
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
if (deptId != null) { if (deptId != null) {
// 删除元素 // 删除元素
teamNumList.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); teamNumList.removeIf(m -> !deptId.toString().equals(m.getImpUnit()));
@ -630,6 +649,48 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
} }
return teamNumList; return teamNumList;
} }
// public List<MaterialRetainedTeamTotalVo> getTeamNumList(MaterialRetainedEquipmentInfo bean) {
// String username = SecurityUtils.getLoginUser().getUsername();
// // 根据用户名查询项目部信息
// List<String> departId = mapper.getDepartId(username);
// // 根据项目部id查询工程信息
// List<MaterialRetainedTeamTotalVo> teamNumList = materialMachineMapper.getTeamNumList(bean);
// if (!CollectionUtils.isEmpty(departId)) {
// List<String> projectIdList = mapper.getProjectId(departId);
// List<BmProject> list = mapper.getProjectInfo(new BmProject());
// if (CollectionUtils.isNotEmpty(list) && CollectionUtils.isNotEmpty(projectIdList)) {
// // 找出list中projectId与projectIdList中相同的数据
// list = list.stream().filter(info -> projectIdList.contains(info.getProjectId())).collect(Collectors.toList());
// if (CollectionUtils.isNotEmpty(list)) {
// // 获取list中的projectId
// List<String> collect = list.stream().map(BmProject::getProjectId).distinct().collect(Collectors.toList());
// // 根据i8工程id查询班组信息
// List<IwsTeamUserVo> iwsTeamUserVos = iwsTeamUserMapper.selectProjectTeamInfoByProjectIds(collect);
// if (CollectionUtil.isNotEmpty(iwsTeamUserVos)) {
// if (CollectionUtil.isNotEmpty(teamNumList)) {
// // 筛选出teamNumList中班组名称和iwsTeamUserVos中班组名称相同的数据
// teamNumList = teamNumList.stream().filter(item -> iwsTeamUserVos.stream().anyMatch(info -> info.getTeamName().equals(item.getTeamName()))).collect(Collectors.toList());
// }
// }
// }
// }
// }
// // 根据用户名判断用户是否为班组长
// BmTeam teamData = materialMachineMapper.getTeamData(username);
// Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
// if (CollectionUtils.isNotEmpty(teamNumList)) {
// if (deptId != null) {
// // 删除元素
// teamNumList.removeIf(m -> !deptId.toString().equals(m.getImpUnit()));
// }
// if (teamData != null) {
// return teamNumList.stream().filter(item -> {
// return StringUtils.isNotBlank(item.getIdCard()) && item.getIdCard().equals(username);
// }).collect(Collectors.toList());
// }
// }
// return teamNumList;
// }
/** /**
* 后台班组在用库存查询二级页面 * 后台班组在用库存查询二级页面