|  | @ -719,15 +719,8 @@ public class DcDeviceController extends BaseController { | 
			
		
	
		
		
			
				
					|  |  |         return getDataTable(dcDeviceService.selectDeviceNameList(dcDevice)); |  |  |         return getDataTable(dcDeviceService.selectDeviceNameList(dcDevice)); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |     @GetMapping("/deviceParameter") |  |  |     @GetMapping("/deviceParameter") | 
			
		
	
		
		
			
				
					
					|  |  |     public TableDataInfo selectDeviceParameterProperties(DcDevice dcDevice) { |  |  |     public AjaxResult selectDeviceParameterProperties(DcDevice dcDevice) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         if (dcDevice==null||dcDevice.getDeviceType()==null){ |  |  |         return AjaxResult.success(dcDeviceService.selectDeviceParameterProperties(dcDevice)); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |             TableDataInfo tableDataInfo = new TableDataInfo(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             tableDataInfo.setCode(UniversalEnum.FIVE_HUNDRED.getNumber()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             tableDataInfo.setMsg(UniversalEnum.PARAMETER_ERROR.getValue()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             return tableDataInfo; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         startPage(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         return getDataTable(dcDeviceService.selectDeviceParameterProperties(dcDevice)); |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |      * 查询设备指定属性属性列表 |  |  |      * 查询设备指定属性属性列表 | 
			
		
	
	
		
		
			
				
					|  | @ -828,5 +821,94 @@ public class DcDeviceController extends BaseController { | 
			
		
	
		
		
			
				
					|  |  |         String key = configService.selectConfigByKey(UniversalEnum.SBX_FUN_KL.getValue());//密钥
 |  |  |         String key = configService.selectConfigByKey(UniversalEnum.SBX_FUN_KL.getValue());//密钥
 | 
			
		
	
		
		
			
				
					|  |  |         return AjaxResult.success(key.equals(secretKey)); |  |  |         return AjaxResult.success(key.equals(secretKey)); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     //设备分析
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @PostMapping("/properties/deviceAnalysis") | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public AjaxResult deviceAnalysis(@RequestBody HashMap map) throws IOException, HttpException { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (map==null||!map.containsKey("deviceId")||!map.containsKey("deviceType") ||!map.containsKey("dateTime")){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return AjaxResult.error(UniversalEnum.PARAMETER_ERROR.getValue()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         String type = map.get("deviceType").toString();//设备类型
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         String deviceId = map.get("deviceId").toString();//设备id
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         DcDevice dcDevice = new DcDevice(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         dcDevice.setDeviceType(type); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         HashMap<String, Object> props = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         props.put("terms[0].column", "timestamp$BTW"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ArrayList<String> dateList = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 添加当前日期的开始和结束时间到列表,用于设定时间范围
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         SimpleDateFormat dateFormat = new SimpleDateFormat(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         try { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             Date date = dateFormat.parse((String) map.get("dateTime")); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             dateList.add(DateUtil.beginOfDay(date).toString()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             dateList.add(DateUtil.endOfDay(date).toString()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } catch (ParseException e) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             e.printStackTrace(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 将日期列表以逗号分隔并设置为查询条件的值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         props.put("terms[0].value", String.join(UniversalEnum.COMMA.getValue(), dateList)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         props.put("paging", false); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         props.put("sorts[0].order", "asc"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         props.put("sorts[0].name", "timestamp"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<HashMap<String, Object>> mapList = dcDeviceService.selectDeviceParameterProperties(dcDevice);//属性的参数信息
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<HashMap> resultsMapValue=new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         for (HashMap<String, Object> hashMap : mapList) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             HashMap<String, Object> resultsMap = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             String name = hashMap.get("name").toString();//属性名称
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             String propertyId = hashMap.get("propertyId").toString();//属性id
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             String propertyName = hashMap.get("propertyName").toString();//属性取值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             AjaxResult ajaxResult = queryDeviceProperties(deviceId, propertyId, props);//取出属性全部信息
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             String code = ajaxResult.get("code").toString(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if ("500".equals(code)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 return ajaxResult; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (UniversalEnum.THIRTEEN.getValue().equals(type) || UniversalEnum.SIXTEEN.getValue().equals(type)) {  //判断是否为设备箱/远端机
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 JSONObject data = (JSONObject) ajaxResult.get("data"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 JSONArray dataVale = (JSONArray) data.get("data"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 List<JSONObject> jsonObjectList = dataVale.toJavaList(JSONObject.class); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 // 定义一个时间格式转换的工具
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 SimpleDateFormat sdf = new SimpleDateFormat(UniversalEnum.TIME_FORMAT_ALL.getValue(), Locale.getDefault()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 // 使用Stream API提取每个JSONObject中的timestamp和propertyName值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 List<Map<String, String>> results = jsonObjectList.stream() | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         .map(jsonObject -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             long timestamp = jsonObject.getLongValue("timestamp"); // 假设timestamp是long类型
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             Date date = new Date(timestamp); // 将时间戳转换为Date对象
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             String formattedTime = sdf.format(date); // 将Date对象格式化为字符串
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             JSONObject formatValue = jsonObject.getJSONObject("formatValue"); // 获取嵌套的JSONObject
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             String result = formatValue.getString(propertyName); // 从嵌套的JSONObject中获取电压值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             Map<String, String> hashMaps = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             hashMaps.put("timestamp", formattedTime); // 使用"timestamp"作为键来存储格式化后的时间
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             hashMaps.put("result", result); // 使用"voltage"作为键来存储电压值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             return hashMaps; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         }).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 results.sort(Comparator.comparing(hashMaps -> hashMaps.get("timestamp"))); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 resultsMap.put("name", name); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 resultsMap.put("results", results); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (UniversalEnum.THREE.getValue().equals(type) || UniversalEnum.SEVENTEEN.getValue().equals(type) || | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     UniversalEnum.FIFTEEN.getValue().equals(type)) { //气象预警/ups设备/太阳能板
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 JSONObject data = (JSONObject) ajaxResult.get("data"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 JSONArray dataValue = (JSONArray) data.get("data"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 List<JSONObject> jsonObjectList = dataValue.toJavaList(JSONObject.class); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 // 定义一个时间格式转换的工具
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 SimpleDateFormat sdf = new SimpleDateFormat(UniversalEnum.TIME_FORMAT_ALL.getValue(), Locale.getDefault()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 List<HashMap<String, String>> results = jsonObjectList.stream() | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         .map(jsonObject -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             long timestamp = jsonObject.getLongValue("timestamp"); // 假设timestamp是long类型
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             Date date = new Date(timestamp); // 将时间戳转换为Date对象
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             String formattedTime = sdf.format(date); // 将Date对象格式化为字符串
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             String result = jsonObject.getString(propertyName); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             HashMap<String, String> hashMaps = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             hashMaps.put("timestamp", formattedTime); // 使用时间戳作为键可能不是最佳实践,但这里保持与原始逻辑一致
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             hashMaps.put("result", result); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             return hashMaps; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         }).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 results.sort(Comparator.comparing(hashMaps -> hashMaps.get("timestamp"))); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 resultsMap.put("name", name); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 resultsMap.put("results", results); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             resultsMapValue.add(resultsMap); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return AjaxResult.success(resultsMapValue); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | 
 |