Explorar el Código

科室门住损益计算及科室损益计算-报表数据界面添加数据权限管控相关代码

JammeyJiang hace 8 meses
padre
commit
ceb883b0f6

+ 17 - 0
src/main/java/com/kcim/service/UserResponsibilityRightService.java

@@ -1,6 +1,7 @@
 package com.kcim.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.kcim.dao.model.Responsibility;
 import com.kcim.dao.model.UserResponsibilityRight;
 import com.kcim.vo.UserResponsibilityRightVO;
 
@@ -22,6 +23,7 @@ public interface UserResponsibilityRightService  extends IService<UserResponsibi
 
     /**
      * 获取用户的责任中心权限列表
+     * @param userId
      * @param responsibilityName
      * @param hideFlag
      * @return
@@ -48,5 +50,20 @@ public interface UserResponsibilityRightService  extends IService<UserResponsibi
      * @param allRightFlag
      */
     void editAllUserResponsibilityRight(Long userId,Integer allRightFlag);
+
+    /**
+     * 获取授权的责任中心
+     * @param fullResponsibilityList 需要去除非授权的完整的责任中心列表
+     * @return
+     */
+    List<Responsibility> getAuthorizedResponsibility(List<Responsibility> fullResponsibilityList);
+
+
+    /**
+     * 是否开启用户损益报表数据权限功能
+     * @return
+     */
+    boolean IsUserReportRightAble();
+
 }
 

+ 24 - 5
src/main/java/com/kcim/service/impl/ComputeMedicalDepartmentProfitServiceImpl.java

@@ -9,12 +9,10 @@ import com.kcim.common.util.ComputeDateUtils;
 import com.kcim.dao.model.ComputeMedicalDepartmentProfit;
 import com.kcim.dao.model.ReportForm;
 import com.kcim.dao.model.Responsibility;
+import com.kcim.dao.model.UserResponsibilityRight;
 import com.kcim.dao.repository.ComputeMedicalDepartmentProfitRepository;
 import com.kcim.dao.repository.CostDepartmentProfitRepository;
-import com.kcim.service.ComputeMedicalDepartmentProfitService;
-import com.kcim.service.ReportFormService;
-import com.kcim.service.ResponsibilityService;
-import com.kcim.service.SqlService;
+import com.kcim.service.*;
 import com.kcim.vo.MedicalResponsibilityVo;
 import com.kcim.vo.ReportFormProfitVo;
 import com.kcim.web.reponse.MedicalProfitResponse;
@@ -48,12 +46,14 @@ public class ComputeMedicalDepartmentProfitServiceImpl implements ComputeMedical
     ResponsibilityService responsibilityService ;
     ReportFormService reportFormService;
     CostDepartmentProfitRepository costDepartmentProfitRepository;
+    UserResponsibilityRightService userResponsibilityRightService;
 
-    public ComputeMedicalDepartmentProfitServiceImpl(SqlService sqlService, ComputeMedicalDepartmentProfitRepository repository, ResponsibilityService responsibilityService, ReportFormService reportFormService, CostDepartmentProfitRepository costDepartmentProfitRepository) {
+    public ComputeMedicalDepartmentProfitServiceImpl(SqlService sqlService, ComputeMedicalDepartmentProfitRepository repository, ResponsibilityService responsibilityService, ReportFormService reportFormService,UserResponsibilityRightService userResponsibilityRightService, CostDepartmentProfitRepository costDepartmentProfitRepository) {
         this.sqlService = sqlService;
         this.repository = repository;
         this.responsibilityService = responsibilityService;
         this.reportFormService = reportFormService;
+        this.userResponsibilityRightService=userResponsibilityRightService;
         this.costDepartmentProfitRepository = costDepartmentProfitRepository;
     }
 
@@ -321,6 +321,25 @@ public class ComputeMedicalDepartmentProfitServiceImpl implements ComputeMedical
         if(CollectionUtils.isEmpty(medicalProfitList)){
             throw new CostException(reportType+"未进行科室门住损益计算");
         }
+        //开启数据权限流程时
+        if(userResponsibilityRightService.IsUserReportRightAble()){
+            //获取用户所有有权限的责任中心
+            List<UserResponsibilityRight> currentUserResponsibilityRights = userResponsibilityRightService.getUserResponsibilityRight();
+            if(CollectionUtils.isEmpty(currentUserResponsibilityRights)){
+                throw new CostException("您没有分配责任中心权限,请联系管理员");
+            }
+            //如果不是分配了全部责任中心权限则过滤没有权限的责任中心
+            if(!currentUserResponsibilityRights.stream().anyMatch(userResponsibilityRight->
+                    userResponsibilityRight.getResponsibilityCode().equals(NumberConstant.ZERO_S))){
+                //筛选出有权限的责任中心对象
+                medicalProfitList = medicalProfitList.stream().filter(responsibility ->
+                        currentUserResponsibilityRights.stream().anyMatch(userRight ->
+                                userRight.getResponsibilityCode().equals(responsibility.getResponsibilityCode()))).collect(Collectors.toList());
+                if(CollectionUtils.isEmpty(medicalProfitList)){
+                    throw new CostException("您没有对应的责任中心权限,请联系管理员");
+                }
+            }
+        }
         //获取当前院区所有的责任中心
         List<Responsibility> responsibilityAllList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
                 .eq(Responsibility::getHospId, hospId));

+ 6 - 19
src/main/java/com/kcim/service/impl/CostDepartmentProfitServiceImpl.java

@@ -1226,7 +1226,6 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
      */
     @Override
     public Object computeProfitReport(String computeDate, Long hospId, String reportType) {
-
         Integer year = ComputeDateUtils.getComputeYear(computeDate);
         Integer month = ComputeDateUtils.getComputeMonth(computeDate);
         Integer integerReportType = Integer.valueOf(reportType);
@@ -1291,6 +1290,8 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
         if (CollectionUtils.isEmpty(responsibilityList)) {
             throw new CostException("未找到对应分摊层级责任中心");
         }
+        //获取授权的责任中心
+        responsibilityList=userResponsibilityRightService.getAuthorizedResponsibility(responsibilityList);
         //获取当前院区所有的责任中心
         List<Responsibility> responsibilityAllList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
                 .eq(Responsibility::getHospId, hospId));
@@ -1595,24 +1596,8 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
         if (CollectionUtils.isEmpty(responsibilityList)) {
             throw new CostException("未找到对应分摊层级责任中心");
         }
-        //开启用户报表数据权限时
-        if(IsUserReportRightAble()){
-            //获取用户所有有权限的责任中心
-            List<UserResponsibilityRight> currentUserResponsibilityRights = userResponsibilityRightService.getUserResponsibilityRight();
-            if(CollectionUtils.isEmpty(currentUserResponsibilityRights)){
-                throw new CostException("您没有分配责任中心权限,请联系管理员");
-            }
-            //如果不是分配了全部责任中心权限则过滤没有权限的责任中心
-            if(!currentUserResponsibilityRights.stream().anyMatch(userResponsibilityRight->userResponsibilityRight.getUserId().equals(NumberConstant.ZERO))){
-                //筛选出有权限的责任中心对象
-                responsibilityList = responsibilityList.stream().filter(responsibility ->
-                        currentUserResponsibilityRights.stream().anyMatch(userRight ->
-                                userRight.getResponsibilityCode().equals(responsibility.getResponsibilityCode()))).collect(Collectors.toList());
-                if(CollectionUtils.isEmpty(responsibilityList)){
-                    throw new CostException("您没有对应的责任中心权限,请联系管理员");
-                }
-            }
-        }
+        //获取授权的责任中心
+        responsibilityList=userResponsibilityRightService.getAuthorizedResponsibility(responsibilityList);
         List<Responsibility> responsibilityAllList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
                 .eq(Responsibility::getHospId, hospId));
         Map<Long, Responsibility> map = responsibilityAllList.stream().collect(Collectors.toMap(Responsibility::getId, responsibility -> responsibility, (a, b) -> b));
