/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  javax.servlet.http.HttpServletRequest
 *  org.apache.commons.lang3.StringUtils
 */
package com.hst.framework.common;

import com.hst.framework.common.PaginationSupport;
import com.hst.framework.common.SimpleXlsCreator;
import com.hst.framework.constants.WebConstants;
import com.hst.framework.domain.UserDomain;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;

public class ExcelExportPOI {
    public static String createExpXls(PaginationSupport ps, HttpServletRequest request) throws Exception {
        return ExcelExportPOI.createExpXls(ps, null, request);
    }

    public static String createExpXls(PaginationSupport ps, String numberFormat, HttpServletRequest request) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String sNow = sdf.format(new Date());
        SimpleXlsCreator sxc = new SimpleXlsCreator();
        if (!StringUtils.isBlank((CharSequence)numberFormat)) {
            sxc.setNumberFormat(numberFormat);
        }
        String sFilePath = null;
        UserDomain userDomain = (UserDomain)request.getSession().getAttribute(WebConstants.SES_USER_INFO);
        sFilePath = userDomain != null ? String.valueOf(WebConstants.TEMP_PATH) + "/" + "commonxls/" + userDomain.getDlzh() + "/" + sNow + ".xls" : String.valueOf(WebConstants.TEMP_PATH) + "/" + "commonxls/" + "unknow/" + sNow + ".xls";
        if (ps.getHeads() != null) {
            sxc.appendHead(ps.getHeads());
        }
        if (ps.getFieldNames() != null) {
            sxc.appendBean(ps.getItems(), ps.getFieldNames());
        } else {
            sxc.append(ps.getItems());
        }
        sxc.createXls(sFilePath);
        request.setAttribute(WebConstants.DOWNLOAD_SRC_PATH, (Object)sFilePath);
        if (StringUtils.isNotBlank((CharSequence)ps.getExpFileName())) {
            request.setAttribute(WebConstants.DOWNLOAD_FILE_NAME, (Object)(String.valueOf(ps.getExpFileName()) + ".xls"));
        }
        return sFilePath;
    }
}
