Merge branch 'dev_nc2k_20251213' into dev
# Conflicts: # mhd-auth/src/main/resources/bootstrap.yml # mhd-gateway/src/main/resources/bootstrap.yml # mhd-modules/mhd-system/src/main/resources/bootstrap.yml # mhd-user-center/src/main/resources/bootstrap.yml # mhd_finance/src/main/resources/bootstrap.yml # mhd_product/src/main/resources/bootstrap.yml # mhd_thrid_party/src/main/resources/bootstrap.yml # mhd_transport/src/main/resources/bootstrap.yml
This commit is contained in:
@@ -180,6 +180,12 @@
|
||||
<version>3.3.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>8.5.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
+18
@@ -522,4 +522,22 @@ public class TmsOrder implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "付款方名称")
|
||||
private String payer;
|
||||
|
||||
@ApiModelProperty("客户编码nc")
|
||||
private String customsCodeNc;
|
||||
|
||||
@ApiModelProperty("制单人编码nc")
|
||||
private String makerCodeNc;
|
||||
|
||||
@ApiModelProperty("业务员编码nc")
|
||||
private String salesmanCodeNc;
|
||||
|
||||
@ApiModelProperty("税率")
|
||||
private BigDecimal taxRate;
|
||||
|
||||
@ApiModelProperty("结算币种")
|
||||
private String settlementCurrency;
|
||||
|
||||
@ApiModelProperty("合同编号")
|
||||
private String contractNo;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package minio;
|
||||
|
||||
import com.aliyun.oss.ServiceException;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PutObjectArgs;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class MinIoUploadService {
|
||||
|
||||
private MinioClient minioClient;
|
||||
|
||||
private static String bucket="ngwl";
|
||||
private static String host="http://10.102.192.5:6000";
|
||||
private static String accessKey="minioadmin";
|
||||
private static String secretKey="gmminioadmin";
|
||||
|
||||
|
||||
/**
|
||||
* 上传到minio
|
||||
* @param fileName
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public String uploadFileToMinIo(MultipartFile multipartFile) {
|
||||
try {
|
||||
initMinio();
|
||||
InputStream inputStream = multipartFile.getInputStream();
|
||||
|
||||
// 上传文件的名称
|
||||
String filename = multipartFile.getOriginalFilename();
|
||||
|
||||
// PutObjectOptions,上传配置(文件大小,内存中文件分片大小)
|
||||
// PutObjectOptions putObjectOptions = new PutObjectOptions(multipartFile.getSize(), PutObjectOptions.MIN_MULTIPART_SIZE);
|
||||
// // 文件的ContentType
|
||||
// putObjectOptions.setContentType(multipartFile.getContentType());
|
||||
|
||||
String prefix = filename.substring(filename.lastIndexOf(".") + 1);//后缀
|
||||
//根据当前时间生成文件夹
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date time = calendar.getTime();
|
||||
// 2. 格式化系统时间--- 这里的时间格式可以根据自己的需要进行改变
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String buckfilename = format.format(time);
|
||||
|
||||
String uuid= UUID.randomUUID().toString().replace("-","");//customer_YYYYMMDDHHMM
|
||||
String fileName = buckfilename+"/"+uuid+"."+prefix; //文件全路径
|
||||
|
||||
PutObjectArgs objectArgs = PutObjectArgs.builder()
|
||||
.object(fileName).bucket(bucket)
|
||||
.stream(inputStream,inputStream.available(),-1).build();
|
||||
//文件名称相同会覆盖
|
||||
minioClient.putObject(objectArgs);
|
||||
String url =host+ "/"+bucket + "/"+fileName;
|
||||
|
||||
//
|
||||
return url;
|
||||
}catch (Exception e){
|
||||
//log.error(e.getMessage(),e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
private MinioClient initMinio() {
|
||||
try{
|
||||
MinioClient minioClient = MinioClient.builder()
|
||||
.endpoint(host)
|
||||
.credentials(accessKey, secretKey)
|
||||
.build();
|
||||
return minioClient;
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return minioClient;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* 文件上传成功,返回文件完整访问路径
|
||||
* 文件上传失败,返回 null
|
||||
*
|
||||
* @param multipartFile 待上传文件
|
||||
* @param fileDir 文件保存目录
|
||||
* @return oss 中的相对文件路径
|
||||
*/
|
||||
/* public static String upload(MultipartFile multipartFile, String fileDir) {
|
||||
|
||||
|
||||
try (InputStream inputStream = multipartFile.getInputStream()) {
|
||||
//初始化minio
|
||||
initMinio();
|
||||
// bucket 不存在,创建
|
||||
if (!minioClient1.bucketExists(bucket)) {
|
||||
minioClient1.makeBucket(bucket);
|
||||
}
|
||||
// 上传文件的名称
|
||||
String fileName = multipartFile.getOriginalFilename();
|
||||
long timestamp = Calendar.getInstance().getTimeInMillis();
|
||||
// PutObjectOptions,上传配置(文件大小,内存中文件分片大小)
|
||||
// PutObjectOptions putObjectOptions = new PutObjectOptions(multipartFile.getSize(), PutObjectOptions.MIN_MULTIPART_SIZE);
|
||||
// // 文件的ContentType
|
||||
// putObjectOptions.setContentType(multipartFile.getContentType());
|
||||
|
||||
SimpleDateFormat sdYear = new SimpleDateFormat("yyyy");
|
||||
SimpleDateFormat sdMonth = new SimpleDateFormat("MM");
|
||||
SimpleDateFormat sdDay = new SimpleDateFormat("dd");
|
||||
String year = sdYear.format(new Date());
|
||||
String month = sdMonth.format(new Date());
|
||||
String day = sdDay.format(new Date());
|
||||
String filrDir = "wlhy/" + year + "/" + month + "/" + day + "/";
|
||||
|
||||
// minioClient.putObject(bucket, filrDir+timestamp+fileName, inputStream, putObjectOptions);
|
||||
minioClient1.putObject(bucket, filrDir+timestamp+fileName, inputStream, multipartFile.getContentType());
|
||||
// 返回访问路径
|
||||
String fileurl = host+ "/"+bucket + "/"+filrDir+timestamp+ UriUtils.encode(fileName, StandardCharsets.UTF_8);
|
||||
System.out.println("fileurl===="+fileurl);
|
||||
FILE_URL = fileurl;
|
||||
return fileurl;
|
||||
} catch (ServiceException e){
|
||||
log.error(e.getErrorMessage());
|
||||
} catch (Exception e){
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return FILE_URL;
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user