@@ -2160,6 +2145,8 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
         if (CollectionUtils.isEmpty(responsibilityList)) {
             throw new CostException("未找到对应分摊层级责任中心");
         }
+        //获取授权的责任中心
+        responsibilityList=userResponsibilityRightService.getAuthorizedResponsibility(responsibilityList);
         List<Responsibility> responsibilityAllList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
                 .eq(Responsibility::getHospId, hospId));
         Map<Long, Responsibility> map = responsibilityAllList.stream().collect(Collectors.toMap(Responsibility::getId, responsibility -> responsibility, (a, b) -> b));

+ 50 - 0
src/main/java/com/kcim/service/impl/UserResponsibilityRightServiceImpl.java

@@ -5,10 +5,13 @@ import com.kcim.common.constants.NumberConstant;
 import com.kcim.common.exception.CostException;
 import com.kcim.common.util.BeanUtil;
 import com.kcim.dao.mapper.UserResponsibilityRightMapper;
+import com.kcim.dao.model.Responsibility;
 import com.kcim.dao.model.UserResponsibilityRight;
 import com.kcim.dao.repository.UserResponsibilityRightRepository;
+import com.kcim.service.CenterService;
 import com.kcim.service.ResponsibilityService;
 import com.kcim.service.UserResponsibilityRightService;
+import com.kcim.vo.CommonParameterVo;
 import com.kcim.vo.CostResponsibilityVO;
 import com.kcim.vo.UserResponsibilityRightVO;
 import lombok.AllArgsConstructor;
@@ -19,8 +22,11 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
+import static com.kcim.common.constants.ParameterConstant.USER_REPORT_AUTHOR_ABLE;
+
 
 /**
  *
@@ -34,6 +40,7 @@ public class UserResponsibilityRightServiceImpl extends ServiceImpl<UserResponsi
 
     UserResponsibilityRightRepository repository;
     ResponsibilityService responsibilityService;
+    CenterService centerService;
 
     /**
      * 获取当前用户有权限的责任中心信息
@@ -130,5 +137,48 @@ public class UserResponsibilityRightServiceImpl extends ServiceImpl<UserResponsi
         }
     }
 
+    /**
+     * 获取授权的责任中心
+     * @param fullResponsibilityList
+     * @return
+     */
+    @Override
+    public List<Responsibility> getAuthorizedResponsibility(List<Responsibility> fullResponsibilityList){
+        //开启用户报表数据权限时
+        if(IsUserReportRightAble()){
+            //获取用户所有有权限的责任中心
+            List<UserResponsibilityRight> currentUserResponsibilityRights = this.getUserResponsibilityRight();
+            if(CollectionUtils.isEmpty(currentUserResponsibilityRights)){
+                throw new CostException("您没有分配责任中心权限,请联系管理员");
+            }
+            //如果不是分配了全部责任中心权限则过滤没有权限的责任中心
+            if(!currentUserResponsibilityRights.stream().anyMatch(userResponsibilityRight->
+                    userResponsibilityRight.getResponsibilityCode().equals(NumberConstant.ZERO_S))){
+                //筛选出有权限的责任中心对象
+                fullResponsibilityList = fullResponsibilityList.stream().filter(responsibility ->
+                        currentUserResponsibilityRights.stream().anyMatch(userRight ->
+                                userRight.getResponsibilityCode().equals(responsibility.getResponsibilityCode()))).collect(Collectors.toList());
+                if(CollectionUtils.isEmpty(fullResponsibilityList)){
+                    throw new CostException("您没有对应的责任中心权限,请联系管理员");
+                }
+            }
+        }
+        return fullResponsibilityList;
+    }
+
+    /**
+     * 判断是否开启用户报表权限功能
+     * @return
+     */
+    @Override
+    public boolean IsUserReportRightAble(){
+        CommonParameterVo parameter = centerService.getParameter(USER_REPORT_AUTHOR_ABLE);
+        if (Objects.isNull(parameter)){
+            return false;
+        }
+        String incomeCollectType = parameter.getValue();
+        return incomeCollectType.equals(NumberConstant.ONE_S);
+    }
+
 
 }