Commit 0ce57e3713ab2effd9b76e0daf3126b01fc4e0a7

Authored by jiangjiazhi
1 parent 1a7a276c98

修改产检删除

Showing 1 changed file with 130 additions and 0 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommonService.java View file @ 0ce57e3
  1 +package com.lyms.platform.biz.service;
  2 +
  3 +import com.lyms.platform.common.enums.RiskDefaultTypeEnum;
  4 +import com.lyms.platform.common.utils.ExceptionUtils;
  5 +import com.lyms.platform.common.utils.JsonUtil;
  6 +import com.lyms.platform.pojo.BasicConfig;
  7 +import org.apache.commons.collections.CollectionUtils;
  8 +import org.apache.commons.lang.StringUtils;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Service;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.HashMap;
  14 +import java.util.List;
  15 +import java.util.Map;
  16 +
  17 +/**
  18 + * Created by Administrator on 2016/12/26 0026.
  19 + */
  20 +@Service
  21 +public class CommonService {
  22 + @Autowired
  23 + private BasicConfigService basicConfigService;
  24 +
  25 +
  26 + /**
  27 + * 还原高危因素
  28 + *
  29 + * @param factor
  30 + * @return
  31 + */
  32 + public String resloveFactor(List<String> factor) {
  33 + String result = "";
  34 + if (CollectionUtils.isNotEmpty(factor)) {
  35 + StringBuilder sb = new StringBuilder(56);
  36 + for (String srt : factor) {
  37 + if (StringUtils.isNotEmpty(srt)) {
  38 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt);
  39 + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) {
  40 + sb.append(basicConfig.getName()).append(',');
  41 + }
  42 + }
  43 + }
  44 + if (sb.toString().endsWith(",")) {
  45 + result = (sb.substring(0, sb.length() - 1));
  46 + } else {
  47 + result = (sb.toString());
  48 + }
  49 + }
  50 + return result;
  51 + }
  52 +
  53 +
  54 +
  55 + /**
  56 + * 高危id转成列表
  57 + *
  58 + * @param riskLevel
  59 + * @return
  60 + */
  61 + public List findRiskLevel(List<String> riskLevel) {
  62 + List level = new ArrayList();
  63 + if (CollectionUtils.isNotEmpty(riskLevel)) {
  64 + try {
  65 + for (String str : riskLevel) {
  66 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str);
  67 + if (null != basicConfig) {
  68 + Map map = new HashMap();
  69 + String name = basicConfig.getName();
  70 + if (name.indexOf("预警") > -1) {
  71 + name = name.replace("预警", "");
  72 + }
  73 + map.put("name", name);
  74 + map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name));
  75 + level.add(map);
  76 + }
  77 + }
  78 + } catch (Exception e) {
  79 + ExceptionUtils.catchException(e, "patients.getRiskLevelId error.");
  80 + }
  81 + }
  82 + return filter(level);
  83 + }
  84 +
  85 +
  86 +
  87 +
  88 + /**
  89 + * 高危id转成列表
  90 + *
  91 + * @param riskLevel
  92 + * @return
  93 + */
  94 + public List findRiskLevel(String riskLevel) {
  95 + List level = new ArrayList();
  96 + if (StringUtils.isNotEmpty(riskLevel)) {
  97 + try {
  98 + List<String> list = JsonUtil.jkstr2Obj(riskLevel, List.class);
  99 + for (String str : list) {
  100 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str);
  101 + if (null != basicConfig) {
  102 + Map map = new HashMap();
  103 + String name = basicConfig.getName();
  104 + if (name.indexOf("预警") > -1) {
  105 + name = name.replace("预警", "");
  106 + }
  107 + map.put("name", name);
  108 + map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name));
  109 + level.add(map);
  110 + }
  111 + }
  112 + } catch (Exception e) {
  113 + ExceptionUtils.catchException(e, "patients.getRiskLevelId error.");
  114 + }
  115 + }
  116 + return filter(level);
  117 + }
  118 +
  119 + public static List filter(List<java.util.Map> level) {
  120 + List list = new ArrayList();
  121 + List addEdList = new ArrayList();
  122 + for (java.util.Map map : level) {
  123 + if (!addEdList.contains(map.get("name"))) {
  124 + list.add(map);
  125 + addEdList.add(map.get("name"));
  126 + }
  127 + }
  128 + return list;
  129 + }
  130 +}