|
@@ -3,16 +3,20 @@ 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.IndicationExportDTO;
|
|
|
+import com.diagbot.dto.DefaultExportDTO;
|
|
|
+import com.diagbot.dto.GatherDTO;
|
|
|
+import com.diagbot.dto.IndicationNewExportDTO;
|
|
|
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.dto.OtherExportDTO;
|
|
|
import com.diagbot.entity.KlRule;
|
|
|
import com.diagbot.entity.KlRuleBase;
|
|
|
import com.diagbot.entity.KlRuleCondition;
|
|
|
+import com.diagbot.enums.CommonEnum;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.enums.RedisEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
@@ -21,9 +25,12 @@ import com.diagbot.service.impl.KlRuleServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.ExcelUtils;
|
|
|
+import com.diagbot.util.ExtUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.RedisUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.ExportDafaultVO;
|
|
|
+import com.diagbot.vo.GatherVO;
|
|
|
import com.diagbot.vo.KlRuleByIdVO;
|
|
|
import com.diagbot.vo.KlRuleInfoClearVO;
|
|
|
import com.diagbot.vo.KlRuleInfoSaveSubVO;
|
|
@@ -32,6 +39,8 @@ import com.diagbot.vo.KlRuleInfoVO;
|
|
|
import com.diagbot.vo.KlRuleSatartOrdisaVO;
|
|
|
import com.diagbot.vo.RuleQueryKeyVO;
|
|
|
import com.diagbot.vo.RuleQueryVO;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -39,6 +48,8 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -53,6 +64,8 @@ public class KlRuleFacade extends KlRuleServiceImpl {
|
|
|
KlRuleBaseFacade klRuleBaseFacade;
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
+ @Autowired
|
|
|
+ KlConceptFacade klConceptFacade;
|
|
|
|
|
|
/**
|
|
|
* @param klRuleInfoVO
|
|
@@ -254,11 +267,183 @@ public class KlRuleFacade extends KlRuleServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public void exportIndicationFac(HttpServletResponse response) {
|
|
|
- List<IndicationExportDTO> indicationExportDTOS = exportIndication();
|
|
|
- ExcelUtils.exportExcel(indicationExportDTOS, null, "开单合理性", IndicationExportDTO.class, "indication.xlsx",
|
|
|
+ ExportDafaultVO exportDafaultVO = new ExportDafaultVO();
|
|
|
+ exportDafaultVO.setRuleType(1);
|
|
|
+ List<IndicationNewExportDTO> res = Lists.newArrayList();
|
|
|
+ List<DefaultExportDTO> defaultExportDTOS = exportOther(exportDafaultVO);
|
|
|
+ GatherVO gatherVO = new GatherVO();
|
|
|
+ List<String> gatherNameList = Lists.newArrayList();
|
|
|
+ for (DefaultExportDTO defaultExportDTO : defaultExportDTOS) {
|
|
|
+ // 开单名称集合
|
|
|
+ if (isGatherType(defaultExportDTO.getLibType())) {
|
|
|
+ gatherNameList.add(defaultExportDTO.getLibName() + CommonEnum.splitSymbol.getName() + defaultExportDTO.getLibType());
|
|
|
+ }
|
|
|
+ // 规则集合
|
|
|
+ if (isGatherType(defaultExportDTO.getBaseType())) {
|
|
|
+ gatherNameList.add(defaultExportDTO.getBaseName() + CommonEnum.splitSymbol.getName() + defaultExportDTO.getBaseType());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gatherVO.setGatherNameList(gatherNameList);
|
|
|
+ Map<String, List<GatherDTO>> gatherMap = klConceptFacade.getGatherFac(gatherVO);
|
|
|
+ Map<String, List<DefaultExportDTO>> multiKeyList = ExtUtil.getMultiKeyList(defaultExportDTOS, CommonEnum.splitSymbol.getName(), "ruleId", "groupType");
|
|
|
+ for (String key : multiKeyList.keySet()) {
|
|
|
+ List<DefaultExportDTO> defaultList = multiKeyList.get(key);
|
|
|
+ for (DefaultExportDTO defaultExportDTO : defaultList) {
|
|
|
+ // 集合类型对集合元素赋值
|
|
|
+ if (isGatherType(defaultExportDTO.getBaseType())) {
|
|
|
+ List<GatherDTO> gatherDTOS = gatherMap.get(defaultExportDTO.getBaseName() + CommonEnum.splitSymbol.getName() + defaultExportDTO.getBaseType());
|
|
|
+ List<String> sonNameList = gatherDTOS.stream().map(r -> r.getSonName()).collect(Collectors.toList());
|
|
|
+ // 子元素赋值
|
|
|
+ defaultExportDTO.setSonName(StringUtils.join(sonNameList, CommonEnum.splitSymbol.getName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ DefaultExportDTO defaultExportDTO = defaultList.get(0);
|
|
|
+ IndicationNewExportDTO indicationNewExportDTO = new IndicationNewExportDTO();
|
|
|
+ indicationNewExportDTO.setRuleGroup(defaultExportDTO.getRuleGroup());
|
|
|
+ indicationNewExportDTO.setLibName(defaultExportDTO.getLibName());
|
|
|
+ indicationNewExportDTO.setLibTypeCn(defaultExportDTO.getLibTypeCn());
|
|
|
+ indicationNewExportDTO.setMsg(defaultExportDTO.getMsg());
|
|
|
+ indicationNewExportDTO.setDefaultExportDTOList(defaultList);
|
|
|
+ // 集合类型对集合元素赋值
|
|
|
+ if (isGatherType(defaultExportDTO.getLibType())) {
|
|
|
+ List<GatherDTO> gatherDTOS = gatherMap.get(defaultExportDTO.getLibName() + CommonEnum.splitSymbol.getName() + defaultExportDTO.getLibType());
|
|
|
+ List<String> sonNameList = gatherDTOS.stream().map(r -> r.getSonName()).collect(Collectors.toList());
|
|
|
+ // 子元素赋值
|
|
|
+ indicationNewExportDTO.setSonLibName(StringUtils.join(sonNameList, CommonEnum.splitSymbol.getName()));
|
|
|
+ }
|
|
|
+ res.add(indicationNewExportDTO);
|
|
|
+ }
|
|
|
+ ExcelUtils.exportExcel(res, null, "开单合理性", IndicationNewExportDTO.class, "indication.xlsx",
|
|
|
response, 12.8f);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 是否集合类型
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean isGatherType(Integer type) {
|
|
|
+ if (type == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ((type >= 308 && type <= 329) || (type >= 301 && type <= 304)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 其他值提醒化验导出
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void exportOtherLis(HttpServletResponse response) {
|
|
|
+ ExportDafaultVO exportDafaultVO = new ExportDafaultVO();
|
|
|
+ exportDafaultVO.setRuleType(4);
|
|
|
+ exportDafaultVO.setLibTypeList(Lists.newArrayList(108L));
|
|
|
+ List<OtherExportDTO> otherExportDTOList = generateExport(exportDafaultVO);
|
|
|
+ ExcelUtils.exportExcel(otherExportDTOList, null, "其他值提醒化验", OtherExportDTO.class, "otherLis.xlsx",
|
|
|
+ response, 12.8F);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 其他值提醒辅检导出
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void exportOtherPacs(HttpServletResponse response) {
|
|
|
+ ExportDafaultVO exportDafaultVO = new ExportDafaultVO();
|
|
|
+ exportDafaultVO.setRuleType(4);
|
|
|
+ exportDafaultVO.setLibTypeList(Lists.newArrayList(112L));
|
|
|
+ List<OtherExportDTO> otherExportDTOList = generateExport(exportDafaultVO);
|
|
|
+ ExcelUtils.exportExcel(otherExportDTOList, null, "其他值提醒辅检", OtherExportDTO.class, "otherPacs.xlsx",
|
|
|
+ response, 12.8F);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 其他值提醒输血导出
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void exportOtherTransfusion(HttpServletResponse response) {
|
|
|
+ ExportDafaultVO exportDafaultVO = new ExportDafaultVO();
|
|
|
+ exportDafaultVO.setRuleType(5);
|
|
|
+ exportDafaultVO.setLibTypeList(Lists.newArrayList(108L));
|
|
|
+ List<OtherExportDTO> otherExportDTOList = generateExport(exportDafaultVO);
|
|
|
+ ExcelUtils.exportExcel(otherExportDTOList, null, "其他值提醒输血", OtherExportDTO.class, "otherTransfusion.xlsx",
|
|
|
+ response, 12.8F);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 危急值化验导出
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void exportCriticalLis(HttpServletResponse response) {
|
|
|
+ ExportDafaultVO exportDafaultVO = new ExportDafaultVO();
|
|
|
+ exportDafaultVO.setRuleType(3);
|
|
|
+ exportDafaultVO.setLibTypeList(Lists.newArrayList(108L));
|
|
|
+ List<OtherExportDTO> otherExportDTOList = generateExport(exportDafaultVO);
|
|
|
+ ExcelUtils.exportExcel(otherExportDTOList, null, "危急值化验", OtherExportDTO.class, "criticalLis.xlsx",
|
|
|
+ response, 12.8F);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 危急值辅检导出
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void exportCriticalPacs(HttpServletResponse response) {
|
|
|
+ ExportDafaultVO exportDafaultVO = new ExportDafaultVO();
|
|
|
+ exportDafaultVO.setRuleType(3);
|
|
|
+ exportDafaultVO.setLibTypeList(Lists.newArrayList(112L));
|
|
|
+ List<OtherExportDTO> otherExportDTOList = generateExport(exportDafaultVO);
|
|
|
+ ExcelUtils.exportExcel(otherExportDTOList, null, "危急值辅检", OtherExportDTO.class, "criticalPacs.xlsx",
|
|
|
+ response, 12.8F);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成导出类
|
|
|
+ *
|
|
|
+ * @param exportDafaultVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<OtherExportDTO> generateExport(ExportDafaultVO exportDafaultVO) {
|
|
|
+ // 导出类
|
|
|
+ List<OtherExportDTO> otherExportDTOList = new ArrayList<>();
|
|
|
+ List<DefaultExportDTO> defaultExportDTOS = exportOther(exportDafaultVO);
|
|
|
+ Map<String, List<DefaultExportDTO>> multiKeyList = ExtUtil.getMultiKeyList(defaultExportDTOS, CommonEnum.splitSymbol.getName(), "ruleId", "groupType");
|
|
|
+ for (String key : multiKeyList.keySet()) {
|
|
|
+ List<DefaultExportDTO> defaultList = multiKeyList.get(key);
|
|
|
+ DefaultExportDTO defaultExportDTO = defaultList.get(0);
|
|
|
+ // rule中conceptId也是规则匹配的一部分,手动添加,判断依据是conceptId和baseConcept如果不一样的,就添加一条
|
|
|
+ if (!defaultExportDTO.getConceptId().equals(defaultExportDTO.getBaseConcept())) {
|
|
|
+ DefaultExportDTO addDefault = new DefaultExportDTO();
|
|
|
+ BeanUtil.copyProperties(defaultExportDTO, addDefault);
|
|
|
+ addDefault.setBaseConcept(defaultExportDTO.getConceptId());
|
|
|
+ addDefault.setBaseName(defaultExportDTO.getLibName());
|
|
|
+ addDefault.setBaseTypeCn(defaultExportDTO.getLibTypeCn());
|
|
|
+ addDefault.setMinValue("");
|
|
|
+ addDefault.setMinOperator("");
|
|
|
+ addDefault.setMaxValue("");
|
|
|
+ addDefault.setMaxOperator("");
|
|
|
+ addDefault.setEqValue("");
|
|
|
+ List<DefaultExportDTO> newDefaultList = Lists.newArrayList();
|
|
|
+ newDefaultList.add(addDefault);
|
|
|
+ newDefaultList.addAll(defaultList);
|
|
|
+ multiKeyList.put(key, newDefaultList);
|
|
|
+ defaultList = newDefaultList;
|
|
|
+ }
|
|
|
+ OtherExportDTO otherExportDTO = new OtherExportDTO();
|
|
|
+ otherExportDTO.setRuleGroup(defaultExportDTO.getRuleGroup());
|
|
|
+ otherExportDTO.setMsg(defaultExportDTO.getMsg());
|
|
|
+ otherExportDTO.setDefaultExportDTOList(defaultList);
|
|
|
+ otherExportDTOList.add(otherExportDTO);
|
|
|
+ }
|
|
|
+ return otherExportDTOList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询所有有效的规则
|
|
|
*
|