Browse Source

bug修改

chenweida 7 years ago
parent
commit
486973572c

+ 1 - 7
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/AgeConvert.java

@ -28,15 +28,9 @@ public class AgeConvert implements Convert {
        List<DataModel> result = new ArrayList<>();
        for(DataModel one:oneList) {
            try {
                Object value = DataModel.class.getMethod("get" + temp.getKey()).invoke(one);
                Object value = one.getIdcard();
                Integer age= IdCardUtil.getAgeForIdcard(String.valueOf(value));
                String key = getAgeCode(age);
//                if("63".equals(temp.getQuotaCode())){
//
//                    if(tempMap.containsKey(String.valueOf(value))){
//                        continue;
//                    }
//                }
                tempMap.put(String.valueOf(value),one);
                DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, key);
//                result.add(one);

+ 0 - 111
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DiseaseConvert.java

@ -1,111 +0,0 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.etl.convert.wlyy.model.HealthLable;
import com.yihu.wlyy.statistics.etl.convert.wlyy.model.PrescriptionDisease;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 长处方疾病
 * Created by zhangdan on 2017/10/26.
 */
public class DiseaseConvert implements Convert {
    @Override
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
        List<DataModel> returnList = new ArrayList<>();
        //初始化标签Map
//        Map<String, Object> map = initHealthLabesMap(jdbcTemplate, temp);
        Map<String,Object> tempMap = new HashMap<>();
        //把标签Map设置到对应的维度里面
        List<String> keyList = null;
        for(DataModel one:oneList){
            try {
                if("63".equals(temp.getQuotaCode())){
                    DataModel dataModelTemp = new DataModel();
                    BeanUtils.copyProperties(one, dataModelTemp);
                    DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, one.getHealthProblem());
                    returnList.add(dataModelTemp);
                }else{
                    keyList = initHealthLabesMap(jdbcTemplate, temp, one);
                    for(String key:keyList){
                        DataModel dataModelTemp = new DataModel();
                        BeanUtils.copyProperties(one, dataModelTemp);
                        DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, key);
                        returnList.add(dataModelTemp);
                    }
                }
            }catch (Exception e) {
                e.printStackTrace();
            }
//            List<String> healthProblems = prescriptionDiseaseMap.get(dataModel.getPrescriptionCode());
//            if (healthProblems != null && healthProblems.size() > 0) {
//                healthProblems.stream().forEach(str -> {
//                    try {
//                        DataModel dataModelTemp = new DataModel();
//                        BeanUtils.copyProperties(dataModel, dataModelTemp);
//                        DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, str);
//                        returnList.add(dataModelTemp);
//                    } catch (Exception e) {
//                        e.printStackTrace();
//                    }
//                });
//            }
        }
        return returnList;
    }
    private List<String> initHealthLabesMap(JdbcTemplate jdbcTemplate, WlyyDimensionQuota temp,DataModel dataModel) {
//        //得到长处方的疾病标签(只要高血压 糖尿病)
//        String sql = "SELECT " +
//                "  health_problem ," +
//                "  prescription_code " +
//                "FROM " +
//                "  wlyy_prescription_diagnosis " +
//                "WHERE " +
//                "  health_problem = 'HP0047' " +
//                "OR health_problem = 'HP0093' ";
//        List<PrescriptionDisease> prescriptionDiseases = jdbcTemplate.query(sql, new BeanPropertyRowMapper(PrescriptionDisease.class));
//        prescriptionDiseases.stream().forEach(one -> {
//            List<String> labels = prescriptionDiseaseMap.get(one.getPrescriptionCode());
//            if (labels == null) {
//                labels = new ArrayList<String>();
//            }
//            labels.add(one.getHealthProblem());
//            prescriptionDiseaseMap.put(one.getPrescriptionCode(), labels);
//        });
        List<String> key = new ArrayList<>();
        String sql = "SELECT " +
                "  health_problem AS healthProblem ," +
                "  prescription_code AS prescriptionCode " +
                "  FROM " +
                "  wlyy_prescription_diagnosis " +
                "  WHERE " +
                "  prescription_code = '"+dataModel.getPrescriptionCode() +"'";
        List<Map<String, Object>>  diagnosisList =jdbcTemplate.queryForList(sql);
//        List<Map<String, Object>> dictList = jdbcTemplate.queryForList(temp.getDictSql());
        for (Map<String, Object> map:diagnosisList){
//            String diagnosis = map.get("healthProblem")+"";
//            for(Map<String, Object> dict:dictList){
//                if(diagnosis.equals(dict.get("code"))){
//                    key.add()
//                }
//            }
            key.add(map.get("healthProblem").toString());
        }
        return key;
    }
}

