| 
					
				 | 
			
			
				@@ -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; 
			 |