OCR识别-问题修改
This commit is contained in:
+68
-66
@@ -66,6 +66,7 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|
||||
queryWrapper.like(StringUtils.isNotEmpty(ocrRecordEOPage.getStandName()), OcrRecordEO::getStandName, ocrRecordEOPage.getStandName())
|
||||
.like(StringUtils.isNotEmpty(ocrRecordEOPage.getStandNumber()), OcrRecordEO::getStandNumber, ocrRecordEOPage.getStandNumber())
|
||||
.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);
|
||||
Page<OcrRecordEO> page = new Page<OcrRecordEO>(ocrRecordEOPage.getPageNo(), ocrRecordEOPage.getPageSize());
|
||||
IPage<OcrRecordEO> pageList = ocrRecordService.page(page, queryWrapper);
|
||||
@@ -92,86 +93,87 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|
||||
|| StringUtils.isBlank(ocrRecordEO.getStandNumber())){
|
||||
return Result.error("参数不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(ocrRecordEO.getFileType())) {
|
||||
return Result.error("文本状态不能为空");
|
||||
}
|
||||
//通过编号和标题查询对应文档
|
||||
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BussDocumentLibraryEO::getTitle, ocrRecordEO.getStandName())
|
||||
.eq(BussDocumentLibraryEO::getSerialNumber, ocrRecordEO.getStandNumber());
|
||||
List<BussDocumentLibraryEO> bussDocumentLibraryEOList = bussDocumentLibraryEOService.list(queryWrapper);
|
||||
if(CollectionUtil.isNotEmpty(bussDocumentLibraryEOList)){
|
||||
if(StringUtils.isBlank(ocrRecordEO.getFileType())){
|
||||
return Result.error("文本状态不也能为空");
|
||||
}
|
||||
OSSFile ossFile = new OSSFile();
|
||||
//查询doc文件的id
|
||||
LambdaQueryWrapper<OSSFile> ossFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
ossFileLambdaQueryWrapper.eq(OSSFile :: getUrl, ocrRecordEO.getDocName());
|
||||
ossFileLambdaQueryWrapper.eq(OSSFile::getUrl, ocrRecordEO.getDocName());
|
||||
List<OSSFile> ossFiles = ossFileService.list(ossFileLambdaQueryWrapper);
|
||||
if(CollectionUtil.isEmpty(ossFiles)){
|
||||
return Result.error("没有可同步的文档");
|
||||
if (CollectionUtil.isEmpty(ossFiles)) {
|
||||
return Result.error("没有可同步的文件");
|
||||
}
|
||||
String docFileId = ossFiles.get(0).getId();
|
||||
ossFile.setId(docFileId);
|
||||
//设置doc文件的关联id
|
||||
if (FileTypeEnum.RELEASE_DRAFT.getValue().equals(ocrRecordEO.getFileType())){
|
||||
String connectId = bussDocumentLibraryEOList.get(0).getReleaseDraft();
|
||||
if(StringUtils.isBlank(connectId)){
|
||||
connectId = UUID.randomUUID().toString().replace("-","");
|
||||
//修改文档库相关字段
|
||||
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
|
||||
bussDocumentLibraryEO.setId(bussDocumentLibraryEOList.get(0).getId());
|
||||
bussDocumentLibraryEO.setReleaseDraft(connectId);
|
||||
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
|
||||
}
|
||||
ossFile.setConnectId(connectId);
|
||||
//开始同步
|
||||
int countSuccess = 0;
|
||||
for(BussDocumentLibraryEO documentLibraryEO : bussDocumentLibraryEOList) {
|
||||
OSSFile ossFile = new OSSFile();
|
||||
String docFileId = ossFiles.get(0).getId();
|
||||
ossFile.setId(docFileId);
|
||||
//设置doc文件的关联id
|
||||
if (FileTypeEnum.RELEASE_DRAFT.getValue().equals(ocrRecordEO.getFileType())) {
|
||||
String connectId = documentLibraryEO.getReleaseDraft();
|
||||
if (StringUtils.isBlank(connectId)) {
|
||||
connectId = UUID.randomUUID().toString().replace("-", "");
|
||||
//修改文档库相关字段
|
||||
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
|
||||
bussDocumentLibraryEO.setId(documentLibraryEO.getId());
|
||||
bussDocumentLibraryEO.setReleaseDraft(connectId);
|
||||
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
|
||||
}
|
||||
ossFile.setConnectId(connectId);
|
||||
|
||||
}else if (FileTypeEnum.SUPPLEMENT.getValue().equals(ocrRecordEO.getFileType())){
|
||||
String connectId = bussDocumentLibraryEOList.get(0).getSupplement();
|
||||
if(StringUtils.isBlank(connectId)){
|
||||
connectId = UUID.randomUUID().toString().replace("-","");
|
||||
//修改文档库相关字段
|
||||
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
|
||||
bussDocumentLibraryEO.setId(bussDocumentLibraryEOList.get(0).getId());
|
||||
bussDocumentLibraryEO.setSupplement(connectId);
|
||||
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
|
||||
}
|
||||
ossFile.setConnectId(connectId);
|
||||
} else if (FileTypeEnum.SUPPLEMENT.getValue().equals(ocrRecordEO.getFileType())) {
|
||||
String connectId = documentLibraryEO.getSupplement();
|
||||
if (StringUtils.isBlank(connectId)) {
|
||||
connectId = UUID.randomUUID().toString().replace("-", "");
|
||||
//修改文档库相关字段
|
||||
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
|
||||
bussDocumentLibraryEO.setId(documentLibraryEO.getId());
|
||||
bussDocumentLibraryEO.setSupplement(connectId);
|
||||
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
|
||||
}
|
||||
ossFile.setConnectId(connectId);
|
||||
|
||||
}else if (FileTypeEnum.APPROVAL_DRAFT.getValue().equals(ocrRecordEO.getFileType())){
|
||||
String connectId = bussDocumentLibraryEOList.get(0).getApprovalDraft();
|
||||
if(StringUtils.isBlank(connectId)){
|
||||
connectId = UUID.randomUUID().toString().replace("-","");
|
||||
//修改文档库相关字段
|
||||
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
|
||||
bussDocumentLibraryEO.setId(bussDocumentLibraryEOList.get(0).getId());
|
||||
bussDocumentLibraryEO.setApprovalDraft(connectId);
|
||||
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
|
||||
}
|
||||
ossFile.setConnectId(connectId);
|
||||
} else if (FileTypeEnum.APPROVAL_DRAFT.getValue().equals(ocrRecordEO.getFileType())) {
|
||||
String connectId = documentLibraryEO.getApprovalDraft();
|
||||
if (StringUtils.isBlank(connectId)) {
|
||||
connectId = UUID.randomUUID().toString().replace("-", "");
|
||||
//修改文档库相关字段
|
||||
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
|
||||
bussDocumentLibraryEO.setId(documentLibraryEO.getId());
|
||||
bussDocumentLibraryEO.setApprovalDraft(connectId);
|
||||
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
|
||||
}
|
||||
ossFile.setConnectId(connectId);
|
||||
|
||||
}else if (FileTypeEnum.EXPOSURE_DRAFT.getValue().equals(ocrRecordEO.getFileType())){
|
||||
String connectId = bussDocumentLibraryEOList.get(0).getExposureDraft();
|
||||
if(StringUtils.isBlank(connectId)){
|
||||
connectId = UUID.randomUUID().toString().replace("-","");
|
||||
//修改文档库相关字段
|
||||
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
|
||||
bussDocumentLibraryEO.setId(bussDocumentLibraryEOList.get(0).getId());
|
||||
bussDocumentLibraryEO.setExposureDraft(connectId);
|
||||
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
|
||||
}
|
||||
ossFile.setConnectId(connectId);
|
||||
} else if (FileTypeEnum.EXPOSURE_DRAFT.getValue().equals(ocrRecordEO.getFileType())) {
|
||||
String connectId = documentLibraryEO.getExposureDraft();
|
||||
if (StringUtils.isBlank(connectId)) {
|
||||
connectId = UUID.randomUUID().toString().replace("-", "");
|
||||
//修改文档库相关字段
|
||||
BussDocumentLibraryEO bussDocumentLibraryEO = new BussDocumentLibraryEO();
|
||||
bussDocumentLibraryEO.setId(documentLibraryEO.getId());
|
||||
bussDocumentLibraryEO.setExposureDraft(connectId);
|
||||
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEO);
|
||||
}
|
||||
ossFile.setConnectId(connectId);
|
||||
|
||||
}
|
||||
boolean updateResult = ossFileService.updateById(ossFile);
|
||||
//修改记录表的同步情况
|
||||
OcrRecordEO updateOcrRecordEO = new OcrRecordEO();
|
||||
updateOcrRecordEO.setId(ocrRecordEO.getId());
|
||||
updateOcrRecordEO.setSyncState(FileSyncStateEnum.SYNC_YES.getValue());
|
||||
ocrRecordService.editById(updateOcrRecordEO);
|
||||
if(updateResult){
|
||||
return Result.OK("同步成功", ossFile);
|
||||
}else{
|
||||
return Result.error("同步失败");
|
||||
}
|
||||
}
|
||||
ossFileService.updateById(ossFile);
|
||||
//修改记录表的同步情况
|
||||
OcrRecordEO updateOcrRecordEO = new OcrRecordEO();
|
||||
updateOcrRecordEO.setId(ocrRecordEO.getId());
|
||||
updateOcrRecordEO.setSyncState(FileSyncStateEnum.SYNC_YES.getValue());
|
||||
ocrRecordService.editById(updateOcrRecordEO);
|
||||
countSuccess++;
|
||||
}
|
||||
return Result.OK("同步成功", countSuccess);
|
||||
}else{
|
||||
return Result.error("没有可同步的文档");
|
||||
}
|
||||
|
||||
+5
-8
@@ -1,14 +1,6 @@
|
||||
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 org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* @Author: liyawei
|
||||
@@ -78,6 +70,11 @@ public class OcrRecordEOPage {
|
||||
|
||||
private String jsonRealFile;
|
||||
|
||||
//分页
|
||||
private Integer pageNo;
|
||||
private Integer pageSize;
|
||||
|
||||
//排序
|
||||
private String orderBy;
|
||||
private String orderByField;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user