+ 1 - 2
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/PrescriptionAgeConvert.java

@ -27,11 +27,10 @@ public class PrescriptionAgeConvert implements Convert {
        List<DataModel> result = new ArrayList<>();
        for(DataModel one:oneList) {
            try {
                Object value = DataModel.class.getMethod("get" + temp.getKey()).invoke(one);
                Object value = one.getIdcard();
                Integer age= IdCardUtil.getAgeForIdcard(String.valueOf(value));
                String key = getAgeCode(age);
                if("63".equals(temp.getQuotaCode())){
                    if(tempMap.containsKey(String.valueOf(value))){
                        continue;
                    }

+ 65 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/PrescriptionDiseaseConvert.java

@ -0,0 +1,65 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.etl.convert.wlyy.model.HealthLable;
import com.yihu.wlyy.statistics.etl.convert.wlyy.model.PrescriptionDisease;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 长处方疾病
 * Created by zhangdan on 2017/10/26.
 */
public class PrescriptionDiseaseConvert implements Convert {
    @Override
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
        List<DataModel> returnList = new ArrayList<>();
        //初始化标签Map
        //把标签Map设置到对应的维度里面
        List<String> keyList = null;
        Map<String,List<String>>  returnMap=initHealthLabesMap(jdbcTemplate, temp);
        for (DataModel one : oneList) {
            try {
                keyList = returnMap.get(one.getPrescriptionCode());
                for (String key : keyList) {
                    DataModel dataModelTemp = new DataModel();
                    BeanUtils.copyProperties(one, dataModelTemp);
                    DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, key);
                    returnList.add(dataModelTemp);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return returnList;
    }
    private  Map<String,List<String>> initHealthLabesMap(JdbcTemplate jdbcTemplate, WlyyDimensionQuota temp) {
//        //得到长处方的疾病标签(只要高血压 糖尿病)
       Map<String,List<String>>  returnMap = new HashMap<>();
        String sql = "SELECT " +
                "  health_problem AS healthProblem ," +
                "  prescription_code AS prescriptionCode " +
                "  FROM " +
                "  wlyy_prescription_diagnosis " ;
        List<Map<String, Object>> diagnosisList = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map : diagnosisList) {
            String key= (String) map.get("prescriptionCode");
            List<String> healthProblemList=returnMap.get(key);
            if(healthProblemList==null){
                healthProblemList=new ArrayList<>();
            }
            healthProblemList.add((String) map.get("healthProblem"));
            returnMap.put(key,healthProblemList);
        }
        return returnMap;
    }
}

+ 65 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/PrescriptionPatientDiseaseConvert.java

@ -0,0 +1,65 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 长处方疾病
 * Created by zhangdan on 2017/10/26.
 */
public class PrescriptionPatientDiseaseConvert implements Convert {
    @Override
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
        List<DataModel> returnList = new ArrayList<>();
        //初始化标签Map
        //把标签Map设置到对应的维度里面
        List<String> keyList = null;
        Map<String,List<String>>  returnMap=initHealthLabesMap(jdbcTemplate, temp);
        for (DataModel one : oneList) {
            try {
                keyList = returnMap.get(one.getPatient());
                for (String key : keyList) {
                    DataModel dataModelTemp = new DataModel();
                    BeanUtils.copyProperties(one, dataModelTemp);
                    DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, key);
                    returnList.add(dataModelTemp);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return returnList;
    }
    private  Map<String,List<String>> initHealthLabesMap(JdbcTemplate jdbcTemplate, WlyyDimensionQuota temp) {
//        //得到长处方的疾病标签(只要高血压 糖尿病)
        Map<String,List<String>>  returnMap = new HashMap<>();
        String sql = "SELECT distinct " +
                "  d.health_problem AS healthProblem, " +
                "  p.patient AS patient " +
                "FROM " +
                "  wlyy_prescription p, " +
                "  wlyy_prescription_diagnosis d " +
                "WHERE " +
                "p.`code`=d.prescription_code" ;
        List<Map<String, Object>> diagnosisList = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map : diagnosisList) {
            String key= (String) map.get("patient");
            List<String> healthProblemList=returnMap.get(key);
            if(healthProblemList==null){
                healthProblemList=new ArrayList<>();
            }
            healthProblemList.add((String) map.get("healthProblem"));
            returnMap.put(key,healthProblemList);
        }
        return returnMap;
    }
}