|
|
|
|
|
|
|
|
import java.util.regex.Matcher; |
|
|
import java.util.regex.Matcher; |
|
|
import java.util.regex.Pattern; |
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* SRT文件经纬度解析工具 |
|
|
* SRT文件经纬度解析工具 |
|
|
* |
|
|
* |
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class SrtDataUtil { |
|
|
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文件 |
|
|
* 机型为御二拍摄的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<>(); |
|
|
List<FlightData> flightDataList = new ArrayList<>(); |
|
|
//将全部字符串按照每个font分割 |
|
|
//将全部字符串按照每个font分割 |
|
|
List<String> msgList = new ArrayList<>(); |
|
|
List<String> msgList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
FlightData flightData = new FlightData(); |
|
|
FlightData flightData = new FlightData(); |
|
|
flightData.setIsSrt(1); |
|
|
flightData.setIsSrt(1); |
|
|
flightData.setInspectionId(inspectionId); |
|
|
flightData.setInspectionId(inspectionId); |
|
|
|
|
|
flightData.setTenantId(tenantId); |
|
|
//找出时间,格式为2021-08-24 09:33:15,848,518 |
|
|
//找出时间,格式为2021-08-24 09:33:15,848,518 |
|
|
Matcher time = Pattern.compile(Pattern.quote("ms") |
|
|
Matcher time = Pattern.compile(Pattern.quote("ms") |
|
|
+ "(.*?)" |
|
|
+ "(.*?)" |
|
|
|
|
|
|
|
|
String timeStamp = String.valueOf(date.getTime()); |
|
|
String timeStamp = String.valueOf(date.getTime()); |
|
|
flightData.setTimestamp(timeStamp); |
|
|
flightData.setTimestamp(timeStamp); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!"); |
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR); |
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String match = longitude.group(1); |
|
|
String match = longitude.group(1); |
|
|
flightData.setLng(match); |
|
|
flightData.setLng(match); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!"); |
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); |
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); |
|
|
} |
|
|
} |
|
|
//找出纬度 |
|
|
//找出纬度 |
|
|
|
|
|
|
|
|
String match = latitude.group(1); |
|
|
String match = latitude.group(1); |
|
|
flightData.setLat(match); |
|
|
flightData.setLat(match); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!"); |
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LAT_IS_ERROR); |
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LAT_IS_ERROR); |
|
|
} |
|
|
} |
|
|
flightDataList.add(flightData); |
|
|
flightDataList.add(flightData); |
|
|
|
|
|
|
|
|
String match = longitude.group(1); |
|
|
String match = longitude.group(1); |
|
|
flightData.setLng(match); |
|
|
flightData.setLng(match); |
|
|
} else { |
|
|
} else { |
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!"); |
|
|
|
|
|
|
|
|
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!"); |
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); |
|
|
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); |
|
|
} |
|
|
} |
|
|
//找出纬度 |
|
|
//找出纬度 |