Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3d24f77a66
|
|
@ -23,6 +23,10 @@
|
||||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
<version>${jasypt-spring-boot-starter.version}</version>
|
<version>${jasypt-spring-boot-starter.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ import com.bonus.material.order.domain.OrderDetailDto;
|
||||||
import com.bonus.material.order.domain.OrderInfoDto;
|
import com.bonus.material.order.domain.OrderInfoDto;
|
||||||
import com.bonus.material.order.mapper.OrderMapper;
|
import com.bonus.material.order.mapper.OrderMapper;
|
||||||
import com.bonus.material.order.service.OrderService;
|
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.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
@ -23,6 +25,7 @@ import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.mock.web.MockMultipartFile;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
@ -36,7 +39,11 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -58,6 +65,9 @@ public class OrderController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private BmContractService bmContractService;
|
private BmContractService bmContractService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RemoteFileService sysFileService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交预约车到订单
|
* 提交预约车到订单
|
||||||
*/
|
*/
|
||||||
|
|
@ -165,7 +175,7 @@ public class OrderController extends BaseController {
|
||||||
|
|
||||||
@ApiOperation(value = "租赁协议(查看)")
|
@ApiOperation(value = "租赁协议(查看)")
|
||||||
@GetMapping("/leaseAgreement")
|
@GetMapping("/leaseAgreement")
|
||||||
public ResponseEntity<byte[]> getleaseAgreement(String orderId, Map<String, String> replacements) throws IOException {
|
public AjaxResult getleaseAgreement(String orderId, Map<String, String> replacements) throws IOException, ParseException {
|
||||||
OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
|
OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
|
||||||
BmContract bmContract = new BmContract();
|
BmContract bmContract = new BmContract();
|
||||||
bmContract.setStatus(1);
|
bmContract.setStatus(1);
|
||||||
|
|
@ -174,8 +184,14 @@ public class OrderController extends BaseController {
|
||||||
InputStream inputStream = new URL(wordUrl).openStream();
|
InputStream inputStream = new URL(wordUrl).openStream();
|
||||||
|
|
||||||
XWPFDocument document = new XWPFDocument(inputStream);
|
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());
|
replacements.put("${czcompanyName}", orderInfoDto.getCzcompanyName());
|
||||||
//承租方所属公司
|
//承租方所属公司
|
||||||
|
|
@ -202,20 +218,7 @@ public class OrderController extends BaseController {
|
||||||
document.write(outputStream);
|
document.write(outputStream);
|
||||||
byte[] wordBytes = outputStream.toByteArray();
|
byte[] wordBytes = outputStream.toByteArray();
|
||||||
|
|
||||||
// Convert Word to Image (simple example using BufferedImage)
|
MultipartFile file = new MockMultipartFile("contract", "contract.docx", MediaType.APPLICATION_OCTET_STREAM_VALUE, wordBytes);
|
||||||
/* BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB);
|
return sysFileService.upload(file);
|
||||||
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();*/
|
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
|
||||||
headers.setContentDispositionFormData("attachment", "contract.docx");
|
|
||||||
return ResponseEntity.ok()
|
|
||||||
.headers(headers)
|
|
||||||
.body(wordBytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.material.order.domain;
|
package com.bonus.material.order.domain;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -35,6 +36,7 @@ public class OrderInfoDto {
|
||||||
|
|
||||||
@ApiModelProperty(value = "订单日期")
|
@ApiModelProperty(value = "订单日期")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date orderTime;
|
private Date orderTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "开始日期")
|
@ApiModelProperty(value = "开始日期")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue