com.claudesoft.service.CarTbDetailed.java Source code

Java tutorial

Introduction

Here is the source code for com.claudesoft.service.CarTbDetailed.java

Source

package com.claudesoft.service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;

public class CarTbDetailed extends SendMail {

    public static void main(String[] args) throws InterruptedException {

        CarTbDetailed send = new CarTbDetailed();

        send.sendMailToJYDW();
    }

    public void sendMailToJYDW() throws InterruptedException {

        CarTbDetailed send;

        ArrayList<String> toArray;
        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<String>();
        toArray.add("liuxiaoming08@liaon.picc.com.cn");
        toArray.add("fuhui03@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21040200", "");
        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<String>();
        toArray.add("wangguanjun03@liaon.picc.com.cn");
        toArray.add("fuliping@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21040300", "");
        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("zhangye11@liaon.picc.com.cn");
        toArray.add("zhangjihong03@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21040400", "");
        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("liudonglin@liaon.picc.com.cn");
        toArray.add("zhaoyini@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21041100", "");
        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("liuwei59@liaon.picc.com.cn");
        toArray.add("liuling09@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21041170", "");
        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("mengwei06@liaon.picc.com.cn");
        toArray.add("jiangxiao01@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21041180", "");

        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("gaofengshan@liaon.picc.com.cn");
        toArray.add("guanfei01@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21042100", "");

        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("yuzhenguo@liaon.picc.com.cn");
        toArray.add("gelijun@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21042200", "");

        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("sunxiujuan@liaon.picc.com.cn");
        toArray.add("cuixiaohong01@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21042300", "");

        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("zhenghao08@liaon.picc.com.cn");
        toArray.add("wangguiyan@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21040390", "");
        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("sunqi@liaon.picc.com.cn");
        toArray.add("caishanshan01@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21040490", "");

        // 
        send = new CarTbDetailed();
        toArray = new ArrayList<>();
        toArray.add("quhui@liaon.picc.com.cn");
        toArray.add("yangxiyuan@liaon.picc.com.cn");
        send.sendMailToJYDW(toArray, "21040500", "");
    }

    private void sendMailToJYDW(ArrayList<String> toArray, String code, String name) throws InterruptedException {

        this.toArray = toArray;
        String dataSql = null;
        String sheetName = null;
        this.title = name + "";
        dataSql = "SELECT COMNAME," + "POLICYNO," + "RISKCODE," + "TO_CHAR(STARTDATE,'YYYY-MM-DD'),"
                + "TO_CHAR(ENDDATE,'YYYY-MM-DD')," + "BRANDNAME" + ",LICENSENO," + "FRAMENO," + "SUMPREMIUM,"
                + "INSUREDNAME," + "HANDLER1CODE," + "HANDLERCODE " + "FROM INFO_CAR_JYDWTBMX "
                + "WHERE TJRQ = (SELECT MAX(TJRQ) FROM INFO_CAR_JYDWTBMX) " + "AND COMCODE =" + code
                + "ORDER BY STARTDATE ";
        sheetName = name + "";
        createSheet(sheetName, dataSql, 3);
        send();
    }

    @Override
    void init() {
        ArrayList<String> toArray = new ArrayList<String>();
        ArrayList<String> ccArray = new ArrayList<String>();
        ccArray.add("quhui@liaon.picc.com.cn");
        ccArray.add("yuyang06@liaon.picc.com.cn");
        ccArray.add("liaon-fus-chexian@liaon.picc.com.cn");
        //        ccArray.add("zhouzhongqiang@liaon.picc.com.cn");
        this.toArray = toArray;
        this.ccArray = ccArray;
        this.columnCount = 12;
        this.tableName = "INFO_CAR_JYDWTBMX";

    }

    @Override
    void makeTableHead(HSSFSheet sheet) {
        HSSFRow row = null;
        HSSFCell cell = null;
        row = sheet.createRow(2);
        for (int j = 0; j < this.columnCount; j++) {

            //
            if (j == 0) {
                sheet.setColumnWidth(j, 10 * 256);
            } else {
                sheet.setColumnWidth(j, 15 * 256);
            }
            cell = row.createCell(j);
            cell.setCellStyle(makeTableHeadStyle());
        }

        cell = sheet.getRow(2).getCell(0);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(1);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(2);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(3);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(4);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(5);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(6);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(7);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(8);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(9);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(10);
        cell.setCellValue("");
        cell = sheet.getRow(2).getCell(11);
        cell.setCellValue("");

    }

    @Override
    void setDataTableStyle(int index, ResultSet rs, HSSFCell cell) throws SQLException {
        if (index == 0) {
            cell.setCellValue(rs.getString(index));
            cell.setCellStyle(this.boldValueCellStyle);
        } else {
            cell.setCellValue(rs.getString(index));
            cell.setCellStyle(this.valueCellStyle);
        }
    }

    @Override
    void makeXls() {
        // TODO Auto-generated method stub

    }

}