|
@ -377,7 +377,105 @@ public class ElasticsearchUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 按照医生人数统计-不重复
|
|
|
* 获取所有指标的增量、到达量
|
|
|
* 备注:原来接口的一级指标对应现在的
|
|
|
*
|
|
|
* @param startDate 开始时间
|
|
|
* @param endDate 结束时间
|
|
|
* @param area 区域code
|
|
|
* @param level 等级
|
|
|
* @param index 指标
|
|
|
* @param timeLevel 1增量 2到达量
|
|
|
* @param interval 1日 2周 3月
|
|
|
* @param lowLevel 下一级区域等级
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public List findDateQuotaLevel0AndPaibanLine(String startDate, String endDate, String area, int level, String index, String timeLevel, String interval, String lowLevel) throws Exception {
|
|
|
|
|
|
//时间格式转换 yyyy-MM-dd转成 2017-07-17T00:00:00+0800
|
|
|
if (StringUtils.isNotEmpty(startDate)) {
|
|
|
if (startDate.length() > 10) {
|
|
|
startDate = changeTime(startDate);
|
|
|
} else {
|
|
|
startDate = changeDate(startDate);
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(endDate)) {
|
|
|
if (endDate.length() > 10) {
|
|
|
endDate = changeTime(endDate);
|
|
|
} else {
|
|
|
endDate = changeDate(endDate);
|
|
|
}
|
|
|
}
|
|
|
StringBuffer sql = new StringBuffer();
|
|
|
StringBuffer groupBy = new StringBuffer();
|
|
|
String low_level = level + "";
|
|
|
if (StringUtils.isNotEmpty(lowLevel)) {
|
|
|
low_level = lowLevel;
|
|
|
}
|
|
|
if (SaveModel.doctorLevel.equals(low_level)) {
|
|
|
sql.append("select doctor,doctorName,count(doctor) result1, count(doctor) result2 from " + esIndex + " where ");
|
|
|
groupBy.append(" group by doctor,doctorName");
|
|
|
}else if (SaveModel.deptLevel.equals(low_level)) {
|
|
|
sql.append("select dept,deptName,count(DISTINCT doctor) result1, count(DISTINCT doctor) result2 from " + esIndex + " where ");
|
|
|
groupBy.append(" group by ");
|
|
|
} else if (SaveModel.OrgLevel.equals(low_level)) {
|
|
|
sql.append("select hospital,hospitalName,count(DISTINCT doctor) result1,count(DISTINCT doctor) result2 from " + esIndex + " where ");
|
|
|
groupBy.append(" group by ");
|
|
|
} else if (SaveModel.townLevel.equals(low_level)) {
|
|
|
sql.append("select town,townName,count(DISTINCT doctor) result1,count(DISTINCT doctor) result2 from " + esIndex + " where ");
|
|
|
groupBy.append(" group by ");
|
|
|
} else if (SaveModel.cityLevel.equals(low_level)) {
|
|
|
sql.append("select city,cityName,count(DISTINCT doctor) result1,count(DISTINCT doctor) result2 from " + esIndex + " where ");
|
|
|
groupBy.append(" group by ");
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(area)) {
|
|
|
|
|
|
if (SaveModel.doctorLevel.equals(level + "")) {
|
|
|
sql.append(" doctor='" + area + "'");
|
|
|
}else if (SaveModel.deptLevel.equals(level + "")) {
|
|
|
sql.append(" dept='" + area + "'");
|
|
|
} else if (SaveModel.OrgLevel.equals(level + "")) {
|
|
|
sql.append(" hospital='" + area + "'");
|
|
|
} else if (SaveModel.townLevel.equals(level + "")) {
|
|
|
sql.append(" town='" + area + "'");
|
|
|
} else if (SaveModel.cityLevel.equals(level + "")) {
|
|
|
sql.append(" city='" + area + "'");
|
|
|
}
|
|
|
sql.append(" and ");
|
|
|
}
|
|
|
// sql.append(" quotaCode='" + index + "' ");
|
|
|
sql.append(" quotaCode in(" + index + ") ");
|
|
|
sql.append(" and timeLevel='" + timeLevel + "' ");
|
|
|
sql.append(" and areaLevel='6'");
|
|
|
sql.append(" and result1<>0 ");
|
|
|
|
|
|
if (StringUtils.isNotEmpty(startDate)) {
|
|
|
sql.append(" and quotaDate>='" + startDate + "'");
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(endDate)) {
|
|
|
sql.append(" and quotaDate<='" + endDate + "'");
|
|
|
}
|
|
|
|
|
|
|
|
|
//根据时间维度分组
|
|
|
if (StringUtils.isNotEmpty(interval)) {
|
|
|
if (SaveModel.interval_month.equals(interval)) {
|
|
|
groupBy.append(" date_histogram(field='quotaDate','interval'='month','time_zone'='+08:00','alias'='quotaDate') ");
|
|
|
} else if (SaveModel.interval_week.equals(interval)) {
|
|
|
groupBy.append(" date_histogram(field='quotaDate','interval'='week','time_zone'='+08:00','alias'='quotaDate') ");
|
|
|
} else if (SaveModel.interval_day.equals(interval)) {
|
|
|
groupBy.append(" date_histogram(field='quotaDate','interval'='1d','time_zone'='+08:00','alias'='quotaDate') ");
|
|
|
}
|
|
|
}
|
|
|
sql.append(groupBy);
|
|
|
|
|
|
return excute(sql.toString(), SaveModel.class, "", "");
|
|
|
}
|
|
|
|
|
|
|
|
|
|