优化日志以及属性设置代码

This commit is contained in:
648540858
2024-07-03 16:14:18 +08:00
parent 10c852c00d
commit 799932f614
95 changed files with 881 additions and 2385 deletions

View File

@@ -1,17 +1,11 @@
package com.genersoft.iot.vmp.gb28181.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 数值格式判断和处理
* @author lawrencehj
* @date 2021年1月27日
*/
public class NumericUtil {
private static Logger logger = LoggerFactory.getLogger(NumericUtil.class);
/**
* 判断是否Double格式
* @param str

View File

@@ -1,6 +1,5 @@
package com.genersoft.iot.vmp.gb28181.utils;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.Gb28181Sdp;
import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo;
import com.genersoft.iot.vmp.utils.DateUtil;
@@ -9,9 +8,8 @@ import gov.nist.javax.sip.address.AddressImpl;
import gov.nist.javax.sip.address.SipUri;
import gov.nist.javax.sip.header.Subject;
import gov.nist.javax.sip.message.SIPRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ObjectUtils;
import javax.sdp.SdpFactory;
@@ -36,10 +34,9 @@ import java.util.UUID;
* @description JAIN SIP的工具类
* @createTime 2021年09月27日 15:12:00
*/
@Slf4j
public class SipUtils {
private final static Logger logger = LoggerFactory.getLogger(SipUtils.class);
public static String getUserIdFromFromHeader(Request request) {
FromHeader fromHeader = (FromHeader)request.getHeader(FromHeader.NAME);
return getUserIdFromFromHeader(fromHeader);
@@ -189,39 +186,6 @@ public class SipUtils {
return new RemoteAddressInfo(remoteAddress, remotePort);
}
public static DeviceChannel updateGps(DeviceChannel deviceChannel, String geoCoordSys) {
if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
if (geoCoordSys == null) {
geoCoordSys = "WGS84";
}
if ("WGS84".equals(geoCoordSys)) {
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeGcj02(position[0]);
deviceChannel.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(geoCoordSys)) {
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeWgs84(position[0]);
deviceChannel.setLatitudeWgs84(position[1]);
}else {
deviceChannel.setLongitudeGcj02(0.00);
deviceChannel.setLatitudeGcj02(0.00);
deviceChannel.setLongitudeWgs84(0.00);
deviceChannel.setLatitudeWgs84(0.00);
}
}else {
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
}
return deviceChannel;
}
public static Gb28181Sdp parseSDP(String sdpStr) throws SdpParseException {
// jainSip不支持y= f=字段, 移除以解析。
@@ -277,7 +241,7 @@ public class SipUtils {
try {
localDateTime = LocalDateTime.parse(timeStr, DateUtil.formatterISO8601);
}catch (DateTimeParseException e2) {
logger.error("[格式化时间] 无法格式化时间: {}", timeStr);
log.error("[格式化时间] 无法格式化时间: {}", timeStr);
return null;
}
}

View File

@@ -2,14 +2,13 @@ package com.genersoft.iot.vmp.gb28181.utils;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
@@ -25,21 +24,12 @@ import java.util.*;
/**
* 基于dom4j的工具包
*
*
*/
@Slf4j
public class XmlUtil {
/**
* 日志服务
*/
private static Logger logger = LoggerFactory.getLogger(XmlUtil.class);
/**
* 解析XML为Document对象
*
* @param xml 被解析的XMl
*
* @return Document
*/
public static Element parseXml(String xml) {
Document document = null;
@@ -49,7 +39,7 @@ public class XmlUtil {
try {
document = saxReader.read(sr);
} catch (DocumentException e) {
logger.error("解析失败", e);
log.error("解析失败", e);
}
return null == document ? null : document.getRootElement();
}