|  | @ -1066,19 +1066,28 @@ public class MonitorPlatformService  {
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     public JSONObject getBrandsAndManufacturer(){
 |  |     public JSONObject getBrandsAndManufacturer(){
 | 
												
													
														
															|  |         try {
 |  |         try {
 | 
												
													
														
															|  |             String sql  = "select count(DISTINCT pd.device_name) as total,pd.device_name,wd.device_name,wd.manufacturer from wlyy.wlyy_patient_device pd,device.wlyy_devices wd \n" +
 |  | 
 | 
												
													
														
															|  | 
 |  |             String sql  = "select count(DISTINCT A.device_name) as total,A.device_name,A.manufacturer from (\n" +
 | 
												
													
														
															|  | 
 |  |                     "select pd.device_name,wd.manufacturer from wlyy.wlyy_patient_device pd,device.wlyy_devices wd\n" +
 | 
												
													
														
															|  |                     "where pd.device_sn = wd.device_code \n" +
 |  |                     "where pd.device_sn = wd.device_code \n" +
 | 
												
													
														
															|  |                     "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' \n" +
 |  | 
 | 
												
													
														
															|  |                     "group by wd.manufacturer_code \n" +
 |  | 
 | 
												
													
														
															|  | 
 |  |                     "and wd.manufacturer_code is not null and wd.manufacturer_code <>''\n" +
 | 
												
													
														
															|  | 
 |  |                     "GROUP BY wd.manufacturer_code,pd.device_name\n" +
 | 
												
													
														
															|  | 
 |  |                     "UNION\n" +
 | 
												
													
														
															|  | 
 |  |                     "select '健康小屋' device_name,manufacturer from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
 | 
												
													
														
															|  | 
 |  |                     ")A\n" +
 | 
												
													
														
															|  | 
 |  |                     "GROUP BY A.manufacturer\n" +
 | 
												
													
														
															|  |                     "ORDER BY total desc";
 |  |                     "ORDER BY total desc";
 | 
												
													
														
															|  |             List<Map<String,Object>>Manufacturers = jdbcTemplate.queryForList(sql);
 |  |             List<Map<String,Object>>Manufacturers = jdbcTemplate.queryForList(sql);
 | 
												
													
														
															|  |             JSONObject result = new JSONObject();
 |  |             JSONObject result = new JSONObject();
 | 
												
													
														
															|  |             JSONArray arr = JSONArray.parseArray(JSON.toJSONString(Manufacturers));
 |  |             JSONArray arr = JSONArray.parseArray(JSON.toJSONString(Manufacturers));
 | 
												
													
														
															|  |             result.put("Manufacturers",arr);
 |  |             result.put("Manufacturers",arr);
 | 
												
													
														
															|  |             sql = "select count(DISTINCT pd.device_name)from wlyy.wlyy_patient_device pd,device.wlyy_devices wd \n" +
 |  | 
 | 
												
													
														
															|  | 
 |  |             sql = "select count(DISTINCT A.device_name)from (\n" +
 | 
												
													
														
															|  | 
 |  |                     "select pd.device_name from wlyy.wlyy_patient_device pd,device.wlyy_devices wd\n" +
 | 
												
													
														
															|  |                     "where pd.device_sn = wd.device_code \n" +
 |  |                     "where pd.device_sn = wd.device_code \n" +
 | 
												
													
														
															|  |                     "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' \n" +
 |  | 
 | 
												
													
														
															|  |                     "ORDER BY pd.device_name desc  ";
 |  | 
 | 
												
													
														
															|  | 
 |  |                     "and wd.manufacturer_code is not null and wd.manufacturer_code <>''\n" +
 | 
												
													
														
															|  | 
 |  |                     "GROUP BY wd.manufacturer_code,pd.device_name\n" +
 | 
												
													
														
															|  | 
 |  |                     "UNION\n" +
 | 
												
													
														
															|  | 
 |  |                     "select '健康小屋' device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
 | 
												
													
														
															|  | 
 |  |                     ")A";
 | 
												
													
														
															|  |             Integer BrandsCount = jdbcTemplate.queryForObject(sql,Integer.class);
 |  |             Integer BrandsCount = jdbcTemplate.queryForObject(sql,Integer.class);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             result.put("Brands",BrandsCount);
 |  |             result.put("Brands",BrandsCount);
 | 
												
											
												
													
														
															|  | @ -1162,8 +1171,8 @@ public class MonitorPlatformService  {
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
													
														
															|  |                 result.put("deviceInfo",arr);//设备信息统计
 |  |                 result.put("deviceInfo",arr);//设备信息统计
 | 
												
													
														
															|  |                 //统计物联率设备,失联设备
 |  |                 //统计物联率设备,失联设备
 | 
												
													
														
															|  |                 sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ");
 |  | 
 | 
												
													
														
															|  |                 sql.append("where d.device_sn in(select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>'') "+sqlCondition+" ");
 |  | 
 | 
												
													
														
															|  | 
 |  |                 sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f   ");
 | 
												
													
														
															|  | 
 |  |                 sql.append("where  f.`status`>0 and f.patient = d.`user` and d.device_sn in(select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>'') "+sqlCondition+" ");
 | 
												
													
														
															|  |                 if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
 |  |                 if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
 | 
												
													
														
															|  |                     sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
 |  |                     sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
											
												
													
														
															|  | @ -1184,7 +1193,7 @@ public class MonitorPlatformService  {
 | 
												
													
														
															|  |                 result.put("lostContact",lostContact);
 |  |                 result.put("lostContact",lostContact);
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |             //deviceType包含小屋且设备名称为空||deviceType包含小屋且设备名称为健康小屋。
 |  |             //deviceType包含小屋且设备名称为空||deviceType包含小屋且设备名称为健康小屋。
 | 
												
													
														
															|  |           if ((deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isBlank(deviceName))||(deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)&&"健康小屋".equals(deviceName))){
 |  | 
 | 
												
													
														
															|  | 
 |  |           if ((deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType))||(deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)&&"健康小屋".equals(deviceName))){
 | 
												
													
														
															|  |                 String sql = "select COUNT(*) from xmiot.iot_equipmet_detail";
 |  |                 String sql = "select COUNT(*) from xmiot.iot_equipmet_detail";
 | 
												
													
														
															|  |                 Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
 |  |                 Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
 | 
												
													
														
															|  |                 JSONObject tmp = new JSONObject();
 |  |                 JSONObject tmp = new JSONObject();
 | 
												
											
												
													
														
															|  | @ -1236,4 +1245,121 @@ public class MonitorPlatformService  {
 | 
												
													
														
															|  |         return filesize + "%";
 |  |         return filesize + "%";
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 获取物联率与失联率
 | 
												
													
														
															|  | 
 |  |      * @param startTime
 | 
												
													
														
															|  | 
 |  |      * @param endTime
 | 
												
													
														
															|  | 
 |  |      * @param deviceType
 | 
												
													
														
															|  | 
 |  |      * @param area
 | 
												
													
														
															|  | 
 |  |      * @param hospital
 | 
												
													
														
															|  | 
 |  |      * @param quotaCode
 | 
												
													
														
															|  | 
 |  |      * @return
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     public JSONObject iotAndLostRange(String startTime,String endTime,
 | 
												
													
														
															|  | 
 |  |                                       String deviceType,String area,String hospital,String quotaCode){
 | 
												
													
														
															|  | 
 |  |         JSONObject result = new JSONObject();
 | 
												
													
														
															|  | 
 |  |         StringBuffer sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f WHERE f.`status`>0 and f.patient = d.`user`  ");
 | 
												
													
														
															|  | 
 |  |         StringBuffer sqlCondition = new StringBuffer(" where 1=1 ");
 | 
												
													
														
															|  | 
 |  |         if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
 | 
												
													
														
															|  | 
 |  |             sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         Integer grantCount = jdbcTemplate.queryForObject(sql.toString(),Integer.class);//单体征设备发放总数
 | 
												
													
														
															|  | 
 |  |         result.put("totalAll",grantCount);
 | 
												
													
														
															|  | 
 |  |         Integer total=0;
 | 
												
													
														
															|  | 
 |  |         if("1".equals(quotaCode)){
 | 
												
													
														
															|  | 
 |  |             //物联
 | 
												
													
														
															|  | 
 |  |             sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f ");
 | 
												
													
														
															|  | 
 |  |             if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
 | 
												
													
														
															|  | 
 |  |                 sql.append("LEFT JOIN wlyy.dm_hospital dh on f.hospital = dh.`code` ");
 | 
												
													
														
															|  | 
 |  |                 sqlCondition.append("and dh.town='"+area+"' ");
 | 
												
													
														
															|  | 
 |  |                 if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
 | 
												
													
														
															|  | 
 |  |                     sqlCondition.append("and dh.code='"+hospital+"' ");
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             sqlCondition.append("and  f.`status`>0 and f.patient = d.`user` and d.device_sn in(select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>''  ");
 | 
												
													
														
															|  | 
 |  |             if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)&&org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
 | 
												
													
														
															|  | 
 |  |                 sqlCondition.append("and record_date >='"+startTime+" 00:00:00' and record_date<='"+endTime+" 23:59:59'  ");
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             sqlCondition.append(" ) and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
 | 
												
													
														
															|  | 
 |  |             sql.append(sqlCondition);
 | 
												
													
														
															|  | 
 |  |             total=jdbcTemplate.queryForObject(sql.toString(),Integer.class);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         //失联
 | 
												
													
														
															|  | 
 |  |         if("2".equals(quotaCode)){
 | 
												
													
														
															|  | 
 |  |             sql = new StringBuffer("SELECT count(*) from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f");
 | 
												
													
														
															|  | 
 |  |             sqlCondition = new StringBuffer(" where 1=1 ");
 | 
												
													
														
															|  | 
 |  |             if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
 | 
												
													
														
															|  | 
 |  |                 sql.append("LEFT JOIN wlyy.dm_hospital dh on f.hospital = dh.`code` ");
 | 
												
													
														
															|  | 
 |  |                 sqlCondition.append("and dh.town='"+area+"' ");
 | 
												
													
														
															|  | 
 |  |                 if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
 | 
												
													
														
															|  | 
 |  |                     sqlCondition.append("and dh.code='"+hospital+"' ");
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             sqlCondition.append("and f.`status`>0 and f.patient = d.`user` ");
 | 
												
													
														
															|  | 
 |  |             sqlCondition.append("  and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
 | 
												
													
														
															|  | 
 |  |             sqlCondition.append("and d.device_sn not in (select device_sn from ( select device_sn,MAX(record_date) record_date from device.wlyy_patient_health_index where device_sn<>'' GROUP BY device_sn)a ");
 | 
												
													
														
															|  | 
 |  |             sqlCondition.append("where TIMESTAMPDIFF(DAY,record_date,NOW()) <= 7)");
 | 
												
													
														
															|  | 
 |  |             sql.append(sqlCondition);
 | 
												
													
														
															|  | 
 |  |             total=jdbcTemplate.queryForObject(sql.toString(),Integer.class);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if ((org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("5"))||org.apache.commons.lang3.StringUtils.isBlank(deviceType)){
 | 
												
													
														
															|  | 
 |  |             String sqll = "select COUNT(*) from xmiot.iot_equipmet_detail";
 | 
												
													
														
															|  | 
 |  |             Integer count = jdbcTemplate.queryForObject(sqll,Integer.class);
 | 
												
													
														
															|  | 
 |  |             result.put("totalAll",grantCount+count);
 | 
												
													
														
															|  | 
 |  |             count =0;
 | 
												
													
														
															|  | 
 |  |             if("1".equals(quotaCode)){//小屋物联率
 | 
												
													
														
															|  | 
 |  |                 sql= new StringBuffer("select count(*) from xmiot.iot_equipmet_detail ");
 | 
												
													
														
															|  | 
 |  |                 sqlCondition = new StringBuffer(" where 1=1 ");
 | 
												
													
														
															|  | 
 |  |                 if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
 | 
												
													
														
															|  | 
 |  |                     sqlCondition.append("and belong_are_code='"+area+"' ");
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |                 sqlCondition.append("and device_code in (select DISTINCT sn device_model from xmiot.wlyy_iot_m where 1=1 ");
 | 
												
													
														
															|  | 
 |  |                 if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)&&org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
 | 
												
													
														
															|  | 
 |  |                     sqlCondition.append("and create_time >='"+startTime+" 00:00:00' and create_time<='"+endTime+" 23:59:59'  ");
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |                 sql.append(sqlCondition+")");
 | 
												
													
														
															|  | 
 |  |                 count = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             if("2".equals(quotaCode)){//小屋失联数0
 | 
												
													
														
															|  | 
 |  |                 count=0;
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             result.put("total",total+count);//互联设备\失联设备数量
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         DecimalFormat df = new DecimalFormat("0.00");
 | 
												
													
														
															|  | 
 |  |         if (result.getInteger("totalAll") > 0) {
 | 
												
													
														
															|  | 
 |  |             result.put("totalRange", df.format(result.getDouble("total") > 0.0 ? ((result.getDouble("total")) / (result.getInteger("totalAll") * 1.0000) * 100) : 0.0) );
 | 
												
													
														
															|  | 
 |  |         } else {
 | 
												
													
														
															|  | 
 |  |             result.put("totalRange", 0.0 );
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         return result;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 获取设备品牌详细
 | 
												
													
														
															|  | 
 |  |      * @param deviceType
 | 
												
													
														
															|  | 
 |  |      * @return
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     public JSONObject getBrandsDetail(String deviceType){
 | 
												
													
														
															|  | 
 |  |         try {
 | 
												
													
														
															|  | 
 |  |             StringBuffer sql = new StringBuffer("select DISTINCT A.device_name from (\n" +
 | 
												
													
														
															|  | 
 |  |                     "select pd.device_name from wlyy.wlyy_patient_device pd,device.wlyy_devices wd\n" +
 | 
												
													
														
															|  | 
 |  |                     "where pd.device_sn = wd.device_code \n" +
 | 
												
													
														
															|  | 
 |  |                     "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' ");
 | 
												
													
														
															|  | 
 |  |             if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
 | 
												
													
														
															|  | 
 |  |                 sql.append("and pd.category_code in ('").append(deviceType.replace(",","','")).append("') ");
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             sql.append("GROUP BY wd.manufacturer_code,pd.device_name ");
 | 
												
													
														
															|  | 
 |  |             if ((org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("5"))||org.apache.commons.lang3.StringUtils.isBlank(deviceType)){
 | 
												
													
														
															|  | 
 |  |                 sql.append("UNION select '健康小屋' device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name");
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             sql.append(")A");
 | 
												
													
														
															|  | 
 |  |             List<String> list = jdbcTemplate.queryForList(sql.toString(),String.class);
 | 
												
													
														
															|  | 
 |  |             JSONObject result = new JSONObject();
 | 
												
													
														
															|  | 
 |  |             result.put("brands",list);
 | 
												
													
														
															|  | 
 |  |             return result;
 | 
												
													
														
															|  | 
 |  |         }catch (Exception e){
 | 
												
													
														
															|  | 
 |  |             e.printStackTrace();
 | 
												
													
														
															|  | 
 |  |             return null;
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | }
 |  | }
 |