`
ysong_summer
  • 浏览: 16054 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

随便写写

阅读更多

package com.cmb.app.driverhome.util;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;

import javax.servlet.http.HttpServletRequest;

public class CommonUtils {
    public static void main(String[] args) {
        //Wed Jul 20 20:00:00 CST 2016
        String str = "Wed Jul 20 20:00:00 CST 2016";
        str = "NUll ";
        System.out.println(nullValueAsBlank(str));

        String numberFormatPattern = "0.00";
        String formatNumber = NumberFormatUtil.format(numberFormatPattern, 2d);
        System.out.println(formatNumber);

        String value = "2.3621245%";
        String tempVal = value.substring(0, value.length()-1);
        System.out.println(tempVal);
       
        String resource = "aa,vvv";
        String[] array = CommonUtils.split2array(resource);
        for(String s : array) {
            System.out.println(s);
        }
       
       
        String successRate = "69.99%";
        float rate = Float.parseFloat(successRate.substring(0, successRate.length() - 1));
        System.out.println("rate:" + rate);
        System.out.println(rate < 70f);
       
    }
   
    /**
     * 按照各种分隔符将字符串分割
     * @param source 待分割的字符串
     * @return
     */
    public static String[] split2array(String source) {
        Set<String> set = split2set(source);
        if(set == null || set.size() <= 0) return null;
        String[] array = new String[set.size()];
        int index = 0;
        for (String s : set) {
            array[index++] = s;
        }
        return array;
    }
   
    /**
     * 按照各种分隔符将字符串分割
     * @param source 待分割的字符串
     * @return
     */
    public static Set<String> split2set(String source) {
        if (source == null || source.equals("") || source.trim().length() == 0) {
            return null;
        }
        source = source.trim();
        Set<String> results = new TreeSet<String>();
        String split = " ";
        if (source.contains("\n")) {
            source = source.replace("\n", ",");
            split = ",";
        } else if (source.contains("\r")) {
            source = source.replace("\r", ",");
            split = ",";
        } else if (source.contains(",")) {
            split = ",";
        } else if (source.contains(",")) {
            split = ",";
        } else if (source.contains("、")) {
            split = "、";
        } else if (source.contains("|")) {
            split = "\\|";
        } else if (source.contains("/")) {
            split = "/";
        } else if (source.contains("\\")) {
            source = source.replace("\\", "/");
            split = "/";
        } else if (source.contains(".")) {
            split = "\\.";
        } else if (source.contains("。")) {
            split = "。";
        } else if (source.contains("-")) {
            split = "-";
        } else if (source.contains("_")) {
            split = "_";
        } else if (source.contains("——")) {
            split = "——";
        } else {
            split = " ";
        }
        String[] names = source.split(split);
        for (String s : names) {
            if(s.trim().equals("")) {
                continue;
            }
            results.add(s.trim());
        }
       
        return results;
    }
   
    public static class NumberFormatUtil{

        public static String format(String pattern, Number number){
            try {
                NumberFormat format = new DecimalFormat(pattern);
                return format.format(number);
            } catch (Exception e) {
                return null;
            }
        }
    }

    /*****************************/
    /**
     * EEE MMM dd HH:mm:ss zzz yyyy格式转GMT格式
     *
     * @param str
     * @param pattern
     * @return
     */
    public static String formatCST2GMT(String str, String pattern) {
        Date date = parse(str, "EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
        SimpleDateFormat format = null;
        if (null == pattern) format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        else format = new SimpleDateFormat(pattern);
        try {
            return format.format(date);
        } catch (Exception e) {
            return null;
        }
    }

    public static Date parse(String str, String pattern, Locale locale) {
        if (str == null || pattern == null) {
            return null;
        }
        try {
            return new SimpleDateFormat(pattern, locale).parse(str);
        } catch (ParseException e) {
            return null;
        }
    }

    public static String format(Date date, String pattern, Locale locale) {
        if (date == null || pattern == null) {
            return null;
        }
        return new SimpleDateFormat(pattern, locale).format(date);
    }

    /*****************************/

    /**
     * 毫秒数转字符串
     *
     * @param millis  毫秒数
     * @param pattern 要输出的日期字符串格式
     */
    public static String longToDateStr(long millis, String pattern) {
        Date date = new Date(millis);
        DateFormat format = new SimpleDateFormat(pattern);
        try {
            return format.format(date);
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * 毫秒数转字符串
     *
     * @param millis 1453338000000格式时间
     * @return yyyyMMddhhmm格式字符串
     */
    public static String longToDateStr(long millis) {
        return dateToStr(new Date(millis));
    }

    /**
     * 日期转字符串
     *
     * @param date 日期
     * @return yyyyMMddhhmm格式字符串
     */
    public static String dateToStr(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);

        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH) + 1;
        int day = c.get(Calendar.DAY_OF_MONTH);
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);

        return year + addZero(month) + addZero(day) + addZero(hour) + addZero(minute);
    }

    /**
     * 日期转字符串
     *
     * @param date    日期
     * @param pattern 字符串格式 如yyyy/MM/dd hh:mm
     */
    public static String dateToStr(Date date, String pattern) {
        try {
            DateFormat format = new SimpleDateFormat(pattern);
            return format.format(date);
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * 得到星期几:星期日0,星期一至星期六1~6
     *
     * @param dateStr 日期字符串
     * @return
     */
    public static String getDay(String dateStr) {
        return getDay(strToDate(dateStr));
    }

    /**
     * 得到星期几:星期日0,星期一至星期六1~6
     *
     * @param date 日期
     * @return
     */
    public static String getDay(Date date) {
        if (null == date) {
            return null;
        }
        return Integer.toString(date.getDay());
    }

    /**
     * 得到兼容的日期格式:yyyy/MM/dd或yyyy-MM-dd或yyyy.MM.dd或yyyyMMdd
     *
     * @param dateStr 日期字符串
     * @return
     */
    public static Date strToDate(String dateStr) {
        Date date = strToDate(dateStr, "yyyy/MM/dd");
        if (null == date) {
            date = strToDate(dateStr, "yyyy-MM-dd");
        }
        if (null == date) {
            date = strToDate(dateStr, "yyyy.MM.dd");
        }
        if (null == date) {
            date = strToDate(dateStr, "yyyyMMdd");
        }
        return date;
    }

    /**
     * 得到兼容的时间格式:yyyy/MM/dd HH:mm或yyyy-MM-dd HH:mm或yyyy.MM.dd HH:mm或yyyyMMdd
     * HH:mm
     *
     * @param dateStr 日期字符串
     * @return
     */
    public static Date strToDatetime(String dateStr) {
        Date date = strToDate(dateStr, "yyyy/MM/dd HH:mm");
        if (null == date) {
            date = strToDate(dateStr, "yyyy-MM-dd HH:mm");
        }
        if (null == date) {
            date = strToDate(dateStr, "yyyy.MM.dd HH:mm");
        }
        if (null == date) {
            date = strToDate(dateStr, "yyyyMMdd HH:mm");
        }
        return date;
    }

    /**
     * 字符串转日期
     *
     * @param dateStr 日期字符串
     * @param pattern 默认的日期格式:yyyy/MM/dd HH:mm 2016/05/25 20:10
     * @return
     */
    public static Date strToDateDefaultPattern(String dateStr) {
        return strToDate(dateStr, "yyyy/MM/dd HH:mm");
    }

    /**
     * 字符串转日期
     *
     * @param dateStr 日期字符串
     * @param pattern 日期的格式
     * @return
     */
    public static Date strToDate(String dateStr, String pattern) {
        DateFormat format = new SimpleDateFormat(pattern);
        try {
            return format.parse(dateStr);
        } catch (ParseException e) {
            return null;
        }
    }

    /**
     * 字符串转日期
     *
     * @param dateStr   待转换的日期字符串
     * @param oldFormat 待转换字符串的日期格式
     * @param newFormat 目标日期格式
     * @return
     */
    public static Date strToDate(String dateStr, String oldFormat, String newFormat) {
        return strToDate(dateStr, oldFormat, newFormat, 0);
    }

    /**
     * 字符串转日期
     *
     * @param dateStr   待转换的日期字符串
     * @param oldFormat 待转换字符串的日期格式
     * @param newFormat 目标日期格式
     * @param index     从字符串第几位开始解析
     */
    public static Date strToDate(String dateStr, String oldFormat, String newFormat, int index) {
        ParsePosition pos = new ParsePosition(index);
        DateFormat sdf = new SimpleDateFormat(oldFormat);
        Date date;
        try {
            date = sdf.parse(dateStr, pos);
        } catch (Exception e) {
            return null;
        }
        return date;
    }

    /**
     * 重新格式化日期字符串
     *
     * @param dateStr   原始日期字符串
     * @param oldFormat 原始字符串的日期格式
     * @param newFormat 返回字符串的日期格式
     */
    public static String dateTrans(String dateStr, String oldFormat, String newFormat) {
        return dateTrans(dateStr, oldFormat, newFormat, 0);
    }

    /**
     * 重新格式化日期字符串
     *
     * @param dateStr   原始日期字符串
     * @param oldFormat 原始字符串的日期格式
     * @param newFormat 返回字符串的日期格式
     * @param index     从字符串第几位开始解析
     */
    public static String dateTrans(String dateStr, String oldFormat, String newFormat, int index) {
        ParsePosition pos = new ParsePosition(index);
        DateFormat format = new SimpleDateFormat(oldFormat);
        Date date;
        try {
            date = format.parse(dateStr, pos);
        } catch (Exception e) {
            return null;
        }
        format = new SimpleDateFormat(newFormat);
        try {
            return format.format(date);
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * @param targetDiff 相差
     * @param target     天/小时/分 (参见Calendar中常量)
     */
    public static Date getDate(Date date, int targetDiff, int... target) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        if (target.length == 1) {
            calendar.add(target[0], targetDiff);
        } else {
            calendar.add(Calendar.DATE, targetDiff);
        }
        return calendar.getTime();
    }

    /***********************************************************/

    /***********************************************************/
    /**
     * double值保留2位小数
     *
     * @param number double值
     */
    public static Double getDoubleRadix(double number) {
        return getDoubleRadix(number, 2);
    }

    /**
     * 保留n为小数
     *
     * @param number double数值
     * @param radix  小数位
     * @return
     */
    public static double getDoubleRadix(double number, int radix) {
        if (radix > 0) {
            String radixformat = "0.";
            for (int i = 0; i < radix; i++) {
                radixformat += "0";
            }
            NumberFormat df = new DecimalFormat(radixformat);
            return new Double(df.format(number).toString());
        }
        return number;
    }

    /**
     * 字符串出现次数
     *
     * @param sub    子串
     * @param source 原串
     */
    public static int countInStr(String sub, String source) {
        int count = 0;
        int start = 0;
        while (source.indexOf(sub, start) >= 0 && start < source.length()) {
            count++;
            start = source.indexOf(sub, start) + sub.length();
        }
        return count;
    }

    /**
     * 格式化2位数字为00格式,如9格式化为09
     *
     * @param num 待格式话的数字
     */
    public static String addZero(int num) {
        return num <= 9 ? ("0" + num) : ("" + num);
    }

    /***********************************************************/
    public static String nullValueAsBlank(String str) {
        if (isEmpty(str)) {
            return null;
        }
        str = trim(str);
        return "null".equalsIgnoreCase(str) ? null : str;
    }

    /**
     * 去空格
     */
    public static String trim(String str, String... defaultValue) {
        if (str == null) return defaultValue.length == 0 ? "" : defaultValue[0] == null ? "" : defaultValue[0].trim();
        return str.toString().trim();
    }

    /**
     * 判断是否空字符
     */
    public static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }

    /**
     * 判断是否空数组
     */
    public static boolean isEmpty(Object[] array) {
        return array == null || array.length == 0;
    }

    /***********************************************************/
    /**
     * 从请求中获取某参数值
     */
    public static String getParamValue(String paramName, HttpServletRequest request) {
        return getParamValueDefault(paramName, request, "");
    }

    /**
     * 从请求中获取某参数值
     */
    public static String getParamValueDefault(String paramName, HttpServletRequest request, String... defaultValue) {
        String paramValue = request.getParameter(paramName);
        String value = trim(paramValue);
        if ("".equals(value) && defaultValue.length > 0) {
            return defaultValue[0];
        }
        return value;
    }

    /***********************************************************/
    /***
     * 计算总页数
     *
     * @param records  记录总数
     * @param pageSize 每页显示数量
     * @return 总页数
     */
    public static int calcuTotalPage(int records, int pageSize) {
        return (records / pageSize) + (records % pageSize == 0 ? 0 : 1);
    }
}


package com.cmb.app.driverhome.util.excelHandle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cmb.app.driverhome.util.ExcelUtil;

public abstract class ExcelCreateHandle {
   
    private static final Logger logger = LoggerFactory.getLogger(ExcelCreateHandle.class);

    public static String classPath = ExcelUtil.class.getResource("").getPath();

    public abstract void creatExcel(List list);  
   
    /**
     * 生成表格标题
     * @param workbook
     * @param sheet
     * @param style 标题样式
     * @param headers 标题:{{"列名","列宽"},{"列名","列宽"},...}
     * @throws Exception
     */
    public void createHeader(Workbook workbook, Sheet sheet, CellStyle style, String[][] headers) throws Exception {
        Row row = sheet.createRow(0);
        row.setHeightInPoints(28);
        // row.setRowStyle(style);       
        for (int i = 0, len = headers.length; i < len; i++) {
            String[] header = headers[i];
            Cell cell = row.createCell(i);
            sheet.setColumnWidth(i, Integer.valueOf(header[1]) * 256);
            // sheet.autoSizeColumn(0, true);
            cell.setCellValue(header[0]);
            cell.setCellStyle(style);
        }
    }
   
    /**
     * 表格标题style
     * @param workbook
     * @return
     */
    public CellStyle createHeaderStyle(Workbook workbook) {
        Font font = workbook.createFont();
        font.setBoldweight(Font.BOLDWEIGHT_BOLD); // 字体加粗
        font.setFontHeightInPoints((short)11);
        font.setFontName("宋体"); // 设置单元格字体
        //font.setColor(Font.COLOR_NORMAL); // 设置单元格字体的颜色

        CellStyle style = workbook.createCellStyle();
        style.setWrapText(true);
       
        //背景前景色
        //style.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index);
        style.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
       
       
        // 边框
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
       
        // 居中
        // style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
       
        // 字体
        style.setFont(font);
        return style;
    }   
   
    /**
     * 表格style
     * @param workbook
     * @return
     */
    public CellStyle createRowStyle(Workbook workbook) {
        Font font = workbook.createFont();
        font.setFontName("宋体"); // 设置单元格字体
        font.setColor(Font.COLOR_NORMAL); // 设置单元格字体的颜色
       
        CellStyle style = workbook.createCellStyle();
        style.setWrapText(true);
       
        // 背景前景
        // style.setFillForegroundColor(Color.LIME.index);
        // style.setFillBackgroundColor(Color.GREEN.index);
       
        // 边框
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
       
        // 居中
        // style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
       
        // 字体
        style.setFont(font);
        return style;
    }
   
    /**
     * 冻结第一列
     * @param sheet
     */
    public void createFreezePaneFirstCol(Sheet sheet) {
        sheet.createFreezePane(1, 0, 1, 0);
    }
   
    /**
     * 冻结第一行
     * @param sheet
     */
    public void createFreezePaneFirstRow(Sheet sheet) {
        sheet.createFreezePane(0, 1, 0, 1);
    }
   
   

    /**
     * 为单元格赋值并设置样式
     * @param workbook
     * @param row
     * @param cellValues
     * @param fontSize
     */
    public void setFontStyle(Workbook workbook, Row row, String[] cellValues, short fontSize) {
        Font font = workbook.createFont();
        font.setFontHeightInPoints(fontSize);// 字号
        font.setBoldweight(Font.BOLDWEIGHT_NORMAL);// 加粗
        font.setFontName("宋体");
       
        CellStyle style = workbook.createCellStyle();
        style.setWrapText(true);
        style.setFont(font);
        setPublicStyle(style);
       
        Cell cell = null;
        for (int i = 0; i < cellValues.length; i++) {
            cell = row.createCell(i);
            cell.setCellValue(cellValues[i]);
            cell.setCellStyle(style);
        }
    }

    /**
     * 设置公共样式:细边框,居中
     * @param style 公共样式:细边框,居中
     */
    public void setPublicStyle(CellStyle style) {
        setBorderStyle(style);
        setAlignmentCenter(style);
    }

    /**
     * 细边框
     * @param style
     */
    public void setBorderStyle(CellStyle style) {       
        style.setBorderTop(CellStyle.BORDER_THIN);// 上边框
        style.setBorderRight(CellStyle.BORDER_THIN);// 右边框
        style.setBorderBottom(CellStyle.BORDER_THIN);// 下边框
        style.setBorderLeft(CellStyle.BORDER_THIN);// 左边框

    }

    /**
     * 上下左右居中
     * @param style
     */
    public void setAlignmentCenter(CellStyle style) {
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);// 上下居中
        style.setAlignment(CellStyle.ALIGN_CENTER);// 左右居中
    }

    /**
     * 设置列宽
     * <p>Set the width (in units of 1/256th of a character width) </p>
     * @param sheet
     * @param columnWidths 列宽数组
     */
    public void setColumnWidth(Sheet sheet, int[] columnWidths) {
        for (int i = 0; i < columnWidths.length; i++) {
            sheet.setColumnWidth(i, columnWidths[i] * 256);
        }
    }

    /**
     * 生成excel
     * @param workbook
     * @param filename 文件名
     */
    public void outPutExcel(Workbook workbook, String filename) {
        try {
            FileOutputStream os = new FileOutputStream(filename);
            workbook.write(os);
            os.close();
        } catch (FileNotFoundException e) {
            logger.error("生成excel文件到指定路径.FileNotFoundException:" + e.getMessage());
        } catch (IOException e) {
            logger.error("生成excel文件到指定路径.IOException:" + e.getMessage());
        }
    }
   
    /**
     * 删除Excel
     * @param pathname
     * @return
     */
    public static boolean deleteExcel(String pathname) {
        File file = new File(pathname);
        // 判断目录或文件是否存在
        if (!file.exists()) { // 不存在返回 false
            return false;
        } else {
            // 判断是否为文件
            if (file.isFile() && file.exists()) {
                file.delete();
                return true;
            } else {
                return false;
            }
        }
    }  
}



package com.cmb.app.driverhome.util;

import com.cmb.app.driverhome.iodj.vo.GradeVO;
import com.cmb.app.driverhome.ticket.vo.SuddenTicketVO;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.util.CellRangeAddress;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.List;

public class ExcelUtil {

    public static String classPath = ExcelUtil.class.getResource("").getPath() + "\\workbook.xls";
    public static String fileName = "ticket.xls";
    public static String gradeExcelName = "总设评审积分查询.xls";
    private static String[] excelTitle = {"TICKET数据表单"};
    private static String[] fieldName = {"ID", "TICKET标题", "状态", "优先级", "ticket类型", "发生时间", "状所属系统", "创建人", "创建时间", "简要描述",};

    private static String[] gradeName = {"团队", "AS400", "S390", "DBA", "RS6000", "WINDOWS"};
    private static String[] gradeType = {"参与度积分", "有效建议积分"};

    public static void createIODJGradeExcel(List<String> reason, List<GradeVO> vos, Date beginTime, Date endTime) {
        System.out.println("**********classPath  ==" + classPath);
        // 创建新的Excel 工作簿
        HSSFWorkbook workbook = new HSSFWorkbook();
        // 如要新建一名为"TICKET"的工作表,其语句为:
        HSSFSheet sheet = workbook.createSheet("总设评审团队积分表");
        setGradeWidth(sheet);
        //合并单元格  起始行 起始列 结束行 结束咧
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, gradeName.length * 2 - 2));
        for (int i = 0; i < 5; i++) {
            sheet.addMergedRegion(new CellRangeAddress(1, 1, i * 2 + 1, i * 2 + 2));
        }

        HSSFRow row = sheet.createRow(0);
        row.setHeight((short) (3 * 256));
        String title = DateUtil.dateToString(beginTime) + "至" + DateUtil.dateToString(endTime) + "总设得分详情";
        titleStyle(workbook, row, new String[]{title});

        row = sheet.createRow(1);
        gradeTitleStyle(workbook, row, gradeName);

        row = sheet.createRow(2);
        gradeTypeStyle(workbook, row, gradeType);

        String[] dataAddStr = new String[gradeName.length * 2 - 1];
        String[] dataSubStr = new String[gradeName.length * 2 - 1];
        for (int i = 0; i < vos.size(); i++) {
            GradeVO vo = vos.get(i);
            dataAddStr[0] = "得分";
            dataSubStr[0] = "扣分";
            dataAddStr[i + 1] = vo.getAddGrade();
            dataSubStr[i + 1] = vo.getSubGrade();
        }

        dataStyle(workbook, sheet.createRow(3), dataAddStr);
        dataStyle(workbook, sheet.createRow(4), dataSubStr);

        FileOutputStream os;
        try {
            os = new FileOutputStream(classPath);
            workbook.write(os);
            os.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void createTicketExcel(List<SuddenTicketVO> list) {
        System.out.println("**********classPath  ==" + classPath);
        // 创建新的Excel 工作簿
        HSSFWorkbook workbook = new HSSFWorkbook();
        // 如要新建一名为"TICKET"的工作表,其语句为:
        HSSFSheet sheet = workbook.createSheet("TICKET");
        setWidth(sheet);
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, fieldName.length - 1));
        HSSFRow row = sheet.createRow(0);
        row.setHeight((short) (3 * 256));
        titleStyle(workbook, row, excelTitle);

        row = sheet.createRow(1);
        fieldStyle(workbook, row, fieldName);

        String[] dataStr = new String[fieldName.length];
        for (int i = 0; i < list.size(); i++) {
            row = sheet.createRow(i + 2);
            SuddenTicketVO vo = list.get(i);
            dataStr[0] = String.valueOf(vo.getId());
            dataStr[1] = vo.getTitle();
            dataStr[2] = vo.getStatus();
            dataStr[3] = vo.getPriority();
            dataStr[4] = vo.getTicketClass();
            dataStr[5] = vo.getHappenTimeStr();
            dataStr[6] = vo.getSystemClass();
            dataStr[7] = vo.getCreateBy();
            dataStr[8] = vo.getCreateTime();
            dataStr[9] = vo.getExpatiation();
            dataStyle(workbook, row, dataStr);
        }

        FileOutputStream os;
        try {
            os = new FileOutputStream(classPath);
            workbook.write(os);
            os.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 填充一行
     * @param row
     * @param str 要填充内容的数组

    public static void fillRow(HSSFRow row,String[] str,HSSFCell cell){
    for (int i = 0; i < str.length; i++) {
    cell = row.createCell(i);
    cell.setCellValue(str[i]);
    }
    }
     */

    /**
     * 标题格式
     *
     * @param cell
     */
    public static void titleStyle(HSSFWorkbook wb, HSSFRow row, String[] str) {
        HSSFCell cell = null;
        HSSFCellStyle style = wb.createCellStyle();
        HSSFFont f = wb.createFont();
        f.setFontHeightInPoints((short) 18);//字号
        f.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);//加粗
        style.setFont(f);
        publicStyle(style);
        for (int i = 0; i < str.length; i++) {
            cell = row.createCell(i);
            cell.setCellValue(str[i]);
            cell.setCellStyle(style);
        }
    }

    public static void fieldStyle(HSSFWorkbook wb, HSSFRow row, String[] str) {
        HSSFCell cell = null;
        HSSFCellStyle style = wb.createCellStyle();
        HSSFFont f = wb.createFont();
        f.setFontHeightInPoints((short) 14);//字号
        style.setFont(f);
        publicStyle(style);
        for (int i = 0; i < str.length; i++) {
            cell = row.createCell(i);
            cell.setCellValue(str[i]);
            cell.setCellStyle(style);
        }
    }

    public static void gradeTitleStyle(HSSFWorkbook wb, HSSFRow row, String[] str) {
        HSSFCell cell = null;
        HSSFCellStyle style = wb.createCellStyle();
        HSSFFont f = wb.createFont();
        f.setFontHeightInPoints((short) 14);//字号
        style.setFont(f);
        publicStyle(style);
        cell = row.createCell(0);
        cell.setCellValue(str[0]);
        cell.setCellStyle(style);
        for (int i = 1; i < str.length * 2 - 1; i = i + 2) {
            cell = row.createCell(i);
            cell.setCellValue(str[i / 2 + 1]);
            cell.setCellStyle(style);
            cell = row.createCell(i + 1);
            //cell.setCellValue(str[i/2+1]);
            cell.setCellStyle(style);
        }
    }

    public static void gradeTypeStyle(HSSFWorkbook wb, HSSFRow row, String[] str) {
        HSSFCell cell = null;
        HSSFCellStyle style = wb.createCellStyle();
        HSSFFont f = wb.createFont();
        f.setFontHeightInPoints((short) 12);//字号
        style.setFont(f);
        publicStyle(style);
        cell = row.createCell(0);
        cell.setCellValue("");
        cell.setCellStyle(style);

        for (int i = 1; i < gradeName.length * 2 - 1; i++) {
            cell = row.createCell(i);
            cell.setCellValue(i % 2 == 1 ? str[0] : str[1]);
            cell.setCellStyle(style);
        }
    }

    public static void dataStyle(HSSFWorkbook wb, HSSFRow row, String[] str) {
        HSSFCell cell = null;
        HSSFCellStyle style = wb.createCellStyle();
        HSSFFont f = wb.createFont();
        f.setFontHeightInPoints((short) 11);//字号
        style.setFont(f);
        publicStyle(style);
        for (int i = 0; i < str.length; i++) {
            cell = row.createCell(i);
            cell.setCellValue(str[i]);
            cell.setCellStyle(style);
        }
    }

    public static void publicStyle(HSSFCellStyle style) {
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);//下边框
        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框    
        style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框    
        style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框    
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);//左右居中   
        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//上下居中  
    }

    public static void setWidth(HSSFSheet sheet) {

        sheet.setColumnWidth(0, 10 * 256);
        sheet.setColumnWidth(1, 30 * 256);
        sheet.setColumnWidth(2, 15 * 256);
        sheet.setColumnWidth(3, 10 * 256);
        sheet.setColumnWidth(4, 10 * 256);
        sheet.setColumnWidth(5, 15 * 256);
        sheet.setColumnWidth(6, 15 * 256);
        sheet.setColumnWidth(7, 12 * 256);
        sheet.setColumnWidth(8, 35 * 256);
        sheet.setColumnWidth(9, 40 * 256);
    }

    public static void setGradeWidth(HSSFSheet sheet) {

        sheet.setColumnWidth(0, 10 * 256);
        sheet.setColumnWidth(1, 15 * 256);
        sheet.setColumnWidth(2, 15 * 256);
        sheet.setColumnWidth(3, 15 * 256);
        sheet.setColumnWidth(4, 15 * 256);
        sheet.setColumnWidth(5, 15 * 256);
        sheet.setColumnWidth(6, 15 * 256);
        sheet.setColumnWidth(7, 15 * 256);
        sheet.setColumnWidth(8, 15 * 256);
        sheet.setColumnWidth(9, 15 * 256);
        sheet.setColumnWidth(10, 15 * 256);
    }

    /**
     * 删除单元格
     *
     * @param classPath
     * @return
     */
    public static boolean deleteExcel(String classPath) {
        File file = new File(classPath);
        // 判断目录或文件是否存在
        if (!file.exists()) {  // 不存在返回 false
            return false;
        } else {
            // 判断是否为文件
            if (file.isFile() && file.exists()) {
                file.delete();
                return true;
            } else {
                return false;
            }
        }
    }

}



package com.cmb.app.driverhome.onlineplan.domain;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.cmb.app.driverhome.common.BaseDomain;

/**
 * 发布工前会内容(风险警示)
 */
public class OnlineRiskWarn extends BaseDomain{
    private Integer onlineProjectId;//项目表t_online_project主键id
    private String updateContent;//本次项目上线要更新的内容:此字段取消
    private String newContent;//本次上线内容是否为新业务:是/否
    private String riskWarnContent;//风险预警:项目如果发布失败,最坏的影响
    private String riskWarnBusiness;//风险预警:项目如果发布失败,影响的具体业务   
    private String emergencyPlan;//应急方案:项目如果发布失败,应对措施
    private String prepareWorkSysenv;//系统环境准备: 上线前必须完成系统环境准备的工作有哪些,是否已经准备妥当: 如网络路由开通,服务器、加密机准备等
    private String prepareWorkAppenv;//应用环境准备: 上线前必须完成应用环境的准备工作有哪些,是否已经准备妥当: 增加业务参数、增加作业条等
    private String applyContent;//上线申请:投产组长或相关的系统管理员是否已经清楚知道上线的时间
    private String businessCheck;//业务验证:业务部门的验证测试人员是否已经联系确认清楚
    private String innerNote;//行内通知:项目上线相关的业务通知是否已经发出
    private String outerNote;//行外通知:是否已经向项目涉及的第三方发出通知
    private String funcOutside;//本次上线功能是否对外开放:对外开放/不对外开放(即仅部署代码至服务器)
    private String channelCodeOperate;//是否涉及渠道码增删改:否/(如有请列出)
    private String jobBarOperate;//是否涉及作业条增删改:否/(如有请列出)
    public Integer getOnlineProjectId() {
        return onlineProjectId;
    }
    public void setOnlineProjectId(Integer onlineProjectId) {
        this.onlineProjectId = onlineProjectId;
    }
    public String getUpdateContent() {
        return updateContent;
    }
    public void setUpdateContent(String updateContent) {
        this.updateContent = updateContent;
    }
    public String getNewContent() {
        return newContent;
    }
    public void setNewContent(String newContent) {
        this.newContent = newContent;
    }
    public String getRiskWarnContent() {
        return riskWarnContent;
    }
    public void setRiskWarnContent(String riskWarnContent) {
        this.riskWarnContent = riskWarnContent;
    }
    public String getRiskWarnBusiness() {
        return riskWarnBusiness;
    }
    public void setRiskWarnBusiness(String riskWarnBusiness) {
        this.riskWarnBusiness = riskWarnBusiness;
    }
    public String getEmergencyPlan() {
        return emergencyPlan;
    }
    public void setEmergencyPlan(String emergencyPlan) {
        this.emergencyPlan = emergencyPlan;
    }
    public String getPrepareWorkSysenv() {
        return prepareWorkSysenv;
    }
    public void setPrepareWorkSysenv(String prepareWorkSysenv) {
        this.prepareWorkSysenv = prepareWorkSysenv;
    }
    public String getPrepareWorkAppenv() {
        return prepareWorkAppenv;
    }
    public void setPrepareWorkAppenv(String prepareWorkAppenv) {
        this.prepareWorkAppenv = prepareWorkAppenv;
    }
    public String getApplyContent() {
        return applyContent;
    }
    public void setApplyContent(String applyContent) {
        this.applyContent = applyContent;
    }
    public String getBusinessCheck() {
        return businessCheck;
    }
    public void setBusinessCheck(String businessCheck) {
        this.businessCheck = businessCheck;
    }
    public String getInnerNote() {
        return innerNote;
    }
    public void setInnerNote(String innerNote) {
        this.innerNote = innerNote;
    }
    public String getOuterNote() {
        return outerNote;
    }
    public void setOuterNote(String outerNote) {
        this.outerNote = outerNote;
    }
    public String getFuncOutside() {
        return funcOutside;
    }
    public void setFuncOutside(String funcOutside) {
        this.funcOutside = funcOutside;
    }
    public String getChannelCodeOperate() {
        return channelCodeOperate;
    }
    public void setChannelCodeOperate(String channelCodeOperate) {
        this.channelCodeOperate = channelCodeOperate;
    }
    public String getJobBarOperate() {
        return jobBarOperate;
    }
    public void setJobBarOperate(String jobBarOperate) {
        this.jobBarOperate = jobBarOperate;
    }
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
   
}



package com.cmb.app.driverhome.common;

import com.cmb.app.driverhome.util.CustomDateSerializer;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.io.Serializable;
import java.util.Date;

/**
 * @Description:
 * @Author: XiongLiangSheng
 * @CreateDate: 2014年1月10日 上午8:32:42
 * @Version: v1.0
 * Date        CR/DEFECT   Modified By    Description of change
 */
@SuppressWarnings("serial")
public abstract class BaseDomain implements Serializable {
    private Date createTime;//创建时间
    private Integer createBy;//创建人
    private Date updateTime;//修改时间
    private Integer updateBy;//修改人
    private Integer version;//版本
    private Boolean isActive;//true-未删除,-false-已删除

    @JsonSerialize(using = CustomDateSerializer.class)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getCreateBy() {
        return createBy;
    }

    public void setCreateBy(Integer createBy) {
        this.createBy = createBy;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(Integer updateBy) {
        this.updateBy = updateBy;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(Boolean isActive) {
        this.isActive = isActive;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

}



package com.cmb.app.driverhome.onlineplan.domain;

import com.cmb.app.driverhome.common.BaseDomain;
import com.cmb.app.driverhome.iodj.domain.User;
import com.cmb.app.driverhome.mbankGrayRelease.constant.GrayStatusEnum;
import com.cmb.app.driverhome.mbankGrayRelease.domain.DevPlatformCheck;
import com.cmb.app.driverhome.onlineplan.constant.ProjectReleaseMainPlatformEnum;
import com.cmb.app.driverhome.onlineplan.constant.ProjectReleaseRegionAreaEnum;
import com.cmb.app.driverhome.onlineplan.constant.ProjectReleaseStatusEnum;
import com.cmb.app.driverhome.onlineplan.constant.ProjectReleaseTypeEnum;
import com.cmb.app.driverhome.util.CustomDateSerializer;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.util.Date;
import java.util.List;

/**
 * @Description:
 * @Author: XiongLiangSheng
 * @CreateDate: 2014年4月1日 下午4:02:56
 * @Version: v1.0 Date CR/DEFECT Modified By Description of change
 */
public class OnlineProject extends BaseDomain {
    private static final long serialVersionUID = 5333789004284569253L;
    private Integer onlineProjectId;//主键
    private Integer onlinePeriodId;//期数主键
    private String projectNo;//项目编号
    private String projectName;//项目名称
    private Date onlineDate;//计划上线时间
    private String personInCharge;//负责人
    private String productionTeamLeader;//投产组长
    private Boolean impactCredit;//是否影响信用卡业务
    private String impactCreditBusinessContent;//影响信用卡业务内容
    private String teamName;//团队名称
    private Boolean cancelOnlinePlan;//取消上线计划
    private String errorInputMsg;//程序用来保存excel输入错误的提示信息
    private Integer status;//导入的时候,如果格式正确2,如果上线时间格式错误1
    private String processInstanceId;
    private String applyUpdateType;
    private String originalOnlineDate;//原始上线日期,不论格式对错
    private Boolean riskAssess;//是否进行了风险评估
    private String riskComment;//风险评估备注
    private Boolean isProblem; //是否存在问题
    private Boolean isGrayRelease;//是否灰度发布
    private Integer releaseType;//发布类型
    private Integer releaseStatus;//发布状态
    private String releaseStatusComment;//发布状态不是正常的时候,需要填写
    private Integer mainPlatform;//主办平台
    private Integer regionArea;//所属片区
    private Boolean batchImport;//项目是否来源于批量导入
    private Integer grayStatus;//灰度状态
    private Integer releaseScheduleId;//灰度发布日程安排表主键id
    /**
     * 整表导入新增的字段
     */
    private Boolean onMeeting;//是否上会
    private Date expectOnlineDate;//项目经理期望上线时间
    private String relatedProject;//关联项目
    private String timeDifference;//时间差(天)
    private String productionPerson;//上线投产人员
    private String qualityPerson;//质量管理员
    private String demandSubmitPerson;//需求提交人
    private String demandSubmitDepartment;//需求提交部门
    private String uatCheckConclusion;//UAT验收结论
    private String businessApply;//业务申请

    //扩展字段
    private String reportPeriod;//用于详情页面显示期数
    private String statusDesc;//status字段对应的描述信息
    private double riskScore;//风险评估得分
    private String riskGrade;//风险等级
    private int conditionId; //1=top35A重大发布;2=top35B重要发布
    private String releaseTypeDesc;//releaseType字段对应的描述信息
    private String releaseStatusDesc;//releaseStatus字段对应的描述信息
    private String mainPlatformDesc;//mainPlatform字段对应的描述信息
    private String regionAreaDesc;//regionArea字段对应的描述信息
    private String involvePlatform;//涉及平台
    private String grayStatusDesc;//grayStatus字段对应的描述信息

    private String taskId;
    private String taskName;
    private String judgeResult;

    //关联属性
    private List<OnlineProgram> onlinePrograms;
    private List<OnlineProblem> onlineProblems;
    private User dutyPerson;//负责人
    private List<DevPlatformCheck> devCheckList;//开发验证意见
    private List<DevPlatformCheck> platformCheckList;//平台管理员意见

    private OnlineRiskWarn onlineRiskWarn;//发布工前会内容(风险警示内容)
    public Boolean getIsProblem() {
        return isProblem;
    }

    public void setIsProblem(Boolean isProblem) {
        this.isProblem = isProblem;
    }

    public String getRiskComment() {
        return riskComment;
    }

    public void setRiskComment(String riskComment) {
        this.riskComment = riskComment;
    }

    public String getApplyUpdateType() {
        return applyUpdateType;
    }

    public void setApplyUpdateType(String applyUpdateType) {
        this.applyUpdateType = applyUpdateType;
    }

    public String getProcessInstanceId() {
        return processInstanceId;
    }

    public void setProcessInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    public Integer getOnlineProjectId() {
        return onlineProjectId;
    }

    public void setOnlineProjectId(Integer onlineProjectId) {
        this.onlineProjectId = onlineProjectId;
    }

    public Integer getOnlinePeriodId() {
        return onlinePeriodId;
    }

    public void setOnlinePeriodId(Integer onlinePeriodId) {
        this.onlinePeriodId = onlinePeriodId;
    }

    public String getProjectNo() {
        return projectNo;
    }

    public void setProjectNo(String projectNo) {
        this.projectNo = projectNo;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    @JsonSerialize(using = CustomDateSerializer.class)
    public Date getOnlineDate() {
        return onlineDate;
    }

    public void setOnlineDate(Date onlineDate) {
        this.onlineDate = onlineDate;
    }

    public String getPersonInCharge() {
        return personInCharge;
    }

    public void setPersonInCharge(String personInCharge) {
        this.personInCharge = personInCharge;
    }

    public String getProductionTeamLeader() {
        return productionTeamLeader;
    }

    public void setProductionTeamLeader(String productionTeamLeader) {
        this.productionTeamLeader = productionTeamLeader;
    }

    public Boolean getImpactCredit() {
        return impactCredit;
    }

    public void setImpactCredit(Boolean impactCredit) {
        this.impactCredit = impactCredit;
    }

    public String getImpactCreditBusinessContent() {
        return impactCreditBusinessContent;
    }

    public void setImpactCreditBusinessContent(String impactCreditBusinessContent) {
        this.impactCreditBusinessContent = impactCreditBusinessContent;
    }

    public String getTeamName() {
        return teamName;
    }

    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }

    public Boolean getCancelOnlinePlan() {
        return cancelOnlinePlan;
    }

    public void setCancelOnlinePlan(Boolean cancelOnlinePlan) {
        this.cancelOnlinePlan = cancelOnlinePlan;
    }

    public String getErrorInputMsg() {
        return errorInputMsg;
    }

    public void setErrorInputMsg(String errorInputMsg) {
        this.errorInputMsg = errorInputMsg;
    }

    public List<OnlineProgram> getOnlinePrograms() {
        return onlinePrograms;
    }

    public void setOnlinePrograms(List<OnlineProgram> onlinePrograms) {
        this.onlinePrograms = onlinePrograms;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getReportPeriod() {
        return reportPeriod;
    }

    public void setReportPeriod(String reportPeriod) {
        this.reportPeriod = reportPeriod;
    }

    public String getStatusDesc() {
        return statusDesc;
    }

    public void setStatusDesc(String statusDesc) {
        this.statusDesc = statusDesc;
    }

    public Boolean getRiskAssess() {
        return riskAssess;
    }

    public void setRiskAssess(Boolean riskAssess) {
        this.riskAssess = riskAssess;
    }

    public double getRiskScore() {
        return riskScore;
    }

    public void setRiskScore(double riskScore) {
        this.riskScore = riskScore;
    }

    public String getOriginalOnlineDate() {
        return originalOnlineDate;
    }

    public void setOriginalOnlineDate(String originalOnlineDate) {
        this.originalOnlineDate = originalOnlineDate;
    }

    public String getRiskGrade() {
        if (this.getRiskScore() == 0) {
            this.setRiskGrade("");
        } else if (this.getRiskScore() > 18) {
            this.setRiskGrade("重大");
        } else if (this.getRiskScore() < 14) {
            if (this.getConditionId() == 1) {
                this.setRiskGrade("重大");
            } else if (this.getConditionId() == 2) {
                this.setRiskGrade("重要");
            } else {
                this.setRiskGrade("普通");
            }
        } else {
            if (this.getConditionId() == 1) {
                this.setRiskGrade("重大");
            } else {
                this.setRiskGrade("重要");
            }
        }
        return riskGrade;
    }

    public void setRiskGrade(String riskGrade) {
        this.riskGrade = riskGrade;
    }

    public int getConditionId() {
        return conditionId;
    }

    public void setConditionId(int conditionId) {
        this.conditionId = conditionId;
    }

    public Boolean getIsGrayRelease() {
        return isGrayRelease;
    }

    public void setIsGrayRelease(Boolean isGrayRelease) {
        this.isGrayRelease = isGrayRelease;
    }

    public Integer getReleaseType() {
        return releaseType;
    }

    public void setReleaseType(Integer releaseType) {
        this.releaseType = releaseType;
    }

    public String getReleaseTypeDesc() {
        return ProjectReleaseTypeEnum.getName(releaseType);
    }

    public void setReleaseTypeDesc(String releaseTypeDesc) {
        this.releaseTypeDesc = releaseTypeDesc;
    }

    public Integer getReleaseStatus() {
        return releaseStatus;
    }

    public void setReleaseStatus(Integer releaseStatus) {
        this.releaseStatus = releaseStatus;
    }

    public String getReleaseStatusDesc() {
        return ProjectReleaseStatusEnum.getName(releaseStatus);
    }

    public void setReleaseStatusDesc(String releaseStatusDesc) {
        this.releaseStatusDesc = releaseStatusDesc;
    }

    public String getReleaseStatusComment() {
        return releaseStatusComment;
    }

    public void setReleaseStatusComment(String releaseStatusComment) {
        this.releaseStatusComment = releaseStatusComment;
    }

    public Integer getMainPlatform() {
        return mainPlatform;
    }

    public void setMainPlatform(Integer mainPlatform) {
        this.mainPlatform = mainPlatform;
    }

    public String getMainPlatformDesc() {
        return ProjectReleaseMainPlatformEnum.getName(mainPlatform);
    }

    public void setMainPlatformDesc(String mainPlatformDesc) {
        this.mainPlatformDesc = mainPlatformDesc;
    }

    public Integer getRegionArea() {
        return regionArea;
    }

    public void setRegionArea(Integer regionArea) {
        this.regionArea = regionArea;
    }

    public String getRegionAreaDesc() {
        return ProjectReleaseRegionAreaEnum.getName(regionArea);
    }

    public void setRegionAreaDesc(String regionAreaDesc) {
        this.regionAreaDesc = regionAreaDesc;
    }

    public String getInvolvePlatform() {
        return involvePlatform;
    }

    public void setInvolvePlatform(String involvePlatform) {
        this.involvePlatform = involvePlatform;
    }

    public Boolean getBatchImport() {
        return batchImport;
    }

    public void setBatchImport(Boolean batchImport) {
        this.batchImport = batchImport;
    }

    public List<OnlineProblem> getOnlineProblems() {
        return onlineProblems;
    }

    public void setOnlineProblems(List<OnlineProblem> onlineProblems) {
        this.onlineProblems = onlineProblems;
    }

    public Integer getGrayStatus() {
        return grayStatus;
    }

    public void setGrayStatus(Integer grayStatus) {
        this.grayStatus = grayStatus;
    }

    public String getGrayStatusDesc() {
        return GrayStatusEnum.getName(grayStatus);
    }

    public void setGrayStatusDesc(String grayStatusDesc) {
        this.grayStatusDesc = grayStatusDesc;
    }

    public User getDutyPerson() {
        return dutyPerson;
    }

    public void setDutyPerson(User dutyPerson) {
        this.dutyPerson = dutyPerson;
    }

    public Boolean getOnMeeting() {
        return onMeeting;
    }

    public void setOnMeeting(Boolean onMeeting) {
        this.onMeeting = onMeeting;
    }

    public Date getExpectOnlineDate() {
        return expectOnlineDate;
    }

    public void setExpectOnlineDate(Date expectOnlineDate) {
        this.expectOnlineDate = expectOnlineDate;
    }

    public String getRelatedProject() {
        return relatedProject;
    }

    public void setRelatedProject(String relatedProject) {
        this.relatedProject = relatedProject;
    }

    public String getTimeDifference() {
        return timeDifference;
    }

    public void setTimeDifference(String timeDifference) {
        this.timeDifference = timeDifference;
    }

    public String getProductionPerson() {
        return productionPerson;
    }

    public void setProductionPerson(String productionPerson) {
        this.productionPerson = productionPerson;
    }

    public String getQualityPerson() {
        return qualityPerson;
    }

    public void setQualityPerson(String qualityPerson) {
        this.qualityPerson = qualityPerson;
    }

    public String getDemandSubmitPerson() {
        return demandSubmitPerson;
    }

    public void setDemandSubmitPerson(String demandSubmitPerson) {
        this.demandSubmitPerson = demandSubmitPerson;
    }

    public String getDemandSubmitDepartment() {
        return demandSubmitDepartment;
    }

    public void setDemandSubmitDepartment(String demandSubmitDepartment) {
        this.demandSubmitDepartment = demandSubmitDepartment;
    }

    public String getUatCheckConclusion() {
        return uatCheckConclusion;
    }

    public void setUatCheckConclusion(String uatCheckConclusion) {
        this.uatCheckConclusion = uatCheckConclusion;
    }

    public String getBusinessApply() {
        return businessApply;
    }

    public void setBusinessApply(String businessApply) {
        this.businessApply = businessApply;
    }

    public Integer getReleaseScheduleId() {
        return releaseScheduleId;
    }

    public void setReleaseScheduleId(Integer releaseScheduleId) {
        this.releaseScheduleId = releaseScheduleId;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getJudgeResult() {
        return judgeResult;
    }

    public void setJudgeResult(String judgeResult) {
        this.judgeResult = judgeResult;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public List<DevPlatformCheck> getDevCheckList() {
        return devCheckList;
    }

    public void setDevCheckList(List<DevPlatformCheck> devCheckList) {
        this.devCheckList = devCheckList;
    }

    public List<DevPlatformCheck> getPlatformCheckList() {
        return platformCheckList;
    }

    public void setPlatformCheckList(List<DevPlatformCheck> platformCheckList) {
        this.platformCheckList = platformCheckList;
    }

    public OnlineRiskWarn getOnlineRiskWarn() {
        return onlineRiskWarn;
    }

    public void setOnlineRiskWarn(OnlineRiskWarn onlineRiskWarn) {
        this.onlineRiskWarn = onlineRiskWarn;
    }
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}



/**
 *
 */
package com.cmb.app.driverhome.onlineplan.domain;

import com.cmb.app.driverhome.common.BaseDomain;

/**
 * @Description:
 * @Author: XiongLiangSheng
 * @CreateDate: 2014年4月1日 下午4:11:56
 * @Version: v1.0 Date CR/DEFECT Modified By Description of change
 */
@SuppressWarnings("serial")
public class OnlineProgram extends BaseDomain {

    private Integer onlineModuleId;//主键id
    private Integer onlineProjectId;//项目id
    private String fireFlyRootName;//FireFly根分支名称
    private String label;//Label名称
    private String onlineScope;//使用范围

    /**
     * 整表导入新增的字段
     */
    private Integer serOfProject;//序号:label在项目中的序号
    private String programDutyPerson;//程序负责人
    private String labelType;//Label类型:源代码/执行码/文档基线
    private String systemPlatform;//系统平台

    public Integer getOnlineModuleId() {
        return onlineModuleId;
    }

    public void setOnlineModuleId(Integer onlineModuleId) {
        this.onlineModuleId = onlineModuleId;
    }

    public Integer getOnlineProjectId() {
        return onlineProjectId;
    }

    public void setOnlineProjectId(Integer onlineProjectId) {
        this.onlineProjectId = onlineProjectId;
    }

    public String getFireFlyRootName() {
        return fireFlyRootName;
    }

    public void setFireFlyRootName(String fireFlyRootName) {
        this.fireFlyRootName = fireFlyRootName;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getOnlineScope() {
        return onlineScope;
    }

    public void setOnlineScope(String onlineScope) {
        this.onlineScope = onlineScope;
    }

    public Integer getSerOfProject() {
        return serOfProject;
    }

    public void setSerOfProject(Integer serOfProject) {
        this.serOfProject = serOfProject;
    }

    public String getProgramDutyPerson() {
        return programDutyPerson;
    }

    public void setProgramDutyPerson(String programDutyPerson) {
        this.programDutyPerson = programDutyPerson;
    }

    public String getLabelType() {
        return labelType;
    }

    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }

    public String getSystemPlatform() {
        return systemPlatform;
    }

    public void setSystemPlatform(String systemPlatform) {
        this.systemPlatform = systemPlatform;
    }

}




package com.cmb.app.driverhome.onlineplan.util;

import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;

import com.cmb.app.driverhome.iodj.domain.User;
import com.cmb.app.driverhome.onlineplan.domain.OnlineProgram;
import com.cmb.app.driverhome.onlineplan.domain.OnlineProject;
import com.cmb.app.driverhome.util.CommonUtils;
import com.cmb.app.driverhome.util.excelHandle.ExcelCreateHandle;

public class RiskWarnProjectExcelhandle extends ExcelCreateHandle {   

    private static Logger logger = LoggerFactory.getLogger(RiskWarnProjectExcelhandle.class);   
   
    String[][] headers = new String[][]{
            {"序号", "5"}, {"项目编号", "9"}, {"项目名称", "30"}, {"上线日期", "11"}, {"负责人", "16"}, {"投产组长", "16"},
            {"序号", "5"}, {"FireFly根分支名称", "20"}, {"Label名称", "34"}, {"程序负责人", "16"}};
   
    private String excelname = "";   
   
    public void setExcelname(String excelname) {
        this.excelname = excelname;
    }
   
    @Override
    public void creatExcel(List list) {
        String excelpath = classPath + "\\" + excelname + ".xlsx";       
       
        // 产生表格
        Workbook workbook = new XSSFWorkbook();
        Sheet sheet = workbook.createSheet();
       
        // 表头行
        CellStyle headerStyle = createHeaderStyle(workbook);
        try {
            createHeader(workbook, sheet, headerStyle, headers);
        } catch (Exception e) {
            logger.error("createExcel.setHeader.Exception:" + e.getMessage());
        }       
       
        // 内容行
        CellStyle rowStyle = createRowStyle(workbook);
        for (int i = 0; i < list.size(); i++) {
            OnlineProject project = (OnlineProject) list.get(i);
            try {
                setRowContent(workbook, sheet, rowStyle, project);
            } catch (Exception e) {
                logger.error("createExcel.setRowContent.Exception:" + e.getMessage());
            }       
        }
       
        // 冻结单元格
        createFreezePaneFirstRow(sheet);
        // 输出excel
        outPutExcel(workbook, excelpath);
    }  
   
    private void setRowContent(Workbook workbook, Sheet sheet, CellStyle style, OnlineProject project) throws Exception {
        List<OnlineProgram> onlinePrograms = project.getOnlinePrograms();
        if (CollectionUtils.isEmpty(onlinePrograms)) {
            return;
        }
       
        String projectNo = project.getProjectNo();
        String projectName = project.getProjectName();
        String onlineDate = CommonUtils.dateToStr(project.getOnlineDate(), "yyyy-MM-dd");
        String personInCharge = project.getPersonInCharge();
        String productionTeamLeader = project.getProductionTeamLeader();
        User dutyPerson = project.getDutyPerson();
       
        for (int i = 0; i < onlinePrograms.size(); i++) {
            OnlineProgram program = onlinePrograms.get(i);
            String serOfProject = program.getSerOfProject() == null ? "" : program.getSerOfProject().toString();
            String fireFlyRootName = program.getFireFlyRootName();
            String label = program.getLabel();
            String programDutyPerson = program.getProgramDutyPerson() == null ? "" : program.getProgramDutyPerson();
           
            int index = sheet.getLastRowNum() + 1;
            Row row = sheet.createRow(index);
            row.setHeightInPoints(28);           
           
            Cell cell = row.createCell(0);// 序号
            cell.setCellValue(index);
            cell.setCellStyle(style);           

            cell = row.createCell(1);// 项目编号
            cell.setCellValue(projectNo);
            cell.setCellStyle(style);

            cell = row.createCell(2);// 项目名称
            cell.setCellValue(projectName);
            cell.setCellStyle(style);

            cell = row.createCell(3);// 上线日期
            cell.setCellValue(onlineDate);
            cell.setCellStyle(style);

            cell = row.createCell(4);// 负责人
           
            if (dutyPerson == null || CommonUtils.isEmpty(dutyPerson.getMobile())) {
                cell.setCellValue(personInCharge);
            } else {
                cell.setCellValue(personInCharge + "/" + dutyPerson.getMobile());
            }
            cell.setCellStyle(style);

            cell = row.createCell(5);// 投产组长
            cell.setCellValue(productionTeamLeader);
            cell.setCellStyle(style);
           
            cell = row.createCell(6);// label序号
            cell.setCellValue(serOfProject);
            cell.setCellStyle(style);

            cell = row.createCell(7);// FireFly根分支名称
            cell.setCellValue(fireFlyRootName);
            cell.setCellStyle(style);

            cell = row.createCell(8);// Label名称
            cell.setCellValue(label);
            cell.setCellStyle(style);           

            cell = row.createCell(9);// 程序负责人
            cell.setCellValue(programDutyPerson);
            cell.setCellStyle(style);

        }
    }
   
    private void setRowContent(Workbook workbook, Sheet sheet, List list) throws Exception {
        if (list == null || list.size() < 1) {
            return;
        }
       
        Font font = workbook.createFont();
        font.setFontName("宋体"); // 设置单元格字体
        font.setColor(Font.COLOR_NORMAL); // 设置单元格字体的颜色.
       
        CellStyle style = workbook.createCellStyle();
        style.setWrapText(true); // 自动换行
       
        // 背景前景
        // style.setFillForegroundColor(Color.LIME.index);
        // style.setFillBackgroundColor(Color.GREEN.index);
       
        // 边框
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
       
        //居中
        // style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
       
        // 字体
        style.setFont(font);
       
        Row row = null;
        Cell cell = null;
        /*
                设定合并单元格区域范围
          firstRow  0-based
          lastRow   0-based
          firstCol  0-based
          lastCol   0-based
          CellRangeAddress cra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
        */
        int firstRow = 1, lastRow = 1, firstCol = 0, lastCol = 0;
        for (int i = 0, len = list.size(); i < len; i++) {
            OnlineProject project = (OnlineProject) list.get(i);
            List<OnlineProgram> onlinePrograms = project.getOnlinePrograms();
            if (CollectionUtils.isEmpty(onlinePrograms)) {
                return;
            }
            int programCount = onlinePrograms.size();
            int projectIndex = sheet.getLastRowNum() + 1;
            int rowIndex = 1;
            row = sheet.createRow(projectIndex);           
           
            for (OnlineProgram program : onlinePrograms) {
                row.setHeight((short) (500 * programCount));
                // row.setRowStyle(style);

                lastRow += programCount - 2;
                CellRangeAddress rowCra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
                sheet.addMergedRegion(rowCra);           
                cell = row.createCell(0);// 序号
                cell.setCellValue(projectIndex);
                cell.setCellStyle(style);

                firstCol = 1;
                lastCol = 1;
                rowCra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
                sheet.addMergedRegion(rowCra);
                cell = row.createCell(1);// 项目编号
                cell.setCellValue(project.getProjectNo());
                cell.setCellStyle(style);

                firstCol = 2;
                lastCol = 2;
                rowCra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
                sheet.addMergedRegion(rowCra);
                cell = row.createCell(2);// 项目名称
                cell.setCellValue(project.getProjectName());
                cell.setCellStyle(style);

                firstCol = 3;
                lastCol = 3;
                rowCra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
                sheet.addMergedRegion(rowCra);
                cell = row.createCell(3);// 上线日期
                cell.setCellValue(CommonUtils.dateToStr(project.getOnlineDate(), "yyyy-MM-dd"));
                cell.setCellStyle(style);

                firstCol = 4;
                lastCol = 4;
                rowCra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
                sheet.addMergedRegion(rowCra);
                cell = row.createCell(4);// 负责人
                User dutyPerson = project.getDutyPerson();
                if (null != dutyPerson && !CommonUtils.isEmpty(dutyPerson.getMobile())) {
                    cell.setCellValue(project.getPersonInCharge() + "/" + dutyPerson.getMobile());
                } else {
                    cell.setCellValue(project.getPersonInCharge());
                }
                cell.setCellStyle(style);

                firstCol = 5;
                lastCol = 5;
                rowCra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
                sheet.addMergedRegion(rowCra);
                cell = row.createCell(5);// 投产组长
                cell.setCellValue(project.getProductionTeamLeader());
                cell.setCellStyle(style);
               
               
                cell = row.createCell(6);// label序号
                cell.setCellValue(program.getSerOfProject());
                cell.setCellStyle(style);
               
                cell = row.createCell(7);// FireFly根分支名称
                cell.setCellValue(program.getFireFlyRootName());
                cell.setCellStyle(style);
               
                cell = row.createCell(8);// Label名称
                cell.setCellValue(program.getLabel());
                cell.setCellStyle(style);
               
                cell = row.createCell(9);// 程序负责人
                cell.setCellValue(program.getProgramDutyPerson());
                cell.setCellStyle(style);
               
                //风险警示行
                row = sheet.createRow(lastRow++);           
                row.setHeight((short) (500 * 13));
               
                firstRow = lastRow;
                lastRow = firstRow;
                firstCol = 0;
                lastCol = 0;
                rowCra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
                sheet.addMergedRegion(rowCra);
                cell = row.createCell(1);// 风险警示
                cell.setCellValue("风险警示");
                cell.setCellStyle(style);
               
                firstCol = 1;
                lastCol = 9;
                rowCra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
                sheet.addMergedRegion(rowCra);
                cell = row.createCell(2);// 风险警示具体内容
                cell.setCellValue("风险警示具体内容");
                cell.setCellStyle(style);
            }           
           
           
        }
    }
   
    private List createList(){
        List<OnlineProject> list = new ArrayList<OnlineProject>();
       
        OnlineProject project = new OnlineProject();
        project.setOnlineProjectId(1);
        project.setProjectNo("P1600641");
        project.setProjectName("供应链金融系统二期第一阶段(风险)");
        project.setOnlineDate(new Date("2016/07/25"));
        project.setPersonInCharge("黄锋/80274620");
        project.setProductionTeamLeader("赵浩宇/01076540");       
       
        List<OnlineProgram> programs = new LinkedList<OnlineProgram>();
       
        OnlineProgram program = new OnlineProgram();
        //program.setSerOfProject(1);
        program.setFireFlyRootName("风险_信用风险_SCM");
        program.setLabel("LU52_P1600641_UAT_20160630_01");
        //program.setProgramDutyPerson("黄锋/80274620");
        programs.add(program);
       
        program = new OnlineProgram();
        //program.setSerOfProject(2);
        program.setFireFlyRootName("风险_信用风险_SCM");
        program.setLabel("P1600642_供应链_LR02.07_GTB_UAT_01_20160718_01");
        program.setProgramDutyPerson("项军洲/80274720");
        programs.add(program);
       
        project.setOnlinePrograms(programs);
        list.add(project);
       
        project = new OnlineProject();
        project.setOnlineProjectId(2);
        project.setProjectNo("T1600642");
        project.setProjectName("供应链");
        project.setOnlineDate(new Date("2016/07/26"));
        project.setPersonInCharge("黎桂林/80174782");
        project.setProductionTeamLeader("王俊麟/01039165");
       
        programs = new LinkedList<OnlineProgram>();
       
        program = new OnlineProgram();
        program.setSerOfProject(5);
        program.setFireFlyRootName("对公_企业年金_SCM");
        program.setLabel("LA04_MBank_UAT_803_V04.00_20160707_02");
        program.setProgramDutyPerson("邬丹/80274840");
        programs.add(program);
       
        program = new OnlineProgram();
        program.setSerOfProject(6);
        program.setFireFlyRootName("风险_信用风险_SCM");
        program.setLabel("LU34_UAT_20160719_01_T1615241");
        program.setProgramDutyPerson("顾才泉/00010951");
        programs.add(program);
       
        program = new OnlineProgram();
        program.setSerOfProject(4);
        program.setFireFlyRootName("风险_信贷_SCM");
        program.setLabel("RTCSAV03/S160630040(T1609961_R1M1_XD_UAT_03_20160630_01)");
        program.setProgramDutyPerson("郭涛/80074150");
        programs.add(program);
       
        project.setOnlinePrograms(programs);
        list.add(project);
       
        return list;
    }
   
    public static void main(String[] args) {
        RiskWarnProjectExcelhandle handle = new RiskWarnProjectExcelhandle();
        List list = handle.createList();                        
       
        String filename = "上线项目风险警示-2016年7月第4周";
        String excelpath = "C:\\Users\\20483\\Desktop\\" + filename + ".xlsx";
       
        Workbook workbook = new XSSFWorkbook();
        Sheet sheet = workbook.createSheet();
       
        // 表头行
        CellStyle headerStyle = handle.createHeaderStyle(workbook);
        try {
            handle.createHeader(workbook, sheet, headerStyle, handle.headers);
        } catch (Exception e) {
            logger.error("createExcel.setHeader.Exception:" + e.getMessage());
        }       
       
        // 内容行
        CellStyle rowStyle = handle.createRowStyle(workbook);
        for (int i = 0; i < list.size(); i++) {
            OnlineProject project = (OnlineProject) list.get(i);
            try {
                handle.setRowContent(workbook, sheet, rowStyle, project);
            } catch (Exception e) {
                logger.error("createExcel.setRowContent.Exception:" + e.getMessage());
            }       
        }
       
        // 冻结单元格
        handle.createFreezePaneFirstRow(sheet);       
        // 输出excel
        handle.outPutExcel(workbook, excelpath);
        System.out.println("done.");
    }
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics