东方骏驰花名册快照table,及台账导出功能
parent
c3cb0dceec
commit
cfcc208fc4
@ -0,0 +1,14 @@
|
||||
package com.api.kqsolution.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/8/29 9:22 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Path("/kqsolution/resource")
|
||||
public class ResourceSnipAction extends com.engine.kqsolution.web.ResourceSnipAction {
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.engine.kqsolution.service;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/8/29 9:26 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface ResourceSnipService {
|
||||
|
||||
/**
|
||||
* @Description: 花名册快照
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2024/8/29 9:58 AM
|
||||
* @param: [monthDate, companyStartDate]
|
||||
* @return: java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
Map<String,Object> resourceSnip(String monthDate, String companyStartDate);
|
||||
|
||||
/**
|
||||
* 花名册快照导出
|
||||
* @param request
|
||||
* @param response
|
||||
* @param monthDate
|
||||
* @param companyStartDate
|
||||
* @return
|
||||
*/
|
||||
XSSFWorkbook snipshotExport(HttpServletRequest request, HttpServletResponse response, String monthDate, String companyStartDate);
|
||||
}
|
@ -0,0 +1,204 @@
|
||||
package com.engine.kqsolution.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cloudstore.dev.api.service.Service_DevTable;
|
||||
import com.cloudstore.eccom.constant.WeaBoolAttr;
|
||||
import com.cloudstore.eccom.pc.table.WeaTable;
|
||||
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||||
import com.cloudstore.eccom.pc.table.WeaTableType;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.kqsolution.service.ResourceSnipService;
|
||||
import com.engine.kqsolution.util.ExcelUtil;
|
||||
import com.engine.kqsolution.util.ResourceSnipUtils;
|
||||
import com.engine.organization.util.HrmI18nUtil;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.PageIdConst;
|
||||
import com.cloudstore.eccom.result.WeaResultMsg;
|
||||
import weaver.general.Util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/8/29 9:27 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ResourceSnipServiceImpl extends Service implements ResourceSnipService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> resourceSnip(String monthDate, String companyStartDate) {
|
||||
Map<String, Object> resultMap = new HashMap<>(4);
|
||||
|
||||
//当前花名册
|
||||
if("".equals(monthDate)){
|
||||
BaseBean bb = new BaseBean();
|
||||
String account = bb.getPropValue("jcsecond", "account");
|
||||
String bankField = bb.getPropValue("jcsecond", "bankField");
|
||||
String regresidentplace = bb.getPropValue("jcsecond", "regresidentplace");
|
||||
String femdate = bb.getPropValue("jcsecond", "femdate");
|
||||
WeaTable table = new WeaTable();
|
||||
String pageId = "73ed858b37304757987724e81d096ff2";
|
||||
table.setPageID(pageId);
|
||||
table.setPageUID(String.format("%s_%s",pageId,user.getUID()));
|
||||
String pageSize = PageIdConst.getPageSize(pageId, user.getUID());
|
||||
table.setPagesize(pageSize);
|
||||
String fields = "a.id,a.workcode,a.lastname,a.birthday,a.sex,a.subcompanyid1,a.departmentid,a.managerid,a.companystartdate," +
|
||||
" a.createdate,a.accumfundaccount,b."+account+" as account,b."+bankField+" as bankname,c."+femdate+" as femdate," +
|
||||
" a.startdate,a.enddate,a.jobtitle,a.status,a.educationlevel,a.mobile,a.certificatenum," +
|
||||
" a.nativeplace,b."+regresidentplace+" as regresidentplace";
|
||||
table.setBackfields(fields);
|
||||
String fromSql = " from hrmresource a\n" +
|
||||
" left join cus_fielddata b on a.id = b.id and b.scopeid = 1\n" +
|
||||
" left join cus_fielddata c on a.id = c.id and c.scopeid = -1";
|
||||
table.setSqlform(fromSql);
|
||||
if (!"".equals(companyStartDate)){
|
||||
String sqlWhere = " where 1=1 and a.companystartdate <= '"+companyStartDate+"'";
|
||||
table.setSqlwhere(sqlWhere);
|
||||
}
|
||||
|
||||
table.setSqlprimarykey("a.id");
|
||||
table.getColumns().add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "编号", "workcode"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "姓名", "lastname"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "出生日期", "birthday"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "性别", "sex").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectSexName"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "分部", "subcompanyid1").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectSubCompanyName"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "部门", "departmentid").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectDeptName"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "直接上级", "managerid").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectResourceName"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "入职日期", "companystartdate"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "创建日期", "createdate"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "公积金账户", "accumfundaccount"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "工资账户", "account").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "工资银行", "bankname").setDisplay(WeaBoolAttr.FALSE).setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectBankName").setOtherpara(bankField));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "首次参保时间", "femdate").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "合同开始日期", "startdate").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "合同结束日期", "enddate").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "岗位", "jobtitle").setDisplay(WeaBoolAttr.FALSE).setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectJobName"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "状态", "status").setDisplay(WeaBoolAttr.FALSE).setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectStatusName"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "学历", "educationlevel").setDisplay(WeaBoolAttr.FALSE).setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectEducName"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "电话", "mobile").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "身份证号", "certificatenum").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "籍贯", "nativeplace").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "户口所在地", "regresidentplace").setDisplay(WeaBoolAttr.FALSE));
|
||||
|
||||
table.setTableType(WeaTableType.NONE);
|
||||
WeaResultMsg result = new WeaResultMsg(false);
|
||||
result.putAll(table.makeDataResult());
|
||||
result.success();
|
||||
resultMap.putAll(result.getResultMap());
|
||||
return resultMap;
|
||||
|
||||
}else {
|
||||
//历史花名册
|
||||
WeaTable table = new WeaTable();
|
||||
String pageId = "89093fe16a7c4a38b26d4a47de791859";
|
||||
table.setPageID(pageId);
|
||||
table.setPageUID(String.format("%s_%s",pageId,user.getUID()));
|
||||
String pageSize = PageIdConst.getPageSize(pageId, user.getUID());
|
||||
table.setPagesize(pageSize);
|
||||
String fields = "t.id,t.gh,t.xm,t.csrq,t.xb,t.fb,t.bm,t.zjsj,t.rzrq,t.cjrq,t.gjjzh,t.gzzh,t.gzyx,t.sccbsj," +
|
||||
" t.htksrq,t.htjsrq,t.gw,t.zt,t.xl,t.dh,t.sfzh,t.jg,t.hkszd,t.cdrq";
|
||||
table.setBackfields(fields);
|
||||
String fromSql = " from uf_hmckz t";
|
||||
table.setSqlform(fromSql);
|
||||
String sqlWhere = " where 1=1 and t.cdrq = '"+monthDate+"'";
|
||||
table.setSqlwhere(sqlWhere);
|
||||
table.setSqlprimarykey("id");
|
||||
table.getColumns().add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "编号", "gh"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "姓名", "xm"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "出生日期", "csrq"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "性别", "xb"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "分部", "fb"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "部门", "bm"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "直接上级", "zjsj"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "入职日期", "rzrq"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "创建日期", "cjrq"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "公积金账户", "gjjzh"));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "工资账户", "gzzh").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "工资银行", "gzyx").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "首次参保时间", "sccbsj").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "合同开始日期", "htksrq").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "合同结束日期", "htjsrq").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "岗位", "gw").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "状态", "zt").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "学历", "xl").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "电话", "dh").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "身份证号", "sfzh").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "籍贯", "jg").setDisplay(WeaBoolAttr.FALSE));
|
||||
table.getColumns().add(new WeaTableColumn("10%", "户口所在地", "hkszd").setDisplay(WeaBoolAttr.FALSE));
|
||||
|
||||
table.setTableType(WeaTableType.NONE);
|
||||
WeaResultMsg result = new WeaResultMsg(false);
|
||||
result.putAll(table.makeDataResult());
|
||||
result.success();
|
||||
resultMap.putAll(result.getResultMap());
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook snipshotExport(HttpServletRequest request, HttpServletResponse response, String monthDate, String companyStartDate) {
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
String bankField = bb.getPropValue("jcsecond", "bankField");
|
||||
|
||||
//全字段导出
|
||||
List<Object> headerList = Arrays.asList("编号","姓名","出生日期","性别","分部","部门","直接上级","入职日期","创建日期","公积金账户","工资账户","工资银行","首次参保时间",
|
||||
"合同开始日期","合同结束日期","岗位","状态","学历","电话","身份证号","籍贯","户口所在地");
|
||||
|
||||
|
||||
Map<String, Object> map = resourceSnip(monthDate, companyStartDate);
|
||||
String dataKey = Util.null2String(map.get("datas"));
|
||||
|
||||
String getcounts = new Service_DevTable().getcounts(request, response, dataKey);
|
||||
JSONObject jsonObject = JSON.parseObject(getcounts);
|
||||
String count = jsonObject.getString("count");
|
||||
|
||||
String datas = new Service_DevTable().datas(request, response, dataKey, count, "[]", "", "", "1", "");
|
||||
jsonObject = JSON.parseObject(datas);
|
||||
List<Map<String, String>> snipshotList = (List<Map<String, String>>) jsonObject.get("datas");
|
||||
|
||||
List<List<Object>> rows = new LinkedList<>();
|
||||
boolean table = "".equals(monthDate);
|
||||
for (Map<String, String> snip : snipshotList) {
|
||||
List<Object> row = new LinkedList<>();
|
||||
row.add(table ? snip.get("workcodespan") : snip.get("gh"));
|
||||
row.add(table ? snip.get("lastnamespan") : snip.get("xm"));
|
||||
row.add(table ? snip.get("birthdayspan") : snip.get("csrq"));
|
||||
row.add(table ? snip.get("sexspan") : snip.get("xb"));
|
||||
row.add(table ? ResourceSnipUtils.selectSubCompanyName(snip.get("subcompanyid1")) : snip.get("fb"));
|
||||
row.add(table ? ResourceSnipUtils.selectDeptName(snip.get("departmentid")) : snip.get("bm"));
|
||||
row.add(table ? ResourceSnipUtils.selectResourceName(snip.get("managerid")) : snip.get("zjsj"));
|
||||
row.add(table ? snip.get("companystartdatespan") : snip.get("rzrq"));
|
||||
row.add(table ? snip.get("createdatespan") : snip.get("cjrq"));
|
||||
row.add(table ? snip.get("accumfundaccountspan") : snip.get("gjjzh"));
|
||||
row.add(table ? snip.get("accountspan") : snip.get("gzzh"));
|
||||
row.add(table ? ResourceSnipUtils.selectBankName(snip.get("subcompanyid1"),bankField) : snip.get("gzyx"));
|
||||
row.add(table ? snip.get("femdatespan") : snip.get("sccbsj"));
|
||||
row.add(table ? snip.get("startdatespan") : snip.get("htksrq"));
|
||||
row.add(table ? snip.get("enddatespan") : snip.get("htjsrq"));
|
||||
row.add(table ? ResourceSnipUtils.selectJobName(snip.get("jobtitle")) : snip.get("gw"));
|
||||
row.add(table ? ResourceSnipUtils.selectStatusName(snip.get("status")) : snip.get("zt"));
|
||||
row.add(table ? ResourceSnipUtils.selectEducName(snip.get("educationlevel")) : snip.get("xl"));
|
||||
row.add(table ? snip.get("mobilespan") : snip.get("dh"));
|
||||
row.add(table ? snip.get("certificatenumspan") : snip.get("sfzh"));
|
||||
row.add(table ? snip.get("nativeplacespan") : snip.get("jg"));
|
||||
row.add(table ? snip.get("regresidentplacespan") : snip.get("hkszd"));
|
||||
|
||||
rows.add(row);
|
||||
}
|
||||
|
||||
List<List<Object>> excelSheetData = new ArrayList<>();
|
||||
excelSheetData.add(headerList);
|
||||
excelSheetData.addAll(rows);
|
||||
String sheetName = "花名册快照"+monthDate;
|
||||
|
||||
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.engine.kqsolution.util;
|
||||
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ExcelUtil {
|
||||
|
||||
|
||||
public static XSSFWorkbook genWorkbookV2(List<List<Object>> rowList, String sheetName) {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
|
||||
// 设置title样式
|
||||
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
XSSFFont titleFont = workbook.createFont();
|
||||
titleFont.setFontName("仿宋");
|
||||
titleFont.setFontHeightInPoints((short) 15);
|
||||
titleCellStyle.setFont(titleFont);
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
titleCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());//背景色
|
||||
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||
cellStyle.setWrapText(true);
|
||||
|
||||
XSSFSheet sheet = workbook.createSheet(sheetName);
|
||||
//自适应宽度
|
||||
sheet.autoSizeColumn(0, true);
|
||||
//默认列宽
|
||||
sheet.setDefaultColumnWidth(25);
|
||||
//默认行高
|
||||
sheet.setDefaultRowHeightInPoints(18);
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<Object> infoList = rowList.get(rowIndex);
|
||||
XSSFRow row = sheet.createRow(rowIndex);
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
XSSFCell cell = row.createCell(cellIndex);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
Object o = infoList.get(cellIndex);
|
||||
if (o instanceof String) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Boolean) {
|
||||
cell.setCellType(CellType.BOOLEAN);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(o == null ? "" : o.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.engine.kqsolution.web;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kqsolution.service.ResourceSnipService;
|
||||
import com.engine.kqsolution.service.impl.ResourceSnipServiceImpl;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/8/29 9:22 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ResourceSnipAction {
|
||||
|
||||
private ResourceSnipService getService(User user) {
|
||||
return ServiceUtil.getService(ResourceSnipServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/snipshot")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String resourceSnip(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@QueryParam("monthDate") String monthDate,@QueryParam("companyStartDate") String companyStartDate){
|
||||
Map<String, Object> data = new HashMap<>(8);
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
data.put("datas",getService(user).resourceSnip(monthDate,companyStartDate));
|
||||
data.put("api_status", true);
|
||||
} catch (Exception e) {
|
||||
data.put("api_status", false);
|
||||
data.put("msg", "catch exception : " + e.getMessage());
|
||||
}
|
||||
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/snipshot/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response snipshotExport(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@QueryParam("monthDate") String monthDate,@QueryParam("companyStartDate") String companyStartDate) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getService(user).snipshotExport(request, response, monthDate,companyStartDate);
|
||||
String fileName = "花名册快照" + monthDate;
|
||||
try {
|
||||
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
StreamingOutput output = outputStream -> {
|
||||
workbook.write(outputStream);
|
||||
outputStream.flush();
|
||||
};
|
||||
response.setContentType("application/octet-stream");
|
||||
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue