|
|
|
@ -3,8 +3,11 @@ package org.jeecg.modules.ocr.controller;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
|
import org.jeecg.common.constant.OcrConstant;
|
|
|
|
|
import org.jeecg.common.constant.enums.OcrStatusEnum;
|
|
|
|
@ -19,8 +22,14 @@ import org.jeecg.modules.ocr.entity.OcrIdentify;
|
|
|
|
|
import org.jeecg.modules.ocr.entity.OcrMetadataConfig;
|
|
|
|
|
import org.jeecg.modules.ocr.service.IOcrIdentifyService;
|
|
|
|
|
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;
|
|
|
|
|
import org.jeecg.modules.ocr.vo.OcrMetadataConfigVo;
|
|
|
|
|
import org.jeecg.modules.ocr.vo.OcrRuleCheckVo;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
@ -44,6 +53,12 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
|
|
|
|
|
private IOcrIdentifyService ocrIdentifyService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private DownloadTemplateUtil downloadTemplateUtil;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IOcrTaskTypeService ocrTaskTypeService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IOcrMetadataConfigService ocrMetadataConfigService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IOcrRuleCheckService ocrRuleCheckService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页列表查询
|
|
|
|
@ -63,7 +78,19 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
|
|
|
|
|
HttpServletRequest req) {
|
|
|
|
|
QueryWrapper<OcrIdentify> queryWrapper = QueryGenerator.initQueryWrapper(ocrIdentify, req.getParameterMap());
|
|
|
|
|
Page<OcrIdentify> page = new Page<OcrIdentify>(pageNo, pageSize);
|
|
|
|
|
Map<String, OcrRuleCheckVo> ocrRuleCheckMap = ocrRuleCheckService.listToMap(null);
|
|
|
|
|
Map<String, OcrMetadataConfigVo> metadataConfigMap = ocrMetadataConfigService.listToMap(null);
|
|
|
|
|
IPage<OcrIdentify> pageList = ocrIdentifyService.page(page, queryWrapper);
|
|
|
|
|
if (pageList != null && pageList.getRecords() != null) {
|
|
|
|
|
for (OcrIdentify record : pageList.getRecords()) {
|
|
|
|
|
OcrRuleCheckVo ocrRuleCheckVo = ocrRuleCheckMap.get(record.getRuleCheck());
|
|
|
|
|
if (ocrRuleCheckVo!=null && StringUtils.isNotBlank(ocrRuleCheckVo.getMetadataConfigId())) {
|
|
|
|
|
record.setMetadataConfigId(ocrRuleCheckVo.getMetadataConfigId());
|
|
|
|
|
OcrMetadataConfigVo ocrMetadataConfigVo = metadataConfigMap.get(ocrRuleCheckVo.getMetadataConfigId());
|
|
|
|
|
record.setTaskType_dictText(ocrMetadataConfigVo!=null?ocrMetadataConfigVo.getTaskType_dictText():null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Result.OK(pageList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -93,6 +120,7 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AssertUtils.hasSize(fileList, "图片目录下未获取到可使用的图片格式文件");
|
|
|
|
|
ocrIdentify.setTaskSource("平台");
|
|
|
|
|
ocrIdentifyService.save(ocrIdentify);
|
|
|
|
|
//3.请求python ocr识别,异步执行
|
|
|
|
|
ocrIdentifyService.postSemantic(ocrIdentify, fileList);
|
|
|
|
@ -159,6 +187,7 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过id查询
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|