Преглед на файлове

规则维护相关接口

wangfeng преди 4 години
родител
ревизия
04bf01cd26

+ 42 - 0
src/main/java/com/diagbot/dto/KlRuleByIdDTO.java

@@ -0,0 +1,42 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-08 11:13
+ */
+@Setter
+@Getter
+public class KlRuleByIdDTO {
+    private Long ruleId;//规则id
+    private Long parId;
+    private String parDescription;//规则名称
+    private Integer parRuleType;//规则类型(1:开单合理性;2:高危;3:危急值;4:其他值提醒;5:其他值提醒输血;6:正常项目重复开立)
+    private Long parConceptId;//提示概念id
+    private String parlibName;
+    private Integer parHasSub;//是否有子条件(0:无,1:有)
+    private String parMsg;//附加信息
+    private Integer parStatus;//启用状态(0:禁用,1:启用)
+    private String parLenName;
+    private String parLenCode;
+    private Long subId;//基础规则id
+    private String subDescription;//基础规则名称
+    private Long subConceptId;//医学标准术语id
+    private String subLibName;//医学标准术语
+    private String subLenName;//基础规则术语类型
+    private String subLenCode;//基础规则术语编码
+    private Integer subType;//基础规则类型(1:开单外等于术语本身;2:开单外存在比较;3:开单外不等于术语本身;4:过敏原;5:开单项;6:检查结果正则表达式)
+    private Integer groupType;
+    private String subMinOperator;//最小域比较符
+    private String subMinValue;//最小域值
+    private String subMinUnit;//最小域单位
+    private String subMaxOperator;//最大域比较符
+    private String subMaxValue;//最大域值
+    private String subMaxUnit;//最大域单位
+    private String subEqOperator;//等于域比较符
+    private String subEqValue;//等于域值
+    private String subEqUnit;//等于域单位
+}

+ 27 - 0
src/main/java/com/diagbot/dto/KlRuleByIdParDTO.java

@@ -0,0 +1,27 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-08 13:18
+ */
+@Setter
+@Getter
+public class KlRuleByIdParDTO {
+    private Long parId;
+    private String parDescription;//规则名称
+    private Integer parRuleType;//规则类型(1:开单合理性;2:高危;3:危急值;4:其他值提醒;5:其他值提醒输血;6:正常项目重复开立)
+    private Long parConceptId;//提示概念id
+    private String parlibName;
+    private Integer parHasSub;//是否有子条件(0:无,1:有)
+    private String parMsg;//附加信息
+    private Integer parStatus;//启用状态(0:禁用,1:启用)
+    private String parLenName;
+    private String parLenCode;
+    private List<KlRuleByIdSubDTO>  klRuleByIdSub;
+}

+ 31 - 0
src/main/java/com/diagbot/dto/KlRuleByIdSubDTO.java

@@ -0,0 +1,31 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-08 13:16
+ */
+@Setter
+@Getter
+public class KlRuleByIdSubDTO {
+    private Long subId;//基础规则id
+    private String subDescription;//基础规则名称
+    private Long subConceptId;//医学标准术语id
+    private String subLibName;//医学标准术语
+    private String subLenName;//基础规则术语类型
+    private String subLenCode;//基础规则术语编码
+    private Integer subType;//基础规则类型(1:开单外等于术语本身;2:开单外存在比较;3:开单外不等于术语本身;4:过敏原;5:开单项;6:检查结果正则表达式)
+    private Integer groupType;
+    private String subMinOperator;//最小域比较符
+    private String subMinValue;//最小域值
+    private String subMinUnit;//最小域单位
+    private String subMaxOperator;//最大域比较符
+    private String subMaxValue;//最大域值
+    private String subMaxUnit;//最大域单位
+    private String subEqOperator;//等于域比较符
+    private String subEqValue;//等于域值
+    private String subEqUnit;//等于域单位
+}

+ 67 - 0
src/main/java/com/diagbot/dto/KlRuleInfoDTO.java

@@ -0,0 +1,67 @@
+package com.diagbot.dto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-05 13:44
+ */
+@Setter
+@Getter
+public class KlRuleInfoDTO {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 提示概念id
+     */
+    private Long conceptId;
+
+    private String conceptName;
+
+
+    private String libTypeName;
+    /**
+     * 描述
+     */
+    private String description;
+
+    /**
+     * 规则类型(1:开单合理性;2:高危;3:危急值;4:其他值提醒;5:其他值提醒输血;6:正常项目重复开立)
+     */
+    private Integer ruleType;
+
+    /**
+     * 是否有子条件(0:无,1:有)
+     */
+    private Integer hasSubCond;
+
+    /**
+     * 启用状态(0:禁用,1:启用)
+     */
+    private Integer status;
+
+    /**
+     * 附加信息
+     */
+    private String msg;
+}

+ 24 - 0
src/main/java/com/diagbot/facade/KlRuleBaseFacade.java

@@ -0,0 +1,24 @@
+package com.diagbot.facade;
+
+import com.diagbot.entity.KlRuleBase;
+import com.diagbot.service.KlRuleBaseService;
+import com.diagbot.service.impl.KlRuleBaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-08 14:00
+ */
+@Component
+public class KlRuleBaseFacade extends KlRuleBaseServiceImpl {
+    @Autowired
+    KlRuleBaseService klRuleBaseService;
+
+    public boolean saveBatchAll(List<KlRuleBase> klRuleBaseList) {
+        return klRuleBaseService.saveBatch(klRuleBaseList);
+    }
+}

+ 25 - 0
src/main/java/com/diagbot/facade/KlRuleConditionFacade.java

@@ -0,0 +1,25 @@
+package com.diagbot.facade;
+
+import com.diagbot.entity.KlRuleCondition;
+import com.diagbot.service.KlRuleConditionService;
+import com.diagbot.service.impl.KlRuleConditionServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-08 13:53
+ */
+@Component
+public class KlRuleConditionFacade extends KlRuleConditionServiceImpl {
+    @Autowired
+    KlRuleConditionService klRuleConditionService;
+
+
+    public boolean saveBatchAll(List<KlRuleCondition> klRuleConditionList){
+        return klRuleConditionService.saveBatch(klRuleConditionList);
+    }
+}

+ 200 - 0
src/main/java/com/diagbot/facade/KlRuleFacade.java

