From 06df89cb220d670695fa39df20b3e41519eb9632 Mon Sep 17 00:00:00 2001
From: "liang.chao" <1360241448@qq.com>
Date: Mon, 16 Dec 2024 17:34:36 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E7=A7=9F=E8=B5=81=E5=8D=8F=E8=AE=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
bonus-modules/bonus-material-mall/pom.xml | 4 +++
.../order/controller/OrderController.java | 25 +++++++++++++------
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/bonus-modules/bonus-material-mall/pom.xml b/bonus-modules/bonus-material-mall/pom.xml
index 72546d3..49ad73d 100644
--- a/bonus-modules/bonus-material-mall/pom.xml
+++ b/bonus-modules/bonus-material-mall/pom.xml
@@ -23,6 +23,10 @@
jasypt-spring-boot-starter
${jasypt-spring-boot-starter.version}
+
+ org.springframework
+ spring-test
+
com.alibaba.cloud
diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java
index 5f62157..4a29850 100644
--- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java
+++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java
@@ -15,6 +15,8 @@ import com.bonus.material.order.domain.OrderDetailDto;
import com.bonus.material.order.domain.OrderInfoDto;
import com.bonus.material.order.mapper.OrderMapper;
import com.bonus.material.order.service.OrderService;
+import com.bonus.system.api.RemoteFileService;
+import com.bonus.system.api.domain.SysFile;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@@ -23,6 +25,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
@@ -58,6 +61,9 @@ public class OrderController extends BaseController {
@Resource
private BmContractService bmContractService;
+ @Resource
+ private RemoteFileService sysFileService;
+
/**
* 提交预约车到订单
*/
@@ -165,7 +171,7 @@ public class OrderController extends BaseController {
@ApiOperation(value = "租赁协议(查看)")
@GetMapping("/leaseAgreement")
- public ResponseEntity getleaseAgreement(String orderId, Map replacements) throws IOException {
+ public AjaxResult getleaseAgreement(String orderId, Map replacements) throws IOException {
OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
BmContract bmContract = new BmContract();
bmContract.setStatus(1);
@@ -202,6 +208,7 @@ public class OrderController extends BaseController {
document.write(outputStream);
byte[] wordBytes = outputStream.toByteArray();
+
// Convert Word to Image (simple example using BufferedImage)
/* BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics();
@@ -210,12 +217,14 @@ public class OrderController extends BaseController {
graphics.setPaint(Color.black);
graphics.drawString(new String(wordBytes), 10, 20);
graphics.dispose();*/
-
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
- headers.setContentDispositionFormData("attachment", "contract.docx");
- return ResponseEntity.ok()
- .headers(headers)
- .body(wordBytes);
+ MultipartFile file = new MockMultipartFile("contract", "contract.docx", MediaType.APPLICATION_OCTET_STREAM_VALUE, wordBytes);
+ AjaxResult upload = sysFileService.upload(file);
+ return upload;
+// HttpHeaders headers = new HttpHeaders();
+// headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
+// headers.setContentDispositionFormData("attachment", "contract.docx");
+// return ResponseEntity.ok()
+// .headers(headers)
+// .body(wordBytes);
}
}
From 97c7285ac368ed59dc184ec838b19cfb8097c9c0 Mon Sep 17 00:00:00 2001
From: "liang.chao" <1360241448@qq.com>
Date: Mon, 16 Dec 2024 17:58:54 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E7=A7=9F=E8=B5=81=E5=8D=8F=E8=AE=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../material/order/controller/OrderController.java | 14 ++++++++++++--
.../bonus/material/order/domain/OrderInfoDto.java | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java
index 4a29850..0051afa 100644
--- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java
+++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java
@@ -39,7 +39,11 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
/**
@@ -171,7 +175,7 @@ public class OrderController extends BaseController {
@ApiOperation(value = "租赁协议(查看)")
@GetMapping("/leaseAgreement")
- public AjaxResult getleaseAgreement(String orderId, Map replacements) throws IOException {
+ public AjaxResult getleaseAgreement(String orderId, Map replacements) throws IOException, ParseException {
OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
BmContract bmContract = new BmContract();
bmContract.setStatus(1);
@@ -180,8 +184,14 @@ public class OrderController extends BaseController {
InputStream inputStream = new URL(wordUrl).openStream();
XWPFDocument document = new XWPFDocument(inputStream);
+ String dateStr = orderInfoDto.getOrderTime().toString();
+ SimpleDateFormat inputFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
+ SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ Date date = inputFormat.parse(dateStr);
+ String formattedDate = outputFormat.format(date);
//订单日期
- replacements.put("${orderTime}", orderInfoDto.getOrderTime().toString());
+ replacements.put("${orderTime}", formattedDate);
//装备所属公司
replacements.put("${czcompanyName}", orderInfoDto.getCzcompanyName());
//承租方所属公司
diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/domain/OrderInfoDto.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/domain/OrderInfoDto.java
index a05329e..2b77966 100644
--- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/domain/OrderInfoDto.java
+++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/domain/OrderInfoDto.java
@@ -1,5 +1,6 @@
package com.bonus.material.order.domain;
+import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -35,6 +36,7 @@ public class OrderInfoDto {
@ApiModelProperty(value = "订单日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+ @JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date orderTime;
@ApiModelProperty(value = "开始日期")
From ddd905b9f1fbf5181bc9e6858751176cc4ce95d5 Mon Sep 17 00:00:00 2001
From: "liang.chao" <1360241448@qq.com>
Date: Mon, 16 Dec 2024 18:00:09 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E7=A7=9F=E8=B5=81=E5=8D=8F=E8=AE=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../order/controller/OrderController.java | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)
diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java
index 0051afa..37004d2 100644
--- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java
+++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/order/controller/OrderController.java
@@ -218,23 +218,7 @@ public class OrderController extends BaseController {
document.write(outputStream);
byte[] wordBytes = outputStream.toByteArray();
-
- // Convert Word to Image (simple example using BufferedImage)
-/* BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB);
- Graphics2D graphics = image.createGraphics();
- graphics.setPaint(Color.white);
- graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
- graphics.setPaint(Color.black);
- graphics.drawString(new String(wordBytes), 10, 20);
- graphics.dispose();*/
MultipartFile file = new MockMultipartFile("contract", "contract.docx", MediaType.APPLICATION_OCTET_STREAM_VALUE, wordBytes);
- AjaxResult upload = sysFileService.upload(file);
- return upload;
-// HttpHeaders headers = new HttpHeaders();
-// headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
-// headers.setContentDispositionFormData("attachment", "contract.docx");
-// return ResponseEntity.ok()
-// .headers(headers)
-// .body(wordBytes);
+ return sysFileService.upload(file);
}
}