|
@ -2,6 +2,7 @@ package com.yihu.wlyy.service.app.statisticsES;
|
|
|
|
|
|
import com.yihu.wlyy.config.es.ElasticFactory;
|
|
|
import com.yihu.wlyy.entity.address.Town;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
|
|
|
import com.yihu.wlyy.entity.organization.Hospital;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
|
|
@ -6130,4 +6131,117 @@ public class StatisticsESService {
|
|
|
return rsJs;
|
|
|
}*/
|
|
|
|
|
|
public JSONArray getDeviceLowLevelTotal(String date, String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String low_level = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
if (date.compareTo(dateFormat.format(new Date())) >= 0) {
|
|
|
date = elasticsearchUtil.getQuotaTime();
|
|
|
}
|
|
|
List<SaveModel> esModelList = new ArrayList<>();
|
|
|
|
|
|
if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
|
|
|
String time = getStatisticsTime();
|
|
|
String sql ="SELECT" +
|
|
|
" pd.doctor team," +
|
|
|
" pd.doctor_name teamName," +
|
|
|
" COUNT(1) result1" +
|
|
|
" FROM" +
|
|
|
" wlyy_patient_device pd," +
|
|
|
" wlyy_sign_family sf" +
|
|
|
" WHERE" +
|
|
|
" pd.user_idcard = sf.idcard" +
|
|
|
" AND sf.type = 2" +
|
|
|
" AND pd.del = 0" +
|
|
|
" AND sf. STATUS IN (1, 2)" +
|
|
|
" AND pd.czrq < '"+time+"'" +
|
|
|
" AND sf.sign_year = '"+year+"'";
|
|
|
if(level==3){
|
|
|
sql +=" AND LEFT(sf.hospital,6)= '"+area+"'";
|
|
|
}else if (level==4){
|
|
|
sql +=" AND sf.hospital = '"+area+"'";
|
|
|
}
|
|
|
sql +=" GROUP BY team,teamName";
|
|
|
esModelList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SaveModel.class));
|
|
|
}else {
|
|
|
esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(date, area, level, index, SaveModel.timeLevel_DDL, low_level);
|
|
|
}
|
|
|
|
|
|
if (esModelList != null && esModelList.size() > 0) {
|
|
|
for (SaveModel one : esModelList) {
|
|
|
Map<String, Object> maps = new HashMap<String, Object>();
|
|
|
maps.put("amount", one.getResult1().intValue());
|
|
|
if (low_level.equals("3")) {
|
|
|
maps.put("code", one.getTown());
|
|
|
maps.put("name", one.getTownName());
|
|
|
} else if (low_level.equals("4")) {
|
|
|
maps.put("code", one.getHospital());
|
|
|
maps.put("name", one.getHospitalName());
|
|
|
} else if (low_level.equals("5")) {
|
|
|
|
|
|
if ( StringUtils.isNotEmpty(one.getTeam()) && StringUtils.isEmpty(one.getTownName())){
|
|
|
maps.put("code", one.getTeam());
|
|
|
Doctor doctor = doctorDao.findByCode(one.getTeam());
|
|
|
if (doctor!=null){
|
|
|
maps.put("name", doctor.getName());
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isEmpty(one.getTeam())){
|
|
|
maps.put("code","0");
|
|
|
maps.put("name", "其他");
|
|
|
}
|
|
|
}
|
|
|
resultList.add(maps);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 结果为空时,自建结果集
|
|
|
if (resultList == null || resultList.size() < 1) {
|
|
|
resultList = getLowLevelMapKey(level, low_level, area);
|
|
|
}
|
|
|
|
|
|
if (resultList != null) {
|
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
|
|
|
|
|
|
if (!low_level.equals("5")) {
|
|
|
PopulationBase peopleNum = getPopulationBase(area, year);
|
|
|
if (peopleNum != null) {
|
|
|
map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
|
|
|
map.put("targetRate", df.format(peopleNum.getTaskNum() * 1.0000 / peopleNum.getNum() * 100));
|
|
|
map.put("rateString", map.get("amount") + "/" + peopleNum.getNum());
|
|
|
map.put("taskRateString", map.get("amount") + "/" + peopleNum.getTaskNum());
|
|
|
map.put("targetRateString", peopleNum.getTaskNum() + "/" + peopleNum.getNum());
|
|
|
map.put("num", peopleNum.getNum());
|
|
|
map.put("task", peopleNum.getTaskNum());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
|
|
|
translateTeamLeaderName(resultList);
|
|
|
}*/
|
|
|
|
|
|
Collections.sort(resultList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
long map1value = (long) o1.get("amount");
|
|
|
long map2value = (long) o2.get("amount");
|
|
|
|
|
|
if (map1value - map2value > 0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value - map2value < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return new JSONArray(resultList);
|
|
|
} else {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
}
|
|
|
}
|