|
|
@ -14,8 +14,10 @@ import com.logpm.factory.oupai.service.*; |
|
|
|
import com.logpm.factory.oupai.vo.OpOrderStatusLogVO; |
|
|
|
import com.logpm.factory.oupai.vo.OpOrderStatusLogVO; |
|
|
|
import com.logpm.factory.props.OuPaiProperties; |
|
|
|
import com.logpm.factory.props.OuPaiProperties; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import org.apache.commons.fileupload.FileItem; |
|
|
|
import org.apache.commons.fileupload.disk.DiskFileItem; |
|
|
|
import org.apache.commons.fileupload.disk.DiskFileItem; |
|
|
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
|
|
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
|
|
|
|
|
|
|
import org.apache.commons.io.IOUtils; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.springblade.common.constant.RabbitConstant; |
|
|
|
import org.springblade.common.constant.RabbitConstant; |
|
|
|
import org.springblade.common.exception.CustomerException; |
|
|
|
import org.springblade.common.exception.CustomerException; |
|
|
@ -27,11 +29,15 @@ import org.springblade.resource.feign.IOssClient; |
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile; |
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
import java.io.OutputStream; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
@ -616,9 +622,9 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { |
|
|
|
private String uploadFile(String body) { |
|
|
|
private String uploadFile(String body) { |
|
|
|
//文本内容和保存为本地文件 并上传
|
|
|
|
//文本内容和保存为本地文件 并上传
|
|
|
|
String logPath = FileLogsUtil.saveFileLogs(body); |
|
|
|
String logPath = FileLogsUtil.saveFileLogs(body); |
|
|
|
|
|
|
|
log.info(">>> 文件路径 {}", logPath); |
|
|
|
|
|
|
|
|
|
|
|
MultipartFile multi = getMultipartFile(logPath); |
|
|
|
MultipartFile multi = getMultipartFile(logPath); |
|
|
|
OpOrderStatusLogEntity orderStatusLog = new OpOrderStatusLogEntity(); |
|
|
|
|
|
|
|
//上传到服务器
|
|
|
|
//上传到服务器
|
|
|
|
R r = ossClient.fileUpload(multi); |
|
|
|
R r = ossClient.fileUpload(multi); |
|
|
|
if (r.isSuccess()) { |
|
|
|
if (r.isSuccess()) { |
|
|
@ -634,11 +640,22 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@NotNull |
|
|
|
@NotNull |
|
|
|
private MultipartFile getMultipartFile(String logPath) { |
|
|
|
private MultipartFile getMultipartFile(String logPath) { |
|
|
|
File f = new File(logPath); |
|
|
|
File file = new File(logPath); |
|
|
|
DiskFileItem fileItem = (DiskFileItem) new DiskFileItemFactory().createItem("file", |
|
|
|
|
|
|
|
"multipart/form-data", true, f.getName()); |
|
|
|
// File 转 MultipartFile
|
|
|
|
MultipartFile multi = new CommonsMultipartFile(fileItem); |
|
|
|
FileItem item = new DiskFileItemFactory().createItem("file" |
|
|
|
return multi; |
|
|
|
, MediaType.MULTIPART_FORM_DATA_VALUE |
|
|
|
|
|
|
|
, true |
|
|
|
|
|
|
|
, file.getName()); |
|
|
|
|
|
|
|
try (InputStream input = new FileInputStream(file); |
|
|
|
|
|
|
|
OutputStream os = item.getOutputStream()) { |
|
|
|
|
|
|
|
// 流转移
|
|
|
|
|
|
|
|
IOUtils.copy(input, os); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException("Invalid file: " + e, e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new CommonsMultipartFile(item); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|