功能优化

This commit is contained in:
mashuai 2025-09-10 17:33:45 +08:00
parent 6510eda512
commit af3b8b420a
12 changed files with 242 additions and 181 deletions

View File

@ -1,5 +1,8 @@
package com.bonus.common.biz.constant; package com.bonus.common.biz.constant;
import java.util.Arrays;
import java.util.List;
/** /**
* 全局常量 * 全局常量
* @author bns_han * @author bns_han
@ -567,4 +570,9 @@ public class GlobalConstants {
*/ */
public static final String XLSX = "xlsx"; public static final String XLSX = "xlsx";
/**
* 特殊角色权限全局配置
*/
public static final List<String> allowedRoles = Arrays.asList("ywgly", "16", "gy");
} }

View File

@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import cn.hutool.core.util.PhoneUtil; import cn.hutool.core.util.PhoneUtil;
import com.alibaba.nacos.common.utils.CollectionUtils; import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.constant.GlobalConstants;
import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.TypeTreeNode; import com.bonus.common.biz.domain.TypeTreeNode;
import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.biz.domain.lease.LeaseOutDetails;
@ -106,12 +107,17 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
//先根据外层id查询上层信息 //先根据外层id查询上层信息
BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id); BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id);
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 检查用户是否具有特殊角色
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); boolean hasSpecialRole = hasSpecialRole(userRoles);
if (CollectionUtils.isEmpty(typeIdList)) { if (!hasSpecialRole) {
backApplyInfo.setUserId(userId == 0 ? null : userId); backApplyInfo.setUserId(userId == 0 ? null : userId);
} }
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
/*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) {
backApplyInfo.setUserId(userId == 0 ? null : userId);
}*/
// 设置审批人签名url,目前固定查询夏成刚签名信息 // 设置审批人签名url,目前固定查询夏成刚签名信息
BackApplyInfo info = backApplyInfoMapper.getDirectAuditUrl(backApplyInfo); BackApplyInfo info = backApplyInfoMapper.getDirectAuditUrl(backApplyInfo);
@ -147,11 +153,11 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(backApplyInfo); List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(backApplyInfo);
if (CollectionUtils.isNotEmpty(backApplyDetailsList)) { if (CollectionUtils.isNotEmpty(backApplyDetailsList)) {
if (!CollectionUtils.isEmpty(typeIdList)) { /*if (!CollectionUtils.isEmpty(typeIdList)) {
backApplyDetailsList = backApplyDetailsList.stream() backApplyDetailsList = backApplyDetailsList.stream()
.filter(item -> typeIdList.contains(item.getFirstId())) .filter(item -> typeIdList.contains(item.getFirstId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }*/
// 核心优化减少数据库查询次数 // 核心优化减少数据库查询次数
// 1. 一次性查询编码设备信息 // 1. 一次性查询编码设备信息
@ -458,31 +464,14 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
.collect(Collectors.toList()); .collect(Collectors.toList());
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); //List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) { Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
backApplyInfo.setUserId(userId == 0 ? null : userId); backApplyInfo.setUserId(userId == 0 ? null : userId);
} }
list = backApplyInfoMapper.selectBackApplyInfoList(backApplyInfo); list = backApplyInfoMapper.selectBackApplyInfoList(backApplyInfo);
if (!CollectionUtils.isEmpty(typeIdList)) {
// 使用流过滤符合条件的元素
list = list.stream()
.filter(item -> {
String firstIdStr = item.getFirstId();
if (firstIdStr == null) {
return false;
}
// 将逗号分隔的字符串转为集合
Set<Long> firstIds = Arrays.stream(firstIdStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.collect(Collectors.toSet());
// 判断两个集合是否有交集
return firstIds.stream().anyMatch(typeIdList::contains);
})
.collect(Collectors.toList());
}
for (BackApplyInfo applyInfo : list) { for (BackApplyInfo applyInfo : list) {
if (StringUtils.isNotBlank(applyInfo.getBackSignUrl())) { if (StringUtils.isNotBlank(applyInfo.getBackSignUrl())) {
if (!applyInfo.getBackSignUrl().startsWith("http")) { if (!applyInfo.getBackSignUrl().startsWith("http")) {
@ -491,7 +480,20 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
} }
} }
if (CollectionUtils.isNotEmpty(infos)) { if (CollectionUtils.isNotEmpty(infos)) {
list.addAll(infos); for (BackApplyInfo info : infos) {
// 假设Info类中有get单号Code()方法获取单号
String infoCode = info.getCode();
// 检查list中是否已存在相同单号的元素
boolean exists = list.stream()
.anyMatch(item -> infoCode.equals(item.getCode()));
// 如果不存在则添加
if (!exists) {
list.add(info);
}
}
} }
if (CollectionUtils.isNotEmpty( list)) { if (CollectionUtils.isNotEmpty( list)) {
list = list.stream() list = list.stream()
@ -529,6 +531,19 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
return list; return list;
} }
/**
* 检查用户是否具有特殊角色
* @param userRoles
* @return
*/
private boolean hasSpecialRole(Set<String> userRoles) {
if (userRoles == null) {
return false;
}
List<String> allowedRoles = GlobalConstants.allowedRoles;
return allowedRoles.stream().anyMatch(userRoles::contains);
}
/** /**
* 关键字搜索 * 关键字搜索
* @param item * @param item
@ -1936,31 +1951,17 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
backApplyInfo.setIsSign(1); backApplyInfo.setIsSign(1);
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); /*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) { if (CollectionUtils.isEmpty(typeIdList)) {
backApplyInfo.setUserId(userId == 0 ? null : userId); backApplyInfo.setUserId(userId == 0 ? null : userId);
}*/
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
backApplyInfo.setUserId(userId == 0 ? null : userId);
} }
List<BackApplyInfo> list = backApplyInfoMapper.selectBackApplyInfoList(backApplyInfo); List<BackApplyInfo> list = backApplyInfoMapper.selectBackApplyInfoList(backApplyInfo);
if (!CollectionUtils.isEmpty(typeIdList)) {
// 使用流过滤符合条件的元素
list = list.stream()
.filter(item -> {
String firstIdStr = item.getFirstId();
if (firstIdStr == null) {
return false;
}
// 将逗号分隔的字符串转为集合
Set<Long> firstIds = Arrays.stream(firstIdStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.collect(Collectors.toSet());
// 判断两个集合是否有交集
return firstIds.stream().anyMatch(typeIdList::contains);
})
.collect(Collectors.toList());
}
// 提取关键字 // 提取关键字
String keyWord = backApplyInfo.getKeyWord(); String keyWord = backApplyInfo.getKeyWord();
// 如果关键字不为空进行过滤 // 如果关键字不为空进行过滤

View File

@ -97,6 +97,9 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
// 性能监控开始 // 性能监控开始
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
Map<String, Long> stepTimes = new LinkedHashMap<>(); Map<String, Long> stepTimes = new LinkedHashMap<>();
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
log.info("=== selectLeaseApplyInfoById开始执行id: {}, keyword: {}, publishTask: {}", id, keyword, publishTask); log.info("=== selectLeaseApplyInfoById开始执行id: {}, keyword: {}, publishTask: {}", id, keyword, publishTask);
@ -110,14 +113,12 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
// 步骤2: 查询用户绑定的物资类型 // 步骤2: 查询用户绑定的物资类型
long step2Start = System.currentTimeMillis(); long step2Start = System.currentTimeMillis();
List<Long> typeIdList = leaseApplyInfoMapper.selectTypeIdList(userId); //List<Long> typeIdList = leaseApplyInfoMapper.selectTypeIdList(userId);
stepTimes.put("查询用户绑定物资类型", System.currentTimeMillis() - step2Start); stepTimes.put("查询用户绑定物资类型", System.currentTimeMillis() - step2Start);
// 步骤3: 设置查询参数 // 步骤3: 设置查询参数
long step3Start = System.currentTimeMillis(); long step3Start = System.currentTimeMillis();
if (!CollectionUtils.isEmpty(typeIdList)) { if (!hasSpecialRole) {
leaseApplyInfo.setTypeIdList(typeIdList);
} else {
leaseApplyInfo.setUserId(userId); leaseApplyInfo.setUserId(userId);
} }
if (StringUtils.isNotBlank(keyword)) { if (StringUtils.isNotBlank(keyword)) {
@ -192,8 +193,8 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
// 步骤8: 获取领料单详情 // 步骤8: 获取领料单详情
long step8Start = System.currentTimeMillis(); long step8Start = System.currentTimeMillis();
List<LeaseApplyDetails> details; List<LeaseApplyDetails> details;
if (!CollectionUtils.isEmpty(typeIdList)) { if (hasSpecialRole) {
details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, null, typeIdList)); details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, null, null));
} else { } else {
details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, userId, null)); details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, userId, null));
} }
@ -467,10 +468,10 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
@Override @Override
public List<LeaseApplyInfo> selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo) { public List<LeaseApplyInfo> selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo) {
try { try {
Long userId = SecurityUtils.getLoginUser().getUserid(); Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 检查用户是否具有特殊角色
List<Long> typeIdList = leaseApplyInfoMapper.selectTypeIdList(userId); boolean hasSpecialRole = hasSpecialRole(userRoles);
if (CollectionUtils.isEmpty(typeIdList)) { if (!hasSpecialRole) {
leaseApplyInfo.setUserId(SecurityUtils.getLoginUser().getUserid()); leaseApplyInfo.setUserId(SecurityUtils.getLoginUser().getUserid());
} }
//用leaseApplyInfo.getQueryType的值来区分是否是领用出库查询如果是时间筛选为发布时间 //用leaseApplyInfo.getQueryType的值来区分是否是领用出库查询如果是时间筛选为发布时间
@ -498,26 +499,6 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
Comparator.nullsFirst(Comparator.naturalOrder())).reversed()) Comparator.nullsFirst(Comparator.naturalOrder())).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(sortedList)) { if (!CollectionUtils.isEmpty(sortedList)) {
if (!CollectionUtils.isEmpty(typeIdList)) {
// 使用流过滤符合条件的元素
sortedList = sortedList.stream()
.filter(item -> {
String firstIdStr = item.getFirstId();
if (firstIdStr == null) {
return false;
}
// 将逗号分隔的字符串转为集合
Set<Long> firstIds = Arrays.stream(firstIdStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.collect(Collectors.toSet());
// 判断两个集合是否有交集
return firstIds.stream().anyMatch(typeIdList::contains);
})
.collect(Collectors.toList());
}
String keyWord = leaseApplyInfo.getKeyWord(); String keyWord = leaseApplyInfo.getKeyWord();
List<?> statusList = leaseApplyInfo.getStatusList(); List<?> statusList = leaseApplyInfo.getStatusList();
@ -538,6 +519,19 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
} }
} }
/**
* 检查用户是否具有特殊角色
* @param userRoles
* @return
*/
private boolean hasSpecialRole(Set<String> userRoles) {
if (userRoles == null) {
return false;
}
List<String> allowedRoles = GlobalConstants.allowedRoles;
return allowedRoles.stream().anyMatch(userRoles::contains);
}
/** /**
* 查询领用数据抽取 * 查询领用数据抽取
* @param leaseApplyInfo * @param leaseApplyInfo
@ -1530,9 +1524,11 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
msg = "监测到当前设备符合出库条件,请确认是否出库!"; msg = "监测到当前设备符合出库条件,请确认是否出库!";
}else{ }else{
msg = "监测到当前设备不符合出库条件,无法出库!"; msg = "监测到当前设备不符合出库条件,无法出库!";
recordList = new ArrayList<>();
} }
} else { } else {
msg = "监测到当前设备不符合出库条件,无法出库!!"; msg = "监测到当前设备不符合出库条件,无法出库!!";
recordList = new ArrayList<>();
} }
// 返回包含设备列表和消息的结果 // 返回包含设备列表和消息的结果
Map<String, Object> result = new HashMap<>(2); Map<String, Object> result = new HashMap<>(2);

View File

@ -1,6 +1,7 @@
package com.bonus.material.lossAssessment.service.impl; package com.bonus.material.lossAssessment.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.bonus.common.biz.constant.GlobalConstants;
import com.bonus.common.biz.domain.BmFileInfo; import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.common.biz.enums.*; import com.bonus.common.biz.enums.*;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
@ -66,32 +67,18 @@ public class LossAssessmentServiceImpl implements LossAssessmentService {
try { try {
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); /*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) { if (CollectionUtils.isEmpty(typeIdList)) {
bean.setUserId(userId == 0 ? null : userId); bean.setUserId(userId == 0 ? null : userId);
}*/
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
bean.setUserId(userId == 0 ? null : userId);
} }
List<RepairTask> list = mapper.getLossAssessmentList(bean); List<RepairTask> list = mapper.getLossAssessmentList(bean);
if (CollectionUtil.isNotEmpty(list)) { if (CollectionUtil.isNotEmpty(list)) {
if (CollectionUtil.isNotEmpty(typeIdList)) {
// 使用流过滤符合条件的元素
list = list.stream()
.filter(item -> {
String firstIdStr = item.getFirstId();
if (firstIdStr == null) {
return false;
}
// 将逗号分隔的字符串转为集合
Set<Long> firstIds = Arrays.stream(firstIdStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.collect(Collectors.toSet());
// 判断两个集合是否有交集
return firstIds.stream().anyMatch(typeIdList::contains);
})
.collect(Collectors.toList());
}
String keyWord = bean.getKeyWord(); String keyWord = bean.getKeyWord();
// 如果关键字不为空进行过滤 // 如果关键字不为空进行过滤
if (!StringUtils.isBlank(keyWord)) { if (!StringUtils.isBlank(keyWord)) {
@ -107,6 +94,19 @@ public class LossAssessmentServiceImpl implements LossAssessmentService {
} }
/**
* 检查用户是否具有特殊角色
* @param userRoles
* @return
*/
private boolean hasSpecialRole(Set<String> userRoles) {
if (userRoles == null) {
return false;
}
List<String> allowedRoles = GlobalConstants.allowedRoles;
return allowedRoles.stream().anyMatch(userRoles::contains);
}
@Override @Override
public List<RepairDeviceSummaryVo> getLossAssessmentDetailsList(RepairTaskDetails bean) { public List<RepairDeviceSummaryVo> getLossAssessmentDetailsList(RepairTaskDetails bean) {
try { try {

View File

@ -1,6 +1,7 @@
package com.bonus.material.repair.service.impl; package com.bonus.material.repair.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.bonus.common.biz.constant.GlobalConstants;
import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.repair.RepairInputDetails; import com.bonus.common.biz.domain.repair.RepairInputDetails;
import com.bonus.common.biz.domain.vo.KeyValueVO; import com.bonus.common.biz.domain.vo.KeyValueVO;
@ -100,19 +101,17 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
public List<RepairAuditDetails> getRepairAuditList(RepairAuditDetails repairAuditDetails) { public List<RepairAuditDetails> getRepairAuditList(RepairAuditDetails repairAuditDetails) {
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); /*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) { if (CollectionUtils.isEmpty(typeIdList)) {
repairAuditDetails.setUserId(userId == 0 ? null : userId); repairAuditDetails.setUserId(userId == 0 ? null : userId);
}*/
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
repairAuditDetails.setUserId(userId == 0 ? null : userId);
} }
List<RepairAuditDetails> list = repairAuditDetailsMapper.selectRepairAuditDetailsList(repairAuditDetails); return repairAuditDetailsMapper.selectRepairAuditDetailsList(repairAuditDetails);
if (CollectionUtil.isNotEmpty(list)) {
if (CollectionUtil.isNotEmpty(typeIdList)) {
list = list.stream()
.filter(item -> typeIdList.contains(item.getFirstId()))
.collect(Collectors.toList());
}
}
return list;
} }
@Override @Override
@ -139,35 +138,19 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
public List<ScrapApplyDetailsVO> selectRepairQuestList(RepairAuditDetails repairAuditDetails) { public List<ScrapApplyDetailsVO> selectRepairQuestList(RepairAuditDetails repairAuditDetails) {
try { try {
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 /*// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) { if (CollectionUtils.isEmpty(typeIdList)) {
repairAuditDetails.setUserId(userId == 0 ? null : userId); repairAuditDetails.setUserId(userId == 0 ? null : userId);
}*/
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
repairAuditDetails.setUserId(userId == 0 ? null : userId);
} }
// 获取所有需要查询的 taskId过滤空的 // 获取所有需要查询的 taskId过滤空的
List<ScrapApplyDetailsVO> repairQuestList = repairAuditDetailsMapper.selectRepairQuestList(repairAuditDetails); List<ScrapApplyDetailsVO> repairQuestList = repairAuditDetailsMapper.selectRepairQuestList(repairAuditDetails);
if (CollectionUtil.isNotEmpty(repairQuestList)) {
if (CollectionUtil.isNotEmpty(typeIdList)) {
// 使用流过滤符合条件的元素
repairQuestList = repairQuestList.stream()
.filter(item -> {
String firstIdStr = item.getFirstId();
if (firstIdStr == null) {
return false;
}
// 将逗号分隔的字符串转为集合
Set<Long> firstIds = Arrays.stream(firstIdStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.collect(Collectors.toSet());
// 判断两个集合是否有交集
return firstIds.stream().anyMatch(typeIdList::contains);
})
.collect(Collectors.toList());
}
}
// 通过流过滤掉空对象 并转换为 List集合 // 通过流过滤掉空对象 并转换为 List集合
List<Long> taskIds = repairQuestList.stream() List<Long> taskIds = repairQuestList.stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)
@ -210,6 +193,19 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
} }
} }
/**
* 检查用户是否具有特殊角色
* @param userRoles
* @return
*/
private boolean hasSpecialRole(Set<String> userRoles) {
if (userRoles == null) {
return false;
}
List<String> allowedRoles = GlobalConstants.allowedRoles;
return allowedRoles.stream().anyMatch(userRoles::contains);
}
/** /**
* 关键字搜索 * 关键字搜索
* @param item * @param item

View File

@ -10,6 +10,7 @@ import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.nacos.common.utils.CollectionUtils; import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.constant.GlobalConstants;
import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.common.biz.enums.*; import com.bonus.common.biz.enums.*;
@ -79,17 +80,18 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService
public List<RepairInputInfo> selectRepairInputDetailsById(RepairInputDetails repairInputDetails) { public List<RepairInputInfo> selectRepairInputDetailsById(RepairInputDetails repairInputDetails) {
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); /*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (org.springframework.util.CollectionUtils.isEmpty(typeIdList)) { if (org.springframework.util.CollectionUtils.isEmpty(typeIdList)) {
repairInputDetails.setUserId(userId == 0 ? null : userId); repairInputDetails.setUserId(userId == 0 ? null : userId);
}*/
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
repairInputDetails.setUserId(userId == 0 ? null : userId);
} }
List<RepairInputInfo> inputInfos = repairInputDetailsMapper.selectRepairInputDetailsById(repairInputDetails); List<RepairInputInfo> inputInfos = repairInputDetailsMapper.selectRepairInputDetailsById(repairInputDetails);
if (CollectionUtils.isNotEmpty(inputInfos)) { if (CollectionUtils.isNotEmpty(inputInfos)) {
if (CollectionUtils.isNotEmpty(typeIdList)) {
inputInfos = inputInfos.stream()
.filter(info -> typeIdList.contains(info.getFirstId()))
.collect(Collectors.toList());
}
for (RepairInputInfo inputInfo : inputInfos) { for (RepairInputInfo inputInfo : inputInfos) {
RepairInputDetails inputDetails = new RepairInputDetails(); RepairInputDetails inputDetails = new RepairInputDetails();
inputDetails.setTaskId(inputInfo.getTaskId()); inputDetails.setTaskId(inputInfo.getTaskId());
@ -130,31 +132,18 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService
public List<RepairInputDetails> selectRepairInputDetailsList(RepairInputDetails repairInputDetails) { public List<RepairInputDetails> selectRepairInputDetailsList(RepairInputDetails repairInputDetails) {
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); /* List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (org.springframework.util.CollectionUtils.isEmpty(typeIdList)) { if (org.springframework.util.CollectionUtils.isEmpty(typeIdList)) {
repairInputDetails.setUserId(userId == 0 ? null : userId); repairInputDetails.setUserId(userId == 0 ? null : userId);
}*/
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
repairInputDetails.setUserId(userId == 0 ? null : userId);
} }
List<RepairInputDetails> list = repairInputDetailsMapper.selectRepairInputDetailsList(repairInputDetails); List<RepairInputDetails> list = repairInputDetailsMapper.selectRepairInputDetailsList(repairInputDetails);
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
if (CollectionUtils.isNotEmpty(typeIdList)) {
list = list.stream()
.filter(item -> {
String firstIdStr = item.getFirstId();
if (firstIdStr == null) {
return false;
}
// 将逗号分隔的字符串转为集合
Set<Long> firstIds = Arrays.stream(firstIdStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.collect(Collectors.toSet());
// 判断两个集合是否有交集
return firstIds.stream().anyMatch(typeIdList::contains);
})
.collect(Collectors.toList());
}
for (RepairInputDetails inputDetails : list) { for (RepairInputDetails inputDetails : list) {
// 根据taskId和userId查询详情赋值最外层任务状态 // 根据taskId和userId查询详情赋值最外层任务状态
inputDetails.setUserId(SecurityUtils.getLoginUser().getUserid()); inputDetails.setUserId(SecurityUtils.getLoginUser().getUserid());
@ -199,6 +188,19 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService
return list; return list;
} }
/**
* 检查用户是否具有特殊角色
* @param userRoles
* @return
*/
private boolean hasSpecialRole(Set<String> userRoles) {
if (userRoles == null) {
return false;
}
List<String> allowedRoles = GlobalConstants.allowedRoles;
return allowedRoles.stream().anyMatch(userRoles::contains);
}
/** /**
* 关键字搜索 * 关键字搜索
* @param item * @param item

View File

@ -1,6 +1,7 @@
package com.bonus.material.repair.service.impl; package com.bonus.material.repair.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.bonus.common.biz.constant.GlobalConstants;
import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.enums.*; import com.bonus.common.biz.enums.*;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
@ -108,9 +109,15 @@ public class RepairServiceImpl implements RepairService {
public List<RepairTask> getRepairTaskList(RepairTask bean) { public List<RepairTask> getRepairTaskList(RepairTask bean) {
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); /*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) { if (CollectionUtils.isEmpty(typeIdList)) {
bean.setUserId(userId == 0 ? null : userId); bean.setUserId(userId == 0 ? null : userId);
}*/
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
bean.setUserId(userId == 0 ? null : userId);
} }
List<RepairTask> list = repairMapper.getRepairTaskList(bean); List<RepairTask> list = repairMapper.getRepairTaskList(bean);
if (CollectionUtil.isNotEmpty(list)) { if (CollectionUtil.isNotEmpty(list)) {
@ -121,7 +128,7 @@ public class RepairServiceImpl implements RepairService {
repairTask.setNum(task.getNum()); repairTask.setNum(task.getNum());
} }
} }
if (CollectionUtil.isNotEmpty(typeIdList)) { /*if (CollectionUtil.isNotEmpty(typeIdList)) {
// 使用流过滤符合条件的元素 // 使用流过滤符合条件的元素
list = list.stream() list = list.stream()
.filter(item -> { .filter(item -> {
@ -140,7 +147,7 @@ public class RepairServiceImpl implements RepairService {
return firstIds.stream().anyMatch(typeIdList::contains); return firstIds.stream().anyMatch(typeIdList::contains);
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
} }*/
String keyWord = bean.getKeyWord(); String keyWord = bean.getKeyWord();
// 如果关键字不为空进行过滤 // 如果关键字不为空进行过滤
if (!StringUtils.isBlank(keyWord)) { if (!StringUtils.isBlank(keyWord)) {
@ -152,6 +159,19 @@ public class RepairServiceImpl implements RepairService {
return list; return list;
} }
/**
* 检查用户是否具有特殊角色
* @param userRoles
* @return
*/
private boolean hasSpecialRole(Set<String> userRoles) {
if (userRoles == null) {
return false;
}
List<String> allowedRoles = GlobalConstants.allowedRoles;
return allowedRoles.stream().anyMatch(userRoles::contains);
}
/** /**
* 关键字搜索 * 关键字搜索
* *
@ -177,19 +197,25 @@ public class RepairServiceImpl implements RepairService {
public List<RepairDeviceSummaryVo> getRepairDeviceSummary(RepairTaskDetails bean) { public List<RepairDeviceSummaryVo> getRepairDeviceSummary(RepairTaskDetails bean) {
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); /*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) { if (CollectionUtils.isEmpty(typeIdList)) {
bean.setUserId(userId == 0 ? null : userId); bean.setUserId(userId == 0 ? null : userId);
}*/
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
bean.setUserId(userId == 0 ? null : userId);
} }
List<RepairDeviceSummaryVo> repairDeviceSummaryVoList = new ArrayList<>(); List<RepairDeviceSummaryVo> repairDeviceSummaryVoList = new ArrayList<>();
List<RepairDeviceVO> repairDeviceList = repairMapper.getRepairDeviceList(bean); List<RepairDeviceVO> repairDeviceList = repairMapper.getRepairDeviceList(bean);
if (CollectionUtil.isNotEmpty(repairDeviceList)) { /*if (CollectionUtil.isNotEmpty(repairDeviceList)) {
if (CollectionUtil.isNotEmpty(typeIdList)) { if (CollectionUtil.isNotEmpty(typeIdList)) {
repairDeviceList = repairDeviceList.stream() repairDeviceList = repairDeviceList.stream()
.filter(item -> typeIdList.contains(item.getFirstId())) .filter(item -> typeIdList.contains(item.getFirstId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }*/
Map<Long, List<RepairDeviceVO>> map = repairDeviceList.stream().collect(Collectors.groupingBy(RepairDeviceVO::getTypeId)); Map<Long, List<RepairDeviceVO>> map = repairDeviceList.stream().collect(Collectors.groupingBy(RepairDeviceVO::getTypeId));
for (Long key : map.keySet()) { for (Long key : map.keySet()) {
List<RepairDeviceVO> tempList = map.get(key); List<RepairDeviceVO> tempList = map.get(key);
@ -1710,19 +1736,18 @@ public class RepairServiceImpl implements RepairService {
try { try {
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息 // 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId); /*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) { if (CollectionUtils.isEmpty(typeIdList)) {
bean.setUserId(userId == 0 ? null : userId); bean.setUserId(userId == 0 ? null : userId);
}*/
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
bean.setUserId(userId == 0 ? null : userId);
} }
List<RepairDeviceSummaryVo> repairDeviceSummaryVoList = new ArrayList<>(); List<RepairDeviceSummaryVo> repairDeviceSummaryVoList = new ArrayList<>();
List<RepairDeviceVO> repairDeviceList = repairMapper.getAppRepairMaTypeListNew(bean); List<RepairDeviceVO> repairDeviceList = repairMapper.getAppRepairMaTypeListNew(bean);
if (CollectionUtil.isNotEmpty(repairDeviceList)) {
if (CollectionUtil.isNotEmpty(typeIdList)) {
repairDeviceList = repairDeviceList.stream()
.filter(item -> typeIdList.contains(item.getFirstId()))
.collect(Collectors.toList());
}
}
Map<Long, List<RepairDeviceVO>> map = repairDeviceList.stream().collect(Collectors.groupingBy(RepairDeviceVO::getTypeId)); Map<Long, List<RepairDeviceVO>> map = repairDeviceList.stream().collect(Collectors.groupingBy(RepairDeviceVO::getTypeId));
for (Long key : map.keySet()) { for (Long key : map.keySet()) {
List<RepairDeviceVO> tempList = map.get(key); List<RepairDeviceVO> tempList = map.get(key);

View File

@ -437,7 +437,7 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService {
newTaskId = insertTt(taskId); newTaskId = insertTt(taskId);
result += insertTta(newTaskId, scrapApplyDetails); result += insertTta(newTaskId, scrapApplyDetails);
} else { } else {
newTaskId = insertScrapTt(); newTaskId = insertScrapTtReject();
} }
if (CollectionUtils.isNotEmpty(scrapApplyDetailsList)) { if (CollectionUtils.isNotEmpty(scrapApplyDetailsList)) {
for (ScrapApplyDetails applyDetails : scrapApplyDetailsList) { for (ScrapApplyDetails applyDetails : scrapApplyDetailsList) {
@ -490,6 +490,28 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
} }
/**
* 插入驳回报废任务
* @return
*/
private Long insertScrapTtReject() {
Long newTask = null;
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_PART_SCRAP.getTaskTypeId());
// 生成盘点报废单号
String code = genderBfTaskCode(thisMonthMaxOrder);
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_PART_SCRAP.getTaskTypeId(), RepairInputStatusEnum.INPUT_TASK_TO_REJECT.getStatus(),
null,thisMonthMaxOrder + 1, code);
tmTask.setCreateTime(DateUtils.getNowDate());
tmTask.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
// 插入任务
int taskId = taskMapper.insertTmTask(tmTask);
// 如果插入成功且返回的 taskId 大于 0
if (taskId > 0 && tmTask.getTaskId() > 0) {
newTask = tmTask.getTaskId();
}
return newTask;
}
/** /**
* 查询报废台账审核总费用 * 查询报废台账审核总费用
* @param scrapApplyDetails * @param scrapApplyDetails

View File

@ -325,10 +325,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
CASE mt.manage_type CASE mt.manage_type
WHEN 0 THEN WHEN 0 THEN
IFNULL(subquery0.num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.dsNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0) IFNULL(subquery0.num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.dsNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0)
+ IFNULL(subquery12.repairAuditNum, 0) + IFNULL(subquery4.inputNum, 0) + IFNULL(subquery6.pendingScrapNum, 0) + IFNULL(subquery12.repairAuditNum, 0) + IFNULL(subquery4.inputNum, 0)
ELSE ELSE
IFNULL(mt.storage_num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.dsNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0) IFNULL(mt.storage_num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.dsNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0)
+ IFNULL(subquery12.repairAuditNum, 0) + IFNULL(subquery4.inputNum, 0) + IFNULL(subquery6.pendingScrapNum, 0) + IFNULL(subquery12.repairAuditNum, 0) + IFNULL(subquery4.inputNum, 0)
END AS allNum, END AS allNum,
CASE mt.manage_type CASE mt.manage_type
WHEN 0 THEN WHEN 0 THEN

View File

@ -354,6 +354,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0'
where where
mm.qr_code = #{qrCode} mm.qr_code = #{qrCode}
<if test="typeId != null">
and mt.type_id = #{typeId}
</if>
</select> </select>
<select id="getCodeList" resultType="com.bonus.material.back.domain.vo.MaCodeVo"> <select id="getCodeList" resultType="com.bonus.material.back.domain.vo.MaCodeVo">

View File

@ -642,8 +642,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mm.type_id as typeId, mm.type_id as typeId,
sd.dict_label as maStatus, sd.dict_label as maStatus,
mm.qr_code as qrCode, mm.qr_code as qrCode,
msi.supplier as maVender, -- 判断ma_vender是否为数字是则取msi.supplier否则取mm.ma_vender
mm.out_fac_time as outFacTime, CASE
WHEN mm.ma_vender REGEXP '^[0-9]+$' THEN msi.supplier
ELSE mm.ma_vender
END as maVender,
LEFT(mm.out_fac_time,10) as outFacTime,
mm.out_fac_code as outFacCode, mm.out_fac_code as outFacCode,
mm.assets_code as assetsCode, mm.assets_code as assetsCode,
mm.check_man as checkMan, mm.check_man as checkMan,

View File

@ -394,7 +394,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sum( sad.scrap_num ) AS scrapNum, sum( sad.scrap_num ) AS scrapNum,
mt.buy_price AS buyPrice, mt.buy_price AS buyPrice,
sad.scrap_type AS scrapType, sad.scrap_type AS scrapType,
GROUP_CONCAT( DISTINCT sad.create_by ) AS createName, CASE
WHEN sad.create_by REGEXP '^[A-Za-z]' THEN su.nick_name
ELSE sad.create_by
END AS createName,
DATE_FORMAT( sad.create_time, '%Y-%m' ) AS month, DATE_FORMAT( sad.create_time, '%Y-%m' ) AS month,
sad.ledger_status AS ledgerStatus, sad.ledger_status AS ledgerStatus,
sad.scrap_source AS scrapSource sad.scrap_source AS scrapSource
@ -402,6 +405,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
scrap_apply_details sad scrap_apply_details sad
LEFT JOIN ma_type mt ON sad.type_id = mt.type_id LEFT JOIN ma_type mt ON sad.type_id = mt.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN sys_user su ON su.user_name = sad.create_by
WHERE sad.`status` = '1' and sad.ledger_status = '0' WHERE sad.`status` = '1' and sad.ledger_status = '0'
<if test="keyWord != null and keyWord != ''"> <if test="keyWord != null and keyWord != ''">
AND ( AND (