320 lines
15 KiB
Java
320 lines
15 KiB
Java
|
|
package com.engine.salary.wrapper;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 薪资档案
|
||
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
||
|
|
* <p>Company: 泛微软件</p>
|
||
|
|
*
|
||
|
|
* @author qiantao
|
||
|
|
* @version 1.0
|
||
|
|
**/
|
||
|
|
public class SalaryArchiveWrapper {
|
||
|
|
// private SalaryArchiveService salaryArchiveService;
|
||
|
|
// private SalaryArchiveItemService salaryArchiveItemService;
|
||
|
|
// private HrmCommonEmployeeService employeeService;
|
||
|
|
// private TaxAgentService taxAgentService;
|
||
|
|
// private SalaryBatchService salaryBatchService;
|
||
|
|
// private ExecutorService taskExecutor;
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 薪资档案列表-高级搜索
|
||
|
|
// *
|
||
|
|
// * @param employeeId
|
||
|
|
// * @param tenantKey
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public WeaSearchCondition getSearchCondition(Long employeeId, String tenantKey) {
|
||
|
|
// List<WeaSearchConditionOption> taxAgentList = new ArrayList<>();
|
||
|
|
// // 获取所有个税扣缴义务人
|
||
|
|
// Collection<TaxAgentListDTO> taxAgentLists = taxAgentService.findAll(tenantKey);
|
||
|
|
// taxAgentLists.forEach(e-> taxAgentList.add(new WeaSearchConditionOption(e.getId().toString(), e.getName())));
|
||
|
|
//
|
||
|
|
// WeaSearchCondition weaSearchCondition = SalaryFormatUtil.<SalaryArchiveSearchConditionDTO>getInstance()
|
||
|
|
// .buildCondition(SalaryArchiveSearchConditionDTO.class,
|
||
|
|
// SalaryArchiveSearchConditionDTO.builder().taxAgentOptions(taxAgentList).build(),
|
||
|
|
// "salaryArchive");
|
||
|
|
// // 入职日期-添加范围
|
||
|
|
// SalaryArchiveBO.addDatePickerRangeOtherParams(weaSearchCondition, "hiredate", employeeId, tenantKey);
|
||
|
|
// // 只保留常用条件
|
||
|
|
// weaSearchCondition.setGroups(weaSearchCondition.getGroups().stream().filter(e-> "commonGroup".equals(e.getId())).collect(Collectors.toList()));
|
||
|
|
//
|
||
|
|
// return weaSearchCondition;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 薪资档案列表(分页)
|
||
|
|
// *
|
||
|
|
// * @param queryParam
|
||
|
|
// * @param employeeId
|
||
|
|
// * @param tenantKey
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public WeaTable<LinkedHashMap> list(SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey) {
|
||
|
|
// Collection<TaxAgentListDTO> taxAgentLists = taxAgentService.findAll(tenantKey);
|
||
|
|
//
|
||
|
|
// Page<SalaryArchiveListDTO> page = new Page<>(queryParam.getCurrent(), queryParam.getPageSize(), true);
|
||
|
|
// page = salaryArchiveService.listPage(page, queryParam, tenantKey);
|
||
|
|
//
|
||
|
|
// Collection<SalaryArchiveListDTO> salaryArchives = page.getRecords();
|
||
|
|
// // 获取所有可被引用的薪资项目
|
||
|
|
// List<SalaryItemPO> salaryItems = salaryArchiveItemService.getCanAdjustSalaryItems(tenantKey);
|
||
|
|
// List<Map<String, Object>> listMaps = salaryArchiveService.buildSalaryArchiveData(salaryArchives, taxAgentLists, salaryItems, employeeId, tenantKey, Boolean.TRUE);
|
||
|
|
//
|
||
|
|
// Page<Map<String, Object>> listPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount());
|
||
|
|
// listPage.setRecords(listMaps);
|
||
|
|
//
|
||
|
|
// WeaTable<LinkedHashMap> weaTable = FormatManager.<LinkedHashMap>getInstance()
|
||
|
|
// .genTable(LinkedHashMap.class, listPage);
|
||
|
|
// weaTable.setPageUid("salaryArchive");
|
||
|
|
// weaTable.setModule("hrmsalary");
|
||
|
|
// //动态列组装
|
||
|
|
// SalaryArchiveBO.buildSalaryArchiveTable(weaTable, salaryItems, employeeId, tenantKey, listMaps.size());
|
||
|
|
// // 在外展示操作按钮
|
||
|
|
// weaTable.getOperates().get(0).setOuter(Boolean.TRUE);
|
||
|
|
// return weaTable;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 获取薪资档案详情表单
|
||
|
|
// *
|
||
|
|
// * @param salaryArchiveId
|
||
|
|
// * @param employeeId
|
||
|
|
// * @param tenantKey
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public SalaryArchiveFormDTO getFrom(Long salaryArchiveId, Long employeeId, String tenantKey) {
|
||
|
|
// if (salaryArchiveId == null) {
|
||
|
|
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100425, "薪资档案id不能为空"));
|
||
|
|
// }
|
||
|
|
// SalaryArchivePO po = salaryArchiveService.getById(salaryArchiveId, tenantKey);
|
||
|
|
// if (po == null) {
|
||
|
|
// throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100463, "薪资档案不存在")+"[id:%s]", salaryArchiveId));
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// List<SimpleEmployee> employeeList = employeeService.getEmployeeByIds(Collections.singletonList(po.getEmployeeId()), tenantKey);
|
||
|
|
// if (CollectionUtils.isEmpty(employeeList)) {
|
||
|
|
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100465, "薪资档案员工信息不存在"));
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// // 获取当前已生效个税扣缴义务人
|
||
|
|
// List<SalaryArchiveTaxAgentPO> taxAgentList = salaryArchiveService.getCurrentEffectiveTaxAgentList(Collections.singletonList(salaryArchiveId), tenantKey);
|
||
|
|
// // 获取所有个税扣缴义务人
|
||
|
|
// Collection<TaxAgentListDTO> taxAgentLists = taxAgentService.findAll(tenantKey);
|
||
|
|
// String taxAgent = "";
|
||
|
|
// if (CollectionUtils.isNotEmpty(taxAgentList)) {
|
||
|
|
// SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = taxAgentList.get(0);
|
||
|
|
// Optional<TaxAgentListDTO> taxAgentOptional = taxAgentLists.stream().filter(f->f.getId().equals(salaryArchiveTaxAgent.getTaxAgentId())).findFirst();
|
||
|
|
// taxAgent = taxAgentOptional.isPresent()?taxAgentOptional.get().getName():taxAgent;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// // 1.基本信息表单
|
||
|
|
// SimpleEmployee employee = employeeList.get(0);
|
||
|
|
// WeaForm salaryArchiveBaseInfoForm = SalaryFormatUtil.<SalaryArchiveBaseInfoFormDTO>getInstance().buildForm(SalaryArchiveBaseInfoFormDTO.class,
|
||
|
|
// SalaryArchiveBaseInfoFormDTO.builder()
|
||
|
|
// .username(employee.getUsername())
|
||
|
|
// .department(employee.getDepartment().getName())
|
||
|
|
// .position(employee.getPosition()==null?"":employee.getPosition().getName())
|
||
|
|
// .hiredate(SalaryDateUtil.getFormatLocalDate(employee.getHiredate()))
|
||
|
|
// .mobile(employee.getMobile())
|
||
|
|
// .taxAgent(taxAgent)
|
||
|
|
// .build());
|
||
|
|
//
|
||
|
|
// List<Map<String, Object>> salaryItems = Lists.newArrayList();
|
||
|
|
// // 获取所有可被引用的薪资项目
|
||
|
|
// List<SalaryItemPO> salaryItemList = salaryArchiveItemService.getCanAdjustSalaryItems(tenantKey);
|
||
|
|
// Collection<Long> salaryItemIds = salaryItemList.stream().map(SalaryItemPO::getId).collect(Collectors.toList());
|
||
|
|
// List<SalaryArchiveItemPO> salaryArchiveItemList = salaryArchiveService.getCurrentEffectiveItemList(Collections.singletonList(salaryArchiveId), salaryItemIds, tenantKey);
|
||
|
|
// salaryArchiveItemList.forEach(m->{
|
||
|
|
// Optional<SalaryItemPO> optionalItem = salaryItemList.stream().filter(f->f.getId().equals(m.getSalaryItemId())).findFirst();
|
||
|
|
// if (optionalItem.isPresent()) {
|
||
|
|
// Map<String, Object> salaryItemMap = new LinkedHashMap<>();
|
||
|
|
// salaryItemMap.put("id", m.getId());
|
||
|
|
// salaryItemMap.put("name", optionalItem.get().getName());
|
||
|
|
// salaryItemMap.put("value", m.getItemValue());
|
||
|
|
// salaryItems.add(salaryItemMap);
|
||
|
|
// }
|
||
|
|
// });
|
||
|
|
//
|
||
|
|
// // 2.薪资档案表单
|
||
|
|
// WeaForm salaryItemFrom = buildSalaryItemForm(salaryItems);
|
||
|
|
//
|
||
|
|
// // 3.调整记录的高级搜索
|
||
|
|
// // 3.1 薪资项目
|
||
|
|
// WeaSearchCondition salaryItemAdjustRecordSearchCondition = buildSalaryItemAdjustRecordSearchCondition(employeeId, tenantKey);
|
||
|
|
//
|
||
|
|
// return SalaryArchiveFormDTO.builder()
|
||
|
|
// .id(salaryArchiveId)
|
||
|
|
// .employeeId(employee.getId())
|
||
|
|
// .baseInfo(salaryArchiveBaseInfoForm)
|
||
|
|
// .adjustSalaryItems(salaryItemFrom)
|
||
|
|
// .salaryItemAdjustRecordSearchCondition(salaryItemAdjustRecordSearchCondition)
|
||
|
|
// .build();
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 薪资调整记录的高级搜索
|
||
|
|
// *
|
||
|
|
// * @param employeeId
|
||
|
|
// * @param tenantKey
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// private WeaSearchCondition buildSalaryItemAdjustRecordSearchCondition(Long employeeId, String tenantKey) {
|
||
|
|
// WeaSearchCondition weaSearchCondition = SalaryFormatUtil.<SalaryItemAdjustRecordForFromSearchConditionDTO>getInstance()
|
||
|
|
// .buildCondition(SalaryItemAdjustRecordForFromSearchConditionDTO.class,
|
||
|
|
// SalaryItemAdjustRecordForFromSearchConditionDTO.builder().build(),
|
||
|
|
// "salaryItemAdjustRecordForFromSearchCondition");
|
||
|
|
// // 生效日期-添加范围
|
||
|
|
// SalaryArchiveBO.addDatePickerRangeOtherParams(weaSearchCondition, "effectiveTime", employeeId, tenantKey);
|
||
|
|
// // 操作日期-添加范围
|
||
|
|
// SalaryArchiveBO.addDatePickerRangeOtherParams(weaSearchCondition, "operateTime", employeeId, tenantKey);
|
||
|
|
//
|
||
|
|
// // 只保留常用条件
|
||
|
|
// weaSearchCondition.setGroups(weaSearchCondition.getGroups().stream().filter(e-> "commonGroup".equals(e.getId())).collect(Collectors.toList()));
|
||
|
|
//
|
||
|
|
// return weaSearchCondition;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 薪资档案-薪资档案表单
|
||
|
|
// *
|
||
|
|
// * @param salaryItems
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// private WeaForm buildSalaryItemForm(List<Map<String, Object>> salaryItems) {
|
||
|
|
// // 构建表单
|
||
|
|
// WeaForm salaryItemForm = new WeaForm();
|
||
|
|
//
|
||
|
|
// // 控件项目
|
||
|
|
// Map<String, WeaFormItem> items = salaryItemForm.getItems();
|
||
|
|
// // 控件布局
|
||
|
|
// List<List<WeaFormLayout>> layout = salaryItemForm.getLayout();
|
||
|
|
// // 控件数据
|
||
|
|
// Map<String, Object> data = salaryItemForm.getData();
|
||
|
|
//
|
||
|
|
// List<WeaFormLayout> layoutSingles = Lists.newArrayList();
|
||
|
|
// int i=0;
|
||
|
|
// while (i<salaryItems.size()) {
|
||
|
|
// WeaFormItem salaryItemItem = new WeaFormItem(WeaFormItemType.INPUT);
|
||
|
|
// salaryItemItem.setReadOnly(Boolean.TRUE);
|
||
|
|
// // 表单项
|
||
|
|
// items.put(String.valueOf(salaryItems.get(i).get("id").toString()), salaryItemItem);
|
||
|
|
// // 表单项布局
|
||
|
|
// layoutSingles.add(new WeaFormLayout(String.valueOf(i/2), salaryItems.get(i).get("name").toString(), new String[]{salaryItems.get(i).get("id").toString()}));
|
||
|
|
// // 如果是奇数并且最后一行加空白单元格
|
||
|
|
// if (layoutSingles.size() % 2 != 0 && i == salaryItems.size()-1) {
|
||
|
|
// layoutSingles.add(new WeaFormLayout(String.valueOf(i/2), "", new String[]{""}));
|
||
|
|
// }
|
||
|
|
// // 表单项数据
|
||
|
|
// data.put(String.valueOf(salaryItems.get(i).get("id").toString()), salaryItems.get(i).get("value").toString());
|
||
|
|
// i++;
|
||
|
|
// }
|
||
|
|
// // 栅格布局换行处理
|
||
|
|
// int j=0;
|
||
|
|
// while (j<=salaryItems.size()/2) {
|
||
|
|
// int finalI = j;
|
||
|
|
// if (CollectionUtils.isNotEmpty(layoutSingles)) {
|
||
|
|
// layout.add(layoutSingles.stream().filter(f->f.getId().equals(String.valueOf(finalI))).collect(Collectors.toList()));
|
||
|
|
// }
|
||
|
|
// j++;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// return salaryItemForm;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 获取离职时段设置表单
|
||
|
|
// *
|
||
|
|
// * @param tenantKey
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public WeaForm getDimissionSetForm(String tenantKey) {
|
||
|
|
// WeaForm salaryTemplateBase = SalaryFormatUtil.<DimissionSetFormDTO>getInstance().buildForm(DimissionSetFormDTO.class, DimissionSetFormDTO.builder().build());
|
||
|
|
// List<SalaryArchiveDimissionPO> dimissionSets = salaryArchiveService.dimissionSets(tenantKey);
|
||
|
|
// Map<String, Object> data = new LinkedHashMap<>();
|
||
|
|
// if (CollectionUtils.isNotEmpty(dimissionSets)) {
|
||
|
|
// data.put("dimissionTimeInterval", dimissionSets.get(0).getDimissionTimeInterval());
|
||
|
|
// }
|
||
|
|
// salaryTemplateBase.setData(data);
|
||
|
|
// return salaryTemplateBase;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 保存离职时段设置
|
||
|
|
// *
|
||
|
|
// * @param saveParam
|
||
|
|
// * @param employeeId
|
||
|
|
// * @param tenantKey
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public String saveDimissionSet(SalaryArchiveDimissionSaveParam saveParam, Long employeeId, String tenantKey) {
|
||
|
|
// return salaryArchiveService.saveDimissionSet(saveParam, employeeId, tenantKey);
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 导出薪资档案
|
||
|
|
// *
|
||
|
|
// * @param queryParam
|
||
|
|
// * @param employeeId
|
||
|
|
// * @param tenantKey
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public Map<String, Object> exportList(SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey) {
|
||
|
|
// // 构建异步导出参数
|
||
|
|
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportSalaryArchive");
|
||
|
|
// String username = UserContext.getCurrentUser().getUsername();
|
||
|
|
// String eteamsId = TenantRpcContext.getEteamsId();
|
||
|
|
// taskExecutor.execute(() -> {
|
||
|
|
// try {
|
||
|
|
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
|
||
|
|
// salaryArchiveService.exportList(map, username, eteamsId, queryParam, employeeId, tenantKey);
|
||
|
|
// } finally {
|
||
|
|
// DSTenantKeyThreadVar.tenantKey.remove();
|
||
|
|
// }
|
||
|
|
// });
|
||
|
|
//
|
||
|
|
// return map;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 下载导入模板
|
||
|
|
// *
|
||
|
|
// * @param queryParam
|
||
|
|
// * @param employeeId
|
||
|
|
// * @param tenantKey
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public Map<String, Object> downloadTemplate(SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey) {
|
||
|
|
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportSalaryArchive");
|
||
|
|
// String username = UserContext.getCurrentUser().getUsername();
|
||
|
|
//
|
||
|
|
// String eteamsId = TenantRpcContext.getEteamsId();
|
||
|
|
// Optional<SalaryArchiveImportTypeEnum> optionalImportType = Arrays.stream(SalaryArchiveImportTypeEnum.values()).filter(e-> StringUtils.isNotEmpty(queryParam.getImportType()) && e.getValue().equals(queryParam.getImportType())).findFirst();
|
||
|
|
// if (!optionalImportType.isPresent()) {
|
||
|
|
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100593, "导入类型不正确"));
|
||
|
|
// }
|
||
|
|
// taskExecutor.execute(() -> {
|
||
|
|
// try {
|
||
|
|
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
|
||
|
|
// salaryArchiveService.downloadTemplate(map, username, eteamsId, optionalImportType.get(), queryParam, employeeId, tenantKey);
|
||
|
|
// } finally {
|
||
|
|
// DSTenantKeyThreadVar.tenantKey.remove();
|
||
|
|
// }
|
||
|
|
// });
|
||
|
|
//
|
||
|
|
// return map;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 获取导入参数
|
||
|
|
// *
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public ExcelImportParam getImportParams() {
|
||
|
|
// return salaryBatchService.buildImportParam("importSalaryArchive",
|
||
|
|
// "importSalaryArchive",
|
||
|
|
// SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), 85368, "薪资档案"),
|
||
|
|
// null,
|
||
|
|
// null);
|
||
|
|
// }
|
||
|
|
}
|