ソースを参照

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida 8 年 前
コミット
1e2eb77bed

+ 176 - 0
patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/ElasticsearchUtil.java

@ -0,0 +1,176 @@
package com.yihu.wlyy.statistics.controller;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.vo.SaveModel;
import org.elasticsearch.action.search.SearchResponse;
import org.nlpcn.es4sql.domain.Select;
import org.nlpcn.es4sql.jdbc.ObjectResult;
import org.nlpcn.es4sql.jdbc.ObjectResultsExtractor;
import org.nlpcn.es4sql.parse.ElasticSqlExprParser;
import org.nlpcn.es4sql.parse.SqlParser;
import org.nlpcn.es4sql.query.AggregationQueryAction;
import org.nlpcn.es4sql.query.DefaultQueryAction;
import org.nlpcn.es4sql.query.SqlElasticSearchRequestBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/7/17.
 * SELECT town,townName,sum(result1) result1 FROM wlyy_quota_test
 where quotaCode='1'
 group by town,townName , date_histogram(field='quotaDate','interval'='week')
 */
@Component
public class ElasticsearchUtil {
    @Autowired
    private ElasticFactory elasticFactory;
    @Value("${es.type}")
    private String esType;
    @Value("${es.index}")
    private String esIndex;
    /**
     *
     * @param quotaCode  指标quotacode
     * @param startDate 开始日期 yyyy-MM-dd
     * @param endDate  结束日期 yyyy-MM-dd
     * @param timeLevel  1增量 2到达量
     * @param areaLevel 1 省 2 市 3 区县 4 机构 5团队
     * @param interval 1日 2周 3月
     * @return
     */
    public List<SaveModel> findQuotas(String quotaCode,
                                      String startDate,
                                      String endDate,
                                      String timeLevel,
                                      String areaLevel,
                                      String interval) {
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        if (SaveModel.teamLevel.equals(areaLevel)) {
            sql.append("select team,teamName,result1,result2 from wlyy_quota_test where ");
        } else if (SaveModel.OrgLevel.equals(areaLevel)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append(" group by hospital,hospitalName");
        } else if (SaveModel.townLevel.equals(areaLevel)) {
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append(" group by town,townName");
        } else if (SaveModel.cityLevel.equals(areaLevel)) {
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where");
            groupBy.append(" group by city,cityName");
        }
        sql.append(" quotaCode='" + quotaCode + "'  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'  ");
        sql.append(" and quotaDate >='" + startDate + "'  ");
        sql.append(" and quotaDate <='" + endDate + "'  ");
        sql.append(groupBy);
        return excute(sql.toString());
    }
    public List<SaveModel> findQuotas(String quotaCode,
                                      String quotaDate,
                                      String timeLevel,
                                      String areaLevel) {
        return null;
    }
    public List<SaveModel> findQuotasByChllevel(String quotaCode,
                                                String startDate,
                                                String endDate,
                                                String timeLevel,
                                                String areaLevel,
                                                String childAreaLevel) {
        return null;
    }
    public List<SaveModel> findQuotasByChllevel(String quotaCode,
                                                String quotaDate,
                                                String timeLevel,
                                                String areaLevel,
                                                String childAreaLevel) {
        return null;
    }
    /**
     * 执行sql查询es
     *
     * @param sql
     * @return
     */
    public List<SaveModel> excute(String sql) {
        List<SaveModel> saveModels = new ArrayList<>();
        try {
            SQLExprParser parser = new ElasticSqlExprParser(sql);
            SQLExpr expr = parser.expr();
            SQLQueryExpr queryExpr = (SQLQueryExpr) expr;
            Select select = null;
            select = new SqlParser().parseSelect(queryExpr);
            //通过抽象语法树,封装成自定义的Select,包含了select、from、where group、limit等
            AggregationQueryAction action = null;
            DefaultQueryAction queryAction = null;
            SqlElasticSearchRequestBuilder requestBuilder = null;
            if (select.isAgg) {
                //包含计算的的排序分组的
                action = new AggregationQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = action.explain();
            } else {
                //封装成自己的Select对象
                queryAction = new DefaultQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = queryAction.explain();
            }
            SearchResponse response = (SearchResponse) requestBuilder.get();
            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getAggregations(), true);
            List<String> heads = temp.getHeaders();
            temp.getLines().stream().forEach(one -> {
                try {
                    SaveModel saveModel = new SaveModel();
                    for (int i = 0; i < one.size(); i++) {
                        String key = "set" + UpFirstStr(heads.get(i));
                        Object value = one.get(i);
                        if (value instanceof String) {
                            SaveModel.class.getMethod(key, String.class).invoke(saveModel, value);
                        } else if (value instanceof Integer) {
                            SaveModel.class.getMethod(key, Integer.class).invoke(saveModel, value);
                        } else if (value instanceof Double) {
                            SaveModel.class.getMethod(key, Integer.class).invoke(saveModel, ((Double) value).intValue());
                        }
                    }
                    saveModels.add(saveModel);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
        return saveModels;
    }
    /**
     * 首字母大写
     *
     * @param str
     * @return
     */
    public String UpFirstStr(String str) {
        return str.replaceFirst(str.substring(0, 1), str.substring(0, 1).toUpperCase());
    }
}

+ 3 - 81
patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/model/job/ElasticsearchService.java

@ -4,6 +4,7 @@ import com.alibaba.druid.pool.ExceptionSorter;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.yihu.wlyy.statistics.controller.ElasticsearchUtil;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.vo.SaveModel;
import io.searchbox.client.JestClient;
@ -35,13 +36,8 @@ import java.util.List;
 */
@Service
public class ElasticsearchService {
    @Autowired
    private ElasticFactory elasticFactory;
    @Value("${es.type}")
    private String esType;
    @Value("${es.index}")
    private String esIndex;
    private ElasticsearchUtil elasticsearchUtil;
    /**
     * 查询一级维度的指标
@ -54,30 +50,6 @@ public class ElasticsearchService {
     * @return
     */
    public SaveModel findDimension1Quota(String quotaCode, String timeLevel, String areaLevel, String code, String quotaDate) {
        try {
            JestClient jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("quotaCode", quotaCode))
                            .must(QueryBuilders.matchQuery("timeLevel", timeLevel))
                            .must(QueryBuilders.matchQuery(SaveModel.getAreaLevelKey(areaLevel), code))
                            .must(QueryBuilders.matchQuery("quotaDate", quotaDate)))
                    .size(10);//一次取10条
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<SaveModel> saveModels = result.getSourceAsObjectList(SaveModel.class);
            if (saveModels != null && saveModels.size() > 0) {
                return saveModels.get(0);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
@ -89,57 +61,7 @@ public class ElasticsearchService {
    public List<SaveModel> excute(String sql) {
        List<SaveModel> saveModels = new ArrayList<>();
        try {
            SQLExprParser parser = new ElasticSqlExprParser(sql);
            SQLExpr expr = parser.expr();
            SQLQueryExpr queryExpr = (SQLQueryExpr) expr;
            Select select = null;
            select = new SqlParser().parseSelect(queryExpr);
            //通过抽象语法树,封装成自定义的Select,包含了select、from、where group、limit等
            AggregationQueryAction action = null;
            DefaultQueryAction queryAction = null;
            SqlElasticSearchRequestBuilder requestBuilder = null;
            if (select.isAgg) {
                //包含计算的的排序分组的
                action = new AggregationQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = action.explain();
            } else {
                //封装成自己的Select对象
                queryAction = new DefaultQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = queryAction.explain();
            }
            SearchResponse response = (SearchResponse) requestBuilder.get();
            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getAggregations(), true);
            List<String> heads = temp.getHeaders();
            temp.getLines().stream().forEach(one -> {
                try {
                    SaveModel saveModel = new SaveModel();
                    for (int i = 0; i < one.size(); i++) {
                        String key = "set" + UpFirstStr(heads.get(i));
                        Object value = one.get(i);
                        if (value instanceof String) {
                            SaveModel.class.getMethod(key, String.class).invoke(saveModel,value);
                        }else if (value instanceof Integer) {
                            SaveModel.class.getMethod(key, Integer.class).invoke(saveModel, value);
                        }else if (value instanceof Double) {
                            SaveModel.class.getMethod(key, Integer.class).invoke(saveModel,  ((Double)value).intValue());
                        }
                    }
                    saveModels.add(saveModel);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
        return saveModels;
        return elasticsearchUtil.excute(sql);
    }
    public String UpFirstStr(String str) {
        return str.replaceFirst(str.substring(0, 1), str.substring(0, 1).toUpperCase());
    }
}

+ 4 - 4
patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/vo/SaveModel.java

@ -18,10 +18,10 @@ public class SaveModel {
    private final static String townKey = "town";
    private final static String cityKey = "city";
    private final static String teamLevel = "5";
    private final static String OrgLevel = "4";
    private final static String townLevel = "3";
    private final static String cityLevel = "2";
    public final static String teamLevel = "5";
    public final static String OrgLevel = "4";
    public final static String townLevel = "3";
    public final static String cityLevel = "2";
    private static final Map<String, String> fieldsSithch = new HashMap<>();
    @JestId

+ 19 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/SignDataFilter.java

@ -38,7 +38,7 @@ public class SignDataFilter {
    public static String level2Health = "5";//健康服务分布
    public static String level2Age2 = "6";//年龄
    public static String level2AgeDisease = "7";//年龄疾病
    public static String level2ServerType= "8";//年龄疾病
    public static String level2ServerType = "8";//年龄疾病
    public static String level3Disease = "1";//疾病分组
@ -347,7 +347,7 @@ public class SignDataFilter {
                    return returnLevel2Key;
                }
                case "8": {
                    return signFamily.getServerType();
                    return getServerType(signFamily);
                }
            }
@ -355,6 +355,23 @@ public class SignDataFilter {
        return returnLevel2Key;
    }
    private String getServerType(SignFamily signFamily) {
        //获取服务类型
        List<String> serverType = CachePool.getServerType(signFamily.getCode());
        //返回服务类型
        if (serverType != null && serverType.size() > 0) {
            StringBuffer str = new StringBuffer();
            for (int i = 0; i < serverType.size(); i++) {
                str.append(serverType.get(i));
                if (serverType.size() != (i + 1)) {
                    str.append(",");
                }
            }
            return str.toString();
        }
        return "0";
    }
    private String getAgeDisease(SignFamily signFamily) {
        //得到患者年龄
        StringBuffer returnLevel2KeyBuffer = new StringBuffer("0");

+ 110 - 62
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/mycache/CachePool.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.statistics.etl.model.CacheModel;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.model.label.SignPatientLabelInfo;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyServer;
import com.yihu.wlyy.statistics.util.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -21,87 +22,95 @@ import java.util.Map;
 */
@Component
public class CachePool {
    private static List<String> keys=new ArrayList<>();
    private static List<String> keys = new ArrayList<>();
    /**
     * 到达量的缓存  key 是时间yyyy-MM-dd
     */
    private static Map<String,CacheModel> arriveSignFamilyExpenseStatus1Map=new HashMap<String,CacheModel>();
    private static Map<String, CacheModel> arriveSignFamilyExpenseStatus1Map = new HashMap<String, CacheModel>();
    /**
     * 分组标签的缓存 key 是患者code
     */
    private static Map<String,String> patientGroup=new HashMap<String,String>();
    private static Map<String, String> patientGroup = new HashMap<String, String>();
    /**
     * 签约服务分组
     */
    private static Map<String, List<String>> serverGroup = new HashMap<String, List<String>>();
    /**
     * 健康标签的缓存 key 是患者code
     */
    private static Map<String,String> healthGroup=new HashMap<String,String>();
    private static Map<String, String> healthGroup = new HashMap<String, String>();
    /**
     * 疾病标签的缓存 key 是患者code
     */
    private static Map<String,List<String>> diseaseGroup=new HashMap<String,List<String>>();
    private static Map<String, List<String>> diseaseGroup = new HashMap<String, List<String>>();
    /**
     * 某天的签约的已扣费的到达量
     *
     * @param date
     * @return
     * @throws Exception
     */
    public synchronized CacheModel getSignFamilysWithExpenseStatus1ByDate(String date) throws Exception{
        CacheModel model= arriveSignFamilyExpenseStatus1Map.get(date);
        if(model==null){
            model=new CacheModel();
            String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status,patient,server_type from wlyy_sign_family a " +
    public synchronized CacheModel getSignFamilysWithExpenseStatus1ByDate(String date) throws Exception {
        CacheModel model = arriveSignFamilyExpenseStatus1Map.get(date);
        if (model == null) {
            model = new CacheModel();
            String sql = " select id,code,idcard,hospital,admin_team_code,expenses_status,patient,server_type from wlyy_sign_family a " +
                    " where " +
                    " status in(1,2) " +
                    " and a.type =2  " +
                    " and expenses_status=1 " +
                    " and a.expenses_time< '"+date+ Constant.quota_date_last+"' " +
                    " and a.sign_year ='"+Constant.getNowYearByDateYeaterday(date)+"'  " ;
            String sqlCount="select count(id) from wlyy_sign_family a " +
                    " and a.expenses_time< '" + date + Constant.quota_date_last + "' " +
                    " and a.sign_year ='" + Constant.getNowYearByDateYeaterday(date) + "'  ";
            String sqlCount = "select count(id) from wlyy_sign_family a " +
                    " where  " +
                    " status in(1,2) " +
                    " and a.type =2 " +
                    " and expenses_status=1 " +
                    " and a.expenses_time< '"+date+ Constant.quota_date_last+"'  " +
                    " and a.sign_year ='"+Constant.getNowYearByDateYeaterday(date)+"'  " ;
                    " and a.expenses_time< '" + date + Constant.quota_date_last + "'  " +
                    " and a.sign_year ='" + Constant.getNowYearByDateYeaterday(date) + "'  ";
            //抽取數據 分页抽取
            List<SignFamily> signFamiliesTemp= SpringUtil.getBean(DBExtract.class).extractByPage(SignFamily.class,sql,sqlCount,true);
            List<SignFamily> signFamiliesTemp = SpringUtil.getBean(DBExtract.class).extractByPage(SignFamily.class, sql, sqlCount, true);
            model.setSql(sql);
            model.setSignFamilies(signFamiliesTemp);
            arriveSignFamilyExpenseStatus1Map.put(date,model);
            arriveSignFamilyExpenseStatus1Map.put(date, model);
            return model;
        }else{
        } else {
            return model;
        }
    }
    /**
     * 查询某人的分组标签
     *
     * @param patientCode
     * @return
     * @throws Exception
     */
    public String getPatientGroup(String patientCode){
        String code=null;
        try{
            if(patientGroup.size()==0){
    public String getPatientGroup(String patientCode) {
        String code = null;
        try {
            if (patientGroup.size() == 0) {
                initPatientGroup();
            }
            code= patientGroup.get(patientCode);
            if(StringUtils.isEmpty(code)){
                code="0";
            code = patientGroup.get(patientCode);
            if (StringUtils.isEmpty(code)) {
                code = "0";
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            return code;
        }
        return code;
    }
    private synchronized void initPatientGroup() throws  Exception{
        if(patientGroup.size()==0) {
            String sql="select patient,label from wlyy_sign_patient_label_info where label_type='1' and status=1";
            String countSql="select count(id) from wlyy_sign_patient_label_info where label_type='1' and status=1";
            List<SignPatientLabelInfo> signPatientLabelInfoList = SpringUtil.getBean(DBExtract.class).extractByPage(SignPatientLabelInfo.class,sql,countSql,true);
    private synchronized void initPatientGroup() throws Exception {
        if (patientGroup.size() == 0) {
            String sql = "select patient,label from wlyy_sign_patient_label_info where label_type='1' and status=1";
            String countSql = "select count(id) from wlyy_sign_patient_label_info where label_type='1' and status=1";
            List<SignPatientLabelInfo> signPatientLabelInfoList = SpringUtil.getBean(DBExtract.class).extractByPage(SignPatientLabelInfo.class, sql, countSql, true);
            for (SignPatientLabelInfo signPatientLabelInfo : signPatientLabelInfoList) {
                patientGroup.put(signPatientLabelInfo.getPatient(), signPatientLabelInfo.getLabel());
            }
@ -110,70 +119,72 @@ public class CachePool {
    /**
     * 查询某人的健康标签
     *
     * @param patientCode
     * @return
     * @throws Exception
     */
    public  String getHealthGroup(String patientCode){
    public String getHealthGroup(String patientCode) {
        String code;
        try{
            if(healthGroup.size()==0){
        try {
            if (healthGroup.size() == 0) {
                initHealthGroup();
            }
             code= healthGroup.get(patientCode);
        }catch (Exception e){
            code = healthGroup.get(patientCode);
        } catch (Exception e) {
            e.printStackTrace();
            return "0";
        }
        if(StringUtils.isEmpty(code)){
            code="0";
        if (StringUtils.isEmpty(code)) {
            code = "0";
        }
        return code;
    }
    private synchronized void initHealthGroup()  throws  Exception{
        if(healthGroup.size()==0){
            String sql="select patient,label from wlyy_sign_patient_label_info where label_type='2' and status=1";
            String countSql="select count(id) from wlyy_sign_patient_label_info where label_type='2' and status=1";
            List<SignPatientLabelInfo> signPatientLabelInfoList = SpringUtil.getBean(DBExtract.class).extractByPage(SignPatientLabelInfo.class,sql,countSql,true);
            for(SignPatientLabelInfo signPatientLabelInfo:signPatientLabelInfoList){
                healthGroup.put(signPatientLabelInfo.getPatient(),signPatientLabelInfo.getLabel());
    private synchronized void initHealthGroup() throws Exception {
        if (healthGroup.size() == 0) {
            String sql = "select patient,label from wlyy_sign_patient_label_info where label_type='2' and status=1";
            String countSql = "select count(id) from wlyy_sign_patient_label_info where label_type='2' and status=1";
            List<SignPatientLabelInfo> signPatientLabelInfoList = SpringUtil.getBean(DBExtract.class).extractByPage(SignPatientLabelInfo.class, sql, countSql, true);
            for (SignPatientLabelInfo signPatientLabelInfo : signPatientLabelInfoList) {
                healthGroup.put(signPatientLabelInfo.getPatient(), signPatientLabelInfo.getLabel());
            }
        }
    }
    /**
     * 查询某人的疾病标签
     *
     * @param patientCode
     * @return
     * @throws Exception
     */
    public  List<String> getDiseaseGroup(String patientCode) {
        try{
            if(diseaseGroup.size()==0){
    public List<String> getDiseaseGroup(String patientCode) {
        try {
            if (diseaseGroup.size() == 0) {
                initDiseaseGroup();
            }
            List<String> code= diseaseGroup.get(patientCode);
            List<String> code = diseaseGroup.get(patientCode);
            return code;
        }catch (Exception e){
        } catch (Exception e) {
            return null;
        }
    }
    private synchronized void initDiseaseGroup()  throws  Exception{
        if(diseaseGroup.size()==0){
            String sql="select patient,label from wlyy_sign_patient_label_info where label_type='3' and status=1";
            String countSql="select count(id) from wlyy_sign_patient_label_info where label_type='3' and status=1";
            List<SignPatientLabelInfo> signPatientLabelInfoList = SpringUtil.getBean(DBExtract.class).extractByPage(SignPatientLabelInfo.class,sql,countSql,true);
            for(SignPatientLabelInfo signPatientLabelInfo:signPatientLabelInfoList){
                if(diseaseGroup.containsKey(signPatientLabelInfo.getPatient())){
                    List<String> code= diseaseGroup.get(signPatientLabelInfo.getPatient());
    private synchronized void initDiseaseGroup() throws Exception {
        if (diseaseGroup.size() == 0) {
            String sql = "select patient,label from wlyy_sign_patient_label_info where label_type='3' and status=1";
            String countSql = "select count(id) from wlyy_sign_patient_label_info where label_type='3' and status=1";
            List<SignPatientLabelInfo> signPatientLabelInfoList = SpringUtil.getBean(DBExtract.class).extractByPage(SignPatientLabelInfo.class, sql, countSql, true);
            for (SignPatientLabelInfo signPatientLabelInfo : signPatientLabelInfoList) {
                if (diseaseGroup.containsKey(signPatientLabelInfo.getPatient())) {
                    List<String> code = diseaseGroup.get(signPatientLabelInfo.getPatient());
                    code.add(signPatientLabelInfo.getLabel());
                    diseaseGroup.put(signPatientLabelInfo.getPatient(),code);
                }else{
                    List<String> code=new ArrayList<>();
                    diseaseGroup.put(signPatientLabelInfo.getPatient(), code);
                } else {
                    List<String> code = new ArrayList<>();
                    code.add(signPatientLabelInfo.getLabel());
                    diseaseGroup.put(signPatientLabelInfo.getPatient(),code);
                    diseaseGroup.put(signPatientLabelInfo.getPatient(), code);
                }
            }
        }
@ -184,6 +195,7 @@ public class CachePool {
        patientGroup.clear();
        diseaseGroup.clear();
        healthGroup.clear();
        serverGroup.clear();
    }
    public static Map<String, CacheModel> getArriveSignFamilyExpenseStatus1Map() {
@ -194,9 +206,11 @@ public class CachePool {
        keys.clear();
        keys.addAll(keyTemp);
    }
    public static List<String> getKeys() {
        return keys;
    }
    public static Map<String, String> getPatientGroup() {
        return patientGroup;
    }
@ -208,4 +222,38 @@ public class CachePool {
    public static Map<String, List<String>> getDiseaseGroup() {
        return diseaseGroup;
    }
    public static List<String> getServerType(String signCode) {
        try {
            if (serverGroup.size() == 0) {
                initServerGroup();
            }
            List<String> code = serverGroup.get(signCode);
            return code;
        } catch (Exception e) {
            return null;
        }
    }
    private static void initServerGroup() {
        try {
            String sql = "select sign_code,server_type from wlyy_sign_family_server ";
            String countSql = "select count(id) from wlyy_sign_family_server ";
            List<SignFamilyServer> signPatientLabelInfoList = null;
            signPatientLabelInfoList = SpringUtil.getBean(DBExtract.class).extractByPage(SignFamilyServer.class, sql, countSql,50000, true);
            for (SignFamilyServer signFamilyServer : signPatientLabelInfoList) {
                if (serverGroup.containsKey(signFamilyServer.getSignCode())) {
                    List<String> code = serverGroup.get(signFamilyServer.getSignCode());
                    code.add(signFamilyServer.getServerType());
                } else {
                    List<String> code = new ArrayList<>();
                    code.add(signFamilyServer.getServerType());
                    serverGroup.put(signFamilyServer.getSignCode(), code);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 14 - 13
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/Constant.java

@ -448,45 +448,46 @@ public class Constant {
    public static String getServerType(String key) {
        switch (key) {
            case "0": {
                return "未分组";
            }
            case "1": {
                return "普通服务";
            }
            case "2": {
                return "老年人服务";
                return "未知2";
            }
            case "3": {
                return "慢性病服务";
                return "老年人";
            }
            case "4": {
                return "未知4";
                return "高血压";
            }
            case "5": {
                return "未知5";
                return "糖尿病";
            }
            case "6": {
                return "孕产妇";
            }
            case "7": {
                return "未知7";
                return "0-6岁儿童";
            }
            case "8": {
                return "儿童(0-6岁)";
                return "贫困人口";
            }
            case "9": {
                return "高血压";
                return "计生特殊人群";
            }
            case "10": {
                return "糖尿病";
                return "重性精神疾病";
            }
            case "11": {
                return "贫困人口";
                return "残疾人";
            }
            case "12": {
                return "计生特殊家庭";
            }
            case "13": {
                return "特殊人群";
                return "结核病";
            }
        }
        return "0";
    }

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java

@ -271,7 +271,7 @@ public class CurrentDayAllQuotaJob implements Job {
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 13, 10, 1);
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 13, 10, 0);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignServerTypeJob.java

@ -100,7 +100,7 @@ public class SignServerTypeJob implements Job {
            List<Map<String, List<ETLModel>>> returnDatas = levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> level2Data = level2Role.elt(returnDatas);
            dbStorage.saveByLevel2(level2Data, yesterday, wlyyQuota, 13, 10, 1);
            dbStorage.saveByLevel2(level2Data, yesterday, wlyyQuota, 13, 10, 0);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());

+ 62 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/signfamily/SignFamilyServer.java

@ -0,0 +1,62 @@
package com.yihu.wlyy.statistics.model.signfamily;
import com.yihu.wlyy.statistics.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2017/7/14.
 */
@Entity
@Table(name = "wlyy_sign_family_server")
public class SignFamilyServer extends IdEntity {
    private String signCode; //签约code
    private String serverType; //服务类型
    private String serverTypeName; //服务类型名称
    private Date czrq; //修改时间
    private Date createTime; //创建时间
    public String getSignCode() {
        return signCode;
    }
    public void setSignCode(String signCode) {
        this.signCode = signCode;
    }
    public String getServerType() {
        return serverType;
    }
    public void setServerType(String serverType) {
        this.serverType = serverType;
    }
    public String getServerTypeName() {
        return serverTypeName;
    }
    public void setServerTypeName(String serverTypeName) {
        this.serverTypeName = serverTypeName;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}