From a76e1d17d67641993dea6335cb8e1465a94df58d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 21 五月 2026 15:39:05 +0800
Subject: [PATCH] feat(stock): 优化库存管理和成品树结构功能 1- 为ApproveProcessMapper.xml和ProductBomMapper.xml添加排序功能 2- 在ProductionProductMainDto中新增bomInputQty字段用于产品结构投入数量 3- 修改ProductionProductMainServiceImpl中投入数量计算逻辑,使用前端传入的bomInputQty值 4- 在ProductWorkOrderDto中添加bomInputQty字段并在服务实现中计算标准投入数量 5- 更新SalesLedgerMapper.xml查询逻辑,从product_summary获取电压信息 6- 为SalesLedgerProduct添加stockId字段并修改库存扣减逻辑使用具体库存ID 7- 重构StockInventoryController中的成品库存树查询接口和导入导出功能 8- 新增成品和非成品库存导入导出的数据模型和Excel工具类 9- 优化StockInventoryServiceImpl中的库存扣减逻辑,支持按特定库存ID操作 10- 更新库存导入导出功能,区分成品和非成品类型并提供相应模板
---
src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java | 40 +++++++++++++++++++++++++++++++++-------
1 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java b/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java
index 81f4192..1fe2055 100644
--- a/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java
+++ b/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java
@@ -9,13 +9,15 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.constant.UserConstants;
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
import com.ruoyi.project.system.domain.SysRole;
import com.ruoyi.project.system.domain.SysRoleDept;
import com.ruoyi.project.system.domain.SysRoleMenu;
+import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.domain.SysUserRole;
import com.ruoyi.project.system.mapper.SysRoleDeptMapper;
import com.ruoyi.project.system.mapper.SysRoleMapper;
@@ -120,7 +122,7 @@
* @return 閫変腑瑙掕壊ID鍒楄〃
*/
@Override
- public List<Integer> selectRoleListByUserId(Long userId)
+ public List<Long> selectRoleListByUserId(Long userId)
{
return roleMapper.selectRoleListByUserId(userId);
}
@@ -144,7 +146,7 @@
* @return 缁撴灉
*/
@Override
- public String checkRoleNameUnique(SysRole role)
+ public boolean checkRoleNameUnique(SysRole role)
{
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
@@ -162,7 +164,7 @@
* @return 缁撴灉
*/
@Override
- public String checkRoleKeyUnique(SysRole role)
+ public boolean checkRoleKeyUnique(SysRole role)
{
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
@@ -183,7 +185,30 @@
{
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin())
{
- throw new CustomException("涓嶅厑璁告搷浣滆秴绾х鐞嗗憳瑙掕壊");
+ throw new ServiceException("涓嶅厑璁告搷浣滆秴绾х鐞嗗憳瑙掕壊");
+ }
+ }
+
+ /**
+ * 鏍¢獙瑙掕壊鏄惁鏈夋暟鎹潈闄�
+ *
+ * @param roleIds 瑙掕壊id
+ */
+ @Override
+ public void checkRoleDataScope(Long... roleIds)
+ {
+ if (!SysUser.isAdmin(SecurityUtils.getUserId()))
+ {
+ for (Long roleId : roleIds)
+ {
+ SysRole role = new SysRole();
+ role.setRoleId(roleId);
+ List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
+ if (StringUtils.isEmpty(roles))
+ {
+ throw new ServiceException("娌℃湁鏉冮檺璁块棶瑙掕壊鏁版嵁锛�");
+ }
+ }
}
}
@@ -339,10 +364,11 @@
for (Long roleId : roleIds)
{
checkRoleAllowed(new SysRole(roleId));
+ checkRoleDataScope(roleId);
SysRole role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0)
{
- throw new CustomException(String.format("%1$s宸插垎閰�,涓嶈兘鍒犻櫎", role.getRoleName()));
+ throw new ServiceException(String.format("%1$s宸插垎閰�,涓嶈兘鍒犻櫎", role.getRoleName()));
}
}
// 鍒犻櫎瑙掕壊涓庤彍鍗曞叧鑱�
@@ -381,7 +407,7 @@
* 鎵归噺閫夋嫨鎺堟潈鐢ㄦ埛瑙掕壊
*
* @param roleId 瑙掕壊ID
- * @param userIds 闇�瑕佸垹闄ょ殑鐢ㄦ埛鏁版嵁ID
+ * @param userIds 闇�瑕佹巿鏉冪殑鐢ㄦ埛鏁版嵁ID
* @return 缁撴灉
*/
@Override
--
Gitblit v1.9.3