Przeglądaj źródła

处理线边库模块数据权限过滤功能

oyq28 3 lat temu
rodzic
commit
68a56c51f3

+ 8 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/dao/ShelvesMapper.java

@@ -1,9 +1,13 @@
 package com.github.zuihou.business.edgeLibrary.dao;
 package com.github.zuihou.business.edgeLibrary.dao;
 
 
-import com.baomidou.mybatisplus.annotation.SqlParser;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.business.edgeLibrary.entity.Shelves;
 import com.github.zuihou.business.edgeLibrary.entity.Shelves;
-import com.github.zuihou.business.edgeLibrary.entity.StorgeType;
+import com.github.zuihou.database.mybatis.auth.DataScope;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 
 
 import java.util.List;
 import java.util.List;
@@ -22,4 +26,6 @@ import java.util.Map;
 public interface ShelvesMapper extends SuperMapper<Shelves> {
 public interface ShelvesMapper extends SuperMapper<Shelves> {
 
 
     List<Shelves> superiorShelvesList();
     List<Shelves> superiorShelvesList();
+
+    IPage<Shelves> shelvesTreeList(Page<Shelves> page, @Param(Constants.WRAPPER) Wrapper<Shelves> queryWrapper, DataScope dataScope);
 }
 }

+ 2 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/dao/StockLogMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.business.edgeLibrary.entity.StockLog;
 import com.github.zuihou.business.edgeLibrary.entity.StockLog;
 
 
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 
 
@@ -26,7 +27,7 @@ public interface StockLogMapper extends SuperMapper<StockLog> {
     /**
     /**
      * 分页
      * 分页
      */
      */
-    IPage<StockLog> pageList(IPage page, @Param("name")String name,@Param(Constants.WRAPPER) Wrapper<StockLog> queryWrapper);
+    IPage<StockLog> pageList(IPage page, @Param("name")String name, @Param(Constants.WRAPPER) Wrapper<StockLog> queryWrapper, DataScope dataScope);
 
 
     /**
     /**
      * 根据产品id查询当前已使用最大编号
      * 根据产品id查询当前已使用最大编号

+ 2 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/dao/StorgeMapper.java

@@ -8,6 +8,7 @@ import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 import com.github.zuihou.business.edgeLibrary.entity.Storge;
 import com.github.zuihou.business.edgeLibrary.entity.Storge;
 import com.github.zuihou.business.edgeLibrary.entity.StorgeType;
 import com.github.zuihou.business.edgeLibrary.entity.StorgeType;
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 
 
@@ -32,7 +33,7 @@ public interface StorgeMapper extends SuperMapper<Storge> {
     /**
     /**
      * 分页
      * 分页
      */
      */
-    IPage<Storge> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<Storge> queryWrapper);
+    IPage<Storge> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<Storge> queryWrapper, DataScope dataScope);
 
 
     /**
     /**
      *
      *

+ 16 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/ShelvesServiceImpl.java

@@ -1,6 +1,10 @@
 package com.github.zuihou.business.edgeLibrary.service.impl;
 package com.github.zuihou.business.edgeLibrary.service.impl;
 
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.zuihou.authority.service.auth.UserService;
 import com.github.zuihou.base.service.SuperCacheServiceImpl;
 import com.github.zuihou.base.service.SuperCacheServiceImpl;
 import com.github.zuihou.business.edgeLibrary.dao.ShelvesMapper;
 import com.github.zuihou.business.edgeLibrary.dao.ShelvesMapper;
 import com.github.zuihou.business.edgeLibrary.dao.StorgeTypeMapper;
 import com.github.zuihou.business.edgeLibrary.dao.StorgeTypeMapper;
@@ -13,12 +17,16 @@ import com.github.zuihou.business.edgeLibrary.entity.StorgeType;
 import com.github.zuihou.business.edgeLibrary.service.ShelvesService;
 import com.github.zuihou.business.edgeLibrary.service.ShelvesService;
 import com.github.zuihou.business.edgeLibrary.service.StorgeTypeService;
 import com.github.zuihou.business.edgeLibrary.service.StorgeTypeService;
 import com.github.zuihou.business.modelingCenter.entity.MModuleField;
 import com.github.zuihou.business.modelingCenter.entity.MModuleField;
+import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.utils.BeanPlusUtil;
 import com.github.zuihou.utils.BeanPlusUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
@@ -44,6 +52,9 @@ import static com.github.zuihou.utils.BizAssert.isFalse;
 
 
 public class ShelvesServiceImpl extends SuperCacheServiceImpl<ShelvesMapper, Shelves> implements ShelvesService {
 public class ShelvesServiceImpl extends SuperCacheServiceImpl<ShelvesMapper, Shelves> implements ShelvesService {
 
 
+    @Autowired
+    private UserService userService;
+
     @Override
     @Override
     protected String getRegion() {
     protected String getRegion() {
         return TENANT;
         return TENANT;
@@ -115,8 +126,12 @@ public class ShelvesServiceImpl extends SuperCacheServiceImpl<ShelvesMapper, She
     public List<Shelves> shelvesTreeList(){
     public List<Shelves> shelvesTreeList(){
         //[{id=xx,name=xx,children=[{id=xx,name=xx}]}]
         //[{id=xx,name=xx,children=[{id=xx,name=xx}]}]
         List<Shelves> returnList = new ArrayList<Shelves>();
         List<Shelves> returnList = new ArrayList<Shelves>();
-        List<Shelves> list = baseMapper.selectList(Wraps.<Shelves>lbQ().eq(Shelves::getStatus,1).orderByAsc(Shelves::getWeight));
+        LbqWrapper<Shelves> queryWrapper  = Wraps.<Shelves>lbQ();
+        queryWrapper.eq(Shelves::getStatus,1).orderByAsc(Shelves::getWeight);
 
 
+        IPage<Shelves> shelves = baseMapper.shelvesTreeList(new Page<Shelves>(1L,50), queryWrapper, new DataScope());
+        //Map shelvesIPage = baseMapper.shelvesTreeList(, new DataScope());
+        List<Shelves> list = (shelves!=null)? (List<Shelves>)shelves.getRecords() : Lists.newArrayList();
         for(Shelves map:list){
         for(Shelves map:list){
             //一级
             //一级
             if(0 == (map.getParentId()==null?0:map.getParentId().longValue())) {
             if(0 == (map.getParentId()==null?0:map.getParentId().longValue())) {

+ 2 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/StockLogServiceImpl.java

@@ -10,6 +10,7 @@ import com.github.zuihou.business.edgeLibrary.service.StockLogService;
 import com.github.zuihou.base.service.SuperServiceImpl;
 import com.github.zuihou.base.service.SuperServiceImpl;
 
 
 import com.github.zuihou.common.constant.CodeRuleModule;
 import com.github.zuihou.common.constant.CodeRuleModule;
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.tenant.service.CodeRuleService;
 import com.github.zuihou.tenant.service.CodeRuleService;
@@ -42,7 +43,7 @@ public class StockLogServiceImpl extends SuperServiceImpl<StockLogMapper, StockL
     // 启用属性自动注入
     // 启用属性自动注入
     @InjectionResult
     @InjectionResult
     public IPage<StockLog> pageList(IPage page,String name, LbqWrapper<StockLog> wrapper) {
     public IPage<StockLog> pageList(IPage page,String name, LbqWrapper<StockLog> wrapper) {
-        IPage<StockLog> list = baseMapper.pageList(page,name ,wrapper);
+        IPage<StockLog> list = baseMapper.pageList(page,name ,wrapper, new DataScope());
 
 
         return list;
         return list;
     }
     }

+ 2 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/StorgeServiceImpl.java

@@ -28,6 +28,7 @@ import com.github.zuihou.business.productionResourceCenter.entity.Productionreso
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.common.util.StringUtil;
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.injection.annonation.InjectionResult;
@@ -94,7 +95,7 @@ public class StorgeServiceImpl extends SuperCacheServiceImpl<StorgeMapper, Storg
     // 启用属性自动注入
     // 启用属性自动注入
     @InjectionResult
     @InjectionResult
     public IPage<Storge> pageList(IPage page, LbqWrapper<Storge> wrapper) {
     public IPage<Storge> pageList(IPage page, LbqWrapper<Storge> wrapper) {
-        return baseMapper.pageList(page, wrapper);
+        return baseMapper.pageList(page, wrapper, new DataScope());
     }
     }
 
 
     @Override
     @Override

+ 11 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/ShelvesMapper.xml

@@ -28,4 +28,15 @@
 
 
     </select>
     </select>
 
 
+    <select id="shelvesTreeList" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>, org_id
+        from (
+        select a.*,z.org_id from imcs_s_shelves a
+        left join imcs_tenant_productionresource p on p.code = a.no
+        left join imcs_z_zone_productionresource r on r.resource_id = p.id
+        left join imcs_z_zone z on z.id = r.zone_id group by a.no
+        ) s ${ew.customSqlSegment}
+    </select>
+
 </mapper>
 </mapper>

+ 10 - 5
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/StockInfoMapper.xml

@@ -35,7 +35,14 @@
         from (
         from (
             select a.*,b.categoryDesc,b.name as brandName,b.no as brandNo,b.specification,0 as lockNum,0 as availableNum, u.org_id from imcs_s_stock_info a
             select a.*,b.categoryDesc,b.name as brandName,b.no as brandNo,b.specification,0 as lockNum,0 as availableNum, u.org_id from imcs_s_stock_info a
             left join view_stock_goods b on a.spec_id = b.specId
             left join view_stock_goods b on a.spec_id = b.specId
-            left join c_auth_user u on u.id = a.create_user
+            left join (
+                select st.id,CONCAT_WS('-',sh.shelvesDesc,st.name) as shelvesDesc, sh.no from imcs_s_storge st
+                left join (
+                    SELECT a.id,CONCAT_WS('-',a.name,b.name) as shelvesDesc, a.no from imcs_s_shelves a
+                    left join imcs_s_shelves b on a.parent_id = b.id
+                    ) sh on st.shelves_id = sh.id
+                ) st on a.storge_id = st.id
+            left join imcs_z_zone z on locate(z.abbreviate, st.shelvesDesc)
         ) s ${ew.customSqlSegment}
         ) s ${ew.customSqlSegment}
     </select>
     </select>
 
 
@@ -90,10 +97,8 @@
         FROM
         FROM
             imcs_s_storge s
             imcs_s_storge s
         LEFT JOIN imcs_s_stock_info i ON s.id = i.storge_id
         LEFT JOIN imcs_s_stock_info i ON s.id = i.storge_id
-
-LEFT JOIN imcs_s_shelves s1 ON s.shelves_id = s1.id
-GROUP BY
-	s1.parent_id
+        LEFT JOIN imcs_s_shelves s1 ON s.shelves_id = s1.id
+        GROUP BY s1.parent_id
     </select>
     </select>
 
 
     <!-- 获取库位的库存数量,判断是否为空库存 -->
     <!-- 获取库位的库存数量,判断是否为空库存 -->

+ 5 - 4
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/StockLogMapper.xml

@@ -30,7 +30,7 @@
     <sql id="Base_Column_List">
     <sql id="Base_Column_List">
         id,create_time,create_user,update_time,update_user,
         id,create_time,create_user,update_time,update_user,
         no, unique_code, storge_id, num, goods_id, goods_type, turn_task_no, opt_type, feed_task_no,spec_id,shelvesDesc,brandNo,name ,specification,
         no, unique_code, storge_id, num, goods_id, goods_type, turn_task_no, opt_type, feed_task_no,spec_id,shelvesDesc,brandNo,name ,specification,
-        reason,rel_order_no,rel_order_id,task_no
+        reason,rel_order_no,rel_order_id,task_no,org_id
     </sql>
     </sql>
 
 
     <!-- 分页 -->
     <!-- 分页 -->
@@ -38,15 +38,16 @@
         select
         select
         <include refid="Base_Column_List"/>
         <include refid="Base_Column_List"/>
         from (
         from (
-            select a.*,st.shelvesDesc,b.no as brandNo,b.name ,b.specification from imcs_s_stock_log a
+            select a.*,st.shelvesDesc,b.no as brandNo,b.name ,b.specification, z.org_id from imcs_s_stock_log a
             left join view_stock_goods b on a.spec_id = b.specId
             left join view_stock_goods b on a.spec_id = b.specId
             left join (
             left join (
-                select st.id,CONCAT_WS('-',sh.shelvesDesc,st.name) as shelvesDesc from imcs_s_storge st
+                select st.id,CONCAT_WS('-',sh.shelvesDesc,st.name) as shelvesDesc, sh.no from imcs_s_storge st
                 left join (
                 left join (
-                    SELECT a.id,CONCAT_WS('-',a.name,b.name) as shelvesDesc from imcs_s_shelves a
+                    SELECT a.id,CONCAT_WS('-',a.name,b.name) as shelvesDesc, a.no from imcs_s_shelves a
                     left join imcs_s_shelves b on a.parent_id = b.id
                     left join imcs_s_shelves b on a.parent_id = b.id
                 ) sh on st.shelves_id = sh.id
                 ) sh on st.shelves_id = sh.id
             ) st on a.storge_id = st.id
             ) st on a.storge_id = st.id
+            left join imcs_z_zone z on locate(z.abbreviate, st.shelvesDesc)
         where 1=1
         where 1=1
         <if test="name != null and name != ''">
         <if test="name != null and name != ''">
             and b.name like concat('%', #{name}, '%')
             and b.name like concat('%', #{name}, '%')

+ 3 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/edgeLibrary/entity/Shelves.java

@@ -107,6 +107,9 @@ public class Shelves extends Entity<Long> {
     @TableField(exist = false)
     @TableField(exist = false)
     private List<Shelves> children;
     private List<Shelves> children;
 
 
+    @TableField(exist = false)
+    private Long orgId;
+
     @Builder
     @Builder
     public Shelves(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, 
     public Shelves(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, 
                     String name, String no, String status, Long parentId, String type,Integer weight) {
                     String name, String no, String status, Long parentId, String type,Integer weight) {