ocr识别-数据字典字段中英文切换
This commit is contained in:
+3
@@ -20,6 +20,9 @@ public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
|
||||
@Select("SELECT * FROM sys_dict_item WHERE DICT_ID = #{mainId} order by sort_order asc, item_value asc")
|
||||
public List<SysDictItem> selectItemsByMainId(String mainId);
|
||||
|
||||
@Select("SELECT sys_dict_item.* FROM sys_dict_item LEFT JOIN sys_dict ON sys_dict_item.dict_id = sys_dict.id WHERE DICT_CODE = #{dictCode} order by sort_order asc, item_value asc")
|
||||
public List<SysDictItem> selectItemsByDictCode(String dictCode);
|
||||
|
||||
@Select("SELECT sys_dict.dict_code,sys_dict_item.* from sys_dict_item LEFT JOIN sys_dict ON sys_dict_item.dict_id = sys_dict.id where status = 1")
|
||||
List<SysDictItem> selectItemsAll();
|
||||
|
||||
|
||||
+2
@@ -16,6 +16,8 @@ import java.util.List;
|
||||
public interface ISysDictItemService extends IService<SysDictItem> {
|
||||
public List<SysDictItem> selectItemsByMainId(String mainId);
|
||||
|
||||
public List<SysDictItem> selectItemsByDictCode(String dictCode);
|
||||
|
||||
/**
|
||||
* 查询所有数据字典信息
|
||||
* @return
|
||||
|
||||
+6
@@ -28,6 +28,12 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
|
||||
return sysDictItemMapper.selectItemsByMainId(mainId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDictItem> selectItemsByDictCode(String dictCode) {
|
||||
return sysDictItemMapper.selectItemsByDictCode(dictCode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有数据字典信息
|
||||
* @return
|
||||
|
||||
+4
-19
@@ -9,7 +9,6 @@ import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
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.page.OcrRecordEOPage;
|
||||
import com.jero.modules.ocr.service.IOcrRecordEOService;
|
||||
@@ -21,7 +20,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -51,9 +49,6 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|
||||
@Autowired
|
||||
private IOSSFileService ossFileService;
|
||||
|
||||
@Value("${OCR.ocrDownPath}")
|
||||
private String ocrDownPath;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
@@ -73,19 +68,7 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|
||||
Page<OcrRecordEO> page = new Page<OcrRecordEO>(ocrRecordEOPage.getPageNo(), ocrRecordEOPage.getPageSize());
|
||||
IPage<OcrRecordEO> pageList = ocrRecordService.page(page, queryWrapper);
|
||||
List<OcrRecordEO> rows = pageList.getRecords();
|
||||
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())) {
|
||||
row.setDocRealFile(ocrDownPath + row.getDocRealName());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(row.getJsonRealName())) {
|
||||
row.setJsonRealFile(ocrDownPath + row.getJsonRealName());
|
||||
}
|
||||
}
|
||||
ocrRecordService.dataProcessing(ocrRecordEOPage.getCut(), rows);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@@ -217,6 +200,7 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|
||||
return Result.error("删除数据不能为空");
|
||||
}
|
||||
ocrRecordService.deleteById(id);
|
||||
//TODO 删除上传的pdf文件,转换成功的将doc文件一并删除
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@@ -234,7 +218,8 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
return Result.error("删除数据不能为空");
|
||||
}
|
||||
this.ocrRecordService.deleteByIds(Arrays.asList(ids.split(",")));
|
||||
ocrRecordService.deleteByIds(Arrays.asList(ids.split(",")));
|
||||
//TODO 删除上传的pdf文件,转换成功的将doc文件一并删除
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -72,7 +71,7 @@ public class OcrRecordEO implements Serializable {
|
||||
|
||||
/**文本状态*/
|
||||
@Excel(name = "文本状态", width = 15, dicCode = "file_type")
|
||||
@Dict(dicCode = "file_type")
|
||||
// @Dict(dicCode = "file_type")
|
||||
@ApiModelProperty(value = "文本状态")
|
||||
private String fileType;
|
||||
|
||||
@@ -83,7 +82,7 @@ public class OcrRecordEO implements Serializable {
|
||||
|
||||
/**转换结果*/
|
||||
@Excel(name = "转换结果", width = 15)
|
||||
@Dict(dicCode = "result_content")
|
||||
// @Dict(dicCode = "result_content")
|
||||
@ApiModelProperty(value = "转换结果")
|
||||
private String resultContent;
|
||||
|
||||
|
||||
+2
@@ -77,4 +77,6 @@ public class OcrRecordEOPage {
|
||||
//排序
|
||||
private String orderBy;
|
||||
private String orderByField;
|
||||
|
||||
private String cut; // 中英文切换标识
|
||||
}
|
||||
|
||||
+9
-4
@@ -1,10 +1,8 @@
|
||||
package com.jero.modules.ocr.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.modules.ocr.entity.OcrRecordEO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.modules.ocr.entity.OcrRecordEO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -87,4 +85,11 @@ public interface IOcrRecordEOService extends IService<OcrRecordEO> {
|
||||
*/
|
||||
List<Map<String, Object>> getForm(String flag, String cut);
|
||||
|
||||
/**
|
||||
* 处理列表数据字典值中英文切换
|
||||
* @param cut
|
||||
* @param ocrRecordEOList
|
||||
* @return
|
||||
*/
|
||||
void dataProcessing(String cut, List<OcrRecordEO> ocrRecordEOList);
|
||||
}
|
||||
|
||||
+76
-8
@@ -1,22 +1,27 @@
|
||||
package com.jero.modules.ocr.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.constant.enums.ModuleEnum;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
|
||||
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
||||
import com.jero.modules.ocr.entity.OcrRecordEO;
|
||||
import com.jero.modules.ocr.enums.FileSourceEnum;
|
||||
import com.jero.modules.ocr.mapper.OcrRecordEOMapper;
|
||||
import com.jero.modules.ocr.service.IOcrRecordEOService;
|
||||
import com.jero.modules.ocr.util.LineHumpUtil;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: OCR识别转换记录表
|
||||
* @Author: jero-boot
|
||||
@@ -28,6 +33,13 @@ public class OcrRecordEOServiceImpl extends ServiceImpl<OcrRecordEOMapper, OcrRe
|
||||
|
||||
@Autowired
|
||||
private OnlCgformFieldServiceImpl onlCgformFieldService;
|
||||
|
||||
@Autowired
|
||||
private ISysDictItemService sysDictItemService;
|
||||
|
||||
@Value("${OCR.ocrDownPath}")
|
||||
private String ocrDownPath;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
@@ -125,12 +137,12 @@ public class OcrRecordEOServiceImpl extends ServiceImpl<OcrRecordEOMapper, OcrRe
|
||||
}
|
||||
|
||||
String dbFieldName = onlCgformField.getDbFieldName();
|
||||
if (StringUtils.isNotBlank(onlCgformField.getDictField())) {
|
||||
map.put("db_field_name", LineHumpUtil.lineToHump(dbFieldName)+ "_dictText");//配置了数据字典的字段,需要特殊处理
|
||||
}else{
|
||||
map.put("db_field_name", LineHumpUtil.lineToHump(dbFieldName));//字段
|
||||
}
|
||||
|
||||
// if (StringUtils.isNotBlank(onlCgformField.getDictField())) {
|
||||
// map.put("db_field_name", LineHumpUtil.lineToHump(dbFieldName)+ "_dictText");//配置了数据字典的字段,需要特殊处理
|
||||
// }else{
|
||||
// map.put("db_field_name", LineHumpUtil.lineToHump(dbFieldName));//字段
|
||||
// }
|
||||
map.put("db_field_name", LineHumpUtil.lineToHump(dbFieldName));//字段
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
map.put("db_field_txt", onlCgformField.getDbFieldTxt());//字段中文名
|
||||
}else{
|
||||
@@ -198,4 +210,60 @@ public class OcrRecordEOServiceImpl extends ServiceImpl<OcrRecordEOMapper, OcrRe
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dataProcessing(String cut, List<OcrRecordEO> ocrRecordEOList) {
|
||||
// 查询文档拆分表中类型是下拉选的字段
|
||||
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.OCR_RECORD.getValue());
|
||||
if (fieldList.size() != 0) {
|
||||
//过滤列表字段(is_show_list-->列表是否显示0否 1是 且 有数据字典编码)
|
||||
fieldList = fieldList.stream()
|
||||
.filter(e -> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowList()))
|
||||
&& StringUtils.isNotBlank(e.getDictField()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// 根据切换语言 查询下拉选字段的下拉值
|
||||
List<SysDictItem> dictItemListAll = new ArrayList<>();
|
||||
for (OnlCgformField onlCgformField : fieldList) {
|
||||
// 查询数据字典值
|
||||
List<SysDictItem> dictItemList = sysDictItemService.selectItemsByDictCode(onlCgformField.getDictField());
|
||||
if(CollectionUtil.isNotEmpty(dictItemList)) {
|
||||
dictItemListAll.addAll(dictItemList);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理数据中所有下拉字典值
|
||||
for (OcrRecordEO ocrRecordEO : ocrRecordEOList){
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
Map<String, String> cnMap = dictItemListAll.stream()
|
||||
.filter(e->e.getItemValue().equals(ocrRecordEO.getFileType())
|
||||
|| e.getItemValue().equals(ocrRecordEO.getResultContent())
|
||||
|| e.getItemValue().equals(ocrRecordEO.getSyncState()))
|
||||
.collect(Collectors.toMap(SysDictItem::getItemValue, SysDictItem::getItemText));
|
||||
ocrRecordEO.setFileType(cnMap.get(ocrRecordEO.getFileType()));
|
||||
ocrRecordEO.setResultContent(cnMap.get(ocrRecordEO.getResultContent()));
|
||||
ocrRecordEO.setSyncState(cnMap.get(ocrRecordEO.getSyncState()));
|
||||
} else {
|
||||
Map<String, String> enMap = dictItemListAll.stream()
|
||||
.filter(e->e.getItemValue().equals(ocrRecordEO.getFileType())
|
||||
|| e.getItemValue().equals(ocrRecordEO.getResultContent())
|
||||
|| e.getItemValue().equals(ocrRecordEO.getSyncState()))
|
||||
.collect(Collectors.toMap(SysDictItem::getItemValue, SysDictItem::getEnName));
|
||||
ocrRecordEO.setFileType(enMap.get(ocrRecordEO.getFileType()));
|
||||
ocrRecordEO.setResultContent(enMap.get(ocrRecordEO.getResultContent()));
|
||||
ocrRecordEO.setSyncState(enMap.get(ocrRecordEO.getSyncState()));
|
||||
}
|
||||
if(StringUtils.isNotEmpty(ocrRecordEO.getConnectId())) {
|
||||
ocrRecordEO.setFileSource(FileSourceEnum.IMPORT.getValue());
|
||||
}else{
|
||||
ocrRecordEO.setFileSource(FileSourceEnum.UPLOAD.getValue());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(ocrRecordEO.getDocRealName())) {
|
||||
ocrRecordEO.setDocRealFile(ocrDownPath + ocrRecordEO.getDocRealName());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(ocrRecordEO.getJsonRealName())) {
|
||||
ocrRecordEO.setJsonRealFile(ocrDownPath + ocrRecordEO.getJsonRealName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user