功能优化
This commit is contained in:
parent
6510eda512
commit
af3b8b420a
|
|
@ -1,5 +1,8 @@
|
|||
package com.bonus.common.biz.constant;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 全局常量
|
||||
* @author bns_han
|
||||
|
|
@ -567,4 +570,9 @@ public class GlobalConstants {
|
|||
*/
|
||||
public static final String XLSX = "xlsx";
|
||||
|
||||
/**
|
||||
* 特殊角色权限全局配置
|
||||
*/
|
||||
public static final List<String> allowedRoles = Arrays.asList("ywgly", "16", "gy");
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
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.domain.TypeTreeNode;
|
||||
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||
|
|
@ -106,12 +107,17 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
//先根据外层id查询上层信息
|
||||
BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id);
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
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);
|
||||
}
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
/*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
backApplyInfo.setUserId(userId == 0 ? null : userId);
|
||||
}*/
|
||||
|
||||
// 设置审批人签名url,目前固定查询夏成刚签名信息
|
||||
BackApplyInfo info = backApplyInfoMapper.getDirectAuditUrl(backApplyInfo);
|
||||
|
|
@ -147,11 +153,11 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(backApplyInfo);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(backApplyDetailsList)) {
|
||||
if (!CollectionUtils.isEmpty(typeIdList)) {
|
||||
/*if (!CollectionUtils.isEmpty(typeIdList)) {
|
||||
backApplyDetailsList = backApplyDetailsList.stream()
|
||||
.filter(item -> typeIdList.contains(item.getFirstId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}*/
|
||||
|
||||
// 核心优化:减少数据库查询次数
|
||||
// 1. 一次性查询编码设备信息
|
||||
|
|
@ -458,31 +464,14 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
.collect(Collectors.toList());
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
//List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
|
||||
// 检查用户是否具有特殊角色
|
||||
boolean hasSpecialRole = hasSpecialRole(userRoles);
|
||||
if (!hasSpecialRole) {
|
||||
backApplyInfo.setUserId(userId == 0 ? null : userId);
|
||||
}
|
||||
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) {
|
||||
if (StringUtils.isNotBlank(applyInfo.getBackSignUrl())) {
|
||||
if (!applyInfo.getBackSignUrl().startsWith("http")) {
|
||||
|
|
@ -491,7 +480,20 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
}
|
||||
}
|
||||
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)) {
|
||||
list = list.stream()
|
||||
|
|
@ -529,6 +531,19 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
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
|
||||
|
|
@ -1936,31 +1951,17 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
backApplyInfo.setIsSign(1);
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
/*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
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);
|
||||
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();
|
||||
// 如果关键字不为空,进行过滤
|
||||
|
|
|
|||
|
|
@ -97,6 +97,9 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
// 性能监控开始
|
||||
long startTime = System.currentTimeMillis();
|
||||
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);
|
||||
|
||||
|
|
@ -110,14 +113,12 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
|
||||
// 步骤2: 查询用户绑定的物资类型
|
||||
long step2Start = System.currentTimeMillis();
|
||||
List<Long> typeIdList = leaseApplyInfoMapper.selectTypeIdList(userId);
|
||||
//List<Long> typeIdList = leaseApplyInfoMapper.selectTypeIdList(userId);
|
||||
stepTimes.put("查询用户绑定物资类型", System.currentTimeMillis() - step2Start);
|
||||
|
||||
// 步骤3: 设置查询参数
|
||||
long step3Start = System.currentTimeMillis();
|
||||
if (!CollectionUtils.isEmpty(typeIdList)) {
|
||||
leaseApplyInfo.setTypeIdList(typeIdList);
|
||||
} else {
|
||||
if (!hasSpecialRole) {
|
||||
leaseApplyInfo.setUserId(userId);
|
||||
}
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
|
|
@ -192,8 +193,8 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
// 步骤8: 获取领料单详情
|
||||
long step8Start = System.currentTimeMillis();
|
||||
List<LeaseApplyDetails> details;
|
||||
if (!CollectionUtils.isEmpty(typeIdList)) {
|
||||
details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, null, typeIdList));
|
||||
if (hasSpecialRole) {
|
||||
details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, null, null));
|
||||
} else {
|
||||
details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, userId, null));
|
||||
}
|
||||
|
|
@ -467,10 +468,10 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
@Override
|
||||
public List<LeaseApplyInfo> selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo) {
|
||||
try {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = leaseApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
|
||||
// 检查用户是否具有特殊角色
|
||||
boolean hasSpecialRole = hasSpecialRole(userRoles);
|
||||
if (!hasSpecialRole) {
|
||||
leaseApplyInfo.setUserId(SecurityUtils.getLoginUser().getUserid());
|
||||
}
|
||||
//用leaseApplyInfo.getQueryType的值来区分是否是领用出库查询,如果是,时间筛选为发布时间
|
||||
|
|
@ -498,26 +499,6 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
Comparator.nullsFirst(Comparator.naturalOrder())).reversed())
|
||||
.collect(Collectors.toList());
|
||||
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();
|
||||
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
|
||||
|
|
@ -1530,9 +1524,11 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
msg = "监测到当前设备符合出库条件,请确认是否出库!";
|
||||
}else{
|
||||
msg = "监测到当前设备不符合出库条件,无法出库!";
|
||||
recordList = new ArrayList<>();
|
||||
}
|
||||
} else {
|
||||
msg = "监测到当前设备不符合出库条件,无法出库!!";
|
||||
recordList = new ArrayList<>();
|
||||
}
|
||||
// 返回包含设备列表和消息的结果
|
||||
Map<String, Object> result = new HashMap<>(2);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.material.lossAssessment.service.impl;
|
||||
|
||||
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.enums.*;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
|
|
@ -66,32 +67,18 @@ public class LossAssessmentServiceImpl implements LossAssessmentService {
|
|||
try {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
/*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
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);
|
||||
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();
|
||||
// 如果关键字不为空,进行过滤
|
||||
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
|
||||
public List<RepairDeviceSummaryVo> getLossAssessmentDetailsList(RepairTaskDetails bean) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.material.repair.service.impl;
|
||||
|
||||
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.domain.repair.RepairInputDetails;
|
||||
import com.bonus.common.biz.domain.vo.KeyValueVO;
|
||||
|
|
@ -100,19 +101,17 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
|||
public List<RepairAuditDetails> getRepairAuditList(RepairAuditDetails repairAuditDetails) {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
/*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
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);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
if (CollectionUtil.isNotEmpty(typeIdList)) {
|
||||
list = list.stream()
|
||||
.filter(item -> typeIdList.contains(item.getFirstId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
return repairAuditDetailsMapper.selectRepairAuditDetailsList(repairAuditDetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -139,35 +138,19 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
|||
public List<ScrapApplyDetailsVO> selectRepairQuestList(RepairAuditDetails repairAuditDetails) {
|
||||
try {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
/*// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
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、过滤空的
|
||||
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<Long> taskIds = repairQuestList.stream()
|
||||
.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
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
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.domain.lease.LeaseOutDetails;
|
||||
import com.bonus.common.biz.enums.*;
|
||||
|
|
@ -79,17 +80,18 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService
|
|||
public List<RepairInputInfo> selectRepairInputDetailsById(RepairInputDetails repairInputDetails) {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
/*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (org.springframework.util.CollectionUtils.isEmpty(typeIdList)) {
|
||||
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);
|
||||
if (CollectionUtils.isNotEmpty(inputInfos)) {
|
||||
if (CollectionUtils.isNotEmpty(typeIdList)) {
|
||||
inputInfos = inputInfos.stream()
|
||||
.filter(info -> typeIdList.contains(info.getFirstId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
for (RepairInputInfo inputInfo : inputInfos) {
|
||||
RepairInputDetails inputDetails = new RepairInputDetails();
|
||||
inputDetails.setTaskId(inputInfo.getTaskId());
|
||||
|
|
@ -130,31 +132,18 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService
|
|||
public List<RepairInputDetails> selectRepairInputDetailsList(RepairInputDetails repairInputDetails) {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
/* List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (org.springframework.util.CollectionUtils.isEmpty(typeIdList)) {
|
||||
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);
|
||||
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) {
|
||||
// 根据taskId和userId查询详情,赋值最外层任务状态
|
||||
inputDetails.setUserId(SecurityUtils.getLoginUser().getUserid());
|
||||
|
|
@ -199,6 +188,19 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService
|
|||
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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.material.repair.service.impl;
|
||||
|
||||
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.enums.*;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
|
|
@ -108,9 +109,15 @@ public class RepairServiceImpl implements RepairService {
|
|||
public List<RepairTask> getRepairTaskList(RepairTask bean) {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
/*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
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);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
|
|
@ -121,7 +128,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
repairTask.setNum(task.getNum());
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(typeIdList)) {
|
||||
/*if (CollectionUtil.isNotEmpty(typeIdList)) {
|
||||
// 使用流过滤符合条件的元素
|
||||
list = list.stream()
|
||||
.filter(item -> {
|
||||
|
|
@ -140,7 +147,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
return firstIds.stream().anyMatch(typeIdList::contains);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}*/
|
||||
String keyWord = bean.getKeyWord();
|
||||
// 如果关键字不为空,进行过滤
|
||||
if (!StringUtils.isBlank(keyWord)) {
|
||||
|
|
@ -152,6 +159,19 @@ public class RepairServiceImpl implements RepairService {
|
|||
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) {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
/*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
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<RepairDeviceVO> repairDeviceList = repairMapper.getRepairDeviceList(bean);
|
||||
if (CollectionUtil.isNotEmpty(repairDeviceList)) {
|
||||
/*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));
|
||||
for (Long key : map.keySet()) {
|
||||
List<RepairDeviceVO> tempList = map.get(key);
|
||||
|
|
@ -1710,19 +1736,18 @@ public class RepairServiceImpl implements RepairService {
|
|||
try {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
|
||||
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
/*List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
|
||||
if (CollectionUtils.isEmpty(typeIdList)) {
|
||||
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<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));
|
||||
for (Long key : map.keySet()) {
|
||||
List<RepairDeviceVO> tempList = map.get(key);
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService {
|
|||
newTaskId = insertTt(taskId);
|
||||
result += insertTta(newTaskId, scrapApplyDetails);
|
||||
} else {
|
||||
newTaskId = insertScrapTt();
|
||||
newTaskId = insertScrapTtReject();
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(scrapApplyDetailsList)) {
|
||||
for (ScrapApplyDetails applyDetails : scrapApplyDetailsList) {
|
||||
|
|
@ -490,6 +490,28 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -325,10 +325,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
CASE mt.manage_type
|
||||
WHEN 0 THEN
|
||||
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
|
||||
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,
|
||||
CASE mt.manage_type
|
||||
WHEN 0 THEN
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
where
|
||||
mm.qr_code = #{qrCode}
|
||||
<if test="typeId != null">
|
||||
and mt.type_id = #{typeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getCodeList" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
||||
|
|
|
|||
|
|
@ -642,8 +642,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
mm.type_id as typeId,
|
||||
sd.dict_label as maStatus,
|
||||
mm.qr_code as qrCode,
|
||||
msi.supplier as maVender,
|
||||
mm.out_fac_time as outFacTime,
|
||||
-- 判断ma_vender是否为数字,是则取msi.supplier,否则取mm.ma_vender
|
||||
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.assets_code as assetsCode,
|
||||
mm.check_man as checkMan,
|
||||
|
|
|
|||
|
|
@ -394,7 +394,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sum( sad.scrap_num ) AS scrapNum,
|
||||
mt.buy_price AS buyPrice,
|
||||
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,
|
||||
sad.ledger_status AS ledgerStatus,
|
||||
sad.scrap_source AS scrapSource
|
||||
|
|
@ -402,6 +405,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
scrap_apply_details sad
|
||||
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 sys_user su ON su.user_name = sad.create_by
|
||||
WHERE sad.`status` = '1' and sad.ledger_status = '0'
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND (
|
||||
|
|
|
|||
Loading…
Reference in New Issue