Explorar el Código

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

tags/v1.0.0^2
wanjing hace 1 año
padre
commit
024c279a7f
Se han modificado 3 ficheros con 24 adiciones y 15 borrados
  1. +7
    -13
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/FileUtils.java
  2. +12
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/upload/UploadFlightUrlService.java
  3. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/utils/SrtDataUtil.java

+ 7
- 13
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/FileUtils.java Ver fichero

@@ -134,7 +134,7 @@ public class FileUtils {
} catch (IOException e) {
e.printStackTrace();
}
ThumbnailUtil.cenerateCompression(filePathName,filePathName,300,0.8);
ThumbnailUtil.cenerateCompression(filePathName, filePathName, 300, 0.8);
return file;
}
}
@@ -152,20 +152,18 @@ public class FileUtils {
}

public static String txtToString(String fileUrl) throws Exception {

StringBuilder sb = new StringBuilder();

int HttpResult; // 服务器返回的状态
try {
URL url =new URL(fileUrl); // 创建URL
URL url = new URL(fileUrl); // 创建URL
URLConnection urlconn = url.openConnection(); // 试图连接并取得返回状态码
urlconn.connect();
HttpURLConnection httpconn =(HttpURLConnection)urlconn;
HttpURLConnection httpconn = (HttpURLConnection) urlconn;
HttpResult = httpconn.getResponseCode();
if(HttpResult != HttpURLConnection.HTTP_OK) {
if (HttpResult != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("无法连接");
} else {
InputStreamReader isReader = new InputStreamReader(urlconn.getInputStream(),"UTF-8");
InputStreamReader isReader = new InputStreamReader(urlconn.getInputStream(), "UTF-8");
BufferedReader reader = new BufferedReader(isReader);
String line; // 用来保存每行读取的内容
line = reader.readLine(); // 读取第一行
@@ -175,16 +173,12 @@ public class FileUtils {
line = reader.readLine(); // 读取下一行
}
}
}
catch (FileNotFoundException e) {
} catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}

return sb.toString();

}



+ 12
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/upload/UploadFlightUrlService.java Ver fichero

@@ -165,7 +165,7 @@ public class UploadFlightUrlService {
inspectionUpdate.setTenantId(inspection.getTenantId());

// 如果任务处于分析完成,响应前端,任务已完成,不能上传视频
updateSrtUrl(request.getSrtUrl(), inspection.getId(), request.getType(), inspection.getTenantId());
this.updateSrtUrl(request.getSrtUrl(), inspection.getId(), request.getType(), inspection.getTenantId());

// 上传离线视频,更新任务状态为分析中
inspectionUpdate.setSrtName(request.getSrtUrl().substring(request.getSrtUrl().lastIndexOf("/") + 1));
@@ -173,19 +173,29 @@ public class UploadFlightUrlService {
inspectionMapper.updateByPrimaryKeySelective(inspectionUpdate);
}

/**
* 长传视频
*
* @param fileUrl
* @param inspectionId
* @param type
* @param tenantId
*/
private void updateSrtUrl(String fileUrl, String inspectionId, Integer type, String tenantId) {
log.info("进入srt文件上传方法, fileUrl:{}, inspectionId:{}, type:{}, tenantId:{}", fileUrl, inspectionId, type, tenantId);
List<FlightData> flightDataList = new ArrayList<>();
try {
String txtContent = FileUtils.txtToString(fileUrl);

//type为1时,机型为M300
if (type == 1) {
//解析srt文件经纬度和时间戳
flightDataList = SrtDataUtil.getByM300(txtContent, inspectionId, tenantId);
} else {
log.info("srt文件上传, type不等于1,异常");
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
if (ObjectUtils.isEmpty(flightDataList)) {
log.info("srt文件上传, 上传文件数据错误,请检查文件!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_IS_ERROR);
}
flightDataMapper.delete(new LambdaQueryWrapper<FlightData>()

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/utils/SrtDataUtil.java Ver fichero

@@ -95,6 +95,7 @@ public class SrtDataUtil {
* 机型为M300拍摄的SRT文件
*/
public static List<FlightData> getByM300(String srtMsg, String inspectionId, String tenantId) throws Exception {
log.info("获取机型为M300拍摄的SRT文件数据");
List<FlightData> flightDataList = new ArrayList<>();
//将全部字符串按照每个font分割
List<String> msgList = new ArrayList<>();
@@ -127,11 +128,13 @@ public class SrtDataUtil {
try {
date = simpleDateFormat.parse(match);
} catch (ParseException e) {
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR);
}
String timeStamp = String.valueOf(date.getTime());
flightData.setTimestamp(timeStamp);
} else {
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR);
}

@@ -145,6 +148,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);
}
//找出纬度
@@ -157,6 +161,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);

Cargando…
Cancelar
Guardar