@@ -1,8 +1,35 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.KlRuleByIdDTO;
+import com.diagbot.dto.KlRuleByIdParDTO;
+import com.diagbot.dto.KlRuleByIdSubDTO;
+import com.diagbot.dto.KlRuleInfoDTO;
+import com.diagbot.entity.KlRule;
+import com.diagbot.entity.KlRuleBase;
+import com.diagbot.entity.KlRuleCondition;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.KlRuleServiceImpl;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
+import com.diagbot.vo.KlRuleByIdVO;
+import com.diagbot.vo.KlRuleInfoClearVO;
+import com.diagbot.vo.KlRuleInfoSaveSubVO;
+import com.diagbot.vo.KlRuleInfoSaveVO;
+import com.diagbot.vo.KlRuleInfoVO;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
 /**
  * @Description:
  * @author: gaodm
@@ -10,4 +37,177 @@ import org.springframework.stereotype.Component;
  */
 @Component
 public class KlRuleFacade extends KlRuleServiceImpl {
+    @Autowired
+    KlRuleConditionFacade klRuleConditionFacade;
+    @Autowired
+    KlRuleBaseFacade klRuleBaseFacade;
+
+    /**
+     * @param klRuleInfoVO
+     * @return
+     */
+    public IPage<KlRuleInfoDTO> getKlRuleInfoPage(KlRuleInfoVO klRuleInfoVO) {
+        return this.getKlRuleInfoPages(klRuleInfoVO);
+    }
+
+    public KlRuleByIdParDTO getByIdRuleInfos(KlRuleByIdVO klRuleByIdVO) {
+        KlRuleByIdParDTO klRuleByIdPar = new KlRuleByIdParDTO();
+        List<KlRuleByIdSubDTO> klRuleByIdSubLsit = new ArrayList<>();
+        List<KlRuleByIdDTO> byIdRuleInfo = this.getByIdRuleInfo(klRuleByIdVO);
+        if (ListUtil.isNotEmpty(byIdRuleInfo)) {
+            klRuleByIdPar.setParId(byIdRuleInfo.get(0).getParId());
+            klRuleByIdPar.setParDescription(byIdRuleInfo.get(0).getParDescription());
+            klRuleByIdPar.setParRuleType(byIdRuleInfo.get(0).getParRuleType());
+            klRuleByIdPar.setParConceptId(byIdRuleInfo.get(0).getParConceptId());
+            klRuleByIdPar.setParlibName(byIdRuleInfo.get(0).getParlibName());
+            klRuleByIdPar.setParHasSub(byIdRuleInfo.get(0).getParHasSub());//是否有子条件(0:无,1:有)
+            klRuleByIdPar.setParMsg(byIdRuleInfo.get(0).getParMsg());//附加信息
+            klRuleByIdPar.setParStatus(byIdRuleInfo.get(0).getParStatus());//启用状态(0:禁用,1:启用)
+            klRuleByIdPar.setParLenName(byIdRuleInfo.get(0).getParLenName());
+            klRuleByIdPar.setParLenCode(byIdRuleInfo.get(0).getParLenCode());
+            for (KlRuleByIdDTO data : byIdRuleInfo) {
+                if (null != data.getSubDescription()) {
+                    KlRuleByIdSubDTO klRuleByIdSub = new KlRuleByIdSubDTO();
+                    BeanUtil.copyProperties(data, klRuleByIdSub);
+                    klRuleByIdSubLsit.add(klRuleByIdSub);
+                }
+            }
+        }
+        klRuleByIdPar.setKlRuleByIdSub(klRuleByIdSubLsit);
+        return klRuleByIdPar;
+    }
+
+    public Boolean saveRuleInfos(KlRuleInfoSaveVO klRuleInfoSaveVO) {
+        Date now = DateUtil.now();
+        boolean res = false;
+        // 校验名称是否相同
+        int count = this.count(new QueryWrapper<KlRule>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("description", klRuleInfoSaveVO.getParDescription())
+                .ne("id", klRuleInfoSaveVO.getId() == null ? -1 : klRuleInfoSaveVO.getId()));
+        if (count > 0) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该规则名称已存在");
+        }
+        //校验数据是否还在
+        if (null != klRuleInfoSaveVO.getId()) {
+            int sum = this.count(new QueryWrapper<KlRule>().eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("id", klRuleInfoSaveVO.getId()));
+            if (sum == 0) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该数据已不存在!");
+            }
+            UpdateWrapper<KlRule> klRuleUpdate = new UpdateWrapper<>();
+            klRuleUpdate.eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("id", klRuleInfoSaveVO.getId())
+                    .set(StringUtil.isNotBlank(klRuleInfoSaveVO.getParDescription()), "description", klRuleInfoSaveVO.getParDescription())
+                    .set(StringUtil.isNotBlank(klRuleInfoSaveVO.getParConceptId().toString()), "concept_id", klRuleInfoSaveVO.getParConceptId())
+                    .set(StringUtil.isNotBlank(klRuleInfoSaveVO.getParRuleType().toString()), "rule_type", klRuleInfoSaveVO.getParRuleType())
+                    .set(StringUtil.isNotBlank(klRuleInfoSaveVO.getParHasSub().toString()), "has_sub_cond", klRuleInfoSaveVO.getParHasSub())
+                    .set(StringUtil.isNotBlank(klRuleInfoSaveVO.getParStatus().toString()), "status", klRuleInfoSaveVO.getParStatus())
+                    .set(StringUtil.isNotBlank(klRuleInfoSaveVO.getParMsg()), "msg", klRuleInfoSaveVO.getParMsg())
+                    .set("gmt_modified", now);
+            res = this.update(klRuleUpdate);
+
+            //先删除原有的详情;
+            res = clearSub(klRuleInfoSaveVO.getId());
+            if (ListUtil.isNotEmpty(klRuleInfoSaveVO.getKlRuleInfoSaveSub())) {
+                //再重新传入的详情保存
+                res = saveCommon(klRuleInfoSaveVO);
+            }
+        } else {
+            //先保存主表rule
+            KlRule klRule = new KlRule();
+            klRule.setConceptId(klRuleInfoSaveVO.getParConceptId());
+            klRule.setDescription(klRuleInfoSaveVO.getParDescription());
+            klRule.setHasSubCond(klRuleInfoSaveVO.getParHasSub());
+            klRule.setRuleType(klRuleInfoSaveVO.getParRuleType());
+            klRule.setMsg(klRuleInfoSaveVO.getParMsg());
+            klRule.setStatus(klRuleInfoSaveVO.getParStatus());
+            klRule.setGmtCreate(now);
+            res = this.save(klRule);
+            if (res) {
+                //再保存附表
+                klRuleInfoSaveVO.setId(klRule.getId());
+                res = saveCommon(klRuleInfoSaveVO);
+            }
+        }
+
+        return res;
+    }
+
+
+    public Boolean clearRuleInfos(KlRuleInfoClearVO klRuleInfoClearVO) {
+        boolean res = false;
+        res = clearSub(klRuleInfoClearVO.getId());
+        //最后删除主表rule
+        res = this.removeById(klRuleInfoClearVO.getId());
+        return res;
+    }
+
+    /**
+     * 删除明细表
+     */
+    public boolean clearSub(Long id) {
+        boolean res = false;
+        QueryWrapper<KlRuleCondition> klRuleConditionQuery = new QueryWrapper<>();
+        klRuleConditionQuery.eq("is_deleted", IsDeleteEnum.N.getKey()).eq("rule_id", id);
+        List<KlRuleCondition> ruleConditionList = klRuleConditionFacade.list(klRuleConditionQuery);
+        List<Long> ruleBaseId = new ArrayList<>();
+        if (ListUtil.isNotEmpty(ruleConditionList)) {
+            for (KlRuleCondition data : ruleConditionList) {
+                ruleBaseId.add(data.getId());
+            }
+        }
+        if (ListUtil.isNotEmpty(ruleBaseId)) {
+            QueryWrapper<KlRuleBase> klRuleBaseQuery = new QueryWrapper<>();
+            klRuleBaseQuery.eq("is_deleted", IsDeleteEnum.N.getKey()).in("id", ruleBaseId);
+            //删除kl_rule_base表数据
+            res = klRuleBaseFacade.remove(klRuleBaseQuery);
+
+        }
+        //删除kl_rule_condition表的数据
+        res = klRuleConditionFacade.remove(klRuleConditionQuery);
+        return res;
+    }
+
+    /**
+     * 保存数据
+     */
+    public boolean saveCommon(KlRuleInfoSaveVO klRuleInfoSaveVO) {
+        boolean res = false;
+        List<KlRuleInfoSaveSubVO> klRuleInfoSaveSub = klRuleInfoSaveVO.getKlRuleInfoSaveSub();
+        //先保存数据到kl_rule_base表里
+        List<KlRuleBase> klRuleBaseList = new ArrayList<>();
+        for (KlRuleInfoSaveSubVO list : klRuleInfoSaveSub) {
+            KlRuleBase klRuleBase = new KlRuleBase();
+            klRuleBase.setConceptId(list.getSubConceptId());
+            klRuleBase.setType(list.getSubType());
+            klRuleBase.setDescription(list.getSubDescription());
+            klRuleBase.setMaxOperator(list.getSubMaxOperator());
+            klRuleBase.setMaxValue(list.getSubMaxValue());
+            klRuleBase.setMaxUnit(list.getSubMaxUnit());
+            klRuleBase.setMinOperator(list.getSubMinOperator());
+            klRuleBase.setMinValue(list.getSubMinValue());
+            klRuleBase.setMinUnit(list.getSubMinUnit());
+            klRuleBase.setStatus(1);
+            klRuleBase.setEqValue(list.getSubEqValue());
+            klRuleBase.setEqOperator(list.getSubEqOperator());
+            klRuleBase.setEqUnit(list.getSubEqUnit());
+            klRuleBaseList.add(klRuleBase);
+        }
+        res = klRuleBaseFacade.saveBatchAll(klRuleBaseList);
+        List<KlRuleCondition> klRuleConditionList = new ArrayList<>();
+        for (KlRuleBase data1 : klRuleBaseList) {
+            for (KlRuleInfoSaveSubVO data2 : klRuleInfoSaveSub) {
+                KlRuleCondition klRuleCondition = new KlRuleCondition();
+                if (data1.getDescription().equals(data2.getSubDescription())) {
+                    klRuleCondition.setGroupType(data2.getGroupType());
+                    klRuleCondition.setRuleBaseId(data1.getId());
+                    klRuleCondition.setRuleId(klRuleInfoSaveVO.getId());
+                    klRuleConditionList.add(klRuleCondition);
+                }
+            }
+        }
+        res = klRuleConditionFacade.saveBatchAll(klRuleConditionList);
+        return res;
+    }
 }

