|
|
@@ -13,6 +13,7 @@ import java.util.List; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* SRT文件经纬度解析工具 |
|
|
|
* |
|
|
@@ -22,10 +23,84 @@ import java.util.regex.Pattern; |
|
|
|
@Slf4j |
|
|
|
public class SrtDataUtil { |
|
|
|
|
|
|
|
/** |
|
|
|
* 机型为御3E拍摄的SRT文件 |
|
|
|
*/ |
|
|
|
public static List<FlightData> getByYu3e(String srtMsg, String inspectionId, String tenantId) throws Exception { |
|
|
|
List<FlightData> flightDataList = new ArrayList<>(); |
|
|
|
//将全部字符串按照每个font分割 |
|
|
|
List<String> msgList = new ArrayList<>(); |
|
|
|
Matcher msg = Pattern.compile( |
|
|
|
Pattern.quote("HOME(") |
|
|
|
+ "(.*?)" |
|
|
|
+ Pattern.quote("ISO:") |
|
|
|
).matcher(srtMsg); |
|
|
|
while (msg.find()) { |
|
|
|
String match = msg.group(1); |
|
|
|
msgList.add(match); |
|
|
|
} |
|
|
|
|
|
|
|
//解析每组数据 |
|
|
|
for (String str : msgList) { |
|
|
|
FlightData flightData = new FlightData(); |
|
|
|
flightData.setIsSrt(1); |
|
|
|
flightData.setInspectionId(inspectionId); |
|
|
|
flightData.setTenantId(tenantId); |
|
|
|
//找出时间,格式为2023.02.27 15:32:19 |
|
|
|
Matcher time = Pattern.compile(Pattern.quote(") ") |
|
|
|
+ "(.*?)" |
|
|
|
+ Pattern.quote("GPS(") |
|
|
|
).matcher(str); |
|
|
|
if (time.find()) { |
|
|
|
String match = time.group(1); |
|
|
|
//截取时间,转为时间戳 |
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); |
|
|
|
Date date = simpleDateFormat.parse(match); |
|
|
|
String timeStamp = String.valueOf(date.getTime()); |
|
|
|
flightData.setTimestamp(timeStamp); |
|
|
|
} else { |
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!"); |
|
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
//找出经度 |
|
|
|
Matcher longitude = Pattern.compile( |
|
|
|
Pattern.quote("GPS(") |
|
|
|
+ "(.*?)" |
|
|
|
+ Pattern.quote(",") |
|
|
|
).matcher(str); |
|
|
|
if (longitude.find()) { |
|
|
|
String match = longitude.group(1); |
|
|
|
flightData.setLng(match); |
|
|
|
} else { |
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!"); |
|
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); |
|
|
|
} |
|
|
|
//找出数据 格式为 GPS(120.909168,32.596070,141.100000) |
|
|
|
Matcher latitude = Pattern.compile( |
|
|
|
Pattern.quote("GPS(") |
|
|
|
+ "(.*?)" |
|
|
|
+ Pattern.quote(")") |
|
|
|
).matcher(str); |
|
|
|
if (latitude.find()) { |
|
|
|
String match = latitude.group(1); |
|
|
|
//找出纬度 |
|
|
|
String lat = match.split(",")[1]; |
|
|
|
flightData.setLat(lat); |
|
|
|
} else { |
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!"); |
|
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LAT_IS_ERROR); |
|
|
|
} |
|
|
|
flightDataList.add(flightData); |
|
|
|
} |
|
|
|
return flightDataList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 机型为御二拍摄的SRT文件 |
|
|
|
*/ |
|
|
|
public static List<FlightData> getByYu2(String srtMsg, String inspectionId) throws Exception { |
|
|
|
public static List<FlightData> getByYu2(String srtMsg, String inspectionId, String tenantId) throws Exception { |
|
|
|
List<FlightData> flightDataList = new ArrayList<>(); |
|
|
|
//将全部字符串按照每个font分割 |
|
|
|
List<String> msgList = new ArrayList<>(); |
|
|
@@ -44,6 +119,7 @@ public class SrtDataUtil { |
|
|
|
FlightData flightData = new FlightData(); |
|
|
|
flightData.setIsSrt(1); |
|
|
|
flightData.setInspectionId(inspectionId); |
|
|
|
flightData.setTenantId(tenantId); |
|
|
|
//找出时间,格式为2021-08-24 09:33:15,848,518 |
|
|
|
Matcher time = Pattern.compile(Pattern.quote("ms") |
|
|
|
+ "(.*?)" |
|
|
@@ -59,6 +135,7 @@ public class SrtDataUtil { |
|
|
|
String timeStamp = String.valueOf(date.getTime()); |
|
|
|
flightData.setTimestamp(timeStamp); |
|
|
|
} else { |
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!"); |
|
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR); |
|
|
|
} |
|
|
|
|
|
|
@@ -72,6 +149,7 @@ public class SrtDataUtil { |
|
|
|
String match = longitude.group(1); |
|
|
|
flightData.setLng(match); |
|
|
|
} else { |
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!"); |
|
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); |
|
|
|
} |
|
|
|
//找出纬度 |
|
|
@@ -84,6 +162,7 @@ public class SrtDataUtil { |
|
|
|
String match = latitude.group(1); |
|
|
|
flightData.setLat(match); |
|
|
|
} else { |
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!"); |
|
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LAT_IS_ERROR); |
|
|
|
} |
|
|
|
flightDataList.add(flightData); |
|
|
@@ -148,7 +227,7 @@ public class SrtDataUtil { |
|
|
|
String match = longitude.group(1); |
|
|
|
flightData.setLng(match); |
|
|
|
} else { |
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!"); |
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!"); |
|
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); |
|
|
|
} |
|
|
|
//找出纬度 |