|
@@ -23,24 +23,14 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
-import org.apache.http.HttpResponse;
|
|
|
-import org.apache.http.client.methods.HttpGet;
|
|
|
-import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
-import org.apache.http.impl.client.HttpClients;
|
|
|
-import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneId;
|
|
|
-import java.time.ZonedDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -79,15 +69,10 @@ public class EquipmentStatusTaskController {
|
|
|
private String userName;
|
|
|
@Value("${sooka.dahua_interface_server.userPwd}")
|
|
|
private String userPwd;
|
|
|
- //获取回放URI接口ip、port、url
|
|
|
- @Value("${sooka.dahua_interface_server.baseUrl}")
|
|
|
- private String baseUrl;
|
|
|
// private String loginIp = "10.53.0.35";
|
|
|
// private String loginPort = "7901";
|
|
|
// private String userName = "system";
|
|
|
// private String userPwd = "Admin123";
|
|
|
-// //获取回放URI接口ip、port、url
|
|
|
-// private String baseUrl = "http://10.53.0.35:7901/videoService/playback/uri";
|
|
|
//按组织获取设备详细信息
|
|
|
public static final String ACTION = "/videoService/devicesManager/devicesInfo";
|
|
|
private List<String> orgCodes = Arrays.asList("11033445593778368", "11248668755298496");
|
|
@@ -177,12 +162,12 @@ public class EquipmentStatusTaskController {
|
|
|
}
|
|
|
} else {
|
|
|
//向执法中心推送设备状态
|
|
|
- R result = remoteLawenforcementBaseService.deviceOpenOrClose(arr);
|
|
|
- if (result.getCode() != 200) {
|
|
|
- log.info("向执法中心推送设备状态失败:{}", result.getMsg());
|
|
|
- }
|
|
|
- //更新执法仪在离线状态
|
|
|
- centermonitorTCameraMapper.updateBatchLawEnforcementInstrumentState(arr);
|
|
|
+// R result = remoteLawenforcementBaseService.deviceOpenOrClose(arr);
|
|
|
+// if (result.getCode() != 200) {
|
|
|
+// log.info("向执法中心推送设备状态失败:{}", result.getMsg());
|
|
|
+// }
|
|
|
+// //更新执法仪在离线状态
|
|
|
+// centermonitorTCameraMapper.updateBatchLawEnforcementInstrumentState(arr);
|
|
|
//误操作开机,导致设备状态非正常使用,进行告警处理
|
|
|
saveOrUpdateRecorderStatus(arr);
|
|
|
}
|
|
@@ -292,68 +277,4 @@ public class EquipmentStatusTaskController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/getAlarmVideoByChannelCodeAndAlarmTime/{deviceSn}/{alarmTime}", method = GET)
|
|
|
- public void test(@PathVariable("deviceSn") String deviceSn, @PathVariable("alarmTime") String alarmTime) {
|
|
|
- R<?> result = null;
|
|
|
- try {
|
|
|
- result = HttpTestUtils.getToken(loginIp, Integer.parseInt(loginPort), userName, userPwd);
|
|
|
- } catch (Exception e) {
|
|
|
- log.info("获取token失败,请检查配置信息:{}", JSONObject.parseObject(result.getMsg()));
|
|
|
- }
|
|
|
- String token = result.getData().toString();
|
|
|
- // 定义输入格式
|
|
|
- DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- // 解析为 LocalDateTime(无时区信息)
|
|
|
- LocalDateTime localDateTime = LocalDateTime.parse(alarmTime, inputFormatter);
|
|
|
-// String deviceSn = "34020000001329000701";
|
|
|
- String beginTime = DateTimeConversion(localDateTime);
|
|
|
- // 加 10 分钟
|
|
|
- LocalDateTime plus10Minutes = localDateTime.plusMinutes(10);
|
|
|
-// String beginTime = "20250626T015000Z";
|
|
|
-// String endTime = "20250626T020000Z";
|
|
|
- String endTime = DateTimeConversion(plus10Minutes);
|
|
|
- String location = "cloud";
|
|
|
- String scheme = "RTSP";
|
|
|
- String response = getVideoRecords(deviceSn, beginTime, endTime, location, scheme, token);
|
|
|
- System.out.println(response);
|
|
|
- }
|
|
|
-
|
|
|
- public String getVideoRecords(String deviceSn, String beginTime,
|
|
|
- String endTime, String location, String scheme,
|
|
|
- String token) {
|
|
|
- // 构建请求URL
|
|
|
- String url = String.format("%s?channelCode=%s&scheme=%s&beginTime=%s&endTime=%s&location=%s",
|
|
|
- baseUrl, deviceSn, scheme, beginTime, endTime, location);
|
|
|
- // 创建HTTP客户端
|
|
|
- try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
|
|
- // 创建GET请求
|
|
|
- HttpGet httpGet = new HttpGet(url);
|
|
|
- // 添加请求头
|
|
|
- httpGet.addHeader("X-Subject-Token", token);
|
|
|
- httpGet.addHeader("Accept", "application/json"); // 根据实际情况设置
|
|
|
- // 执行请求
|
|
|
- HttpResponse response = httpClient.execute(httpGet);
|
|
|
- // 检查响应状态
|
|
|
- int statusCode = response.getStatusLine().getStatusCode();
|
|
|
- if (statusCode != 200) {
|
|
|
- log.error("HTTP request failed with code: " + statusCode);
|
|
|
- }
|
|
|
- // 获取响应内容
|
|
|
- return EntityUtils.toString(response.getEntity());
|
|
|
- } catch (IOException e) {
|
|
|
- log.error("HTTP request failed with exception: " + e.getMessage());
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private String DateTimeConversion(LocalDateTime dateTime) {
|
|
|
- // 转换为东八区时间(假设原始时间是东八区)
|
|
|
- ZonedDateTime beijingTime = dateTime.atZone(ZoneId.of("Asia/Shanghai"));
|
|
|
- // 转换为 UTC 时间(减 8 小时)
|
|
|
- ZonedDateTime utcTime = beijingTime.withZoneSameInstant(ZoneId.of("UTC"));
|
|
|
- // 定义输出格式(ISO 8601 格式)
|
|
|
- DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'");
|
|
|
- return utcTime.format(outputFormatter);
|
|
|
- }
|
|
|
-
|
|
|
}
|