2022-03-10 17:57:46 +08:00
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
2022-05-09 14:11:07 +08:00
|
|
|
import com.engine.salary.biz.EmployBiz;
|
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-05-09 14:11:07 +08:00
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
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-05-09 14:11:07 +08:00
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
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-05-09 14:11:07 +08:00
|
|
|
import java.util.*;
|
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) {
|
2022-05-09 14:11:07 +08:00
|
|
|
OtherDeductionQueryParam OtherDeductionQueryParam = (OtherDeductionQueryParam) params.get("queryParam");
|
|
|
|
|
|
|
|
|
|
OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz();
|
|
|
|
|
XSSFWorkbook workbook = OtherDeductionBiz.export(OtherDeductionQueryParam);
|
|
|
|
|
|
|
|
|
|
return workbook;
|
|
|
|
|
// return commandExecutor.execute(new OtherDeductionExportCmd(params, user));
|
2022-03-10 17:57:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public XSSFWorkbook exportDetail(Map<String, Object> params) {
|
2022-05-09 14:11:07 +08:00
|
|
|
|
|
|
|
|
OtherDeductionQueryParam queryParam = (OtherDeductionQueryParam) params.get("queryParam");
|
|
|
|
|
OtherDeductionBiz biz = new OtherDeductionBiz();
|
|
|
|
|
EmployBiz employBiz = new EmployBiz();
|
|
|
|
|
|
|
|
|
|
Long id = queryParam.getOtherTaxExemptDeductionId();
|
|
|
|
|
if (id == null) {
|
|
|
|
|
throw new SalaryRunTimeException("id不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OtherDeductionPO po = biz.getById(id);
|
|
|
|
|
if (po == null) {
|
|
|
|
|
throw new SalaryRunTimeException(String.format("其他免税扣除不存在"+"[id:%s]", id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = employBiz.getEmployeeByIds(Collections.singletonList(po.getEmployeeId()));
|
|
|
|
|
if (CollectionUtils.isEmpty(employeeList)) {
|
|
|
|
|
throw new SalaryRunTimeException("员工信息不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//构建参数
|
|
|
|
|
queryParam.setEmployeeId(po.getEmployeeId());
|
|
|
|
|
//申报月份
|
|
|
|
|
List<String> declareMonth = queryParam.getDeclareMonth();
|
|
|
|
|
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
|
|
|
|
queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return biz.exportDetail(queryParam);
|
|
|
|
|
|
|
|
|
|
// return commandExecutor.execute(new OtherDeductionExportDetailCmd(params, user));
|
2022-03-10 17:57:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
}
|