Ver código fonte

实现模块的数据权限过滤功能

oyq28 3 anos atrás
pai
commit
1b50df7829
15 arquivos alterados com 100 adições e 28 exclusões
  1. 2 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/dao/StockInfoMapper.java
  2. 1 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/StockInfoService.java
  3. 2 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/StockInfoServiceImpl.java
  4. 3 2
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/dao/RepairMapper.java
  5. 3 2
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RepairServiceImpl.java
  6. 21 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/ToolServiceImpl.java
  7. 3 2
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/StockInfoMapper.xml
  8. 6 4
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionResourceCenter/RepairMapper.xml
  9. 2 2
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/productionResourceCenter/entity/Tool.java
  10. 3 2
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/dao/ProductionresourceMapper.java
  11. 2 1
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/dao/ProductionresourceviewMapper.java
  12. 2 2
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/ProductionresourceService.java
  13. 36 4
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/impl/ProductionresourceServiceImpl.java
  14. 3 3
      imcs-admin-boot/imcs-tenant-biz/src/main/resources/mapper_tenant/base/defaults/ProductionresourceMapper.xml
  15. 11 2
      imcs-admin-boot/imcs-tenant-biz/src/main/resources/mapper_tenant/base/defaults/ProductionresourceviewMapper.xml

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

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
@@ -26,7 +27,7 @@ public interface StockInfoMapper extends SuperMapper<StockInfo> {
     /**
      * 分页
      */
-    IPage<StockInfo> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<StockInfo> queryWrapper);
+    IPage<StockInfo> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<StockInfo> queryWrapper, DataScope dataScope);
     /**
      * 根据货架(层)查询库存数量
      * @return

+ 1 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/StockInfoService.java

@@ -10,6 +10,7 @@ import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureMeter
 import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureTray;
 import com.github.zuihou.business.productionReadyCenter.entity.MToolClamp;
 import com.github.zuihou.business.productionReadyCenter.entity.Tray;
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 
 import java.math.BigDecimal;

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

@@ -26,6 +26,7 @@ import com.github.zuihou.business.productionResourceCenter.entity.Productionreso
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.constant.CodeRuleModule;
 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.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionResult;
@@ -82,7 +83,7 @@ public class StockInfoServiceImpl extends SuperServiceImpl<StockInfoMapper, Stoc
     // 启用属性自动注入
     @InjectionResult
     public IPage<StockInfo> pageList(IPage page, LbqWrapper<StockInfo> wrapper) {
-        IPage<StockInfo> list = baseMapper.pageList(page, wrapper);
+        IPage<StockInfo> list = baseMapper.pageList(page, wrapper, new DataScope());
 
         return list;
     }

+ 3 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/dao/RepairMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.business.productionResourceCenter.entity.Repair;
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
@@ -20,7 +21,7 @@ public interface RepairMapper extends SuperMapper<Repair> {
     /**
      * 分页
      */
-    IPage<Repair> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<Repair> queryWrapper);
+    IPage<Repair> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<Repair> queryWrapper, DataScope dataScope);
 
-    List<Repair> getList(Repair repair);
+    List<Repair> getList(Repair repair, DataScope dataScope);
 }

+ 3 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RepairServiceImpl.java

@@ -9,6 +9,7 @@ import com.github.zuihou.business.productionResourceCenter.dto.RepairSaveDTO;
 import com.github.zuihou.business.productionResourceCenter.dto.RepairUpdateDTO;
 import com.github.zuihou.business.productionResourceCenter.entity.Repair;
 import com.github.zuihou.business.productionResourceCenter.service.RepairService;
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionField;
@@ -34,14 +35,14 @@ public class RepairServiceImpl extends SuperServiceImpl<RepairMapper, Repair> im
     @Override
     @InjectionField
     public IPage<Repair> pageList(IPage page, LbqWrapper<Repair> wrapper) {
-        return baseMapper.pageList(page,wrapper);
+        return baseMapper.pageList(page,wrapper,new DataScope());
     }
 
     @Override
     @InjectionField
     public List<Repair> getList(RepairPageDTO dto) {
         Repair repair = BeanPlusUtil.toBean(dto, Repair.class);
-        List<Repair> list =  baseMapper.getList(repair);
+        List<Repair> list =  baseMapper.getList(repair, new DataScope());
         return list;
     }
 

+ 21 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/ToolServiceImpl.java

@@ -1,6 +1,8 @@
 package com.github.zuihou.business.productionResourceCenter.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.authority.service.auth.UserService;
 import com.github.zuihou.business.productionResourceCenter.dao.ToolMapper;
 import com.github.zuihou.business.productionResourceCenter.dto.ToolSaveDTO;
 import com.github.zuihou.business.productionResourceCenter.dto.ToolUpdateDTO;
@@ -8,13 +10,20 @@ import com.github.zuihou.business.productionResourceCenter.entity.Tool;
 import com.github.zuihou.business.productionResourceCenter.service.ToolService;
 import com.github.zuihou.base.service.SuperServiceImpl;
 
+import com.github.zuihou.common.util.StringUtil;
+import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.utils.BeanPlusUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.compress.utils.Lists;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 业务实现类
@@ -27,8 +36,20 @@ import org.springframework.transaction.annotation.Transactional;
 @Slf4j
 @Service
 public class ToolServiceImpl extends SuperServiceImpl<ToolMapper, Tool> implements ToolService {
+
+    @Autowired
+    private UserService userService;
+
     @Override
     public IPage<Tool> pageList(IPage page, LbqWrapper<Tool> wrapper) {
+        //String ordIds =
+        Long userId = BaseContextHandler.getUserId();
+        //获取用户权限访问机构
+        Map<String, Object> orgMap = userService.getDataScopeById(userId);
+        List<Long> orgIds = orgMap.containsKey("orgIds")? (List)orgMap.get("orgIds") : Lists.newArrayList();
+        if(CollectionUtil.isNotEmpty(orgIds)){
+            //wrapper.in(Tool::getOrgId, orgIds);
+        }
         return baseMapper.selectPage(page, wrapper);
     }
 

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

@@ -25,7 +25,7 @@
     <sql id="Base_Column_List">
         id,create_time,create_user,update_time,update_user,
         storge_id, lock_status, goods_type, goods_id, num, unique_code, turn_task_no, feed_task_no,storgeNo,
-        categoryDesc,brandName,brandNo,specification,weight,spec_id,lockNum,availableNum
+        categoryDesc,brandName,brandNo,specification,weight,spec_id,lockNum,availableNum,org_id
     </sql>
 
     <!-- 分页 -->
@@ -33,8 +33,9 @@
         select
         <include refid="Base_Column_List"/>
         from (
-            select a.*,b.categoryDesc,b.name as brandName,b.no as brandNo,b.specification,0 as lockNum,0 as availableNum 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 c_auth_user u on u.id = a.create_user
         ) s ${ew.customSqlSegment}
     </select>
 

+ 6 - 4
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionResourceCenter/RepairMapper.xml

@@ -20,7 +20,7 @@
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id,create_time,create_user,update_time,update_user,
-        productionresource_id,repair_end_time,repair_status,status,remark,code,productionresourceName,lineDesc,process,downTime,operationName,expireFlag
+        productionresource_id,repair_end_time,repair_status,status,remark,code,productionresourceName,lineDesc,process,downTime,operationName,expireFlag,org_id
     </sql>
 
     <!-- 分页 -->
@@ -51,7 +51,8 @@
         b.CODE,
         b.NAME AS productionresourceName,
         izz.id as productionLineId,
-        izz.NAME AS lineDesc
+        izz.NAME AS lineDesc,
+        izz.org_id
         FROM
         zuihou_base_yj_0000.imcs_tenant_repair a,
         imcs_z_zone_productionresource izzp,
@@ -80,11 +81,12 @@
         a.repair_end_time )* 100, 0 ) AS process,
         b.CODE,
         b.NAME AS productionresourceName,
-        c.NAME AS lineDesc
+        c.NAME AS lineDesc,
+        c.org_id
         FROM
         zuihou_base_yj_0000.imcs_tenant_repair a
         LEFT JOIN zuihou_base_yj_0000.imcs_tenant_productionresource b ON a.productionresource_id = b.id
-        LEFT JOIN zuihou_base_yj_0000.imcs_tenant_productionline c ON b.productionline_id = c.id
+        LEFT JOIN zuihou_base_yj_0000.imcs_z_zone c ON b.productionline_id = c.id
         where 1=1
         <if test="code != null and code != ''">
             and b.code = #{code}

+ 2 - 2
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/productionResourceCenter/entity/Tool.java

@@ -163,8 +163,8 @@ public class Tool extends Entity<Long> {
     @TableField(exist = false)
     private List<Long> resourceIdList;
 
-    /*@TableField(exist = false)
-    private List<Long> resourceList;*/
+    @TableField(exist = false)
+    private Long orgId;
 
     @Builder
     public Tool(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, 

+ 3 - 2
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/dao/ProductionresourceMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.github.zuihou.base.mapper.SuperMapper;
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.tenant.entity.Productionresource;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
@@ -35,7 +36,7 @@ public interface ProductionresourceMapper extends SuperMapper<Productionresource
 
     /**
      * 获取边缘盒子数据
-     * @param  获取边缘盒子数据
+     * @param  bean
      * @return
      */
     List<Productionresource> getModelList(Productionresource bean);
@@ -43,7 +44,7 @@ public interface ProductionresourceMapper extends SuperMapper<Productionresource
     /**
      * 分页
      */
-    IPage<Productionresource> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<Productionresource> queryWrapper);
+    IPage<Productionresource> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<Productionresource> queryWrapper, DataScope dataScope);
 
 
     int createDynTable(@Param("sql") String sql);

+ 2 - 1
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/dao/ProductionresourceviewMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.github.zuihou.base.mapper.SuperMapper;
+import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.tenant.entity.Productionresource;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
@@ -33,7 +34,7 @@ public interface ProductionresourceviewMapper extends SuperMapper<Productionreso
 
     /**
      * 获取设备和生产单元(产线)的关系
-     * @param map
+     * @param
      * @return
      */
     List<Map>getResourceZone();

+ 2 - 2
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/ProductionresourceService.java

@@ -37,7 +37,7 @@ public interface ProductionresourceService extends SuperCacheService<Productionr
     /**
      * 检测 边缘盒子/生产资源编码是否存在
      *
-     * @param tenantCode
+     * @param data
      * @return
      */
     boolean check(ProductionresourceSaveDTO data);
@@ -76,7 +76,7 @@ public interface ProductionresourceService extends SuperCacheService<Productionr
     /**
      * 删除边缘盒子/生产资源数据
      *
-     * @param ids
+     * @param model
      * @return
      */
     Boolean delete(Productionresource model);

+ 36 - 4
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/impl/ProductionresourceServiceImpl.java

@@ -5,8 +5,13 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.authority.entity.auth.User;
 import com.github.zuihou.authority.entity.common.DictionaryItem;
+import com.github.zuihou.authority.entity.core.Org;
+import com.github.zuihou.authority.service.auth.UserService;
 import com.github.zuihou.authority.service.common.DictionaryItemService;
+import com.github.zuihou.authority.strategy.DataScopeContext;
+import com.github.zuihou.authority.strategy.impl.ThisLevelChildrenDataScope;
 import com.github.zuihou.authority.utils.XxlJobUtil;
 import com.github.zuihou.base.service.SuperCacheServiceImpl;
 import com.github.zuihou.common.constant.BizConstant;
@@ -14,6 +19,8 @@ import com.github.zuihou.common.constant.CacheKey;
 import com.github.zuihou.common.constant.DictionaryType;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.database.mybatis.auth.DataScope;
+import com.github.zuihou.database.mybatis.auth.DataScopeType;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.properties.DatabaseProperties;
@@ -31,6 +38,7 @@ import com.github.zuihou.tenant.service.*;
 import com.github.zuihou.utils.BeanPlusUtil;
 import com.github.zuihou.utils.StrPool;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.httpclient.NameValuePair;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -90,6 +98,9 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
     @Autowired
     private DatabaseProperties databaseProperties;
 
+    @Autowired
+    private UserService userService;
+
     @Value("${xxl.job.admin.addresses}")
     private String jobAdminUrl;
     @Value("${xxl.job.login.username}")
@@ -113,11 +124,16 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
         if(map==null) map = new HashMap();
         //需要查询状态
         String resourceStatus = map.get("resourceStatus")==null?"":map.get("resourceStatus").toString();
+        String gatherSql = "";
         if("1".equals(resourceStatus)){
-            String gatherSql = getGatherSQL();
+            gatherSql = getGatherSQL();
             map.put("gatherSql",gatherSql);
         }
 
+        String getOrgIds = this.getOrgIds();
+        if(StringUtil.isNotEmpty(getOrgIds)){
+            map.put("orgIds", getOrgIds);
+        }
         List<Map>list = productionresourceviewMapper.getList(map);
         //设置字典表
         setDesc(list);
@@ -143,9 +159,15 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
 
         //需要查询状态
         String resourceStatus = map.get("resourceStatus")==null?"":map.get("resourceStatus").toString();
+        String gatherSql = "";
         if("1".equals(resourceStatus)){
-            String gatherSql = getGatherSQL();
-            map.put("gatherSql",gatherSql);
+             gatherSql = getGatherSQL();
+             map.put("gatherSql",gatherSql);
+        }
+
+        String getOrgIds = this.getOrgIds();
+        if(StringUtil.isNotEmpty(getOrgIds)){
+            map.put("orgIds", getOrgIds);
         }
 
         getQueryMap(map);
@@ -164,6 +186,16 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
         return retMap;
     }
 
+    public String getOrgIds(){
+        //机构部门数据权限判断验证
+        BaseContextHandler.setTenant("0000");
+        Long userId = BaseContextHandler.getUserId();
+        //获取用户权限访问机构
+        Map<String, Object> orgMap = userService.getDataScopeById(userId);
+        List<Long> orgIds = orgMap.containsKey("orgIds")? (List)orgMap.get("orgIds") : Lists.newArrayList();
+        return CollectionUtil.isNotEmpty(orgIds)? CollectionUtil.join(orgIds, ",") : "";
+    }
+
 
     private Map getQueryMap(Map map){
         Map modelMap = map.get("model")==null?null:(Map)map.get("model");
@@ -236,7 +268,7 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
     // 启用属性自动注入
     @InjectionResult
     public IPage<Productionresource> pageList(IPage page, LbqWrapper<Productionresource> wrapper) {
-        return baseMapper.pageList(page, wrapper);
+        return baseMapper.pageList(page, wrapper, new DataScope());
     }
 
     @Override

+ 3 - 3
imcs-admin-boot/imcs-tenant-biz/src/main/resources/mapper_tenant/base/defaults/ProductionresourceMapper.xml

@@ -36,7 +36,7 @@
     <sql id="Base_Column_List">
         id,create_time,create_user,update_time,update_user,
         tenant_id, productionline_id, box_id, type, category, module_id, name, code, status, remark, resources_type,resources_category,lineDesc,moduleDesc,tenantDesc,pic,
-        ip,port,capital_no,capital_name,capital_type,mode_specification,capital_price,production_date,production_no,manufacturer
+        ip,port,capital_no,capital_name,capital_type,mode_specification,capital_price,production_date,production_no,manufacturer,org_id
     </sql>
 
     <!-- 分页 -->
@@ -45,9 +45,9 @@
         <include refid="Base_Column_List"/>
         from (
             SELECT
-            a.*,b.name as lineDesc,c.name as moduleDesc,d.name as tenantDesc,c.pic,c.category
+            a.*,b.name as lineDesc,b.org_id,c.name as moduleDesc,d.name as tenantDesc,c.pic,c.category
             from imcs_tenant_productionresource a
-            left join imcs_tenant_productionline b on a.productionline_id = b.id
+            left join zuihou_base_yj_0000.imcs_z_zone b on a.productionline_id = b.id
             left join imcs_tenant_module c on a.module_id = c.id
             left join d_tenant d on a.tenant_id = d.id
         ) s ${ew.customSqlSegment}

+ 11 - 2
imcs-admin-boot/imcs-tenant-biz/src/main/resources/mapper_tenant/base/defaults/ProductionresourceviewMapper.xml

@@ -40,6 +40,7 @@
             max_speed AS maxSpeed,
             tray_num AS trayNum,
             a.zoneName,
+            a.org_id AS orgId,
             b.positionCount,
             c.cnc_program cncProgram,
             c.show_status showStatus,
@@ -52,7 +53,8 @@
             SELECT
                 zp.resource_id,
                 z.id zoneId,
-                z. NAME zoneName
+                z.NAME zoneName,
+                z.org_id
             FROM
                 imcs_z_zone z
             LEFT JOIN imcs_z_zone_productionresource zp ON z.id = zp.zone_id
@@ -75,6 +77,9 @@
         <if test="code != null and code != ''">
             and v.code = #{code}
         </if>
+        <if test="orgIds != null and orgIds != ''">
+            and a.org_id in (${orgIds})
+        </if>
         <if test="codes != null and codes != ''">
             and v.code in (${codes})
         </if>
@@ -113,7 +118,8 @@
         LEFT JOIN (
         SELECT
         zp.resource_id,
-        z. NAME zoneName
+        z. NAME zoneName,
+        z.org_id
         FROM
         imcs_z_zone z
         LEFT JOIN imcs_z_zone_productionresource zp ON z.id = zp.zone_id
@@ -130,6 +136,9 @@
         <if test="zoneId != null">
             and a.zoneId =  #{zoneId}
         </if>
+        <if test="orgIds != null and orgIds != ''">
+            and a.org_id in (${orgIds})
+        </if>
         <if test="code != null and code != ''">
             and v.code = #{code}
         </if>