Compare commits
	
		
			2 Commits
		
	
	
		
			b64f24c2f2
			...
			f243e118a6
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								
								 | 
						f243e118a6 | |
| 
							
							
								
								 | 
						1f69390318 | 
| 
						 | 
				
			
			@ -164,19 +164,16 @@ public class OrderController extends BaseController {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "租赁协议(查看)")
 | 
			
		||||
    @PostMapping("/leaseAgreement")
 | 
			
		||||
    public ResponseEntity<byte[]> getleaseAgreement(@RequestParam String orderId,
 | 
			
		||||
                                                     @RequestParam("file") MultipartFile file,
 | 
			
		||||
                                                     @RequestParam Map<String, String> replacements) throws IOException {
 | 
			
		||||
    @GetMapping("/leaseAgreement")
 | 
			
		||||
    public ResponseEntity<byte[]> getleaseAgreement(String orderId, Map<String, String> replacements) throws IOException {
 | 
			
		||||
        OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
 | 
			
		||||
     /*   BmContract bmContract = new BmContract();
 | 
			
		||||
        BmContract bmContract = new BmContract();
 | 
			
		||||
        bmContract.setStatus(1);
 | 
			
		||||
        List<BmContract> list = bmContractService.list(bmContract);
 | 
			
		||||
        String wordUrl = list.get(0).getBmFileInfoList().get(0).getFileUrl();
 | 
			
		||||
        InputStream inputStream = new URL(wordUrl).openStream();
 | 
			
		||||
 | 
			
		||||
        XWPFDocument document = new XWPFDocument(inputStream);*/
 | 
			
		||||
        XWPFDocument document = new XWPFDocument(file.getInputStream());
 | 
			
		||||
        XWPFDocument document = new XWPFDocument(inputStream);
 | 
			
		||||
        //订单日期
 | 
			
		||||
        replacements.put("${orderTime}", orderInfoDto.getOrderTime().toString());
 | 
			
		||||
        //装备所属公司
 | 
			
		||||
| 
						 | 
				
			
			@ -206,20 +203,19 @@ public class OrderController extends BaseController {
 | 
			
		|||
        byte[] wordBytes = outputStream.toByteArray();
 | 
			
		||||
 | 
			
		||||
        // Convert Word to Image (simple example using BufferedImage)
 | 
			
		||||
        BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB);
 | 
			
		||||
/*        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();
 | 
			
		||||
 | 
			
		||||
        ByteArrayOutputStream imageOutputStream = new ByteArrayOutputStream();
 | 
			
		||||
        ImageIO.write(image, "png", imageOutputStream);
 | 
			
		||||
        byte[] imageBytes = imageOutputStream.toByteArray();
 | 
			
		||||
        graphics.dispose();*/
 | 
			
		||||
 | 
			
		||||
        HttpHeaders headers = new HttpHeaders();
 | 
			
		||||
        headers.setContentType(MediaType.IMAGE_PNG);
 | 
			
		||||
        return ResponseEntity.ok().headers(headers).body(imageBytes);
 | 
			
		||||
        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
 | 
			
		||||
        headers.setContentDispositionFormData("attachment", "contract.docx");
 | 
			
		||||
        return ResponseEntity.ok()
 | 
			
		||||
                .headers(headers)
 | 
			
		||||
                .body(wordBytes);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue