|
|
|
@ -5,9 +5,11 @@ import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
|
import org.jeecg.common.constant.OcrConstant;
|
|
|
|
@ -22,12 +24,10 @@ import org.jeecg.common.system.vo.DictModel;
|
|
|
|
|
import org.jeecg.common.util.AssertUtils;
|
|
|
|
|
import org.jeecg.common.util.RedisUtil;
|
|
|
|
|
import org.jeecg.modules.ocr.entity.OcrIdentify;
|
|
|
|
|
import org.jeecg.modules.ocr.entity.OcrIdentifyDetail;
|
|
|
|
|
import org.jeecg.modules.ocr.entity.OcrMetadataConfig;
|
|
|
|
|
import org.jeecg.modules.ocr.service.IOcrIdentifyService;
|
|
|
|
|
import org.jeecg.modules.ocr.service.*;
|
|
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
|
|
import org.jeecg.modules.ocr.service.IOcrMetadataConfigService;
|
|
|
|
|
import org.jeecg.modules.ocr.service.IOcrRuleCheckService;
|
|
|
|
|
import org.jeecg.modules.ocr.service.IOcrTaskTypeService;
|
|
|
|
|
import org.jeecg.modules.ocr.utils.DownloadTemplateUtil;
|
|
|
|
|
import org.jeecg.modules.ocr.utils.FileOUtils;
|
|
|
|
|
import org.jeecg.modules.ocr.vo.OcrIdentifyVo;
|
|
|
|
@ -57,6 +57,8 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
|
|
|
|
|
@Autowired
|
|
|
|
|
private IOcrIdentifyService ocrIdentifyService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IOcrIdentifyDetailService ocrIdentifyDetailService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private DownloadTemplateUtil downloadTemplateUtil;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IOcrTaskTypeService ocrTaskTypeService;
|
|
|
|
@ -92,8 +94,27 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
|
|
|
|
|
Map<String, OcrMetadataConfigVo> metadataConfigMap = ocrMetadataConfigService.listToMap(null);
|
|
|
|
|
Map<String, String> taskNameMap = ocrTaskTypeService.listNameToMap(null);
|
|
|
|
|
IPage<OcrIdentify> pageList = ocrIdentifyService.page(page, queryWrapper);
|
|
|
|
|
|
|
|
|
|
if (pageList != null && pageList.getRecords() != null) {
|
|
|
|
|
List<String> idList = pageList.getRecords().stream().map(p -> p.getId()).collect(Collectors.toList());
|
|
|
|
|
List<OcrIdentifyDetail> ocrIdentifyDetailList = ocrIdentifyDetailService.list(new LambdaQueryWrapper<OcrIdentifyDetail>().in(OcrIdentifyDetail::getIdentifyId, idList));
|
|
|
|
|
List<OcrIdentifyDetail> identifyDetailList = new ArrayList<>();
|
|
|
|
|
for (OcrIdentify record : pageList.getRecords()) {
|
|
|
|
|
if ("1".equals(record.getStatus())) {
|
|
|
|
|
//判断明细是否识别成功
|
|
|
|
|
identifyDetailList = ocrIdentifyDetailList.stream().filter(o -> o.getIdentifyId().equals(record.getId())).collect(Collectors.toList());
|
|
|
|
|
if (identifyDetailList.size()>0) {
|
|
|
|
|
long errorCount = identifyDetailList.stream().filter(i -> i.getStatus().equals("1")).count();
|
|
|
|
|
//errorCount>0,说明有失败的明细
|
|
|
|
|
record.setTaskResult(errorCount>0?"0":"1");
|
|
|
|
|
}else{
|
|
|
|
|
//失败
|
|
|
|
|
record.setTaskResult("0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OcrRuleCheckVo ocrRuleCheckVo = ocrRuleCheckMap.get(record.getRuleCheck());
|
|
|
|
|
if (ocrRuleCheckVo!=null && StringUtils.isNotBlank(ocrRuleCheckVo.getMetadataConfigId())) {
|
|
|
|
|
record.setMetadataConfigId(ocrRuleCheckVo.getMetadataConfigId());
|
|
|
|
|