1、新增百度OCR
2、新增应收应付
This commit is contained in:
+21
-20
@@ -11,6 +11,7 @@ import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.log.annotation.ApiLog;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.FR;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.file.listener.FileEvent;
|
||||
@@ -57,29 +58,29 @@ public class FileController extends BladeController {
|
||||
@ApiLog("附件管理-批量上传")
|
||||
@Operation(summary = "OBS批量上传", description = "OBS批量上传,参数名:files")
|
||||
@PostMapping("/ossUpload")
|
||||
public R ossUpload(MultipartFile[] files, @RequestParam(value = "fileName", required = false) String fileName) {
|
||||
public FR ossUpload(MultipartFile[] files, @RequestParam(value = "fileName", required = false) String fileName) {
|
||||
return attachmentService.batchOssUpload(files, fileName);
|
||||
}
|
||||
|
||||
@Operation(summary = "上传", description = "上传,参数名:file")
|
||||
@PostMapping("/upload")
|
||||
public R upload(MultipartFile file) {
|
||||
public FR upload(MultipartFile file) {
|
||||
MultipartFile[] files = {file};
|
||||
R<List<Attachment>> result = attachmentService.batchOssUpload(files, null);
|
||||
List<Attachment> data = result.getData();
|
||||
if(data != null && !data.isEmpty())return R.data(data.get(0));
|
||||
return R.fail("上传失败");
|
||||
if(data != null && !data.isEmpty())return FR.data(data.get(0));
|
||||
return FR.fail("上传失败");
|
||||
}
|
||||
|
||||
@Operation(summary = "获取附件,多个附件id用逗号分割", description = "获取附件,多个附件id用逗号分割")
|
||||
@GetMapping("/getAttachment")
|
||||
public R getAttachment(@RequestParam(value = "id") String id) {
|
||||
return R.data(attachmentService.getAttachment(id));
|
||||
public FR getAttachment(@RequestParam(value = "id") String id) {
|
||||
return FR.data(attachmentService.getAttachment(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取文件url", description = "获取文件url,参数:objectKey")
|
||||
@GetMapping("/getFileUrl")
|
||||
public R getFileUrl(@RequestParam(value = "objectKey") String objectKey, @RequestParam(value = "attachmentName", required = false) String attachmentName) {
|
||||
public FR getFileUrl(@RequestParam(value = "objectKey") String objectKey, @RequestParam(value = "attachmentName", required = false) String attachmentName) {
|
||||
if (StringUtil.isBlank(attachmentName)) {
|
||||
// 附件名为空,查询附件名
|
||||
Attachment attachment = attachmentService.getOne(Wrappers.<Attachment>lambdaQuery()
|
||||
@@ -94,7 +95,7 @@ public class FileController extends BladeController {
|
||||
attachmentName = attachmentName.replaceAll(",", "_");
|
||||
}
|
||||
}
|
||||
return R.data(fileService.getFileUrl(objectKey, attachmentName, null));
|
||||
return FR.data(fileService.getFileUrl(objectKey, attachmentName, null));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,9 +105,9 @@ public class FileController extends BladeController {
|
||||
*/
|
||||
@Operation(summary = "获取wps文件预览url", description = "获取wps文件预览url")
|
||||
@GetMapping("/getWpsFilePreviewUrl")
|
||||
public R getWpsFilePreviewUrl(@NotNull(message = "附件id不能为空") @RequestParam(value = "attachmentId", required = false) String attachmentId,
|
||||
public FR getWpsFilePreviewUrl(@NotNull(message = "附件id不能为空") @RequestParam(value = "attachmentId", required = false) String attachmentId,
|
||||
@NotBlank(message = "附件名称不能为空") @RequestParam(value = "attachmentName", required = false) String attachmentName) {
|
||||
return R.data(wpsService.getFilePreviewUrl(attachmentId, attachmentName));
|
||||
return FR.data(wpsService.getFilePreviewUrl(attachmentId, attachmentName));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,41 +118,41 @@ public class FileController extends BladeController {
|
||||
*/
|
||||
@Operation(summary = "获取wps文件编辑url", description = "获取wps文件编辑url")
|
||||
@GetMapping("/getWpsFileEditUrl")
|
||||
public R getWpsFileEditUrl(@NotNull(message = "附件id不能为空") @RequestParam(value = "attachmentId", required = false) String attachmentId,
|
||||
public FR getWpsFileEditUrl(@NotNull(message = "附件id不能为空") @RequestParam(value = "attachmentId", required = false) String attachmentId,
|
||||
@NotBlank(message = "附件名称不能为空") @RequestParam(value = "attachmentName", required = false) String attachmentName) {
|
||||
return R.data(wpsService.getWpsFileEditUrl(attachmentId, attachmentName));
|
||||
return FR.data(wpsService.getWpsFileEditUrl(attachmentId, attachmentName));
|
||||
}
|
||||
|
||||
@Operation(summary = "批量获取文件url", description = "批量获取文件url,参数:objectKey数组")
|
||||
@PostMapping("/getFileUrls")
|
||||
public R getFileUrls(@RequestBody List<String> objectKeys) {
|
||||
return R.data(fileService.getFileUrls(objectKeys, null));
|
||||
public FR getFileUrls(@RequestBody List<String> objectKeys) {
|
||||
return FR.data(fileService.getFileUrls(objectKeys, null));
|
||||
}
|
||||
|
||||
@ApiLog("OCR识别-识别身份证")
|
||||
@Operation(summary = "识别身份证信息支持正反面", description = "参数:url")
|
||||
@GetMapping("/recognitionIDCard")
|
||||
public R recognitionIDCard(@RequestParam(value = "url", required = false) String url,
|
||||
@RequestParam(value = "objectKey", required = false) String objectKey) {
|
||||
public FR recognitionIDCard(@RequestParam(value = "url", required = false) String url,
|
||||
@RequestParam(value = "objectKey", required = false) String objectKey) {
|
||||
String imageUrl = StringUtil.isNotBlank(url) ? url : objectKey;
|
||||
if (StringUtil.isBlank(imageUrl)) {
|
||||
return R.fail("图片地址不能为空");
|
||||
return FR.fail("图片地址不能为空");
|
||||
}
|
||||
if (!imageUrl.startsWith("http://") && !imageUrl.startsWith("https://")) {
|
||||
imageUrl = fileService.getFileUrl(imageUrl, null);
|
||||
}
|
||||
return R.data(ocrService.recognitionIDCard(List.of(imageUrl)));
|
||||
return FR.data(ocrService.recognitionIDCard(List.of(imageUrl)));
|
||||
}
|
||||
|
||||
@SentinelResource("ocr:batchCards")
|
||||
@ApiLog("OCR识别-识别车辆运输凭证(不知道类型)")
|
||||
@Operation(summary = "识别车辆运输凭证,不知道类型", description = "参数:objectKeylist")
|
||||
@PostMapping("/recognitionTransportCertificates")
|
||||
public R<TransportCertificateVO> recognitionTransportCertificates(
|
||||
public FR<TransportCertificateVO> recognitionTransportCertificates(
|
||||
@RequestBody List<Object> attachments,
|
||||
@RequestParam(value = "projectAbbreviation", required = false) String projectAbbreviation,
|
||||
@RequestParam(value = "code", required = false) String code) {
|
||||
return R.data(ocrConvertService.recognitionTransportCertificate(
|
||||
return FR.data(ocrConvertService.recognitionTransportCertificate(
|
||||
buildCertificateBatchRecognitionDTO(attachments, projectAbbreviation, code)
|
||||
));
|
||||
}
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@
|
||||
package org.springblade.file.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springblade.core.tool.api.FR;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.file.pojo.entity.Attachment;
|
||||
import org.springblade.file.pojo.vo.AttachmentDetailVO;
|
||||
@@ -49,7 +50,7 @@ public interface IAttachmentService extends IService<Attachment> {
|
||||
* @param fileName 文件名,如果 files只有1个,且fileName不为空,设置文件名为 fileName
|
||||
* @return
|
||||
*/
|
||||
R<List<Attachment>> batchOssUpload(MultipartFile[] files, String fileName);
|
||||
FR<List<Attachment>> batchOssUpload(MultipartFile[] files, String fileName);
|
||||
|
||||
/**
|
||||
* 获取附件,多个附件id用逗号分割
|
||||
|
||||
+4
-3
@@ -32,6 +32,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.tool.api.FR;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.CollectionUtil;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
@@ -78,7 +79,7 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
|
||||
private IAttachmentService self;
|
||||
|
||||
@Override
|
||||
public R<List<Attachment>> batchOssUpload(MultipartFile[] files, String overWriteFileName){
|
||||
public FR<List<Attachment>> batchOssUpload(MultipartFile[] files, String overWriteFileName){
|
||||
try {
|
||||
List<Attachment> attachmentList = new ArrayList<>();
|
||||
// 文件数量为1个,且重写的文件名不为空,使用重写的文件名,给uniapp上传使用,uniapp上传的文件名不是原始文件名
|
||||
@@ -98,11 +99,11 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
|
||||
}
|
||||
this.saveBatch(attachmentList);
|
||||
log.info("OBS上传 successfully");
|
||||
return R.data(attachmentList,"OBS上传 successfully");
|
||||
return FR.data(attachmentList,"OBS上传 successfully");
|
||||
} catch (Exception e) {
|
||||
log.error("OBS上传 failed,Exception", e);
|
||||
}
|
||||
return R.fail("OBS上传 failed");
|
||||
return FR.fail("OBS上传 failed");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user