|  | @@ -13,6 +13,7 @@ import thyyxxk.webserver.config.exception.BizException;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.config.exception.ExceptionEnum;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.entity.ResultVo;
 | 
	
		
			
				|  |  | +import thyyxxk.webserver.entity.RoleCode;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.entity.datamodify.YzActOrder;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.entity.zhuyuanyisheng.ZyOrderZk;
 | 
	
	
		
			
				|  | @@ -691,7 +692,9 @@ public class YiZhuLuRuServer {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public ResultVo<String> baoCunMuBan(YzOrderPattern param) {
 | 
	
		
			
				|  |  |          YzOrderPattern yzOrderPattern;
 | 
	
		
			
				|  |  | -        if ("3".equals(param.getInputType())) {
 | 
	
		
			
				|  |  | +        if (StringUtil.notBlank(param.getPatternCode())) {
 | 
	
		
			
				|  |  | +            yzOrderPattern = dao.getDataAccordingToTemplateCode(param.getPatternCode(), TokenUtil.getTokenUserId());
 | 
	
		
			
				|  |  | +        } else if ("3".equals(param.getInputType())) {
 | 
	
		
			
				|  |  |              yzOrderPattern = dao.yuanLaiDeMuBanBianMa(param.getPatternName(), TokenUtil.getTokenUserId());
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              yzOrderPattern = dao.gongGongMuBan(param.getPatternName());
 | 
	
	
		
			
				|  | @@ -708,10 +711,10 @@ public class YiZhuLuRuServer {
 | 
	
		
			
				|  |  |          log.info("data:{}", JSON.toJSONString(yzOrderPattern));
 | 
	
		
			
				|  |  |          String patternCode = yzOrderPattern.getPatternCode();
 | 
	
		
			
				|  |  |          if (StringUtil.notBlank(patternCode) && !param.getQingZhiTiHuan()) {
 | 
	
		
			
				|  |  | -            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "模板名重复。是否替换:【900】");
 | 
	
		
			
				|  |  | +            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "模板名重复,是否替换:【900】");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (StringUtil.notBlank(patternCode)) {
 | 
	
		
			
				|  |  | -            // 更新的时候先删除模板
 | 
	
		
			
				|  |  | +            // 更新的时候先删除模板 原来的模板
 | 
	
		
			
				|  |  |              dao.shanChuLaoMuBan(patternCode);
 | 
	
		
			
				|  |  |              param.setPatternCode(patternCode);
 | 
	
		
			
				|  |  |          } else {
 | 
	
	
		
			
				|  | @@ -756,26 +759,52 @@ public class YiZhuLuRuServer {
 | 
	
		
			
				|  |  |          if (yzOrderPattern == null) {
 | 
	
		
			
				|  |  |              return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到对应的模板信息。");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        String inputId = TokenUtil.getTokenUserId();
 | 
	
		
			
				|  |  | +        String userId = TokenUtil.getTokenUserId();
 | 
	
		
			
				|  |  |          List<Integer> role = publicServer.getRoleCode().getData();
 | 
	
		
			
				|  |  | -        if (publicServer.noNeedRule(role, 43)) {
 | 
	
		
			
				|  |  | -            if (inputId.equals(yzOrderPattern.getInputId().trim())) {
 | 
	
		
			
				|  |  | -                // 删除父模板以及下面的子模板 数据
 | 
	
		
			
				|  |  | -                dao.shanChuMuBan(yzOrderPattern.getPatternCode());
 | 
	
		
			
				|  |  | -                return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "删除成功。");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            // 11 是科室主任, 主任可以删除本科室的模板
 | 
	
		
			
				|  |  | -            if (publicServer.needRule(11) && "2".equals(yzOrderPattern.getInputType())) {
 | 
	
		
			
				|  |  | -                if (dao.userDeptCode(inputId).equals(yzOrderPattern.getDeptCode())) {
 | 
	
		
			
				|  |  | -                    dao.shanChuMuBan(yzOrderPattern.getPatternCode());
 | 
	
		
			
				|  |  | -                    return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "删除成功。");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您没有权限删除这个模板。");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +        if (publicServer.needRule(role, RoleCode.PHYSICIAN_S_ORDER_TEMPLATEEDIT)) {
 | 
	
		
			
				|  |  | +            return startDeletingTemplates(patternCode);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        if (userId.equals(yzOrderPattern.getInputId())) {
 | 
	
		
			
				|  |  | +            return startDeletingTemplates(patternCode);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //   主任可以删除本科室的任意模板
 | 
	
		
			
				|  |  | +        if (publicServer.needRule(role, RoleCode.DIRECTOR) && dao.userDeptCode(userId).equals(yzOrderPattern.getDeptCode())) {
 | 
	
		
			
				|  |  | +            return startDeletingTemplates(patternCode);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您没有权限删除这个模板。");
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 删除父模板以及下面的子模板 数据
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param patternCode 模板编码
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private ResultVo<String> startDeletingTemplates(String patternCode) {
 | 
	
		
			
				|  |  | +        dao.shanChuMuBan(patternCode);
 | 
	
		
			
				|  |  |          log.info("删除医嘱模板==> 操作人:{},模板编码:{}", TokenUtil.getTokenUserId(), patternCode);
 | 
	
		
			
				|  |  | -        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
 | 
	
		
			
				|  |  | +        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "删除成功。");
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 收藏医嘱模板或者取消收藏
 | 
	
		
			
				|  |  | +     * 如果以及收藏了就删除,没有就收藏
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param patternCode 模板号
 | 
	
		
			
				|  |  | +     * @return 提示
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public ResultVo<String> collectDoctorSOrderTemplate(String patternCode) {
 | 
	
		
			
				|  |  | +        String userId = TokenUtil.getTokenUserId();
 | 
	
		
			
				|  |  | +        String saveTheDoctorSOrderNumber = dao.whetherToSaveTheDoctorSOrderTemplate(patternCode, userId);
 | 
	
		
			
				|  |  | +        if (StringUtil.notBlank(saveTheDoctorSOrderNumber)) {
 | 
	
		
			
				|  |  | +            dao.shanChuMuBan(saveTheDoctorSOrderNumber);
 | 
	
		
			
				|  |  | +            return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "已取消删除。");
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            YzOrderPattern yzOrderPattern = dao.huoQuMuBanXinXi(patternCode);
 | 
	
		
			
				|  |  | +            EntityStringTrim.beanAttributeValueTrim(yzOrderPattern);
 | 
	
		
			
				|  |  | +            dao.chaRuShouCang(publicServer.getPatternCode(), yzOrderPattern.getPatternName() + "(收藏)",
 | 
	
		
			
				|  |  | +                    yzOrderPattern.getPyCode(), yzOrderPattern.getDCode(), dao.userDeptCode(userId), userId, yzOrderPattern.getPatternCode());
 | 
	
		
			
				|  |  | +            return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "收藏成功。");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 |