|
@@ -47,6 +47,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
|
|
|
import static com.taais.biz.domain.table.ToInfraredTableDef.TO_INFRARED;
|
|
|
+import static com.taais.biz.service.impl.DataSeqServiceImpl.calculateImagePath;
|
|
|
+import static com.taais.biz.service.impl.DataSeqServiceImpl.isImageFile;
|
|
|
import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
|
|
|
|
|
|
/**
|
|
@@ -397,15 +399,15 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
|
|
|
|
|
|
public String readLogContent(String path) {
|
|
|
String content = "";
|
|
|
- try(BufferedReader br = new BufferedReader(new FileReader(path))) {
|
|
|
+ try (BufferedReader br = new BufferedReader(new FileReader(path))) {
|
|
|
String line;
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
- content += ( line + "<br />\n");
|
|
|
+ content += (line + "<br />\n");
|
|
|
}
|
|
|
- }catch(Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
System.out.println("读取文件失败!" + e.getMessage());
|
|
|
- content = "读取文件失败!" + e.getMessage();
|
|
|
+ content = "读取文件失败!" + e.getMessage();
|
|
|
}
|
|
|
|
|
|
return content;
|
|
@@ -445,6 +447,63 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
|
|
|
return CommonResult.success(res, "success");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CommonResult previewPredictResult(Long id) {
|
|
|
+ ToInfrared entity = getById(id);
|
|
|
+
|
|
|
+ SysOssVo inputOssEntity = ossService.getById(entity.getInputOssId());
|
|
|
+
|
|
|
+ String filePath = inputOssEntity.getFileName();
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
+ String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
+
|
|
|
+ String fileName = StringUtils.substringAfterLast(filePath, "/");
|
|
|
+ String fileName_without_suffix = removeFileExtension(fileName);
|
|
|
+
|
|
|
+ Path path = Paths.get(resourcePath);
|
|
|
+ Path inputPath = path.resolveSibling(fileName_without_suffix + BizConstant.UNZIP_SUFFIX + File.separator + BizConstant.PREDICT_PATH);
|
|
|
+ Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TO_INFRARED_SUFFIX + File.separator + BizConstant.PREDICT_PATH);
|
|
|
+
|
|
|
+ String urlPrefix = inputOssEntity.getUrl().substring(0, inputOssEntity.getUrl().indexOf(Constants.RESOURCE_PREFIX) + Constants.RESOURCE_PREFIX.length());
|
|
|
+
|
|
|
+ return getCompareImage(urlPrefix, inputPath.toString(), outputPath.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ public static CommonResult getCompareImage(String urlPrefix, String inputPath, String outputPath) {
|
|
|
+ try {
|
|
|
+ List<String> inputImageList = calculateImagePath(urlPrefix, inputPath);
|
|
|
+ List<String> outputImageList = calculateImagePath(urlPrefix, outputPath);
|
|
|
+
|
|
|
+ HashMap<String,String> nameToUrl1 = new HashMap<>();
|
|
|
+
|
|
|
+ for (String imageUrl : inputImageList) {
|
|
|
+ String name = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
|
|
|
+ nameToUrl1.put(name, imageUrl);
|
|
|
+ }
|
|
|
+ HashMap<String,String> nameToUrl2 = new HashMap<>();
|
|
|
+ for (String imageUrl : outputImageList) {
|
|
|
+ String name = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
|
|
|
+ nameToUrl2.put(name, imageUrl);
|
|
|
+ }
|
|
|
+ List<String> inputImageNames = new ArrayList<>(nameToUrl1.keySet());
|
|
|
+
|
|
|
+ inputImageNames.sort(Comparator.naturalOrder());
|
|
|
+
|
|
|
+ List<Map<String, String>> resultList = new ArrayList<>();
|
|
|
+ for (String inputImageName : inputImageNames) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("inputUrl", nameToUrl1.get(inputImageName));
|
|
|
+ map.put("outputUrl", nameToUrl2.get(inputImageName));
|
|
|
+ resultList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.success(resultList, "success");
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("getImages error: " + e.getMessage());
|
|
|
+ return CommonResult.fail("getImages error: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private ResponseEntity<org.springframework.core.io.Resource> getPredictImages(ToInfrared toInfrared) {
|
|
|
String outputPath = toInfrared.getOutputPath();
|
|
|
String predictDir = outputPath + File.separator + BizConstant.PREDICT_PATH;
|