+ 8 - 0
src/main/java/com/diagbot/mapper/KlRuleMapper.java

@@ -1,8 +1,13 @@
 package com.diagbot.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.KlRuleByIdDTO;
+import com.diagbot.dto.KlRuleInfoDTO;
 import com.diagbot.dto.RuleDTO;
 import com.diagbot.entity.KlRule;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.vo.KlRuleByIdVO;
+import com.diagbot.vo.KlRuleInfoVO;
 
 import java.util.List;
 
@@ -18,4 +23,7 @@ public interface KlRuleMapper extends BaseMapper<KlRule> {
 
     List<RuleDTO> getAllRule();
 
+    IPage<KlRuleInfoDTO> getKlRuleInfoPage(KlRuleInfoVO klRuleInfoVO);
+
+    List<KlRuleByIdDTO> getByIdRuleInfo(KlRuleByIdVO klRuleByIdVO);
 }

+ 10 - 0
src/main/java/com/diagbot/service/KlRuleService.java

@@ -1,8 +1,16 @@
 package com.diagbot.service;
 
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.KlRuleByIdDTO;
+import com.diagbot.dto.KlRuleInfoDTO;
 import com.diagbot.dto.RuleDTO;
 import com.diagbot.entity.KlRule;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.vo.KlRuleByIdVO;
