| 
					
				 | 
			
			
				@ -7,9 +7,12 @@ import com.yihu.jw.care.dao.device.PatientDeviceDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.PatientDeviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.DevicePatientDevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.es.util.ElasticsearchUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.es.util.SaveModel; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.base.BaseRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.models.auth.In; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang.StringUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -44,6 +47,9 @@ public class DetectionPlatformService  { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientDeviceDao patientDeviceDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientDao patientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ElasticsearchUtil elasticsearchUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static final String defalutArea = "330100"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 体征监测 安防监护 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -335,35 +341,47 @@ public class DetectionPlatformService  { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return nightRecordList;  //起夜记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getDistributionOfWarningTypes(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getDistributionOfWarningTypes() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject object = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filter=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(listtmp.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgCodes = orgCodes.replaceAll(",","','"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filter = " and hospital not in ('"+orgCodes+"') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /****预警类型分布****/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT hsd.`value`,aa.count FROM base_system_dict_entry hsd LEFT JOIN \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(SELECT topic_item,COUNT(1) count FROM base_security_monitoring_order GROUP BY topic_item)aa \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(SELECT topic_item,COUNT(1) count FROM base_security_monitoring_order where 1=1 "+filter+" GROUP BY topic_item)aa \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ON CONVERT(hsd.`code` USING utf8) COLLATE utf8_unicode_ci = aa.topic_item  WHERE hsd.remark = 'security'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /****工单总量****/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlAll = "SELECT COUNT(1) count FROM base_security_monitoring_order"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer countAll = jdbcTemplate.queryForObject(sqlAll,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(DateUtil.getStringDateShort(),DateUtil.getStringDateShort(),defalutArea,2,"46","2","4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long countAll = saveModel.getResult2().longValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /****误报警数量****/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql1 = "SELECT COUNT(1) count FROM base_security_monitoring_order WHERE emergency_cancel IS NOT NULL OR emergency_cancel != ''"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer falseAlarmCount = jdbcTemplate.queryForObject(sql1,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //安防误报警 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        saveModel = elasticsearchUtil.findOneDateQuotaLevel2NoSlaveKey1(DateUtil.getStringDateShort(),defalutArea,2,"46","2","-2","4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long falseAlarmCount = saveModel.getResult2().longValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /****响应数量****/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String responseCountSql = "SELECT COUNT(1) count FROM base_security_monitoring_order WHERE (emergency_cancel IS NOT NULL OR emergency_cancel != '') OR `status` = 0 GROUP BY id"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> responseList = jdbcTemplate.queryForList(responseCountSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer responseCount = responseList.size(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /****响应数量**误报警+完成**/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        saveModel = elasticsearchUtil.findOneDateQuotaLevel2NoSlaveKey1(DateUtil.getStringDateShort(),defalutArea,2,"46","2","-2","4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long responseCount = saveModel.getResult2().longValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        saveModel = elasticsearchUtil.findOneDateQuotaLevel2NoSlaveKey1(DateUtil.getStringDateShort(),defalutArea,2,"46","2","0","4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        responseCount += saveModel.getResult2().longValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("distributionOfWarning",list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("countAll",countAll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("falseAlarmCount",falseAlarmCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("responseCount",responseCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /****误报警率****/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("falseAlarmLaw",getRange(falseAlarmCount,countAll)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("falseAlarmLaw",getRange(Integer.parseInt(falseAlarmCount+""),Integer.parseInt(countAll+""))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /****响应率****/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("responseLaw",getRange(responseCount,countAll)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("responseLaw",getRange(Integer.parseInt(responseCount+"") ,Integer.parseInt(countAll+""))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return object; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |