|  | @ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONArray;
 | 
												
													
														
															|  | import com.alibaba.fastjson.JSONObject;
 |  | import com.alibaba.fastjson.JSONObject;
 | 
												
													
														
															|  | import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
 |  | import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
 | 
												
													
														
															|  | import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
 |  | import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.es.util.ElasticsearchUtil;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.es.util.SaveModel;
 | 
												
													
														
															|  | import com.yihu.jw.restmodel.web.PageEnvelop;
 |  | import com.yihu.jw.restmodel.web.PageEnvelop;
 | 
												
													
														
															|  | import com.yihu.jw.util.common.IdCardUtil;
 |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
												
													
														
															|  | import org.apache.commons.lang3.StringUtils;
 |  | import org.apache.commons.lang3.StringUtils;
 | 
												
											
												
													
														
															|  | @ -27,7 +29,14 @@ public class WlyygcStatisticsService {
 | 
												
													
														
															|  |     private JdbcTemplate jdbcTemplate;
 |  |     private JdbcTemplate jdbcTemplate;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private BaseEmergencyWarnLogDao logDao;
 |  |     private BaseEmergencyWarnLogDao logDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private ElasticsearchUtil elasticsearchUtil;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private StatisticsService statisticsService;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     private static final String defalutArea = "330100";
 | 
												
													
														
															|  | 
 |  |     private static final Integer defalutLevel = 2;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /***************************************************华联社区******************************************************/
 |  |     /***************************************************华联社区******************************************************/
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
											
												
													
														
															|  | @ -628,7 +637,8 @@ public class WlyygcStatisticsService {
 | 
												
													
														
															|  |                 " o.address AS address," +
 |  |                 " o.address AS address," +
 | 
												
													
														
															|  |                 " p. NAME AS `name`," +
 |  |                 " p. NAME AS `name`," +
 | 
												
													
														
															|  |                 " t. STATUS AS `status`," +
 |  |                 " t. STATUS AS `status`," +
 | 
												
													
														
															|  |                 " o. NAME AS `orgName`" +
 |  | 
 | 
												
													
														
															|  | 
 |  |                 " o. NAME AS `orgName`," +
 | 
												
													
														
															|  | 
 |  |                 " p.idcard AS idcard" +
 | 
												
													
														
															|  |                 " FROM" +
 |  |                 " FROM" +
 | 
												
													
														
															|  |                 " base_patient p" +
 |  |                 " base_patient p" +
 | 
												
													
														
															|  |                 " LEFT JOIN base_doctor_patient_tmp t ON t.patient = p.id" +
 |  |                 " LEFT JOIN base_doctor_patient_tmp t ON t.patient = p.id" +
 | 
												
											
												
													
														
															|  | @ -688,6 +698,115 @@ public class WlyygcStatisticsService {
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 幼儿信息计数
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     public JSONObject infantTotal(String endDate) throws Exception {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         JSONObject res = new JSONObject();
 | 
												
													
														
															|  | 
 |  |         // 64 活动浏览数
 | 
												
													
														
															|  | 
 |  |         // 65 课程播放数
 | 
												
													
														
															|  | 
 |  |         // 66 活动报名数
 | 
												
													
														
															|  | 
 |  |         //28 新生儿-在线咨询总数
 | 
												
													
														
															|  | 
 |  |         //35 新生儿-上门辅导-服务工单数
 | 
												
													
														
															|  | 
 |  |         SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "64", SaveModel.timeLevel_DDL);
 | 
												
													
														
															|  | 
 |  |         res.put("activity_1", saveModel.getResult2().longValue());
 | 
												
													
														
															|  | 
 |  |         saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "65", SaveModel.timeLevel_DDL);
 | 
												
													
														
															|  | 
 |  |         res.put("activity_2", saveModel.getResult2().longValue());
 | 
												
													
														
															|  | 
 |  |         saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "66", SaveModel.timeLevel_DDL);
 | 
												
													
														
															|  | 
 |  |         res.put("activity_3", saveModel.getResult2().longValue());
 | 
												
													
														
															|  | 
 |  |         saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "28", SaveModel.timeLevel_DDL);
 | 
												
													
														
															|  | 
 |  |         res.put("index_28", saveModel.getResult2().longValue());
 | 
												
													
														
															|  | 
 |  |         saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "35", SaveModel.timeLevel_DDL);
 | 
												
													
														
															|  | 
 |  |         res.put("index_35", saveModel.getResult2().longValue());
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         //托育机构
 | 
												
													
														
															|  | 
 |  |         String orgSql = "SELECT COUNT(id) FROM base_org WHERE type = 4 AND del = 1 AND `code` NOT IN (SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' and dict_code is not null)";
 | 
												
													
														
															|  | 
 |  |         List<Integer> totalList = jdbcTemplate.queryForList(orgSql, Integer.class);
 | 
												
													
														
															|  | 
 |  |         res.put("orgTotal",totalList.get(0));
 | 
												
													
														
															|  | 
 |  |         //教师
 | 
												
													
														
															|  | 
 |  |         String teacherSql = "SELECT COUNT(id) FROM base_doctor WHERE doctor_level = 3 AND del =1 AND id NOT IN(SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_teacher' and dict_code is not null)";
 | 
												
													
														
															|  | 
 |  |         totalList = jdbcTemplate.queryForList(teacherSql, Integer.class);
 | 
												
													
														
															|  | 
 |  |         res.put("teacherTotal",totalList.get(0));
 | 
												
													
														
															|  | 
 |  |         String infantSql = "SELECT COUNT(id) FROM base_patient WHERE archive_type = 2 AND del = 1 AND id NOT IN (SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' and dict_code is not null)";
 | 
												
													
														
															|  | 
 |  |         //照护幼儿
 | 
												
													
														
															|  | 
 |  |         totalList = jdbcTemplate.queryForList(infantSql,Integer.class);
 | 
												
													
														
															|  | 
 |  |         res.put("zh_infantTotal",totalList.get(0));
 | 
												
													
														
															|  | 
 |  |         //幼儿总数
 | 
												
													
														
															|  | 
 |  |         String infantTotalSql = "SELECT infant_num FROM base_older_num ";
 | 
												
													
														
															|  | 
 |  |         totalList = jdbcTemplate.queryForList(infantTotalSql,Integer.class);
 | 
												
													
														
															|  | 
 |  |         res.put("infantTotal",totalList.get(0));
 | 
												
													
														
															|  | 
 |  |         //照护率
 | 
												
													
														
															|  | 
 |  |          res.put("zh_rate", (Float.parseFloat(res.get("zh_infantTotal").toString()) / (float) 1335 * 100) + "%");
 | 
												
													
														
															|  | 
 |  |         return res;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 老人信息计数
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     public JSONObject oldTotal(String endDate) throws Exception {
 | 
												
													
														
															|  | 
 |  |         JSONObject res = new JSONObject();
 | 
												
													
														
															|  | 
 |  |         //老人总数
 | 
												
													
														
															|  | 
 |  |         String totalList = "SELECT lsqs_num+bss_num+jss_num+ybs_num AS total FROM base_older_num";
 | 
												
													
														
															|  | 
 |  |         List<Integer> integers = jdbcTemplate.queryForList(totalList, Integer.class);
 | 
												
													
														
															|  | 
 |  |         res.put("oldTotal",integers.get(0));
 | 
												
													
														
															|  | 
 |  |         //照护老人总数
 | 
												
													
														
															|  | 
 |  |         String zhTotalList = "SELECT COUNT(id) FROM base_patient where archive_type = 1 AND del = 1 AND id NOT IN(SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE  dict_name = 'jkzl_older'  and dict_code is not null) ";
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         //设备总数
 | 
												
													
														
															|  | 
 |  |         String deviceSql ="SELECT COUNT(id) AS total, COUNT(IF(device_type = 0,device_type,NULL)) AS jk,COUNT(IF(device_type = 1,device_type,NULL)) AS af FROM wlyy_devices where 1=1 ";
 | 
												
													
														
															|  | 
 |  |         //医疗机构
 | 
												
													
														
															|  | 
 |  |         //养老机构
 | 
												
													
														
															|  | 
 |  |         String orgSql = "SELECT COUNT(IF(type = 2,type,null)) AS yl,COUNT(IF(type = 3,type,null)) AS yangl  FROM base_org WHERE del = 1 AND `code` NOT IN (SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' and dict_code is not null) ";
 | 
												
													
														
															|  | 
 |  |         //助老员
 | 
												
													
														
															|  | 
 |  |         //医护人员
 | 
												
													
														
															|  | 
 |  |         //社工
 | 
												
													
														
															|  | 
 |  |         String zlSql = "SELECT COUNT(IF(doctor_level = 1,doctor_level,null)) AS yh,COUNT(IF(doctor_level = 2,doctor_level,null)) AS sg,COUNT(IF(doctor_level = 4,doctor_level,null)) AS zly FROM base_doctor WHERE id NOT IN(SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_user' or dict_name = 'jkzl_helper') and dict_code is not null) ";
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(endDate)) {
 | 
												
													
														
															|  | 
 |  |             zhTotalList += " and create_time <= '"+endDate+"'";
 | 
												
													
														
															|  | 
 |  |             orgSql += " and create_time <= '"+endDate+"'";
 | 
												
													
														
															|  | 
 |  |             zlSql += " and create_time <= '"+endDate+"'";
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         integers = jdbcTemplate.queryForList(zhTotalList,Integer.class);
 | 
												
													
														
															|  | 
 |  |         res.put("zh_oldTotal",integers.get(0));
 | 
												
													
														
															|  | 
 |  |         //照护率
 | 
												
													
														
															|  | 
 |  |         res.put("zh_rate", (Float.parseFloat(res.get("zh_oldTotal").toString()) / Float.parseFloat(res.get("oldTotal").toString()) * 100) + "%");
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> deviceList = jdbcTemplate.queryForList(deviceSql);
 | 
												
													
														
															|  | 
 |  |         res.put("deviceTotal",deviceList.get(0).get("total"));
 | 
												
													
														
															|  | 
 |  |         res.put("deviceJkTotal",deviceList.get(0).get("jk"));
 | 
												
													
														
															|  | 
 |  |         res.put("deviceAfTotal",deviceList.get(0).get("af"));
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> orgList = jdbcTemplate.queryForList(orgSql);
 | 
												
													
														
															|  | 
 |  |         res.put("yanglao",orgList.get(0).get("yangl"));
 | 
												
													
														
															|  | 
 |  |         res.put("yl",orgList.get(0).get("yl"));
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> maps = jdbcTemplate.queryForList(zlSql);
 | 
												
													
														
															|  | 
 |  |         res.put("yl",maps.get(0).get("yh"));
 | 
												
													
														
															|  | 
 |  |         res.put("sg",maps.get(0).get("sg"));
 | 
												
													
														
															|  | 
 |  |         res.put("zly",maps.get(0).get("zly"));
 | 
												
													
														
															|  | 
 |  |         //指标
 | 
												
													
														
															|  | 
 |  |         JSONArray jsonArray = statisticsService.cloudCareForTheElderly(endDate, defalutArea, defalutLevel);
 | 
												
													
														
															|  | 
 |  |         res.put("label",jsonArray);
 | 
												
													
														
															|  | 
 |  |         JSONObject jsonObject = statisticsService.statisticsOrderServer("50", endDate, 2, "2");
 | 
												
													
														
															|  | 
 |  |         res.put("age",jsonObject);
 | 
												
													
														
															|  | 
 |  |         // 紧急预警
 | 
												
													
														
															|  | 
 |  |         String jjyjSql = "SELECT patient_name FROM base_emergency_assistance_order WHERE `status` = 1 ";
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(endDate)) {
 | 
												
													
														
															|  | 
 |  |             jjyjSql += "AND create_time <= '"+endDate+"'";
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> jjyj = jdbcTemplate.queryForList(jjyjSql);
 | 
												
													
														
															|  | 
 |  |         res.put("emeName",jjyj);
 | 
												
													
														
															|  | 
 |  |         return res;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 社区计数
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
													
														
															|  |      * 排除测试数据
 |  |      * 排除测试数据
 |