puzhibing
2023-02-11 521efb9bc33d52ef4772f0b30f8a371ba4b0070c
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -15,6 +15,7 @@
import com.stylefeng.guns.modular.system.dao.DriverTrainMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.EmailUtil;
import com.stylefeng.guns.modular.system.util.HttpRequestUtil;
import com.stylefeng.guns.modular.system.util.PushURL;
import com.stylefeng.guns.modular.system.util.ResultUtil;
@@ -22,6 +23,9 @@
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
@@ -33,6 +37,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -73,8 +78,8 @@
    @Resource
    private DriverPunishMapper driverPunishMapper;
    @Value("${pushMinistryOfTransport}")
    private boolean pushMinistryOfTransport;
    @Value("${spring.mail.template-path}")
    private String templatePath;
@@ -585,11 +590,38 @@
                tDriver.setAuthState(4);
            }
            Map<String,String> map = new HashMap<>();
            map.put("uid", String.valueOf(tDriver.getId()));
            map.put("type", String.valueOf(type));
            String result = HttpRequestUtil.postRequest(PushURL.driver_auth_url, map);
            System.out.println("司机注册审核发送短信 :【driverId="+tDriver.getId().toString()+"】,调用接口:"+result);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        String path = templatePath +  "driver/index.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("invite1").attr("style", "display: none;");
                        document.getElementById("user1").attr("style", "display: none;");
                        document.getElementById("settle1").attr("style", "display: none;");
                        document.getElementById("pass1").attr("style", "display: none;");
                        document.getElementById("email1").attr("style", "display: none;");
                        document.getElementById("bill1").attr("style", "display: none;");
                        document.getElementById("reward1").attr("style", "display: none;");
                        document.getElementById("rewardToday1").attr("style", "display: none;");
                        document.getElementById("carAudit1").attr("style", "display: none;");
                        Element driver_audit1_user = document.getElementById("driver_audit1_user");
                        driver_audit1_user.text("Hello " + tDriver.getName() + ",");
                        Element driver_audit1_content = document.getElementById("driver_audit1_content");
                        if(1 == authState){
                            driver_audit1_content.text("You application has been approved.");
                        }else{
                            driver_audit1_content.text("I'm sorry, your application was rejected. Reason for rejection: Incomplete filling in personal information.");
                        }
                        EmailUtil.send(tDriver.getEmail(), "Notice of driver registration application",  document.html());
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }).start();
            tDriverService.updateById(tDriver);
        }