master
周文涛 2 years ago
parent 61243310a7
commit 3c0fe9f1fa

@ -102,8 +102,8 @@ public class OcrSimulatorController{
ocrIdentifyDetailService.saveBatch(ocrIdentifyDetailList);
//返回前端的json
responseBody.put("ocrTime",ocrTimeSum);
responseBody.put("nluTime",nluTimeSum);
responseBody.put("ocrTime",new BigDecimal(ocrTimeSum).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
responseBody.put("nluTime",new BigDecimal(nluTimeSum).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
responseBody.put("detailList",ocrIdentifyDetailList);
return Result.OK(responseBody);
}

@ -9,6 +9,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.OcrConstant;
import org.jeecg.common.util.AssertUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.RestUtil;
import org.jeecg.modules.ocr.dto.OcrResultDTO;
@ -35,8 +36,10 @@ import javax.annotation.Resource;
import java.awt.*;
import java.io.File;
import java.math.BigDecimal;
import java.text.Collator;
import java.util.*;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
/**
@ -1080,12 +1083,21 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
//OCR和NlU执行时间总和
double ocrAndNluTimeSum = identifyDetailList.stream().mapToDouble(i -> (i.getOcrTime() == null ? 0 : i.getOcrTime()) + (i.getNluTime() == null ? 0 : i.getNluTime())).sum();
//执行时间(毫秒)
double dataStructuredTime = overDataCheckTime.getTime() - startDataCheckTime.getTime();
double executionTime = (ocrAndNluTimeSum * 1000) + dataStructuredTime;
double dataStructuredTime = new BigDecimal(overDataCheckTime.getTime() - startDataCheckTime.getTime()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
double executionTime = new BigDecimal(ocrAndNluTimeSum+(dataStructuredTime/1000)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
responseBody.put("min",min);
responseBody.put("max",max);
responseBody.put("dataStructuredTime",dataStructuredTime);
responseBody.put("allExecutionTime",executionTime);
//排序
Comparator<Object> english= Collator.getInstance(Locale.ENGLISH);
Collections.sort(ocrResultDTOList,(o1,o2)->{
if(english.compare(o1.getTag(),o2.getTag())==0){
return 1;
}
return -1;
});
responseBody.put("detailList", ocrResultDTOList);
if (ocrResultDTOList.size()==0) {
//没有匹配结果

Loading…
Cancel
Save