Merge remote-tracking branch 'origin/master'
This commit is contained in:
+28
-90
@@ -7,11 +7,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
import com.jero.common.aspect.annotation.AutoLog;
|
import com.jero.common.aspect.annotation.AutoLog;
|
||||||
import com.jero.common.system.base.controller.JeroController;
|
import com.jero.common.system.base.controller.JeroController;
|
||||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
|
||||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||||
import com.jero.modules.ocr.entity.OcrRecordEO;
|
import com.jero.modules.ocr.entity.OcrRecordEO;
|
||||||
|
import com.jero.modules.ocr.enums.FileSourceEnum;
|
||||||
import com.jero.modules.ocr.enums.FileSyncStateEnum;
|
import com.jero.modules.ocr.enums.FileSyncStateEnum;
|
||||||
import com.jero.modules.ocr.enums.FileTypeEnum;
|
|
||||||
import com.jero.modules.ocr.page.OcrRecordEOPage;
|
import com.jero.modules.ocr.page.OcrRecordEOPage;
|
||||||
import com.jero.modules.ocr.service.IOcrRecordEOService;
|
import com.jero.modules.ocr.service.IOcrRecordEOService;
|
||||||
import com.jero.modules.oss.entity.OSSFile;
|
import com.jero.modules.oss.entity.OSSFile;
|
||||||
@@ -28,7 +27,9 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,6 +73,11 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|
|||||||
IPage<OcrRecordEO> pageList = ocrRecordService.page(page, queryWrapper);
|
IPage<OcrRecordEO> pageList = ocrRecordService.page(page, queryWrapper);
|
||||||
List<OcrRecordEO> rows = pageList.getRecords();
|
List<OcrRecordEO> rows = pageList.getRecords();
|
||||||
for (OcrRecordEO row : rows){
|
for (OcrRecordEO row : rows){
|
||||||
|
if(StringUtils.isNotEmpty(row.getConnectId())) {
|
||||||
|
row.setFileSource(FileSourceEnum.IMPORT.getValue());
|
||||||
|
}else{
|
||||||
|
row.setFileSource(FileSourceEnum.UPLOAD.getValue());
|
||||||
|
}
|
||||||
if(StringUtils.isNotEmpty(row.getDocRealName())) {
|
if(StringUtils.isNotEmpty(row.getDocRealName())) {
|
||||||
row.setDocRealFile(ocrDownPath + row.getDocRealName());
|
row.setDocRealFile(ocrDownPath + row.getDocRealName());
|
||||||
}
|
}
|
||||||
@@ -86,97 +92,29 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|
|||||||
@ApiOperation(value="OCR识别转换记录表-同步至文档库", notes="OCR识别转换记录表-同步至文档库")
|
@ApiOperation(value="OCR识别转换记录表-同步至文档库", notes="OCR识别转换记录表-同步至文档库")
|
||||||
@PostMapping(value = "/syncToDocument")
|
@PostMapping(value = "/syncToDocument")
|
||||||
public Result<?> syncToDocument(@RequestBody OcrRecordEO ocrRecordEO) {
|
public Result<?> syncToDocument(@RequestBody OcrRecordEO ocrRecordEO) {
|
||||||
if(StringUtils.isBlank(ocrRecordEO.getAttId())){
|
if(StringUtils.isBlank(ocrRecordEO.getConnectId())){
|
||||||
return Result.error("没有可同步的文档");
|
return Result.error("同步失败");
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(ocrRecordEO.getStandName())
|
//查询doc文件的id
|
||||||
|| StringUtils.isBlank(ocrRecordEO.getStandNumber())){
|
LambdaQueryWrapper<OSSFile> ossFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
return Result.error("参数不能为空");
|
ossFileLambdaQueryWrapper.eq(OSSFile::getUrl, ocrRecordEO.getDocName());
|
||||||
|
List<OSSFile> ossFiles = ossFileService.list(ossFileLambdaQueryWrapper);
|
||||||
|
if (CollectionUtil.isEmpty(ossFiles)) {
|
||||||
|
return Result.error("没有可同步的文件");
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(ocrRecordEO.getFileType())) {
|
OSSFile ossFile = new OSSFile();
|
||||||
return Result.error("文本状态不能为空");
|
String docFileId = ossFiles.get(0).getId();
|
||||||
}
|
ossFile.setId(docFileId);
|
||||||
//通过编号和标题查询对应文档
|
ossFile.setConnectId(ocrRecordEO.getConnectId());
|
||||||
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapper = new LambdaQueryWrapper<>();
|
ossFileService.updateById(ossFile);
|
||||||
queryWrapper.eq(BussDocumentLibraryEO::getTitle, ocrRecordEO.getStandName())
|
|
||||||
.eq(BussDocumentLibraryEO::getSerialNumber, ocrRecordEO.getStandNumber());
|
|
||||||
List<BussDocumentLibraryEO> bussDocumentLibraryEOList = bussDocumentLibraryEOService.list(queryWrapper);
|
|
||||||
if(CollectionUtil.isNotEmpty(bussDocumentLibraryEOList)){
|
|
||||||
//查询doc文件的id
|
|
||||||
LambdaQueryWrapper<OSSFile> ossFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
ossFileLambdaQueryWrapper.eq(OSSFile::getUrl, ocrRecordEO.getDocName());
|
|
||||||
List<OSSFile> ossFiles = ossFileService.list(ossFileLambdaQueryWrapper);
|
|
||||||
if (CollectionUtil.isEmpty(ossFiles)) {
|
|
||||||
return Result.error("没有可同步的文件");
|
|
||||||
}
|
|
||||||
//开始同步
|
|
||||||
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 = documentLibraryEO.getSupplement();
|
OcrRecordEO updateOcrRecordEO = new OcrRecordEO();
|
||||||
if (StringUtils.isBlank(connectId)) {
|
updateOcrRecordEO.setId(ocrRecordEO.getId());
|
||||||
connectId = UUID.randomUUID().toString().replace("-", "");
|
updateOcrRecordEO.setSyncState(FileSyncStateEnum.SYNC_YES.getValue());
|
||||||
//修改文档库相关字段
|
ocrRecordService.editById(updateOcrRecordEO);
|
||||||
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())) {
|
return Result.OK("同步成功", ossFile);
|
||||||
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 = 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);
|
|
||||||
|
|
||||||
}
|
|
||||||
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("没有可同步的文档");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+3
-1
@@ -105,7 +105,9 @@ public class OcrRestfulController{
|
|||||||
* OCR回调
|
* OCR回调
|
||||||
* @param wordFile
|
* @param wordFile
|
||||||
* @param jsonFile
|
* @param jsonFile
|
||||||
* @param ocrCallBackResultEo
|
* @param taskId
|
||||||
|
* @param result
|
||||||
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "OCR回调")
|
@ApiOperation(value = "OCR回调")
|
||||||
|
|||||||
+11
-7
@@ -1,22 +1,20 @@
|
|||||||
package com.jero.modules.ocr.entity;
|
package com.jero.modules.ocr.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
|
||||||
import com.jero.common.aspect.annotation.Dict;
|
import com.jero.common.aspect.annotation.Dict;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,9 +126,15 @@ public class OcrRecordEO implements Serializable {
|
|||||||
@Excel(name = "同步状态", width = 15)
|
@Excel(name = "同步状态", width = 15)
|
||||||
@ApiModelProperty(value = "同步状态")
|
@ApiModelProperty(value = "同步状态")
|
||||||
private String syncState;
|
private String syncState;
|
||||||
|
|
||||||
|
/**文档库关联文件id*/
|
||||||
|
@ApiModelProperty(value = "文档库关联文件id")
|
||||||
|
private String connectId;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String docRealFile;
|
private String docRealFile;
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String jsonRealFile;
|
private String jsonRealFile;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String fileSource; //文件来源:0-上传 1-导入
|
||||||
}
|
}
|
||||||
|
|||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package com.jero.modules.ocr.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: liyawei
|
||||||
|
* @Description:
|
||||||
|
* @Date: Created in 16:04 2022/3/8
|
||||||
|
*/
|
||||||
|
public enum FileSourceEnum {
|
||||||
|
UPLOAD("上传","0"),
|
||||||
|
IMPORT("导入","1");
|
||||||
|
|
||||||
|
String name;
|
||||||
|
String value;
|
||||||
|
|
||||||
|
FileSourceEnum(String name, String value) {
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
@@ -21,5 +21,6 @@
|
|||||||
<result column="json_file_code" property="jsonFileCode" />
|
<result column="json_file_code" property="jsonFileCode" />
|
||||||
<result column="att_id" property="attId" />
|
<result column="att_id" property="attId" />
|
||||||
<result column="sync_state" property="syncState" />
|
<result column="sync_state" property="syncState" />
|
||||||
|
<result column="connect_id" property="connectId" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
</mapper>
|
</mapper>
|
||||||
+14
-1
@@ -11,6 +11,8 @@ import com.jero.modules.ocr.service.IOcrRestfulService;
|
|||||||
import com.jero.modules.ocr.util.Base64Util;
|
import com.jero.modules.ocr.util.Base64Util;
|
||||||
import com.jero.modules.ocr.util.RsaUtil;
|
import com.jero.modules.ocr.util.RsaUtil;
|
||||||
import com.jero.modules.ocr.util.UUIDUtils;
|
import com.jero.modules.ocr.util.UUIDUtils;
|
||||||
|
import com.jero.modules.oss.entity.OSSFile;
|
||||||
|
import com.jero.modules.oss.service.IOSSFileService;
|
||||||
import com.jero.modules.system.vo.OcrVO;
|
import com.jero.modules.system.vo.OcrVO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@@ -32,6 +34,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @program: OcrDemo
|
* @program: OcrDemo
|
||||||
@@ -52,6 +55,8 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOcrRecordEOService ocrRecordEOService;
|
private IOcrRecordEOService ocrRecordEOService;
|
||||||
|
@Autowired
|
||||||
|
private IOSSFileService ossFileService;
|
||||||
|
|
||||||
|
|
||||||
//请求处理文件url
|
//请求处理文件url
|
||||||
@@ -202,7 +207,15 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
|||||||
ocrRecordEO.setJsonFileCode(null);
|
ocrRecordEO.setJsonFileCode(null);
|
||||||
ocrRecordEO.setUpdateTime(new Date());
|
ocrRecordEO.setUpdateTime(new Date());
|
||||||
ocrRecordEO.setResultContent("转换成功");
|
ocrRecordEO.setResultContent("转换成功");
|
||||||
ocrRecordEOService.editById(ocrRecordEO);
|
ocrRecordEOService.updateById(ocrRecordEO);
|
||||||
|
|
||||||
|
//记录doc文件信息
|
||||||
|
OSSFile docFile = new OSSFile();
|
||||||
|
docFile.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||||
|
docFile.setUrl(saveWordFilePath);
|
||||||
|
docFile.setFileName(saveWordFilePath.substring(saveWordFilePath.lastIndexOf("_")+1));
|
||||||
|
ossFileService.save(docFile);
|
||||||
|
|
||||||
return "{\"result\":\"success\"}";
|
return "{\"result\":\"success\"}";
|
||||||
}else{
|
}else{
|
||||||
updateDb(taskId,"error:File does not exist");
|
updateDb(taskId,"error:File does not exist");
|
||||||
|
|||||||
Reference in New Issue
Block a user