Browse Source

增加退药权限

lihong 1 year ago
parent
commit
f0c5a2e832

+ 29 - 5
src/main/java/cn/hnthyy/thmz/controller/mz/YpMzFytjController.java

@@ -5,12 +5,18 @@ import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.his.mz.MzPatientMi;
 import cn.hnthyy.thmz.entity.his.yp.YpMzFytj;
 import cn.hnthyy.thmz.entity.his.yp.YpZdGroupName;
+import cn.hnthyy.thmz.entity.thmz.Button;
+import cn.hnthyy.thmz.entity.thmz.RoleButtonRelation;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.enums.ConfirmFlagEnum;
 import cn.hnthyy.thmz.service.his.mz.MzPatientMiService;
 import cn.hnthyy.thmz.service.his.yp.YpMzFytjService;
 import cn.hnthyy.thmz.service.his.yp.YpZdGroupNameService;
+import cn.hnthyy.thmz.service.thmz.ButtonService;
+import cn.hnthyy.thmz.service.thmz.RoleButtonRelationService;
+import cn.hnthyy.thmz.service.thmz.UserRoleRelationService;
 import cn.hnthyy.thmz.vo.*;
+import cn.hutool.core.collection.CollUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +37,10 @@ public class YpMzFytjController {
     private YpZdGroupNameService ypZdGroupNameService;
     @Autowired
     private MzPatientMiService mzPatientMiService;
+    @Autowired
+    private ButtonService buttonService;
+
+
     /**
      * 门诊医生查询发药记录单
      *
@@ -66,14 +76,17 @@ public class YpMzFytjController {
             }
             chargeFeeParamsVo.setConfirmFlag(ConfirmFlagEnum.CONFIRM.code);
             User tokenUser = TokenUtil.getUser(httpServletRequest);
-            chargeFeeParamsVo.setOpId(tokenUser.getUserIdCode());
+            if(!isReFrug()){
+                chargeFeeParamsVo.setOpId(tokenUser.getUserIdCode());
+            }
             List<YpMzFytj> ypMzFytjList = ypMzFytjService.queryYpMzFytj(chargeFeeParamsVo);
             if(ypMzFytjList!=null && ypMzFytjList.size()>0){
+                List<YpZdGroupName> ypZdGroupNames = ypZdGroupNameService.queryAllYpZdGroupName();
                 for (YpMzFytj ypMzFytj:ypMzFytjList){
                     if(ypMzFytj==null || StringUtils.isBlank(ypMzFytj.getGroupNo())){
                         continue;
                     }
-                    YpZdGroupName ypZdGroupName=ypZdGroupNameService.queryByGroupNo(ypMzFytj.getGroupNo());
+                    YpZdGroupName ypZdGroupName=CollUtil.isEmpty(ypZdGroupNames)? null: ypZdGroupNames.stream().filter(item->item.getGroupNo().trim().equals(ypMzFytj.getGroupNo())).findFirst().get();
                     if(ypZdGroupName==null){
                         ypMzFytj.setGroupNoOut(ypMzFytj.getGroupNo());
                         continue;
@@ -91,7 +104,15 @@ public class YpMzFytjController {
             return resultMap;
         }
     }
-
+    /**
+     * @description:是否有退药权限
+     * @author: lihong
+     * @date: 2023/11/15 10:15
+     **/
+    private boolean isReFrug() {
+        List<Button> buttons = buttonService.queryByUserId(TokenUtil.getUser().getId());
+        return CollUtil.isNotEmpty(buttons)  && (buttons.stream().anyMatch(item->item.getButtonCode().equals(Button.RE_DRUG)));
+    }
 
 
     /**
@@ -279,14 +300,17 @@ public class YpMzFytjController {
                 }
             }
             User tokenUser = TokenUtil.getUser(httpServletRequest);
-            chargeFeeParamsVo.setOpId(tokenUser.getUserIdCode());
+            if(!isReFrug()){
+                chargeFeeParamsVo.setOpId(tokenUser.getUserIdCode());
+            }
             List<YpMzFytj> ypMzFytjList = ypMzFytjService.queryRepealRefund(chargeFeeParamsVo);
             if(ypMzFytjList!=null && ypMzFytjList.size()>0){
+                List<YpZdGroupName> ypZdGroupNames = ypZdGroupNameService.queryAllYpZdGroupName();
                 for (YpMzFytj ypMzFytj:ypMzFytjList){
                     if(ypMzFytj==null || StringUtils.isBlank(ypMzFytj.getGroupNo())){
                         continue;
                     }
-                    YpZdGroupName ypZdGroupName=ypZdGroupNameService.queryByGroupNo(ypMzFytj.getGroupNo());
+                    YpZdGroupName ypZdGroupName = CollUtil.isEmpty(ypZdGroupNames) ? null : ypZdGroupNames.stream().filter(item->item.getGroupNo().trim().equals(ypMzFytj.getGroupNo())).findFirst().get();
                     if(ypZdGroupName==null){
                         ypMzFytj.setGroupNoOut(ypMzFytj.getGroupNo());
                         continue;

+ 4 - 0
src/main/java/cn/hnthyy/thmz/entity/thmz/Button.java

@@ -16,6 +16,10 @@ import java.util.Date;
 public class Button extends PageParams implements Serializable {
 
 	private static final long serialVersionUID =  4998927733722176876L;
+	/**
+	 * 退药code
+	 */
+	public static final String RE_DRUG = "re_drug";
 
 	/**
 	 * 主键

+ 31 - 0
src/main/java/cn/hnthyy/thmz/service/impl/thmz/ButtonServiceImpl.java

@@ -2,18 +2,30 @@ package cn.hnthyy.thmz.service.impl.thmz;
 
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.thmz.Button;
+import cn.hnthyy.thmz.entity.thmz.RoleButtonRelation;
+import cn.hnthyy.thmz.entity.thmz.UserRoleRelation;
 import cn.hnthyy.thmz.mapper.thmz.ButtonMapper;
 import cn.hnthyy.thmz.service.thmz.ButtonService;
+import cn.hnthyy.thmz.service.thmz.RoleButtonRelationService;
+import cn.hnthyy.thmz.service.thmz.UserRoleRelationService;
+import cn.hutool.core.collection.CollUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
+
 @Service
 public class ButtonServiceImpl implements ButtonService {
     @SuppressWarnings("all")
     @Autowired
     private ButtonMapper buttonMapper;
+    @Autowired
+    private RoleButtonRelationService roleButtonRelationService;
+    @Autowired
+    private UserRoleRelationService userRoleRelationService;
     @Override
     public int saveButton(Button button,Long userId) throws MzException {
         Button dbButton =buttonMapper.selectByButtonCode(button.getButtonCode());
@@ -65,4 +77,23 @@ public class ButtonServiceImpl implements ButtonService {
     public int removeButton(Long id) {
         return buttonMapper.deleteButton(id);
     }
+
+    /**
+     * @param id
+     * @description:根据用户id查询按钮权限
+     * @author: lihong
+     * @date: 2023/11/15 10:02
+     * @param: id
+     * @return: java.util.List<cn.hnthyy.thmz.entity.thmz.Button>
+     */
+    @Override
+    public List<Button> queryByUserId(Long id) {
+        List<Button> result = new ArrayList<>();
+        List<UserRoleRelation> userRoleRelations = userRoleRelationService.queryByUserId(id);
+        if (CollUtil.isEmpty(userRoleRelations)) return result;
+        List<RoleButtonRelation> roleButtonRelations = roleButtonRelationService.queryByRoleIds(userRoleRelations.stream().map(item -> item.getRoleId()).collect(Collectors.toList()));
+        if (CollUtil.isEmpty(roleButtonRelations)) return result;
+        result = buttonMapper.selectButtonByIds(roleButtonRelations.stream().map(item -> item.getButtonId()).collect(Collectors.toList()));
+        return result;
+    }
 }

+ 8 - 1
src/main/java/cn/hnthyy/thmz/service/thmz/ButtonService.java

@@ -70,5 +70,12 @@ public interface ButtonService {
      * @return
      */
     int removeButton(Long id);
-
+    /**
+     * @description:根据用户id查询按钮权限
+     * @author: lihong
+     * @date: 2023/11/15 10:02
+     * @param: id
+     * @return: java.util.List<cn.hnthyy.thmz.entity.thmz.Button>
+     **/
+    List<Button> queryByUserId(Long id);
 }