2022-03-28 16:36:40 +08:00
|
|
|
|
package com.engine.salary.entity.salaryarchive.bo;
|
|
|
|
|
|
|
2022-04-01 13:50:24 +08:00
|
|
|
|
import com.cloudstore.eccom.constant.WeaBoolAttr;
|
|
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
import com.engine.salary.common.LocalDateRange;
|
2022-04-01 13:50:24 +08:00
|
|
|
|
import com.engine.salary.constant.SalaryItemConstant;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveItemDataDTO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentDataDTO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
|
2022-07-18 18:08:59 +08:00
|
|
|
|
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
|
2022-04-01 13:50:24 +08:00
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
2022-03-28 16:36:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @Description: 薪资档案
|
|
|
|
|
|
* @Author: wangxiangzhong
|
|
|
|
|
|
* @Date: 2021-11-03 10:51
|
|
|
|
|
|
*/
|
|
|
|
|
|
public class SalaryArchiveBO {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String toString() {
|
|
|
|
|
|
return "SalaryArchiveBO{}";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 添加日期范围
|
|
|
|
|
|
* @param weaSearchCondition
|
|
|
|
|
|
* @param employeeId
|
|
|
|
|
|
* @param tenantKey
|
|
|
|
|
|
*/
|
|
|
|
|
|
// public static void addDatePickerRangeOtherParams(WeaSearchCondition weaSearchCondition, String datePickerKey, Long employeeId, String tenantKey) {
|
|
|
|
|
|
// WeaSearchConditionItem datePickerItem = weaSearchCondition.getItems().get(datePickerKey);
|
|
|
|
|
|
// 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, "结束日期"));
|
|
|
|
|
|
// datePickerItem.setOtherParams(otherParams);
|
|
|
|
|
|
// weaSearchCondition.getItems().put(datePickerKey, datePickerItem);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 构建表格动态列
|
2022-04-01 13:50:24 +08:00
|
|
|
|
*
|
2022-03-28 16:36:40 +08:00
|
|
|
|
* @param salaryItems
|
|
|
|
|
|
*/
|
2022-04-01 13:50:24 +08:00
|
|
|
|
public static List<WeaTableColumn> buildSalaryArchiveTable(List<SalaryItemPO> salaryItems) {
|
|
|
|
|
|
// 表格表头
|
|
|
|
|
|
List<WeaTableColumn> columns = new ArrayList<>();
|
|
|
|
|
|
WeaTableColumn idColumn = new WeaTableColumn("100px", "id", "id");
|
|
|
|
|
|
idColumn.setIsPrimarykey(WeaBoolAttr.TRUE);
|
|
|
|
|
|
idColumn.setDisplay(WeaBoolAttr.FALSE);
|
|
|
|
|
|
columns.add(idColumn);
|
|
|
|
|
|
WeaTableColumn employeeIdColumn = new WeaTableColumn("100px", "人员信息表的主键id", "employeeId");
|
|
|
|
|
|
employeeIdColumn.setDisplay(WeaBoolAttr.FALSE);
|
|
|
|
|
|
columns.add(employeeIdColumn);
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "username"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgentName"));
|
2022-08-09 10:09:55 +08:00
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86185, "分部"), "subcompanyName"));
|
2022-04-01 13:50:24 +08:00
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86187, "员工状态"), "employeeStatus"));
|
2022-07-18 18:08:59 +08:00
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86187, "起始发薪日期"), "payStartDate"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86187, "最后发薪日期"), "payEndDate"));
|
2022-04-01 13:50:24 +08:00
|
|
|
|
for (SalaryItemPO salaryItem : salaryItems) {
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", salaryItem.getName(), salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX));
|
|
|
|
|
|
}
|
2022-04-01 14:13:04 +08:00
|
|
|
|
columns.add(new WeaTableColumn("100px", "操作", "operate"));
|
2022-04-01 13:50:24 +08:00
|
|
|
|
return columns;
|
|
|
|
|
|
}
|
2022-03-28 16:36:40 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 构建薪资档案数据
|
2022-04-01 13:50:24 +08:00
|
|
|
|
*
|
2022-07-18 18:08:59 +08:00
|
|
|
|
* @param salaryArchiveList
|
2022-03-28 16:36:40 +08:00
|
|
|
|
* @param salaryArchiveItemDataList
|
|
|
|
|
|
* @param localDateRange
|
|
|
|
|
|
* @param allEmployeeIds
|
|
|
|
|
|
* @param isOnlyTaxAgent
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2022-07-18 18:08:59 +08:00
|
|
|
|
public static List<SalaryArchiveDataDTO> buildSalaryArchiveData(List<SalaryArchivePO> salaryArchiveList,
|
2022-03-28 20:04:27 +08:00
|
|
|
|
List<SalaryArchiveItemPO> salaryArchiveItemDataList,
|
|
|
|
|
|
LocalDateRange localDateRange,
|
|
|
|
|
|
List<Long> allEmployeeIds,
|
|
|
|
|
|
boolean isOnlyTaxAgent) {
|
|
|
|
|
|
// 开始日期
|
|
|
|
|
|
Date start = localDateRange.getFromDate();
|
|
|
|
|
|
// 结束日期
|
|
|
|
|
|
Date end = localDateRange.getEndDate();
|
|
|
|
|
|
|
|
|
|
|
|
List<SalaryArchiveDataDTO> list = new ArrayList<>();
|
2022-09-14 11:28:17 +08:00
|
|
|
|
allEmployeeIds.forEach(e -> {
|
2022-07-18 18:08:59 +08:00
|
|
|
|
// 同一个人的档案数据
|
2022-09-14 11:28:17 +08:00
|
|
|
|
List<SalaryArchivePO> salaryArchives = salaryArchiveList.stream().filter(f -> f.getEmployeeId().equals(e)).collect(Collectors.toList());
|
2022-07-18 18:08:59 +08:00
|
|
|
|
List<Long> salaryArchiveIds = salaryArchives.stream().map(SalaryArchivePO::getId).collect(Collectors.toList());
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// 同一个人的薪资项目调整历史数据
|
2022-09-14 11:28:17 +08:00
|
|
|
|
List<SalaryArchiveItemPO> salaryArchiveItems = salaryArchiveItemDataList.stream().filter(d -> salaryArchiveIds.contains(d.getSalaryArchiveId())).collect(Collectors.toList());
|
2022-03-28 20:04:27 +08:00
|
|
|
|
List<Long> salaryArchiveItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemPO::getSalaryItemId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
SalaryArchiveDataDTO salaryArchiveData = new SalaryArchiveDataDTO();
|
|
|
|
|
|
salaryArchiveData.setEmployeeId(e);
|
|
|
|
|
|
List<SalaryArchiveTaxAgentDataDTO> taxAgents = new ArrayList<>();
|
|
|
|
|
|
// 按个税扣缴义务人生效日期时间段切割
|
2022-07-18 18:08:59 +08:00
|
|
|
|
for (SalaryArchivePO salaryArchive : salaryArchives) {
|
|
|
|
|
|
Date fromDate = salaryArchive.getPayStartDate();
|
|
|
|
|
|
Date endDate = salaryArchive.getPayEndDate();
|
|
|
|
|
|
// 起始发薪日不为空,且不能比结束日期晚,最后发薪日可空可不空,但是如果不为空,就不能比开始日期早,且起始发薪日不能晚于最后发薪日
|
|
|
|
|
|
boolean isEnable = fromDate != null && !fromDate.after(end) && (endDate == null || (!fromDate.after(endDate) && !endDate.before(start)));
|
|
|
|
|
|
if (isEnable) {
|
|
|
|
|
|
SalaryArchiveTaxAgentDataDTO taxAgent = new SalaryArchiveTaxAgentDataDTO();
|
|
|
|
|
|
taxAgent.setTaxAgentId(salaryArchive.getTaxAgentId());
|
|
|
|
|
|
// taxAgent.setIncomeCategory(salaryArchive.getIncomeCategory());
|
2022-09-14 11:28:17 +08:00
|
|
|
|
taxAgent.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDate.before(start) ? start : fromDate)).endDate(endDate == null || endDate.after(end) ? end : endDate).build());
|
2022-07-18 18:08:59 +08:00
|
|
|
|
// 薪资项目数据按个税扣缴义务人切割
|
|
|
|
|
|
if (!isOnlyTaxAgent) {
|
|
|
|
|
|
// 开始日期
|
|
|
|
|
|
Date startItem = taxAgent.getEffectiveDateRange().getFromDate();
|
|
|
|
|
|
// 结束日期
|
|
|
|
|
|
Date endItem = taxAgent.getEffectiveDateRange().getEndDate();
|
|
|
|
|
|
Date endTempItem = endItem;
|
|
|
|
|
|
List<SalaryArchiveItemDataDTO> salaryItemValues = new ArrayList<>();
|
|
|
|
|
|
for (Long salaryArchiveItemId : salaryArchiveItemIds) {
|
|
|
|
|
|
for (SalaryArchiveItemPO salaryArchiveItem : salaryArchiveItems) {
|
|
|
|
|
|
if (!salaryArchiveItemId.equals(salaryArchiveItem.getSalaryItemId()) || !salaryArchiveItem.getSalaryArchiveId().equals(salaryArchive.getId())) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
Date fromDateItem = salaryArchiveItem.getEffectiveTime();
|
2022-09-14 11:28:17 +08:00
|
|
|
|
if (fromDateItem.after(endTempItem) || (!endTempItem.after(startItem) && !endTempItem.equals(startItem))) {
|
2022-07-18 18:08:59 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
SalaryArchiveItemDataDTO salaryArchiveItemData = new SalaryArchiveItemDataDTO();
|
2022-09-14 11:28:17 +08:00
|
|
|
|
salaryArchiveItemData.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDateItem.before(startItem) ? startItem : fromDateItem)).endDate(endTempItem).build());
|
|
|
|
|
|
//排除1号调薪,之前的历史周期为2022-01-01-2022-01-01这种情况
|
|
|
|
|
|
if (!salaryArchiveItemData.getEffectiveDateRange().getFromDate().before(salaryArchiveItemData.getEffectiveDateRange().getEndDate())) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2022-07-18 18:08:59 +08:00
|
|
|
|
salaryArchiveItemData.setSalaryItemId(salaryArchiveItem.getSalaryItemId());
|
|
|
|
|
|
salaryArchiveItemData.setValue(salaryArchiveItem.getItemValue());
|
|
|
|
|
|
salaryItemValues.add(salaryArchiveItemData);
|
|
|
|
|
|
endTempItem = fromDateItem;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
}
|
2022-07-18 18:08:59 +08:00
|
|
|
|
endTempItem = endItem;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
}
|
2022-07-18 18:08:59 +08:00
|
|
|
|
taxAgent.setSalaryItemValues(salaryItemValues);
|
2022-03-28 20:04:27 +08:00
|
|
|
|
}
|
2022-07-18 18:08:59 +08:00
|
|
|
|
taxAgents.add(taxAgent);
|
2022-03-28 20:04:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
salaryArchiveData.setTaxAgents(taxAgents);
|
|
|
|
|
|
list.add(salaryArchiveData);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
2022-03-28 16:36:40 +08:00
|
|
|
|
}
|