|
@@ -2,6 +2,7 @@ package com.trade.client.trade.sales.service.impl;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -23,6 +24,9 @@ import com.trade.service.DictConstants;
|
|
|
import com.trade.service.companyrelated.domain.VendorEntity;
|
|
|
import com.trade.service.companyrelated.service.IVendorEntityService;
|
|
|
import com.trade.service.enterprise.dto.EnterpriseDto;
|
|
|
+import com.trade.service.filestorage.service.OSSFileService;
|
|
|
+import com.trade.service.filestorage.service.TFileStorageService;
|
|
|
+import com.trade.service.filestorage.util.oss.OSSUtil;
|
|
|
import com.trade.service.sales.vo.ImportCommodityVo;
|
|
|
import com.trade.service.serialNum.service.SerialNumberGenerator;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
@@ -53,7 +57,6 @@ import com.trade.service.contract.dto.ContractGenOutputItem;
|
|
|
import com.trade.service.contract.service.ContractService;
|
|
|
import com.trade.service.filestorage.entity.TFileStorage;
|
|
|
import com.trade.service.filestorage.enums.FileModuleEnum;
|
|
|
-import com.trade.service.filestorage.service.LocalFileService;
|
|
|
import com.trade.service.filestorage.util.MultipartFileUtil;
|
|
|
import com.trade.service.sales.domain.*;
|
|
|
import com.trade.service.sales.dto.ContractSearchDto;
|
|
@@ -86,7 +89,11 @@ public class SalesServiceImpl implements SalesService {
|
|
|
@Resource
|
|
|
private ContractFileService contractFileService;
|
|
|
@Resource
|
|
|
- private LocalFileService localFileService;
|
|
|
+ private OSSFileService ossFileService;
|
|
|
+ @Resource
|
|
|
+ private TFileStorageService tFileStorageService;
|
|
|
+ @Resource
|
|
|
+ private OSSUtil ossUtil;
|
|
|
@Resource
|
|
|
private ContractService contractService;
|
|
|
@Resource
|
|
@@ -202,11 +209,15 @@ public class SalesServiceImpl implements SalesService {
|
|
|
contractTermsExtends.addAll(contractTermsDto.getTitleInfo());
|
|
|
ContractFile contractFile = handleInkassoContractFile(salesContract, customerUser, contractTerms,
|
|
|
contractTermsExtends);
|
|
|
- TFileStorage tFileStorage = localFileService.getFileById(contractFile.getUnsignFileStorageId());
|
|
|
try {
|
|
|
+ TFileStorage tFileStorage = tFileStorageService
|
|
|
+ .getFileStorageById(contractFile.getUnsignFileStorageId());
|
|
|
+ String objName = tFileStorage.getPath();
|
|
|
+ String fileName = tFileStorage.getOriginalName();
|
|
|
+ InputStream in = ossUtil.downloadFile(objName);
|
|
|
OutputStream out = response.getOutputStream();
|
|
|
- FileUtils.setAttachmentResponseHeader(response, tFileStorage.getOriginalName());
|
|
|
- FileUtils.writeBytes(tFileStorage.getAbsolutePath(), out);
|
|
|
+ FileUtils.setAttachmentResponseHeader(response, fileName);
|
|
|
+ FileUtils.writeInputStream(in, out);
|
|
|
} catch (Exception e) {
|
|
|
log.error("文件下载失败,合同编号={},客户id={},异常原因={}", salesContract.getContractNo(), customerUser.getId(), e);
|
|
|
throw new ValidatorException(HttpStatus.ERROR, "文件下载失败!");
|
|
@@ -255,7 +266,7 @@ public class SalesServiceImpl implements SalesService {
|
|
|
}
|
|
|
try {
|
|
|
if (contractFileExist != null) {
|
|
|
- TFileStorage fileStorage = localFileService.addStorage(transferFile, FileModuleEnum.SIGNED_CONTRACT);
|
|
|
+ TFileStorage fileStorage = ossFileService.addStorage(transferFile, FileModuleEnum.SIGNED_CONTRACT);
|
|
|
contractFileExist.setSignedFileStorageId(fileStorage.getId());
|
|
|
contractFileService.updateById(contractFileExist);
|
|
|
} else {
|
|
@@ -264,7 +275,7 @@ public class SalesServiceImpl implements SalesService {
|
|
|
contractFile.setSignFileType(FileTypeEnum.SALES_CONTRACT.getCode());
|
|
|
contractFile.setGenerationTime(LocalDateTime.now());
|
|
|
contractFile.setOperatorName(customerUser.getNickname());
|
|
|
- TFileStorage fileStorage = localFileService.addStorage(transferFile, FileModuleEnum.SIGNED_CONTRACT);
|
|
|
+ TFileStorage fileStorage = ossFileService.addStorage(transferFile, FileModuleEnum.SIGNED_CONTRACT);
|
|
|
contractFile.setContractNo(salesContract.getContractNo());
|
|
|
contractFile.setUnsignFileStorageId(fileStorage.getId());
|
|
|
contractFile.setSignedFileStorageId(fileStorage.getId());
|
|
@@ -295,8 +306,9 @@ public class SalesServiceImpl implements SalesService {
|
|
|
fileId = contractFileExist.getUnsignFileStorageId();
|
|
|
}
|
|
|
}
|
|
|
- TFileStorage fileStorage = localFileService.getFileById(fileId);
|
|
|
- FileDownUtils.downloadFile(response, new File(fileStorage.getAbsolutePath()));
|
|
|
+ TFileStorage tFileStorage = tFileStorageService.getFileStorageById(fileId);
|
|
|
+ InputStream in = ossUtil.downloadFile(tFileStorage.getPath());
|
|
|
+ FileDownUtils.downloadFile(response, in, tFileStorage.getOriginalName());
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -463,7 +475,7 @@ public class SalesServiceImpl implements SalesService {
|
|
|
customerUser.getId());
|
|
|
contractFile.setUnsignFileStorageId(contractGenOutput.getFileId());
|
|
|
} else {
|
|
|
- TFileStorage fileStorage = localFileService.addStorage(transferFile, FileModuleEnum.SIGNED_CONTRACT);
|
|
|
+ TFileStorage fileStorage = ossFileService.addStorage(transferFile, FileModuleEnum.SIGNED_CONTRACT);
|
|
|
contractFile.setContractNo(salesContractDto.getContractNo());
|
|
|
contractFile.setUnsignFileStorageId(fileStorage.getId());
|
|
|
contractFile.setSignedFileStorageId(fileStorage.getId());
|