package com.engine.salary.wrapper; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; import com.api.browser.util.ConditionFactory; import com.api.browser.util.ConditionType; import com.engine.core.impl.Service; import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; import com.engine.salary.service.OtherDeductionService; 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.OtherDeductionRecordDTO; import com.weaver.hrm.salary.entity.datacollection.po.OtherDeductionPO; 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 weaver.systeminfo.SystemEnv; import java.time.LocalDate; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @Description: 其他免税扣除 * @Author: wangxiangzhong * @Date: 2022/3/14 16:09 */ @Component public class OtherDeductionWrapper extends Service { private OtherDeductionService otherDeductionService; private TaxAgentV2Service taxAgentService; private SalaryEmployeeService salaryEmployeeService; /** * 数据采集-其他免税扣除列表的高级搜索 * * @return */ public Map getSearchCondition() { Map apidatas = new HashMap(); ConditionFactory conditionFactory = new ConditionFactory(user); //条件组 List addGroups = new ArrayList(); List conditionItems = new ArrayList(); //文本输入框 SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT,25034, "username"); username.setInputType("input"); username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 username.setFieldcol(16); //条件输入框所占宽度,默认值18 username.setLabelcol(8); username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 conditionItems.add(username); SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER,502227,"departmentName","4"); departmentName.setInputType("browser"); departmentName.setColSpan(2); departmentName.setFieldcol(16); departmentName.setLabelcol(8); departmentName.setViewAttr(2); departmentName.setIsQuickSearch(false); departmentName.setLabel("部门"); conditionItems.add(departmentName); SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT,25034, "jobNum"); jobNum.setInputType("input"); jobNum.setColSpan(2); jobNum.setFieldcol(16); jobNum.setLabelcol(8); jobNum.setViewAttr(2); jobNum.setLabel("工号"); conditionItems.add(jobNum); SearchConditionItem idNo = conditionFactory.createCondition(ConditionType.INPUT,25034, "idNo"); idNo.setInputType("input"); idNo.setColSpan(2); idNo.setFieldcol(16); idNo.setLabelcol(8); idNo.setViewAttr(2); idNo.setLabel("证件号码"); conditionItems.add(idNo); //日期范围选项 List dateOptions = new ArrayList(); dateOptions.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(32530, user.getLanguage()),true));//指定日期范围(必须为6) SearchConditionItem hiredate = conditionFactory.createCondition(ConditionType.RANGEPICKER, 18648, new String[]{"hiredate","hiredate"}); hiredate.setInputType("rangepicker"); hiredate.setFormat("yyyy-MM-dd"); hiredate.setFieldcol(16); hiredate.setLabelcol(8); hiredate.setViewAttr(2); hiredate.setLabel("入职日期"); hiredate.setOptions(dateOptions); conditionItems.add(hiredate); SearchConditionItem mobile = conditionFactory.createCondition(ConditionType.INPUT,25034, "mobile"); mobile.setInputType("input"); mobile.setColSpan(2); mobile.setFieldcol(16); mobile.setLabelcol(8); mobile.setViewAttr(2); mobile.setLabel("手机号"); conditionItems.add(mobile); addGroups.add(new SearchConditionGroup("常用条件",true,conditionItems)); apidatas.put("condition",addGroups); return apidatas; } /** * 数据采集-其他免税扣除列表(分页) * * @param queryParam * @return */ public PageInfo list(OtherDeductionQueryParam queryParam) { queryParam.setDeclareMonthDate(queryParam.getDeclareMonth().stream().map(e-> LocalDate.of(e.getYear(),e.getMonthValue(),1)).collect(Collectors.toList())); PageInfo page = new Page<>(queryParam.getCurrent(), queryParam.getPageSize(), true); page = otherDeductionService.listPage(page, queryParam, currentEmployeeId, currentTenantKey); List list = page.getRecords(); List simpleUserInfos = salaryEmployeeService.listByEmployeeIds(list.stream().map(OtherDeductionListDTO::getEmployeeId).collect(Collectors.toList()), currentTenantKey); // 人员信息赋值 list.forEach(m->{ // 身份证号 m.setIdNo(DataCollectionBO.getIdNo(m.getEmployeeId(), simpleUserInfos)); }); WeaTable weaTable = FormatManager.getInstance().genTable(OtherDeductionListDTO.class, page); // 在外展示操作按钮 weaTable.getOperates().get(0).setOuter(Boolean.TRUE); weaTable.setModule("hrmsalary"); return weaTable; } /** * 数据采集-其他免税扣除详情列表(分页) * * @param queryParam * @param currentEmployeeId * @param currentTenantKey * @return */ public WeaTable getDetailList(OtherDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) { Long id = queryParam.getOtherTaxExemptDeductionId(); OtherDeductionPO po = otherDeductionService.getById(id, currentTenantKey); if (po == null) { throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100415, "其他免税扣除不存在")+"[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 = otherDeductionService.recordListPage(page, queryParam, currentEmployeeId, currentTenantKey); // 记录表格 WeaTable weaTable = FormatManager.getInstance() .genTable(OtherDeductionRecordDTO.class, page); weaTable.setModule("hrmsalary"); return weaTable; } /** * 导出-其他免税扣除列表 * * @param queryParam * @param currentEmployeeId * @param currentTenantKey * @return */ public Map export(OtherDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) { // 构建异步导出参数 Map map = salaryBatchService.buildeExportParam("exportOtherDeduction"); String username = UserContext.getCurrentUser().getUsername(); String eteamsId = TenantRpcContext.getEteamsId(); boolean isChief = taxAgentService.isChief(currentEmployeeId, currentTenantKey); taskExecutor.execute(() -> { try { DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); otherDeductionService.export(map, username, eteamsId, isChief, queryParam, currentEmployeeId, currentTenantKey); } finally { DSTenantKeyThreadVar.tenantKey.remove(); } }); return map; } /** * 导出-其他免税扣除详情列表 * * @param queryParam * @param currentEmployeeId * @param currentTenantKey * @return */ public Map exportDetail(OtherDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) { Long id = queryParam.getOtherTaxExemptDeductionId(); OtherDeductionPO po = otherDeductionService.getById(id, currentTenantKey); if (po == null) { throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100415, "其他免税扣除不存在")+"[id:%s]", id)); } boolean isChief = taxAgentService.isChief(currentEmployeeId, currentTenantKey); // 构建异步导出参数 Map map = salaryBatchService.buildeExportParam("exportOtherDeductionDetail"); String username = UserContext.getCurrentUser().getUsername(); String eteamsId = TenantRpcContext.getEteamsId(); taskExecutor.execute(() -> { try { DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); otherDeductionService.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(OtherDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) { // 构建异步导出参数 Map map = salaryBatchService.buildeExportParam("exportOtherDeduction"); boolean isChief = taxAgentService.isChief(currentEmployeeId, currentTenantKey); String username = UserContext.getCurrentUser().getUsername(); String eteamsId = TenantRpcContext.getEteamsId(); taskExecutor.execute(() -> { try { DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); otherDeductionService.export(map, username, eteamsId, isChief, queryParam, currentEmployeeId, currentTenantKey); } finally { DSTenantKeyThreadVar.tenantKey.remove(); } }); return map; } /** * 获取导入参数 * * @return */ public ExcelImportParam getImportParams() { return salaryBatchService.buildImportParam("importOtherDeduction", "importOtherDeduction", SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), 93849, "其他免税扣除"), null, null); } }