瀏覽代碼

分页查询有效的规则

gaodm 3 年之前
父節點
當前提交
f971d237b2

+ 24 - 0
src/main/java/com/diagbot/dto/RuleQueryDTO.java

@@ -0,0 +1,24 @@
+package com.diagbot.dto;
+
+import com.diagbot.enums.RuleTypeEnum;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2021/12/30 13:21
+ */
+@Getter
+@Setter
+public class RuleQueryDTO {
+    private String libName;
+    private Integer libType;
+    private String libTypeName;
+    private Integer ruleType;
+    private String ruleTypeName;
+
+    public String getRuleTypeName() {
+        return RuleTypeEnum.getName(ruleType);
+    }
+}

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

@@ -8,10 +8,13 @@ import com.diagbot.dto.KlRuleByIdDTO;
 import com.diagbot.dto.KlRuleByIdParDTO;
 import com.diagbot.dto.KlRuleByIdSubDTO;
 import com.diagbot.dto.KlRuleInfoDTO;
+import com.diagbot.dto.RuleDTO;
+import com.diagbot.dto.RuleQueryDTO;
 import com.diagbot.entity.KlRule;
 import com.diagbot.entity.KlRuleBase;
 import com.diagbot.entity.KlRuleCondition;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.RedisEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.KlRuleServiceImpl;
@@ -19,6 +22,7 @@ import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.ExcelUtils;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.RedisUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.KlRuleByIdVO;
 import com.diagbot.vo.KlRuleInfoClearVO;
@@ -26,6 +30,8 @@ import com.diagbot.vo.KlRuleInfoSaveSubVO;
 import com.diagbot.vo.KlRuleInfoSaveVO;
 import com.diagbot.vo.KlRuleInfoVO;
 import com.diagbot.vo.KlRuleSatartOrdisaVO;
+import com.diagbot.vo.RuleQueryKeyVO;
+import com.diagbot.vo.RuleQueryVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -45,6 +51,8 @@ public class KlRuleFacade extends KlRuleServiceImpl {
     KlRuleConditionFacade klRuleConditionFacade;
     @Autowired
     KlRuleBaseFacade klRuleBaseFacade;
+    @Autowired
+    private RedisUtil redisUtil;
 
     /**
      * @param klRuleInfoVO
@@ -250,4 +258,25 @@ public class KlRuleFacade extends KlRuleServiceImpl {
         ExcelUtils.exportExcel(indicationExportDTOS, null, "开单合理性", IndicationExportDTO.class, "indication.xlsx",
                 response, 12.8f);
     }
+
+    /**
+     * 查询所有有效的规则
+     *
+     * @param ruleQueryVO
+     * @return
+     */
+    public IPage<RuleQueryDTO> getRulePageFac(RuleQueryVO ruleQueryVO) {
+        return this.getRulePage(ruleQueryVO);
+    }
+
+    /**
+     * 根据录入内容查询有效规则的明细
+     *
+     * @param ruleQueryKeyVO
+     * @return
+     */
+    public RuleDTO getRuleDetail(RuleQueryKeyVO ruleQueryKeyVO) {
+        String key = RedisEnum.allRule.getName() + ruleQueryKeyVO.getLibType() + "_" + ruleQueryKeyVO.getLibName() + "_" + ruleQueryKeyVO.getRuleType();
+        return redisUtil.get(key);
+    }
 }

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

@@ -8,10 +8,12 @@ import com.diagbot.dto.RuleBaseInitDTO;
 import com.diagbot.dto.RuleConditionInitDTO;
 import com.diagbot.dto.RuleDTO;
 import com.diagbot.dto.RuleInitDTO;
+import com.diagbot.dto.RuleQueryDTO;
 import com.diagbot.entity.KlRule;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.diagbot.vo.KlRuleByIdVO;
 import com.diagbot.vo.KlRuleInfoVO;
+import com.diagbot.vo.RuleQueryVO;
 
 import java.util.List;
 
@@ -46,4 +48,6 @@ public interface KlRuleMapper extends BaseMapper<KlRule> {
     List<RuleBaseInitDTO> getRuleBaseInitDTONotHaveClass();
 
     List<RuleBaseInitDTO> getRuleBaseInitDTOHaveClass();
+
+    IPage<RuleQueryDTO> getRulePage(RuleQueryVO ruleQueryVO);
 }

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

@@ -9,9 +9,11 @@ import com.diagbot.dto.RuleBaseInitDTO;
 import com.diagbot.dto.RuleConditionInitDTO;
 import com.diagbot.dto.RuleDTO;
 import com.diagbot.dto.RuleInitDTO;
+import com.diagbot.dto.RuleQueryDTO;
 import com.diagbot.entity.KlRule;
 import com.diagbot.vo.KlRuleByIdVO;
 import com.diagbot.vo.KlRuleInfoVO;
+import com.diagbot.vo.RuleQueryVO;
 
 import java.util.List;
 
