puzhibing
2023-05-18 53562814add61acfdc02d6b25dae6324f6fd5f92
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCarController.java
@@ -13,14 +13,16 @@
import com.stylefeng.guns.modular.system.dao.CarInsuranceMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.PushMinistryOfTransportUtil;
import com.stylefeng.guns.modular.system.util.EmailUtil;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import org.apache.commons.lang.time.DateUtils;
import org.apache.poi.hdf.extractor.TC;
import org.apache.poi.ss.usermodel.Cell;
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.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@@ -33,6 +35,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -79,17 +82,17 @@
    @Autowired
    private ITServerCarmodelService itServerCarmodelService;
    @Autowired
    private PushMinistryOfTransportUtil pushMinistryOfTransportUtil;
    @Resource
    private CarInsuranceMapper carInsuranceMapper;
    @Autowired
    private ITCarColorService carColorService;
    @Value("${pushMinistryOfTransport}")
    private boolean pushMinistryOfTransport;
    @Value("${spring.mail.template-path}")
    private String templatePath;
    /**
     * 跳转到车辆管理首页
@@ -260,8 +263,13 @@
                one = 2;
                zcModel = obj.getServerCarModelId();
            }
            if (obj.getType() == 1){
                four = 2;
                zcModel = obj.getServerCarModelId();
            }
        }
        model.addAttribute("one",one);
        model.addAttribute("four",four);
        model.addAttribute("zcModel",zcModel);
        List<TServerCarmodel> zcModelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 1).eq("state", 1));
        model.addAttribute("zcModelList",zcModelList);
@@ -318,24 +326,8 @@
    public ResultUtil saveCarInsurance(CarInsurance carInsurance){
        if(carInsurance.getId() == null){
            carInsuranceMapper.insert(carInsurance);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    if(pushMinistryOfTransport){//上传数据
                        pushMinistryOfTransportUtil.baseInfoVehicleInsurance(carInsurance.getId(), 1);
                    }
                }
            }).start();
        }else{
            carInsuranceMapper.updateById(carInsurance);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    if(pushMinistryOfTransport){//上传数据
                        pushMinistryOfTransportUtil.baseInfoVehicleInsurance(carInsurance.getId(), 2);
                    }
                }
            }).start();
        }
        return ResultUtil.success();
@@ -386,14 +378,6 @@
    @RequestMapping(value = "/delCarInsurance", method = RequestMethod.POST)
    public ResultUtil delCarInsurance(Integer id){
        carInsuranceMapper.deleteById(id);
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(pushMinistryOfTransport){//上传数据
                    pushMinistryOfTransportUtil.baseInfoVehicleInsurance(id, 3);
                }
            }
        }).start();
        return ResultUtil.success();
    }
@@ -497,6 +481,7 @@
        }
        tCar.setInsertTime(new Date());
        tCar.setState(1);
        tCar.setAuthState(1);
        tCarService.insert(tCar);
        //添加经营业务
@@ -512,16 +497,6 @@
            }
            tCarServiceService.insert(service);
        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(pushMinistryOfTransport){//上传数据
                    pushMinistryOfTransportUtil.baseInfoCompanyStat();
                    pushMinistryOfTransportUtil.baseInfoVehicle(tCar.getId());
                }
            }
        }).start();
        return SUCCESS_TIP;
    }
@@ -541,16 +516,6 @@
            obj.setCarId(null);
            tDriverService.updateById(obj);
        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(pushMinistryOfTransport){//上传数据
                    pushMinistryOfTransportUtil.baseInfoCompanyStat();
                    pushMinistryOfTransportUtil.baseInfoVehicle(tCar.getId());
                }
            }
        }).start();
        return SUCCESS_TIP;
    }
@@ -608,14 +573,6 @@
        }
        tCarService.updateById(tCar);
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(pushMinistryOfTransport){
                    pushMinistryOfTransportUtil.baseInfoVehicle(tCar.getId());
                }
            }
        }).start();
        return SUCCESS_TIP;
    }
    @RequestMapping(value = "/updateAuth")
@@ -625,16 +582,62 @@
        if(tCar.getAuthState()==2){
            String[] serverArray = serverBox.split(",");
            for (int i=0;i<serverArray.length;i++){
                TCarService service = new TCarService();
                service.setCarId(tCar.getId());
                service.setType(Integer.valueOf(serverArray[i]));
                if (1 == service.getType()){
                    service.setServerCarModelId(Integer.valueOf(zcModel));
                TCarService tCarService = tCarServiceService.selectOne(new EntityWrapper<TCarService>().eq("carId", tCar.getId()).eq("type", Integer.valueOf(serverArray[i])));
                if(null == tCarService){
                    tCarService = new TCarService();
                    tCarService.setCarId(tCar.getId());
                    tCarService.setType(Integer.valueOf(serverArray[i]));
                    if (1 == tCarService.getType()){
                        tCarService.setServerCarModelId(Integer.valueOf(zcModel));
                    }
                    tCarServiceService.insert(tCarService);
                }else{
                    if (1 == tCarService.getType()){
                        tCarService.setServerCarModelId(Integer.valueOf(zcModel));
                    }
                    tCarServiceService.updateById(tCarService);
                }
                tCarServiceService.insert(service);
            }
        }
        tCarService.updateById(tCar);
        tCar = tCarService.selectById(tCar.getId());
        TDriver tDriver = tDriverService.selectById(tCar.getDriverId());
        TCar finalTCar = tCar;
        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("driverAudit1").attr("style", "display: none;");
                    Element car_audit1_user = document.getElementById("car_audit1_user");
                    car_audit1_user.text("Hello " + tDriver.getName() + ",");
                    Element car_audit1_content = document.getElementById("car_audit1_content");
                    if(2 == finalTCar.getAuthState()){
                        car_audit1_content.text("You vehicle application has been approved. See the I-GO platform for details.");
                    }else{
                        car_audit1_content.text("Sorry, your vehicle application was not approved. The reason for the failure is: incomplete filling of vehicle information.");
                    }
                    EmailUtil.send(tDriver.getEmail(), "Vehicle audit notice",  document.html());
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }).start();
        return SUCCESS_TIP;
    }
@@ -663,16 +666,16 @@
        shellList.add("所属分公司[提示:加盟车辆选填]");
        shellList.add("所属加盟商[提示:加盟车辆选填]");
        shellList.add("服务模式:专车[是/否]");
        shellList.add("服务模式:出租车[是/否]");
        shellList.add("服务模式:跨城出行[是/否]");
        shellList.add("服务模式:小件同城物流[是/否]");
        shellList.add("服务模式:小件跨城物流[是/否]");
        shellList.add("服务模式:包车[是/否]");
//        shellList.add("服务模式:出租车[是/否]");
//        shellList.add("服务模式:跨城出行[是/否]");
        shellList.add("服务模式:市内小件物流[是/否]");
//        shellList.add("服务模式:小件跨城物流[是/否]");
//        shellList.add("服务模式:包车[是/否]");
        shellList.add("车辆品牌");
        shellList.add("车辆类型");
        shellList.add("车辆颜色[黑色/银色/白色/红色/黄色/橙色/蓝色]");
        shellList.add("车牌号");
        shellList.add("行驶证编号");
        shellList.add("roadworthiness sticker");
        shellList.add("年检到期时间[例如 2020-02-02]");
        shellList.add("商业保险到期时间[例如 2020-02-02]");
        dataList.add(shellList);
@@ -732,81 +735,81 @@
                    three = String.valueOf(cell3.getStringCellValue()).trim();
                }
                Cell cell4 = row.getCell(4);  //服务模式:出租车[是/否]
                String four = null;
                if (SinataUtil.isNotEmpty(cell4)){
                    four = String.valueOf(cell4.getStringCellValue()).trim();
                }
//                Cell cell4 = row.getCell(4);  //服务模式:出租车[是/否]
//                String four = null;
//                if (SinataUtil.isNotEmpty(cell4)){
//                    four = String.valueOf(cell4.getStringCellValue()).trim();
//                }
//
//                Cell cell5 = row.getCell(5);  //服务模式:跨城出行[是/否]
//                String five = null;
//                if (SinataUtil.isNotEmpty(cell5)){
//                    five = String.valueOf(cell5.getStringCellValue()).trim();
//                }
                Cell cell5 = row.getCell(5);  //服务模式:跨城出行[是/否]
                String five = null;
                if (SinataUtil.isNotEmpty(cell5)){
                    five = String.valueOf(cell5.getStringCellValue()).trim();
                }
                Cell cell6 = row.getCell(6);  //服务模式:小件跨城物流[是/否]
                Cell cell6 = row.getCell(4);  //服务模式:小件跨城物流[是/否]
                String six = null;
                if (SinataUtil.isNotEmpty(cell6)){
                    six = String.valueOf(cell6.getStringCellValue()).trim();
                }
                Cell cell7 = row.getCell(7);  //服务模式:小件跨城物流[是/否]
                String seven = null;
                if (SinataUtil.isNotEmpty(cell7)){
                    seven = String.valueOf(cell7.getStringCellValue()).trim();
                }
//                Cell cell7 = row.getCell(7);  //服务模式:小件跨城物流[是/否]
//                String seven = null;
//                if (SinataUtil.isNotEmpty(cell7)){
//                    seven = String.valueOf(cell7.getStringCellValue()).trim();
//                }
//
//                Cell cell8 = row.getCell(8);  //服务模式:包车[是/否]
//                String eight = null;
//                if (SinataUtil.isNotEmpty(cell8)){
//                    eight = String.valueOf(cell8.getStringCellValue()).trim();
//                }
                Cell cell8 = row.getCell(8);  //服务模式:包车[是/否]
                String eight = null;
                if (SinataUtil.isNotEmpty(cell8)){
                    eight = String.valueOf(cell8.getStringCellValue()).trim();
                }
                Cell cell9 = row.getCell(9);  //车辆品牌
                Cell cell9 = row.getCell(5);  //车辆品牌
                String nine = null;
                if (SinataUtil.isNotEmpty(cell9)){
                    nine = String.valueOf(cell9.getStringCellValue()).trim();
                }
                Cell cell10 = row.getCell(10);  //车辆类型
                Cell cell10 = row.getCell(6);  //车辆类型
                String ten = null;
                if (SinataUtil.isNotEmpty(cell10)){
                    ten = String.valueOf(cell10.getStringCellValue()).trim();
                }
                Cell cell11 = row.getCell(11);  //车辆颜色[黑色/银色/白色/红色/黄色/橙色/蓝色]
                Cell cell11 = row.getCell(7);  //车辆颜色[黑色/银色/白色/红色/黄色/橙色/蓝色]
                String eleven = null;
                if (SinataUtil.isNotEmpty(cell11)){
                    eleven = String.valueOf(cell11.getStringCellValue()).trim();
                }
                Cell cell12 = row.getCell(12);  //车牌号
                Cell cell12 = row.getCell(8);  //车牌号
                String twelve = null;
                if (SinataUtil.isNotEmpty(cell12)){
                    twelve = String.valueOf(cell12.getStringCellValue()).trim();
                }
                Cell cell13 = row.getCell(13);  //行驶证编号
                Cell cell13 = row.getCell(9);  //行驶证编号
                String thirteen = null;
                if (SinataUtil.isNotEmpty(cell13)){
                    thirteen = String.valueOf(cell13.getStringCellValue()).trim();
                }
                Cell cell14 = row.getCell(14);  //年检到期时间
                Cell cell14 = row.getCell(10);  //年检到期时间
                String fourteen = null;
                if (SinataUtil.isNotEmpty(cell14)){
                    fourteen = String.valueOf(cell14.getStringCellValue()).trim();
                }
                Cell cell15 = row.getCell(15);  //商业保险到期时间
                Cell cell15 = row.getCell(11);  //商业保险到期时间
                String fifteen = null;
                if (SinataUtil.isNotEmpty(cell15)){
                    fifteen = String.valueOf(cell15.getStringCellValue()).trim();
                }
                if (SinataUtil.isEmpty(zero) || SinataUtil.isEmpty(three) || SinataUtil.isEmpty(four)
                        || SinataUtil.isEmpty(five) || SinataUtil.isEmpty(six) || SinataUtil.isEmpty(seven)
                        || SinataUtil.isEmpty(eight) || SinataUtil.isEmpty(nine) || SinataUtil.isEmpty(ten)
                if (SinataUtil.isEmpty(zero) || SinataUtil.isEmpty(three) /*|| SinataUtil.isEmpty(four)
                        || SinataUtil.isEmpty(five) */|| SinataUtil.isEmpty(six) || /*SinataUtil.isEmpty(seven)
                        || SinataUtil.isEmpty(eight) || */SinataUtil.isEmpty(nine) || SinataUtil.isEmpty(ten)
                        || SinataUtil.isEmpty(eleven) || SinataUtil.isEmpty(twelve) || SinataUtil.isEmpty(thirteen)
                        || SinataUtil.isEmpty(fourteen) || SinataUtil.isEmpty(fifteen)){
                    return new ErrorTip(500, "单元格不能为空");
@@ -819,26 +822,26 @@
                    if (!three.equals("是") && !three.equals("否")){
                        return new ErrorTip(500, "服务模式【专车】内容不正确");
                    }
                    //判断服务模式【出租车】
                    if (!four.equals("是") && !four.equals("否")){
                        return new ErrorTip(500, "服务模式【出租车】内容不正确");
                    }
                    //判断服务模式【跨城出行】
                    if (!five.equals("是") && !five.equals("否")){
                        return new ErrorTip(500, "服务模式【跨城出行】内容不正确");
                    }
//                    //判断服务模式【出租车】
//                    if (!four.equals("是") && !four.equals("否")){
//                        return new ErrorTip(500, "服务模式【出租车】内容不正确");
//                    }
//                    //判断服务模式【跨城出行】
//                    if (!five.equals("是") && !five.equals("否")){
//                        return new ErrorTip(500, "服务模式【跨城出行】内容不正确");
//                    }
                    //判断服务模式【小件同城物流】
                    if (!six.equals("是") && !six.equals("否")){
                        return new ErrorTip(500, "服务模式【小件同城物流】内容不正确");
                        return new ErrorTip(500, "服务模式【小件市内物流】内容不正确");
                    }
                    //判断服务模式【小件跨城物流】
                    if (!seven.equals("是") && !seven.equals("否")){
                        return new ErrorTip(500, "服务模式【小件跨城物流】内容不正确");
                    }
                    //判断服务模式【包车】
                    if (!eight.equals("是") && !eight.equals("否")){
                        return new ErrorTip(500, "服务模式【包车】内容不正确");
                    }
//                    //判断服务模式【小件跨城物流】
//                    if (!seven.equals("是") && !seven.equals("否")){
//                        return new ErrorTip(500, "服务模式【小件跨城物流】内容不正确");
//                    }
//                    //判断服务模式【包车】
//                    if (!eight.equals("是") && !eight.equals("否")){
//                        return new ErrorTip(500, "服务模式【包车】内容不正确");
//                    }
                    //判断车辆颜色
                    if (!eleven.equals("黑色") && !eleven.equals("银色") && !eleven.equals("白色") && !eleven.equals("红色") && !eleven.equals("黄色") && !eleven.equals("橙色") && !eleven.equals("蓝色")){
                        return new ErrorTip(500, "车辆颜色内容不正确");
@@ -934,20 +937,20 @@
                        service.setType(1);
                        tCarServiceService.insert(service);
                    }
                    //添加出租车服务模式
                    if ("是".equals(four)){
                        TCarService service = new TCarService();
                        service.setCarId(car.getId());
                        service.setType(2);
                        tCarServiceService.insert(service);
                    }
                    //添加跨城出行服务模式
                    if ("是".equals(five)){
                        TCarService service = new TCarService();
                        service.setCarId(car.getId());
                        service.setType(3);
                        tCarServiceService.insert(service);
                    }
//                    //添加出租车服务模式
//                    if ("是".equals(four)){
//                        TCarService service = new TCarService();
//                        service.setCarId(car.getId());
//                        service.setType(2);
//                        tCarServiceService.insert(service);
//                    }
//                    //添加跨城出行服务模式
//                    if ("是".equals(five)){
//                        TCarService service = new TCarService();
//                        service.setCarId(car.getId());
//                        service.setType(3);
//                        tCarServiceService.insert(service);
//                    }
                    //添加小件同城物流服务模式
                    if ("是".equals(six)){
                        TCarService service = new TCarService();
@@ -955,20 +958,20 @@
                        service.setType(4);
                        tCarServiceService.insert(service);
                    }
                    //添加小件跨城物流服务模式
                    if ("是".equals(seven)){
                        TCarService service = new TCarService();
                        service.setCarId(car.getId());
                        service.setType(5);
                        tCarServiceService.insert(service);
                    }
                    //添加包车服务模式
                    if ("是".equals(eight)){
                        TCarService service = new TCarService();
                        service.setCarId(car.getId());
                        service.setType(6);
                        tCarServiceService.insert(service);
                    }
//                    //添加小件跨城物流服务模式
//                    if ("是".equals(seven)){
//                        TCarService service = new TCarService();
//                        service.setCarId(car.getId());
//                        service.setType(5);
//                        tCarServiceService.insert(service);
//                    }
//                    //添加包车服务模式
//                    if ("是".equals(eight)){
//                        TCarService service = new TCarService();
//                        service.setCarId(car.getId());
//                        service.setType(6);
//                        tCarServiceService.insert(service);
//                    }
                }
            }
        } catch (Exception e) {
@@ -1038,7 +1041,7 @@
        shellList.add("颜色");
        shellList.add("服务模式");
        shellList.add("车牌号");
        shellList.add("行驶证号码");
        shellList.add("roadworthiness sticker");
        shellList.add("座位数");
        shellList.add("关联司机");
        shellList.add("年检到期时间");