2023-04-10 09:47:33 +08:00
|
|
|
package com.engine.salary.report.wrapper;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.engine.salary.report.service.SalaryStatisticsReportService;
|
|
|
|
|
import com.google.common.base.Joiner;
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
import com.weaver.common.authority.format.FormatManager;
|
|
|
|
|
import com.weaver.common.component.browser.entity.WeaBrowserBean;
|
|
|
|
|
import com.weaver.common.component.form.WeaForm;
|
|
|
|
|
import com.weaver.common.component.form.item.WeaFormItem;
|
|
|
|
|
import com.weaver.common.component.form.item.WeaFormOption;
|
|
|
|
|
import com.weaver.common.component.search.WeaSearchCondition;
|
|
|
|
|
import com.weaver.common.component.search.item.WeaSearchConditionItem;
|
|
|
|
|
import com.weaver.common.component.search.item.WeaSearchConditionItemType;
|
|
|
|
|
import com.weaver.common.component.search.layout.WeaSearchConditionLayout;
|
|
|
|
|
import com.weaver.common.component.table.WeaTable;
|
|
|
|
|
import com.weaver.common.component.table.column.WeaTableColumn;
|
|
|
|
|
import com.weaver.common.component.table.page.Page;
|
|
|
|
|
import com.weaver.framework.util.JsonUtil;
|
|
|
|
|
import com.weaver.salary.report.common.constant.SalaryReportModule;
|
|
|
|
|
import com.weaver.salary.report.entity.bo.SalaryStatisticsReportBO;
|
|
|
|
|
import com.weaver.salary.report.entity.dto.SalaryStatisticsReportFormDTO;
|
|
|
|
|
import com.weaver.salary.report.entity.param.*;
|
|
|
|
|
import com.weaver.salary.report.entity.po.SalaryStatisticsDimensionPO;
|
|
|
|
|
import com.weaver.salary.report.entity.po.SalaryStatisticsItemPO;
|
|
|
|
|
import com.weaver.salary.report.entity.po.SalaryStatisticsReportPO;
|
|
|
|
|
import com.weaver.salary.report.enums.WeaBrowserTypeEnum;
|
|
|
|
|
import com.weaver.salary.report.exception.SalaryRunTimeException;
|
|
|
|
|
import com.weaver.salary.report.service.SalaryStatisticsDimensionService;
|
|
|
|
|
import com.weaver.salary.report.service.SalaryStatisticsItemService;
|
|
|
|
|
import com.weaver.salary.report.service.SubTableExportService;
|
|
|
|
|
import com.weaver.salary.report.util.*;
|
|
|
|
|
import com.weaver.teams.security.context.TenantContext;
|
|
|
|
|
import com.weaver.teams.security.context.UserContext;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description: 薪酬统计维度
|
|
|
|
|
* @Author: wangxiangzhong
|
|
|
|
|
* @Date: 2022/12/15 13:46
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
public class SalaryStatisticsReportWrapper {
|
|
|
|
|
|
|
|
|
|
private static final String conditionId = "salaryStatisticsReportSearchCondition";
|
|
|
|
|
|
2023-04-10 12:43:48 +08:00
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
private SalaryStatisticsReportService salaryStatisticsReportService;
|
2023-04-10 12:43:48 +08:00
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
private SalaryStatisticsItemService salaryStatisticsItemService;
|
2023-04-10 12:43:48 +08:00
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
private SalaryStatisticsDimensionService salaryStatisticsDimensionService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private SubTableExportService subTableExportService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 报表列表
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param queryParam
|
|
|
|
|
* @param currentEmployeeId
|
|
|
|
|
* @param currentTenantKey
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<Map<String, Object>> list(SalaryStatisticsReportQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) {
|
|
|
|
|
// 初始化
|
|
|
|
|
salaryStatisticsDimensionService.init(currentEmployeeId, currentTenantKey);
|
|
|
|
|
|
|
|
|
|
List<SalaryStatisticsReportPO> reportList = salaryStatisticsReportService.list(currentEmployeeId, currentTenantKey);
|
|
|
|
|
if (StringUtils.isNotEmpty(queryParam.getReportName())) {
|
|
|
|
|
reportList = reportList.stream().filter(rp -> rp.getReportName().contains(queryParam.getReportName())).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
List<SalaryStatisticsDimensionPO> salaryStatisticsDimensionList = this.salaryStatisticsDimensionService.listAll(currentTenantKey);
|
|
|
|
|
Map<String, String> salaryStatisticsDimensionMap = SalaryEntityUtil.convert2Map(salaryStatisticsDimensionList, k -> k.getId().toString(), SalaryStatisticsDimensionPO::getDimName);
|
|
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
|
reportList.forEach(po -> {
|
|
|
|
|
Map<String, Object> temp = new HashMap<>();
|
|
|
|
|
temp.put("id", po.getId().toString());
|
|
|
|
|
temp.put("reportName", po.getReportName());
|
|
|
|
|
|
|
|
|
|
List<String> dimNames = Arrays.stream(po.getDimension().split(",")).map(dim -> Optional.ofNullable(salaryStatisticsDimensionMap.get(dim)).orElse("")).collect(Collectors.toList());
|
|
|
|
|
temp.put("dimension", Joiner.on(",").join(dimNames));
|
|
|
|
|
temp.put("dimensionId", po.getDimension());
|
|
|
|
|
result.add(temp);
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取薪酬统计报表表单
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param currentEmployeeId
|
|
|
|
|
* @param currentTenantKey
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public WeaForm getFrom(Long id, Long currentEmployeeId, String currentTenantKey) {
|
|
|
|
|
|
|
|
|
|
List<SalaryStatisticsDimensionPO> salaryStatisticsDimensions = salaryStatisticsDimensionService.listAll(currentTenantKey);
|
|
|
|
|
List<WeaFormOption> statsDimOptions = salaryStatisticsDimensions.stream().map(sd -> new WeaFormOption(sd.getId().toString(), sd.getDimName())).collect(Collectors.toList());
|
|
|
|
|
// 1.构建基础信息表单
|
|
|
|
|
WeaForm weaForm = FormatManager.<SalaryStatisticsReportFormDTO>getInstance().genForm(SalaryStatisticsReportFormDTO.class, SalaryStatisticsReportFormDTO.builder().statsDimOptions(statsDimOptions).build());
|
|
|
|
|
|
|
|
|
|
String placeholder = SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 85987, "请输入");
|
|
|
|
|
|
|
|
|
|
WeaFormItem nameItem = weaForm.getItems().get("reportName");
|
|
|
|
|
Map<String, Object> otherParams = Maps.newHashMap();
|
|
|
|
|
otherParams.put("showCount", true);
|
|
|
|
|
otherParams.put("placeholder", placeholder);
|
|
|
|
|
nameItem.setOtherParams(otherParams);
|
|
|
|
|
weaForm.getItems().put("reportName", nameItem);
|
|
|
|
|
|
|
|
|
|
if (id != null) {
|
|
|
|
|
SalaryStatisticsReportPO po = this.salaryStatisticsReportService.getById(id, currentTenantKey);
|
|
|
|
|
if (po == null) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 161845, "薪酬统计报表不存在"));
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> dataMap = JsonUtil.parseMap(po, Object.class);
|
|
|
|
|
dataMap.put("dimension", Arrays.asList(po.getDimension().split(",")));
|
|
|
|
|
weaForm.setData(dataMap);
|
|
|
|
|
}
|
|
|
|
|
return weaForm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存薪酬统计报表
|
|
|
|
|
*
|
|
|
|
|
* @param saveParam
|
|
|
|
|
* @param currentEmployeeId
|
|
|
|
|
* @param currentTenantKey
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String save(SalaryStatisticsReportSaveParam saveParam, Long currentEmployeeId, String currentTenantKey) {
|
|
|
|
|
return salaryStatisticsReportService.save(saveParam, currentEmployeeId, currentTenantKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除薪酬统计报表
|
|
|
|
|
*
|
|
|
|
|
* @param ids
|
|
|
|
|
* @param currentEmployeeId
|
|
|
|
|
* @param currentTenantKey
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Object> delete(Collection<Long> ids, Long currentEmployeeId, String currentTenantKey) {
|
|
|
|
|
return salaryStatisticsReportService.delete(ids, currentEmployeeId, currentTenantKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取统计条件
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param employeeId
|
|
|
|
|
* @param tenantKey
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public WeaSearchCondition getSearchCondition(Long id, Long employeeId, String tenantKey) {
|
|
|
|
|
// 高级搜索实例
|
|
|
|
|
WeaSearchCondition weaSearchCondition = new WeaSearchCondition(conditionId);
|
|
|
|
|
|
|
|
|
|
if (id != null) {
|
|
|
|
|
SalaryStatisticsReportPO po = this.salaryStatisticsReportService.getById(id, tenantKey);
|
|
|
|
|
SalaryAssert.notNull(po, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 152563, "报表不存在"));
|
|
|
|
|
|
|
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
|
|
data.put("salaryStartMonth", ReportTimeUtil.getFormatYearMonth(po.getSalaryStartMonth()));
|
|
|
|
|
data.put("salaryEndMonth", ReportTimeUtil.getFormatYearMonth(po.getSalaryEndMonth()));
|
|
|
|
|
data.put("taxAgent", JSONArray.parseArray(po.getTaxAgentSetting()));
|
|
|
|
|
data.put("incomeCategory", JSONArray.parseArray(po.getIncomeCategorySetting()));
|
|
|
|
|
data.put("subCompany", JSONArray.parseArray(po.getSubCompanySetting()));
|
|
|
|
|
data.put("department", JSONArray.parseArray(po.getDepartSetting()));
|
|
|
|
|
data.put("grade", JSONArray.parseArray(po.getGradeSetting()));
|
|
|
|
|
data.put("position", JSONArray.parseArray(po.getPositionSetting()));
|
|
|
|
|
data.put("status", JSONArray.parseArray(po.getStatusSetting()));
|
|
|
|
|
data.put("employee", JSONArray.parseArray(po.getEmployeeSetting()));
|
|
|
|
|
data.put("hiredate", JSONArray.parseArray(po.getHiredateSetting()));
|
|
|
|
|
// data.put("leavedate", JSONArray.parseArray(po.getLeavedateSetting()));
|
|
|
|
|
|
|
|
|
|
weaSearchCondition.setData(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 搜索项目
|
|
|
|
|
// 个税扣缴义务人
|
|
|
|
|
WeaSearchConditionItem taxAgent = new WeaSearchConditionItem();
|
|
|
|
|
taxAgent.setItemType(WeaSearchConditionItemType.BROWSER);
|
|
|
|
|
WeaBrowserBean paymentOrgBrowserBean = new WeaBrowserBean(SalaryReportModule.BROWSER_MODULE, WeaBrowserTypeEnum.TAX_AGENT.getBrowserType(), Boolean.TRUE);
|
|
|
|
|
taxAgent.setBrowserBean(paymentOrgBrowserBean);
|
|
|
|
|
weaSearchCondition.getItems().put("taxAgent", taxAgent);
|
|
|
|
|
// 收入所得项目
|
|
|
|
|
WeaSearchConditionItem incomeCategory = new WeaSearchConditionItem();
|
|
|
|
|
incomeCategory.setItemType(WeaSearchConditionItemType.BROWSER);
|
|
|
|
|
WeaBrowserBean incomeCategoryBrowserBean = new WeaBrowserBean(SalaryReportModule.BROWSER_MODULE, WeaBrowserTypeEnum.INCOME_CATEGORY.getBrowserType(), Boolean.TRUE);
|
|
|
|
|
incomeCategory.setBrowserBean(incomeCategoryBrowserBean);
|
|
|
|
|
weaSearchCondition.getItems().put("incomeCategory", incomeCategory);
|
|
|
|
|
// 分部
|
|
|
|
|
WeaSearchConditionItem subCompany = new WeaSearchConditionItem();
|
|
|
|
|
subCompany.setItemType(WeaSearchConditionItemType.BROWSER);
|
|
|
|
|
WeaBrowserBean subcompanyBrowserBean = new WeaBrowserBean(SalaryReportModule.BROWSER_MODULE, "subcompany", Boolean.TRUE);
|
|
|
|
|
subCompany.setBrowserBean(subcompanyBrowserBean);
|
|
|
|
|
weaSearchCondition.getItems().put("subCompany", subCompany);
|
|
|
|
|
// 部门
|
|
|
|
|
WeaSearchConditionItem department = new WeaSearchConditionItem();
|
|
|
|
|
department.setItemType(WeaSearchConditionItemType.BROWSER);
|
|
|
|
|
WeaBrowserBean departmentBrowserBean = new WeaBrowserBean(SalaryReportModule.BROWSER_MODULE, "department", Boolean.TRUE);
|
|
|
|
|
department.setBrowserBean(departmentBrowserBean);
|
|
|
|
|
weaSearchCondition.getItems().put("department", department);
|
|
|
|
|
// 职级
|
|
|
|
|
WeaSearchConditionItem grade = new WeaSearchConditionItem();
|
|
|
|
|
grade.setItemType(WeaSearchConditionItemType.BROWSER);
|
|
|
|
|
WeaBrowserBean gradeBrowserBean = new WeaBrowserBean(SalaryReportModule.BROWSER_MODULE, "grade", Boolean.TRUE);
|
|
|
|
|
grade.setBrowserBean(gradeBrowserBean);
|
|
|
|
|
weaSearchCondition.getItems().put("grade", grade);
|
|
|
|
|
// 岗位
|
|
|
|
|
WeaSearchConditionItem position = new WeaSearchConditionItem();
|
|
|
|
|
position.setItemType(WeaSearchConditionItemType.BROWSER);
|
|
|
|
|
WeaBrowserBean positionBrowserBean = new WeaBrowserBean(SalaryReportModule.BROWSER_MODULE, "position", Boolean.TRUE);
|
|
|
|
|
position.setBrowserBean(positionBrowserBean);
|
|
|
|
|
weaSearchCondition.getItems().put("position", position);
|
|
|
|
|
// 人事状态
|
|
|
|
|
WeaSearchConditionItem status = new WeaSearchConditionItem();
|
|
|
|
|
status.setItemType(WeaSearchConditionItemType.BROWSER);
|
|
|
|
|
WeaBrowserBean statusBrowserBean = new WeaBrowserBean(SalaryReportModule.BROWSER_MODULE, WeaBrowserTypeEnum.USER_STATUS.getBrowserType(), Boolean.TRUE);
|
|
|
|
|
status.setBrowserBean(statusBrowserBean);
|
|
|
|
|
weaSearchCondition.getItems().put("status", status);
|
|
|
|
|
// 人员
|
|
|
|
|
WeaSearchConditionItem employee = new WeaSearchConditionItem();
|
|
|
|
|
employee.setItemType(WeaSearchConditionItemType.BROWSER);
|
|
|
|
|
WeaBrowserBean employeeBrowserBean = new WeaBrowserBean(SalaryReportModule.BROWSER_MODULE, "resource", Boolean.TRUE);
|
|
|
|
|
employee.setBrowserBean(employeeBrowserBean);
|
|
|
|
|
weaSearchCondition.getItems().put("employee", employee);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> otherParams = Maps.newHashMap();
|
|
|
|
|
otherParams.put("isRange", true);
|
|
|
|
|
otherParams.put("type", "day");
|
|
|
|
|
otherParams.put("startPlaceholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 90648, "开始日期"));
|
|
|
|
|
otherParams.put("endPlaceholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 90649, "结束日期"));
|
|
|
|
|
// 在otherParams中添加 showMultiBtnGroup showUnlimit 这两个字段 并且都为false
|
|
|
|
|
// 入职日期
|
|
|
|
|
WeaSearchConditionItem hiredate = new WeaSearchConditionItem();
|
|
|
|
|
hiredate.setItemType(WeaSearchConditionItemType.DATEPICKER);
|
|
|
|
|
hiredate.setOtherParams(otherParams);
|
|
|
|
|
weaSearchCondition.getItems().put("hiredate", hiredate);
|
|
|
|
|
// 离职日期
|
|
|
|
|
WeaSearchConditionItem leavedate = new WeaSearchConditionItem();
|
|
|
|
|
leavedate.setItemType(WeaSearchConditionItemType.INPUT);
|
|
|
|
|
leavedate.setReadOnly(true);
|
|
|
|
|
// leavedate.setItemType(WeaSearchConditionItemType.DATEPICKER);
|
|
|
|
|
// leavedate.setOtherParams(otherParams);
|
|
|
|
|
weaSearchCondition.getItems().put("leavedate", leavedate);
|
|
|
|
|
|
|
|
|
|
//layout布局
|
|
|
|
|
List<WeaSearchConditionLayout> firstLine = new ArrayList<>();
|
|
|
|
|
firstLine.add(new WeaSearchConditionLayout("taxAgent", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86184, "个税扣缴义务人"), new String[]{"taxAgent"}));
|
|
|
|
|
firstLine.add(new WeaSearchConditionLayout("incomeCategory", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 121908, "收入所得项目"), new String[]{"incomeCategory"}));
|
|
|
|
|
List<WeaSearchConditionLayout> secondLine = new ArrayList<>();
|
|
|
|
|
secondLine.add(new WeaSearchConditionLayout("subCompany", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 107369, "分部"), new String[]{"subCompany"}));
|
|
|
|
|
secondLine.add(new WeaSearchConditionLayout("department", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86185, "部门"), new String[]{"department"}));
|
|
|
|
|
List<WeaSearchConditionLayout> thirdLine = new ArrayList<>();
|
|
|
|
|
thirdLine.add(new WeaSearchConditionLayout("grade", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 98623, "职级"), new String[]{"grade"}));
|
|
|
|
|
thirdLine.add(new WeaSearchConditionLayout("position", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 90633, "岗位"), new String[]{"position"}));
|
|
|
|
|
List<WeaSearchConditionLayout> forthLine = new ArrayList<>();
|
|
|
|
|
forthLine.add(new WeaSearchConditionLayout("status", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 109332, "人事状态"), new String[]{"status"}));
|
|
|
|
|
forthLine.add(new WeaSearchConditionLayout("employee", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100133, "人员"), new String[]{"employee"}));
|
|
|
|
|
List<WeaSearchConditionLayout> fifthLine = new ArrayList<>();
|
|
|
|
|
fifthLine.add(new WeaSearchConditionLayout("hiredate", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86319, "入职日期"), new String[]{"hiredate"}));
|
|
|
|
|
// fifthLine.add(new WeaSearchConditionLayout("leavedate", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 95228, "离职日期"), new String[]{"leavedate"}));
|
|
|
|
|
fifthLine.add(new WeaSearchConditionLayout("leavedate", " ", new String[]{"leavedate"}));
|
|
|
|
|
|
|
|
|
|
weaSearchCondition.getLayout().add(firstLine);
|
|
|
|
|
weaSearchCondition.getLayout().add(secondLine);
|
|
|
|
|
weaSearchCondition.getLayout().add(thirdLine);
|
|
|
|
|
weaSearchCondition.getLayout().add(forthLine);
|
|
|
|
|
weaSearchCondition.getLayout().add(fifthLine);
|
|
|
|
|
return weaSearchCondition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String saveSearchCondition(SalaryStatisticsSearchConditionSaveParam param, Long currentEmployeeId, String currentTenantKey) {
|
|
|
|
|
return this.salaryStatisticsReportService.saveSearchCondition(param, currentEmployeeId, currentTenantKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取报表数据
|
|
|
|
|
*
|
|
|
|
|
* @param param
|
|
|
|
|
* @param employeeId
|
|
|
|
|
* @param tenantKey
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Object> getData(SalaryStatisticsReportDataQueryParam param, Long employeeId, String tenantKey) {
|
|
|
|
|
|
|
|
|
|
if (param.getId() == null || param.getDimensionId() == null) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
}
|
|
|
|
|
SalaryStatisticsDimensionPO dimension = salaryStatisticsDimensionService.getById(param.getDimensionId(), tenantKey);
|
|
|
|
|
if (dimension == null) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 161300, "统计维度不存在"));
|
|
|
|
|
}
|
|
|
|
|
// weaTable对象
|
|
|
|
|
WeaTable<Map<String, Object>> weaTable = new WeaTable<>();
|
|
|
|
|
// 查询报表配置
|
|
|
|
|
SalaryStatisticsReportPO po = this.salaryStatisticsReportService.getById(param.getId(), tenantKey);
|
|
|
|
|
if (po == null) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 161845, "薪酬统计报表不存在"));
|
|
|
|
|
}
|
|
|
|
|
// 查询自定义统计项目
|
|
|
|
|
List<SalaryStatisticsItemPO> salaryStatisticsItemList = this.salaryStatisticsItemService.listByStatisticsReportId(po.getId(), employeeId, tenantKey);
|
|
|
|
|
// 列表data
|
|
|
|
|
Page<Map<String, Object>> page = this.salaryStatisticsReportService.buildReportRecords(dimension, param, po, salaryStatisticsItemList, employeeId, tenantKey);
|
|
|
|
|
|
|
|
|
|
// 组装合计
|
|
|
|
|
Map<String, Object> countResultMap = SalaryStatisticsReportBO.buildTotal(page, salaryStatisticsItemList, employeeId, tenantKey);
|
|
|
|
|
|
|
|
|
|
// 人员维度分页
|
|
|
|
|
if (Objects.equal(dimension.getDimCode(), "employee")) {
|
|
|
|
|
if (CollectionUtils.isNotEmpty(page.getRecords())) {
|
|
|
|
|
page.setRecords(SalaryPageUtil.subList((int) page.getCurrent(), (int) page.getSize(), page.getRecords()));
|
|
|
|
|
weaTable.setCurrent(page.getCurrent());
|
|
|
|
|
weaTable.setTotal(page.getTotal());
|
|
|
|
|
weaTable.setPageSize(page.getSize());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
weaTable.setData(page.getRecords());
|
|
|
|
|
weaTable.setModule(SalaryReportModule.BROWSER_MODULE);
|
|
|
|
|
// 列表columns
|
|
|
|
|
List<WeaTableColumn> weaTableColumns = SalaryStatisticsReportBO.buildReportColumns(dimension.getDimName(), salaryStatisticsItemList, employeeId, tenantKey);
|
|
|
|
|
weaTable.setColumns(weaTableColumns);
|
|
|
|
|
// pageuid
|
|
|
|
|
weaTable.setPageUid("salaryStatisticsReportDataPage");
|
|
|
|
|
|
|
|
|
|
Map<String, Object> resultMap = Maps.newHashMap();
|
|
|
|
|
resultMap.putAll(JsonUtil.parseMap(weaTable, Object.class));
|
|
|
|
|
resultMap.put("countResult", countResultMap);
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出报表数据
|
|
|
|
|
*
|
|
|
|
|
* @param param
|
|
|
|
|
* @param employeeId
|
|
|
|
|
* @param tenantKey
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, String> exportData(SalaryStatisticsReportDataQueryParam param, Long employeeId, String tenantKey) {
|
|
|
|
|
if (param.getId() == null || param.getDimensionId() == null) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SalaryStatisticsReportPO po = this.salaryStatisticsReportService.getById(param.getId(), tenantKey);
|
|
|
|
|
if (po == null) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 161845, "薪酬统计报表不存在"));
|
|
|
|
|
}
|
|
|
|
|
SalaryStatisticsDimensionPO dimension = salaryStatisticsDimensionService.getById(param.getDimensionId(), tenantKey);
|
|
|
|
|
if (dimension == null) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 161300, "统计维度不存在"));
|
|
|
|
|
}
|
|
|
|
|
// 查询自定义统计项目
|
|
|
|
|
List<SalaryStatisticsItemPO> salaryStatisticsItemList = this.salaryStatisticsItemService.listByStatisticsReportId(po.getId(), employeeId, tenantKey);
|
|
|
|
|
// 列表data
|
|
|
|
|
Page<Map<String, Object>> page = this.salaryStatisticsReportService.buildReportRecords(dimension, param, po, salaryStatisticsItemList, employeeId, tenantKey);
|
|
|
|
|
// 组装合计
|
|
|
|
|
Map<String, Object> countResultMap = SalaryStatisticsReportBO.buildTotal(page, salaryStatisticsItemList, employeeId, tenantKey);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(page.getRecords()) && MapUtils.isNotEmpty(countResultMap)) {
|
|
|
|
|
page.getRecords().add(countResultMap);
|
|
|
|
|
}
|
|
|
|
|
// 获取数据
|
|
|
|
|
List<Map<String, String>> records = CollectionUtils.emptyIfNull(page.getRecords()).stream().map(m -> m.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue() + StringUtils.EMPTY))).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 获取列头
|
|
|
|
|
List<WeaTableColumn> weaTableColumns = SalaryStatisticsReportBO.buildReportColumns(dimension.getDimName(), salaryStatisticsItemList, employeeId, tenantKey);
|
|
|
|
|
|
|
|
|
|
// 组装导出参数
|
|
|
|
|
ExportCommonParam exportParam = SalaryStatisticsReportBO.buildExportParam(dimension.getDimName(), weaTableColumns, records);
|
|
|
|
|
exportParam.setSheetName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 179263, "薪酬统计报表") + "-" + exportParam.getDimensionName());
|
|
|
|
|
return subTableExportService.exportCommon(exportParam, UserContext.getCurrentUser(), TenantContext.getCurrentTenantKey());
|
|
|
|
|
}
|
|
|
|
|
}
|