|
@ -80,55 +80,28 @@ public class OnenetService {
|
|
JSONObject msg = jsonObject.getJSONObject("msg");
|
|
JSONObject msg = jsonObject.getJSONObject("msg");
|
|
String deviceSn = msg.getString("imei");
|
|
String deviceSn = msg.getString("imei");
|
|
OnenetDevice onenetDevice = onenetDeviceDao.findBySn(deviceSn);
|
|
OnenetDevice onenetDevice = onenetDeviceDao.findBySn(deviceSn);
|
|
String categoryCode = "";
|
|
|
|
|
|
if(onenetDevice == null){
|
|
|
|
logger.info("onenetDevice 设备不存在"+body);
|
|
|
|
return;
|
|
|
|
}
|
|
String title = "";
|
|
String title = "";
|
|
if(onenetDevice!=null){
|
|
|
|
categoryCode = onenetDevice.getCategoryCode();
|
|
|
|
if("14".equals(categoryCode)){
|
|
|
|
title = "可燃气体探测器报警信息接收";
|
|
|
|
}else if("15".equals(categoryCode)){
|
|
|
|
title = "烟探测器监测信息接收";
|
|
|
|
}
|
|
|
|
|
|
String categoryCode = onenetDevice.getCategoryCode();
|
|
|
|
if("14".equals(categoryCode)){
|
|
|
|
title = "可燃气体探测器报警信息接收";
|
|
|
|
}else if("15".equals(categoryCode)){
|
|
|
|
title = "烟探测器监测信息接收";
|
|
}
|
|
}
|
|
hvDeviceService.updContactStatus(deviceSn,1);
|
|
hvDeviceService.updContactStatus(deviceSn,1);
|
|
dataPushLogUtil.savePushLog(deviceSn,msg.toJSONString(),title);
|
|
dataPushLogUtil.savePushLog(deviceSn,msg.toJSONString(),title);
|
|
//未来鹰设备 类型2是设备状态(不准)
|
|
//未来鹰设备 类型2是设备状态(不准)
|
|
Integer type = msg.getInteger("type");
|
|
Integer type = msg.getInteger("type");
|
|
String value = msg.getString("value");
|
|
String value = msg.getString("value");
|
|
if(type==1){
|
|
|
|
String order = value.substring(10,14);
|
|
|
|
if("1401".equals(order)){
|
|
|
|
//自定义命令数据更新(心跳/设备状态上报)
|
|
|
|
String gas_Level = value.substring(22,24);
|
|
|
|
Integer gas = Integer.parseInt(gas_Level, 16);
|
|
|
|
if(gas>0){
|
|
|
|
//气体浓度大于0触发报警
|
|
|
|
|
|
|
|
String sql = "select count(*) from base_device_health_index where device_sn = '"+deviceSn+"'" +
|
|
|
|
" and value>0 and create_time>='"+DateUtil.getNextMinute(-60)+"' ";
|
|
|
|
Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
|
if(count==0){
|
|
|
|
logger.info("气体浓度大于0触发报警,deviceSn:{}",deviceSn);
|
|
|
|
//1小时内不重复发起
|
|
|
|
JSONObject tmp = new JSONObject();
|
|
|
|
tmp.put("gas",gas);
|
|
|
|
orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DeviceHealthIndex index = new DeviceHealthIndex();
|
|
|
|
index.setDeviceSn(deviceSn);
|
|
|
|
if("14".equals(categoryCode)){
|
|
|
|
index.setUnit("%LEL");
|
|
|
|
index.setDeviceType("1");
|
|
|
|
}else if("15".equals(categoryCode)){
|
|
|
|
index.setUnit("%");
|
|
|
|
index.setDeviceType("2");
|
|
|
|
}
|
|
|
|
|
|
|
|
index.setValue(gas+"");
|
|
|
|
index.setRecordTime(DateUtil.getStringDate());
|
|
|
|
deviceHealthIndexDao.save(index);
|
|
|
|
}
|
|
|
|
|
|
if("1".equals(onenetDevice.getDeviceType())){
|
|
|
|
wlyDateDel(categoryCode,msg);
|
|
|
|
}else if("2".equals(onenetDevice.getDeviceType())){
|
|
|
|
//海康设备
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
record.setContent(msg.toJSONString());
|
|
record.setContent(msg.toJSONString());
|
|
@ -232,4 +205,38 @@ public class OnenetService {
|
|
logger.info("apikeyPost="+result);
|
|
logger.info("apikeyPost="+result);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 未来鹰设备数据处理
|
|
|
|
* @param categoryCode
|
|
|
|
* @param msg
|
|
|
|
*/
|
|
|
|
public void wlyDateDel(String categoryCode,JSONObject msg){
|
|
|
|
String dsId = msg.getString("ds_id");
|
|
|
|
String msgId = dsId.split("_")[2];
|
|
|
|
String value = msg.getString("value");
|
|
|
|
String deviceSn = msg.getString("imei");
|
|
|
|
if ("14".equals(categoryCode)){//燃气设备
|
|
|
|
|
|
|
|
}else if ("15".equals(categoryCode)){//烟雾设备
|
|
|
|
if ("5504".equals(msgId)){//烟雾浓度消息 大于0 触发报警
|
|
|
|
Integer gasValue = Integer.parseInt(value);
|
|
|
|
if (gasValue>0){
|
|
|
|
JSONObject tmp = new JSONObject();
|
|
|
|
tmp.put("smoke",value);
|
|
|
|
orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
|
|
|
|
}
|
|
|
|
DeviceHealthIndex index = new DeviceHealthIndex();
|
|
|
|
index.setDeviceSn(deviceSn);
|
|
|
|
index.setUnit("%");
|
|
|
|
index.setDeviceType("2");
|
|
|
|
index.setValue(value);
|
|
|
|
index.setRecordTime(DateUtil.getStringDate());
|
|
|
|
deviceHealthIndexDao.save(index);
|
|
|
|
}
|
|
|
|
if ("5503".equals(msgId)){//各消息类型
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|