| 
					
				 | 
			
			
				@ -16,14 +16,18 @@ import com.yihu.iot.util.excel.HibenateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.iot.dict.IotSystemDictDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.iot.equipment.IotEquipmentDetailDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.MixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.LatitudeUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.http.HttpClientUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import iot.device.LocationDataVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.http.Consts; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.http.client.utils.URLEncodedUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.http.message.BasicNameValuePair; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.jasper.tagplugins.jstl.core.ForEach; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.elasticsearch.core.geo.GeoPoint; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.BeanPropertyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.SqlInOutParameter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -31,6 +35,7 @@ import org.springframework.util.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestMethod; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.print.DocFlavor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.DecimalFormat; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -86,29 +91,47 @@ public class MonitorPlatformService  { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        MixEnvelop<LocationDataVO, LocationDataVO> envelopTmp = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer total = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(org.apache.commons.lang.StringUtils.isNotBlank(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String re = searchpatientdevicesn(type, page, size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject json = JSON.parseObject(re); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(json.getInteger("status")==200){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject data = json.getJSONObject("data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                total = data.getInteger("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONArray list = data.getJSONArray("list"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for(int i=0;i<list.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray jsonArrayTemp = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject deviceSn = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceSn.put("andOr","or"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceSn.put("field","deviceSn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceSn.put("condition","="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceSn.put("value",list.getString(i)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonArrayTemp.add(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("filter",jsonArrayTemp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("page",page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("size",size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //figureLabelSerachService.getFigureLabelByList(locationDataVOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(locationDataVOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    envelop.getDetailModelList().addAll(list2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject json = iotSearchPatientDeviceSN(type,page,size,deviceName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            total = json.getInteger("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray list = json.getJSONArray("list"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(int i=0;i<list.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sql ="select id, idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "create_time createTime,device_name equimentName from device.wlyy_patient_device_location where del=0 and  device_sn='"+list.getString(i)+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<Map<String,Object>> result = jdbcTemplate.queryForList(sql.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<LocationDataVO> locationDataVOList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.forEach(map->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    LocationDataVO locationDataVO = new LocationDataVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject location = JSONObject.parseObject(map.get("location").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    GeoPoint geoPoint = new GeoPoint(Double.parseDouble(location.get("lat").toString()),Double.parseDouble(location.get("lon").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setId(map.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setIdCard(map.get("idCard").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setCategoryCode(map.get("categoryCode").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setDeviceSn(map.get("deviceSn").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setLocation(geoPoint); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setDeviceTime(map.get("deviceTime").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setLabel(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setDiseaseCondition(Integer.parseInt(map.get("diseaseCondition").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setCreateTime(map.get("createTime").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    locationDataVO.setName(ConcealUtil.nameOrAddrConceal(map.get("name").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setCode(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setEquimentName((String) map.get("equimentName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVOList.add(locationDataVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                JSONArray jsonArrayTemp = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                JSONObject deviceSn = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                deviceSn.put("andOr","or"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                deviceSn.put("field","deviceSn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                deviceSn.put("condition","="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                deviceSn.put("value",list.getString(i)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                jsonArrayTemp.add(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                jsonObject.put("filter",jsonArrayTemp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                jsonObject.put("page",page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                jsonObject.put("size",size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //figureLabelSerachService.getFigureLabelByList(locationDataVOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(locationDataVOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                envelop.getDetailModelList().addAll(list2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            envelop.setTotalCount(total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return envelop; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -136,66 +159,144 @@ public class MonitorPlatformService  { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        envelop.getDetailModelList().addAll(euipmentList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (String categoryCode:categoryCodes){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray jsonArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(diseaseCondition!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        json.put("andOr","and"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        json.put("field","diseaseCondition"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        json.put("condition","="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        json.put("value",diseaseCondition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        jsonArray.add(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if(!"5".equals(categoryCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         List<String> listTmp = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             String[] deviceNames = deviceName.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             for (String tmp :deviceNames){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 String sql="select DISTINCT device_code from device.wlyy_devices wd INNER JOIN wlyy.wlyy_patient_device pd on pd.device_sn = wd.device_code  where wd.device_name like '%"+tmp+"%' and pd.del=0  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 List<String> tmpList = jdbcTemplate.queryForList(sql,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 listTmp.addAll(tmpList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if (listTmp.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 json.put("andOr","and"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 json.put("field","deviceSn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 json.put("condition","in"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 json.put("value",listTmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 jsonArray.add(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             String sql="select DISTINCT device_code from device.wlyy_devices wd INNER JOIN wlyy.wlyy_patient_device pd on pd.device_sn = wd.device_code where 1=1 and pd.del=0 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 sql+="and pd.category_code in ('"+deviceType.replace(",","','")+"') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             List<String> tmpList = jdbcTemplate.queryForList(sql,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             json.put("andOr","and"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             json.put("field","deviceSn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             json.put("condition","in"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             json.put("value",tmpList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             jsonArray.add(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         jsonObject.put("filter",jsonArray); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         jsonObject.put("page",page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         jsonObject.put("size",size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         if (jsonArray.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(locationDataVOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             //figureLabelSerachService.getFigureLabelByList(locationDataVOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             envelop.getDetailModelList().addAll(list2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                           totalCount += iotPatientDeviceService.getESCount(jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                StringBuffer sql = new StringBuffer("select id,idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "create_time createTime,device_name equimentName\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "from device.wlyy_patient_device_location  "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                StringBuffer sqlCounts = new StringBuffer("select count(*) from device.wlyy_patient_device_location "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                StringBuffer sqlCondition  = new StringBuffer("where del=0 "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (diseaseCondition!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sqlCondition.append(" and disease_condition ="+diseaseCondition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sqlCondition.append(" and category_code in('").append(deviceType.replace(",","','")).append("') "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sqlCondition.append(" and device_name in ('").append(deviceName.replace(",","','")).append("') "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql.append(sqlCondition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sqlCounts.append(sqlCondition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql.append( " limit "+(page-1)*size+","+page*size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalCount = jdbcTemplate.queryForObject(sqlCounts.toString(),Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<Map<String,Object>> result = jdbcTemplate.queryForList(sql.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<LocationDataVO> locationDataVOList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.forEach(map->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    LocationDataVO locationDataVO = new LocationDataVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject location = JSONObject.parseObject(map.get("location").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    GeoPoint geoPoint = new GeoPoint(Double.parseDouble(location.get("lat").toString()),Double.parseDouble(location.get("lon").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setId(map.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setIdCard(map.get("idCard").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setCategoryCode(map.get("categoryCode").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setDeviceSn(map.get("deviceSn").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setLocation(geoPoint); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setDeviceTime(map.get("deviceTime").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setLabel(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setDiseaseCondition(Integer.parseInt(map.get("diseaseCondition").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setCreateTime(map.get("createTime").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    locationDataVO.setName(ConcealUtil.nameOrAddrConceal(map.get("name").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setCode(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVO.setEquimentName((String) map.get("equimentName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    locationDataVOList.add(locationDataVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(locationDataVOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                envelop.getDetailModelList().addAll(list2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                for (String categoryCode:categoryCodes){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    JSONArray jsonArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    if(diseaseCondition!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        json.put("andOr","and"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        json.put("field","diseaseCondition"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        json.put("condition","="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        json.put("value",diseaseCondition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        jsonArray.add(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                     if(!"5".equals(categoryCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         List<String> listTmp = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                             String[] deviceNames = deviceName.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                             for (String tmp :deviceNames){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                 String sql="select DISTINCT device_code  from device.wlyy_devices wd   where wd.device_name like '%"+tmp+"%'  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                 List<String> tmpList = jdbcTemplate.queryForList(sql,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                 listTmp.addAll(tmpList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                             if (listTmp.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                 json.put("andOr","and"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                 json.put("field","deviceSn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                 json.put("condition","in"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                 json.put("value",listTmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                 jsonArray.add(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            if(!"5".equals(categoryCode)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                json.put("andOr", "and"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                json.put("field", "categoryCode"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                json.put("condition", "="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                json.put("value", Integer.parseInt(categoryCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                jsonArray.add(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         jsonObject.put("filter",jsonArray); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         jsonObject.put("page",page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         jsonObject.put("size",size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         if (jsonArray.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                             List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                             List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(locationDataVOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                             //figureLabelSerachService.getFigureLabelByList(locationDataVOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                             envelop.getDetailModelList().addAll(list2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                           totalCount += iotPatientDeviceService.getESCount(jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                     if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                         break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            envelop.setTotalCount(totalCount>totalEqCount?totalCount:totalEqCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public com.alibaba.fastjson.JSONObject iotSearchPatientDeviceSN(String type,Integer page,Integer pageSize,String deviceName){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(page != 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            page = page - 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer sql = new StringBuffer("select t.device_sn from"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql.append("  ( SELECT DISTINCT d.* FROM wlyy.wlyy_patient_device d, wlyy.wlyy_sign_family f WHERE f.`status` > 0 AND f.patient = d.`user`  "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append("and d.device_name in ('").append(deviceName.replace(",","','")).append("') "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql.append("  ) t, wlyy.wlyy_patient p " ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql.append("  LEFT JOIN wlyy.wlyy_sign_patient_label_info l on  p. CODE = l.patient"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql.append("   and l.`status`=1 AND l.label_type = 3 and l.label='"+type+"'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql.append(" WHERE t.user = p. CODE limit "+page+","+pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> list = jdbcTemplate.queryForList(sql.toString(),String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer count = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer countsql = new StringBuffer("select count(t.device_sn) total from"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        countsql.append("  ( SELECT DISTINCT d.* FROM wlyy.wlyy_patient_device d, wlyy.wlyy_sign_family f WHERE f.`status` > 0 AND f.patient = d.`user`  "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            countsql.append("and d.device_name in ('").append(deviceName.replace(",","','")).append("') "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        countsql.append("   ) t,wlyy.wlyy_patient p " ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        countsql.append("  LEFT JOIN wlyy.wlyy_sign_patient_label_info l on  p. CODE = l.patient"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        countsql.append("   and l.`status`=1 AND l.label_type = 3 and l.label='"+type+"'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        countsql.append(" WHERE t.user = p. CODE "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        count = jdbcTemplate.queryForObject(countsql.toString(),Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("total",count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("list",list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 根据病种类型,搜索已绑定设备的居民设备SN码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 类型(1高血压 2糖尿病) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1027,15 +1128,26 @@ public class MonitorPlatformService  { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                jsonObject.put("filter",jsonArray1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                jsonObject.put("page",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                jsonObject.put("size",5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<LocationDataVO> list = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sqlLocation = "select idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "create_time createTime,device_name equimentName\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "from device.wlyy_patient_device_location where del=0 and  device_sn='"+deviceSn+"' limit 0,5 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    list = iotPatientDeviceService.findDeviceLocationsBySn(jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.put("locationData",list.get(0).getLocation()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.put("diseaseCondition",list.get(0).getDiseaseCondition()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<Map<String,Object>> locationDataVOList = jdbcTemplate.queryForList(sqlLocation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject location = JSONObject.parseObject(locationDataVOList.get(0).get("location").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(locationDataVOList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.put("locationData",location); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.put("diseaseCondition",Integer.parseInt(locationDataVOList.get(0).get("diseaseCondition").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.put("locationData","{}"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    list = iotPatientDeviceService.findDeviceLocationsBySn(jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    if(list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        data.put("locationData",list.get(0).getLocation()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        data.put("diseaseCondition",list.get(0).getDiseaseCondition()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        data.put("locationData","{}"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1612,4 +1724,49 @@ public class MonitorPlatformService  { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return deviceName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject savePatientDeviceLocation(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select DISTINCT pd.category_code ,pd.czrq create_time,pd.device_sn ,pd.device_name, p.disease_condition ,p.`code`,p.idcard ,p.address,sf.hospital_name\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "from  wlyy.wlyy_patient_device pd \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "INNER JOIN wlyy.wlyy_sign_family sf on pd.`user` = sf.patient and sf.`status`>0 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "INNER JOIN wlyy.wlyy_patient p on p.idcard = sf.idcard and p.`status`=1\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where  pd.del=0 and pd.category_code in (1,2)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        sql="select * from device.wlyy_patient_device_location_tmp"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        list.forEach(map->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(map.get("disease_condition")==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //未定标的居民设置成-1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("disease_condition","-1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String, String> json = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (map.get("address")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(map.get("address").toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        json = LatitudeUtils.getGeocoderLatitude(map.get("address").toString().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", "")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (json==null||map.get("address")==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (map.get("hospital_name")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (!org.apache.commons.lang3.StringUtils.isNoneBlank(map.get("hospital_name").toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            json = LatitudeUtils.getGeocoderLatitude(("福建省厦门市"+map.get("hospital_name").toString()).replace("G.", "").replace("(糖友网)", "").replace("(高友网)", "")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (json !=null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject location = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    location.put("lat", Double.valueOf(json.get("lat"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    location.put("lon", Double.valueOf(json.get("lng"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String insertSql = "INSERT INTO device.wlyy_patient_device_location(patient,idcard,disease_condition,device_sn,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "device_name,category_code,device_time,create_time,location)\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "VALUES('" + map.get("code").toString() + "','" + map.get("idcard").toString() + "','" + map.get("disease_condition").toString() + "','" + map.get("device_sn").toString() + "','" + map.get("device_name") + "',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "'" + map.get("category_code").toString() + "','" + map.get("create_time") + "','" + map.get("create_time").toString() + "','" + location.toJSONString() + "')\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jdbcTemplate.execute(insertSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                System.out.println(map.get("device_sn").toString()+"-----"+map.get("idcard").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |