screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
@@ -358,8 +358,14 @@ Map<String,Object> historyHourlyMap = new HashMap<>(); historyHourlyMap.put("mac",mac); JSONObject value = JSONObject.parseObject(historyFiveMinutely.getValue()); if (value.get(sensorCode)==null){ historyHourlyMap.put(sensorCode,0.0); }else { Double sensorValue = Double.parseDouble(value.get(sensorCode).toString()); historyHourlyMap.put(sensorCode,sensorValue); } // Double sensorValue = Double.parseDouble(value.get(sensorCode).toString()); // historyHourlyMap.put(sensorCode,sensorValue); Date time = historyFiveMinutely.getTime(); String timeStr = DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); historyHourlyMap.put("time",timeStr); screen-manage/src/main/java/com/moral/api/controller/TestController.java
@@ -12,7 +12,9 @@ import com.moral.api.service.SysDictDataService; import com.moral.api.service.TestService; import com.moral.api.service.impl.SensorServiceImpl; import com.moral.api.util.AdjustDataUtils; import com.moral.api.util.CacheUtils; import com.moral.api.util.CompareFieldUtils; import com.moral.constant.Constants; import com.moral.constant.KafkaConstants; import com.moral.constant.RedisConstants; @@ -211,6 +213,8 @@ private SensorService sensorService; @Autowired SysDictDataMapper sysDictDataMapper; @Autowired private AdjustDataUtils adjustDataUtils; @ApiOperation(value = "因子测试", notes = "因子测试") @ApiImplicitParams({ @@ -218,6 +222,12 @@ }) @RequestMapping(value = "getSensor", method = RequestMethod.GET) public void getSensor() { HashMap<String, Object> map = new HashMap<>(); map.put("time","1692364996898"); map.put("mac","p5dnd7a0391986"); HashMap<String, Object> map1 = new HashMap<>(); HashMap<String, Object> map2 = new HashMap<>(); Map<String, Object> adjust = adjustDataUtils.adjust(map, map1, map2, "2"); QueryWrapper<Sensor> queryWrapper = new QueryWrapper<>(); queryWrapper.select("code").eq("is_delete", Constants.NOT_DELETE); List<Object> list = sensorService.listObjs(queryWrapper); screen-manage/src/main/java/com/moral/api/kafka/consumer/DeviceConsumer.java
@@ -10,6 +10,9 @@ import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -96,8 +99,19 @@ } //数据过滤 // data.remove("time"); data.remove("time"); data.remove("entryTime"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String format = dateFormat.format(new Date().getTime()); //获取年份 String substring = format.substring(0, 4); String substring1 = time.toString().substring(0, 4); String replace = time.toString().replace(substring1, substring); data.put("DataTime",replace); Iterator<Map.Entry<String, Object>> iterator = data.entrySet().iterator(); Map<String, Object> newMap = new HashMap<>(); Map.Entry<String, Object> next; screen-manage/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
@@ -51,14 +51,13 @@ Map<String, Object> versionInfo = (Map<String, Object>) deviceInfo.get("version"); Integer version = (Integer) versionInfo.get("id"); //获取时间戳 String time1 = data.get("time").toString(); long l = Long.parseLong(time1); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); String format1 = dateFormat.format(l); Date time = DateUtils.getDate(format1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); // String time1 = data.get("time").toString(); // long l = Long.parseLong(time1); // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); // String format1 = dateFormat.format(l); // Date time = DateUtils.getDate(format1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); // Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN); Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN); String yearAndMonth = DateUtils.dateToDateString(DateUtils.addHours(time, -1), DateUtils.yyyyMM_EN); result.put("mac", mac); screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java
@@ -126,37 +126,47 @@ if (ObjectUtils.isEmpty(map)){ return deviceData; } if (ObjectUtils.isEmpty(aqiMap.get("a21005"))){ JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); if (ObjectUtils.isEmpty(aqiMap)){ deviceData.put("a21005",Double.parseDouble(jsonObject.get("a21005").toString())); deviceData.put("a21026",Double.parseDouble(jsonObject.get("a21026").toString())); deviceData.put("a21004",Double.parseDouble(jsonObject.get("a21004").toString())); deviceData.put("a34002",Double.parseDouble(jsonObject.get("a34002").toString())); deviceData.put("a34004",Double.parseDouble(jsonObject.get("a34004").toString())); deviceData.put("a05024",Double.parseDouble(jsonObject.get("a05024").toString())); }else { if (ObjectUtils.isEmpty(aqiMap.get("a21005"))){ String a21005 = jsonObject.get("a21005").toString(); deviceData.put("a21005",Double.parseDouble(a21005)); } if (ObjectUtils.isEmpty(aqiMap.get("a21026"))){ JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); String a21026 = jsonObject.get("a21026").toString(); deviceData.put("a21026",Double.parseDouble(a21026)); } if (ObjectUtils.isEmpty(aqiMap.get("a21004"))){ JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); String a21004 = jsonObject.get("a21004").toString(); deviceData.put("a21004",Double.parseDouble(a21004)); } if (ObjectUtils.isEmpty(aqiMap.get("a34002"))){ JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); String a34002 = jsonObject.get("a34002").toString(); deviceData.put("a34002",Double.parseDouble(a34002)); } if (ObjectUtils.isEmpty(aqiMap.get("a34004"))){ JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); String a34004 = jsonObject.get("a34004").toString(); deviceData.put("a34004",Double.parseDouble(a34004)); } if (ObjectUtils.isEmpty(aqiMap.get("a05024"))){ JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); String a05024 = jsonObject.get("a05024").toString(); deviceData.put("a05024",Double.parseDouble(a05024)); } } } } catch (Exception e) { log.error("param[0] deviceData:" + JSON.toJSONString(deviceData));