Merge remote-tracking branch 'origin/master'
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
package com.jero.common.constant.enums;
|
||||
|
||||
/**
|
||||
* 中英文切换标识
|
||||
* @description
|
||||
* @date 2022/1/21 15:22
|
||||
* @auth zhn
|
||||
*/
|
||||
public enum IsMustEnum {
|
||||
YES("是","0"),
|
||||
NO("否","1");
|
||||
|
||||
|
||||
String name;
|
||||
String value;
|
||||
|
||||
private IsMustEnum(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;
|
||||
}
|
||||
}
|
||||
+22
-1
@@ -646,5 +646,26 @@ public class DateUtils extends PropertyEditorSupport {
|
||||
calendar.setTime(getDate());
|
||||
return calendar.get(Calendar.YEAR);
|
||||
}
|
||||
/***
|
||||
* @Description: 判断多个日期是否都符合日期格式
|
||||
* @Author: yangxuenan
|
||||
* @Date: 2020/12/31 11:31
|
||||
* @Param: [str]
|
||||
* @Return: boolean
|
||||
*/
|
||||
public static boolean isValidDate(String str){
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String[] strArr = str.split(",");
|
||||
for (String dateStr : strArr) {
|
||||
String replace = dateStr.replace("/", "-");
|
||||
try {
|
||||
simpleDateFormat.setLenient(false);
|
||||
simpleDateFormat.parse(replace);
|
||||
} catch (Exception e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -71,6 +71,7 @@ public class ShiroConfig {
|
||||
}
|
||||
// 配置不会被拦截的链接 顺序判断
|
||||
filterChainDefinitionMap.put("/sys/cas/client/validateLogin", "anon"); //cas验证登录
|
||||
filterChainDefinitionMap.put("/ocr/OcrRestful/ocrHandleResult", "anon"); //ocr回调接口
|
||||
filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/sys/getRSAPublicKey", "anon"); //获取RSA公钥接口排除
|
||||
|
||||
+4
-64
@@ -1,6 +1,8 @@
|
||||
package com.jero.modules.system.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -9,6 +11,7 @@ import java.io.Serializable;
|
||||
* <b>日期:</b> 2019-03-25 <br>
|
||||
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
|
||||
*/
|
||||
@Data
|
||||
public class OcrVO implements Serializable{
|
||||
private String restHandleFileUrl;
|
||||
private String OcrUserId;
|
||||
@@ -18,68 +21,5 @@ public class OcrVO implements Serializable{
|
||||
private String fileContent;
|
||||
private String taskId;
|
||||
private String RestCallBackUrl;
|
||||
|
||||
public String getRestHandleFileUrl() {
|
||||
return restHandleFileUrl;
|
||||
}
|
||||
|
||||
public void setRestHandleFileUrl(String restHandleFileUrl) {
|
||||
this.restHandleFileUrl = restHandleFileUrl;
|
||||
}
|
||||
|
||||
public String getOcrUserId() {
|
||||
return OcrUserId;
|
||||
}
|
||||
|
||||
public void setOcrUserId(String ocrUserId) {
|
||||
OcrUserId = ocrUserId;
|
||||
}
|
||||
|
||||
public String getAuthCode() {
|
||||
return authCode;
|
||||
}
|
||||
|
||||
public void setAuthCode(String authCode) {
|
||||
this.authCode = authCode;
|
||||
}
|
||||
|
||||
public String getConvertType() {
|
||||
return convertType;
|
||||
}
|
||||
|
||||
public void setConvertType(String convertType) {
|
||||
this.convertType = convertType;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getFileContent() {
|
||||
return fileContent;
|
||||
}
|
||||
|
||||
public void setFileContent(String fileContent) {
|
||||
this.fileContent = fileContent;
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getRestCallBackUrl() {
|
||||
return RestCallBackUrl;
|
||||
}
|
||||
|
||||
public void setRestCallBackUrl(String restCallBackUrl) {
|
||||
RestCallBackUrl = restCallBackUrl;
|
||||
}
|
||||
private Boolean isThird; //调用方:单纯获取识别的返回结果
|
||||
}
|
||||
|
||||
+2
-10
@@ -413,16 +413,8 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
|
||||
@ApiOperation(value = "导入.zip")
|
||||
@PostMapping(value = "/importZip")
|
||||
public Result<?> importZip(@RequestParam(value = "file", required = false) MultipartFile file) throws Exception {
|
||||
//验证文件名是否合格
|
||||
//截取后缀名
|
||||
int pos = file.getOriginalFilename().lastIndexOf(".");
|
||||
String str = file.getOriginalFilename().substring(pos+1).toLowerCase();
|
||||
String filenameorg = file.getOriginalFilename().substring(0,pos);
|
||||
//判断上传文件必须是zip
|
||||
if (!str.equals("zip")) {
|
||||
return Result.error("请上传zip文件");
|
||||
}
|
||||
return Result.OK("导入成功");
|
||||
String result = bussDocumentLibraryEOService.importZip(file);
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "推送")
|
||||
|
||||
+3
@@ -78,4 +78,7 @@ public interface BussDocumentLibraryEOMapper extends BaseMapper<BussDocumentLibr
|
||||
List<Map<String, Object>> getInfoListByReplaceStandard(@Param("replaceStandard") String replaceStandard);
|
||||
|
||||
|
||||
List<Map<String,Object>> getListBySerialNumber(@Param("serialNumbers") String serialNumbers);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+11
@@ -70,5 +70,16 @@
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<!--根据编码列表查询-->
|
||||
<select id="getListBySerialNumber" resultType="java.util.LinkedHashMap">
|
||||
select * from buss_document_library
|
||||
where 1=1
|
||||
<if test="serialNumbers != null" >
|
||||
and serial_number in
|
||||
<foreach collection="serialNumbers.split(',')" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
+141
-125
@@ -3,7 +3,7 @@ package com.jero.modules.document.service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -13,164 +13,180 @@ import java.util.Map;
|
||||
/**
|
||||
* @Description: 文档库信息表
|
||||
* @Author: jero-boot
|
||||
* @Date: 2022-01-21
|
||||
* @Date: 2022-01-21
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IBussDocumentLibraryEOService extends IService<BussDocumentLibraryEO> {
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
void deleteById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
void deleteByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
BussDocumentLibraryEO queryById(String id);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<BussDocumentLibraryEO> queryList();
|
||||
|
||||
/**
|
||||
* 查询条件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> queryCondition(String flag,String cut);
|
||||
* 查询条件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> queryCondition(String flag, String cut);
|
||||
|
||||
/**
|
||||
* 列表表头
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> getHeader(String flag,String cut);
|
||||
* 列表表头
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getHeader(String flag, String cut);
|
||||
|
||||
/**
|
||||
* 新增表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> getAddForm(String flag,String cut,String type);
|
||||
* 新增表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getAddForm(String flag, String cut, String type);
|
||||
|
||||
/**
|
||||
* 编辑数据查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> getDocumentInfoById(String id,String cut);
|
||||
/**
|
||||
* 编辑数据查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getDocumentInfoById(String id, String cut);
|
||||
|
||||
/**
|
||||
* 详情数据查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> getInfoById(String id,String cut);
|
||||
/**
|
||||
* 详情数据查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getInfoById(String id, String cut);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
* @param map
|
||||
*/
|
||||
void addInfo(Map<String,Object> map);
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
void addInfo(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
* @param map
|
||||
*/
|
||||
void updateInfo(Map<String,Object> map);
|
||||
/**
|
||||
* 编辑数据
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
void updateInfo(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
IPage getInfoPage(Map<String,Object> parameter);
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
IPage getInfoPage(Map<String, Object> parameter);
|
||||
|
||||
/**
|
||||
* 代替标准分页
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
IPage replacePageInfo(Map<String,Object> parameter);
|
||||
/**
|
||||
* 代替标准分页
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
IPage replacePageInfo(Map<String, Object> parameter);
|
||||
|
||||
/**
|
||||
* ocr识别调取已入库文件分页
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
IPage ocrPageInfo(Map<String,Object> parameter);
|
||||
/**
|
||||
* ocr识别调取已入库文件分页
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
IPage ocrPageInfo(Map<String, Object> parameter);
|
||||
|
||||
/**
|
||||
* 添加收藏
|
||||
* @param id
|
||||
*/
|
||||
void addCollect(String id);
|
||||
/**
|
||||
* 添加收藏
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void addCollect(String id);
|
||||
|
||||
/**
|
||||
* 取消收藏
|
||||
* @param id
|
||||
*/
|
||||
void cancelCollect(String id);
|
||||
/**
|
||||
* 取消收藏
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void cancelCollect(String id);
|
||||
|
||||
/**
|
||||
* 添加订阅
|
||||
* @param id
|
||||
*/
|
||||
void addSubscribe(String id);
|
||||
/**
|
||||
* 添加订阅
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void addSubscribe(String id);
|
||||
|
||||
/**
|
||||
* 取消订阅
|
||||
* @param id
|
||||
*/
|
||||
void cancelSubscribe(String id);
|
||||
/**
|
||||
* 取消订阅
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void cancelSubscribe(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
* @param map
|
||||
* @param response
|
||||
* @param request
|
||||
*/
|
||||
void exportExcel(Map<String,Object> map,
|
||||
HttpServletResponse response,
|
||||
HttpServletRequest request);
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param map
|
||||
* @param response
|
||||
* @param request
|
||||
*/
|
||||
void exportExcel(Map<String, Object> map,
|
||||
HttpServletResponse response,
|
||||
HttpServletRequest request);
|
||||
|
||||
void exportZip(Map<String,Object> map,
|
||||
HttpServletResponse response,
|
||||
HttpServletRequest request);
|
||||
void exportZip(Map<String, Object> map,
|
||||
HttpServletResponse response,
|
||||
HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 模板下载
|
||||
* @param response
|
||||
* @param request
|
||||
*/
|
||||
void exportTemplate(Map<String,Object> map,HttpServletResponse response, HttpServletRequest request);
|
||||
/**
|
||||
* 模板下载
|
||||
*
|
||||
* @param response
|
||||
* @param request
|
||||
*/
|
||||
void exportTemplate(Map<String, Object> map, HttpServletResponse response, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* ocr识别调取已入库文件-中英文切换
|
||||
* @param flag
|
||||
* @param cut
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getHeaderOrConditionForOcr(String flag, String cut);
|
||||
/**
|
||||
* ocr识别调取已入库文件-中英文切换
|
||||
*
|
||||
* @param flag
|
||||
* @param cut
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getHeaderOrConditionForOcr(String flag, String cut);
|
||||
|
||||
String pullMessage(String departIds,String ids,String documentIds);
|
||||
String pullMessage(String departIds, String ids, String documentIds);
|
||||
|
||||
String importZip(MultipartFile file);
|
||||
|
||||
}
|
||||
|
||||
+582
-125
File diff suppressed because it is too large
Load Diff
+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.aspect.annotation.AutoLog;
|
||||
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.ocr.entity.OcrRecordEO;
|
||||
import com.jero.modules.ocr.enums.FileSourceEnum;
|
||||
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.service.IOcrRecordEOService;
|
||||
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.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);
|
||||
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());
|
||||
}
|
||||
@@ -86,97 +92,29 @@ public class OcrRecordEOController extends JeroController<OcrRecordEO, IOcrRecor
|
||||
@ApiOperation(value="OCR识别转换记录表-同步至文档库", notes="OCR识别转换记录表-同步至文档库")
|
||||
@PostMapping(value = "/syncToDocument")
|
||||
public Result<?> syncToDocument(@RequestBody OcrRecordEO ocrRecordEO) {
|
||||
if(StringUtils.isBlank(ocrRecordEO.getAttId())){
|
||||
return Result.error("没有可同步的文档");
|
||||
if(StringUtils.isBlank(ocrRecordEO.getConnectId())){
|
||||
return Result.error("同步失败");
|
||||
}
|
||||
if (StringUtils.isBlank(ocrRecordEO.getStandName())
|
||||
|| StringUtils.isBlank(ocrRecordEO.getStandNumber())){
|
||||
return Result.error("参数不能为空");
|
||||
//查询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("没有可同步的文件");
|
||||
}
|
||||
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)){
|
||||
//查询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);
|
||||
OSSFile ossFile = new OSSFile();
|
||||
String docFileId = ossFiles.get(0).getId();
|
||||
ossFile.setId(docFileId);
|
||||
ossFile.setConnectId(ocrRecordEO.getConnectId());
|
||||
ossFileService.updateById(ossFile);
|
||||
|
||||
} 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);
|
||||
//修改记录表的同步情况
|
||||
OcrRecordEO updateOcrRecordEO = new OcrRecordEO();
|
||||
updateOcrRecordEO.setId(ocrRecordEO.getId());
|
||||
updateOcrRecordEO.setSyncState(FileSyncStateEnum.SYNC_YES.getValue());
|
||||
ocrRecordService.editById(updateOcrRecordEO);
|
||||
|
||||
} 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 = 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("没有可同步的文档");
|
||||
}
|
||||
return Result.OK("同步成功", ossFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+48
-16
@@ -1,11 +1,10 @@
|
||||
package com.jero.modules.ocr.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.ocr.entity.OcrCallBackResultEO;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.ocr.entity.OcrRecordEO;
|
||||
import com.jero.modules.ocr.enums.ResultContentEnum;
|
||||
import com.jero.modules.ocr.service.IOcrRecordEOService;
|
||||
import com.jero.modules.ocr.service.IOcrRestfulService;
|
||||
import com.jero.modules.ocr.util.MD5Util;
|
||||
@@ -14,6 +13,7 @@ import com.jero.modules.oss.service.IOSSFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,11 +22,11 @@ import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: OcrDemo
|
||||
@@ -56,9 +56,37 @@ public class OcrRestfulController{
|
||||
@Value("${OCR.ocrDownPath}")
|
||||
private String ocrDownPath;
|
||||
|
||||
@Value("${OCR.ocrPath}")
|
||||
private String ocrPath;
|
||||
|
||||
@Value("${jero.path.upload}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
@ApiOperation(value = "下载word文件")
|
||||
@GetMapping("/downFile")
|
||||
public void downFile(String fileName, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
response.reset();
|
||||
try {
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||
response.setContentType("application/octet-stream");
|
||||
|
||||
String fullPath = ocrPath + fileName;
|
||||
is = new FileInputStream(fullPath);
|
||||
os = response.getOutputStream();
|
||||
IOUtils.copy(is, os);
|
||||
os.flush();
|
||||
} catch (FileNotFoundException var4) {
|
||||
throw new JeroBootException("文件[" + ocrPath + fileName + "]不存在");
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
is.close();
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试OCR
|
||||
* @param file
|
||||
@@ -77,34 +105,38 @@ public class OcrRestfulController{
|
||||
* OCR回调
|
||||
* @param wordFile
|
||||
* @param jsonFile
|
||||
* @param ocrCallBackResultEo
|
||||
* @param taskId
|
||||
* @param result
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "OCR回调")
|
||||
@PostMapping("/OcrHandleResult")
|
||||
public String OcrHandleResult(@RequestParam("wordFile") MultipartFile wordFile,@RequestParam("jsonFile") MultipartFile jsonFile, OcrCallBackResultEO ocrCallBackResultEo) {
|
||||
@PostMapping("/ocrHandleResult")
|
||||
public String ocrHandleResult(@RequestParam("wordFile") MultipartFile wordFile,
|
||||
@RequestParam("jsonFile") MultipartFile jsonFile,
|
||||
@RequestParam("taskId") String taskId,
|
||||
@RequestParam("result") String result,
|
||||
@RequestParam("key") String key) {
|
||||
try{
|
||||
log.info("调取到我了");
|
||||
log.info("接口回调结果:"+ JSON.toJSONString(ocrCallBackResultEo));
|
||||
log.info("接口回调时所传文件---wordFile:"+ wordFile.toString() +"; jsonFile:"+jsonFile.toString());
|
||||
if("error".equals(ocrCallBackResultEo.getResult())){
|
||||
if("error".equals(result)){
|
||||
log.info("客户接口处理文件失败");
|
||||
ocrRestfulService.updateDb(ocrCallBackResultEo.getTaskID(),"客户接口处理文件失败");
|
||||
ocrRestfulService.updateDb(taskId,"客户接口处理文件失败");
|
||||
return "{\"result\":\"error\"}";
|
||||
}
|
||||
//1.验证 key 是否符合,不符合打回,符合继续
|
||||
//2.向后传递文件
|
||||
String key = ocrCallBackResultEo.getKey();
|
||||
String sign = ocrCallBackResultEo.getTaskID() + OcrPublicKey;
|
||||
String sign = taskId + OcrPublicKey;
|
||||
String signMD5 = MD5Util.string2MD5(sign);
|
||||
// String encpySign =MD5Util.convertMD5(signMD5);
|
||||
if(!signMD5.equals(key)){
|
||||
//不同,则认证失败
|
||||
log.info("认证失败");
|
||||
ocrRestfulService.updateDb(ocrCallBackResultEo.getTaskID(),"回调接口认证失败");
|
||||
ocrRestfulService.updateDb(taskId, ResultContentEnum.OCR_CONVERT_FAIL.getValue());
|
||||
return "{\"result\":\"Authentication failed\"}";
|
||||
}
|
||||
return ocrRestfulService.OcrHandleResult(wordFile,jsonFile,ocrCallBackResultEo.getTaskID());
|
||||
return ocrRestfulService.ocrHandleResult(wordFile,jsonFile,taskId);
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
return "{\"result\":\"runTimeException\"}";
|
||||
|
||||
+11
-7
@@ -1,22 +1,20 @@
|
||||
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.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
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)
|
||||
@ApiModelProperty(value = "同步状态")
|
||||
private String syncState;
|
||||
|
||||
/**文档库关联文件id*/
|
||||
@ApiModelProperty(value = "文档库关联文件id")
|
||||
private String connectId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String docRealFile;
|
||||
@TableField(exist = false)
|
||||
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="att_id" property="attId" />
|
||||
<result column="sync_state" property="syncState" />
|
||||
<result column="connect_id" property="connectId" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.jero.modules.ocr.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.ocr.entity.OcrRecordEO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -13,7 +12,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
public interface IOcrRestfulService{
|
||||
Result<?> handleFile(MultipartFile file, String fileName, OcrRecordEO getOcrEO, String type) throws Exception;
|
||||
|
||||
String OcrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception;
|
||||
String ocrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception;
|
||||
|
||||
OcrRecordEO getOcrResult(String taskId, int i) throws Exception;
|
||||
|
||||
|
||||
+22
-6
@@ -10,6 +10,9 @@ import com.jero.modules.ocr.service.IOcrRecordEOService;
|
||||
import com.jero.modules.ocr.service.IOcrRestfulService;
|
||||
import com.jero.modules.ocr.util.Base64Util;
|
||||
import com.jero.modules.ocr.util.RsaUtil;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -52,6 +55,8 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
||||
|
||||
@Autowired
|
||||
private IOcrRecordEOService ocrRecordEOService;
|
||||
@Autowired
|
||||
private IOSSFileService ossFileService;
|
||||
|
||||
|
||||
//请求处理文件url
|
||||
@@ -86,7 +91,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
||||
public Result<?> handleFile(MultipartFile file, String fileName, OcrRecordEO getOcrEO, String type) throws Exception {
|
||||
String taskId = "";
|
||||
if ("add".equals(type)) {
|
||||
taskId = UUID.randomUUID().toString().replace("-", "");
|
||||
taskId = UUIDUtils.randomUUID20();
|
||||
} else {
|
||||
taskId = getOcrEO.getId();
|
||||
}
|
||||
@@ -126,6 +131,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
||||
ocrVO.setFileContent(fileContent);
|
||||
ocrVO.setTaskId(taskId);
|
||||
ocrVO.setRestCallBackUrl(RestCallBackUrl);
|
||||
ocrVO.setIsThird(true);
|
||||
ResponseEntity<String> responseEntity = localToolFeignClient.getFile(ocrVO);
|
||||
|
||||
log.info("请求OCR接口完毕,返回响应状态:【"+sdf.format(new Date())+"】");
|
||||
@@ -145,6 +151,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
||||
ocrRecordEO.setStandNumber(getOcrEO.getStandNumber());
|
||||
ocrRecordEO.setStandName(getOcrEO.getStandName());
|
||||
ocrRecordEO.setFileType(getOcrEO.getFileType());
|
||||
ocrRecordEO.setConnectId(getOcrEO.getConnectId());
|
||||
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// ocrRecordEO.setCreateBy(sysUser.getId());
|
||||
// ocrRecordEO.setCreateTime(new Date());
|
||||
@@ -160,6 +167,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
||||
ocrRecordEO.setStandName(getOcrEO.getStandName());
|
||||
ocrRecordEO.setFileType(getOcrEO.getFileType());
|
||||
ocrRecordEO.setCreateTime(new Date());
|
||||
ocrRecordEO.setConnectId(getOcrEO.getConnectId());
|
||||
ocrRecordEOService.editById(ocrRecordEO); //TODO ??
|
||||
return Result.OK( "加入转换成功", taskId);
|
||||
}
|
||||
@@ -173,19 +181,19 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
||||
}
|
||||
}
|
||||
|
||||
public String OcrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception {
|
||||
public String ocrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception {
|
||||
//首先将文件保存至本地
|
||||
String saveWordFilePath=null;
|
||||
String saveWordFileName=null;
|
||||
if(wordFile!=null && !wordFile.isEmpty()){
|
||||
saveWordFileName= UUID.randomUUID().toString().replace("-", "") + "_"+wordFile.getOriginalFilename();
|
||||
saveWordFileName= UUIDUtils.randomUUID20() + "_"+wordFile.getOriginalFilename();
|
||||
saveWordFilePath=ocrFilePath+saveWordFileName;
|
||||
FileUtils.copyInputStreamToFile(wordFile.getInputStream(),new File(saveWordFilePath));
|
||||
}
|
||||
String saveJsonFilePath=null;
|
||||
String saveJsonFileName=null;
|
||||
if(jsonFile!=null && !jsonFile.isEmpty()){
|
||||
saveJsonFileName=UUID.randomUUID().toString().replace("-", "") + "_"+jsonFile.getOriginalFilename();
|
||||
saveJsonFileName=UUIDUtils.randomUUID20() + "_"+jsonFile.getOriginalFilename();
|
||||
saveJsonFilePath=ocrFilePath+saveJsonFileName;
|
||||
FileUtils.copyInputStreamToFile(jsonFile.getInputStream(),new File(saveJsonFilePath));
|
||||
}
|
||||
@@ -201,7 +209,15 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
||||
ocrRecordEO.setJsonFileCode(null);
|
||||
ocrRecordEO.setUpdateTime(new Date());
|
||||
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\"}";
|
||||
}else{
|
||||
updateDb(taskId,"error:File does not exist");
|
||||
@@ -236,7 +252,7 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService {
|
||||
ocrRecordEO.setId(taskId);
|
||||
ocrRecordEO.setUpdateTime(new Date());
|
||||
ocrRecordEO.setResultContent(result);
|
||||
ocrRecordEOService.editById(ocrRecordEO);
|
||||
ocrRecordEOService.updateById(ocrRecordEO);
|
||||
}
|
||||
|
||||
public boolean checkFileName(String fileName){
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.jero.modules.ocr.util;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @Author: liyawei
|
||||
* @Description:
|
||||
* @Date: Created in 0:09 2022/3/8
|
||||
*/
|
||||
public class RandomUtils extends org.apache.commons.lang3.RandomUtils {
|
||||
private static final char[] codeSeq = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||
private static final char[] numberArray = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||
private static Random random = new Random();
|
||||
|
||||
public RandomUtils() {
|
||||
}
|
||||
|
||||
public static final String randomString(int length) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(int i = 0; i < length; ++i) {
|
||||
sb.append(String.valueOf(codeSeq[random.nextInt(codeSeq.length)]));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static final String randomNumberString(int length) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(int i = 0; i < length; ++i) {
|
||||
sb.append(String.valueOf(numberArray[random.nextInt(numberArray.length)]));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static Color randomColor(int fc, int bc) {
|
||||
int f = fc;
|
||||
int b = bc;
|
||||
Random random = new Random();
|
||||
if (fc > 255) {
|
||||
f = 255;
|
||||
}
|
||||
|
||||
if (bc > 255) {
|
||||
b = 255;
|
||||
}
|
||||
|
||||
return new Color(f + random.nextInt(b - f), f + random.nextInt(b - f), f + random.nextInt(b - f));
|
||||
}
|
||||
|
||||
public static int nextInt(int bound) {
|
||||
return random.nextInt(bound);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.jero.modules.ocr.util;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class UUIDUtils {
|
||||
|
||||
public static String randomUUID10() {
|
||||
return RandomUtils.randomString(10);
|
||||
}
|
||||
|
||||
public static String randomUUID20() {
|
||||
return RandomUtils.randomString(20);
|
||||
}
|
||||
|
||||
public static String randomUUID(int length) {
|
||||
return RandomUtils.randomString(length);
|
||||
}
|
||||
|
||||
public static String getUUIDPath(String uuid){
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append("/");
|
||||
builder.append((uuid.substring(0, 3).hashCode())%100+"").append("/");
|
||||
builder.append((uuid.substring(7,10).hashCode())%100+"").append("/");
|
||||
builder.append((uuid.substring(11,14).hashCode())%100+"").append("/");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String getAttTable(){
|
||||
Random rand = new Random();
|
||||
int nextInt = rand.nextInt(10)+1;
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append("ATT_FILE_").append(String.format("%02d", nextInt));
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+50
-3
@@ -113,21 +113,51 @@ public class FileUnZip {
|
||||
* @param filename
|
||||
*/
|
||||
public static List<File> readFileByFilename(String path,String filename) {
|
||||
if(filename.contains("/")){
|
||||
filename = filename.split("/")[1];
|
||||
}
|
||||
List<File> resultlist = new ArrayList<>();
|
||||
if (StringUtil.isNotEmpty(path)){
|
||||
File file = new File(path);
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
for (File fi : files) {
|
||||
// 对文件进行过滤
|
||||
if (fi.getName().equals(filename)) {
|
||||
resultlist.add(fi);
|
||||
if(fi.isDirectory()){
|
||||
File[] filesTemp = fi.listFiles();
|
||||
for (File fileTemp : filesTemp) {
|
||||
// 对文件进行过滤
|
||||
if (fileTemp.getName().equals(filename)) {
|
||||
resultlist.add(fileTemp);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// 对文件进行过滤
|
||||
if (fi.getName().equals(filename)) {
|
||||
resultlist.add(fi);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultlist;
|
||||
}
|
||||
// public static List<File> readFileByFilename(String path,String filename) {
|
||||
// List<File> resultlist = new ArrayList<>();
|
||||
// if (StringUtil.isNotEmpty(path)){
|
||||
// File file = new File(path);
|
||||
// if (file.isDirectory()) {
|
||||
// File[] files = file.listFiles();
|
||||
// for (File fi : files) {
|
||||
// // 对文件进行过滤
|
||||
// if (fi.getName().equals(filename)) {
|
||||
// resultlist.add(fi);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return resultlist;
|
||||
// }
|
||||
|
||||
/**
|
||||
*@Description: 删除某个文件
|
||||
@@ -152,4 +182,21 @@ public class FileUnZip {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<File> readImpExcelFile(String path) {
|
||||
File file = new File(path);
|
||||
List<File> resultlist = new ArrayList<>();
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
for (File fi : files) {
|
||||
// 对文件进行过滤,只读取Excel文件
|
||||
String name = fi.getName();
|
||||
// "导入模板".equals(fi.getName()) || "导入模板.xlsx".equals(fi.getName())
|
||||
if (name != null &&( fi.getName().contains(".xls") || fi.getName().contains(".xlsx") )){
|
||||
resultlist.add(fi);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultlist;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -299,11 +299,11 @@ justauth:
|
||||
# 云端OCR识别集成配置参数
|
||||
OCR:
|
||||
#请求OCR转换接口
|
||||
handleFileUrl: https://sws.trans-cosmos.com.cn/WebService.asmx/FileConversion
|
||||
#handleFileUrl = https://61.136.1.103:8091/WebService.asmx/FileConversion
|
||||
# handleFileUrl: https://sws.trans-cosmos.com.cn/WebService.asmx/FileConversion
|
||||
handleFileUrl: http://61.136.1.103:8091/WebService.asmx/FileConversion
|
||||
# OCR回调接口地址 配置客户本地的IP及端口号
|
||||
# callBackUrl: http://139.9.235.66:9110/api/ocr/OCRRestful/OcrHandleResult
|
||||
callBackUrl: http://127.0.0.1:8080/api/ocr/OCRRestful/OcrHandleResult
|
||||
# callBackUrl: http://139.9.235.66:9110//api/ocr/OCRRestful/OcrHandleResult
|
||||
callBackUrl: http://139.9.235.66:9022/local-tool/ocr/ocrHandleResult
|
||||
# OCR认证用户
|
||||
userId: dayuzhou1234
|
||||
# OCR认证编码
|
||||
@@ -320,11 +320,6 @@ OCR:
|
||||
times: 20
|
||||
# OCR转换类型
|
||||
convertType: BOTH
|
||||
## 这个IFeignService是加了@FeignClient注解的类
|
||||
local-tool:
|
||||
ribbon:
|
||||
## 服务提供者的地址,不是服务注册中心的地址
|
||||
listOfServers: http://139.9.235.66:9022
|
||||
|
||||
## 这个要有,如果不加,只加了上面也没用
|
||||
ribbon:
|
||||
|
||||
Reference in New Issue
Block a user