+import com.diagbot.vo.KlRuleInfoVO;
 
 import java.util.List;
 
@@ -16,4 +24,6 @@ import java.util.List;
  */
 public interface KlRuleService extends IService<KlRule> {
     List<RuleDTO> getAllRule();
+    IPage<KlRuleInfoDTO> getKlRuleInfoPages(KlRuleInfoVO klRuleInfoVO);
+    List<KlRuleByIdDTO> getByIdRuleInfo(KlRuleByIdVO klRuleByIdVO);
 }

+ 17 - 1
src/main/java/com/diagbot/service/impl/KlRuleServiceImpl.java

@@ -1,17 +1,23 @@
 package com.diagbot.service.impl;
 
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.KlRuleByIdDTO;
+import com.diagbot.dto.KlRuleInfoDTO;
 import com.diagbot.dto.RuleDTO;
 import com.diagbot.entity.KlRule;
 import com.diagbot.mapper.KlRuleMapper;
 import com.diagbot.service.KlRuleService;
+import com.diagbot.vo.KlRuleByIdVO;
+import com.diagbot.vo.KlRuleInfoVO;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
 
 /**
  * <p>
- * 规则信息表 服务实现
+ * 规则信息表 服务类
  * </p>
  *
  * @author gaodm
@@ -22,4 +28,14 @@ public class KlRuleServiceImpl extends ServiceImpl<KlRuleMapper, KlRule> impleme
     public List<RuleDTO> getAllRule() {
         return baseMapper.getAllRule();
     }
+
+    @Override
+    public IPage<KlRuleInfoDTO> getKlRuleInfoPages(KlRuleInfoVO klRuleInfoVO) {
+        return baseMapper.getKlRuleInfoPage(klRuleInfoVO);
+    }
+
+    @Override
+    public List<KlRuleByIdDTO> getByIdRuleInfo(KlRuleByIdVO klRuleByIdVO) {
+        return baseMapper.getByIdRuleInfo(klRuleByIdVO);
+    }
 }

+ 18 - 0
src/main/java/com/diagbot/vo/KlRuleByIdVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-08 11:11
+ */
+@Setter
+@Getter
+public class KlRuleByIdVO {
+    @NotNull(message = "请输id")
+    private Long id;
+}

