Browse Source

仓库查询权限2023/07/07

wangzhuo 1 năm trước cách đây
mục cha
commit
f484fd6ee6

+ 15 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/basicData/TWarehouseController.java

@@ -243,5 +243,20 @@ public class TWarehouseController extends BaseController {
         return AjaxResult.success(tWarehouseService.buildDeptTreeSelect(tWarehouses));
     }
 
+    /**
+     * 根据用户绑定的仓库查询仓库下拉
+     */
+    @GetMapping("/nominate-treeselect")
+    public AjaxResult nominateTreeselect(TWarehouse tWarehouse) {
+        List<TWarehouse> tWarehouses = tWarehouseService.nominateTreeselect(tWarehouse);
+
+        // 当前登录用户没有配置仓库
+        if (tWarehouses == null) {
+            return AjaxResult.success(null);
+        }
+
+        return AjaxResult.success(tWarehouseService.buildDeptTreeSelect(tWarehouses));
+    }
+
 
 }

+ 6 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TWarehouseUserMapper.java

@@ -91,4 +91,10 @@ public interface TWarehouseUserMapper {
      */
     public List<Map<String, Object>> biWarehouseList(Long userId);
 
+    /**
+     * 获取当前登录用户的仓库idList
+     * @param userId
+     * @return
+     */
+    List<Long> getWarehouseIdListByUserId(Long userId);
 }

+ 3 - 0
ruoyi-system/src/main/resources/mapper/system/TWarehouseUserMapper.xml

@@ -87,5 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where user_id = #{userId}
         order by convert(warehouse_name using gbk)
     </select>
+    <select id="getWarehouseIdListByUserId" resultType="java.lang.Long">
+        select warehouse_id from t_warehouse_user where user_id = #{userId}
+    </select>
 
 </mapper>

+ 12 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/mapper/TWarehouseMapper.java

@@ -302,5 +302,17 @@ public interface TWarehouseMapper {
     public int receiptCancel(@Param("ownerName") String ownerName,@Param("identifier") String identifier,@Param("numbers") String numbers);
 
     TWarehouse selectByPidANDName(@Param("stringCellValue")String stringCellValue, @Param("fWarehouseid")Long fWarehouseid);
+
+    /**
+     * 根据用户绑定的仓库查询仓库下拉
+     */
+    List<TWarehouse> nominateTreeselect(@Param("tWarehouse") TWarehouse tWarehouse, @Param("warehouseIdList") List<Long> warehouseIdList);
+
+    /**
+     * 根据仓库idList查询仓库数据
+     * @param warehouseIdList
+     * @return
+     */
+    List<TWarehouse> getByFIdList(@Param("warehouseIdList") List<String> warehouseIdList);
 }
 

+ 5 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/ITWarehouseService.java

@@ -311,4 +311,9 @@ public interface ITWarehouseService {
      * 仓单解锁指令
      */
     public int receiptCancel(String ownerName, String identifier, String numbers);
+
+    /**
+     * 根据用户绑定的仓库查询仓库下拉
+     */
+    List<TWarehouse> nominateTreeselect(TWarehouse tWarehouse);
 }

+ 26 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/impl/TWarehouseServiceImpl.java

@@ -22,6 +22,7 @@ import com.ruoyi.common.exception.CustomException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.mapper.TWarehouseUserMapper;
 import com.ruoyi.system.service.ISysDictDataService;
 import com.ruoyi.warehouseBusiness.domain.TAnnex;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
