From b0a224caed1e2d137a5960bcb04ce8f80141c939 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期三, 17 七月 2024 16:59:25 +0800
Subject: [PATCH] 2.0bug修改

---
 ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TReportLossController.java |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TReportLossController.java b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TReportLossController.java
index 79e6d89..aa9afb7 100644
--- a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TReportLossController.java
+++ b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TReportLossController.java
@@ -6,9 +6,12 @@
 import com.stylefeng.guns.core.shiro.ShiroKit;
 import com.stylefeng.guns.core.util.SinataUtil;
 import com.stylefeng.guns.core.util.ToolUtil;
+import com.stylefeng.guns.modular.system.model.TEmail;
 import com.stylefeng.guns.modular.system.model.TUser;
 import com.stylefeng.guns.modular.system.service.ITUserService;
+import com.stylefeng.guns.modular.system.service.TEmailService;
 import com.stylefeng.guns.modular.system.util.EmailUtil;
+import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -25,6 +28,10 @@
 import com.stylefeng.guns.modular.system.service.ITReportLossService;
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.util.Date;
 import java.util.Map;
 
 /**
@@ -47,6 +54,9 @@
 
     @Value("${spring.mail.template-path}")
     private String templatePath;
+
+    @Autowired
+    private TEmailService emailService;
 
     /**
      * 跳转到首页
@@ -149,13 +159,46 @@
                 if(ToolUtil.isNotEmpty(userInfo.getEmail())){
                     String path = templatePath +  "user/reportLossResult.html";
                     Document document = Jsoup.parse(new File(path), "UTF-8");
-                    document.getElementById("chinese").attr("style", "display: none;");
-                    document.getElementById("french").attr("style", "display: none;");
+                    document.getElementById("chinese").remove();
+                    document.getElementById("french").remove();
+                    document.getElementsByTag("title").get(0).text("Notification of the result of the loss report");
                     Element english_user = document.getElementById("english_user");
                     english_user.text("Hello " + userInfo.getNickName() + ",");
                     Element english_content = document.getElementById("english_content");
                     english_content.text(info);
                     EmailUtil.send(userInfo.getEmail(), "Notification of the result of the loss report",  document.html());
+
+                    //开始生成pdf收据和html收据
+                    File file = new File("/usr/local/nginx/html/files/html/");
+                    if(!file.exists()){
+                        file.mkdirs();
+                    }
+                    String randomString = ToolUtil.getRandomString(10);
+                    file = new File("/usr/local/nginx/html/files/html/reportLossResult_" + randomString + ".html");
+                    if(!file.exists()){
+                        file.createNewFile();
+                    }
+                    FileWriter fileWriter = new FileWriter(file);
+                    fileWriter.write(document.html());
+                    fileWriter.flush();
+                    fileWriter.close();
+
+                    String link ="http://182.160.16.251:81/files/html/reportLossResult_" + randomString + ".html";
+                    TEmail tEmail = new TEmail();
+                    tEmail.setLink(link);
+                    tEmail.setUserId(userInfo.getId());
+                    tEmail.setType(1);
+                    tEmail.setName("Notification of the result of the loss report");
+                    tEmail.setCreateTime(new Date());
+                    int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1;
+                    tEmail.setWeek(EmailUtil.getWeek(2,i));
+                    boolean am = cn.hutool.core.date.DateUtil.isAM(new Date());
+                    if(am){
+                        tEmail.setAmOrPm("AM");
+                    }else {
+                        tEmail.setAmOrPm("PM");
+                    }
+                    emailService.insert(tEmail);
                 }
             }catch (Exception e){
                 e.printStackTrace();

--
Gitblit v1.7.1