diff --git a/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java index 31ebcddbf..ca5424b51 100644 --- a/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java @@ -4,6 +4,7 @@ import com.cloudstore.eccom.pc.table.WeaTableType; import com.engine.salary.annotation.SalaryTable; import com.engine.salary.annotation.SalaryTableColumn; import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; import com.engine.salary.util.excel.ExcelProperty; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; @@ -46,6 +47,7 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 0) @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") private String username; /** @@ -53,13 +55,20 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 1) @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") private String taxAgentName; + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + /** * 部门 */ @ExcelProperty(index = 2) @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") private String departmentName; /** @@ -67,6 +76,7 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 3) @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") private String mobile; /** @@ -74,6 +84,7 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 4) @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") private String jobNum; /** @@ -81,6 +92,7 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 5) @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") private String idNo; /** @@ -89,6 +101,7 @@ public class AddUpDeductionDTO { @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @ExcelProperty(index = 6, msg = "第7列,入职日期解析错误,标准格式应为yyyy-MM-dd,例如:2022-01-01") @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate") + @TableTitle(title = "入职日期", dataIndex = "hiredate", key = "hiredate") private String hiredate; /** @@ -96,6 +109,7 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 7, msg = "第8列,累计子女教育解析错误,请输入数字") @SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation") + @TableTitle(title = "累计子女教育", dataIndex = "addUpChildEducation", key = "addUpChildEducation") private BigDecimal addUpChildEducation; /** @@ -103,6 +117,7 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 8, msg = "第9列,累计继续教育教育解析错误,请输入数字") @SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation") + @TableTitle(title = "累计继续教育", dataIndex = "addUpContinuingEducation", key = "addUpContinuingEducation") private BigDecimal addUpContinuingEducation; /** @@ -110,6 +125,7 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 9, msg = "第10列,累计住房贷款利息解析错误,请输入数字") @SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest") + @TableTitle(title = "累计住房贷款利息", dataIndex = "addUpHousingLoanInterest", key = "addUpHousingLoanInterest") private BigDecimal addUpHousingLoanInterest; /** @@ -117,6 +133,7 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 10, msg = "第11列,累计住房租金解析错误,请输入数字") @SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent") + @TableTitle(title = "累计住房租金", dataIndex = "addUpHousingRent", key = "addUpHousingRent") private BigDecimal addUpHousingRent; /** @@ -124,6 +141,7 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 11, msg = "第12列,累计赡养老人解析错误,请输入数字") @SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly") + @TableTitle(title = "累计赡养老人", dataIndex = "addUpSupportElderly", key = "addUpSupportElderly") private BigDecimal addUpSupportElderly; /** @@ -131,12 +149,15 @@ public class AddUpDeductionDTO { */ @ExcelProperty(index = 12, msg = "第13列,累计大病医疗解析错误,请输入数字") @SalaryTableColumn(text = "累计大病医疗", width = "10%", column = "addUpIllnessMedical") + @TableTitle(title = "累计大病医疗", dataIndex = "addUpIllnessMedical", key = "addUpIllnessMedical") private BigDecimal addUpIllnessMedical; @ExcelProperty(index = 13, msg = "第14列,累计婴幼儿照护解析错误,请输入数字") @SalaryTableColumn(text = "累计婴幼儿照护", width = "10%", column = "addUpInfantCare") + @TableTitle(title = "累计婴幼儿照护", dataIndex = "addUpInfantCare", key = "addUpInfantCare") private BigDecimal addUpInfantCare; @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + @TableTitle(title = "操作", dataIndex = "operate", key = "operate") private String operate; } diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpDeductionQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionQueryParam.java index 3d6c2ce3e..e3a68a51f 100644 --- a/src/com/engine/salary/entity/datacollection/param/AddUpDeductionQueryParam.java +++ b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionQueryParam.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.datacollection.param; +import com.engine.salary.common.BaseQueryParam; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -21,7 +22,7 @@ import java.util.List; @Builder @NoArgsConstructor @AllArgsConstructor -public class AddUpDeductionQueryParam { +public class AddUpDeductionQueryParam extends BaseQueryParam { /** * 主键id diff --git a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml index 8860f0400..34b0855b1 100644 --- a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml @@ -86,6 +86,7 @@ e.workcode as job_num, e.companystartdate as hiredate, t2.name AS tax_agent_name, + t2.id AS tax_agent_name, t1.add_up_child_education, t1.add_up_continuing_education, t1.add_up_housing_loan_interest, diff --git a/src/com/engine/salary/service/AddUpDeductionService.java b/src/com/engine/salary/service/AddUpDeductionService.java index f9d04e82a..2909a3655 100644 --- a/src/com/engine/salary/service/AddUpDeductionService.java +++ b/src/com/engine/salary/service/AddUpDeductionService.java @@ -1,7 +1,11 @@ package com.engine.salary.service; import com.engine.salary.entity.datacollection.AddUpDeduction; +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.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.time.YearMonth; @@ -24,6 +28,81 @@ public interface AddUpDeductionService { XSSFWorkbook exportDetail(Map map); + + XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam); + + + + //-----------------------------------分权--------------------------------------------------- + + + + /** + * 通过id获取单条累计专项附加扣除记录 + * + * @param id + * @return + */ + AddUpDeduction getById(Long id); + + /** + * 数据采集-累计专项附加扣除列表(分页) + * + * @param queryParam + * @param employeeId + * @return + */ + PageInfo listPage(AddUpDeductionQueryParam queryParam, Long employeeId); + + /** + * 获取数据采集-累计专项附加扣除详情列表(分页) + * + * @param queryParam + * @param employeeId + * @return + */ + PageInfo recordListPage(AddUpDeductionQueryParam queryParam, Long employeeId); + + /** + * 导出 + * + * @param map + * @param username + * @param eteamsId + * @param isChief + * @param queryParam + * @param employeeId + * @param tenantKey + */ + void export(Map map, String username, String eteamsId, boolean isChief, AddUpDeductionQueryParam queryParam, Long employeeId, String tenantKey); + + /** + * 导出详情 + * + * @param map + * @param username + * @param eteamsId + * @param beLongEmployeeId + * @param isChief + * @param queryParam + * @param employeeId + * @param tenantKey + */ + void exportDetail(Map map, String username, String eteamsId, Long beLongEmployeeId, boolean isChief, AddUpDeductionQueryParam queryParam, Long employeeId, String tenantKey); + + /** + * 下载导入模板 + * + * @param map + * @param username + * @param eteamsId + * @param isChief + * @param queryParam + * @param employeeId + * @param tenantKey + */ + void downloadTemplate(Map map, String username, String eteamsId, boolean isChief, AddUpDeductionQueryParam queryParam, Long employeeId, String tenantKey); + /** * 获取累计专项附加扣除数据 * @@ -33,5 +112,11 @@ public interface AddUpDeductionService { */ List getAddUpDeductionList(YearMonth declareMonth, List employeeIds); - XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam); + /** + * 根据年月获取已核算数据 + * + * @param yearMonth + * @return + */ + List getAccountedEmployeeData(String yearMonth); } diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index ee1405cd4..c61f5dd5c 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -8,16 +8,22 @@ import com.engine.salary.entity.datacollection.AddUpDeduction; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; +import com.engine.salary.entity.taxagent.bo.TaxAgentBO; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.datacollection.AddUpDeductionMapper; -import com.engine.salary.service.AddUpDeductionService; +import com.engine.salary.service.*; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.excel.ExcelComment; import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.PageUtil; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.general.Util; @@ -31,6 +37,12 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction return MapperProxyFactory.getProxy(AddUpDeductionMapper.class); } + private TaxAgentV2Service taxAgentService; + private SalaryAcctRecordService salaryAcctRecordService; + private SalaryAcctEmployeeService salaryAcctEmployeeService; + private SalaryEmployeeService salaryEmployeeService; + + @Override public Map list(Map params) { return commandExecutor.execute(new AddUpDeductionListCmd(params, user)); @@ -80,7 +92,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction AddUpDeduction po = biz.getById(id); if (po == null) { - throw new SalaryRunTimeException(String.format("累计专项附加扣除不存在"+"[id:%s]", id)); + throw new SalaryRunTimeException(String.format("累计专项附加扣除不存在" + "[id:%s]", id)); } List employeeList = employBiz.getEmployeeByIds(Collections.singletonList(po.getEmployeeId())); @@ -182,4 +194,101 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction return book; } + + + @Override + public AddUpDeduction getById(Long id) { + return getAddUpDeductionMapper().getById(id); + } + +// /** +// * 获取作为修改者的最新记录 +// * 说明:以人员id和个税口角义务人id去重 +// * +// * @param currentEmployeeId +// * @return +// */ +// private List getLastListByModifier(Long currentEmployeeId) { +// List 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 listPage(AddUpDeductionQueryParam queryParam, Long employeeId) { + PageInfo dtoPage = PageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); + + // 未开启分权或是薪酬模块总管理员 + if (!taxAgentService.isOpenDevolution() || taxAgentService.isChief(employeeId)) { + PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List list = getAddUpDeductionMapper().list(queryParam); + return new PageInfo<>(list, AddUpDeductionDTO.class); + } else { + List taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId); + List taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); +// List lastList = getLastListByModifier(employeeId); + List 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()); + // 填充总数和当页数据 + // 分页参数 + dtoPage.setTotal(list.size()); + dtoPage.setRecords(SalaryPageUtil.subList((int) dtoPage.getCurrent(), (int) dtoPage.getSize(), list)); + page = dtoPage; + } + return page; + } + + @Override + public Page recordListPage(Page page, AddUpDeductionQueryParam queryParam, Long employeeId, String tenantKey) { + // 未开启分权或是薪酬模块总管理员 + if (!taxAgentService.isOpenDevolution(tenantKey) || taxAgentService.isChief(employeeId, tenantKey)) { + getAddUpDeductionMapper().recordList(page, queryParam, tenantKey); + } else { + List taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId, tenantKey); + List taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId, tenantKey).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + List lastList = getLastListByModifier(employeeId, tenantKey); + List list = getAddUpDeductionMapper().recordList(queryParam, tenantKey); + // 分页参数 + Page dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); + 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()); + // 填充总数和当页数据 + dtoPage.setTotal(list.size()); + dtoPage.setRecords(SalaryPageUtil.subList((int) dtoPage.getCurrent(), (int) dtoPage.getSize(), list)); + page = dtoPage; + } + return page; + } + + @Override + public List getAddUpDeductionList(YearMonth declareMonth, List employeeIds, String tenantKey) { + if (declareMonth == null || StringUtils.isEmpty(tenantKey)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, UserContext.getCurrentEmployeeId(), 100342, "参数有误:申报月份、租户key必传")); + } + return new LambdaQueryChainWrapper<>(getAddUpDeductionMapper()) + .eq(AddUpDeductionPO::getDeleteType, 0) + .eq(AddUpDeductionPO::getTenantKey, tenantKey) + .eq(AddUpDeductionPO::getDeclareMonth, declareMonth.atDay(1)) + .in(CollectionUtils.isNotEmpty(employeeIds), AddUpDeductionPO::getEmployeeId, employeeIds).list(); + } + + }