导出明细
This commit is contained in:
parent
1319543251
commit
d55fca8eeb
|
|
@ -6,13 +6,10 @@ import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO;
|
|||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
|
||||
import com.engine.salary.mapper.datacollection.AddUpDeductionMapper;
|
||||
import com.engine.salary.util.excel.ExcelUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
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.XSSFWorkbook;
|
||||
import weaver.conn.mybatis.MyBatisFactory;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
|
@ -60,6 +57,7 @@ public class AddUpDeductionBiz extends BaseBean {
|
|||
|
||||
/**
|
||||
* 根据id获取
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -75,10 +73,11 @@ public class AddUpDeductionBiz extends BaseBean {
|
|||
|
||||
/**
|
||||
* 详情列表
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
public List<AddUpDeductionRecordDTO> recordList(AddUpDeductionQueryParam param){
|
||||
public List<AddUpDeductionRecordDTO> recordList(AddUpDeductionQueryParam param) {
|
||||
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
|
||||
try {
|
||||
AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class);
|
||||
|
|
@ -99,7 +98,7 @@ public class AddUpDeductionBiz extends BaseBean {
|
|||
try {
|
||||
AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class);
|
||||
mapper.insertData(param);
|
||||
sqlSession.commit();
|
||||
sqlSession.commit();
|
||||
} finally {
|
||||
sqlSession.close();
|
||||
}
|
||||
|
|
@ -139,71 +138,22 @@ public class AddUpDeductionBiz extends BaseBean {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* excel标题
|
||||
*/
|
||||
private final static List<String> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人");
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
public HSSFWorkbook export(AddUpDeductionQueryParam param) {
|
||||
public XSSFWorkbook export(AddUpDeductionQueryParam param) {
|
||||
|
||||
//excel标题
|
||||
List<String> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人");
|
||||
|
||||
//获取操作按钮资源
|
||||
List<List<String>> rowList = getExcelRowList(param);
|
||||
List<List<String>> rowList = getExcelRowList(title, param);
|
||||
|
||||
//获取excel
|
||||
return getWorkbook(rowList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取excel
|
||||
*
|
||||
* @param rowList 行列表
|
||||
* @return workbook
|
||||
*/
|
||||
private HSSFWorkbook getWorkbook(List<List<String>> rowList) {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
|
||||
// 设置title样式
|
||||
HSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
HSSFFont 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);
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
HSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
HSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||
cellStyle.setWrapText(true);
|
||||
|
||||
HSSFSheet sheet = workbook.createSheet("0");
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<String> infoList = rowList.get(rowIndex);
|
||||
HSSFRow row = sheet.createRow(rowIndex);
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
HSSFCell cell = row.createCell(cellIndex);
|
||||
cell.setCellType(CellType.STRING);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
cell.setCellValue(infoList.get(cellIndex));
|
||||
sheet.setColumnWidth(cellIndex, 35 * 256);
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
return ExcelUtil.genWorkbook(rowList);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -212,7 +162,7 @@ public class AddUpDeductionBiz extends BaseBean {
|
|||
*
|
||||
* @return 导出数据行集合
|
||||
*/
|
||||
private List<List<String>> getExcelRowList(AddUpDeductionQueryParam param) {
|
||||
private List<List<String>> getExcelRowList(List<String> title, AddUpDeductionQueryParam param) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<AddUpDeductionDTO> list = list(param);
|
||||
final List<List<String>> dataRowList = Optional.ofNullable(list)
|
||||
|
|
@ -241,6 +191,67 @@ public class AddUpDeductionBiz extends BaseBean {
|
|||
return rowList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出详情列表
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
public XSSFWorkbook exportDetail(AddUpDeductionQueryParam param) {
|
||||
|
||||
//获取操作按钮资源
|
||||
List<List<String>> rowList = getExcelRowDetailList(param);
|
||||
|
||||
//获取excel
|
||||
return ExcelUtil.genWorkbook(rowList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出详情
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
private List<List<String>> getExcelRowDetailList(AddUpDeductionQueryParam param) {
|
||||
|
||||
//excel标题
|
||||
List<String> title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "工号", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人");
|
||||
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
|
||||
//查询详细信息
|
||||
List<AddUpDeductionRecordDTO> list = recordList(param);
|
||||
final List<List<String>> dataRowList = Optional.ofNullable(list)
|
||||
.map(List::stream)
|
||||
.map(operatorStream -> operatorStream.map(dto -> {
|
||||
List<String> cellList = new ArrayList<>();
|
||||
cellList.add(Util.null2String(dto.getUsername()));
|
||||
cellList.add(Util.null2String(dto.getDeclareMonth() == null ? "" : formatter.format(dto.getDeclareMonth())));
|
||||
cellList.add(Util.null2String(dto.getTaxAgentName()));
|
||||
cellList.add(Util.null2String(dto.getDepartmentName()));
|
||||
cellList.add(Util.null2String(dto.getJobNum()));
|
||||
cellList.add(String.valueOf(dto.getAddUpChildEducation()));
|
||||
cellList.add(String.valueOf(dto.getAddUpContinuingEducation()));
|
||||
cellList.add(String.valueOf(dto.getAddUpHousingLoanInterest()));
|
||||
cellList.add(String.valueOf(dto.getAddUpHousingRent()));
|
||||
cellList.add(String.valueOf(dto.getAddUpSupportElderly()));
|
||||
return cellList;
|
||||
}).collect(Collectors.toList()))
|
||||
.orElse(Collections.emptyList());
|
||||
|
||||
List<List<String>> rowList = new ArrayList<>();
|
||||
rowList.add(title);
|
||||
rowList.addAll(dataRowList);
|
||||
return rowList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理导入数据
|
||||
*
|
||||
* @param pos
|
||||
*/
|
||||
public void handleImportData(List<AddUpDeduction> pos) {
|
||||
if (CollectionUtils.isEmpty(pos)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -5,13 +5,10 @@ import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO;
|
|||
import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam;
|
||||
import com.engine.salary.mapper.datacollection.AddUpSituationMapper;
|
||||
import com.engine.salary.util.excel.ExcelUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
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.XSSFWorkbook;
|
||||
import weaver.conn.mybatis.MyBatisFactory;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
|
@ -124,71 +121,19 @@ public class AddUpSituationBiz extends BaseBean {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* excel标题
|
||||
*/
|
||||
private final static List<String> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计收入额", "累计减除费用", "累计社保个人合计", "累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计企业(职业)年金及其他福利", "累计其他扣除", "累计免税收入", "累计准予扣除的捐赠额", "累计已预扣预缴税额");
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
public HSSFWorkbook export(AddUpSituationQueryParam param) {
|
||||
public XSSFWorkbook export(AddUpSituationQueryParam param) {
|
||||
|
||||
//获取操作按钮资源
|
||||
List<List<String>> rowList = getExcelRowList(param);
|
||||
|
||||
//获取excel
|
||||
return getWorkbook(rowList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取excel
|
||||
*
|
||||
* @param rowList 行列表
|
||||
* @return workbook
|
||||
*/
|
||||
private HSSFWorkbook getWorkbook(List<List<String>> rowList) {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
|
||||
// 设置title样式
|
||||
HSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
HSSFFont 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);
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
HSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
HSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||
cellStyle.setWrapText(true);
|
||||
|
||||
HSSFSheet sheet = workbook.createSheet("0");
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<String> infoList = rowList.get(rowIndex);
|
||||
HSSFRow row = sheet.createRow(rowIndex);
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
HSSFCell cell = row.createCell(cellIndex);
|
||||
cell.setCellType(CellType.STRING);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
cell.setCellValue(infoList.get(cellIndex));
|
||||
sheet.setColumnWidth(cellIndex, 35 * 256);
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
return ExcelUtil.genWorkbook(rowList);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -198,6 +143,9 @@ public class AddUpSituationBiz extends BaseBean {
|
|||
* @return 导出数据行集合
|
||||
*/
|
||||
private List<List<String>> getExcelRowList(AddUpSituationQueryParam param) {
|
||||
// excel标题
|
||||
final List<String> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计收入额", "累计减除费用", "累计社保个人合计", "累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计企业(职业)年金及其他福利", "累计其他扣除", "累计免税收入", "累计准予扣除的捐赠额", "累计已预扣预缴税额");
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<AddUpSituationDTO> list = list(param);
|
||||
final List<List<String>> dataRowList = Optional.ofNullable(list)
|
||||
|
|
@ -235,6 +183,61 @@ public class AddUpSituationBiz extends BaseBean {
|
|||
return rowList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出详情列表
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
public XSSFWorkbook exportDetail(AddUpSituationQueryParam param) {
|
||||
|
||||
//获取操作按钮资源
|
||||
List<List<String>> rowList = getExcelRowDetailList(param);
|
||||
|
||||
//获取excel
|
||||
return ExcelUtil.genWorkbook(rowList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出详情
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
private List<List<String>> getExcelRowDetailList(AddUpSituationQueryParam param) {
|
||||
|
||||
//excel标题
|
||||
List<String> title = Arrays.asList("税款所属期", "个税扣缴义务人", "部门", "工号", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人");
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
|
||||
//查询详细信息
|
||||
List<AddUpSituationRecordDTO> list = recordList(param);
|
||||
final List<List<String>> dataRowList = Optional.ofNullable(list)
|
||||
.map(List::stream)
|
||||
.map(operatorStream -> operatorStream.map(dto -> {
|
||||
List<String> cellList = new ArrayList<>();
|
||||
cellList.add(Util.null2String(dto.getTaxYearMonth() == null ? "" : formatter.format(dto.getTaxYearMonth())));
|
||||
cellList.add(Util.null2String(dto.getTaxAgentName()));
|
||||
cellList.add(Util.null2String(dto.getDepartmentName()));
|
||||
cellList.add(Util.null2String(dto.getJobNum()));
|
||||
cellList.add(String.valueOf(dto.getAddUpChildEducation()));
|
||||
cellList.add(String.valueOf(dto.getAddUpContinuingEducation()));
|
||||
cellList.add(String.valueOf(dto.getAddUpHousingLoanInterest()));
|
||||
cellList.add(String.valueOf(dto.getAddUpHousingRent()));
|
||||
cellList.add(String.valueOf(dto.getAddUpSupportElderly()));
|
||||
return cellList;
|
||||
}).collect(Collectors.toList()))
|
||||
.orElse(Collections.emptyList());
|
||||
|
||||
List<List<String>> rowList = new ArrayList<>();
|
||||
rowList.add(title);
|
||||
rowList.addAll(dataRowList);
|
||||
return rowList;
|
||||
}
|
||||
|
||||
|
||||
public void handleImportData(List<AddUpSituation> pos) {
|
||||
if (CollectionUtils.isEmpty(pos)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ import com.engine.common.entity.BizLogContext;
|
|||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.salary.biz.AddUpDeductionBiz;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AddUpDeductionExportCmd extends AbstractCommonCommand<HSSFWorkbook> {
|
||||
public class AddUpDeductionExportCmd extends AbstractCommonCommand<XSSFWorkbook> {
|
||||
|
||||
public AddUpDeductionExportCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
|
|
@ -23,11 +23,11 @@ public class AddUpDeductionExportCmd extends AbstractCommonCommand<HSSFWorkbook>
|
|||
}
|
||||
|
||||
@Override
|
||||
public HSSFWorkbook execute(CommandContext commandContext) {
|
||||
public XSSFWorkbook execute(CommandContext commandContext) {
|
||||
AddUpDeductionQueryParam addUpDeductionQueryParam = (AddUpDeductionQueryParam) params.get("addUpDeductionQueryParam");
|
||||
|
||||
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
||||
HSSFWorkbook workbook = addUpDeductionBiz.export(addUpDeductionQueryParam);
|
||||
XSSFWorkbook workbook = addUpDeductionBiz.export(addUpDeductionQueryParam);
|
||||
|
||||
return workbook;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.engine.salary.cmd.datacollection;
|
||||
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.salary.biz.AddUpDeductionBiz;
|
||||
import com.engine.salary.entity.datacollection.AddUpDeduction;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AddUpDeductionExportDetailCmd extends AbstractCommonCommand<XSSFWorkbook> {
|
||||
|
||||
public AddUpDeductionExportDetailCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook execute(CommandContext commandContext) {
|
||||
AddUpDeductionQueryParam queryParam = (AddUpDeductionQueryParam) params.get("addUpDeductionQueryParam");
|
||||
AddUpDeductionBiz biz = new AddUpDeductionBiz();
|
||||
|
||||
Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId();
|
||||
if (id == null) {
|
||||
throw new SalaryRunTimeException("id不能为空");
|
||||
}
|
||||
|
||||
AddUpDeduction po = biz.getById(id);
|
||||
if (po == null) {
|
||||
throw new SalaryRunTimeException(String.format("累计专项附加扣除不存在"+"[id:%s]", id));
|
||||
}
|
||||
|
||||
XSSFWorkbook workbook = biz.exportDetail(queryParam);
|
||||
|
||||
return workbook;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,12 +5,12 @@ import com.engine.common.entity.BizLogContext;
|
|||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.salary.biz.AddUpSituationBiz;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AddUpSituationExportCmd extends AbstractCommonCommand<HSSFWorkbook> {
|
||||
public class AddUpSituationExportCmd extends AbstractCommonCommand<XSSFWorkbook> {
|
||||
|
||||
public AddUpSituationExportCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
|
|
@ -23,10 +23,10 @@ public class AddUpSituationExportCmd extends AbstractCommonCommand<HSSFWorkbook>
|
|||
}
|
||||
|
||||
@Override
|
||||
public HSSFWorkbook execute(CommandContext commandContext) {
|
||||
public XSSFWorkbook execute(CommandContext commandContext) {
|
||||
AddUpSituationQueryParam queryParam = (AddUpSituationQueryParam) params.get("queryParam");
|
||||
AddUpSituationBiz biz = new AddUpSituationBiz();
|
||||
HSSFWorkbook workbook = biz.export(queryParam);
|
||||
XSSFWorkbook workbook = biz.export(queryParam);
|
||||
return workbook;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.engine.salary.cmd.datacollection;
|
||||
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.salary.biz.AddUpSituationBiz;
|
||||
import com.engine.salary.entity.datacollection.AddUpSituation;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AddUpSituationExportDetailCmd extends AbstractCommonCommand<XSSFWorkbook> {
|
||||
|
||||
public AddUpSituationExportDetailCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook execute(CommandContext commandContext) {
|
||||
AddUpSituationQueryParam queryParam = (AddUpSituationQueryParam) params.get("queryParam");
|
||||
AddUpSituationBiz biz = new AddUpSituationBiz();
|
||||
|
||||
|
||||
Long id = queryParam.getAccumulatedSituationId();
|
||||
if (id == null) {
|
||||
throw new SalaryRunTimeException("id不能为空");
|
||||
}
|
||||
|
||||
AddUpSituation po = biz.getById(id);
|
||||
if (po == null) {
|
||||
throw new SalaryRunTimeException(String.format("累计情况不存在"+"[id:%s]", id));
|
||||
}
|
||||
|
||||
XSSFWorkbook workbook = biz.exportDetail(queryParam);
|
||||
return workbook;
|
||||
}
|
||||
}
|
||||
|
|
@ -288,7 +288,7 @@
|
|||
,
|
||||
t1.declare_month,
|
||||
t1.employee_id,
|
||||
e.lastname as usename,
|
||||
e.lastname as username,
|
||||
d.departmentname AS departmentName,
|
||||
e.mobile,
|
||||
e.workcode as job_num,
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@
|
|||
(SELECT employee_id, MAX(tax_year_month) tax_year_month FROM hrsa_add_up_situation GROUP BY employee_id) t ON
|
||||
t.employee_id = t1.employee_id AND t.tax_year_month = t1.tax_year_month
|
||||
LEFT JOIN hrmresource e ON e.id = t1.employee_id
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.department
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
||||
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
|
||||
WHERE
|
||||
t1.delete_type = 0
|
||||
|
|
@ -639,7 +639,7 @@
|
|||
(SELECT employee_id, MAX(tax_year_month) tax_year_month FROM hrsa_add_up_situation GROUP BY employee_id) t ON
|
||||
t.employee_id = t1.employee_id AND t.tax_year_month = t1.tax_year_month
|
||||
LEFT JOIN hrmresource e ON e.id = t1.employee_id
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.department
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
||||
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
|
||||
WHERE
|
||||
t1.delete_type = 0
|
||||
|
|
@ -658,7 +658,7 @@
|
|||
(SELECT employee_id, MAX(tax_year_month) tax_year_month FROM hrsa_add_up_situation GROUP BY employee_id) t ON
|
||||
t.employee_id = t1.employee_id AND t.tax_year_month = t1.tax_year_month
|
||||
LEFT JOIN hrmresource e ON e.id = t1.employee_id
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.department
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
||||
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
|
||||
WHERE
|
||||
t1.delete_type = 0
|
||||
|
|
@ -675,7 +675,7 @@
|
|||
FROM
|
||||
hrsa_add_up_situation t1
|
||||
LEFT JOIN hrmresource e ON e.id = t1.employee_id
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.department
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
||||
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
|
||||
WHERE
|
||||
t1.delete_type = 0
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ public interface AddUpDeductionService {
|
|||
|
||||
Map<String, Object> list(Map<String, Object> params);
|
||||
|
||||
HSSFWorkbook export(Map<String, Object> params);
|
||||
XSSFWorkbook export(Map<String, Object> params);
|
||||
|
||||
Map<String, Object> getSearchCondition(Map<String, Object> params);
|
||||
|
||||
|
|
@ -17,4 +17,6 @@ public interface AddUpDeductionService {
|
|||
Map<String, Object> getDetailList(Map<String, Object> params);
|
||||
|
||||
Map<String, Object> preview(Map<String, Object> params);
|
||||
|
||||
XSSFWorkbook exportDetail(Map<String, Object> map);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -8,9 +8,11 @@ public interface AddUpSituationService {
|
|||
|
||||
Map<String, Object> list(Map<String, Object> params);
|
||||
|
||||
HSSFWorkbook export(Map<String, Object> params);
|
||||
XSSFWorkbook export(Map<String, Object> params);
|
||||
|
||||
Map<String, Object> getSearchCondition(Map<String, Object> params);
|
||||
|
||||
Map<String, Object> importAddUpSituation(Map<String, Object> params);
|
||||
|
||||
XSSFWorkbook exportDetail(Map<String, Object> params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.engine.salary.service.impl;
|
|||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.cmd.datacollection.*;
|
||||
import com.engine.salary.service.AddUpDeductionService;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
}
|
||||
|
||||
@Override
|
||||
public HSSFWorkbook export(Map<String, Object> params) {
|
||||
public XSSFWorkbook export(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new AddUpDeductionExportCmd(params, user));
|
||||
}
|
||||
|
||||
|
|
@ -38,4 +38,9 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
public Map<String, Object> preview(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new AddUpDeductionPreviewCmd(params, user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook exportDetail(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new AddUpDeductionExportDetailCmd(params, user));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.cmd.datacollection.AddUpSituationExportCmd;
|
||||
import com.engine.salary.cmd.datacollection.AddUpSituationGetSearchConditionCmd;
|
||||
import com.engine.salary.cmd.datacollection.AddUpSituationImportCmd;
|
||||
import com.engine.salary.cmd.datacollection.AddUpSituationListCmd;
|
||||
import com.engine.salary.cmd.datacollection.*;
|
||||
import com.engine.salary.service.AddUpSituationService;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -18,7 +15,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
|
|||
}
|
||||
|
||||
@Override
|
||||
public HSSFWorkbook export(Map<String, Object> params) {
|
||||
public XSSFWorkbook export(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new AddUpSituationExportCmd(params, user));
|
||||
}
|
||||
|
||||
|
|
@ -31,4 +28,9 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
|
|||
public Map<String, Object> importAddUpSituation(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new AddUpSituationImportCmd(params, user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook exportDetail(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new AddUpSituationExportDetailCmd(params, user));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package com.engine.salary.util.excel;
|
||||
|
||||
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 {
|
||||
/**
|
||||
* 生成excel
|
||||
* @param rowList
|
||||
* @return
|
||||
*/
|
||||
public static XSSFWorkbook genWorkbook(List<List<String>> rowList) {
|
||||
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("累计专项附加扣除明细");
|
||||
//自适应宽度
|
||||
sheet.autoSizeColumn(0, true);
|
||||
//默认列宽
|
||||
sheet.setDefaultColumnWidth(20);
|
||||
//默认行高
|
||||
sheet.setDefaultRowHeightInPoints(18);
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<String> infoList = rowList.get(rowIndex);
|
||||
XSSFRow row = sheet.createRow(rowIndex);
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
XSSFCell cell = row.createCell(cellIndex);
|
||||
cell.setCellType(CellType.STRING);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
cell.setCellValue(infoList.get(cellIndex));
|
||||
// sheet.setColumnWidth(cellIndex, 35 * 256);
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import com.engine.salary.util.ResponseResult;
|
|||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
|
|
@ -110,7 +111,7 @@ public class AddUpDeductionController {
|
|||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
map.put("addUpDeductionQueryParam", param);
|
||||
|
||||
HSSFWorkbook workbook = getService(user).export(map);
|
||||
XSSFWorkbook workbook = getService(user).export(map);
|
||||
|
||||
String fileName = null;
|
||||
try {
|
||||
|
|
@ -130,6 +131,38 @@ public class AddUpDeductionController {
|
|||
.header("Cache-Control", "no-cache").build();
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/exportDetail")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response exportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
|
||||
AddUpDeductionQueryParam param = buildParam(request);
|
||||
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
map.put("addUpDeductionQueryParam", param);
|
||||
|
||||
XSSFWorkbook workbook = getService(user).exportDetail(map);
|
||||
|
||||
String fileName = null;
|
||||
try {
|
||||
fileName = URLEncoder.encode("累计专项附加扣除明细.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();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private AddUpDeductionQueryParam buildParam(HttpServletRequest request) {
|
||||
AddUpDeductionQueryParam param = new AddUpDeductionQueryParam();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.engine.salary.service.impl.AddUpSituationServiceImpl;
|
|||
import com.engine.salary.util.ResponseResult;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
|
|
@ -106,9 +106,10 @@ public class AddUpSituationController {
|
|||
User user = HrmUserVarify.getUser(request, response);
|
||||
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
map.put("queryParam", new AddUpSituationQueryParam());
|
||||
AddUpSituationQueryParam queryParam = buildParam(request);
|
||||
map.put("queryParam", queryParam);
|
||||
|
||||
HSSFWorkbook workbook = getService(user).export(map);
|
||||
XSSFWorkbook workbook = getService(user).export(map);
|
||||
|
||||
String fileName = null;
|
||||
try {
|
||||
|
|
@ -128,6 +129,43 @@ public class AddUpSituationController {
|
|||
.header("Cache-Control", "no-cache").build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出明细
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("/exportDetail")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response exportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
AddUpSituationQueryParam queryParam = buildParam(request);
|
||||
map.put("queryParam", queryParam);
|
||||
|
||||
XSSFWorkbook workbook = getService(user).exportDetail(map);
|
||||
|
||||
String fileName = null;
|
||||
try {
|
||||
fileName = URLEncoder.encode("累计情况明细.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();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private AddUpSituationQueryParam buildParam(HttpServletRequest request) {
|
||||
AddUpSituationQueryParam param = new AddUpSituationQueryParam();
|
||||
|
|
|
|||
Loading…
Reference in New Issue