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 = "开始日期")