+ 18 - 0
src/main/java/com/diagbot/vo/KlRuleInfoClearVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-08 13:46
+ */
+@Setter
+@Getter
+public class KlRuleInfoClearVO {
+    @NotNull(message = "请输id")
+    private Long id;
+}

+ 30 - 0
src/main/java/com/diagbot/vo/KlRuleInfoSaveSubVO.java

@@ -0,0 +1,30 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-08 13:38
+ */
+@Setter
+@Getter
+public class KlRuleInfoSaveSubVO {
+    private String subDescription;//基础规则名称
+    private Long subConceptId;//医学标准术语id
+/*    private String subLibName;//医学标准术语
+    private String subLenName;//基础规则术语类型
+    private String subLenCode;//基础规则术语编码*/
+    private Integer subType;//基础规则类型(1:开单外等于术语本身;2:开单外存在比较;3:开单外不等于术语本身;4:过敏原;5:开单项;6:检查结果正则表达式)
+    private Integer groupType;
+    private String subMinOperator;//最小域比较符
+    private String subMinValue;//最小域值
+    private String subMinUnit;//最小域单位
+    private String subMaxOperator;//最大域比较符
+    private String subMaxValue;//最大域值
+    private String subMaxUnit;//最大域单位
+    private String subEqOperator;//等于域比较符
+    private String subEqValue;//等于域值
+    private String subEqUnit;//等于域单位
+}

+ 28 - 0
src/main/java/com/diagbot/vo/KlRuleInfoSaveVO.java

@@ -0,0 +1,28 @@
+package com.diagbot.vo;
+
+import com.diagbot.dto.KlRuleByIdSubDTO;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-08 13:37
+ */
+@Setter
+@Getter
+public class KlRuleInfoSaveVO {
+    private Long id;
+    private String parDescription;//规则名称
+    private Integer parRuleType;//规则类型(1:开单合理性;2:高危;3:危急值;4:其他值提醒;5:其他值提醒输血;6:正常项目重复开立)
+    private Long parConceptId;//提示概念id
+    private Integer parHasSub;//是否有子条件(0:无,1:有)
+    private String parMsg;//附加信息
+    private Integer parStatus;//启用状态(0:禁用,1:启用)
+/*    private String parlibName;
+    private String parLenName;
+    private String parLenCode;*/
+    private List<KlRuleInfoSaveSubVO> klRuleInfoSaveSub;
+}

+ 30 - 0
src/main/java/com/diagbot/vo/KlRuleInfoVO.java

@@ -0,0 +1,30 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-05 13:44
+ */
+@Setter
+@Getter
+public class KlRuleInfoVO extends Page {
+    /**
+     * 描述
+     */
+    private String description;
+    /**
+     * 规则类型(1:开单合理性;2:高危;3:危急值;4:其他值提醒;5:其他值提醒输血;6:正常项目重复开立)
+     */
+    private Integer ruleType;
+
+    private String conceptName;
+    /**
+     * 启用状态(0:禁用,1:启用)
+     */
+    private Integer status;
+
+}

+ 20 - 0
src/main/java/com/diagbot/web/KlRuleBaseController.java

