parent
39873804a3
commit
4901af59a8
|
|
@ -82,7 +82,7 @@ public class GeneratedInsFactory {
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
"",
|
"",
|
||||||
"downFile", SecurityConstants.INNER);
|
"wrkGen", SecurityConstants.INNER);
|
||||||
// 不为空时, 说明 上传成功
|
// 不为空时, 说明 上传成功
|
||||||
if (listResult.isSuccess() && CollectionUtil.isNotEmpty(listResult.getData())){
|
if (listResult.isSuccess() && CollectionUtil.isNotEmpty(listResult.getData())){
|
||||||
log.info("上传成功");
|
log.info("上传成功");
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板相关管理
|
* 模板相关管理
|
||||||
|
|
@ -90,8 +91,9 @@ public class TemplateController {
|
||||||
@SysLog(value = "模板", businessType = BusinessType.UPLOAD)
|
@SysLog(value = "模板", businessType = BusinessType.UPLOAD)
|
||||||
@PostMapping(value = "/upload")
|
@PostMapping(value = "/upload")
|
||||||
@RequiresPermissions(value = "ins:template:upload")
|
@RequiresPermissions(value = "ins:template:upload")
|
||||||
public AjaxResult uploadTemplate(@RequestParam MultipartFile file){
|
public AjaxResult uploadTemplate(@RequestPart(name = "file") MultipartFile file,
|
||||||
return AjaxResult.success(tbTemplateService.uploadFile(file));
|
@RequestParam String templateType) throws IOException {
|
||||||
|
return AjaxResult.success(tbTemplateService.uploadFile(file, templateType));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import com.chushang.inspection.project.po.Template;
|
||||||
import com.chushang.oss.entity.vo.FileSourceVo;
|
import com.chushang.oss.entity.vo.FileSourceVo;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @auther: zhao
|
* @auther: zhao
|
||||||
* @date: 2024/7/2 11:04
|
* @date: 2024/7/2 11:04
|
||||||
|
|
@ -27,5 +29,5 @@ public interface TbTemplateService extends IService<Template> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSourceVo uploadFile(MultipartFile file);
|
FileSourceVo uploadFile(MultipartFile file, String templateType) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import com.chushang.common.mybatis.utils.WrapperUtils;
|
||||||
import com.chushang.inspection.project.mapper.TemplateMapper;
|
import com.chushang.inspection.project.mapper.TemplateMapper;
|
||||||
import com.chushang.inspection.project.po.Template;
|
import com.chushang.inspection.project.po.Template;
|
||||||
import com.chushang.inspection.project.service.TbTemplateService;
|
import com.chushang.inspection.project.service.TbTemplateService;
|
||||||
import com.chushang.oss.entity.dto.UploadFileDTO;
|
import com.chushang.oss.entity.dto.UploadBytesDTO;
|
||||||
import com.chushang.oss.entity.vo.FileSourceVo;
|
import com.chushang.oss.entity.vo.FileSourceVo;
|
||||||
import com.chushang.oss.feign.RemoteOssService;
|
import com.chushang.oss.feign.RemoteOssService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,12 +73,15 @@ public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, Template> i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileSourceVo uploadFile(MultipartFile file) {
|
public FileSourceVo uploadFile(MultipartFile file, String templateType) throws IOException {
|
||||||
// 上传模板信息
|
// 上传模板信息
|
||||||
Result<List<FileSourceVo>> listResult =
|
Result<List<FileSourceVo>> listResult =
|
||||||
remoteOssService.uploadFile(UploadFileDTO.builder()
|
remoteOssService.uploadBytes(
|
||||||
.files(new MultipartFile[]{file})
|
UploadBytesDTO.builder()
|
||||||
.build(), null, false, null, "template", SecurityConstants.INNER);
|
.bytes(file.getBytes())
|
||||||
|
.build(),
|
||||||
|
file.getOriginalFilename(),
|
||||||
|
false, null, templateType, SecurityConstants.INNER);
|
||||||
if (listResult.isSuccess() && CollectionUtil.isNotEmpty(listResult.getData())){
|
if (listResult.isSuccess() && CollectionUtil.isNotEmpty(listResult.getData())){
|
||||||
FileSourceVo fileSourceVo = listResult.getData().get(0);
|
FileSourceVo fileSourceVo = listResult.getData().get(0);
|
||||||
Template template = new Template();
|
Template template = new Template();
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ public class WrkInfoPhoneServiceImpl extends ServiceImpl<WrkInfoPhoneMapper, Wrk
|
||||||
ExcelUtils.exportList(outputStream, WrkInfoPhoneImportDTO.class, errList,"电话工单导入异常");
|
ExcelUtils.exportList(outputStream, WrkInfoPhoneImportDTO.class, errList,"电话工单导入异常");
|
||||||
Result<List<FileSourceVo>> ossResult = remoteOssService.uploadBytes(
|
Result<List<FileSourceVo>> ossResult = remoteOssService.uploadBytes(
|
||||||
UploadBytesDTO.builder().bytes(outputStream.toByteArray()).build()
|
UploadBytesDTO.builder().bytes(outputStream.toByteArray()).build()
|
||||||
, "", null, null, "importFile", SecurityConstants.INNER);
|
, "", null, null, "phoneWrk", SecurityConstants.INNER);
|
||||||
if (ossResult.isSuccess() && CollectionUtil.isNotEmpty(ossResult.getData())){
|
if (ossResult.isSuccess() && CollectionUtil.isNotEmpty(ossResult.getData())){
|
||||||
List<FileSourceVo> data = ossResult.getData();
|
List<FileSourceVo> data = ossResult.getData();
|
||||||
FileSourceVo fileSourceVo = data.get(0);
|
FileSourceVo fileSourceVo = data.get(0);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.chushang.oss.entity;
|
package com.chushang.oss.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.chushang.common.dict.annotation.DictFormat;
|
||||||
|
import com.chushang.common.mybatis.annotation.Condition;
|
||||||
import com.chushang.common.mybatis.base.BaseEntity;
|
import com.chushang.common.mybatis.base.BaseEntity;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -34,6 +36,8 @@ public class FileSourceInfo extends BaseEntity{
|
||||||
* 查看字典 sys_file_type
|
* 查看字典 sys_file_type
|
||||||
*/
|
*/
|
||||||
@TableField("file_type")
|
@TableField("file_type")
|
||||||
|
@Condition(name = "file_type")
|
||||||
|
@DictFormat(dictType = "sys_file_type")
|
||||||
private String fileType;
|
private String fileType;
|
||||||
/**
|
/**
|
||||||
* 文件大小
|
* 文件大小
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,19 @@ import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @auther: zhao
|
* @auther: zhao
|
||||||
* @date: 2024/6/29 18:09
|
* @date: 2024/6/29 18:09
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
public class UploadFileDTO {
|
public class UploadFileDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private MultipartFile[] files;
|
private MultipartFile[] files;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import com.chushang.oss.entity.dto.UploadStreamDTO;
|
||||||
import com.chushang.oss.entity.vo.FileSourceVo;
|
import com.chushang.oss.entity.vo.FileSourceVo;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -20,7 +21,7 @@ import java.util.Set;
|
||||||
public interface RemoteOssService {
|
public interface RemoteOssService {
|
||||||
|
|
||||||
@PostMapping(value = "/upload")
|
@PostMapping(value = "/upload")
|
||||||
Result<List<FileSourceVo>> uploadFile(@RequestBody UploadFileDTO uploadFile,
|
Result<List<FileSourceVo>> uploadFile(@RequestPart(name = "files") MultipartFile[] files,
|
||||||
@RequestParam(value = "ocrType", required = false) String ocrType,
|
@RequestParam(value = "ocrType", required = false) String ocrType,
|
||||||
@RequestParam(value = "sealFlag", required = false, defaultValue= "false") Boolean sealFlag,
|
@RequestParam(value = "sealFlag", required = false, defaultValue= "false") Boolean sealFlag,
|
||||||
@RequestParam(value = "formats", required = false) String formats,
|
@RequestParam(value = "formats", required = false) String formats,
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,12 @@ public class RemoteFileController implements RemoteOssService {
|
||||||
@SysLog(value = "feign文件上传", businessType = BusinessType.INSERT)
|
@SysLog(value = "feign文件上传", businessType = BusinessType.INSERT)
|
||||||
@PostMapping(value = "/upload")
|
@PostMapping(value = "/upload")
|
||||||
@InnerAuth
|
@InnerAuth
|
||||||
public Result<List<FileSourceVo>> uploadFile(@RequestBody UploadFileDTO uploadFile,
|
public Result<List<FileSourceVo>> uploadFile(@RequestPart(name = "files") MultipartFile[] files,
|
||||||
@RequestParam(value = "ocrType", required = false) String ocrType,
|
@RequestParam(value = "ocrType", required = false) String ocrType,
|
||||||
@RequestParam(value = "sealFlag", required = false, defaultValue= "false") Boolean sealFlag,
|
@RequestParam(value = "sealFlag", required = false, defaultValue= "false") Boolean sealFlag,
|
||||||
@RequestParam(value = "formats", required = false) String formats,
|
@RequestParam(value = "formats", required = false) String formats,
|
||||||
@RequestHeader(SecurityConstants.FROM_SOURCE)String source,
|
@RequestHeader(SecurityConstants.FROM_SOURCE)String source,
|
||||||
@RequestParam(value = "fileType", required = false) String fileType) {
|
@RequestParam(value = "fileType", required = false) String fileType) {
|
||||||
MultipartFile[] files = uploadFile.getFiles();
|
|
||||||
return Result.ok(fileSourceService.addFile(files, ocrType, sealFlag, formats, fileType));
|
return Result.ok(fileSourceService.addFile(files, ocrType, sealFlag, formats, fileType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,7 +105,8 @@ public class RemoteFileController implements RemoteOssService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<List<FileSourceVo>> uploadStream(UploadStreamDTO uploadStream, String fileName, Boolean sealFlag, String formats, String fileType, String source)
|
@PostMapping(value = "/upload/stream")
|
||||||
|
public Result<List<FileSourceVo>> uploadStream(@RequestBody UploadStreamDTO uploadStream, String fileName, Boolean sealFlag, String formats, String fileType, String source)
|
||||||
{
|
{
|
||||||
InputStream is = uploadStream.getIs();
|
InputStream is = uploadStream.getIs();
|
||||||
return Result.ok(fileSourceService.uploadFile(is, fileName, sealFlag, formats, fileType));
|
return Result.ok(fileSourceService.uploadFile(is, fileName, sealFlag, formats, fileType));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue