|
@ -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;
|
|
|
}
|
|
|
}
|