@@ -0,0 +1,20 @@
+package com.diagbot.web;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ * 规则基础表 前端控制器
+ * </p>
+ *
+ * @author gaodm
+ * @since 2021-03-05
+ */
+@Controller
+@RequestMapping("/klRuleBase")
+public class KlRuleBaseController {
+
+}

+ 20 - 0
src/main/java/com/diagbot/web/KlRuleConditionController.java

@@ -0,0 +1,20 @@
+package com.diagbot.web;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ * 规则条件表 前端控制器
+ * </p>
+ *
+ * @author gaodm
+ * @since 2021-03-05
+ */
+@Controller
+@RequestMapping("/klRuleCondition")
+public class KlRuleConditionController {
+
+}

+ 73 - 0
src/main/java/com/diagbot/web/KlRuleController.java

@@ -0,0 +1,73 @@
+package com.diagbot.web;
+
+
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.KlRuleByIdParDTO;
+import com.diagbot.dto.KlRuleInfoDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.KlRuleFacade;
+import com.diagbot.vo.KlRuleByIdVO;
+import com.diagbot.vo.KlRuleInfoClearVO;
+import com.diagbot.vo.KlRuleInfoSaveVO;
+import com.diagbot.vo.KlRuleInfoVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+
+/**
+ * <p>
+ * 规则信息表 前端控制器
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2021-03-05
+ */
+@RestController
+@RequestMapping("/klRule")
+@Api(value = "规则维护相关API", tags = { "规则维护相关API" })
+@SuppressWarnings("unchecked")
+public class KlRuleController {
+
+    @Autowired
+    KlRuleFacade klRuleFacade;
+
+    @ApiOperation(value = "分页获取规则维护列表[by:wangfeng]")
+    @PostMapping("/getKlRuleInfoPage")
+    @SysLogger("getKlRuleInfoPage")
+    public RespDTO<IPage<KlRuleInfoDTO>> getKlRuleInfoPages(@RequestBody KlRuleInfoVO klRuleInfoVO) {
+        return RespDTO.onSuc(klRuleFacade.getKlRuleInfoPage(klRuleInfoVO));
+    }
+
+    @ApiOperation(value = "根据规则Id获取规则详情[by:wangfeng]")
+    @PostMapping("/getByIdRuleInfo")
+    @SysLogger("getByIdRuleInfo")
+    public RespDTO<KlRuleByIdParDTO> getByIdRuleInfoAll(@RequestBody @Valid KlRuleByIdVO klRuleByIdVO) {
+        return RespDTO.onSuc(klRuleFacade.getByIdRuleInfos(klRuleByIdVO));
+    }
+
+    @ApiOperation(value = "保存规则详情[by:wangfeng]")
+    @PostMapping("/saveRuleInfo")
+    @SysLogger("saveRuleInfo")
+    @Transactional
+    public RespDTO<Boolean> saveRuleInfoAll(@RequestBody @Valid KlRuleInfoSaveVO klRuleInfoSaveVO) {
+        return RespDTO.onSuc(klRuleFacade.saveRuleInfos(klRuleInfoSaveVO));
+    }
+
+    @ApiOperation(value = "刪除规则详情[by:wangfeng]")
+    @PostMapping("/clearRuleInfo")
+    @SysLogger("clearRuleInfo")
+    @Transactional
+    public RespDTO<Boolean> clearRuleInfoAll(@RequestBody @Valid KlRuleInfoClearVO klRuleInfoClearVO) {
+        return RespDTO.onSuc(klRuleFacade.clearRuleInfos(klRuleInfoClearVO));
+    }
+
+}

+ 102 - 2
src/main/resources/mapper/KlRuleMapper.xml

@@ -24,7 +24,7 @@
         <collection property="ruleConditionDTOList" ofType="com.diagbot.dto.RuleConditionDTO">
             <result column="hasSubCond" property="hasSubCond"/>
             <result column="ruleGroup" property="ruleGroup"/>
-			<result column="msg" property="msg"/>
+            <result column="msg" property="msg"/>
             <collection property="ruleBaseDTOList" ofType="com.diagbot.dto.RuleBaseDTO">
                 <result column="baseLibName" property="baseLibName"/>
                 <result column="baseLibType" property="baseLibType"/>
@@ -125,5 +125,105 @@
 			t10.ruleType,
 			t10.ruleGroup
     </select>
-
+    <select id="getKlRuleInfoPage" resultType="com.diagbot.dto.KlRuleInfoDTO">
+        SELECT
+        ru.id as id,
+        ru.description as description,
+        ru.rule_type as ruleType,
+        ru.concept_id as conceptId,
+        co.lib_name as conceptName,
+        le.name as libTypeName,
+        ru.has_sub_cond as hasSubCond,
+        ru.msg as msg,
+        ru.status as status,
+        ru.gmt_modified as gmtModified,
+        ru.modifier as modifier
+        FROM
+        kl_rule ru,
+        kl_concept co,
+        kl_lexicon le
+        WHERE ru.is_deleted = 'N'
+        AND co.is_deleted = 'N'
+        AND le.is_deleted = 'N'
+        AND ru.concept_id = co.`id`
+        AND co.lib_type = le.`code`
+        <if test="description!=null and description!=''">
+            AND UPPER(ru.description) LIKE CONCAT('%', UPPER(trim(#{description})), '%')
+        </if>
+        <if test="ruleType !=null">
+            AND ru.rule_type = #{ruleType}
+        </if>
+        <if test="conceptName!=null and conceptName!=''">
+            AND UPPER(co.lib_name) LIKE CONCAT('%', UPPER(trim(#{conceptName})), '%')
+        </if>
+        <if test="status!=null">
+            AND ru.status = #{status}
+        </if>
+        ORDER BY ru.gmt_modified DESC
+    </select>
+    <select id="getByIdRuleInfo" resultType="com.diagbot.dto.KlRuleByIdDTO">
+        SELECT
+        par.*,
+        CASE
+        WHEN ISNULL(ruco.rule_id)
+        THEN par.parId
+        ELSE ruco.rule_id
+        END AS ruleId,
+        sub.*,
+        ruco.group_type AS groupType
+        FROM
+        (SELECT
+        a.id AS parId,
+        a.description AS parDescription,
+        a.rule_type AS parRuleType,
+        a.concept_id AS parconceptId,
+        b.lib_name AS parlibName,
+        a.has_sub_cond AS parHasSub,
+        a.msg AS parMsg,
+        a.status AS parStatus,
+        c.name AS parLenName,
+        c.code AS parLenCode
+        FROM
+        kl_rule a,
+        kl_concept b,
+        kl_lexicon c
+        WHERE a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.concept_id = b.id
+        <if test="id != null">
+            and a.id = #{id}
+        </if>
+        AND b.lib_type = c.code) par
+        LEFT JOIN kl_rule_condition ruco
+        ON par.parId = ruco.rule_id
+        LEFT JOIN
+        (SELECT
+        c.id AS subId,
+        c.description AS subDescription,
+        c.concept_id AS subConceptId,
+        d.lib_name AS subLibName,
+        f.name AS subLenName,
+        f.code AS subLenCode,
+        c.type AS subType,
+        c.min_operator AS subMinOperator,
+        c.min_value AS subMinValue,
+        c.min_unit AS subMinUnit,
+        c.max_operator AS subMaxOperator,
+        c.max_value AS subMaxValue,
+        c.max_unit AS subMaxUnit,
+        c.eq_operator AS subEqOperator,
+        c.eq_value AS subEqValue,
+        c.eq_unit AS subEqUnit
+        FROM
+        kl_rule_base c,
+        kl_concept d,
+        kl_lexicon f
+        WHERE c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND f.is_deleted = 'N'
+        AND c.concept_id = d.id
+        AND d.lib_type = f.code) sub
+        ON sub.subId = ruco.rule_base_id
+    </select>
 </mapper>