|
|
|
|
@ -124,7 +124,7 @@ public class ExternalUtils { |
|
|
|
|
// 遍历设备列表更新设备状态信息
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
|
// 报警主机在线状态:true在线 false离线
|
|
|
|
|
boolean presence = Alarm.presence(); |
|
|
|
|
// boolean presence = Alarm.presence();
|
|
|
|
|
|
|
|
|
|
// 设备状态信息
|
|
|
|
|
HCNetSDK.NET_DVR_ALARMHOST_MAIN_STATUS_V40 status = Alarm.getStatus(); |
|
|
|
|
@ -138,37 +138,42 @@ public class ExternalUtils { |
|
|
|
|
String id = tagsMap.get("buildingNo").toString(); |
|
|
|
|
// 防区号
|
|
|
|
|
int sCIDCode = Integer.parseInt(tagsMap.get("buildingNo").toString()); |
|
|
|
|
// 防区布防状态 0-对应防区处于撤防状态,1-对应防区处于布防状态
|
|
|
|
|
byte bySetupAlarmStatus = status.bySetupAlarmStatus[sCIDCode - 1]; |
|
|
|
|
// 防区旁路状态 0-表示防区没有旁路 1-表示防区旁路
|
|
|
|
|
byte byBypassStatus = status.byBypassStatus[sCIDCode - 1]; |
|
|
|
|
// 防区故障状态,0-对应防区处于正常状态,1-对应防区处于故障状态
|
|
|
|
|
byte byAlarmInFaultStatus = status.byAlarmInFaultStatus[sCIDCode - 1]; |
|
|
|
|
|
|
|
|
|
// 设备真实状态
|
|
|
|
|
int fqStatus = 0; |
|
|
|
|
|
|
|
|
|
if (byAlarmInFaultStatus == 0) { |
|
|
|
|
if (bySetupAlarmStatus == 1) { |
|
|
|
|
fqStatus = 5; |
|
|
|
|
} else if (bySetupAlarmStatus == 0 && byBypassStatus == 0) { |
|
|
|
|
fqStatus = 6; |
|
|
|
|
} else if (byBypassStatus == 1) { |
|
|
|
|
fqStatus = 7; |
|
|
|
|
int presence = 0; |
|
|
|
|
|
|
|
|
|
if (status != null) { |
|
|
|
|
presence = 1; |
|
|
|
|
// 防区布防状态 0-对应防区处于撤防状态,1-对应防区处于布防状态
|
|
|
|
|
byte bySetupAlarmStatus = status.bySetupAlarmStatus[sCIDCode - 1]; |
|
|
|
|
// 防区旁路状态 0-表示防区没有旁路 1-表示防区旁路
|
|
|
|
|
byte byBypassStatus = status.byBypassStatus[sCIDCode - 1]; |
|
|
|
|
// 防区故障状态,0-对应防区处于正常状态,1-对应防区处于故障状态
|
|
|
|
|
byte byAlarmInFaultStatus = status.byAlarmInFaultStatus[sCIDCode - 1]; |
|
|
|
|
|
|
|
|
|
if (byAlarmInFaultStatus == 0) { |
|
|
|
|
if (bySetupAlarmStatus == 1) { |
|
|
|
|
fqStatus = 5; |
|
|
|
|
} else if (bySetupAlarmStatus == 0 && byBypassStatus == 0) { |
|
|
|
|
fqStatus = 6; |
|
|
|
|
} else if (byBypassStatus == 1) { |
|
|
|
|
fqStatus = 7; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
fqStatus = 4; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
fqStatus = 4; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (fqStatus == state) { |
|
|
|
|
// updateById(id, byBypassStatus);
|
|
|
|
|
test(id, byBypassStatus); |
|
|
|
|
// updateById(id, fqStatus, presence);
|
|
|
|
|
test(id, fqStatus, presence); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 海信iot
|
|
|
|
|
// updateById(id, byBypassStatus);
|
|
|
|
|
test(id, byBypassStatus); |
|
|
|
|
// updateById(id, fqStatus,presence);
|
|
|
|
|
test(id, fqStatus, presence); |
|
|
|
|
// 物联网平台
|
|
|
|
|
bizDevice(Integer.parseInt(String.valueOf(map.get("id"))), fqStatus); |
|
|
|
|
} |
|
|
|
|
@ -178,24 +183,57 @@ public class ExternalUtils { |
|
|
|
|
/** |
|
|
|
|
* 根据设备id修改设备状态信息-海信iot |
|
|
|
|
*/ |
|
|
|
|
public void updateById(String id, byte byBypassStatus) { |
|
|
|
|
// 设备状态信息上报给海信iot
|
|
|
|
|
public void updateById(String id, int byBypassStatus, int presence) { |
|
|
|
|
int pntType = 6; |
|
|
|
|
int pntTypeValue = 0; |
|
|
|
|
|
|
|
|
|
// 离线状态
|
|
|
|
|
if (presence == 0) { |
|
|
|
|
queue(id, pntType, pntTypeValue); |
|
|
|
|
} |
|
|
|
|
// 在线状态
|
|
|
|
|
else { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
queue(id, pntType, pntTypeValue); |
|
|
|
|
|
|
|
|
|
pntType = 9; |
|
|
|
|
// 故障
|
|
|
|
|
if (byBypassStatus == 4) { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
queue(id, pntType, pntTypeValue); |
|
|
|
|
} |
|
|
|
|
// 未故障
|
|
|
|
|
else { |
|
|
|
|
pntTypeValue = 0; |
|
|
|
|
queue(id, pntType, pntTypeValue); |
|
|
|
|
|
|
|
|
|
pntType = 8; |
|
|
|
|
// 旁路
|
|
|
|
|
if (byBypassStatus == 7) { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
queue(id, pntType, pntTypeValue); |
|
|
|
|
} |
|
|
|
|
// 未旁路
|
|
|
|
|
else { |
|
|
|
|
pntTypeValue = 0; |
|
|
|
|
queue(id, pntType, pntTypeValue); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* // 设备状态信息上报给海信iot
|
|
|
|
|
* @param id |
|
|
|
|
* @param pntType |
|
|
|
|
* @param pntTypeValue |
|
|
|
|
*/ |
|
|
|
|
private void queue(String id, int pntType, int pntTypeValue) { |
|
|
|
|
if (queueUtils == null) { |
|
|
|
|
queueUtils = SpringUtil.getBean(QueueUtils.class); |
|
|
|
|
} |
|
|
|
|
// byte[] byteValue = DataTrans.intToBytesBigEndian(0);
|
|
|
|
|
// ByteString byteString = ByteString.copyFrom(byteValue);
|
|
|
|
|
Point point = Point.newBuilder() |
|
|
|
|
.setId(id) |
|
|
|
|
.setDevType(2) |
|
|
|
|
.setPntType(8) |
|
|
|
|
.setPntTypeValue(byBypassStatus).build(); |
|
|
|
|
Point point = Point.newBuilder().setId(id).setDevType(2).setPntType(pntType).setPntTypeValue(pntTypeValue).build(); |
|
|
|
|
boolean b = queueUtils.saveQueueDataStatus(point); |
|
|
|
|
if (queueUtils.saveQueueDataStatus(point)) { |
|
|
|
|
System.out.println("海信iot-发送成功"); |
|
|
|
|
} else { |
|
|
|
|
System.out.println("海信iot-发送失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -238,10 +276,50 @@ public class ExternalUtils { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 和iot联调测试专用接口 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @param byBypassStatus |
|
|
|
|
*/ |
|
|
|
|
public void test(String id, byte byBypassStatus) { |
|
|
|
|
public void test(String id, int byBypassStatus, int presence) { |
|
|
|
|
int pntType = 6; |
|
|
|
|
int pntTypeValue = 0; |
|
|
|
|
|
|
|
|
|
// 离线状态
|
|
|
|
|
if (presence == 0) { |
|
|
|
|
test1(id, pntType, pntTypeValue); |
|
|
|
|
} |
|
|
|
|
// 在线状态
|
|
|
|
|
else { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
test1(id, pntType, pntTypeValue); |
|
|
|
|
|
|
|
|
|
pntType = 9; |
|
|
|
|
// 故障
|
|
|
|
|
if (byBypassStatus == 4) { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
test1(id, pntType, pntTypeValue); |
|
|
|
|
} |
|
|
|
|
// 未故障
|
|
|
|
|
else { |
|
|
|
|
pntTypeValue = 0; |
|
|
|
|
test1(id, pntType, pntTypeValue); |
|
|
|
|
|
|
|
|
|
pntType = 8; |
|
|
|
|
// 旁路
|
|
|
|
|
if (byBypassStatus == 7) { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
test1(id, pntType, pntTypeValue); |
|
|
|
|
} |
|
|
|
|
// 未旁路
|
|
|
|
|
else { |
|
|
|
|
pntTypeValue = 0; |
|
|
|
|
test1(id, pntType, pntTypeValue); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void test1(String id, int pntType, int pntTypeValue) { |
|
|
|
|
String url = "http://152.136.119.150:81/alarmInformation/hikRemote"; |
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8")); |
|
|
|
|
@ -249,8 +327,8 @@ public class ExternalUtils { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("id_", id); |
|
|
|
|
map.put("devType_", 2); |
|
|
|
|
map.put("pntType_", 8); |
|
|
|
|
map.put("pntTypeValue_", byBypassStatus); |
|
|
|
|
map.put("pntType_", pntType); |
|
|
|
|
map.put("pntTypeValue_", pntTypeValue); |
|
|
|
|
String content = JSON.toJSONString(map); |
|
|
|
|
|
|
|
|
|
HttpEntity<String> httpEntity = new HttpEntity<>(content, headers); |
|
|
|
|
|