|
@ -62,6 +62,7 @@ public class StatisticsESService {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX");
|
|
|
SimpleDateFormat dateFormat3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
/**
|
|
|
* 获取上次统计时间
|
|
|
*
|
|
@ -3175,7 +3176,7 @@ public class StatisticsESService {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String,Object>> getPrescriptionCostLowLevel(String level,String lowlevel,String area,String disease,String type) throws Exception{
|
|
|
DecimalFormat decimalFormat=new DecimalFormat("0.00");
|
|
|
|
|
|
String quotaDate = elasticsearchUtil.getQuotaTime();
|
|
|
//1.总量
|
|
|
List<SaveModel> list = elasticsearchUtil.findListDateQuotaLevel1(quotaDate,area,Integer.parseInt(level),"61","2",lowlevel,disease);
|
|
@ -3200,8 +3201,9 @@ public class StatisticsESService {
|
|
|
}else{
|
|
|
//2.平均值
|
|
|
//去重获取总人数,计算人均费用
|
|
|
String sql = " select count(DISTINCT(s.patient)) as num from wlyy_prescription_pay p left join wlyy_prescription s on p.prescription_code = s. CODE ";
|
|
|
String sql = "";
|
|
|
for(SaveModel one:list){
|
|
|
sql = " select count(DISTINCT(s.patient)) as num from wlyy_prescription_pay p left join wlyy_prescription s on p.prescription_code = s. CODE ";
|
|
|
sql +=" and p.trace_time <= "+one.getQuotaDate();
|
|
|
Map<String, Object> count = jdbcTemplate.queryForMap(sql);
|
|
|
map = new HashMap<>();
|
|
@ -3233,9 +3235,59 @@ public class StatisticsESService {
|
|
|
* @param endDate
|
|
|
* @param type 1.按日,2.按周,3.按月
|
|
|
*/
|
|
|
public List<Map<String,Object>> getPrescriptionCostAvgLine(String level,String area,String disease,String startDate,String endDate,String type){
|
|
|
public List<Map<String,Object>> getPrescriptionCostAvgLine(String level,String area,String disease,String startDate,String endDate,String type) throws Exception{
|
|
|
|
|
|
startDate = elasticsearchUtil.changeTime(startDate += " 00:00:00");
|
|
|
endDate = elasticsearchUtil.changeTime(endDate += " 23:59:59");
|
|
|
List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate,endDate,area,Integer.parseInt(level),"61","2",type,disease);
|
|
|
String sql = "";
|
|
|
Map<String,Object> map = null;
|
|
|
List<Map<String,Object>> countList = new ArrayList<>();
|
|
|
for(SaveModel one:list){
|
|
|
sql = " select count(DISTINCT(s.patient)) as num from wlyy_prescription_pay p left join wlyy_prescription s on p.prescription_code = s. CODE ";
|
|
|
sql += " and p.trace_time <= "+one.getQuotaDate();
|
|
|
if(SaveModel.townLevel.equals(level)||SaveModel.cityLevel.equals(level)){
|
|
|
sql += " and LEFT(s.hospital,6) ='" + area+ "' ";
|
|
|
}else if(SaveModel.OrgLevel.equals(level)){
|
|
|
sql += " and s.hospital ='" + area+ "' ";
|
|
|
}else if(SaveModel.teamLevel.equals(level)){
|
|
|
sql += " and s.admin_team_id ='" + area+ "' ";
|
|
|
}
|
|
|
Map<String, Object> count = jdbcTemplate.queryForMap(sql);
|
|
|
Long num = (Long)count.get("num");
|
|
|
String avg = decimalFormat.format(one.getResult1()/num);
|
|
|
map = new HashMap<>();
|
|
|
map.put("avg",avg);
|
|
|
map.put("date",dateFormat.format(one.getQuotaDate()));
|
|
|
countList.add(map);
|
|
|
}
|
|
|
return countList;
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
public Map<String,Object> getPrescriptionCost(String level,String area,String disease) throws Exception{
|
|
|
SaveModel saveModel = null;
|
|
|
String quotaDate = elasticsearchUtil.getQuotaTime();
|
|
|
if(StringUtils.isNotEmpty(disease)){
|
|
|
saveModel = elasticsearchUtil.findOneDateQuotaLevel1(quotaDate,area,Integer.parseInt(level),"61","2",disease);
|
|
|
}else{
|
|
|
saveModel = elasticsearchUtil.findOneDateQuotaLevel0(quotaDate,area,Integer.parseInt(level),"61","2");
|
|
|
}
|
|
|
String sql = " select count(DISTINCT(s.patient)) as num from wlyy_prescription_pay p left join wlyy_prescription s on p.prescription_code = s. CODE ";
|
|
|
sql += " and p.trace_time <= "+dateFormat3.parse(quotaDate);
|
|
|
if(SaveModel.townLevel.equals(level)||SaveModel.cityLevel.equals(level)){
|
|
|
sql += " and LEFT(s.hospital,6) ='" + area+ "' ";
|
|
|
}else if(SaveModel.OrgLevel.equals(level)){
|
|
|
sql += " and s.hospital ='" + area+ "' ";
|
|
|
}else if(SaveModel.teamLevel.equals(level)){
|
|
|
sql += " and s.admin_team_id ='" + area+ "' ";
|
|
|
}
|
|
|
Map<String, Object> count = jdbcTemplate.queryForMap(sql);
|
|
|
Long num = (Long)count.get("num");
|
|
|
Map<String,Object> rs = new HashedMap();
|
|
|
BigDecimal s = BigDecimal.valueOf(num);
|
|
|
BigDecimal a = BigDecimal.valueOf(saveModel.getResult2()/num);
|
|
|
rs.put("sum",s.divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
rs.put("avg",a.divide((new BigDecimal(100))).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
return rs;
|
|
|
}
|
|
|
}
|