package com.engine.salary.wrapper; import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; import com.engine.salary.service.AddUpDeductionService; import com.engine.salary.service.SalaryEmployeeService; import com.engine.salary.service.TaxAgentV2Service; import com.engine.salary.util.page.PageInfo; import com.weaver.common.authority.format.FormatManager; import com.weaver.common.component.table.WeaTable; import com.weaver.common.component.table.page.Page; import com.weaver.datasecurity.interceptor.DSTenantKeyThreadVar; import com.weaver.framework.rpc.context.impl.TenantRpcContext; import com.weaver.hrm.salary.common.excel.ExcelImportParam; import com.weaver.hrm.salary.entity.datacollection.bo.DataCollectionBO; import com.weaver.hrm.salary.entity.datacollection.dto.AddUpDeductionListDTO; import com.weaver.hrm.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; import com.weaver.hrm.salary.entity.datacollection.po.AddUpDeductionPO; import com.weaver.hrm.salary.exception.SalaryRunTimeException; import com.weaver.hrm.salary.util.SalaryI18nUtil; import com.weaver.teams.domain.hr.SimpleUserInfo; import com.weaver.teams.security.context.TenantContext; import com.weaver.teams.security.context.UserContext; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Component; import java.time.LocalDate; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import static weaver.formmode.modesetdelete.DeleteItemType.page; /** * 累计专项附加扣除 *

Copyright: Copyright (c) 2022

*

Company: 泛微软件

* * @author qiantao * @version 1.0 **/ @Component public class AddUpDeductionWrapper { private AddUpDeductionService addUpDeductionService; private TaxAgentV2Service taxAgentService; private SalaryEmployeeService salaryEmployeeService; /** * 数据采集-累计专项附加扣除列表(分页) * * @param queryParam * @return */ public PageInfo list(AddUpDeductionQueryParam queryParam) { //申报月份 List declareMonth = queryParam.getDeclareMonth(); if (CollectionUtils.isNotEmpty(declareMonth)) { queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); } page = addUpDeductionService.listPage(page, queryParam); List list = page.getRecords(); List simpleUserInfos = salaryEmployeeService.listByEmployeeIds(list.stream().map(AddUpDeductionListDTO::getEmployeeId).collect(Collectors.toList()), currentTenantKey); // 人员信息赋值 list.forEach(m -> { // 身份证号 m.setIdNo(DataCollectionBO.getIdNo(m.getEmployeeId(), simpleUserInfos)); }); WeaTable weaTable = FormatManager.getInstance().genTable(AddUpDeductionListDTO.class, page); weaTable.setModule("hrmsalary"); // 在外展示操作按钮 weaTable.getOperates().get(0).setOuter(Boolean.TRUE); return weaTable; } /** * 数据采集-累计专项附加扣除详情列表(分页) * * @param queryParam * @param currentEmployeeId * @param currentTenantKey * @return */ public WeaTable getDetailList(AddUpDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) { Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId(); AddUpDeductionPO po = addUpDeductionService.getById(id, currentTenantKey); if (po == null) { throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100338, "累计专项附加扣除不存在") + "[id:%s]", id)); } queryParam.setDeclareMonthDate(CollectionUtils.emptyIfNull(queryParam.getDeclareMonth()).stream().map(e -> LocalDate.of(e.getYear(), e.getMonthValue(), 1)).collect(Collectors.toList())); queryParam.setEmployeeId(po.getEmployeeId()); Page page = new Page<>(queryParam.getCurrent(), queryParam.getPageSize(), true); page = addUpDeductionService.recordListPage(page, queryParam, currentEmployeeId, currentTenantKey); // 记录表格 WeaTable weaTable = FormatManager.getInstance() .genTable(AddUpDeductionRecordDTO.class, page); weaTable.setModule("hrmsalary"); return weaTable; } /** * 导出-累计专项附加扣除列表 * * @param queryParam * @param currentEmployeeId * @param currentTenantKey * @return */ public Map export(AddUpDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) { // 构建异步导出参数 Map map = salaryBatchService.buildeExportParam("exportAddUpDeduction"); String username = UserContext.getCurrentUser().getUsername(); String eteamsId = TenantRpcContext.getEteamsId(); boolean isChief = taxAgentService.isChief(currentEmployeeId, currentTenantKey); taskExecutor.execute(() -> { try { DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); addUpDeductionService.export(map, username, eteamsId, isChief, queryParam, currentEmployeeId, currentTenantKey); } finally { DSTenantKeyThreadVar.tenantKey.remove(); } }); return map; } /** * 导出-累计专项附加扣除详情列表 * * @param queryParam * @param currentEmployeeId * @param currentTenantKey * @return */ public Map exportDetail(AddUpDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) { Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId(); AddUpDeductionPO po = addUpDeductionService.getById(id, currentTenantKey); if (po == null) { throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100338, "累计专项附加扣除不存在") + "[id:%s]", id)); } boolean isChief = taxAgentService.isChief(currentEmployeeId, currentTenantKey); // 构建异步导出参数 Map map = salaryBatchService.buildeExportParam("exportAddUpDeductionDetail"); String username = UserContext.getCurrentUser().getUsername(); String eteamsId = TenantRpcContext.getEteamsId(); taskExecutor.execute(() -> { try { DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); addUpDeductionService.exportDetail(map, username, eteamsId, po.getEmployeeId(), isChief, queryParam, currentEmployeeId, currentTenantKey); } finally { DSTenantKeyThreadVar.tenantKey.remove(); } }); return map; } /** * 下载导入模板 * * @param queryParam * @param currentEmployeeId * @param currentTenantKey * @return */ public Map downloadTemplate(AddUpDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) { // 构建异步导出参数 Map map = salaryBatchService.buildeExportParam("exportAddUpDeduction"); boolean isChief = taxAgentService.isChief(currentEmployeeId, currentTenantKey); String username = UserContext.getCurrentUser().getUsername(); String eteamsId = TenantRpcContext.getEteamsId(); taskExecutor.execute(() -> { try { DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); addUpDeductionService.downloadTemplate(map, username, eteamsId, isChief, queryParam, currentEmployeeId, currentTenantKey); } finally { DSTenantKeyThreadVar.tenantKey.remove(); } }); return map; } }