Merge branch 'master' into dev/abl支持
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java # src/main/java/com/genersoft/iot/vmp/media/bean/MediaInfo.java # src/main/java/com/genersoft/iot/vmp/media/bean/MediaServer.java # src/main/java/com/genersoft/iot/vmp/media/bean/RecordInfo.java # src/main/java/com/genersoft/iot/vmp/service/bean/CloudRecordItem.java # src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java # src/main/java/com/genersoft/iot/vmp/storager/dao/CloudRecordServiceMapper.java # src/main/resources/application.yml
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
package com.genersoft.iot.vmp.utils;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
public enum CivilCodeUtil {
|
||||
|
||||
INSTANCE;
|
||||
private final static Logger log = LoggerFactory.getLogger(CivilCodeUtil.class);
|
||||
|
||||
// 用与消息的缓存
|
||||
private final Map<String, CivilCodePo> civilCodeMap = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -27,6 +28,10 @@ public enum CivilCodeUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public void add(CivilCodePo civilCodePo) {
|
||||
civilCodeMap.put(civilCodePo.getCode(), civilCodePo);
|
||||
}
|
||||
|
||||
public CivilCodePo getParentCode(String code) {
|
||||
if (code.length() > 8) {
|
||||
return null;
|
||||
@@ -45,6 +50,50 @@ public enum CivilCodeUtil {
|
||||
}
|
||||
return civilCodeMap.get(parentCode);
|
||||
}
|
||||
}
|
||||
|
||||
public CivilCodePo getCivilCodePo(String code) {
|
||||
if (code.length() > 8) {
|
||||
return null;
|
||||
}else {
|
||||
return civilCodeMap.get(code);
|
||||
}
|
||||
}
|
||||
|
||||
public List<CivilCodePo> getAllParentCode(String civilCode) {
|
||||
List<CivilCodePo> civilCodePoList = new ArrayList<>();
|
||||
CivilCodePo parentCode = getParentCode(civilCode);
|
||||
if (parentCode != null) {
|
||||
civilCodePoList.add(parentCode);
|
||||
List<CivilCodePo> allParentCode = getAllParentCode(parentCode.getCode());
|
||||
if (!allParentCode.isEmpty()) {
|
||||
civilCodePoList.addAll(allParentCode);
|
||||
}else {
|
||||
return civilCodePoList;
|
||||
}
|
||||
}
|
||||
return civilCodePoList;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return civilCodeMap.isEmpty();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return civilCodeMap.size();
|
||||
}
|
||||
|
||||
public List<Region> getAllChild(String parent) {
|
||||
List<Region> result = new ArrayList<>();
|
||||
for (String key : civilCodeMap.keySet()) {
|
||||
if (parent == null) {
|
||||
if (ObjectUtils.isEmpty(civilCodeMap.get(key).getParentCode().trim())) {
|
||||
result.add(Region.getInstance(key, civilCodeMap.get(key).getName(), civilCodeMap.get(key).getParentCode()));
|
||||
}
|
||||
}else if (civilCodeMap.get(key).getParentCode().equals(parent)) {
|
||||
result.add(Region.getInstance(key, civilCodeMap.get(key).getName(), civilCodeMap.get(key).getParentCode()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.utils;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -14,7 +15,7 @@ import java.time.temporal.TemporalAccessor;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 全局时间工具类
|
||||
* @author lin
|
||||
*/
|
||||
@@ -66,11 +67,10 @@ public class DateUtil {
|
||||
public static final DateTimeFormatter DateFormatter = DateTimeFormatter.ofPattern(date_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
||||
public static final DateTimeFormatter urlFormatter = DateTimeFormatter.ofPattern(URL_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
||||
|
||||
public static String yyyy_MM_dd_HH_mm_ssToISO8601(String formatTime) {
|
||||
|
||||
public static String yyyy_MM_dd_HH_mm_ssToISO8601(@NotNull String formatTime) {
|
||||
return formatterISO8601.format(formatter.parse(formatTime));
|
||||
}
|
||||
|
||||
|
||||
public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) {
|
||||
// 三种日期格式都尝试,为了兼容不同厂家的日期格式
|
||||
if (verification(formatTime, formatterCompatibleISO8601)) {
|
||||
@@ -207,6 +207,7 @@ public class DateUtil {
|
||||
}
|
||||
Instant startInstant = Instant.from(formatter.parse(startTime));
|
||||
Instant endInstant = Instant.from(formatter.parse(endTime));
|
||||
return ChronoUnit.MILLIS.between(endInstant, startInstant);
|
||||
return ChronoUnit.MILLIS.between(startInstant, endInstant);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
package com.genersoft.iot.vmp.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Slf4j
|
||||
public class GpsUtil {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(GpsUtil.class);
|
||||
|
||||
public static BaiduPoint Wgs84ToBd09(String xx, String yy) {
|
||||
|
||||
|
||||
@@ -31,4 +31,15 @@ public final class JsonUtil {
|
||||
}
|
||||
return clazz.cast(jsonObject);
|
||||
}
|
||||
|
||||
public static <T> T redisHashJsonToObject(RedisTemplate<Object, Object> redisTemplate, String key, String objKey, Class<T> clazz) {
|
||||
// if (key == null || objKey == null) {
|
||||
// return null;
|
||||
// }
|
||||
Object jsonObject = redisTemplate.opsForHash().get(key, objKey);
|
||||
if (Objects.isNull(jsonObject)) {
|
||||
return null;
|
||||
}
|
||||
return clazz.cast(jsonObject);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.genersoft.iot.vmp.utils;
|
||||
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.*;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.hardware.NetworkIF;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
import oshi.util.FormatUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -22,10 +22,9 @@ import java.util.concurrent.TimeUnit;
|
||||
* 版权声明:本文为xiaozhangnomoney原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明
|
||||
* 原文出处链接:https://blog.csdn.net/xiaozhangnomoney/article/details/107769147
|
||||
*/
|
||||
@Slf4j
|
||||
public class SystemInfoUtils {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(SystemInfoUtils.class);
|
||||
|
||||
/**
|
||||
* 获取cpu信息
|
||||
* @return
|
||||
@@ -78,7 +77,7 @@ public class SystemInfoUtils {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("[线程休眠失败] : {}", e.getMessage());
|
||||
log.error("[线程休眠失败] : {}", e.getMessage());
|
||||
}
|
||||
List<NetworkIF> afterNetworkIFs = hal.getNetworkIFs();
|
||||
NetworkIF afterNet = afterNetworkIFs.get(afterNetworkIFs.size() - 1);
|
||||
@@ -145,4 +144,19 @@ public class SystemInfoUtils {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getHardwareId(){
|
||||
SystemInfo systemInfo = new SystemInfo();
|
||||
HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
||||
// CPU ID
|
||||
String cpuId = hardware.getProcessor().getProcessorIdentifier().getProcessorID();
|
||||
// 主板序号
|
||||
String serialNumber = hardware.getComputerSystem().getSerialNumber();
|
||||
|
||||
return DigestUtils.md5DigestAsHex(
|
||||
(
|
||||
DigestUtils.md5DigestAsHex(cpuId.getBytes(StandardCharsets.UTF_8)) +
|
||||
DigestUtils.md5DigestAsHex(serialNumber.getBytes(StandardCharsets.UTF_8))
|
||||
).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@@ -17,9 +16,9 @@ import java.util.Objects;
|
||||
* @version 1.0
|
||||
* @date 2022/3/11 10:17
|
||||
*/
|
||||
@Slf4j
|
||||
public class UJson {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(UJson.class);
|
||||
public static final ObjectMapper JSON_MAPPER = new ObjectMapper();
|
||||
|
||||
static {
|
||||
@@ -39,7 +38,7 @@ public class UJson {
|
||||
try {
|
||||
this.node = JSON_MAPPER.readValue(json, ObjectNode.class);
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
log.error(e.getMessage(), e);
|
||||
this.node = JSON_MAPPER.createObjectNode();
|
||||
}
|
||||
}
|
||||
@@ -90,7 +89,7 @@ public class UJson {
|
||||
try {
|
||||
return JSON_MAPPER.readValue(json, clazz);
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +98,7 @@ public class UJson {
|
||||
try{
|
||||
return JSON_MAPPER.writeValueAsString(object);
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
log.error(e.getMessage(), e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user