@@ -76,6 +77,9 @@ public class TWarehouseServiceImpl implements ITWarehouseService {
     @Autowired
     private ISysDictDataService sysDictDataService;
 
+    @Autowired
+    private TWarehouseUserMapper tWarehouseUserMapper;
+
 
     /**
      * 查询仓库
@@ -731,6 +735,28 @@ public class TWarehouseServiceImpl implements ITWarehouseService {
     }
 
     @Override
+    public List<TWarehouse> nominateTreeselect(TWarehouse tWarehouse) {
+
+        // 获取当前登录用户
+        Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
+        // 获取当前登录用户的仓库idList
+        List<Long> warehouseIdList = tWarehouseUserMapper.getWarehouseIdListByUserId(userId);
+
+        if (warehouseIdList.size() == 0) {
+            return null;
+        }
+
+        for (Long warehouseId : warehouseIdList) {
+            if (warehouseId == 0) {
+                warehouseIdList = null;
+                break;
+            }
+        }
+
+        return tWarehouseMapper.nominateTreeselect(tWarehouse, warehouseIdList);
+    }
+
+    @Override
     public String checkUFNoUnique(TWarehouse tWarehouse) {
         TWarehouse tWarehouse1 = tWarehouseMapper.checkFNoUnique(tWarehouse.getfNo());
         if (StringUtils.isNotNull(tWarehouse1) && tWarehouse1.getfId() != tWarehouse.getfId()) {

+ 46 - 0
ruoyi-warehouse/src/main/resources/mapper/basicData/TWarehouseMapper.xml

@@ -940,4 +940,50 @@
         ORDER BY IFNULL( ROUND( SUM(TW.f_grossweightblc) / 1000, 2 ), 0 ) DESC
         LIMIT #{topCnt}
     </select>
+    <select id="nominateTreeselect" resultMap="TWarehouseResult">
+        <include refid="selectTWarehouseVo"/>
+        <where>
+            parent_id = 100 and
+            <if test="warehouseIdList != null and warehouseIdList != ''">
+                 f_id in
+                <foreach item="number" collection="warehouseIdList" open="(" separator="," close=")">
+                    #{number}
+                </foreach>
+                or
+                <foreach collection="warehouseIdList" item="item" index="index"  separator="OR">
+                    ancestors LIKE CONCAT('%',#{item},'%')
+                </foreach>
+            </if>
+            <if test="tWarehouse.parentId != null  and tWarehouse.parentId != ''">and parent_id = #{tWarehouse.parentId}</if>
+            <if test="tWarehouse.fIsBonded != null  and tWarehouse.fIsBonded != ''">and f_is_bonded = #{tWarehouse.fIsBonded}</if>
+            <if test="tWarehouse.ancestors != null  and tWarehouse.ancestors != ''">and ancestors like concat('%', #{tWarehouse.ancestors}, '%')</if>
+            <if test="tWarehouse.fNo != null  and tWarehouse.fNo != ''">and f_no like concat('%', #{tWarehouse.fNo}, '%')</if>
+            <if test="tWarehouse.fName != null  and tWarehouse.fName != ''">and f_name like concat('%', #{tWarehouse.fName}, '%')</if>
+            <if test="tWarehouse.fCname != null  and tWarehouse.fCname != ''">and f_cname like concat('%', #{tWarehouse.fCname}, '%')</if>
+            <if test="tWarehouse.fAddr != null  and tWarehouse.fAddr != ''">and f_addr like concat('%', #{tWarehouse.fAddr}, '%')</if>
+            <if test="tWarehouse.fTotalgross != null ">and f_totalgross like concat('%', #{tWarehouse.fTotalgross}, '%')</if>
+            <if test="tWarehouse.fContacts != null  and tWarehouse.fContacts != ''">and f_contacts = #{tWarehouse.fContacts}</if>
+            <if test="tWarehouse.fTel != null  and tWarehouse.fTel != ''">and f_tel = #{tWarehouse.fTel}</if>
+            <if test="tWarehouse.fCharg != null ">and f_charg = #{tWarehouse.fCharg}</if>
+            <if test="tWarehouse.fStatus != null  and tWarehouse.fStatus != ''">and f_status = #{tWarehouse.fStatus}</if>
+            <if test="tWarehouse.supervise != null and tWarehouse.supervise != ''">and supervise = #{tWarehouse.supervise}</if>
+            <if test="tWarehouse.fProperties != null and tWarehouse.fProperties != ''">and f_properties like concat('%', #{tWarehouse.fProperties}, '%')</if>
+            <if test="tWarehouse.fType != null and tWarehouse.fType != ''">and f_type like concat('%', #{tWarehouse.fType}, '%')</if>
+            <if test="tWarehouse.fGoodsType != null and tWarehouse.fGoodsType != ''">and f_goods_type like concat('%', #{tWarehouse.fGoodsType}, '%')</if>
+            <if test="tWarehouse.fCoverArea != null and tWarehouse.fCoverArea != ''">and f_cover_area like concat('%', #{tWarehouse.fCoverArea}, '%')</if>
+        </where>
+        <!-- 数据范围过滤 -->
+        order by parent_id, order_num, convert(f_name using gbk)
+    </select>
+    <select id="getByFIdList" resultMap="TWarehouseResult">
+        <include refid="selectTWarehouseVo"/>
+        <where>
+            parent_id = 100 and f_id in
+            <foreach collection="warehouseIdList" item="fid" index="index" open="(" close=")"
+                     separator=",">
+                #{fid}
+            </foreach>
+
+        </where>
+    </select>
 </mapper>