修改仓库数据范围报错

This commit is contained in:
liuhanqing
2025-06-16 13:56:41 +08:00
parent fc7364cc99
commit 36c95928ba
14 changed files with 230 additions and 42 deletions

View File

@@ -6,9 +6,11 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 仓库管理对象 bas_warehouse
*
*
* @author lsy
* @date 2025-05-20
*/
@@ -55,6 +57,10 @@ public class BasWarehouse extends BaseEntity
@Excel(name = "是否可用", readConverterExp = "不=允许为空")
private String isCurrent;
/*仓库数据权限*/
private List<String> dataScope;
// @Override
// public String toString() {

View File

@@ -1,17 +1,26 @@
package com.ruoyi.bas.warehouse.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.bas.warehouse.domain.BasWarehouse;
import com.ruoyi.bas.warehouse.mapper.BasWarehouseMapper;
import com.ruoyi.bas.warehouse.service.IBasWarehouseService;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 仓库管理Service业务层处理
*
*
* @author lsy
* @date 2025-05-20
*/
@@ -20,10 +29,12 @@ public class BasWarehouseServiceImpl implements IBasWarehouseService
{
@Autowired
private BasWarehouseMapper basWarehouseMapper;
@Autowired
private ISysRoleService sysRoleService;
/**
* 查询仓库管理
*
*
* @param warehouseId 仓库管理主键
* @return 仓库管理
*/
@@ -35,19 +46,31 @@ public class BasWarehouseServiceImpl implements IBasWarehouseService
/**
* 查询仓库管理列表
*
*
* @param basWarehouse 仓库管理
* @return 仓库管理
*/
@Override
public List<BasWarehouse> selectBasWarehouseList(BasWarehouse basWarehouse)
{
return basWarehouseMapper.selectBasWarehouseList(basWarehouse);
List<SysRole> roles = sysRoleService.selectRolesByUserId(SecurityUtils.getUserId());
if (roles.stream().anyMatch(SysRole::isAdmin)){
return basWarehouseMapper.selectBasWarehouseList(basWarehouse);
}else {
List<String> dateScope =new ArrayList<>();
for (SysRole role : roles) {
if (CollUtil.isNotEmpty(role.getWarehouseDataScope())){
dateScope.addAll(role.getWarehouseDataScope());
}
}
basWarehouse.setDataScope(dateScope);
return basWarehouseMapper.selectBasWarehouseList(basWarehouse);
}
}
/**
* 新增仓库管理
*
*
* @param basWarehouse 仓库管理
* @return 结果
*/
@@ -59,7 +82,7 @@ public class BasWarehouseServiceImpl implements IBasWarehouseService
/**
* 修改仓库管理
*
*
* @param basWarehouse 仓库管理
* @return 结果
*/
@@ -71,7 +94,7 @@ public class BasWarehouseServiceImpl implements IBasWarehouseService
/**
* 批量删除仓库管理
*
*
* @param warehouseIds 需要删除的仓库管理主键
* @return 结果
*/
@@ -83,7 +106,7 @@ public class BasWarehouseServiceImpl implements IBasWarehouseService
/**
* 删除仓库管理信息
*
*
* @param warehouseId 仓库管理主键
* @return 结果
*/

View File

@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.bas.warehouse.mapper.BasWarehouseMapper">
<resultMap type="BasWarehouse" id="BasWarehouseResult">
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseNo" column="warehouse_no" />
@@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBasWarehouseList" parameterType="BasWarehouse" resultMap="BasWarehouseResult">
<include refid="selectBasWarehouseVo"/>
<where>
<where>
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
<if test="warehouseNo != null and warehouseNo != ''"> and warehouse_no = #{warehouseNo}</if>
<if test="projectNo != null and projectNo != ''"> and project_no = #{projectNo}</if>
@@ -32,9 +32,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warehouseKind != null and warehouseKind != ''"> and warehouse_kind = #{warehouseKind}</if>
<if test="warehouseType != null and warehouseType != ''"> and warehouse_type = #{warehouseType}</if>
<if test="isCurrent != null and isCurrent != ''"> and is_current = #{isCurrent}</if>
<if test="dataScope !=null and dataScope.size()>0">
and warehouse_id in
<foreach item="item" index="index" collection="dataScope" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectBasWarehouseByWarehouseId" parameterType="String" resultMap="BasWarehouseResult">
<include refid="selectBasWarehouseVo"/>
where warehouse_id = #{warehouseId}
@@ -86,7 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteBasWarehouseByWarehouseIds" parameterType="String">
delete from bas_warehouse where warehouse_id in
delete from bas_warehouse where warehouse_id in
<foreach item="warehouseId" collection="array" open="(" separator="," close=")">
#{warehouseId}
</foreach>
@@ -96,4 +102,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectBasWarehouseVo"/>
where warehouse_type in (1,3)
</select>
</mapper>
</mapper>