|
@@ -14,7 +14,11 @@ import java.nio.file.Paths;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import cn.hutool.core.lang.Dict;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.alibaba.fastjson2.TypeReference;
|
|
|
import com.mybatisflex.core.paginate.Page;
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
|
import com.taais.biz.constant.BizConstant;
|
|
@@ -33,6 +37,7 @@ import com.taais.common.core.constant.Constants;
|
|
|
import com.taais.common.core.core.domain.CommonResult;
|
|
|
import com.taais.common.core.utils.MapstructUtils;
|
|
|
import com.taais.common.core.utils.StringUtils;
|
|
|
+import com.taais.common.json.utils.JsonUtils;
|
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
|
import com.taais.common.core.core.page.PageResult;
|
|
|
import com.taais.common.orm.core.service.impl.BaseServiceImpl;
|
|
@@ -475,6 +480,40 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
|
|
|
return getCompareImage(urlPrefix, inputPath.toString(), outputPath.toString());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CommonResult getStatisticsResult(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);
|
|
|
+
|
|
|
+ Path path = Paths.get(resourcePath);
|
|
|
+ Path outputPath = path.resolveSibling(entity.getId().toString() + BizConstant.TO_INFRARED_SUFFIX + File.separator + BizConstant.PREDICT_PATH);
|
|
|
+
|
|
|
+ Path statisticsResultPath = outputPath.resolve(BizConstant.RESULT_JSON_NAME);
|
|
|
+
|
|
|
+ List<Dict> resultMap = parseJsonMapList(statisticsResultPath);
|
|
|
+ if(ObjectUtil.isEmpty(resultMap)) {
|
|
|
+ return CommonResult.fail("获取结果文件失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.success(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Dict> parseJsonMapList(Path path) {
|
|
|
+ try {
|
|
|
+ String jsonString = new String(Files.readAllBytes(path));
|
|
|
+ List<Dict> dicts = JsonUtils.parseArrayMap(jsonString);
|
|
|
+ return dicts;
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static CommonResult getCompareImage(String urlPrefix, String inputPath, String outputPath) {
|
|
|
try {
|
|
|
List<String> inputImageList = calculateImagePath(urlPrefix, inputPath);
|