weaver-hrm-salary/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java

141 lines
5.9 KiB
Java
Raw Normal View History

2022-03-10 17:57:46 +08:00
package com.engine.salary.service.impl;
import com.engine.core.impl.Service;
2022-04-11 20:17:47 +08:00
import com.engine.salary.biz.OtherDeductionBiz;
2022-03-10 17:57:46 +08:00
import com.engine.salary.cmd.datacollection.*;
2022-04-28 17:44:26 +08:00
import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO;
import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam;
2022-04-11 20:17:47 +08:00
import com.engine.salary.entity.datacollection.po.OtherDeductionPO;
import com.engine.salary.exception.SalaryRunTimeException;
2022-04-28 17:44:26 +08:00
import com.engine.salary.mapper.datacollection.OtherDeductionMapper;
2022-03-10 17:57:46 +08:00
import com.engine.salary.service.OtherDeductionService;
2022-04-11 20:17:47 +08:00
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryI18nUtil;
2022-04-28 17:44:26 +08:00
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelComment;
import com.engine.salary.util.excel.ExcelUtil;
import com.google.common.collect.Lists;
2022-03-10 17:57:46 +08:00
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
2022-04-11 20:17:47 +08:00
import java.time.YearMonth;
2022-04-28 17:44:26 +08:00
import java.util.ArrayList;
import java.util.Arrays;
2022-04-11 20:17:47 +08:00
import java.util.List;
2022-03-10 17:57:46 +08:00
import java.util.Map;
2022-04-28 17:44:26 +08:00
import java.util.stream.Collectors;
2022-03-10 17:57:46 +08:00
public class OtherDeductionServiceImpl extends Service implements OtherDeductionService {
2022-04-28 17:44:26 +08:00
private OtherDeductionMapper getOtherDeductionMapper() {
return MapperProxyFactory.getProxy(OtherDeductionMapper.class);
}
2022-03-10 17:57:46 +08:00
@Override
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
return commandExecutor.execute(new OtherDeductionGetSearchConditionCmd(params, user));
}
@Override
public Map<String, Object> list(Map<String, Object> params) {
return commandExecutor.execute(new OtherDeductionListCmd(params, user));
}
@Override
public Map<String, Object> preview(Map<String, Object> params) {
return commandExecutor.execute(new OtherDeductionPreviewCmd(params, user));
}
@Override
public Map<String, Object> importData(Map<String, Object> params) {
return commandExecutor.execute(new OtherDeductionImportCmd(params, user));
}
@Override
public XSSFWorkbook export(Map<String, Object> params) {
return commandExecutor.execute(new OtherDeductionExportCmd(params, user));
}
@Override
public XSSFWorkbook exportDetail(Map<String, Object> params) {
return commandExecutor.execute(new OtherDeductionExportDetailCmd(params, user));
}
@Override
public Map<String, Object> getDetailList(Map<String, Object> params) {
return commandExecutor.execute(new OtherDeductionGetDetailListCmd(params, user));
}
2022-04-11 20:17:47 +08:00
@Override
public List<OtherDeductionPO> getOtherDeductionList(YearMonth declareMonth, List<Long> employeeIds) {
if (declareMonth == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传"));
}
OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz();
return OtherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).build());
}
2022-04-28 17:44:26 +08:00
@Override
public XSSFWorkbook downloadTemplate(OtherDeductionQueryParam param) {
// 1.工作簿名称
String sheetName = SalaryI18nUtil.getI18nLabel( 101604, "其他免税扣除导入模板");
String[] header = {
SalaryI18nUtil.getI18nLabel( 85429, "姓名"),
SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人"),
SalaryI18nUtil.getI18nLabel( 86185, "部门"),
SalaryI18nUtil.getI18nLabel( 86186, "手机号"),
SalaryI18nUtil.getI18nLabel( 86317, "工号"),
SalaryI18nUtil.getI18nLabel( 86318, "证件号码"),
SalaryI18nUtil.getI18nLabel( 86319, "入职日期"),
SalaryI18nUtil.getI18nLabel( 91238, "商业健康保险"),
SalaryI18nUtil.getI18nLabel( 91239, "税延养老保险"),
SalaryI18nUtil.getI18nLabel( 84500, "其他"),
SalaryI18nUtil.getI18nLabel( 91240, "准予扣除的捐赠额")
};
// 2.表头
List<Object> headerList = Arrays.asList(header);
// 获取其他免税扣除
List<OtherDeductionListDTO> list = getOtherDeductionMapper().list(param);
// 人员信息赋值
list.stream().map(m->{
// todo 身份证号
m.setIdNo(null);
return m;
}).collect(Collectors.toList());
List<List<Object>> rows = new ArrayList<>();
rows.add(headerList);
for (OtherDeductionListDTO dto : list) {
List<Object> row = new ArrayList<>();
row.add(dto.getUsername());
row.add(dto.getTaxAgentName());
row.add(dto.getDepartmentName());
row.add(dto.getMobile());
row.add(dto.getJobNum());
row.add(dto.getIdNo());
row.add(dto.getHiredate()+"");
row.add(dto.getBusinessHealthyInsurance());
row.add(dto.getTaxDelayEndowmentInsurance());
row.add(dto.getOtherDeduction());
row.add(dto.getDeductionAllowedDonation());
rows.add(row);
}
// 3.表数据
// 4.注释
List<ExcelComment> excelComments = Lists.newArrayList();
excelComments.add(new ExcelComment(0, 0, 3, 2, SalaryI18nUtil.getI18nLabel(100344, "必填")));
excelComments.add(new ExcelComment(1, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填")));
excelComments.add(new ExcelComment(7, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
excelComments.add(new ExcelComment(8, 0, 11, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
excelComments.add(new ExcelComment(9, 0, 12, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
excelComments.add(new ExcelComment(10, 0, 13, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
XSSFWorkbook book = ExcelUtil.genWorkbookV2(rows, sheetName, excelComments);
return book;
}
2022-03-10 17:57:46 +08:00
}