|  | @ -17,14 +17,17 @@ import com.yihu.iot.util.conceal.ConcealUtil;
 | 
	
		
			
				|  |  | 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.entity.iot.statistics.IotStatisticsAppDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.iot.statistics.IotStatisticsCommonDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.iot.statistics.IotStatisticsRealtimeDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.iot.statistics.IotStatisticsStockDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.util.AesEncryptUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.PageEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.LatitudeUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | import iot.device.IotLocationDataVO;
 | 
	
		
			
				|  |  | import iot.device.LocationDataVO;
 | 
	
		
			
				|  |  | import org.apache.http.Consts;
 | 
	
		
			
				|  |  | import org.apache.http.client.utils.URLEncodedUtils;
 | 
	
	
		
			
				|  | @ -43,6 +46,7 @@ import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.text.DecimalFormat;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | import java.util.stream.Collectors;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import static cn.hutool.core.util.ObjectUtil.hasEmpty;
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -88,6 +92,75 @@ public class MonitorPlatformService {
 | 
	
		
			
				|  |  |     private WlyyIotTzDictDao wlyyIotTzDictDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private IotStatisticsCommonDao iotStatisticsCommonDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private JdbcTemplate jdbcTempalte;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 新的物联网大屏地理搜索
 | 
	
		
			
				|  |  |      * @param deviceCommon 设备通用名编码
 | 
	
		
			
				|  |  |      * @param page
 | 
	
		
			
				|  |  |      * @param size
 | 
	
		
			
				|  |  |      * @param use 用途
 | 
	
		
			
				|  |  |      * @param combinationMethod 组合方式
 | 
	
		
			
				|  |  |      * @param networkTransmission 网络传输
 | 
	
		
			
				|  |  |      * @param town 地理区划
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public PageEnvelop<IotLocationDataVO> findLocationPage(String deviceCommon, Integer page, Integer size,
 | 
	
		
			
				|  |  |                    String use, String combinationMethod, String networkTransmission, String town) {
 | 
	
		
			
				|  |  |         String countSql = "select count(*) ";
 | 
	
		
			
				|  |  |         String sql = "select * ";
 | 
	
		
			
				|  |  |         String fileter = " from wlyy_patient_device_location where del=0 ";
 | 
	
		
			
				|  |  |         if(!StringUtils.isEmpty(deviceCommon)){
 | 
	
		
			
				|  |  |             fileter += " and device_common = '"+deviceCommon+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(!StringUtils.isEmpty(use)){
 | 
	
		
			
				|  |  |             fileter += " and use_code = '"+use+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(!StringUtils.isEmpty(combinationMethod)){
 | 
	
		
			
				|  |  |             fileter += " and combination_method = '"+combinationMethod+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(!StringUtils.isEmpty(networkTransmission)){
 | 
	
		
			
				|  |  |             fileter += " and network_transmission = '"+networkTransmission+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(!StringUtils.isEmpty(town)&&"350200".equals(town)){
 | 
	
		
			
				|  |  |             fileter += " and town = '"+town+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String limit = " limit "+(page-1)*size+","+size;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String, Object>> result = jdbcTemplate.queryForList(sql+fileter+limit);
 | 
	
		
			
				|  |  |         List<IotLocationDataVO> locationDataVOList = new ArrayList<>();
 | 
	
		
			
				|  |  |         result.forEach(map -> {
 | 
	
		
			
				|  |  |             IotLocationDataVO locationDataVO = new IotLocationDataVO();
 | 
	
		
			
				|  |  |             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(AesEncryptUtils.decrypt(map.get("idcard")+""));
 | 
	
		
			
				|  |  |             locationDataVO.setCategoryCode(map.get("category_code")+"");
 | 
	
		
			
				|  |  |             locationDataVO.setDeviceSn(map.get("device_sn")+"");
 | 
	
		
			
				|  |  |             locationDataVO.setLocation(geoPoint);
 | 
	
		
			
				|  |  |             locationDataVO.setDeviceTime(map.get("device_time")+"");
 | 
	
		
			
				|  |  |             locationDataVO.setLabel(map.get("label")+"");
 | 
	
		
			
				|  |  |             if(map.get("disease_condition")!=null){
 | 
	
		
			
				|  |  |                 locationDataVO.setDiseaseCondition(Integer.parseInt(map.get("disease_condition").toString()));
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 locationDataVO.setDiseaseCondition(0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             locationDataVO.setCreateTime(map.get("create_time")+"");
 | 
	
		
			
				|  |  |             locationDataVO.setPatient(map.get("patient")+"");
 | 
	
		
			
				|  |  |             locationDataVO.setDeviceCommon(map.get("device_common")+"");
 | 
	
		
			
				|  |  |             locationDataVO.setUseCode(map.get("useCode")+"");
 | 
	
		
			
				|  |  |             locationDataVO.setCombinationMethod(map.get("xombination_method")+"");
 | 
	
		
			
				|  |  |             locationDataVO.setTown(map.get("town")+"");
 | 
	
		
			
				|  |  |             locationDataVO.setNetworkTransmission(map.get("network_transmission")+"");
 | 
	
		
			
				|  |  |             locationDataVOList.add(locationDataVO);
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long totalCount = jdbcTemplate.queryForObject(countSql+fileter, Long.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return PageEnvelop.getSuccessListWithPage("获取成功",locationDataVOList,page,size,totalCount);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取位置信息
 | 
	
	
		
			
				|  | @ -1215,33 +1288,57 @@ public class MonitorPlatformService {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject getBrandsAndManufacturer() {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             String sql = "select count(DISTINCT A.device_name) as total,A.device_name, IF(A.manufacturer = '健康之路', '福建健康之路信息技术有限公司',  A.manufacturer) 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 and pd.del=0 \n" +
 | 
	
		
			
				|  |  |                     "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机'  \n" +
 | 
	
		
			
				|  |  |                     "GROUP BY wd.manufacturer_code,pd.device_name\n" +
 | 
	
		
			
				|  |  |                     "UNION\n" +
 | 
	
		
			
				|  |  |                     "select case device_name when '自助体检一体机' then '健康小屋'  else device_name  end AS 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";
 | 
	
		
			
				|  |  |             List<Map<String, Object>> Manufacturers = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |             JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |             JSONArray arr = JSONArray.parseArray(JSON.toJSONString(Manufacturers));
 | 
	
		
			
				|  |  |             result.put("Manufacturers", arr);
 | 
	
		
			
				|  |  |             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 and pd.del=0 \n" +
 | 
	
		
			
				|  |  |                     "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机' \n" +
 | 
	
		
			
				|  |  |                     "GROUP BY wd.manufacturer_code,pd.device_name\n" +
 | 
	
		
			
				|  |  |                     "UNION\n" +
 | 
	
		
			
				|  |  |                     "select case device_name when '自助体检一体机' then '健康小屋'  else device_name  end AS device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
 | 
	
		
			
				|  |  |                     ")A";
 | 
	
		
			
				|  |  |             Integer BrandsCount = jdbcTemplate.queryForObject(sql, Integer.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             result.put("Brands", BrandsCount);
 | 
	
		
			
				|  |  |             result.put("manufacturerCount", arr.size());
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |             JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |             String sql = "select * from iot_statistics_app where type = '3' or type='4' order by num desc";
 | 
	
		
			
				|  |  |             List<IotStatisticsAppDO> appDOS = jdbcTempalte.query(sql,new BeanPropertyRowMapper<>(IotStatisticsAppDO.class));
 | 
	
		
			
				|  |  |             if(appDOS.size()>0){
 | 
	
		
			
				|  |  |                 Map<String,List<IotStatisticsAppDO>> listMap = appDOS.stream().collect(Collectors.groupingBy(IotStatisticsAppDO::getType));
 | 
	
		
			
				|  |  |                 IotStatisticsAppDO appDO = listMap.get("4").get(0);
 | 
	
		
			
				|  |  |                 List<IotStatisticsAppDO> appDOList = listMap.get("3");
 | 
	
		
			
				|  |  |                 JSONArray jsonArray = new JSONArray();
 | 
	
		
			
				|  |  |                 for (IotStatisticsAppDO app:appDOList){
 | 
	
		
			
				|  |  |                     JSONObject json = new JSONObject();
 | 
	
		
			
				|  |  |                     json.put("manufacturer",app.getName());
 | 
	
		
			
				|  |  |                     json.put("total",app.getNum());
 | 
	
		
			
				|  |  |                     jsonArray.add(json);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 object.put("Brands",appDO.getNum());//产品数
 | 
	
		
			
				|  |  |                 object.put("Manufacturers",jsonArray);
 | 
	
		
			
				|  |  |                 object.put("manufacturerCount",appDO.getName());
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 object.put("Brands",0);
 | 
	
		
			
				|  |  |                 object.put("Manufacturers",new ArrayList<>());
 | 
	
		
			
				|  |  |                 object.put("manufacturerCount",40);//目前暂无医疗机构接入,默认0家。
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return object;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //            String sql = "select count(DISTINCT A.device_name) as total,A.device_name, IF(A.manufacturer = '健康之路', '福建健康之路信息技术有限公司',  A.manufacturer) 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 and pd.del=0 \n" +
 | 
	
		
			
				|  |  | //                    "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机'  \n" +
 | 
	
		
			
				|  |  | //                    "GROUP BY wd.manufacturer_code,pd.device_name\n" +
 | 
	
		
			
				|  |  | //                    "UNION\n" +
 | 
	
		
			
				|  |  | //                    "select case device_name when '自助体检一体机' then '健康小屋'  else device_name  end AS 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";
 | 
	
		
			
				|  |  | //            List<Map<String, Object>> Manufacturers = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  | //            JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  | //            JSONArray arr = JSONArray.parseArray(JSON.toJSONString(Manufacturers));
 | 
	
		
			
				|  |  | //            result.put("Manufacturers", arr);
 | 
	
		
			
				|  |  | //            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 and pd.del=0 \n" +
 | 
	
		
			
				|  |  | //                    "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机' \n" +
 | 
	
		
			
				|  |  | //                    "GROUP BY wd.manufacturer_code,pd.device_name\n" +
 | 
	
		
			
				|  |  | //                    "UNION\n" +
 | 
	
		
			
				|  |  | //                    "select case device_name when '自助体检一体机' then '健康小屋'  else device_name  end AS device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
 | 
	
		
			
				|  |  | //                    ")A";
 | 
	
		
			
				|  |  | //            Integer BrandsCount = jdbcTemplate.queryForObject(sql, Integer.class);
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //            result.put("Brands", BrandsCount);
 | 
	
		
			
				|  |  | //            result.put("manufacturerCount", arr.size());
 | 
	
		
			
				|  |  | //            return result;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             e.printStackTrace();
 |