2023-04-10 09:47:33 +08:00
|
|
|
|
package com.engine.salary.report.wrapper;
|
|
|
|
|
|
|
2023-06-15 17:34:52 +08:00
|
|
|
|
import cn.hutool.crypto.SecureUtil;
|
2023-04-23 10:14:32 +08:00
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
2023-06-08 18:04:25 +08:00
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTable;
|
2023-06-07 15:43:23 +08:00
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
2023-04-14 15:18:18 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
2023-04-11 09:22:09 +08:00
|
|
|
|
import com.engine.core.impl.Service;
|
2023-06-15 17:34:52 +08:00
|
|
|
|
import com.engine.salary.cache.SalaryCacheKey;
|
2023-04-18 18:55:38 +08:00
|
|
|
|
import com.engine.salary.component.WeaFormOption;
|
2023-04-27 16:05:03 +08:00
|
|
|
|
import com.engine.salary.component.WeaTableColumnGroup;
|
2023-06-07 15:43:23 +08:00
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
2023-04-11 09:22:09 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2023-06-07 15:43:23 +08:00
|
|
|
|
import com.engine.salary.report.common.constant.SalaryConstant;
|
2023-04-11 09:22:09 +08:00
|
|
|
|
import com.engine.salary.report.entity.bo.SalaryStatisticsReportBO;
|
2023-06-07 15:43:23 +08:00
|
|
|
|
import com.engine.salary.report.entity.param.*;
|
2023-09-18 18:20:53 +08:00
|
|
|
|
import com.engine.salary.report.entity.po.*;
|
|
|
|
|
|
import com.engine.salary.report.service.*;
|
|
|
|
|
|
import com.engine.salary.report.service.impl.*;
|
2023-06-07 15:43:23 +08:00
|
|
|
|
import com.engine.salary.service.SalaryAcctEmployeeService;
|
|
|
|
|
|
import com.engine.salary.service.SalaryAcctResultService;
|
2023-06-15 17:34:52 +08:00
|
|
|
|
import com.engine.salary.service.SalaryCacheService;
|
2023-06-07 15:43:23 +08:00
|
|
|
|
import com.engine.salary.service.SalaryItemService;
|
|
|
|
|
|
import com.engine.salary.service.impl.SalaryAcctEmployeeServiceImpl;
|
|
|
|
|
|
import com.engine.salary.service.impl.SalaryAcctResultServiceImpl;
|
2023-06-15 17:34:52 +08:00
|
|
|
|
import com.engine.salary.service.impl.SalaryCacheServiceImpl;
|
2023-06-07 15:43:23 +08:00
|
|
|
|
import com.engine.salary.service.impl.SalaryItemServiceImpl;
|
2023-04-23 10:14:32 +08:00
|
|
|
|
import com.engine.salary.util.*;
|
2023-04-24 16:34:23 +08:00
|
|
|
|
import com.engine.salary.util.excel.ExcelUtilPlus;
|
2023-04-11 09:22:09 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2023-04-24 16:34:23 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2023-04-10 09:47:33 +08:00
|
|
|
|
import com.google.common.collect.Maps;
|
2023-04-24 16:34:23 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
import org.apache.commons.collections4.MapUtils;
|
2023-04-10 09:47:33 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2023-04-24 16:34:23 +08:00
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2023-06-08 18:04:25 +08:00
|
|
|
|
import weaver.general.PageIdConst;
|
2023-04-14 15:18:18 +08:00
|
|
|
|
import weaver.hrm.User;
|
2023-06-15 17:34:52 +08:00
|
|
|
|
import weaver.wechat.util.Utils;
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
2023-06-15 17:34:52 +08:00
|
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
|
/**
|
2023-05-05 14:08:37 +08:00
|
|
|
|
* 薪酬统计维度
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
2023-04-11 09:22:09 +08:00
|
|
|
|
public class SalaryStatisticsReportWrapper extends Service {
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
|
|
|
|
|
private static final String conditionId = "salaryStatisticsReportSearchCondition";
|
|
|
|
|
|
|
2023-04-14 15:18:18 +08:00
|
|
|
|
private SalaryStatisticsReportService getSalaryStatisticsReportService(User user) {
|
2023-04-24 14:09:27 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user);
|
2023-04-14 15:18:18 +08:00
|
|
|
|
}
|
2023-04-11 09:22:09 +08:00
|
|
|
|
|
2023-04-14 15:18:18 +08:00
|
|
|
|
private SalaryStatisticsItemService getSalaryStatisticsItemService(User user) {
|
2023-04-24 14:09:27 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryStatisticsItemServiceImpl.class, user);
|
2023-04-14 15:18:18 +08:00
|
|
|
|
}
|
2023-04-11 09:22:09 +08:00
|
|
|
|
|
2023-04-14 15:18:18 +08:00
|
|
|
|
private SalaryStatisticsDimensionService getSalaryStatisticsDimensionService(User user) {
|
2023-04-24 14:09:27 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, user);
|
2023-04-14 15:18:18 +08:00
|
|
|
|
}
|
2023-04-24 14:09:27 +08:00
|
|
|
|
|
2023-04-14 15:18:18 +08:00
|
|
|
|
private SubTableExportService getSubTableExportService(User user) {
|
2023-04-24 14:09:27 +08:00
|
|
|
|
return ServiceUtil.getService(SubTableExportServiceImpl.class, user);
|
2023-04-14 15:18:18 +08:00
|
|
|
|
}
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
2023-06-07 15:43:23 +08:00
|
|
|
|
private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryAcctResultService getSalaryAcctResultService(User user) {
|
2023-06-15 17:34:52 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
|
2023-06-07 15:43:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryItemService getSalaryItemService(User user) {
|
2023-06-15 17:34:52 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryCacheService getSalaryCacheService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryCacheServiceImpl.class, user);
|
2023-06-07 15:43:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-18 18:20:53 +08:00
|
|
|
|
private SalaryStatisticsPushService getSalaryStatisticsPushService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryStatisticsPushServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryStatisticsPushDetailService getSalaryStatisticsPushDetailService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryStatisticsPushDetailServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 报表列表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param queryParam
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-04-11 09:22:09 +08:00
|
|
|
|
public List<Map<String, Object>> list(SalaryStatisticsReportQueryParam queryParam) {
|
2023-09-18 18:20:53 +08:00
|
|
|
|
Long uid = Long.valueOf(user.getUID());
|
2023-04-10 09:47:33 +08:00
|
|
|
|
// 初始化
|
2023-09-18 18:20:53 +08:00
|
|
|
|
getSalaryStatisticsDimensionService(user).init(uid);
|
|
|
|
|
|
|
|
|
|
|
|
// 所有人能够看到自己创建的报表
|
|
|
|
|
|
List<SalaryStatisticsReportPO> reportList = getSalaryStatisticsReportService(user).listByCreator(uid);
|
|
|
|
|
|
// 获取所有没有撤回没有过期的报表ID(不包含过期失效的)
|
|
|
|
|
|
List<SalaryStatisticsPushPO> pushList = getSalaryStatisticsPushService(user).getSuccessPushListByReceiver(uid);
|
|
|
|
|
|
List<Long> sharedReportIds = pushList.stream().map(po -> Arrays.asList(StringUtils.split(po.getReportIds(), ",")))
|
|
|
|
|
|
.flatMap(Collection::stream).distinct().map(Long::valueOf).collect(Collectors.toList());
|
|
|
|
|
|
reportList.addAll(getSalaryStatisticsReportService(user).getByIds(sharedReportIds));
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(queryParam.getReportName())) {
|
|
|
|
|
|
reportList = reportList.stream().filter(rp -> rp.getReportName().contains(queryParam.getReportName())).collect(Collectors.toList());
|
|
|
|
|
|
}
|
2023-04-14 15:18:18 +08:00
|
|
|
|
List<SalaryStatisticsDimensionPO> salaryStatisticsDimensionList = this.getSalaryStatisticsDimensionService(user).listAll();
|
2023-04-10 09:47:33 +08:00
|
|
|
|
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());
|
|
|
|
|
|
|
2023-04-11 09:22:09 +08:00
|
|
|
|
List<String> dimNames = Arrays.stream(po.getDimension().split(",")).map(dim -> Optional.ofNullable(salaryStatisticsDimensionMap.get(dim)).orElse("")).collect(Collectors.toList());
|
|
|
|
|
|
temp.put("dimension", StringUtils.join(dimNames, ","));
|
2023-04-10 09:47:33 +08:00
|
|
|
|
temp.put("dimensionId", po.getDimension());
|
2023-09-18 18:20:53 +08:00
|
|
|
|
temp.put("isShare", sharedReportIds.contains(po.getId()));
|
2023-04-10 09:47:33 +08:00
|
|
|
|
result.add(temp);
|
|
|
|
|
|
});
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取薪酬统计报表表单
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param id
|
2023-04-11 09:22:09 +08:00
|
|
|
|
* @param
|
2023-04-10 09:47:33 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-04-24 14:09:27 +08:00
|
|
|
|
public Map<String, Object> getFrom(Long id) {
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
2023-04-14 15:18:18 +08:00
|
|
|
|
List<SalaryStatisticsDimensionPO> salaryStatisticsDimensions = getSalaryStatisticsDimensionService(user).listAll();
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
2023-04-18 18:55:38 +08:00
|
|
|
|
List<WeaFormOption> statsDimOptions = salaryStatisticsDimensions.stream().map(sd -> new WeaFormOption(sd.getId().toString(), sd.getDimName())).collect(Collectors.toList());
|
2023-05-24 14:17:31 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取默认维度统计
|
|
|
|
|
|
List<SalaryStatisticsDimensionPO> defaultSalaryStatisticsDimensions = getSalaryStatisticsDimensionService(user).listAllDefaultDimension();
|
|
|
|
|
|
List<Long> defaultDimensionIds = defaultSalaryStatisticsDimensions.stream().map(SalaryStatisticsDimensionPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
// 获取有薪资统计报表引用的统计维度
|
|
|
|
|
|
Set<String> haveUsedDimIds = new HashSet<>();
|
|
|
|
|
|
List<SalaryStatisticsReportPO> salaryStatisticsReports = getSalaryStatisticsReportService(user).listAll();
|
|
|
|
|
|
salaryStatisticsReports.stream().forEach(report -> Collections.addAll(haveUsedDimIds, report.getDimension().split(",")));
|
|
|
|
|
|
statsDimOptions.stream().forEach(option -> {
|
2023-06-15 17:34:52 +08:00
|
|
|
|
if (defaultDimensionIds.contains(Long.valueOf(option.getId()))) {
|
2023-05-24 14:17:31 +08:00
|
|
|
|
// 默认维度不允许修改、删除
|
|
|
|
|
|
option.setCanDelete(false);
|
|
|
|
|
|
option.setCanEdit(false);
|
2023-06-15 17:34:52 +08:00
|
|
|
|
} else if (haveUsedDimIds.contains(option.getId())) {
|
2023-05-24 14:17:31 +08:00
|
|
|
|
// 被薪资统计报表引用的不能删除
|
|
|
|
|
|
option.setCanEdit(true);
|
|
|
|
|
|
option.setCanDelete(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2023-04-18 18:55:38 +08:00
|
|
|
|
// 1.构建基础信息表单
|
2023-04-24 14:09:27 +08:00
|
|
|
|
Map<String, Object> weaForm = new HashMap<>();
|
|
|
|
|
|
weaForm.put("statsDimOptions", statsDimOptions);
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
2023-04-18 18:55:38 +08:00
|
|
|
|
|
|
|
|
|
|
if (id != null) {
|
|
|
|
|
|
SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(id);
|
|
|
|
|
|
if (po == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在"));
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String, Object> dataMap = JsonUtil.parseMap(po, Object.class);
|
|
|
|
|
|
dataMap.put("dimension", Arrays.asList(po.getDimension().split(",")));
|
2023-04-24 14:09:27 +08:00
|
|
|
|
weaForm.put("data", dataMap);
|
2023-04-10 09:47:33 +08:00
|
|
|
|
}
|
2023-04-18 18:55:38 +08:00
|
|
|
|
|
|
|
|
|
|
return weaForm;
|
2023-04-10 09:47:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 保存薪酬统计报表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param saveParam
|
2023-04-11 09:22:09 +08:00
|
|
|
|
* @param
|
2023-04-10 09:47:33 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-04-11 09:22:09 +08:00
|
|
|
|
public String save(SalaryStatisticsReportSaveParam saveParam) {
|
2023-04-14 15:18:18 +08:00
|
|
|
|
return getSalaryStatisticsReportService(user).save(saveParam);
|
2023-04-10 09:47:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除薪酬统计报表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param ids
|
2023-04-11 09:22:09 +08:00
|
|
|
|
* @param
|
2023-04-10 09:47:33 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-04-11 09:22:09 +08:00
|
|
|
|
public Map<String, Object> delete(Collection<Long> ids) {
|
2023-04-14 15:18:18 +08:00
|
|
|
|
return getSalaryStatisticsReportService(user).delete(ids);
|
2023-04-10 09:47:33 +08:00
|
|
|
|
}
|
2023-04-23 10:14:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取统计条件
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-04-24 14:09:27 +08:00
|
|
|
|
public Map<String, Object> getSearchCondition(Long id) {
|
2023-04-23 10:14:32 +08:00
|
|
|
|
// 高级搜索实例
|
2023-04-24 14:09:27 +08:00
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
2023-04-23 10:14:32 +08:00
|
|
|
|
|
|
|
|
|
|
if (id != null) {
|
|
|
|
|
|
SalaryStatisticsReportPO po = getSalaryStatisticsReportService(user).getById(id);
|
|
|
|
|
|
SalaryAssert.notNull(po, SalaryI18nUtil.getI18nLabel(152563, "报表不存在"));
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> data = new HashMap<>();
|
2023-04-24 14:57:54 +08:00
|
|
|
|
data.put("salaryStartMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth()));
|
|
|
|
|
|
data.put("salaryEndMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth()));
|
2023-04-23 10:14:32 +08:00
|
|
|
|
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()));
|
|
|
|
|
|
|
2023-04-24 14:09:27 +08:00
|
|
|
|
map.put("data", data);
|
2023-04-23 10:14:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
2023-04-11 09:22:09 +08:00
|
|
|
|
public String saveSearchCondition(SalaryStatisticsSearchConditionSaveParam param) {
|
2023-04-14 15:18:18 +08:00
|
|
|
|
return this.getSalaryStatisticsReportService(user).saveSearchCondition(param);
|
2023-04-10 09:47:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取报表数据
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-04-11 09:22:09 +08:00
|
|
|
|
public Map<String, Object> getData(SalaryStatisticsReportDataQueryParam param) {
|
2023-09-18 18:20:53 +08:00
|
|
|
|
if (param.getShare()) {
|
|
|
|
|
|
// 是被分享的报表
|
|
|
|
|
|
Long uid = Long.valueOf(user.getUID());
|
|
|
|
|
|
// 校验查看权限,获取有效的分享记录
|
|
|
|
|
|
List<SalaryStatisticsPushPO> pushList = getSalaryStatisticsPushService(user).shareReportValid(param.getId());
|
|
|
|
|
|
List<Long> batchIds = pushList.stream().map(SalaryStatisticsPushPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
getSalaryStatisticsPushService(user).updateReportViewStatus(batchIds, uid);
|
|
|
|
|
|
// salaryStatisticsPushService.sendViewedMsg(param.getBatchId(), param.getId(), employeeId, tenantKey);
|
|
|
|
|
|
}
|
2023-06-15 17:34:52 +08:00
|
|
|
|
Long id = param.getId();
|
|
|
|
|
|
if (id == null || param.getDimensionId() == null) {
|
2023-04-10 09:47:33 +08:00
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
|
}
|
2023-04-14 15:18:18 +08:00
|
|
|
|
SalaryStatisticsDimensionPO dimension = getSalaryStatisticsDimensionService(user).getById(param.getDimensionId());
|
2023-04-10 09:47:33 +08:00
|
|
|
|
if (dimension == null) {
|
2023-04-11 09:22:09 +08:00
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161300, "统计维度不存在"));
|
2023-04-10 09:47:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
// weaTable对象
|
2023-04-24 14:09:27 +08:00
|
|
|
|
Map<String, Object> weaTable = new HashMap<>();
|
2023-04-10 09:47:33 +08:00
|
|
|
|
// 查询报表配置
|
2023-06-15 17:34:52 +08:00
|
|
|
|
SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(id);
|
2023-04-10 09:47:33 +08:00
|
|
|
|
if (po == null) {
|
2023-04-11 09:22:09 +08:00
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在"));
|
2023-04-10 09:47:33 +08:00
|
|
|
|
}
|
2023-06-15 17:34:52 +08:00
|
|
|
|
|
2023-06-27 16:18:42 +08:00
|
|
|
|
// 查询自定义统计项目
|
|
|
|
|
|
List<SalaryStatisticsItemPO> salaryStatisticsItemList = this.getSalaryStatisticsItemService(user).listByStatisticsReportId(po.getId());
|
|
|
|
|
|
|
2023-06-15 18:48:31 +08:00
|
|
|
|
// 参数转换
|
|
|
|
|
|
SalaryStatisticsReportBO.poToQueryParam(param, po);
|
2023-06-27 16:18:42 +08:00
|
|
|
|
String paramMd5 = SecureUtil.md5(param + salaryStatisticsItemList.toString());
|
2023-06-15 17:34:52 +08:00
|
|
|
|
|
|
|
|
|
|
//已缓存的报表id
|
|
|
|
|
|
String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS));
|
|
|
|
|
|
String salaryReportConditions = "";
|
|
|
|
|
|
if (StringUtils.isNotBlank(salaryReportIds) && salaryReportIds.contains(id + "")) {
|
|
|
|
|
|
//报表中缓存的条件
|
|
|
|
|
|
salaryReportConditions = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id));
|
|
|
|
|
|
if (StringUtils.isNotBlank(salaryReportConditions) && salaryReportConditions.contains(paramMd5)) {
|
|
|
|
|
|
return getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
|
// 列表data
|
2023-06-15 18:48:31 +08:00
|
|
|
|
PageInfo<Map<String, Object>> page = this.getSalaryStatisticsReportService(user).buildReportRecords(dimension, param, salaryStatisticsItemList);
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
|
|
|
|
|
// 组装合计
|
2023-04-24 14:09:27 +08:00
|
|
|
|
Map<String, Object> countResultMap = SalaryStatisticsReportBO.buildTotal(page, salaryStatisticsItemList, (long) user.getUID());
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
|
|
|
|
|
// 列表columns
|
2023-04-27 16:05:03 +08:00
|
|
|
|
List<WeaTableColumnGroup> weaTableColumns = SalaryStatisticsReportBO.buildReportColumns(dimension.getDimName(), salaryStatisticsItemList);
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
|
|
|
|
|
Map<String, Object> resultMap = Maps.newHashMap();
|
|
|
|
|
|
resultMap.putAll(JsonUtil.parseMap(weaTable, Object.class));
|
2023-04-11 09:22:09 +08:00
|
|
|
|
resultMap.put("columns", weaTableColumns);
|
|
|
|
|
|
resultMap.put("pageInfo", page);
|
2023-04-10 09:47:33 +08:00
|
|
|
|
resultMap.put("countResult", countResultMap);
|
2023-06-15 17:34:52 +08:00
|
|
|
|
resultMap.put("reportId", id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getSalaryCacheService(user).set(SalaryCacheKey.SALARY_REPORT_IDS, salaryReportIds + "," + id);
|
|
|
|
|
|
getSalaryCacheService(user).set(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id, salaryReportConditions + "," + paramMd5);
|
|
|
|
|
|
getSalaryCacheService(user).set(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5, resultMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
|
return resultMap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-15 17:34:52 +08:00
|
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 导出报表数据
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-04-27 16:05:03 +08:00
|
|
|
|
public Map<String, Object> exportData(SalaryStatisticsReportDataQueryParam param) {
|
2023-04-24 16:34:23 +08:00
|
|
|
|
if (param.getId() == null || param.getDimensionId() == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(param.getId());
|
|
|
|
|
|
if (po == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在"));
|
|
|
|
|
|
}
|
|
|
|
|
|
SalaryStatisticsDimensionPO dimension = getSalaryStatisticsDimensionService(user).getById(param.getDimensionId());
|
|
|
|
|
|
if (dimension == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161300, "统计维度不存在"));
|
|
|
|
|
|
}
|
2023-06-15 18:48:31 +08:00
|
|
|
|
|
|
|
|
|
|
// 参数转换
|
|
|
|
|
|
SalaryStatisticsReportBO.poToQueryParam(param, po);
|
|
|
|
|
|
|
2023-04-24 16:34:23 +08:00
|
|
|
|
// 查询自定义统计项目
|
|
|
|
|
|
List<SalaryStatisticsItemPO> salaryStatisticsItemList = this.getSalaryStatisticsItemService(user).listByStatisticsReportId(po.getId());
|
|
|
|
|
|
// 列表data
|
2023-06-15 18:48:31 +08:00
|
|
|
|
PageInfo<Map<String, Object>> page = this.getSalaryStatisticsReportService(user).buildReportRecords(dimension, param, salaryStatisticsItemList);
|
2023-04-24 16:34:23 +08:00
|
|
|
|
// 组装合计
|
|
|
|
|
|
Map<String, Object> countResultMap = SalaryStatisticsReportBO.buildTotal(page, salaryStatisticsItemList, (long) user.getUID());
|
|
|
|
|
|
List<Map<String, Object>> list = page.getList();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list) && MapUtils.isNotEmpty(countResultMap)) {
|
|
|
|
|
|
list.add(countResultMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取数据
|
|
|
|
|
|
List<Map<String, String>> records = list.stream().map(m -> m.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue() + StringUtils.EMPTY))).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
// 获取列头
|
2023-04-27 16:05:03 +08:00
|
|
|
|
List<WeaTableColumnGroup> weaTableColumns = SalaryStatisticsReportBO.buildReportColumns(dimension.getDimName(), salaryStatisticsItemList);
|
2023-04-24 16:34:23 +08:00
|
|
|
|
|
|
|
|
|
|
// 组装导出参数
|
2023-04-11 09:22:09 +08:00
|
|
|
|
// ExportCommonParam exportParam = SalaryStatisticsReportBO.buildExportParam(dimension.getDimName(), weaTableColumns, records);
|
|
|
|
|
|
// exportParam.setSheetName(SalaryI18nUtil.getI18nLabel(179263, "薪酬统计报表") + "-" + exportParam.getDimensionName());
|
2023-04-24 16:34:23 +08:00
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
List rows = new ArrayList<>();
|
|
|
|
|
|
rows.add(weaTableColumns);
|
2023-04-27 16:05:03 +08:00
|
|
|
|
|
|
|
|
|
|
List<String> head = new ArrayList<>();
|
|
|
|
|
|
weaTableColumns.forEach(weaTableColumn -> {
|
|
|
|
|
|
String column = weaTableColumn.getColumn();
|
|
|
|
|
|
if (CollectionUtils.isEmpty(weaTableColumn.getChildren())) {
|
|
|
|
|
|
head.add(column);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
weaTableColumn.getChildren().forEach(children -> {
|
|
|
|
|
|
head.add(children.getColumn());
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2023-04-24 16:34:23 +08:00
|
|
|
|
for (Map<String, String> map : records) {
|
|
|
|
|
|
List<Object> row = Lists.newArrayListWithExpectedSize(records.size());
|
2023-04-27 16:05:03 +08:00
|
|
|
|
head.forEach(k -> {
|
2023-04-24 16:34:23 +08:00
|
|
|
|
row.add(map.getOrDefault(k, StringUtils.EMPTY));
|
2023-04-27 16:05:03 +08:00
|
|
|
|
});
|
2023-04-24 16:34:23 +08:00
|
|
|
|
rows.add(row);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String sheetName = SalaryI18nUtil.getI18nLabel(179263, "薪酬统计报表") + "-" + dimension.getDimName();
|
|
|
|
|
|
XSSFWorkbook book = ExcelUtilPlus.genWorkbookWithChildTitleColumn(rows, sheetName, true);
|
|
|
|
|
|
|
2023-04-27 16:05:03 +08:00
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
map.put("workbook", book);
|
|
|
|
|
|
map.put("fileName", sheetName);
|
2023-04-24 16:34:23 +08:00
|
|
|
|
|
|
|
|
|
|
return map;
|
2023-04-10 09:47:33 +08:00
|
|
|
|
}
|
2023-06-07 15:43:23 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取报表透视数据
|
2023-06-15 17:34:52 +08:00
|
|
|
|
*
|
2023-06-07 15:43:23 +08:00
|
|
|
|
* @param param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, Object> getDataPerspective(SalaryStatisticsDataPerspectiveQueryParam param) {
|
|
|
|
|
|
if (param.getId() == null || param.getDimensionId() == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
|
}
|
|
|
|
|
|
SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(param.getId());
|
|
|
|
|
|
if (po == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在"));
|
|
|
|
|
|
}
|
|
|
|
|
|
SalaryStatisticsDimensionPO dimension = getSalaryStatisticsDimensionService(user).getById(param.getDimensionId());
|
|
|
|
|
|
if (dimension == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161300, "统计维度不存在"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询自定义统计项目中所有薪资项目id
|
|
|
|
|
|
List<SalaryStatisticsItemPO> salaryStatisticsItemPOS = getSalaryStatisticsItemService(user).listByStatisticsReportId(param.getId());
|
|
|
|
|
|
List<Long> salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(","))
|
|
|
|
|
|
.flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList());
|
|
|
|
|
|
|
2023-06-07 16:50:09 +08:00
|
|
|
|
PageInfo<Map<String, Object>> pageInfo = getSalaryStatisticsReportService(user).buildDataPerspectiveRecords(param, po, dimension, salaryStatisticsItemPOS);
|
2023-06-07 15:43:23 +08:00
|
|
|
|
|
|
|
|
|
|
List<SalaryItemPO> itemList = getSalaryItemService(user).listByIds(salaryItemIds);
|
|
|
|
|
|
// 列表columns
|
|
|
|
|
|
List<WeaTableColumn> weaTableColumns = buildDataPerspectiveTableColumns(itemList);
|
|
|
|
|
|
|
2023-06-08 18:04:25 +08:00
|
|
|
|
WeaTable table = new WeaTable();
|
2023-06-15 17:34:52 +08:00
|
|
|
|
String pageId = "a4f85an7-9576-4125-adn9-7d06e7sy69f2";
|
2023-06-08 18:04:25 +08:00
|
|
|
|
table.setPageID(pageId);
|
2023-06-15 17:34:52 +08:00
|
|
|
|
table.setPageUID(pageId + user.getUID());
|
2023-06-08 18:04:25 +08:00
|
|
|
|
table.setPagesize(PageIdConst.getPageSize(pageId, user.getUID()));
|
|
|
|
|
|
table.setBackfields("");
|
|
|
|
|
|
|
2023-06-07 15:43:23 +08:00
|
|
|
|
table.setColumns(weaTableColumns);
|
|
|
|
|
|
|
|
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
|
|
result.success();
|
|
|
|
|
|
|
|
|
|
|
|
// 结果
|
|
|
|
|
|
Map<String, Object> resultMap = Maps.newHashMap();
|
|
|
|
|
|
resultMap.put("dataKey", result.getResultMap());
|
|
|
|
|
|
resultMap.put("pageInfo", pageInfo);
|
|
|
|
|
|
return resultMap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<WeaTableColumn> buildDataPerspectiveTableColumns(List<SalaryItemPO> salaryItems) {
|
|
|
|
|
|
// 表格表头
|
|
|
|
|
|
List<WeaTableColumn> columns = new ArrayList<>();
|
2023-06-07 16:50:09 +08:00
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "姓名"), "userName"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "部门"), "departmentName"));
|
2023-06-07 15:43:23 +08:00
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "薪资所属月"), "salaryMonth"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgent"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "账套"), "salarySob"));
|
2023-06-08 12:25:11 +08:00
|
|
|
|
// columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "次数"), "acctTimes").setDisplay(WeaBoolAttr.FALSE));
|
2023-06-07 15:43:23 +08:00
|
|
|
|
salaryItems.forEach(item -> {
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", item.getName(), item.getId() + SalaryConstant.DYNAMIC_SUFFIX));
|
|
|
|
|
|
});
|
|
|
|
|
|
return columns;
|
|
|
|
|
|
}
|
2023-04-10 09:47:33 +08:00
|
|
|
|
}
|