Browse Source

线边库数据权限过滤

oyq28 3 years ago
parent
commit
ea9796b31b

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

@@ -32,10 +32,16 @@
         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
+            SELECT d.* , z.org_id FROM (
+                  SELECT c.* , ifnull(c.pname, c.NAME) AS zone_name FROM (
+                  SELECT a.*, b. NAME AS pname FROM imcs_s_shelves a LEFT JOIN imcs_s_shelves b ON a.parent_id = b.id
+                 )c
+            ) d
+        <!--
+       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 locate(z.abbreviate, left(d.zone_name,5))
+        WHERE d.status = '1'
         ) s ${ew.customSqlSegment}
     </select>
 

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

@@ -154,7 +154,7 @@
         select sum(shelvesCount) as shelvesCount,sum(storgeCount) as storgeCount,sum(instockCount) as instockCount,
         (sum(storgeCount)-sum(instockCount)) as freestockCount,sum(lockstockCount) as lockstockCount from (
             -- 货架
-            select count(1) as shelvesCount,0 as storgeCount,0 as instockCount,0 as lockstockCount from (select s.name, z.org_id from imcs_s_shelves s left join imcs_z_zone z on locate(z.abbreviate, s.name) where s.type= '1' and s.status= '1'
+            select count(1) as shelvesCount,0 as storgeCount,0 as instockCount,0 as lockstockCount from (select s.name, z.org_id from imcs_s_shelves s left join imcs_z_zone z on locate(z.abbreviate, left(s.name, 5) ) where s.type= '1' and s.status= '1'
             <if test="orgIds != null and orgIds != ''">
                 and z.org_id in (${orgIds})
             </if>
@@ -162,21 +162,21 @@
             union all
             -- 库位
             select 0 as shelvesCount,count(1) as storgeCount,0 as instockCount,0 as lockstockCount from imcs_s_storge s  LEFT JOIN ( SELECT  h.id, h.parent_id, h.name as bname, h1.name as aname, h1.status as storgeStatus FROM imcs_s_shelves h LEFT JOIN imcs_s_shelves h1 ON h.parent_id = h1.id
-            ) b ON s.shelves_id = b.id LEFT JOIN imcs_z_zone z ON Locate(z.abbreviate, b.aname) where b.storgeStatus = 1
+            ) b ON s.shelves_id = b.id LEFT JOIN imcs_z_zone z ON Locate(z.abbreviate, left(b.aname,5)) where b.storgeStatus = 1
             <if test="orgIds != null and orgIds != ''">
                 and z.org_id in (${orgIds})
             </if>
             union all
             -- 已存库位
             select 0 as shelvesCount,0 as storgeCount,count(1) as instockCount,0 as lockstockCount from imcs_s_storge s LEFT JOIN ( SELECT  h.id, h.parent_id, h.name as bname, h1.name as aname, h1.status as instockStatus FROM imcs_s_shelves h LEFT JOIN imcs_s_shelves h1 ON h.parent_id = h1.id
-            ) b ON s.shelves_id = b.id LEFT JOIN imcs_z_zone z ON Locate(z.abbreviate, b.aname) where s.id in (select storge_id from imcs_s_stock_info) and b.instockStatus = 1
+            ) b ON s.shelves_id = b.id LEFT JOIN imcs_z_zone z ON Locate(z.abbreviate, left(b.aname,5)) where s.id in (select storge_id from imcs_s_stock_info) and b.instockStatus = 1
             <if test="orgIds != null and orgIds != ''">
                 and z.org_id in (${orgIds})
             </if>
             union all
             -- 锁定库位
             select 0 as shelvesCount,0 as storgeCount,0 as instockCount,count(1) as lockstockCount from imcs_s_storge s LEFT JOIN ( SELECT  h.id, h.parent_id, h.name as bname, h1.name as aname, h1.status as lockStaus FROM imcs_s_shelves h LEFT JOIN imcs_s_shelves h1 ON h.parent_id = h1.id
-            ) b ON s.shelves_id = b.id LEFT JOIN imcs_z_zone z ON Locate(z.abbreviate, b.aname) where s.lock_status = '0' and b.lockStaus
+            ) b ON s.shelves_id = b.id LEFT JOIN imcs_z_zone z ON Locate(z.abbreviate, left(b.aname,5)) where s.lock_status = '0' and b.lockStaus
             <if test="orgIds != null and orgIds != ''">
                 and z.org_id in (${orgIds})
             </if>