This commit is contained in:
钱涛 2023-05-09 10:43:51 +08:00
parent 7e940b4db4
commit 797d5095eb
11 changed files with 646 additions and 21 deletions

View File

@ -0,0 +1,8 @@
package com.api.salary.web;
import javax.ws.rs.Path;
@Path("/bs/hrmsalary/report/statistics/employee")
public class SalaryStatisticsEmployeeController extends com.engine.salary.report.web.SalaryStatisticsEmployeeController{
}

View File

@ -1,14 +1,10 @@
package com.engine.salary.report.entity.bo;
import com.engine.salary.util.SalaryDateUtil;
import com.google.common.collect.Sets;
import org.apache.commons.collections4.CollectionUtils;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -23,12 +19,12 @@ public class SalaryStatisticsEmployeeBO {
* @param salaryMonth
* @return
*/
public static Set<String> getSalaryMonths(Integer year, List<YearMonth> salaryMonth) {
public static Set<String> getSalaryMonths(Integer year, List<Date> salaryMonth) {
Set<String> salaryMonths = Sets.newHashSet();
// 年份参数
if (Objects.nonNull(year)) {
List<String> months = Arrays.asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
for (int i=0;i<months.size();i++) {
for (int i = 0; i < months.size(); i++) {
salaryMonths.add(year + "-" + months.get(i));
}
}
@ -36,16 +32,16 @@ public class SalaryStatisticsEmployeeBO {
if (CollectionUtils.isNotEmpty(salaryMonth)) {
salaryMonth = (salaryMonth.size() > 2 ? salaryMonth.subList(0, 1) : salaryMonth);
if (salaryMonth.size() == 2) {
if (salaryMonth.get(0).isAfter(salaryMonth.get(1))) {
if (salaryMonth.get(0).after(salaryMonth.get(1))) {
salaryMonths.clear();
salaryMonths.add("2000-01");
} else {
YearMonth startYearMonth = salaryMonth.get(0);
YearMonth endYearMonth = salaryMonth.get(1);
Date startYearMonth = salaryMonth.get(0);
Date endYearMonth = salaryMonth.get(1);
Set<String> yearMonths = Sets.newHashSet();
while (!startYearMonth.isAfter(endYearMonth)) {
yearMonths.add(startYearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM")));
startYearMonth = startYearMonth.plusMonths(1);
while (!startYearMonth.after(endYearMonth)) {
yearMonths.add(SalaryDateUtil.getFormatYearMonth(startYearMonth));
startYearMonth = SalaryDateUtil.plusMonths(startYearMonth, 1);
}
if (CollectionUtils.isNotEmpty(salaryMonths)) {
Set<String> finalSalaryMonths = salaryMonths;
@ -56,7 +52,7 @@ public class SalaryStatisticsEmployeeBO {
}
}
} else {
String singMonth = salaryMonth.get(0).format(DateTimeFormatter.ofPattern("yyyy-MM"));
String singMonth = SalaryDateUtil.getFormatYearMonth(salaryMonth.get(0));
salaryMonths.add(CollectionUtils.isNotEmpty(salaryMonths) ? (salaryMonths.contains(singMonth) ? singMonth : "2000-01") : singMonth);
}
}

View File

@ -1,5 +1,6 @@
package com.engine.salary.report.entity.dto;
import com.engine.salary.annotation.TableTitle;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
@ -21,24 +22,31 @@ public class SalaryStatisticsEmployeeListDTO {
private Long id;
//姓名
@TableTitle(title = "姓名", dataIndex = "name", key = "name")
private String name;
//分部
@TableTitle(title = "分部", dataIndex = "subCompany", key = "subCompany")
private String subCompany;
//部门
@TableTitle(title = "部门", dataIndex = "department", key = "department")
private String department;
//岗位
@TableTitle(title = "岗位", dataIndex = "position", key = "position")
private String position;
// 员工状态
@TableTitle(title = "员工状态", dataIndex = "status", key = "status")
private String status;
//工号
@TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum")
private String jobNum;
//证件号码
@TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo")
private String idNo;
//人员类型

View File

@ -5,7 +5,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.YearMonth;
import java.util.Date;
import java.util.List;
/**
@ -30,5 +30,5 @@ public class SalaryAcctEmployeeQueryParam {
private Integer year;
//薪资所属月")
private List<YearMonth> salaryMonth;
private List<Date> salaryMonth;
}

View File

@ -5,7 +5,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.YearMonth;
import java.util.Date;
import java.util.List;
/**
@ -39,5 +39,5 @@ public class SalaryStatisticsEmployeeDetailQueryParam extends BaseQueryParam {
private Integer year;
//薪资所属月
private List<YearMonth> salaryMonth;
private List<Date> salaryMonth;
}

View File

@ -6,7 +6,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.YearMonth;
import java.util.Date;
import java.util.List;
/**
@ -31,7 +31,7 @@ public class SalaryStatisticsEmployeeQueryParam extends BaseQueryParam {
private Integer year;
//薪资所属月")
private List<YearMonth> salaryMonth;
private List<Date> salaryMonth;
//人员类型ORGANIZATION内部人员 EXT_EMPLOYEE外部人员")
private EmployeeTypeEnum employeeType;

View File

@ -0,0 +1,54 @@
package com.engine.salary.report.service;
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.util.page.PageInfo;
import java.util.List;
import java.util.Map;
/**
* 薪酬统计员工明细
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface SalaryStatisticsEmployeeService {
/**
* 获取员工统计分页列表
*
* @param queryParam
* @return
*/
PageInfo<SalaryStatisticsEmployeeListDTO> listPage(SalaryStatisticsEmployeeQueryParam queryParam);
/**
* 获取员工明细结果数据
*
* @param queryParam
* @return
*/
SalaryStatisticsEmployeeDetailResultDTO getDetailSalaryAcctResult(SalaryStatisticsEmployeeDetailQueryParam queryParam);
/**
* 获取员工核算详情数据分页列表
*
* @param salaryStatisticsEmployeeDetailResult
* @param queryParam
* @return
*/
List<Map<String, Object>> listDetailPage(SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult, SalaryStatisticsEmployeeDetailQueryParam queryParam);
/**
* 导出员工详情列表
*
* @param map
* @param queryParam
*/
// void exportDetailList(Map<String, Object> map, SalaryStatisticsEmployeeDetailQueryParam queryParam);
}

View File

@ -0,0 +1,348 @@
package com.engine.salary.report.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper;
import com.engine.salary.report.common.constant.SalaryConstant;
import com.engine.salary.report.entity.bo.SalaryStatisticsEmployeeBO;
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.service.*;
import com.engine.salary.service.impl.*;
import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.hrm.User;
import java.util.*;
import java.util.stream.Collectors;
/**
* 薪酬统计员工明细
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Slf4j
public class SalaryStatisticsEmployeeServiceImpl extends Service implements SalaryStatisticsEmployeeService {
private SalaryAcctEmployeeMapper getSalaryAcctEmployeeMapper() {
return MapperProxyFactory.getProxy(SalaryAcctEmployeeMapper.class);
}
private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) {
return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user);
}
private SalaryAcctResultService getSalaryAcctResultService(User user) {
return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
}
private SalaryItemService getSalaryItemService(User user) {
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
}
// private ExtEmployeeMapper extEmployeeMapper;
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
@Override
public PageInfo<SalaryStatisticsEmployeeListDTO> listPage(SalaryStatisticsEmployeeQueryParam queryParam) {
List<SalaryStatisticsEmployeeListDTO> list = Collections.emptyList();
PageInfo<SalaryStatisticsEmployeeListDTO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list);
// 1.分权处理, 首先获取个税扣缴义务人参数
Collection<TaxAgentPO> taxAgentViews = getTaxAgentService(user).listAllTaxAgents((long) user.getUID());
List<Long> taxAgentIds = Objects.isNull(taxAgentViews) ? Lists.newArrayList() : taxAgentViews.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(taxAgentIds)) {
return page;
}
// 2.年月参数处理注意薪资所属月居然是用字符串存储的无法通过sql between处理
Set<Date> salaryMonths = SalaryStatisticsEmployeeBO.getSalaryMonths(queryParam.getYear(), queryParam.getSalaryMonth())
.stream()
.map(SalaryDateUtil::dateStrToLocalYearMonth)
.collect(Collectors.toSet());
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listByTaxAgentAndSalaryMonth(taxAgentIds, salaryMonths);
if (CollectionUtils.isEmpty(salaryAcctEmployeeList)) {
return page;
}
// if (queryParam.getEmployeeType() != null) {
// salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(s -> queryParam.getEmployeeType().getValue().equals(s.getEmployeeType())).collect(Collectors.toList());
// }
// // 外部人员id
// Set<Long> extEmployeeIds = Sets.newHashSet();
// 内部人员id
Set<Long> innerEmployeeIds = Sets.newHashSet();
for (SalaryAcctEmployeePO sae : salaryAcctEmployeeList) {
// if (EmployeeTypeEnum.EXT_EMPLOYEE.getValue().equals(sae.getEmployeeType())) {
// extEmployeeIds.add(sae.getEmployeeId());
// } else if (EmployeeTypeEnum.ORGANIZATION.getValue().equals(sae.getEmployeeType())) {
// innerEmployeeIds.add(sae.getEmployeeId());
// }
innerEmployeeIds.add(sae.getEmployeeId());
}
// 3.关键字搜索参数
if (StringUtils.isNotEmpty(queryParam.getKeyword())) {
// if (CollectionUtils.isNotEmpty(extEmployeeIds)) {
// // 查询外部人员
// List<ExtEmployeePO> extEmployeeList = new LambdaQueryChainWrapper<>(extEmployeeMapper)
// .eq(ExtEmployeePO::getTenantKey, tenantKey)
// .eq(ExtEmployeePO::getDeleteType, 0)
// .list();
// Set<Long> finalExtEmployeeIds = extEmployeeIds;
// extEmployeeIds = extEmployeeList.stream()
// .filter(e -> finalExtEmployeeIds.contains(e.getId()) && (e.getUsername().contains(queryParam.getKeyword()) || (StringUtils.isNotEmpty(e.getCardNum()) && e.getCardNum().contains(queryParam.getKeyword()))))
// .map(ExtEmployeePO::getId)
// .collect(Collectors.toSet());
// }
if (CollectionUtils.isNotEmpty(innerEmployeeIds)) {
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listAll();
Set<Long> finalInnerEmployeeIds = innerEmployeeIds;
innerEmployeeIds = salaryEmployees.stream()
.filter(e -> finalInnerEmployeeIds.contains(e.getEmployeeId()) && (e.getUsername().contains(queryParam.getKeyword()) || (StringUtils.isNotEmpty(e.getWorkcode()) && e.getWorkcode().contains(queryParam.getKeyword()))))
.map(DataCollectionEmployee::getEmployeeId)
.collect(Collectors.toSet());
// Map<Long, String> idNoMap = idNoMapByEmployeeIds(finalInnerEmployeeIds);
// for (Long k : idNoMap.keySet()) {
// if (idNoMap.get(k) != null && idNoMap.get(k).contains(queryParam.getKeyword())) {
// innerEmployeeIds.addAll(idNoMap.keySet());
// }
// }
}
}
List<Long> innerEmployeeIdList = innerEmployeeIds.stream().sorted(Comparator.comparing(e -> e)).collect(Collectors.toList());
// List<Long> extEmployeeIdList = extEmployeeIds.stream().sorted(Comparator.comparing(e -> e)).collect(Collectors.toList());
// 排序内部员工优先
list = innerEmployeeIdList.stream().map(e -> SalaryStatisticsEmployeeListDTO.builder()
.id(e)
// .employeeType(EmployeeTypeEnum.ORGANIZATION.getValue())
.build()).collect(Collectors.toList());
// list.addAll(extEmployeeIdList.stream().map(e -> SalaryStatisticsEmployeeListDTO.builder()
// .id(e)
// .employeeType(EmployeeTypeEnum.EXT_EMPLOYEE.getValue())
// .build()).collect(Collectors.toList()));
// 第一页数据显示处理
page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, SalaryStatisticsEmployeeListDTO.class);
List<SalaryStatisticsEmployeeListDTO> salaryStatisticsEmployeeListDTOs = page.getList();
List<Long> employeeIds = salaryStatisticsEmployeeListDTOs.stream().map(SalaryStatisticsEmployeeListDTO::getId).collect(Collectors.toList());
// 查询外部人员
// List<ExtEmployeePO> extEmployeeList = CollectionUtils.isEmpty(extEmployeeIdList) ? Lists.newArrayList() : new LambdaQueryChainWrapper<>(extEmployeeMapper)
// .eq(ExtEmployeePO::getTenantKey, tenantKey)
// .eq(ExtEmployeePO::getDeleteType, 0)
// .in(ExtEmployeePO::getId, extEmployeeIdList)
// .list();
// Map<Long, ExtEmployeePO> extEmployeeMap = extEmployeeList.stream().collect(Collectors.toMap(ExtEmployeePO::getId, v -> v));
List<DataCollectionEmployee> simpleEmployeeList = getSalaryEmployeeService(user).getEmployeeByIds(employeeIds);
Map<Long, DataCollectionEmployee> innerEmployeeMap = simpleEmployeeList.stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, v -> v));
salaryStatisticsEmployeeListDTOs.forEach(e -> {
DataCollectionEmployee simpleEmployee = innerEmployeeMap.get(e.getId());
e.setName(Objects.isNull(simpleEmployee) ? "" : simpleEmployee.getUsername());
e.setSubCompany(simpleEmployee.getSubcompanyName());
e.setDepartment(simpleEmployee.getDepartmentName());
e.setPosition(simpleEmployee.getJobtitleName());
e.setStatus(simpleEmployee.getStatus());
e.setJobNum(simpleEmployee.getWorkcode());
e.setIdNo(simpleEmployee.getIdNo());
});
page.setList(salaryStatisticsEmployeeListDTOs);
return page;
}
@Override
public SalaryStatisticsEmployeeDetailResultDTO getDetailSalaryAcctResult(SalaryStatisticsEmployeeDetailQueryParam queryParam) {
SalaryAssert.notNull(queryParam.getEmployeeId(), SalaryI18nUtil.getI18nLabel(163974, "人员id不能为空"));
// 薪资所属月参数如果已经有年的就取交集
Set<Date> salaryMonths = SalaryStatisticsEmployeeBO.getSalaryMonths(queryParam.getYear(), queryParam.getSalaryMonth()).stream().map(SalaryDateUtil::dateStrToLocalYearMonth).collect(Collectors.toSet());
// 1.获取该员工所有核算人员数据
SalaryAcctEmployeePO build = SalaryAcctEmployeePO.builder().employeeId(queryParam.getEmployeeId()).build();
if (CollectionUtils.isNotEmpty(queryParam.getIds())) {
build.setIds(queryParam.getIds());
}
if (CollectionUtils.isNotEmpty(salaryMonths)) {
build.setSalaryMonths(salaryMonths);
}
if (Objects.nonNull(queryParam.getTaxAgentId())) {
build.setTaxAgentId(queryParam.getTaxAgentId());
}
List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeMapper().listSome(build);
salaryAcctEmployees = salaryAcctEmployees.stream().sorted(Comparator.comparing(SalaryAcctEmployeePO::getSalaryMonth)).collect(Collectors.toList());
Collections.reverse(salaryAcctEmployees);
// 2.获取核算结果数据
Set<Long> salaryAcctEmployeeIds = salaryAcctEmployees.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toSet());
List<SalaryAcctResultPO> salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
// 3.获取薪资项目
Map<String, String> resultMap = Maps.newHashMap();
salaryAcctResultValues.forEach(sv -> {
resultMap.put(sv.getSalaryItemId() + "", sv.getResultValue());
});
List<Long> salaryItemIds = resultMap.keySet().stream().map(Long::valueOf).collect(Collectors.toList());
List<SalaryItemPO> salaryItemList = CollectionUtils.isEmpty(salaryItemIds) ? Lists.newArrayList() : getSalaryItemService(user).listByIds(salaryItemIds);
return SalaryStatisticsEmployeeDetailResultDTO.builder()
.salaryAcctEmployeeList(salaryAcctEmployees)
.salaryAcctResultValueList(salaryAcctResultValues)
.salaryItemList(salaryItemList)
.build();
}
@Override
public List<Map<String, Object>> listDetailPage(SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult, SalaryStatisticsEmployeeDetailQueryParam queryParam) {
List<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAll();
Map<Long, String> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentPO::getId, TaxAgentPO::getName);
Map<Long, List<SalaryAcctResultPO>> acctResultValueList = SalaryEntityUtil.group2Map(salaryStatisticsEmployeeDetailResult.getSalaryAcctResultValueList(), SalaryAcctResultPO::getSalaryAcctEmpId);
Map<Long, Map<String, String>> acctResultValueMap = new HashMap<>();
acctResultValueList.forEach((k, v) -> {
Map<String, String> map = new HashMap();
v.forEach(l -> {
map.put(l.getSalaryItemId() + "", l.getResultValue());
});
acctResultValueMap.put(k, map);
});
List<Map<String, Object>> list = Lists.newArrayList();
Map<String, Object> map;
for (SalaryAcctEmployeePO se : salaryStatisticsEmployeeDetailResult.getSalaryAcctEmployeeList()) {
map = Maps.newHashMap();
Map<String, String> resultValueMap = Optional.ofNullable(acctResultValueMap.get(se.getId())).orElse(Maps.newHashMap());
Map<String, Object> finalMap = map;
resultValueMap.forEach((k, v) -> {
finalMap.put(k + SalaryConstant.DYNAMIC_SUFFIX, v);
});
map.put("id", se.getId().toString());
map.put("salaryMonth", se.getSalaryMonth());
map.put("taxAgent", taxAgentMap.get(se.getTaxAgentId()));
// IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(Integer.parseInt(se.getIncomeCategory()));
// map.put("incomeCategory", Objects.isNull(incomeCategoryEnum) ? "" : SalaryI18nUtil.getI18nLabel(incomeCategoryEnum.getLabelId(), incomeCategoryEnum.getDefaultLabel()));
list.add(map);
}
return list;
}
// @Override
// public void exportDetailList(Map<String, Object> map, SalaryStatisticsEmployeeDetailQueryParam queryParam) {
// DataCollectionEmployee employee = getSalaryEmployeeService(user).getEmployeeById(queryParam.getEmployeeId());
// // 获取核算数据
// SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult;
// if (Objects.isNull(employee)) {
// salaryStatisticsEmployeeDetailResult = SalaryStatisticsEmployeeDetailResultDTO.builder()
// .salaryAcctEmployeeList(Lists.newArrayList())
// .salaryAcctResultValueList(Lists.newArrayList())
// .salaryItemList(Lists.newArrayList())
// .build();
// } else {
// salaryStatisticsEmployeeDetailResult = this.getDetailSalaryAcctResult(queryParam);
// }
//
// String nameI18n = (StringUtils.isEmpty(employee.getUsername()) ? "" : "[" + employee.getUsername() + "]") + SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 177855, "薪资明细表");
//
// List<ExcelSheetData> sheetList = new ArrayList<>();
// ExcelSheetData excelSheetData = new ExcelSheetData();
// // 1.工作簿名称
// excelSheetData.setSheetName(nameI18n);
// List<String> headerList = Lists.newArrayList();
// headerList.add(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 87614, "薪资所属月"));
// headerList.add(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86184, "个税扣缴义务人"));
// headerList.add(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 121908, "收入所得项目"));
// salaryStatisticsEmployeeDetailResult.getSalaryItemList().forEach(item -> headerList.add(item.getName()));
// // 2.表头
// excelSheetData.setHeaders(Collections.singletonList(headerList.toArray(new String[]{})));
//
// List<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAll(tenantKey);
// Map<Long, String> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentPO::getId, TaxAgentPO::getName);
//
// Map<Long, Map<String, String>> acctResultValueMap = SalaryEntityUtil.convert2Map(salaryStatisticsEmployeeDetailResult.getSalaryAcctResultValueList(), SalaryAcctResultPO::getSalaryAcctEmployeeId, SalaryAcctResultPO::getResultValue);
//
// // 组装数据
// List<List<Object>> rows = new ArrayList<>();
// for (SalaryAcctEmployeePO se : salaryStatisticsEmployeeDetailResult.getSalaryAcctEmployeeList()) {
// if (CollectionUtils.isNotEmpty(queryParam.getIds()) && !queryParam.getIds().contains(se.getId())) {
// continue;
// }
// List<Object> row = new ArrayList<>();
// row.add(se.getSalaryMonth());
// row.add(taxAgentMap.get(se.getTaxAgentId()));
// IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(Integer.parseInt(se.getIncomeCategory()));
// row.add(Objects.isNull(incomeCategoryEnum) ? "" : SalaryI18nUtil.getI18nLabel(incomeCategoryEnum.getLabelId(), incomeCategoryEnum.getDefaultLabel()));
// // 薪资项目
// Map<String, String> resultValueMap = Optional.ofNullable(acctResultValueMap.get(se.getId())).orElse(Maps.newHashMap());
// salaryStatisticsEmployeeDetailResult.getSalaryItemList().forEach(item -> row.add(Optional.ofNullable(resultValueMap.get(item.getId().toString())).orElse("")));
//
// rows.add(row);
// }
// if (CollectionUtils.isNotEmpty(rows)) {
// List<Object> countRow = new ArrayList<>();
// countRow.add(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 93278, "合计"));
// countRow.add("-");
// countRow.add("-");
//
// for (int i = 3; i < headerList.size(); i++) {
// BigDecimal sumBigDecimal = new BigDecimal(SalaryStatisticsReportBO.D_ZERO);
// for (List<Object> row : rows) {
// sumBigDecimal = sumBigDecimal.add(new BigDecimal(StringUtils.isEmpty(row.get(i).toString()) ? SalaryStatisticsReportBO.ZERO : row.get(i).toString()));
// }
// countRow.add(sumBigDecimal.toString());
// }
// rows.add(countRow);
// }
//
// // 3.表数据
// excelSheetData.setRows(rows);
//
// sheetList.add(excelSheetData);
//
// salaryBatchService.simpleExportExcel(ExportExcelInfo.builder()
//// .sharePassword(queryParam.getSharePassword())
// .bizId(map.get("biz").toString())
// .flag(true)
// .userId(employeeId)
// .eteamsId(map.get("eteamsId").toString())
// .tenantKey(tenantKey)
// .operator(map.get("username").toString())
// .module(map.get("module").toString())
// .fileName(nameI18n + ReportTimeUtil.getFormatLocalDateTime(LocalDateTime.now()))
// .handlerName("exportSalaryStatisticsEmployeeDetailList")
// .dataType(nameI18n)
// .function("exportSalaryStatisticsEmployeeDetailList").build(), sheetList);
// }
}

View File

@ -0,0 +1,77 @@
package com.engine.salary.report.web;
import com.engine.common.util.ServiceUtil;
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.wrapper.SalaryStatisticsEmployeeWrapper;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.page.PageInfo;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;
/**
* 薪酬统计员工明细
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class SalaryStatisticsEmployeeController {
private SalaryStatisticsEmployeeWrapper getSalaryStatisticsEmployeeWrapper(User user) {
return ServiceUtil.getService(SalaryStatisticsEmployeeWrapper.class, user);
}
/**
* 员工列表
*
* @param queryParam
* @return
*/
@POST
@Path("/list")
@Produces(MediaType.APPLICATION_JSON)
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsEmployeeQueryParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryStatisticsEmployeeQueryParam, PageInfo<SalaryStatisticsEmployeeListDTO>>(user).run(getSalaryStatisticsEmployeeWrapper(user)::list, queryParam);
}
/**
* 员工详情列表
*
* @param queryParam
* @return
*/
@POST
@Path("/detailList")
@Produces(MediaType.APPLICATION_JSON)
public String detailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsEmployeeDetailQueryParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryStatisticsEmployeeDetailQueryParam, Map<String, Object>>(user).run(getSalaryStatisticsEmployeeWrapper(user)::detailList, queryParam);
}
// /**
// * 导出员工详情列表
// *
// * @param queryParam
// * @return
// */
// @PostMapping("/exportDetailList")
// @ApiOperation("导出员工详情列表")
// @WeaPermission(publicPermission = true)
// public WeaResult<Map<String, Object>> exportDetailList(@RequestBody SalaryStatisticsEmployeeDetailQueryParam queryParam) {
// return WeaResult.success(getSalaryStatisticsEmployeeWrapper(user).exportDetailList(queryParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
}

View File

@ -0,0 +1,129 @@
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;
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)) {
if (Objects.nonNull(record.get(itemKey)) && StringUtils.isNotEmpty(record.get(itemKey).toString())) {
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;
// }
}

View File

@ -585,6 +585,11 @@ public class SalaryDateUtil {
ZoneId zoneOffset = StrUtil.isNotEmpty(offset) ? ZoneOffset.of(offset) : ZoneOffset.systemDefault();
return Date.from(dateTime.atZone(zoneOffset).toInstant());
}
public static Date plusMonths(Date date, int i) {
LocalDate localDate = SalaryDateUtil.dateToLocalDate(date).plusMonths(i);
return SalaryDateUtil.localDateToDate(localDate);
}
}