Search in sources :

Example 1 with ExportLMExcel

use of com.kendy.excel.ExportLMExcel in project financial by greatkendy123.

the class LMController method exportSingleClubAction.

/**
 ********************************************************************************
 *
 *                                     导出Excel
 *
 **********************************************************************************
 */
/**
 * 导出单个俱乐部帐单
 *
 * @time 2017年11月22日
 * @param event
 */
public void exportSingleClubAction(ActionEvent event) {
    Club club = getSelectedClub();
    if (StringUtil.isBlank(club.getClubId())) {
        ShowUtil.show("请先选择俱乐部!");
        return;
    }
    String clubName = club.getName();
    String clubId = club.getClubId();
    String time = DataConstans.Date_Str;
    if (StringUtil.isBlank(time)) {
    // ShowUtil.show("导出失败! 您今天还没导入01场次的战绩,无法确认时间!!");
    // return;
    }
    List<LMDetailInfo> list = new ArrayList<>();
    ObservableList<LMDetailInfo> obList = tableLMDetail.getItems();
    if (obList != null && obList.size() > 0) {
        for (LMDetailInfo info : obList) {
            list.add(info);
        }
    } else {
        ShowUtil.show(clubName + "没有需要导出的数据!!");
        return;
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    String title = clubName + "帐单-" + sdf.format(new Date());
    log.info(title);
    String[] rowsName = new String[] { "场次", "战绩", "保险", "人数" };
    List<Object[]> dataList = new ArrayList<Object[]>();
    Object[] objs = null;
    for (LMDetailInfo info : list) {
        objs = new Object[rowsName.length];
        objs[0] = info.getLmDetailTableId();
        objs[1] = info.getLmDetailZJ();
        objs[2] = info.getLmDetailInsure();
        objs[3] = info.getLmDetailPersonCount();
        dataList.add(objs);
    }
    String[] rowsName2 = new String[] { "名称", "总战绩", "总保险", "总人数" };
    List<Object[]> sumList = new ArrayList<>();
    Object[] sumObjs = null;
    ObservableList<LMSumInfo> ob_List = tableLMSum.getItems();
    if (ob_List != null && ob_List.size() > 0) {
        for (LMSumInfo info : ob_List) {
            sumObjs = new Object[rowsName2.length];
            sumObjs[0] = StringUtil.nvl(info.getLmSumName(), "");
            sumObjs[1] = StringUtil.nvl(info.getLmSumZJ(), "");
            sumObjs[2] = StringUtil.nvl(info.getLmSumInsure(), "");
            sumObjs[3] = StringUtil.nvl(info.getLmSumPersonCount(), "");
            sumList.add(sumObjs);
        }
    }
    String out = "D:/" + title + System.currentTimeMillis();
    ExportLMExcel ex = new ExportLMExcel(title, rowsName, dataList, out, rowsName2, sumList);
    try {
        ex.export();
        log.info("导出单个联盟帐单完成!");
    } catch (Exception e) {
        ErrorUtil.err("导出单个联盟帐单失败", e);
    }
}
Also used : LMSumInfo(com.kendy.entity.LMSumInfo) ExportLMExcel(com.kendy.excel.ExportLMExcel) ArrayList(java.util.ArrayList) Date(java.util.Date) LMDetailInfo(com.kendy.entity.LMDetailInfo) Club(com.kendy.entity.Club) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

Club (com.kendy.entity.Club)1 LMDetailInfo (com.kendy.entity.LMDetailInfo)1 LMSumInfo (com.kendy.entity.LMSumInfo)1 ExportLMExcel (com.kendy.excel.ExportLMExcel)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1