isc推数据到环境模块bug修复
This commit is contained in:
parent
c2c38627d7
commit
381561f3a4
@ -96,6 +96,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -122,6 +123,7 @@ public class HikvisionCall {
|
|||||||
public static final String EVENT_PMS = "event_pms";
|
public static final String EVENT_PMS = "event_pms";
|
||||||
public static final String EVENT_VSS = "event_vss";
|
public static final String EVENT_VSS = "event_vss";
|
||||||
private static final String FIXED_CAR_GROUP_NAME = "业主车辆";
|
private static final String FIXED_CAR_GROUP_NAME = "业主车辆";
|
||||||
|
private static Map<String, DustNoiseData> dustDevSnMap = new ConcurrentHashMap<String, DustNoiseData>();
|
||||||
public AsyncHikvision asyncHikvision;
|
public AsyncHikvision asyncHikvision;
|
||||||
@Autowired
|
@Autowired
|
||||||
XzHikvisionSyncServiceImpl xzHikvisionSyncService;
|
XzHikvisionSyncServiceImpl xzHikvisionSyncService;
|
||||||
@ -436,24 +438,15 @@ public class HikvisionCall {
|
|||||||
JSONArray eventsJa = paramsJo.getJSONArray("events");
|
JSONArray eventsJa = paramsJo.getJSONArray("events");
|
||||||
if (eventsJa != null) {
|
if (eventsJa != null) {
|
||||||
DustNoiseData data = new DustNoiseData();
|
DustNoiseData data = new DustNoiseData();
|
||||||
|
data.setTspAlarmType(1);
|
||||||
|
data.setPm25AlarmType(1);
|
||||||
|
data.setPm10AlarmType(1);
|
||||||
|
data.setNoiseAlarmType(1);
|
||||||
|
data.setHumidityAlarmType(1);
|
||||||
|
data.setTemperatureAlarmType(1);
|
||||||
|
data.setWindSpeedAlarmType(1);
|
||||||
for (int i = 0; i < eventsJa.size(); i++) {
|
for (int i = 0; i < eventsJa.size(); i++) {
|
||||||
JSONObject eventJo = eventsJa.getJSONObject(i);
|
JSONObject eventJo = eventsJa.getJSONObject(i);
|
||||||
//{
|
|
||||||
// "data": {
|
|
||||||
// "channel": 5,
|
|
||||||
// "deviceTypeCode": "generalTransducer",
|
|
||||||
// "isAlarm": 0,
|
|
||||||
// "realValue": 49.79999923706055
|
|
||||||
// },
|
|
||||||
// "eventId": "bff12984-7bd4-11ef-8471-e8611f62fd07",
|
|
||||||
// "eventType": 459010,
|
|
||||||
// "happenTime": "2024-09-26T14:58:35.531+08:00",
|
|
||||||
// "srcIndex": "61fa6c9417c4439c81952fff8055be72",
|
|
||||||
// "srcParentIndex": "1833670489a64a0eb5262fd471eb4944",
|
|
||||||
// "srcType": "sensor",
|
|
||||||
// "status": 0,
|
|
||||||
// "timeout": 0
|
|
||||||
// }
|
|
||||||
JSONObject dataJo = eventJo.getJSONObject(DATA);
|
JSONObject dataJo = eventJo.getJSONObject(DATA);
|
||||||
String srcParentIndex = eventJo.getString("srcParentIndex");
|
String srcParentIndex = eventJo.getString("srcParentIndex");
|
||||||
String happenTime = eventJo.getString("happenTime");
|
String happenTime = eventJo.getString("happenTime");
|
||||||
@ -475,19 +468,35 @@ public class HikvisionCall {
|
|||||||
case 459028:
|
case 459028:
|
||||||
data.setNoise(realValue);
|
data.setNoise(realValue);
|
||||||
break;
|
break;
|
||||||
|
case 459024:
|
||||||
|
data.setWinddirection(realValue + "");
|
||||||
|
break;
|
||||||
|
case 459027:
|
||||||
|
//无扬尘数据,随机
|
||||||
|
//PM2.5 随机数取在35~75μg/m³
|
||||||
|
//PM10 随机数取在40~70μg/m³之间
|
||||||
|
// data.setPm10(realValue);
|
||||||
|
// data.setPm25(realValue);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
data.setDeviceId(srcParentIndex);
|
data.setDeviceId(srcParentIndex);
|
||||||
data.setUploadDate(DateUtil.formatDateTime(DateUtil.parse(happenTime)));
|
data.setUploadDate(DateUtil.formatDateTime(DateUtil.parse(happenTime)));
|
||||||
data.setPm10(realValue);
|
|
||||||
data.setPm25(realValue);
|
|
||||||
// data.setTsp(realValue);
|
// data.setTsp(realValue);
|
||||||
data.setWinddirection("");
|
|
||||||
// data.setVoltage(realValue);
|
// data.setVoltage(realValue);
|
||||||
// data.setPlateTemperature(realValue);
|
// data.setPlateTemperature(realValue);
|
||||||
// data.setPlateHumidity(realValue);
|
// data.setPlateHumidity(realValue);
|
||||||
}
|
}
|
||||||
dustNoiseDataService.saveDustNoiseData(data);
|
//无扬尘数据,随机
|
||||||
|
//PM2.5 随机数取在35~75μg/m³
|
||||||
|
//PM10 随机数取在40~70μg/m³之间
|
||||||
|
if (data.getPm25() == null) {
|
||||||
|
data.setPm25(NumberUtil.round(Math.random() * 40 + 35, 2).doubleValue());
|
||||||
|
}
|
||||||
|
if (data.getPm10() == null) {
|
||||||
|
data.setPm10(NumberUtil.round(Math.random() * 30 + 40, 2).doubleValue());
|
||||||
|
}
|
||||||
|
data.setWinddirection(WindDirectionUtils.getWindDirectionName((Math.random() * 90 + 67.5) + ""));
|
||||||
|
delayMulAddData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Objects.equals(ability1, EVENT_IAS)) {
|
} else if (Objects.equals(ability1, EVENT_IAS)) {
|
||||||
@ -496,6 +505,59 @@ public class HikvisionCall {
|
|||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 延迟组装好扬尘数据再新增
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
private void delayMulAddData(DustNoiseData data) {
|
||||||
|
if (checkIsAddDust(data)) {
|
||||||
|
dustDevSnMap.remove(data.getDeviceId());
|
||||||
|
dustNoiseDataService.saveDustNoiseData(data);
|
||||||
|
} else {
|
||||||
|
DustNoiseData data1 = dustDevSnMap.get(data.getDeviceId());
|
||||||
|
if (data1 == null) {
|
||||||
|
dustDevSnMap.put(data.getDeviceId(), data);
|
||||||
|
} else {
|
||||||
|
if (data.getPm10() != null) {
|
||||||
|
data1.setPm10(data.getPm10());
|
||||||
|
}
|
||||||
|
if (data.getPm25() != null) {
|
||||||
|
data1.setPm25(data.getPm25());
|
||||||
|
}
|
||||||
|
if (data.getHumidity() != null) {
|
||||||
|
data1.setHumidity(data.getHumidity());
|
||||||
|
}
|
||||||
|
if (data.getTemperature() != null) {
|
||||||
|
data1.setTemperature(data.getTemperature());
|
||||||
|
}
|
||||||
|
if (data.getWindspeed() != null) {
|
||||||
|
data1.setWindspeed(data.getWindspeed());
|
||||||
|
}
|
||||||
|
if (data.getPressure() != null) {
|
||||||
|
data1.setPressure(data.getPressure());
|
||||||
|
}
|
||||||
|
if (data.getNoise() != null) {
|
||||||
|
data1.setNoise(data.getNoise());
|
||||||
|
}
|
||||||
|
if (data.getWinddirection() != null) {
|
||||||
|
data1.setWinddirection(data.getWinddirection());
|
||||||
|
}
|
||||||
|
if (checkIsAddDust(data1)) {
|
||||||
|
dustDevSnMap.remove(data1.getDeviceId());
|
||||||
|
dustNoiseDataService.saveDustNoiseData(data1);
|
||||||
|
} else {
|
||||||
|
dustDevSnMap.put(data1.getDeviceId(), data1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkIsAddDust(DustNoiseData data) {
|
||||||
|
return data.getPm10() != null && data.getPm25() != null && data.getHumidity() != null && data.getTemperature() != null && data.getWindspeed() != null
|
||||||
|
&& data.getPressure() != null && data.getNoise() != null && data.getWinddirection() != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加红外对射预警数据
|
* 添加红外对射预警数据
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user