2022-03-03 13:50:03 +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.AddUpDeductionBiz;
|
2022-05-09 14:11:07 +08:00
|
|
|
|
import com.engine.salary.biz.EmployBiz;
|
2022-03-08 15:40:26 +08:00
|
|
|
|
import com.engine.salary.cmd.datacollection.*;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.AddUpDeduction;
|
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.AddUpDeductionDTO;
|
2022-05-25 13:10:03 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
|
|
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
|
|
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.engine.salary.mapper.datacollection.AddUpDeductionMapper;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
import com.engine.salary.service.*;
|
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;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2022-05-25 13:10:03 +08:00
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2022-05-09 14:11:07 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-03-10 11:09:08 +08:00
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2022-05-20 14:41:42 +08:00
|
|
|
|
import weaver.general.Util;
|
2022-03-03 13:50:03 +08:00
|
|
|
|
|
2022-05-25 13:10:03 +08:00
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
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-03 13:50:03 +08:00
|
|
|
|
|
|
|
|
|
|
public class AddUpDeductionServiceImpl extends Service implements AddUpDeductionService {
|
|
|
|
|
|
|
2022-04-28 17:44:26 +08:00
|
|
|
|
private AddUpDeductionMapper getAddUpDeductionMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(AddUpDeductionMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-24 15:20:12 +08:00
|
|
|
|
private TaxAgentV2Service taxAgentService;
|
|
|
|
|
|
private SalaryAcctRecordService salaryAcctRecordService;
|
|
|
|
|
|
private SalaryAcctEmployeeService salaryAcctEmployeeService;
|
|
|
|
|
|
private SalaryEmployeeService salaryEmployeeService;
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-03 13:50:03 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, Object> list(Map<String, Object> params) {
|
2022-03-07 15:08:56 +08:00
|
|
|
|
return commandExecutor.execute(new AddUpDeductionListCmd(params, user));
|
2022-03-03 13:50:03 +08:00
|
|
|
|
}
|
2022-03-04 10:10:38 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-03-10 11:09:08 +08:00
|
|
|
|
public XSSFWorkbook export(Map<String, Object> params) {
|
2022-05-25 13:10:03 +08:00
|
|
|
|
|
|
|
|
|
|
Boolean chief = taxAgentService.isChief((long) user.getUID());
|
|
|
|
|
|
|
2022-05-09 14:11:07 +08:00
|
|
|
|
AddUpDeductionQueryParam addUpDeductionQueryParam = (AddUpDeductionQueryParam) params.get("addUpDeductionQueryParam");
|
|
|
|
|
|
|
|
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
|
XSSFWorkbook workbook = addUpDeductionBiz.export(addUpDeductionQueryParam);
|
|
|
|
|
|
|
|
|
|
|
|
return workbook;
|
|
|
|
|
|
// return commandExecutor.execute(new AddUpDeductionExportCmd(params, user));
|
2022-03-04 10:10:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
|
2022-03-07 15:08:56 +08:00
|
|
|
|
return commandExecutor.execute(new AddUpDeductionGetSearchConditionCmd(params, user));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, Object> importAddUpDeduction(Map<String, Object> params) {
|
|
|
|
|
|
return commandExecutor.execute(new AddUpDeductionImportCmd(params, user));
|
2022-03-04 10:10:38 +08:00
|
|
|
|
}
|
2022-03-08 15:40:26 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, Object> getDetailList(Map<String, Object> params) {
|
|
|
|
|
|
return commandExecutor.execute(new AddUpDeductionGetDetailListCmd(params, user));
|
|
|
|
|
|
}
|
2022-03-09 16:40:14 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, Object> preview(Map<String, Object> params) {
|
|
|
|
|
|
return commandExecutor.execute(new AddUpDeductionPreviewCmd(params, user));
|
|
|
|
|
|
}
|
2022-03-10 11:09:08 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public XSSFWorkbook exportDetail(Map<String, Object> params) {
|
2022-05-09 14:11:07 +08:00
|
|
|
|
AddUpDeductionQueryParam queryParam = (AddUpDeductionQueryParam) params.get("addUpDeductionQueryParam");
|
|
|
|
|
|
EmployBiz employBiz = new EmployBiz();
|
|
|
|
|
|
AddUpDeductionBiz biz = new AddUpDeductionBiz();
|
|
|
|
|
|
|
|
|
|
|
|
Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId();
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("id不能为空");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AddUpDeduction po = biz.getById(id);
|
|
|
|
|
|
if (po == null) {
|
2022-05-24 15:20:12 +08:00
|
|
|
|
throw new SalaryRunTimeException(String.format("累计专项附加扣除不存在" + "[id:%s]", id));
|
2022-05-09 14:11:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
XSSFWorkbook workbook = biz.exportDetail(queryParam);
|
|
|
|
|
|
|
|
|
|
|
|
return workbook;
|
|
|
|
|
|
// return commandExecutor.execute(new AddUpDeductionExportDetailCmd(params, user));
|
2022-03-10 11:09:08 +08:00
|
|
|
|
}
|
2022-04-11 20:17:47 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<AddUpDeduction> getAddUpDeductionList(YearMonth declareMonth, List<Long> employeeIds) {
|
|
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
|
if (declareMonth == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份、租户key必传"));
|
|
|
|
|
|
}
|
|
|
|
|
|
return addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).build());
|
|
|
|
|
|
}
|
2022-04-28 17:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam) {
|
|
|
|
|
|
|
|
|
|
|
|
String sheetName = SalaryI18nUtil.getI18nLabel(101603, "累计专项附加扣除导入模板");
|
|
|
|
|
|
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(86321, "累计子女教育"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(86323, "累计继续教育"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(86324, "累计住房贷款利息"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(86325, "累计住房租金"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(86326, "累计赡养老人"),
|
2022-05-20 14:41:42 +08:00
|
|
|
|
SalaryI18nUtil.getI18nLabel(105142, "累计大病医疗"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(105142, "累计婴幼儿照护")
|
2022-04-28 17:44:26 +08:00
|
|
|
|
};
|
|
|
|
|
|
List<Object> headerList = Arrays.asList(header);
|
|
|
|
|
|
// 2.表头
|
|
|
|
|
|
if (queryParam.getDeclareMonth() != null) {
|
|
|
|
|
|
queryParam.setDeclareMonth(queryParam.getDeclareMonth().stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取累计专项附加扣除
|
|
|
|
|
|
List<AddUpDeductionDTO> list = getAddUpDeductionMapper().list(queryParam);
|
|
|
|
|
|
// 人员信息赋值
|
|
|
|
|
|
list.forEach(m -> {
|
|
|
|
|
|
// todo 身份证号
|
|
|
|
|
|
m.setIdNo("");
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
|
|
|
|
rows.add(headerList);
|
|
|
|
|
|
for (AddUpDeductionDTO dto : list) {
|
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
2022-05-20 14:41:42 +08:00
|
|
|
|
row.add(Util.null2String(dto.getUsername()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getTaxAgentName()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getDepartmentName()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getMobile()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getJobNum()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getIdNo()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getHiredate()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getAddUpChildEducation()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getAddUpContinuingEducation()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getAddUpHousingLoanInterest()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getAddUpHousingRent()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getAddUpSupportElderly()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getAddUpIllnessMedical()));
|
|
|
|
|
|
row.add(Util.null2String(dto.getAddUpInfantCare()));
|
2022-04-28 17:44:26 +08:00
|
|
|
|
rows.add(row);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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, "输入数字")));
|
|
|
|
|
|
excelComments.add(new ExcelComment(11, 0, 14, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
|
|
|
|
|
excelComments.add(new ExcelComment(12, 0, 15, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
2022-05-20 14:41:42 +08:00
|
|
|
|
excelComments.add(new ExcelComment(13, 0, 16, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
2022-04-28 17:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XSSFWorkbook book = ExcelUtil.genWorkbookV2(rows, sheetName, excelComments);
|
|
|
|
|
|
|
|
|
|
|
|
return book;
|
|
|
|
|
|
}
|
2022-05-24 15:20:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public AddUpDeduction getById(Long id) {
|
|
|
|
|
|
return getAddUpDeductionMapper().getById(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
|
// * 获取作为修改者的最新记录
|
|
|
|
|
|
// * 说明:以人员id和个税口角义务人id去重
|
|
|
|
|
|
// *
|
|
|
|
|
|
// * @param currentEmployeeId
|
|
|
|
|
|
// * @return
|
|
|
|
|
|
// */
|
|
|
|
|
|
// private List<AddUpDeduction> getLastListByModifier(Long currentEmployeeId) {
|
|
|
|
|
|
// List<AddUpDeductionPO> list = new LambdaQueryChainWrapper<>(getAddUpDeductionMapper())
|
|
|
|
|
|
// .eq(AddUpDeductionPO::getDeleteType, 0)
|
|
|
|
|
|
// .eq(AddUpDeductionPO::getTenantKey)
|
|
|
|
|
|
// .eq(AddUpDeductionPO::getModifier, currentEmployeeId)
|
|
|
|
|
|
// .orderByDesc(AddUpDeductionPO::getDeclareMonth)
|
|
|
|
|
|
// .list();
|
|
|
|
|
|
// return list.stream()
|
|
|
|
|
|
// .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new));
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<AddUpDeductionDTO> listPage(AddUpDeductionQueryParam queryParam, Long employeeId) {
|
|
|
|
|
|
|
|
|
|
|
|
// 未开启分权或是薪酬模块总管理员
|
|
|
|
|
|
if (!taxAgentService.isOpenDevolution() || taxAgentService.isChief(employeeId)) {
|
2022-05-25 13:10:03 +08:00
|
|
|
|
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
2022-05-24 15:20:12 +08:00
|
|
|
|
List<AddUpDeductionDTO> list = getAddUpDeductionMapper().list(queryParam);
|
|
|
|
|
|
return new PageInfo<>(list, AddUpDeductionDTO.class);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<TaxAgentEmployeeDTO> taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId);
|
|
|
|
|
|
List<Long> taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
// List<AddUpDeductionPO> lastList = getLastListByModifier(employeeId);
|
|
|
|
|
|
List<AddUpDeductionDTO> list = getAddUpDeductionMapper().list(queryParam);
|
|
|
|
|
|
list = list.stream().filter(f ->
|
|
|
|
|
|
// 作为管理员
|
|
|
|
|
|
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
|
|
|
|
|
// 作为分管理员
|
|
|
|
|
|
|| TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId())
|
|
|
|
|
|
// 自己最后修改过的,则可以看到最新和其历史
|
|
|
|
|
|
// || lastList.stream().anyMatch(l -> l.getEmployeeId().equals(f.getEmployeeId()) && l.getTaxAgentId().equals(f.getTaxAgentId()) && !l.getDeclareMonth().isBefore(f.getDeclareMonth()))
|
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
// 填充总数和当页数据
|
|
|
|
|
|
// 分页参数
|
2022-05-25 13:10:03 +08:00
|
|
|
|
PageInfo<AddUpDeductionDTO> dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), AddUpDeductionDTO.class);
|
2022-05-24 15:20:12 +08:00
|
|
|
|
dtoPage.setTotal(list.size());
|
2022-05-25 13:10:03 +08:00
|
|
|
|
dtoPage.setList(SalaryPageUtil.subList(dtoPage.getPageNum(), dtoPage.getSize(), list));
|
|
|
|
|
|
return dtoPage;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-05-25 13:10:03 +08:00
|
|
|
|
public PageInfo<AddUpDeductionRecordDTO> recordListPage(AddUpDeductionQueryParam queryParam, Long employeeId) {
|
2022-05-24 15:20:12 +08:00
|
|
|
|
// 未开启分权或是薪酬模块总管理员
|
2022-05-25 13:10:03 +08:00
|
|
|
|
if (!taxAgentService.isOpenDevolution() || taxAgentService.isChief(employeeId)) {
|
|
|
|
|
|
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
|
List<AddUpDeductionRecordDTO> list = getAddUpDeductionMapper().recordList(queryParam);
|
|
|
|
|
|
return new PageInfo<>(list, AddUpDeductionRecordDTO.class);
|
2022-05-24 15:20:12 +08:00
|
|
|
|
} else {
|
2022-05-25 13:10:03 +08:00
|
|
|
|
List<TaxAgentEmployeeDTO> taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId);
|
|
|
|
|
|
List<Long> taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
// List<AddUpDeductionPO> lastList = getLastListByModifier(employeeId, tenantKey);
|
|
|
|
|
|
List<AddUpDeductionRecordDTO> list = getAddUpDeductionMapper().recordList(queryParam);
|
|
|
|
|
|
list = list.stream().filter(f ->
|
|
|
|
|
|
// 作为管理员
|
|
|
|
|
|
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
|
|
|
|
|
// 作为分管理员
|
|
|
|
|
|
|| TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId())
|
|
|
|
|
|
// 自己最后修改过的,则可以看到最新和其历史
|
|
|
|
|
|
// || lastList.stream().anyMatch(l -> l.getEmployeeId().equals(f.getEmployeeId()) && l.getTaxAgentId().equals(f.getTaxAgentId()) && !l.getDeclareMonth().isBefore(f.getDeclareMonth()))
|
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
// 分页参数
|
|
|
|
|
|
// 填充总数和当页数据
|
|
|
|
|
|
PageInfo<AddUpDeductionRecordDTO> dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), AddUpDeductionRecordDTO.class);
|
|
|
|
|
|
dtoPage.setTotal(list.size());
|
|
|
|
|
|
dtoPage.setList(SalaryPageUtil.subList(dtoPage.getPageNum(), dtoPage.getSize(), list));
|
|
|
|
|
|
return dtoPage;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void export(Map<String, Object> map, String username, String eteamsId, boolean isChief, AddUpDeductionQueryParam queryParam, Long employeeId, String tenantKey) {
|
|
|
|
|
|
List<ExcelSheetData> sheetList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
ExcelSheetData excelSheetData = new ExcelSheetData();
|
|
|
|
|
|
|
|
|
|
|
|
String nameI18n = SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85380, "累计专项附加扣除");
|
|
|
|
|
|
// 1.工作簿名称
|
|
|
|
|
|
excelSheetData.setSheetName(nameI18n);
|
|
|
|
|
|
String[] header = {
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85429, "姓名"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86184, "个税扣缴义务人"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86185, "部门"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86186, "手机号"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86317, "工号"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86318, "证件号码"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86319, "入职日期"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86321, "累计子女教育"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86323, "累计继续教育"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86324, "累计住房贷款利息"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86325, "累计住房租金"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86326, "累计赡养老人"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 105142, "累计大病医疗"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 117732, "累计婴幼儿照护")
|
|
|
|
|
|
};
|
|
|
|
|
|
// 2.表头
|
|
|
|
|
|
excelSheetData.setHeaders(Collections.singletonList(header));
|
|
|
|
|
|
queryParam.setDeclareMonthDate(CollectionUtils.emptyIfNull(queryParam.getDeclareMonth()).stream().map(e-> LocalDate.of(e.getYear(),e.getMonthValue(),1)).collect(Collectors.toList()));
|
|
|
|
|
|
// 获取累计专项附加扣除
|
|
|
|
|
|
List<AddUpDeductionListDTO> list = addUpDeductionMapper.list(queryParam, tenantKey);
|
|
|
|
|
|
|
|
|
|
|
|
// 开启分权并且不是薪酬模块总管理员
|
|
|
|
|
|
if (taxAgentService.isOpenDevolution(tenantKey) && !isChief) {
|
|
|
|
|
|
List<TaxAgentEmployeeDTO> taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId, tenantKey);
|
2022-05-24 15:20:12 +08:00
|
|
|
|
List<Long> taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId, tenantKey).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
List<AddUpDeductionPO> lastList = getLastListByModifier(employeeId, tenantKey);
|
|
|
|
|
|
list = list.stream().filter(f ->
|
|
|
|
|
|
// 作为管理员
|
|
|
|
|
|
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
|
|
|
|
|
// 作为分管理员
|
|
|
|
|
|
|| TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId())
|
|
|
|
|
|
// 自己最后修改过的,则可以看到最新和其历史
|
2022-05-25 13:10:03 +08:00
|
|
|
|
|| lastList.stream().anyMatch(l->l.getEmployeeId().equals(f.getEmployeeId()) && l.getTaxAgentId().equals(f.getTaxAgentId()) && !l.getDeclareMonth().isBefore(f.getDeclareMonth()))
|
2022-05-24 15:20:12 +08:00
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
}
|
2022-05-25 13:10:03 +08:00
|
|
|
|
List<SimpleUserInfo> simpleUserInfos = salaryEmployeeService.listByEmployeeIds(list.stream().map(AddUpDeductionListDTO::getEmployeeId).collect(Collectors.toList()), tenantKey);
|
|
|
|
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
|
|
|
|
for (AddUpDeductionListDTO 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(DataCollectionBO.getIdNo(dto.getEmployeeId(), simpleUserInfos));
|
|
|
|
|
|
row.add(dto.getHiredate()+"");
|
|
|
|
|
|
row.add(dto.getAddUpChildEducation());
|
|
|
|
|
|
row.add(dto.getAddUpContinuingEducation());
|
|
|
|
|
|
row.add(dto.getAddUpHousingLoanInterest());
|
|
|
|
|
|
row.add(dto.getAddUpHousingRent());
|
|
|
|
|
|
row.add(dto.getAddUpSupportElderly());
|
|
|
|
|
|
row.add(dto.getAddUpIllnessMedical());
|
|
|
|
|
|
row.add(dto.getAddUpInfantCare());
|
|
|
|
|
|
rows.add(row);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 3.表数据
|
|
|
|
|
|
excelSheetData.setRows(rows);
|
|
|
|
|
|
|
|
|
|
|
|
sheetList.add(excelSheetData);
|
|
|
|
|
|
|
|
|
|
|
|
salaryBatchService.simpleExportExcel(ExportExcelInfo.builder()
|
|
|
|
|
|
.bizId(map.get("biz").toString())
|
|
|
|
|
|
.flag(true)
|
|
|
|
|
|
.userId(employeeId)
|
|
|
|
|
|
.eteamsId(eteamsId)
|
|
|
|
|
|
.tenantKey(tenantKey)
|
|
|
|
|
|
.operator(username)
|
|
|
|
|
|
.module(map.get("module").toString())
|
|
|
|
|
|
.fileName(nameI18n + SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now()))
|
|
|
|
|
|
.handlerName(map.get("function").toString())
|
|
|
|
|
|
.dataType(nameI18n)
|
|
|
|
|
|
.function(map.get("function").toString()).build(), sheetList);
|
2022-05-24 15:20:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-05-25 13:10:03 +08:00
|
|
|
|
public void downloadTemplate(Map<String, Object> map, String username, String eteamsId, boolean isChief, AddUpDeductionQueryParam queryParam, Long employeeId, String tenantKey) {
|
|
|
|
|
|
List<ExcelSheetData> sheetList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
ExcelSheetData excelSheetData = new ExcelSheetData();
|
|
|
|
|
|
|
|
|
|
|
|
String nameI18n = SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 101603, "累计专项附加扣除导入模板");
|
|
|
|
|
|
// 1.工作簿名称
|
|
|
|
|
|
excelSheetData.setSheetName(nameI18n);
|
|
|
|
|
|
String[] header = {
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85429, "姓名"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86184, "个税扣缴义务人"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86185, "部门"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86186, "手机号"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86317, "工号"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86318, "证件号码"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86319, "入职日期"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86321, "累计子女教育"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86323, "累计继续教育"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86324, "累计住房贷款利息"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86325, "累计住房租金"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86326, "累计赡养老人"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 105142, "累计大病医疗"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 117732, "累计婴幼儿照护")
|
|
|
|
|
|
};
|
|
|
|
|
|
// 2.表头
|
|
|
|
|
|
excelSheetData.setHeaders(Collections.singletonList(header));
|
|
|
|
|
|
queryParam.setDeclareMonthDate(CollectionUtils.emptyIfNull(queryParam.getDeclareMonth()).stream().map(e-> LocalDate.of(e.getYear(),e.getMonthValue(),1)).collect(Collectors.toList()));
|
|
|
|
|
|
// 获取累计专项附加扣除
|
|
|
|
|
|
List<AddUpDeductionListDTO> list = addUpDeductionMapper.list(queryParam, tenantKey);
|
|
|
|
|
|
List<SimpleUserInfo> simpleUserInfos = salaryEmployeeService.listByEmployeeIds(list.stream().map(AddUpDeductionListDTO::getEmployeeId).collect(Collectors.toList()), tenantKey);
|
|
|
|
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
|
|
|
|
for (AddUpDeductionListDTO 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(DataCollectionBO.getIdNo(dto.getEmployeeId(), simpleUserInfos));
|
|
|
|
|
|
row.add(dto.getHiredate()+"");
|
|
|
|
|
|
row.add(dto.getAddUpChildEducation());
|
|
|
|
|
|
row.add(dto.getAddUpContinuingEducation());
|
|
|
|
|
|
row.add(dto.getAddUpHousingLoanInterest());
|
|
|
|
|
|
row.add(dto.getAddUpHousingRent());
|
|
|
|
|
|
row.add(dto.getAddUpSupportElderly());
|
|
|
|
|
|
row.add(dto.getAddUpIllnessMedical());
|
|
|
|
|
|
row.add(dto.getAddUpInfantCare());
|
|
|
|
|
|
rows.add(row);
|
2022-05-24 15:20:12 +08:00
|
|
|
|
}
|
2022-05-25 13:10:03 +08:00
|
|
|
|
// 3.表数据
|
|
|
|
|
|
excelSheetData.setRows(rows);
|
|
|
|
|
|
// 4.注释
|
|
|
|
|
|
List<ExcelComment> excelComments = Lists.newArrayList();
|
|
|
|
|
|
salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100344, "必填"), 0, 0, 0, 0);
|
|
|
|
|
|
salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100344, "必填"), 0, 0, 1, 1);
|
|
|
|
|
|
salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 7, 7);
|
|
|
|
|
|
salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 8, 8);
|
|
|
|
|
|
salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 9, 9);
|
|
|
|
|
|
salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 10, 10);
|
|
|
|
|
|
salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 11, 11);
|
|
|
|
|
|
salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 12, 12);
|
|
|
|
|
|
salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 13, 13);
|
|
|
|
|
|
excelSheetData.setExcelComment(excelComments);
|
|
|
|
|
|
|
|
|
|
|
|
sheetList.add(excelSheetData);
|
|
|
|
|
|
|
|
|
|
|
|
salaryBatchService.simpleExportExcel(ExportExcelInfo.builder()
|
|
|
|
|
|
.bizId(map.get("biz").toString())
|
|
|
|
|
|
.flag(true)
|
|
|
|
|
|
.userId(employeeId)
|
|
|
|
|
|
.eteamsId(eteamsId)
|
|
|
|
|
|
.tenantKey(tenantKey)
|
|
|
|
|
|
.operator(username)
|
|
|
|
|
|
.module(map.get("module").toString())
|
|
|
|
|
|
.fileName(nameI18n + SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now()))
|
|
|
|
|
|
.handlerName(map.get("function").toString())
|
|
|
|
|
|
.dataType(nameI18n)
|
|
|
|
|
|
.function(map.get("function").toString()).build(), sheetList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导出
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private XSSFWorkbook export(AddUpDeductionQueryParam param) {
|
|
|
|
|
|
|
|
|
|
|
|
//获取操作按钮资源
|
|
|
|
|
|
List<List<String>> rowList = getExcelRowList(param);
|
|
|
|
|
|
|
|
|
|
|
|
//获取excel
|
|
|
|
|
|
return ExcelUtil.genWorkbook(rowList, "累计专项附加扣除");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取excel数据行
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 导出数据行集合
|
|
|
|
|
|
*/
|
|
|
|
|
|
private List<List<String>> getExcelRowList(AddUpDeductionQueryParam param) {
|
|
|
|
|
|
//excel标题
|
|
|
|
|
|
List<String> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计婴幼儿照护");
|
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
List<AddUpDeductionDTO> list = list(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.getTaxAgentName()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getDepartmentName()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getMobile()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getJobNum()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getIdNo()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getHiredate()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpChildEducation()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpContinuingEducation()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpHousingLoanInterest()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpHousingRent()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpSupportElderly()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpIllnessMedical()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpInfantCare()));
|
|
|
|
|
|
return cellList;
|
|
|
|
|
|
}).collect(Collectors.toList()))
|
|
|
|
|
|
.orElse(Collections.emptyList());
|
|
|
|
|
|
|
|
|
|
|
|
List<List<String>> rowList = new ArrayList<>();
|
|
|
|
|
|
rowList.add(title);
|
|
|
|
|
|
rowList.addAll(dataRowList);
|
|
|
|
|
|
return rowList;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-03 13:50:03 +08:00
|
|
|
|
}
|