Bläddra i källkod

加入数据权限

wangliang 1 år sedan
förälder
incheckning
aa61acc6fe

+ 12 - 1
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDelayWarnMapper.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.result.TBDelayWarnResult;
 import com.qmth.sop.business.bean.result.WorkWarnResult;
 import com.qmth.sop.business.entity.TBDelayWarn;
@@ -24,9 +25,19 @@ public interface TBDelayWarnMapper extends BaseMapper<TBDelayWarn> {
      * 查询列表
      *
      * @param iPage
+     * @param type
+     * @param status
+     * @param serviceId
+     * @param custom
+     * @param fieldObj
+     * @param sopNo
+     * @param startTime
+     * @param endTime
+     * @param id
+     * @param dpr
      * @return
      */
-    IPage<TBDelayWarnResult> query(IPage<Map> iPage, @Param("type") String type, @Param("status") String status, @Param("serviceId") Long serviceId, @Param("custom") String custom, @Param("fieldObj") String fieldObj, @Param("sopNo") String sopNo, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("id") Long id);
+    IPage<TBDelayWarnResult> query(IPage<Map> iPage, @Param("type") String type, @Param("status") String status, @Param("serviceId") Long serviceId, @Param("custom") String custom, @Param("fieldObj") String fieldObj, @Param("sopNo") String sopNo, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("id") Long id, @Param("dpr") DataPermissionDto dpr);
 
     /**
      * 获取预警待办

+ 3 - 1
sop-business/src/main/java/com/qmth/sop/business/mapper/TBProjectExchangeMapper.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.result.ProjectExchangeResult;
 import com.qmth.sop.business.entity.TBProjectExchange;
 import org.apache.ibatis.annotations.Param;
@@ -31,7 +32,8 @@ public interface TBProjectExchangeMapper extends BaseMapper<TBProjectExchange> {
      * @param exchangeNo
      * @param startTime
      * @param endTime
+     * @param dpr
      * @return
      */
-    IPage<ProjectExchangeResult> list(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("createUserId") Long createUserId, @Param("type") String type, @Param("customType") String customType, @Param("flowStatus") String flowStatus, @Param("customName") String customName, @Param("exchangeNo") String exchangeNo, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
+    IPage<ProjectExchangeResult> list(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("createUserId") Long createUserId, @Param("type") String type, @Param("customType") String customType, @Param("flowStatus") String flowStatus, @Param("customName") String customName, @Param("exchangeNo") String exchangeNo, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);
 }

+ 21 - 9
sop-business/src/main/java/com/qmth/sop/business/mapper/TBViolationMapper.java

@@ -2,15 +2,16 @@ package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.result.TBViolationResult;
 import com.qmth.sop.business.entity.TBViolation;
 import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Param;
+
 import java.util.Map;
 
 /**
  * sop违规登记表 Mapper 接口.
- * 
+ *
  * @author: shudonghui
  * @date: 2023-08-09 10:33:08
  * @version: 1.0
@@ -19,12 +20,23 @@ import java.util.Map;
  */
 public interface TBViolationMapper extends BaseMapper<TBViolation> {
 
-	/**
-	 * 查询列表
-	 * @param iPage
-	 * @return
-	 */
-    IPage<TBViolationResult> query(IPage<Map> iPage, @Param("serviceId")  Long serviceId, @Param("type")  String type, @Param("status")  String status, @Param("userId")  Long userId, @Param("custom")  String custom, @Param("sopNo")  String sopNo, @Param("createId")  Long createId, @Param("startTime")  Long startTime, @Param("endTime")  Long endTime);
+    /**
+     * 查询列表
+     *
+     * @param iPage
+     * @param serviceId
+     * @param type
+     * @param status
+     * @param userId
+     * @param custom
+     * @param sopNo
+     * @param createId
+     * @param startTime
+     * @param endTime
+     * @param dpr
+     * @return
+     */
+    IPage<TBViolationResult> query(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("type") String type, @Param("status") String status, @Param("userId") Long userId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("createId") Long createId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);
 
-	TBViolationResult getByCode(@Param("code")  String code);
+    TBViolationResult getByCode(@Param("code") String code);
 }

+ 9 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBDelayWarnService.java

@@ -26,6 +26,15 @@ public interface TBDelayWarnService extends IService<TBDelayWarn> {
      * 查询列表
      *
      * @param iPage
+     * @param type
+     * @param status
+     * @param serviceId
+     * @param custom
+     * @param fieldObj
+     * @param sopNo
+     * @param startTime
+     * @param endTime
+     * @param id
      * @return
      */
     IPage<TBDelayWarnResult> query(IPage<Map> iPage, DelayWarnTypeEnum type, DelayWarnStatusEnum status, Long serviceId, String custom, String fieldObj, String sopNo, Long startTime, Long endTime, Long id);

+ 17 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDelayWarnServiceImpl.java

@@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.result.TBDelayWarnResult;
 import com.qmth.sop.business.bean.result.WorkWarnResult;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBDelayWarn;
 import com.qmth.sop.business.entity.TBDelayWarnDetail;
 import com.qmth.sop.business.mapper.TBDelayWarnMapper;
+import com.qmth.sop.business.service.SysUserService;
 import com.qmth.sop.business.service.TBDelayWarnDetailService;
 import com.qmth.sop.business.service.TBDelayWarnService;
 import com.qmth.sop.common.enums.*;
@@ -39,15 +41,29 @@ public class TBDelayWarnServiceImpl extends ServiceImpl<TBDelayWarnMapper, TBDel
     @Resource
     TBDelayWarnDetailService tBDelayWarnDetailService;
 
+    @Resource
+    SysUserService sysUserService;
+
     /**
      * 查询列表
      *
      * @param iPage
+     * @param type
+     * @param status
+     * @param serviceId
+     * @param custom
+     * @param fieldObj
+     * @param sopNo
+     * @param startTime
+     * @param endTime
+     * @param id
      * @return
      */
     @Override
     public IPage<TBDelayWarnResult> query(IPage<Map> iPage, DelayWarnTypeEnum type, DelayWarnStatusEnum status, Long serviceId, String custom, String fieldObj, String sopNo, Long startTime, Long endTime, Long id) {
-        return this.baseMapper.query(iPage, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(status) ? status.name() : null, serviceId, custom, fieldObj, sopNo, startTime, endTime, id);
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
+        return this.baseMapper.query(iPage, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(status) ? status.name() : null, serviceId, custom, fieldObj, sopNo, startTime, endTime, id, dpr);
     }
 
     /**

+ 8 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBProjectExchangeServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.activiti.service.ActivitiService;
+import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.dto.UserDto;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.result.CrmProjectResult;
@@ -13,10 +14,7 @@ import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBProjectExchange;
 import com.qmth.sop.business.entity.TFCustomFlowEntity;
 import com.qmth.sop.business.mapper.TBProjectExchangeMapper;
-import com.qmth.sop.business.service.SysUserRoleService;
-import com.qmth.sop.business.service.TBCrmService;
-import com.qmth.sop.business.service.TBProjectExchangeService;
-import com.qmth.sop.business.service.TFCustomFlowEntityService;
+import com.qmth.sop.business.service.*;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.*;
 import com.qmth.sop.common.util.ServletUtil;
@@ -59,6 +57,9 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
     @Resource
     TBCrmService tbCrmService;
 
+    @Resource
+    SysUserService sysUserService;
+
     /**
      * 新增项目变更计划申请
      *
@@ -106,9 +107,9 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
      */
     @Override
     public IPage<ProjectExchangeResult> list(IPage<Map> iPage, Long serviceId, Long createUserId, DelayWarnTypeEnum type, ProductTypeEnum customType, ProjectExchangeFlowStatusEnum flowStatus, String customName, String exchangeNo, Long startTime, Long endTime) {
-//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-//        createUserId = Objects.isNull(createUserId) ? sysUser.getId() : createUserId;
-        return this.baseMapper.list(iPage, serviceId, createUserId, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(customType) ? customType.name() : null, Objects.nonNull(flowStatus) ? flowStatus.name() : null, customName, exchangeNo, startTime, endTime);
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
+        return this.baseMapper.list(iPage, serviceId, createUserId, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(customType) ? customType.name() : null, Objects.nonNull(flowStatus) ? flowStatus.name() : null, customName, exchangeNo, startTime, endTime, dpr);
     }
 
     /**

+ 18 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBViolationServiceImpl.java

@@ -4,16 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.result.TBViolationResult;
 import com.qmth.sop.business.entity.SysMessage;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBViolation;
 import com.qmth.sop.business.entity.TBViolationDetail;
 import com.qmth.sop.business.mapper.TBViolationMapper;
-import com.qmth.sop.business.service.SequenceService;
-import com.qmth.sop.business.service.SysMessageService;
-import com.qmth.sop.business.service.TBViolationDetailService;
-import com.qmth.sop.business.service.TBViolationService;
+import com.qmth.sop.business.service.*;
 import com.qmth.sop.business.util.SmsSendUtil;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.*;
@@ -40,6 +38,7 @@ public class TBViolationServiceImpl extends ServiceImpl<TBViolationMapper, TBVio
 
     @Resource
     SysMessageService sysMessageService;
+
     @Resource
     SmsSendUtil smsSendUtil;
 
@@ -49,17 +48,29 @@ public class TBViolationServiceImpl extends ServiceImpl<TBViolationMapper, TBVio
     @Resource
     TBViolationDetailService tbViolationDetailService;
 
+    @Resource
+    SysUserService sysUserService;
+
     /**
      * 查询列表
      *
      * @param iPage
+     * @param serviceId
+     * @param type
+     * @param status
+     * @param userId
+     * @param custom
+     * @param sopNo
+     * @param createId
+     * @param startTime
+     * @param endTime
      * @return
      */
-
-
     @Override
     public IPage<TBViolationResult> query(IPage<Map> iPage, Long serviceId, ViolationTypeEnum type, ViolationStatusEnum status, Long userId, String custom, String sopNo, Long createId, Long startTime, Long endTime) {
-        return this.baseMapper.query(iPage, serviceId, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(status) ? status.name() : null, userId, custom, sopNo, createId, startTime, endTime);
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
+        return this.baseMapper.query(iPage, serviceId, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(status) ? status.name() : null, userId, custom, sopNo, createId, startTime, endTime, dpr);
     }
 
     /**

+ 21 - 0
sop-business/src/main/resources/mapper/TBDelayWarnMapper.xml

@@ -50,6 +50,27 @@
                 and a.warn_time <= #{endTime}
                 ]]>
             </if>
+            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
+                <choose>
+                    <when test="dpr.hasBusiness">
+                        AND s.service_lead_id = #{dpr.requestUserId}
+                    </when>
+                    <otherwise>
+                        <choose>
+                            <when test="dpr.hasRegionManager">
+                                AND c.lead_id = #{dpr.requestUserId}
+                            </when>
+                            <otherwise>
+                                <choose>
+                                    <when test="dpr.hasRegionCoordinator">
+                                        AND c.region_coordinator_id = #{dpr.requestUserId}
+                                    </when>
+                                </choose>
+                            </otherwise>
+                        </choose>
+                    </otherwise>
+                </choose>
+            </if>
         </where>
 
         ORDER BY a.create_time DESC

+ 21 - 0
sop-business/src/main/resources/mapper/TBProjectExchangeMapper.xml

@@ -76,6 +76,27 @@
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                 and (tbpe.create_time <![CDATA[ >= ]]> #{startTime} or tbpe.create_time <![CDATA[ <= ]]> 1)
             </if>
+            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
+                <choose>
+                    <when test="dpr.hasBusiness">
+                        AND tbs.service_lead_id = #{dpr.requestUserId}
+                    </when>
+                    <otherwise>
+                        <choose>
+                            <when test="dpr.hasRegionManager">
+                                AND tbc.lead_id = #{dpr.requestUserId}
+                            </when>
+                            <otherwise>
+                                <choose>
+                                    <when test="dpr.hasRegionCoordinator">
+                                        AND tbc.region_coordinator_id = #{dpr.requestUserId}
+                                    </when>
+                                </choose>
+                            </otherwise>
+                        </choose>
+                    </otherwise>
+                </choose>
+            </if>
         </where>
     </select>
 </mapper>

+ 21 - 0
sop-business/src/main/resources/mapper/TBViolationMapper.xml

@@ -51,6 +51,27 @@
                 and a.warn_time <= #{endTime}
                 ]]>
             </if>
+            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
+                <choose>
+                    <when test="dpr.hasBusiness">
+                        AND s.service_lead_id = #{dpr.requestUserId}
+                    </when>
+                    <otherwise>
+                        <choose>
+                            <when test="dpr.hasRegionManager">
+                                AND c.lead_id = #{dpr.requestUserId}
+                            </when>
+                            <otherwise>
+                                <choose>
+                                    <when test="dpr.hasRegionCoordinator">
+                                        AND c.region_coordinator_id = #{dpr.requestUserId}
+                                    </when>
+                                </choose>
+                            </otherwise>
+                        </choose>
+                    </otherwise>
+                </choose>
+            </if>
         </where>
 
         ORDER BY a.create_time DESC