From fdd2df45768ea2f86e176146d1035fac45bef13b Mon Sep 17 00:00:00 2001 From: mashuai Date: Fri, 5 Sep 2025 13:09:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/domain/lease/LeaseOutDetails.java | 3 + .../MaterialBackApplyInfoServiceImpl.java | 116 ++++++++++------ .../impl/MaterialLeaseInfoServiceImpl.java | 124 +++++++++++------- .../impl/MaterialMachineServiceImpl.java | 79 +++++++---- .../material/common/mapper/SelectMapper.java | 7 + .../lease/domain/LeaseApplyDetails.java | 3 + .../lease/mapper/LeaseApplyDetailsMapper.java | 18 ++- .../impl/LeaseApplyInfoServiceImpl.java | 36 ++++- .../mapper/material/common/SelectMapper.xml | 11 ++ .../lease/LeaseApplyDetailsMapper.xml | 64 +++++++-- .../material/lease/LeaseOutDetailsMapper.xml | 6 + 11 files changed, 338 insertions(+), 129 deletions(-) diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java index bf6b5cd2..e19dce57 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java @@ -176,4 +176,7 @@ public class LeaseOutDetails extends BaseEntity { @ApiModelProperty(value = "任务单号") private String code; + @ApiModelProperty(value = "唯一任务id") + private String keyId; + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialBackApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialBackApplyInfoServiceImpl.java index 53798a42..f413b144 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialBackApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialBackApplyInfoServiceImpl.java @@ -82,27 +82,35 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe @Override public List selectBackApplyInfoList(MaterialBackApplyInfo backApplyInfo) { String username = SecurityUtils.getLoginUser().getUsername(); - // 根据用户名判断用户是否为班组长 - BmTeam teamData = materialMachineMapper.getTeamData(username); - if (teamData == null) { - // 根据用户名查询项目部信息 - String departId = mapper.getDepartId(username); - // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); - if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { - backApplyInfo.setProjectIdList(projectIdList); + BmTeam teamData = null; + Set userRoles = SecurityUtils.getLoginUser().getRoles(); + // 检查用户是否具有特殊角色 + boolean hasSpecialRole = hasSpecialRole(userRoles); + if (!hasSpecialRole) { + // 根据用户名判断用户是否为班组长 + teamData = materialMachineMapper.getTeamData(username); + if (teamData == null) { + // 根据用户名查询项目部信息 + String departId = mapper.getDepartId(username); + // 根据项目部id查询工程信息 + List projectIdList = mapper.getProjectId(departId); + if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { + backApplyInfo.setProjectIdList(projectIdList); + } + backApplyInfo.setIdCard(null); } - backApplyInfo.setIdCard(null); } List list = materialBackInfoMapper.selectBackApplyInfoList(backApplyInfo); // 如果列表为空,直接返回空列表 if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); } - Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - if (!org.springframework.util.CollectionUtils.isEmpty(list) && deptId != null) { - // 删除元素 - list.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + if (!hasSpecialRole) { + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!org.springframework.util.CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + } } if (!org.springframework.util.CollectionUtils.isEmpty(list)) { // 班组长权限 @@ -186,23 +194,31 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe */ @Override public List getTotalList(MaterialBackApplyInfo backApplyInfo) { + Set userRoles = SecurityUtils.getLoginUser().getRoles(); String username = SecurityUtils.getLoginUser().getUsername(); - // 根据用户名判断用户是否为班组长 - BmTeam teamData = materialMachineMapper.getTeamData(username); - if (teamData == null) { - // 根据用户名查询项目部信息 - String departId = mapper.getDepartId(username); - // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); - if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { - backApplyInfo.setProjectIdList(projectIdList); + // 检查用户是否具有特殊角色 + boolean hasSpecialRole = hasSpecialRole(userRoles); + BmTeam teamData = null; + if (!hasSpecialRole) { + // 根据用户名判断用户是否为班组长 + teamData = materialMachineMapper.getTeamData(username); + if (teamData == null) { + // 根据用户名查询项目部信息 + String departId = mapper.getDepartId(username); + // 根据项目部id查询工程信息 + List projectIdList = mapper.getProjectId(departId); + if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { + backApplyInfo.setProjectIdList(projectIdList); + } } } List list = materialBackInfoMapper.getTotalList(backApplyInfo); - Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - if (!org.springframework.util.CollectionUtils.isEmpty(list) && deptId != null) { - // 删除元素 - list.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + if (!hasSpecialRole) { + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!org.springframework.util.CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + } } if (!org.springframework.util.CollectionUtils.isEmpty(list)) { // 班组长权限 @@ -227,6 +243,18 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe return list; } + /** + * 检查用户是否具有特殊角色 + * @param userRoles + * @return + */ + private boolean hasSpecialRole(Set userRoles) { + if (userRoles == null) { + return false; + } + List allowedRoles = Collections.singletonList("clzcx"); + return allowedRoles.stream().anyMatch(userRoles::contains); + } /** * 查询总站点退料详情数据 * @param backApplyInfo @@ -535,23 +563,31 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe @Override public List getBackInfoDetails(MaterialBackApplyTotalInfo info) { String username = SecurityUtils.getLoginUser().getUsername(); - // 根据用户名判断用户是否为班组长 - BmTeam teamData = materialMachineMapper.getTeamData(username); - if (teamData == null) { - // 根据用户名查询项目部信息 - String departId = mapper.getDepartId(username); - // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); - if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { - info.setProjectIdList(projectIdList); + BmTeam teamData = null; + Set userRoles = SecurityUtils.getLoginUser().getRoles(); + // 检查用户是否具有特殊角色 + boolean hasSpecialRole = hasSpecialRole(userRoles); + if (!hasSpecialRole) { + // 根据用户名判断用户是否为班组长 + teamData = materialMachineMapper.getTeamData(username); + if (teamData == null) { + // 根据用户名查询项目部信息 + String departId = mapper.getDepartId(username); + // 根据项目部id查询工程信息 + List projectIdList = mapper.getProjectId(departId); + if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { + info.setProjectIdList(projectIdList); + } } } BigDecimal backNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); List list = materialBackInfoMapper.getBackInfoDetails(info); - Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - if (!CollectionUtils.isEmpty(list) && deptId != null) { - // 删除元素 - list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + if (!hasSpecialRole) { + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + } } if (!org.springframework.util.CollectionUtils.isEmpty(list)) { // 班组长权限 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java index 3160f55e..017b88c6 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java @@ -101,29 +101,37 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { */ @Override public List selectLeaseApplyInfoList(MaterialLeaseApplyInfo leaseApplyInfo) { + Set userRoles = SecurityUtils.getLoginUser().getRoles(); String username = SecurityUtils.getLoginUser().getUsername(); - // 根据用户名判断用户是否为班组长 - BmTeam teamData = materialMachineMapper.getTeamData(username); - if (teamData == null) { - // 根据用户名查询项目部信息 - String departId = mapper.getDepartId(username); - // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); - if (!CollectionUtils.isEmpty(projectIdList)) { - leaseApplyInfo.setProjectIdList(projectIdList); + BmTeam teamData = null; + // 检查用户是否具有特殊角色 + boolean hasSpecialRole = hasSpecialRole(userRoles); + if (!hasSpecialRole) { + // 根据用户名判断用户是否为班组长 + teamData = materialMachineMapper.getTeamData(username); + if (teamData == null) { + // 根据用户名查询项目部信息 + String departId = mapper.getDepartId(username); + // 根据项目部id查询工程信息 + List projectIdList = mapper.getProjectId(departId); + if (!CollectionUtils.isEmpty(projectIdList)) { + leaseApplyInfo.setProjectIdList(projectIdList); + } + leaseApplyInfo.setIdCard(null); } - leaseApplyInfo.setIdCard(null); } List list = materialLeaseInfoMapper.selectLeaseApplyInfoList(leaseApplyInfo); // 利用Stream API进行降序排序 List sortedList = list.stream() .sorted(Comparator.comparing(MaterialLeaseApplyInfo::getCreateTime).reversed()) .collect(Collectors.toList()); - // 数据权限划分,获取当前用户的deptId - Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - if (!CollectionUtils.isEmpty(sortedList) && deptId != null) { - // 删除元素 - sortedList.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + if (!hasSpecialRole) { + // 数据权限划分,获取当前用户的deptId + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(sortedList) && deptId != null) { + // 删除元素 + sortedList.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + } } if (!CollectionUtils.isEmpty(sortedList)) { if (teamData != null) { @@ -131,9 +139,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { sortedList = sortedList.stream() .filter(item -> StringUtils.isBlank(item.getTeamLeaderIdCard()) || username.equals(item.getTeamLeaderIdCard())) .collect(Collectors.toList()); - } /*else { - sortedList = filterByDataPermission(sortedList); - }*/ + } } // 处理剩余数据 if (!CollectionUtils.isEmpty(sortedList)) { @@ -154,6 +160,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { return sortedList; } + /** * 数据权限过滤 * @@ -214,16 +221,22 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { */ @Override public List getTotalList(MaterialLeaseApplyInfo leaseApplyInfo) { + Set userRoles = SecurityUtils.getLoginUser().getRoles(); String username = SecurityUtils.getLoginUser().getUsername(); - // 根据用户名判断用户是否为班组长 - BmTeam teamData = materialMachineMapper.getTeamData(username); - if (teamData == null) { - // 根据用户名查询项目部信息 - String departId = mapper.getDepartId(username); - // 根据项目部id查询工程信息 - List projectIdList = mapper.getAllProjectList(departId); - if (!CollectionUtils.isEmpty(projectIdList)) { - leaseApplyInfo.setProjectIdList(projectIdList); + BmTeam teamData = new BmTeam(); + // 检查用户是否具有特殊角色 + boolean hasSpecialRole = hasSpecialRole(userRoles); + if (!hasSpecialRole) { + // 根据用户名判断用户是否为班组长 + teamData = materialMachineMapper.getTeamData(username); + if (teamData == null) { + // 根据用户名查询项目部信息 + String departId = mapper.getDepartId(username); + // 根据项目部id查询工程信息 + List projectIdList = mapper.getAllProjectList(departId); + if (!CollectionUtils.isEmpty(projectIdList)) { + leaseApplyInfo.setProjectIdList(projectIdList); + } } } // 领料数据 @@ -251,10 +264,12 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { .sorted(Comparator.comparing(MaterialLeaseApplyInfo::getCreateTime, Comparator.nullsLast(Comparator.naturalOrder())).reversed()) .collect(Collectors.toList()); - Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - if (!CollectionUtils.isEmpty(sortedList) && deptId != null) { - // 删除元素 - sortedList.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + if (!hasSpecialRole) { + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(sortedList) && deptId != null) { + // 删除元素 + sortedList.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + } } if (!CollectionUtils.isEmpty(sortedList)) { // 班组数据权限 @@ -276,6 +291,19 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { return sortedList; } + /** + * 检查用户是否具有特殊角色 + * @param userRoles + * @return + */ + private boolean hasSpecialRole(Set userRoles) { + if (userRoles == null) { + return false; + } + List allowedRoles = Collections.singletonList("clzcx"); + return allowedRoles.stream().anyMatch(userRoles::contains); + } + /** * 查询总站点领料详情数据 * @@ -1192,25 +1220,33 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { @Override public List getLeaseInfoDetails(LeaseTotalInfo info) { String username = SecurityUtils.getLoginUser().getUsername(); - // 根据用户名判断用户是否为班组长 - BmTeam teamData = materialMachineMapper.getTeamData(username); - if (teamData == null) { - // 根据用户名查询项目部信息 - String departId = mapper.getDepartId(username); - // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); - if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { - info.setProjectIdList(projectIdList); + BmTeam teamData = null; + Set userRoles = SecurityUtils.getLoginUser().getRoles(); + // 检查用户是否具有特殊角色 + boolean hasSpecialRole = hasSpecialRole(userRoles); + if (!hasSpecialRole) { + // 根据用户名判断用户是否为班组长 + teamData = materialMachineMapper.getTeamData(username); + if (teamData == null) { + // 根据用户名查询项目部信息 + String departId = mapper.getDepartId(username); + // 根据项目部id查询工程信息 + List projectIdList = mapper.getProjectId(departId); + if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { + info.setProjectIdList(projectIdList); + } } } BigDecimal preNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); BigDecimal outNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); BigDecimal pendingNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); List list = materialLeaseInfoMapper.getLeaseInfoDetails(info); - Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - if (!CollectionUtils.isEmpty(list) && deptId != null) { - // 删除元素 - list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + if (!hasSpecialRole) { + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + } } if (!CollectionUtils.isEmpty(list)) { // 班组长权限 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java index 2555e087..29e9b309 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java @@ -59,20 +59,26 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { */ @Override public List getMachineInfo(Machine machine) { + Set userRoles = SecurityUtils.getLoginUser().getRoles(); String username = SecurityUtils.getLoginUser().getUsername(); - // 根据用户名判断用户是否为班组长 - BmTeam teamData = materialMachineMapper.getTeamData(username); - if (teamData == null) { - // 根据用户名查询项目部信息 - String departId = mapper.getDepartId(username); - // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); - if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { - machine.setProjectIdList(projectIdList); + BmTeam teamData = new BmTeam(); + // 检查用户是否具有特殊角色 + boolean hasSpecialRole = hasSpecialRole(userRoles); + if (!hasSpecialRole) { + // 根据用户名判断用户是否为班组长 + teamData = materialMachineMapper.getTeamData(username); + if (teamData == null) { + // 根据用户名查询项目部信息 + String departId = mapper.getDepartId(username); + // 根据项目部id查询工程信息 + List projectIdList = mapper.getProjectId(departId); + if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { + machine.setProjectIdList(projectIdList); + } } + // 查询slt_agreement_info数据 + machine.setImpUnit(SecurityUtils.getLoginUser().getSysUser().getDeptId().toString()); } - // 查询slt_agreement_info数据 - machine.setImpUnit(SecurityUtils.getLoginUser().getSysUser().getDeptId().toString()); List mergedList = materialMachineMapper.getMachineInfo(machine); if (!CollectionUtils.isEmpty(mergedList)) { // 班组权限 @@ -718,8 +724,11 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { String username = SecurityUtils.getLoginUser().getUsername(); // 根据用户名查询项目部信息 String departId = mapper.getDepartId(username); + if (StringUtils.isBlank(departId)) { + return AjaxResult.success(); + } // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); + List projectIdList = mapper.getInProject(departId); List list = mapper.getProjectInfo(new BmProject()); Set agreementIdList = new HashSet<>(); if (CollectionUtils.isNotEmpty(list)) { @@ -751,21 +760,28 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { @Override public List getTotalList(MaterialRetainedEquipmentInfo bean) { String username = SecurityUtils.getLoginUser().getUsername(); - // 根据用户名判断用户是否为班组长 - BmTeam teamData = materialMachineMapper.getTeamData(username); - if (teamData == null) { - // 根据用户名查询项目部信息 - String departId = mapper.getDepartId(username); - // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); - if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { - bean.setProjectIdList(projectIdList); + BmTeam teamData = null; + Set userRoles = SecurityUtils.getLoginUser().getRoles(); + // 检查用户是否具有特殊角色 + boolean hasSpecialRole = hasSpecialRole(userRoles); + if (!hasSpecialRole) { + // 根据用户名判断用户是否为班组长 + teamData = materialMachineMapper.getTeamData(username); + if (teamData == null) { + // 根据用户名查询项目部信息 + String departId = mapper.getDepartId(username); + // 根据项目部id查询工程信息 + List projectIdList = mapper.getProjectId(departId); + if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) { + bean.setProjectIdList(projectIdList); + } + } + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (deptId != null) { + bean.setImpUnit(deptId.toString()); } } - Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - if (deptId != null) { - bean.setImpUnit(deptId.toString()); - } + List recordList = materialMachineMapper.getRetainedEquipmentList(bean); if (!CollectionUtils.isEmpty(recordList)) { if (teamData != null) { @@ -815,6 +831,19 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { return groupedList; } + /** + * 检查用户是否具有特殊角色 + * @param userRoles + * @return + */ + private boolean hasSpecialRole(Set userRoles) { + if (userRoles == null) { + return false; + } + List allowedRoles = Collections.singletonList("clzcx"); + return allowedRoles.stream().anyMatch(userRoles::contains); + } + /** * 工器具台账关键字查询 * @param item diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java index b8867f54..931bdba6 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java @@ -322,4 +322,11 @@ public interface SelectMapper { * @return */ List getAllProjectList(String departId); + + /** + * 获取在建工程信息 + * @param departId + * @return + */ + List getInProject(String departId); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java index 547ec91f..17d1d6f3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java @@ -203,6 +203,9 @@ public class LeaseApplyDetails extends BaseEntity { @ApiModelProperty(value = "待出库数量") private BigDecimal pendingOutNum; + @ApiModelProperty(value = "任务唯一标识单号") + private String keyId; + @ApiModelProperty(value = "领料物资名称汇总") private String maTypeNames; public LeaseApplyDetails(Long id, Long parentId, Long typeId, BigDecimal preNum, BigDecimal auditNum, BigDecimal alNum, String status, Long companyId) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java index d45a1a2f..6894e264 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java @@ -197,7 +197,7 @@ public interface LeaseApplyDetailsMapper { * @param leaseOutDetails * @return */ - LeaseApplyDetails getPendingCodeLeaseApplyDetails(LeaseOutDetails leaseOutDetails); + List getPendingCodeLeaseApplyDetails(LeaseOutDetails leaseOutDetails); /** * 查询待出库详情 @@ -219,4 +219,20 @@ public interface LeaseApplyDetailsMapper { * @return */ int updateLeaseApplyPublishDetails(LeaseApplyDetails bean); + + /** + * 获取领用任务详细 + * @param leaseOutDetails + * @return + */ + List getLeaseMaCode(LeaseOutDetails leaseOutDetails); + + /** + * 获取待出库数量 + * @param leaseOutDetails + * @return + */ + LeaseApplyDetails getPengNum(LeaseOutDetails leaseOutDetails); + + LeaseApplyDetails getPendLease(LeaseOutDetails leaseOutDetails); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index 5abe65ec..4c3b2a7f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -1400,23 +1400,45 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { @Override public AjaxResult leaseOut(LeaseOutRequestVo leaseOutRequestVo) { // 判断库存是否充足 - /*if (!CollectionUtils.isEmpty(leaseOutRequestVo.getLeaseOutDetailsList())) { + if (!CollectionUtils.isEmpty(leaseOutRequestVo.getLeaseOutDetailsList())) { LeaseOutDetails leaseOutDetails = leaseOutRequestVo.getLeaseOutDetailsList().get(0); if (leaseOutDetails != null) { + // 根据前端传入的keyId进行判断 + BigDecimal pendingNum = BigDecimal.ZERO; + if (leaseOutDetails.getKeyId() != null) { + List list = leaseApplyDetailsMapper.getPendingCodeLeaseApplyDetails(leaseOutDetails); + if (!CollectionUtils.isEmpty(list)) { + return AjaxResult.error("该设备已出库,请勿重复操作"); + } + } if (leaseOutDetails.getManageType().equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId())) { + // 查询待出库数量 + LeaseApplyDetails info = new LeaseApplyDetails(); + if (StringUtils.isNotBlank(leaseOutDetails.getPublishTask())) { + info = leaseApplyDetailsMapper.getPengNum(leaseOutDetails); + } else { + info = leaseApplyDetailsMapper.getPendLease(leaseOutDetails); + } LeaseApplyDetails details = leaseApplyDetailsMapper.getPendingLeaseApplyDetails(leaseOutDetails); - if (leaseOutDetails.getInputNum().compareTo(details.getOutNum()) > 0) { - return AjaxResult.error("出库数量大于领料数量,请重新输入选择"); + if (details == null) { + pendingNum = info.getOutNum().subtract(BigDecimal.ZERO); + } else { + pendingNum = info.getOutNum().subtract(details.getOutNum()); + } + if (leaseOutDetails.getInputNum().compareTo(pendingNum) > 0) { + return AjaxResult.error("该设备已出库,请勿重复操作"); } } if (leaseOutDetails.getManageType().equals(MaTypeManageTypeEnum.CODE_DEVICE.getTypeId())) { - LeaseApplyDetails details = leaseApplyDetailsMapper.getPendingCodeLeaseApplyDetails(leaseOutDetails); - if (BigDecimal.valueOf(leaseOutRequestVo.getLeaseOutDetailsList().size()).compareTo(details.getOutNum()) > 0) { - return AjaxResult.error("出库数量大于领料数量,请重新输入选择"); + if (leaseOutDetails.getParentId() != null) { + List detailsList = leaseApplyDetailsMapper.getLeaseMaCode(leaseOutDetails); + if (!CollectionUtils.isEmpty(detailsList)) { + return AjaxResult.error("该设备已出库,请勿重复操作"); + } } } } - }*/ + } for (LeaseOutDetails bean : leaseOutRequestVo.getLeaseOutDetailsList()) { if (Objects.isNull(bean)) { continue; diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml index 19bf0cf6..53a55bba 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml @@ -1020,4 +1020,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND project_dept_id = #{departId} + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml index f9970eb9..6f74b187 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml @@ -682,28 +682,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml index 702ce3ef..6ccc4fd0 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml @@ -110,6 +110,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" publish_task, + + key_id, + create_time, update_time @@ -147,6 +150,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{publishTask}, + + #{keyId}, + NOW(), NOW()