2023年8月8日17:32:56

main
litao 2 years ago
parent ec154190e4
commit 3a0549b384
  1. 10
      src/main/java/org/springblade/hospital/controller/AlarmInformationController.java
  2. 28
      src/main/java/org/springblade/hospital/controller/AppDataController.java
  3. 15
      src/main/java/org/springblade/hospital/hik/alarm/Alarm.java
  4. 7
      src/main/java/org/springblade/hospital/hik/alarm/AlarmDataParse.java
  5. 3
      src/main/java/org/springblade/hospital/service/IAlarmInformationService.java
  6. 15
      src/main/java/org/springblade/hospital/service/impl/AlarmInformationServiceImpl.java
  7. 2
      src/main/java/org/springblade/hospital/utils/CornJobUtil.java
  8. 154
      src/main/java/org/springblade/hospital/utils/ExternalUtils.java

@ -41,6 +41,7 @@ import org.springblade.hospital.excel.AlarmInformationExcel;
import org.springblade.hospital.hik.alarm.Alarm; import org.springblade.hospital.hik.alarm.Alarm;
import org.springblade.hospital.service.IAlarmInformationService; import org.springblade.hospital.service.IAlarmInformationService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
@ -62,11 +63,6 @@ public class AlarmInformationController extends BladeController {
private final QueueUtils queueUtils; private final QueueUtils queueUtils;
@PostMapping("/save")
public void save(AlarmInformation alarmInformation) {
alarmInformationService.search("4515465");
}
@PostMapping("/hikRemote") @PostMapping("/hikRemote")
public R hikRemote(@RequestBody Map<String, Object> params) { public R hikRemote(@RequestBody Map<String, Object> params) {
System.out.println("-------params:" + params); System.out.println("-------params:" + params);
@ -86,10 +82,6 @@ public class AlarmInformationController extends BladeController {
/** /**
* 报警信息列表 * 报警信息列表
*
* @param alarmInformation
* @param query
* @return
*/ */
@GetMapping("/list") @GetMapping("/list")
public R<IPage<AlarmInformation>> list(AlarmInformation alarmInformation, Query query) { public R<IPage<AlarmInformation>> list(AlarmInformation alarmInformation, Query query) {

@ -19,6 +19,7 @@ package org.springblade.hospital.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
@ -113,19 +114,23 @@ public class AppDataController extends BladeController {
String response = ""; String response = "";
// 请求地址 // 请求地址
String url = "https://test48xwjfile.juhaolian.cn/iot-open-device/report/alarm"; // String url = "https://test48xwjfile.juhaolian.cn/iot-open-device/report/alarm";
// String url = paramService.getValue("url"); // String url = "https://test48xwjfile.juhaolian.cn/iot-data-receive/alarm/report/forAdapter";
String url = paramService.getValue("url");
// 设置请求Header // 设置请求Header
String appKey = "BN8ZDpBI"; String appKey = "BN8ZDpBI";
String appSecret = "5FtRlaVFqvggNUM8/b7u0/MP6zE65V80EPWEK6dDAps="; String appSecret = "5FtRlaVFqvggNUM8/b7u0/MP6zE65V80EPWEK6dDAps=";
// String zfcAll = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; // String nonce = Long.toString(IdWorker.getId());
// char[] zfc = zfcAll.toCharArray();
// String nonce = RandomStringUtils.random(32, zfc); String zfcAll = "1234567890";
UUID id = UUID.randomUUID(); char[] zfc = zfcAll.toCharArray();
String[] idd = id.toString().split("-"); String nonce = RandomStringUtils.random(32, zfc);
String nonce = idd[0] + idd[1] + idd[2] + idd[3] + idd[4];
// UUID id = UUID.randomUUID();
// String[] idd = id.toString().split("-");
// String nonce = idd[0] + idd[1] + idd[2] + idd[3] + idd[4];
String timestamp = String.valueOf(System.currentTimeMillis()); String timestamp = String.valueOf(System.currentTimeMillis());
@ -142,10 +147,9 @@ public class AppDataController extends BladeController {
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8")); headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
headers.set("Haiot-appKey", appKey); headers.set("Haiot-appKey", appKey);
headers.set("Haiot-nonce", nonce); headers.set("Haiot-nonce", nonce);
headers.set("Haiot-timeStamp", timestamp); headers.set("Haiot-timestamp", timestamp);
headers.set("Haiot-signature", hash); headers.set("Haiot-signature", hash);
System.out.println("url:" + url); System.out.println("url:" + url);
String content = JSON.toJSONString(alarm); String content = JSON.toJSONString(alarm);
@ -280,7 +284,7 @@ public class AppDataController extends BladeController {
@GetMapping("/test") @GetMapping("/test")
public void test() { public void test() {
// Alarm.getStatus(); Alarm.getStatus();
externalUtils.updateStatus(); // externalUtils.updateStatus();
} }
} }

@ -201,21 +201,12 @@ public class Alarm implements CommandLineRunner {
// boolean status = hCNetSDK.NET_DVR_RemoteControl(lUserID, HCNetSDK.NET_DVR_CHECK_USER_STATUS, null, 0); // boolean status = hCNetSDK.NET_DVR_RemoteControl(lUserID, HCNetSDK.NET_DVR_CHECK_USER_STATUS, null, 0);
if (status) { if (status) {
System.out.println("设备在线"); System.out.println("设备在线");
statusV40.read();
return statusV40;
} else { } else {
System.out.println("设备通讯失败"); System.out.println("设备通讯失败");
return null;
} }
statusV40.read();
byte b1 = statusV40.bySetupAlarmStatus[0];
byte b2 = statusV40.byAlarmInStatus[0];
byte b3 = statusV40.byBypassStatus[0];
byte b4 = statusV40.bySubSystemGuardStatus[0];
byte b5 = statusV40.byAlarmInFaultStatus[0];
byte b6 = statusV40.byAlarmInMemoryStatus[0];
byte b7 = statusV40.byAlarmInTamperStatus[0];
byte b8 = statusV40.byEnableSubSystem[0];
byte b9 = statusV40.byRes[0];
byte b10 = statusV40.bySubSystemGuardType[0];
return statusV40;
} }
public static boolean presence() { public static boolean presence() {

@ -380,12 +380,9 @@ public class AlarmDataParse {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("id_", String.valueOf(Integer.sum(strCIDalarm.wDefenceNo, 1))); map.put("id_", String.valueOf(Integer.sum(strCIDalarm.wDefenceNo, 1)));
map.put("type_", 2);
map.put("dataType_", 1);
map.put("chann_", 4);
map.put("devType_", 2); map.put("devType_", 2);
map.put("pntType_", 5); map.put("pntType_", 7);
map.put("pntTypeValue_", 6); map.put("pntTypeValue_", 1);
String content = JSON.toJSONString(map); String content = JSON.toJSONString(map);
HttpEntity<String> httpEntity = new HttpEntity<>(content, headers); HttpEntity<String> httpEntity = new HttpEntity<>(content, headers);

@ -19,7 +19,9 @@ package org.springblade.hospital.service;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.hospital.entity.AlarmInformation; import org.springblade.hospital.entity.AlarmInformation;
import org.springblade.hospital.excel.AlarmInformationExcel; import org.springblade.hospital.excel.AlarmInformationExcel;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
@ -31,5 +33,4 @@ public interface IAlarmInformationService extends BaseService<AlarmInformation>
List<AlarmInformationExcel> export(AlarmInformation alarmInformation); List<AlarmInformationExcel> export(AlarmInformation alarmInformation);
String search(String query);
} }

@ -31,7 +31,12 @@ import org.springblade.hospital.excel.AlarmInformationExcel;
import org.springblade.hospital.mapper.AlarmInformationMapper; import org.springblade.hospital.mapper.AlarmInformationMapper;
import org.springblade.hospital.service.IAlarmInformationService; import org.springblade.hospital.service.IAlarmInformationService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
@ -42,16 +47,6 @@ import java.util.List;
@Service @Service
public class AlarmInformationServiceImpl extends BaseServiceImpl<AlarmInformationMapper, AlarmInformation> implements IAlarmInformationService { public class AlarmInformationServiceImpl extends BaseServiceImpl<AlarmInformationMapper, AlarmInformation> implements IAlarmInformationService {
@Override
public String search(String query) {
// Point point = Point.newBuilder().setId(RandomStringUtils.random(8)).setType(1).build();
// System.out.println("blockingStub=" + stub);
// CommonResult command = stub.command(CommandRequest.newBuilder().setPoint(point).build());
// System.out.println(command.toString());
return "";
}
@Override @Override
public List<AlarmInformationExcel> export(AlarmInformation alarmInformation) { public List<AlarmInformationExcel> export(AlarmInformation alarmInformation) {
// LambdaQueryWrapper<AlarmInformation> wrapper = Wrappers.lambdaQuery(alarmInformation); // LambdaQueryWrapper<AlarmInformation> wrapper = Wrappers.lambdaQuery(alarmInformation);

@ -35,7 +35,7 @@ public class CornJobUtil {
} }
/** /**
* 定时执行布撤防定时任务每3分钟执行一次 * 定时布撤防每3分钟执行一次
*/ */
@Async @Async
@Scheduled(initialDelay = 5000, fixedRate = 180000) @Scheduled(initialDelay = 5000, fixedRate = 180000)

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

Loading…
Cancel
Save