@@ -42,4 +44,6 @@ public interface KlRuleService extends IService<KlRule> {
     List<RuleBaseInitDTO> getRuleBaseInitDTONotHaveClass();
 
     List<RuleBaseInitDTO> getRuleBaseInitDTOHaveClass();
+
+    IPage<RuleQueryDTO> getRulePage(RuleQueryVO queryVO);
 }

+ 14 - 7
src/main/java/com/diagbot/service/impl/KlRuleServiceImpl.java

@@ -9,11 +9,13 @@ import com.diagbot.dto.RuleBaseInitDTO;
 import com.diagbot.dto.RuleConditionInitDTO;
 import com.diagbot.dto.RuleDTO;
 import com.diagbot.dto.RuleInitDTO;
+import com.diagbot.dto.RuleQueryDTO;
 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 com.diagbot.vo.RuleQueryVO;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -48,38 +50,43 @@ public class KlRuleServiceImpl extends ServiceImpl<KlRuleMapper, KlRule> impleme
     }
 
     @Override
-    public List<RuleInitDTO> getRuleInitDTO(){
+    public List<RuleInitDTO> getRuleInitDTO() {
         return baseMapper.getRuleInitDTO();
     }
 
     @Override
-    public List<RuleConditionInitDTO> getRuleConditionInitDTO(){
+    public List<RuleConditionInitDTO> getRuleConditionInitDTO() {
         return baseMapper.getRuleConditionInitDTO();
     }
 
     @Override
-    public List<RuleBaseInitDTO> getRuleBaseInitDTO(){
+    public List<RuleBaseInitDTO> getRuleBaseInitDTO() {
         return baseMapper.getRuleBaseInitDTO();
     }
 
 
     @Override
-    public List<RuleInitDTO> getRuleInitDTONotHaveClass(){
+    public List<RuleInitDTO> getRuleInitDTONotHaveClass() {
         return baseMapper.getRuleInitDTONotHaveClass();
     }
 
     @Override
-    public List<RuleInitDTO> getRuleInitDTOHaveClass(){
+    public List<RuleInitDTO> getRuleInitDTOHaveClass() {
         return baseMapper.getRuleInitDTOHaveClass();
     }
 
     @Override
-    public List<RuleBaseInitDTO> getRuleBaseInitDTONotHaveClass(){
+    public List<RuleBaseInitDTO> getRuleBaseInitDTONotHaveClass() {
         return baseMapper.getRuleBaseInitDTONotHaveClass();
     }
 
     @Override
-    public List<RuleBaseInitDTO> getRuleBaseInitDTOHaveClass(){
+    public List<RuleBaseInitDTO> getRuleBaseInitDTOHaveClass() {
         return baseMapper.getRuleBaseInitDTOHaveClass();
     }
+
+    @Override
+    public IPage<RuleQueryDTO> getRulePage(RuleQueryVO ruleQueryVO) {
+        return baseMapper.getRulePage(ruleQueryVO);
+    }
 }

+ 23 - 0
src/main/java/com/diagbot/vo/RuleQueryKeyVO.java

@@ -0,0 +1,23 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2021/12/30 13:21
+ */
+@Getter
+@Setter
+public class RuleQueryKeyVO {
+    @NotBlank(message = "医学标准术语不可为空")
+    private String libName;
+    @NotNull(message = "术语类型不可为空")
+    private Integer libType;
+    @NotNull(message = "规则类型不可为空")
+    private Integer ruleType;
+}

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

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2021/12/30 13:21
+ */
+@Getter
+@Setter
+public class RuleQueryVO extends Page {
+    private String libName;
+    private Integer libType;
+    private Integer ruleType;
+}

+ 20 - 2
src/main/java/com/diagbot/web/KlRuleController.java

@@ -6,6 +6,8 @@ import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.KlRuleByIdParDTO;
 import com.diagbot.dto.KlRuleInfoDTO;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.RuleDTO;
+import com.diagbot.dto.RuleQueryDTO;
 import com.diagbot.enums.StatusEnum;
 import com.diagbot.facade.KlRuleFacade;
 import com.diagbot.vo.KlRuleByIdVO;
@@ -13,6 +15,8 @@ import com.diagbot.vo.KlRuleInfoClearVO;
 import com.diagbot.vo.KlRuleInfoSaveVO;
 import com.diagbot.vo.KlRuleInfoVO;
 import com.diagbot.vo.KlRuleSatartOrdisaVO;
+import com.diagbot.vo.RuleQueryKeyVO;
+import com.diagbot.vo.RuleQueryVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -75,14 +79,28 @@ public class KlRuleController {
     @PostMapping("/disableRuleInfo")
     @SysLogger("disableRuleInfo")
     public RespDTO<Boolean> disableRuleInfos(@RequestBody @Valid KlRuleSatartOrdisaVO klRuleSatartOrdisaVO) {
-        return RespDTO.onSuc(klRuleFacade.startOrDisableRule(klRuleSatartOrdisaVO,StatusEnum.Disable.getKey()));
+        return RespDTO.onSuc(klRuleFacade.startOrDisableRule(klRuleSatartOrdisaVO, StatusEnum.Disable.getKey()));
     }
 
     @ApiOperation(value = "启用规则[by:wangfeng]")
     @PostMapping("/startRuleInfo")
     @SysLogger("startRuleInfo")
     public RespDTO<Boolean> startRuleInfos(@RequestBody @Valid KlRuleSatartOrdisaVO klRuleSatartOrdisaVO) {
-        return RespDTO.onSuc(klRuleFacade.startOrDisableRule(klRuleSatartOrdisaVO,StatusEnum.Enable.getKey()));
+        return RespDTO.onSuc(klRuleFacade.startOrDisableRule(klRuleSatartOrdisaVO, StatusEnum.Enable.getKey()));
+    }
+
+    @ApiOperation(value = "查询所有有效的规则[by:gaodm]")
+    @PostMapping("/getRulePage")
+    @SysLogger("getRulePage")
+    public RespDTO<IPage<RuleQueryDTO>> getRulePage(@RequestBody RuleQueryVO ruleQueryVO) {
+        return RespDTO.onSuc(klRuleFacade.getRulePageFac(ruleQueryVO));
+    }
+
+    @ApiOperation(value = "根据录入内容查询有效规则的明细[by:gaodm]")
+    @PostMapping("/getRuleDetail")
+    @SysLogger("getRuleDetail")
+    public RespDTO<RuleDTO> getRuleDetail(@RequestBody @Valid RuleQueryKeyVO ruleQueryKeyVO) {
+        return RespDTO.onSuc(klRuleFacade.getRuleDetail(ruleQueryKeyVO));
     }
 
 }

+ 90 - 0
src/main/resources/mapper/KlRuleMapper.xml

@@ -529,4 +529,94 @@
         AND t10. STATUS = 1
         AND t11. STATUS = 1
     </select>
+
+    <select id="getRulePage" resultType="com.diagbot.dto.RuleQueryDTO" parameterType="com.diagbot.vo.RuleQueryVO">
+        SELECT DISTINCT
+        t12.libName AS libName,
+        t12.libType AS libType,
+        t12.ruleType AS ruleType,
+        t13.`name` AS libTypeName
+        FROM
+        (
+        SELECT
+        t1.concept_id AS conceptId,
+        CONCAT_WS(
+        "_",
+        t1.concept_id,
+        t1.rule_type
+        ) AS conceptGroup,
+        t1.id AS ruleId,
+        t4.lib_name AS libName,
+        t4.lib_type AS libType,
+        t1.rule_type AS ruleType,
+        t1.has_sub_cond AS hasSubCond,
+        t1.description AS description,
+        t1.msg AS msg,
+        t1.gmt_modified AS gmtModified
+        FROM
+        kl_rule t1,
+        kl_concept t4
+        WHERE
+        t1.is_deleted = "N"
+        AND t4.is_deleted = "N"
+        AND t1.concept_id = t4.id
+        AND t1. STATUS = 1
+        AND t4. STATUS = 1
+        AND t4.lib_type BETWEEN 100
+        AND 299
+        UNION
+        SELECT
+        t11.id AS conceptId,
+        CONCAT_WS("_", t11.id, t1.rule_type) AS conceptGroup,
+        t1.id AS ruleId,
+        t11.lib_name AS libName,
+        t11.lib_type AS libType,
+        t1.rule_type AS ruleType,
+        t1.has_sub_cond AS hasSubCond,
+        t1.description AS description,
+        t1.msg AS msg,
+        t1.gmt_modified AS gmtModified
+        FROM
+        kl_rule t1,
+        kl_concept t4,
+        kl_relation t10,
+        kl_concept t11
+        WHERE
+        t1.is_deleted = "N"
+        AND t4.is_deleted = "N"
+        AND t1.concept_id = t4.id
+        AND t1. STATUS = 1
+        AND t4. STATUS = 1
+        AND t4.lib_type BETWEEN 300
+        AND 399
+        AND t10.start_id = t4.id
+        AND t10.relation_id = 600
+        AND t10.end_id = t11.id
+        AND t11.lib_type BETWEEN 100
+        AND 299
+        AND t10.is_deleted = "N"
+        AND t11.is_deleted = "N"
+        AND t10. STATUS = 1
+        AND t11. STATUS = 1
+        ) t12,
+        kl_lexicon t13
+        WHERE
+        t12.libType = t13.`code`
+        AND t13.is_deleted = "N"
+        <if test="libName!=null and libName!=''">
+            AND UPPER(t12.libName) LIKE CONCAT('%', UPPER(trim(#{libName})), '%')
+        </if>
+        <if test="libType !=null">
+            AND t12.libType = #{libType}
+        </if>
+        <if test="ruleType !=null">
+            AND t12.ruleType = #{ruleType}
+        </if>
+        ORDER BY
+        t12.conceptId,
+        t12.ruleType,
+        t12.hasSubCond,
+        t12.gmtModified DESC,
+        t12.ruleId DESC
+    </select>
 </mapper>