OCR识别-问题修改

This commit is contained in:
liyawei
2022-03-03 19:05:57 +08:00
parent a014b2b8c4
commit ff7c8d4e35
2 changed files with 73 additions and 74 deletions
@@ -66,6 +66,7 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
queryWrapper.like(StringUtils.isNotEmpty(ocrRecordEOPage.getStandName()), OcrRecordEO::getStandName, ocrRecordEOPage.getStandName()) queryWrapper.like(StringUtils.isNotEmpty(ocrRecordEOPage.getStandName()), OcrRecordEO::getStandName, ocrRecordEOPage.getStandName())
.like(StringUtils.isNotEmpty(ocrRecordEOPage.getStandNumber()), OcrRecordEO::getStandNumber, ocrRecordEOPage.getStandNumber()) .like(StringUtils.isNotEmpty(ocrRecordEOPage.getStandNumber()), OcrRecordEO::getStandNumber, ocrRecordEOPage.getStandNumber())
.eq(StringUtils.isNotEmpty(ocrRecordEOPage.getResultContent()), OcrRecordEO::getResultContent, ocrRecordEOPage.getResultContent()) .eq(StringUtils.isNotEmpty(ocrRecordEOPage.getResultContent()), OcrRecordEO::getResultContent, ocrRecordEOPage.getResultContent())
.orderBy(StringUtils.isNotBlank(ocrRecordEOPage.getOrderByField()), "1".equals(ocrRecordEOPage.getOrderBy())?true:false, OcrRecordEO::getUpdateTime)
.orderByDesc(OcrRecordEO::getCreateTime); .orderByDesc(OcrRecordEO::getCreateTime);
Page<OcrRecordEO> page = new Page<OcrRecordEO>(ocrRecordEOPage.getPageNo(), ocrRecordEOPage.getPageSize()); Page<OcrRecordEO> page = new Page<OcrRecordEO>(ocrRecordEOPage.getPageNo(), ocrRecordEOPage.getPageSize());
IPage<OcrRecordEO> pageList = ocrRecordService.page(page, queryWrapper); IPage<OcrRecordEO> pageList = ocrRecordService.page(page, queryWrapper);
@@ -92,86 +93,87 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|| StringUtils.isBlank(ocrRecordEO.getStandNumber())){ || StringUtils.isBlank(ocrRecordEO.getStandNumber())){
return Result.error("参数不能为空"); return Result.error("参数不能为空");
} }
if (StringUtils.isBlank(ocrRecordEO.getFileType())) {
return Result.error("文本状态不能为空");
}
//通过编号和标题查询对应文档 //通过编号和标题查询对应文档
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BussDocumentLibraryEO::getTitle, ocrRecordEO.getStandName()) queryWrapper.eq(BussDocumentLibraryEO::getTitle, ocrRecordEO.getStandName())
.eq(BussDocumentLibraryEO::getSerialNumber, ocrRecordEO.getStandNumber()); .eq(BussDocumentLibraryEO::getSerialNumber, ocrRecordEO.getStandNumber());
List<BussDocumentLibraryEO> bussDocumentLibraryEOList = bussDocumentLibraryEOService.list(queryWrapper); List<BussDocumentLibraryEO> bussDocumentLibraryEOList = bussDocumentLibraryEOService.list(queryWrapper);
if(CollectionUtil.isNotEmpty(bussDocumentLibraryEOList)){ if(CollectionUtil.isNotEmpty(bussDocumentLibraryEOList)){
if(StringUtils.isBlank(ocrRecordEO.getFileType())){
return Result.error("文本状态不也能为空");
}
OSSFile ossFile = new OSSFile();
//查询doc文件的id //查询doc文件的id
LambdaQueryWrapper<OSSFile> ossFileLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OSSFile> ossFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
ossFileLambdaQueryWrapper.eq(OSSFile :: getUrl, ocrRecordEO.getDocName()); ossFileLambdaQueryWrapper.eq(OSSFile::getUrl, ocrRecordEO.getDocName());
List<OSSFile> ossFiles = ossFileService.list(ossFileLambdaQueryWrapper); List<OSSFile> ossFiles = ossFileService.list(ossFileLambdaQueryWrapper);
if(CollectionUtil.isEmpty(ossFiles)){ if (CollectionUtil.isEmpty(ossFiles)) {
return Result.error("没有可同步的文"); return Result.error("没有可同步的文");
} }
String docFileId = ossFiles.get(0).getId(); //开始同步
ossFile.setId(docFileId); int countSuccess = 0;
//设置doc文件的关联id for(BussDocumentLibraryEO documentLibraryEO : bussDocumentLibraryEOList) {
if (FileTypeEnum.RELEASE_DRAFT.getValue().equals(ocrRecordEO.getFileType())){ OSSFile ossFile = new OSSFile();
String connectId = bussDocumentLibraryEOList.get(0).getReleaseDraft(); String docFileId = ossFiles.get(0).getId();
if(StringUtils.isBlank(connectId)){ ossFile.setId(docFileId);
connectId = UUID.randomUUID().toString().replace("-",""); //设置doc文件的关联id
//修改文档库相关字段 if (FileTypeEnum.RELEASE_DRAFT.getValue().equals(ocrRecordEO.getFileType())) {
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO(); String connectId = documentLibraryEO.getReleaseDraft();
bussDocumentLibraryEO.setId(bussDocumentLibraryEOList.get(0).getId()); if (StringUtils.isBlank(connectId)) {
bussDocumentLibraryEO.setReleaseDraft(connectId); connectId = UUID.randomUUID().toString().replace("-", "");
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO); //修改文档库相关字段
} BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
ossFile.setConnectId(connectId); bussDocumentLibraryEO.setId(documentLibraryEO.getId());
bussDocumentLibraryEO.setReleaseDraft(connectId);
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
}
ossFile.setConnectId(connectId);
}else if (FileTypeEnum.SUPPLEMENT.getValue().equals(ocrRecordEO.getFileType())){ } else if (FileTypeEnum.SUPPLEMENT.getValue().equals(ocrRecordEO.getFileType())) {
String connectId = bussDocumentLibraryEOList.get(0).getSupplement(); String connectId = documentLibraryEO.getSupplement();
if(StringUtils.isBlank(connectId)){ if (StringUtils.isBlank(connectId)) {
connectId = UUID.randomUUID().toString().replace("-",""); connectId = UUID.randomUUID().toString().replace("-", "");
//修改文档库相关字段 //修改文档库相关字段
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO(); BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
bussDocumentLibraryEO.setId(bussDocumentLibraryEOList.get(0).getId()); bussDocumentLibraryEO.setId(documentLibraryEO.getId());
bussDocumentLibraryEO.setSupplement(connectId); bussDocumentLibraryEO.setSupplement(connectId);
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO); bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
} }
ossFile.setConnectId(connectId); ossFile.setConnectId(connectId);
}else if (FileTypeEnum.APPROVAL_DRAFT.getValue().equals(ocrRecordEO.getFileType())){ } else if (FileTypeEnum.APPROVAL_DRAFT.getValue().equals(ocrRecordEO.getFileType())) {
String connectId = bussDocumentLibraryEOList.get(0).getApprovalDraft(); String connectId = documentLibraryEO.getApprovalDraft();
if(StringUtils.isBlank(connectId)){ if (StringUtils.isBlank(connectId)) {
connectId = UUID.randomUUID().toString().replace("-",""); connectId = UUID.randomUUID().toString().replace("-", "");
//修改文档库相关字段 //修改文档库相关字段
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO(); BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
bussDocumentLibraryEO.setId(bussDocumentLibraryEOList.get(0).getId()); bussDocumentLibraryEO.setId(documentLibraryEO.getId());
bussDocumentLibraryEO.setApprovalDraft(connectId); bussDocumentLibraryEO.setApprovalDraft(connectId);
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO); bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
} }
ossFile.setConnectId(connectId); ossFile.setConnectId(connectId);
}else if (FileTypeEnum.EXPOSURE_DRAFT.getValue().equals(ocrRecordEO.getFileType())){ } else if (FileTypeEnum.EXPOSURE_DRAFT.getValue().equals(ocrRecordEO.getFileType())) {
String connectId = bussDocumentLibraryEOList.get(0).getExposureDraft(); String connectId = documentLibraryEO.getExposureDraft();
if(StringUtils.isBlank(connectId)){ if (StringUtils.isBlank(connectId)) {
connectId = UUID.randomUUID().toString().replace("-",""); connectId = UUID.randomUUID().toString().replace("-", "");
//修改文档库相关字段 //修改文档库相关字段
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO(); BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
bussDocumentLibraryEO.setId(bussDocumentLibraryEOList.get(0).getId()); bussDocumentLibraryEO.setId(documentLibraryEO.getId());
bussDocumentLibraryEO.setExposureDraft(connectId); bussDocumentLibraryEO.setExposureDraft(connectId);
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO); bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
} }
ossFile.setConnectId(connectId); ossFile.setConnectId(connectId);
} }
boolean updateResult = ossFileService.updateById(ossFile); ossFileService.updateById(ossFile);
//修改记录表的同步情况 //修改记录表的同步情况
OcrRecordEO updateOcrRecordEO = new OcrRecordEO(); OcrRecordEO updateOcrRecordEO = new OcrRecordEO();
updateOcrRecordEO.setId(ocrRecordEO.getId()); updateOcrRecordEO.setId(ocrRecordEO.getId());
updateOcrRecordEO.setSyncState(FileSyncStateEnum.SYNC_YES.getValue()); updateOcrRecordEO.setSyncState(FileSyncStateEnum.SYNC_YES.getValue());
ocrRecordService.editById(updateOcrRecordEO); ocrRecordService.editById(updateOcrRecordEO);
if(updateResult){ countSuccess++;
return Result.OK("同步成功", ossFile); }
}else{ return Result.OK("同步成功", countSuccess);
return Result.error("同步失败");
}
}else{ }else{
return Result.error("没有可同步的文档"); return Result.error("没有可同步的文档");
} }
@@ -1,14 +1,6 @@
package com.jero.modules.ocr.page; package com.jero.modules.ocr.page;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/** /**
* @Author: liyawei * @Author: liyawei
@@ -78,6 +70,11 @@ public class OcrRecordEOPage {
private String jsonRealFile; private String jsonRealFile;
//分页
private Integer pageNo; private Integer pageNo;
private Integer pageSize; private Integer pageSize;
//排序
private String orderBy;
private String orderByField;
} }