weaver-hrm-salary/src/com/engine/salary/report/wrapper/SalaryStatisticsEmployeeWra...

131 lines
6.1 KiB
Java
Raw Normal View History

2023-05-09 10:43:51 +08:00
package com.engine.salary.report.wrapper;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.report.common.constant.SalaryConstant;
import com.engine.salary.report.entity.bo.SalaryStatisticsReportBO;
import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeDetailResultDTO;
import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeListDTO;
import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeDetailQueryParam;
import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeQueryParam;
import com.engine.salary.report.service.SalaryStatisticsEmployeeService;
import com.engine.salary.report.service.impl.SalaryStatisticsEmployeeServiceImpl;
import com.engine.salary.report.util.ReportDataUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
2023-05-25 13:51:27 +08:00
import org.apache.commons.lang3.math.NumberUtils;
2023-05-09 10:43:51 +08:00
import weaver.hrm.User;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* 薪酬统计员工明细
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class SalaryStatisticsEmployeeWrapper extends Service {
private SalaryStatisticsEmployeeService getSalaryStatisticsEmployeeService(User user) {
return ServiceUtil.getService(SalaryStatisticsEmployeeServiceImpl.class, user);
}
/**
* 员工列表
*
* @param queryParam
* @return
*/
public PageInfo<SalaryStatisticsEmployeeListDTO> list(SalaryStatisticsEmployeeQueryParam queryParam) {
PageInfo<SalaryStatisticsEmployeeListDTO> page = getSalaryStatisticsEmployeeService(user).listPage(queryParam);
return page;
}
/**
* 员工详情列表
*
* @param queryParam
* @return
*/
public Map<String, Object> detailList(SalaryStatisticsEmployeeDetailQueryParam queryParam) {
// 获取核算数据
SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult = getSalaryStatisticsEmployeeService(user).getDetailSalaryAcctResult(queryParam);
List<Map<String, Object>> records = getSalaryStatisticsEmployeeService(user).listDetailPage(salaryStatisticsEmployeeDetailResult, queryParam);
Map<String, Object> countResultMap = Maps.newHashMap();
countResultMap.put("id", "1000000");
countResultMap.put("salaryMonth", "-");
countResultMap.put("taxAgent", "-");
countResultMap.put("incomeCategory", "-");
if (CollectionUtils.isNotEmpty(records)) {
List<SalaryItemPO> salaryItems = salaryStatisticsEmployeeDetailResult.getSalaryItemList();
for (SalaryItemPO item : salaryItems) {
BigDecimal sumBigDecimal = new BigDecimal(SalaryStatisticsReportBO.ZERO);
String itemKey = item.getId() + SalaryConstant.DYNAMIC_SUFFIX;
for (Map<String, Object> record : records) {
if (record.containsKey(itemKey)) {
2023-05-25 13:51:27 +08:00
if (Objects.nonNull(record.get(itemKey)) && StringUtils.isNotEmpty(record.get(itemKey).toString())&& NumberUtils.isCreatable(record.get(itemKey).toString())) {
2023-05-09 10:43:51 +08:00
sumBigDecimal = sumBigDecimal.add(new BigDecimal(record.get(itemKey).toString()));
record.put(itemKey, ReportDataUtil.thousandthConvert(record.get(itemKey).toString()));
}
}
}
countResultMap.put(itemKey, ReportDataUtil.thousandthConvert(sumBigDecimal.toString()));
}
}
PageInfo<Map<String, Object>> pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), records);
// 列表columns
List<WeaTableColumn> weaTableColumns = buildDetailTableColumns(salaryStatisticsEmployeeDetailResult);
// 结果
Map<String, Object> resultMap = Maps.newHashMap();
resultMap.put("columns", weaTableColumns);
resultMap.put("pageInfo", pageInfo);
return resultMap;
}
private List<WeaTableColumn> buildDetailTableColumns(SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult) {
// 表格表头
List<WeaTableColumn> columns = new ArrayList<>();
columns.add(new WeaTableColumn(SalaryI18nUtil.getI18nLabel( 87614, "薪资所属月"), "salaryMonth", "100"));
columns.add(new WeaTableColumn(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人"), "taxAgent", "150"));
columns.add(new WeaTableColumn(SalaryI18nUtil.getI18nLabel( 121908, "收入所得项目"), "incomeCategory", "150"));
salaryStatisticsEmployeeDetailResult.getSalaryItemList().forEach(item -> {
columns.add(new WeaTableColumn(item.getName(), item.getId() + SalaryConstant.DYNAMIC_SUFFIX, "100"));
});
return columns;
}
// public Map<String, Object> exportDetailList(SalaryStatisticsEmployeeDetailQueryParam queryParam) {
// SalaryAssert.notNull(queryParam.getEmployeeId(), SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 163974, "人员id不能为空"));
// // 构建异步导出参数
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportSalaryStatisticsEmployeeDetailList");
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(currentTenantKey);
// getSalaryStatisticsEmployeeService(user).exportDetailList(map, queryParam);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.execute(localRunnable);
//
// return map;
// }
}