|
@ -2,6 +2,7 @@ package com.yihu.quota.service.quota;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.yihu.ehr.util.datetime.DateUtil;
|
|
import com.yihu.ehr.util.datetime.DateUtil;
|
|
|
|
import com.yihu.ehr.util.rest.Envelop;
|
|
import com.yihu.quota.dao.jpa.TjQuotaDao;
|
|
import com.yihu.quota.dao.jpa.TjQuotaDao;
|
|
import com.yihu.quota.dao.jpa.TjQuotaGovProvisionDao;
|
|
import com.yihu.quota.dao.jpa.TjQuotaGovProvisionDao;
|
|
import com.yihu.quota.etl.extract.es.EsResultExtract;
|
|
import com.yihu.quota.etl.extract.es.EsResultExtract;
|
|
@ -1967,4 +1968,43 @@ public class BaseStatistsService {
|
|
});
|
|
});
|
|
return map.get("result");
|
|
return map.get("result");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public Envelop searchEsByParam(String eventType, String time, Integer month) {
|
|
|
|
Envelop envelop = new Envelop();
|
|
|
|
String start = "", end = "";
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
List<String> xData = new ArrayList<>(); // x轴坐标
|
|
|
|
List<String> yData = new ArrayList<>(); // x轴坐标对应的值
|
|
|
|
// 设置查询时间范围
|
|
|
|
if (StringUtils.isNotEmpty(time)) {
|
|
|
|
SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd'T'23:59:59'Z'");
|
|
|
|
Date dateTime = DateUtil.strToDate(time);
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
calendar.setTime(dateTime);
|
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
|
end = dfs.format(calendar.getTime());
|
|
|
|
calendar.add(Calendar.MONTH, -(month - 1));
|
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
|
|
|
|
start = DateUtil.utcToDate(calendar.getTime());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("0".equals(eventType)) {
|
|
|
|
sb.append("SELECT count(*) FROM medical_service_index where quotaCode='HC041100' and slaveKey1=0 and quotaDate>='")
|
|
|
|
.append(start).append("' and quotaDate<='").append(end).append("' group by date_histogram(field='quotaDate', 'interval'='month')");
|
|
|
|
} else if ("1".equals(eventType)) {
|
|
|
|
sb.append("SELECT count(*) FROM medical_service_index where quotaCode='HC041103' and quotaDate>='")
|
|
|
|
.append(start).append("' and quotaDate<='").append(end).append("' group by date_histogram(field='quotaDate', 'interval'='month')");
|
|
|
|
}
|
|
|
|
log.info(sb.toString());
|
|
|
|
|
|
|
|
List<Map<String, Object>> list = elasticsearchUtil.excuteDataModel(sb.toString());
|
|
|
|
list.forEach(one -> {
|
|
|
|
xData.add((one.get("date_histogram(field=quotaDate,interval=month)") + "").substring(0,7));
|
|
|
|
yData.add(one.get("COUNT(*)") + "");
|
|
|
|
});
|
|
|
|
envelop.setSuccessFlg(true);
|
|
|
|
envelop.setObj(xData);
|
|
|
|
envelop.setDetailModelList(yData);
|
|
|
|
return envelop;
|
|
|
|
}
|
|
}
|
|
}
|