Merge remote-tracking branch 'remotes/origin/develop' into feature/v2-baseInfoOneToMore
This commit is contained in:
commit
5daf7a1aff
|
|
@ -124,21 +124,21 @@ delete from hrsa_insurance_base_info where 1=1
|
|||
|
||||
|
||||
INSERT INTO hrsa_insurance_category (id, insurance_name, welfare_type, is_use, payment_scope, data_type, create_time, update_time, creator, delete_type, tenant_key) VALUES (9001, '养老保险', 1, 1, '1,2', 1, '2022-02-22 10:46:02', '2022-02-22 10:46:02', 0, 0, 'all_teams')
|
||||
;
|
||||
;
|
||||
INSERT INTO hrsa_insurance_category (id, insurance_name, welfare_type, is_use, payment_scope, data_type, create_time, update_time, creator, delete_type, tenant_key) VALUES (9002, '医疗保险', 1, 1, '1,2', 1, '2022-02-22 10:46:02', '2022-02-22 10:46:02', 0, 0, 'all_teams')
|
||||
;
|
||||
;
|
||||
INSERT INTO hrsa_insurance_category (id, insurance_name, welfare_type, is_use, payment_scope, data_type, create_time, update_time, creator, delete_type, tenant_key) VALUES (9003, '工伤保险', 1, 1, '1,2', 1, '2022-02-22 10:46:02', '2022-02-22 10:46:02', 0, 0, 'all_teams')
|
||||
;
|
||||
;
|
||||
INSERT INTO hrsa_insurance_category (id, insurance_name, welfare_type, is_use, payment_scope, data_type, create_time, update_time, creator, delete_type, tenant_key) VALUES (9004, '失业保险', 1, 1, '1,2', 1, '2022-02-22 10:46:02', '2022-02-22 10:46:02', 0, 0, 'all_teams')
|
||||
;
|
||||
;
|
||||
INSERT INTO hrsa_insurance_category (id, insurance_name, welfare_type, is_use, payment_scope, data_type, create_time, update_time, creator, delete_type, tenant_key) VALUES (9005, '生育保险', 1, 1, '1,2', 1, '2022-02-22 10:46:02', '2022-02-22 10:46:02', 0, 0, 'all_teams')
|
||||
;
|
||||
;
|
||||
INSERT INTO hrsa_insurance_category (id, insurance_name, welfare_type, is_use, payment_scope, data_type, create_time, update_time, creator, delete_type, tenant_key) VALUES (9006, '住房公积金', 2, 1, '1,2', 1, '2022-02-22 10:46:02', '2022-02-22 10:46:02', 0, 0, 'all_teams')
|
||||
;
|
||||
;
|
||||
INSERT INTO hrsa_insurance_category (id, insurance_name, welfare_type, is_use, payment_scope, data_type, create_time, update_time, creator, delete_type, tenant_key) VALUES (9007, '企业年金', 3, 1, '1,2', 1, '2022-02-22 10:46:02', '2022-02-22 10:46:02', 0, 0, 'all_teams')
|
||||
;
|
||||
;
|
||||
INSERT INTO hrsa_insurance_category (id, insurance_name, welfare_type, is_use, payment_scope, data_type, create_time, update_time, creator, delete_type, tenant_key) VALUES (9008, '补充住房公积金', 2, 1, '1,2', 1, '2022-02-22 10:46:02', '2022-02-22 10:46:02', 0, 0, 'all_teams')
|
||||
;
|
||||
;
|
||||
|
||||
|
||||
INSERT INTO hrsa_tax_agent_base(id, devolution_status, create_time, update_time, creator, delete_type, tenant_key) VALUES (1653303537239, 0, '2022-05-23 18:58:53', '2022-05-23 19:12:12', 1, 0, 'all_teams');
|
||||
|
|
|
|||
|
|
@ -1319,7 +1319,8 @@ public class SIArchivesBiz {
|
|||
addBaseInfoList.add(po);
|
||||
}
|
||||
//将历史基本信息入库
|
||||
getInsuranceBaseInfoMapper().batchSave(addBaseInfoList);
|
||||
List<List<InsuranceArchivesBaseInfoPO>> partition = Lists.partition(addBaseInfoList, 50);
|
||||
partition.forEach(getInsuranceBaseInfoMapper()::batchSave);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.engine.salary.constant;
|
||||
|
||||
/**
|
||||
* @Description: 薪资档案常量
|
||||
* @Author: wangxiangzhong
|
||||
* @Date: 2022/5/27 13:32
|
||||
*/
|
||||
public class SalaryArchiveConstant {
|
||||
|
||||
/**
|
||||
* 数字正则表达式
|
||||
* 包含负数、正数、小数、0、0.00000等
|
||||
*/
|
||||
public static final String NUMBER_REGEX = "(-?[1-9]\\d*\\.?\\d+)|(-?0\\.\\d*[0-9])|(\\d+)";
|
||||
}
|
||||
|
|
@ -102,18 +102,88 @@ public class SalaryArchiveBO {
|
|||
LocalDateRange localDateRange,
|
||||
List<Long> allEmployeeIds,
|
||||
boolean isOnlyTaxAgent) {
|
||||
// // 开始日期
|
||||
// Date start = localDateRange.getFromDate();
|
||||
// // 结束日期
|
||||
// Date end = localDateRange.getEndDate();
|
||||
//
|
||||
// List<SalaryArchiveDataDTO> list = new ArrayList<>();
|
||||
// allEmployeeIds.forEach(e -> {
|
||||
// // 同一个人的档案数据
|
||||
// List<SalaryArchivePO> salaryArchives = salaryArchiveList.stream().filter(f -> f.getEmployeeId().equals(e)).collect(Collectors.toList());
|
||||
// List<Long> salaryArchiveIds = salaryArchives.stream().map(SalaryArchivePO::getId).collect(Collectors.toList());
|
||||
// // 同一个人的薪资项目调整历史数据
|
||||
// List<SalaryArchiveItemPO> salaryArchiveItems = salaryArchiveItemDataList.stream().filter(d -> salaryArchiveIds.contains(d.getSalaryArchiveId())).collect(Collectors.toList());
|
||||
// List<Long> salaryArchiveItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemPO::getSalaryItemId).distinct().collect(Collectors.toList());
|
||||
//
|
||||
// SalaryArchiveDataDTO salaryArchiveData = new SalaryArchiveDataDTO();
|
||||
// salaryArchiveData.setEmployeeId(e);
|
||||
// List<SalaryArchiveTaxAgentDataDTO> taxAgents = new ArrayList<>();
|
||||
// // 按个税扣缴义务人生效日期时间段切割
|
||||
// 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());
|
||||
// taxAgent.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDate.before(start) ? start : fromDate)).endDate(endDate == null || endDate.after(end) ? end : endDate).build());
|
||||
// // 薪资项目数据按个税扣缴义务人切割
|
||||
// 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();
|
||||
// if (fromDateItem.after(endTempItem) || (!endTempItem.after(startItem) && !endTempItem.equals(startItem))) {
|
||||
// continue;
|
||||
// }
|
||||
// SalaryArchiveItemDataDTO salaryArchiveItemData = new SalaryArchiveItemDataDTO();
|
||||
// salaryArchiveItemData.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDateItem.before(startItem) ? startItem : fromDateItem)).endDate(endTempItem).build());
|
||||
// //fixme 排除1号调薪,之前的历史周期为2022-01-01-2022-01-01这种情况
|
||||
// if (!salaryArchiveItemData.getEffectiveDateRange().getFromDate().before(salaryArchiveItemData.getEffectiveDateRange().getEndDate())) {
|
||||
// continue;
|
||||
// }
|
||||
// salaryArchiveItemData.setSalaryItemId(salaryArchiveItem.getSalaryItemId());
|
||||
// salaryArchiveItemData.setValue(salaryArchiveItem.getItemValue());
|
||||
// salaryItemValues.add(salaryArchiveItemData);
|
||||
// endTempItem = fromDateItem;
|
||||
// }
|
||||
// endTempItem = endItem;
|
||||
// }
|
||||
// taxAgent.setSalaryItemValues(salaryItemValues);
|
||||
// }
|
||||
// taxAgents.add(taxAgent);
|
||||
// }
|
||||
// }
|
||||
// salaryArchiveData.setTaxAgents(taxAgents);
|
||||
// list.add(salaryArchiveData);
|
||||
// });
|
||||
//
|
||||
// return list;
|
||||
|
||||
|
||||
// 开始日期
|
||||
Date start = localDateRange.getFromDate();
|
||||
// 结束日期
|
||||
Date end = localDateRange.getEndDate();
|
||||
|
||||
List<SalaryArchiveDataDTO> list = new ArrayList<>();
|
||||
allEmployeeIds.forEach(e -> {
|
||||
allEmployeeIds.forEach(e->{
|
||||
// 同一个人的档案数据
|
||||
List<SalaryArchivePO> salaryArchives = salaryArchiveList.stream().filter(f -> f.getEmployeeId().equals(e)).collect(Collectors.toList());
|
||||
List<SalaryArchivePO> salaryArchives = salaryArchiveList.stream().filter(f->f.getEmployeeId().equals(e)).collect(Collectors.toList());
|
||||
List<Long> salaryArchiveIds = salaryArchives.stream().map(SalaryArchivePO::getId).collect(Collectors.toList());
|
||||
// 同一个人的薪资项目调整历史数据
|
||||
List<SalaryArchiveItemPO> salaryArchiveItems = salaryArchiveItemDataList.stream().filter(d -> salaryArchiveIds.contains(d.getSalaryArchiveId())).collect(Collectors.toList());
|
||||
List<SalaryArchiveItemPO> salaryArchiveItems = salaryArchiveItemDataList.stream().filter(d->salaryArchiveIds.contains(d.getSalaryArchiveId())).collect(Collectors.toList());
|
||||
List<Long> salaryArchiveItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemPO::getSalaryItemId).distinct().collect(Collectors.toList());
|
||||
|
||||
SalaryArchiveDataDTO salaryArchiveData = new SalaryArchiveDataDTO();
|
||||
|
|
@ -129,7 +199,8 @@ public class SalaryArchiveBO {
|
|||
SalaryArchiveTaxAgentDataDTO taxAgent = new SalaryArchiveTaxAgentDataDTO();
|
||||
taxAgent.setTaxAgentId(salaryArchive.getTaxAgentId());
|
||||
// taxAgent.setIncomeCategory(salaryArchive.getIncomeCategory());
|
||||
taxAgent.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDate.before(start) ? start : fromDate)).endDate(endDate == null || endDate.after(end) ? end : endDate).build());
|
||||
// taxAgent.setSalarySobIds(salaryArchiveSobList.stream().filter(sob->sob.getSalaryArchiveId().equals(salaryArchive.getId())).map(SalaryArchiveSobPO::getSalarySobId).distinct().collect(Collectors.toList()));
|
||||
taxAgent.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDate.before(start)?start:fromDate)).endDate(endDate == null || endDate.after(end)?end:endDate).build());
|
||||
// 薪资项目数据按个税扣缴义务人切割
|
||||
if (!isOnlyTaxAgent) {
|
||||
// 开始日期
|
||||
|
|
@ -144,15 +215,11 @@ public class SalaryArchiveBO {
|
|||
continue;
|
||||
}
|
||||
Date fromDateItem = salaryArchiveItem.getEffectiveTime();
|
||||
if (fromDateItem.after(endTempItem) || (!endTempItem.after(startItem) && !endTempItem.equals(startItem))) {
|
||||
if (fromDateItem.after(endTempItem) || !endTempItem.after(startItem)) {
|
||||
continue;
|
||||
}
|
||||
SalaryArchiveItemDataDTO salaryArchiveItemData = new SalaryArchiveItemDataDTO();
|
||||
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;
|
||||
}
|
||||
salaryArchiveItemData.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDateItem.before(startItem)?startItem:fromDateItem)).endDate(endTempItem).build());
|
||||
salaryArchiveItemData.setSalaryItemId(salaryArchiveItem.getSalaryItemId());
|
||||
salaryArchiveItemData.setValue(salaryArchiveItem.getItemValue());
|
||||
salaryItemValues.add(salaryArchiveItemData);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,818 @@
|
|||
package com.engine.salary.entity.salaryarchive.bo;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.constant.SalaryArchiveConstant;
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportDTO;
|
||||
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportSameDTO;
|
||||
import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustValidDTO;
|
||||
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportHandleParam;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
||||
import com.engine.salary.enums.UserStatusEnum;
|
||||
import com.engine.salary.enums.salaryarchive.*;
|
||||
import com.engine.salary.service.SalaryEmployeeService;
|
||||
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.excel.ExcelComment;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import dm.jdbc.util.IdGenerator;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 薪资档案-excel
|
||||
* @Author: wangxiangzhong
|
||||
* @Date: 2021-11-03 10:51
|
||||
*/
|
||||
public class SalaryArchiveExcelBO extends Service {
|
||||
|
||||
|
||||
private SalaryEmployeeService getSalaryEmployeeService() {
|
||||
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
||||
}
|
||||
|
||||
public static String userNameI18n;
|
||||
public static String departmentI18n;
|
||||
public static String jobNumI18n;
|
||||
public static String hrStatusI18n;
|
||||
public static String repeatMsg;
|
||||
public static String taxAgentI18n;
|
||||
public static String taxAgentRangeMsg;
|
||||
public static String empRepeatMsg;
|
||||
|
||||
public static String notEmptyI18n;
|
||||
|
||||
public static String incomeCategoryI18n;
|
||||
public static String salarySobI18n;
|
||||
public static String effectiveTimeI18n;
|
||||
public static String payStartDateI18n;
|
||||
public static String payEndDateI18n;
|
||||
public static String adjustReasonI18n;
|
||||
public static String listTypeErrMsg;
|
||||
public static String taxAgentNoExist;
|
||||
public static String incomeCategoryNoExist;
|
||||
public static String currSalarySobI18n;
|
||||
public static String noExist;
|
||||
public static String effectiveTimeErr;
|
||||
public static String adjustReasonNoExist;
|
||||
public static String dateErr;
|
||||
public static String payStartUnableAfterEnd;
|
||||
|
||||
public static String salaryItemNoBeforeCurrentEffectiveTime;
|
||||
public static String salaryItemAdjustNoSame;
|
||||
public static String salaryItemAdjustNoSameIneffective;
|
||||
|
||||
public static String salaryArchiveErr;
|
||||
public static String numberErr;
|
||||
|
||||
/**
|
||||
* 初始化i18n
|
||||
*
|
||||
*/
|
||||
public static void initI18n() {
|
||||
userNameI18n = SalaryI18nUtil.getI18nLabel(85429, "姓名");
|
||||
departmentI18n = SalaryI18nUtil.getI18nLabel(86185, "部门");
|
||||
jobNumI18n = SalaryI18nUtil.getI18nLabel(86317, "工号");
|
||||
hrStatusI18n = SalaryI18nUtil.getI18nLabel(109332, "人事状态");
|
||||
repeatMsg = "[" + Joiner.on(",").join(new List[]{Arrays.asList(userNameI18n, departmentI18n, jobNumI18n, hrStatusI18n)}) + "]";
|
||||
taxAgentI18n = SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人");
|
||||
taxAgentRangeMsg = SalaryI18nUtil.getI18nLabel(132633, "该员工不在该个税扣缴义务人的人员范围中") + "," + SalaryI18nUtil.getI18nLabel(127308, "请检查") + repeatMsg;
|
||||
empRepeatMsg = SalaryI18nUtil.getI18nLabel(121899, "员工信息重复,请检查") + repeatMsg;
|
||||
|
||||
notEmptyI18n = SalaryI18nUtil.getI18nLabel(100577, "不能为空");
|
||||
|
||||
incomeCategoryI18n = SalaryI18nUtil.getI18nLabel(121908, "收入所得项目");
|
||||
salarySobI18n = SalaryI18nUtil.getI18nLabel(87889, "薪资账套");
|
||||
effectiveTimeI18n = SalaryI18nUtil.getI18nLabel(85904, "生效日期");
|
||||
payStartDateI18n = SalaryI18nUtil.getI18nLabel(109527, "起始发薪日期");
|
||||
payEndDateI18n = SalaryI18nUtil.getI18nLabel(109329, "最后发薪日期");
|
||||
adjustReasonI18n = SalaryI18nUtil.getI18nLabel(85431, "调整原因");
|
||||
|
||||
listTypeErrMsg = SalaryI18nUtil.getI18nLabel(115527, "该条数据不符合当前列表导入要求或其他列表存在该档案,不可导入");
|
||||
|
||||
taxAgentNoExist = SalaryI18nUtil.getI18nLabel(100545, "个税扣缴义务人不存在");
|
||||
incomeCategoryNoExist = SalaryI18nUtil.getI18nLabel(121923, "收入所得项目不存在");
|
||||
|
||||
currSalarySobI18n = SalaryI18nUtil.getI18nLabel(127213, "该收入所得项目");
|
||||
noExist = SalaryI18nUtil.getI18nLabel(127236, "不存在");
|
||||
|
||||
effectiveTimeErr = SalaryI18nUtil.getI18nLabel(102497, "生效日期错误或格式不正确,正确格式示例为'2022-01-01'、'2022/1/1'");
|
||||
adjustReasonNoExist = SalaryI18nUtil.getI18nLabel(100591, "调整原因不存在");
|
||||
|
||||
dateErr = SalaryI18nUtil.getI18nLabel(109819, "日期错误或格式不正确,正确格式示例为'2022-01-01'、'2022/1/1'");
|
||||
|
||||
payStartUnableAfterEnd = SalaryI18nUtil.getI18nLabel(109214, "起始发薪日期不可晚于最后发薪日");
|
||||
|
||||
salaryItemNoBeforeCurrentEffectiveTime = SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期");
|
||||
salaryItemAdjustNoSame = SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同");
|
||||
salaryItemAdjustNoSameIneffective = SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同");
|
||||
|
||||
salaryArchiveErr = SalaryI18nUtil.getI18nLabel(101723, "该员工的薪资档案记录有误,请检查");
|
||||
numberErr = SalaryI18nUtil.getI18nLabel(100581, "请输入数字");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查导入参数
|
||||
*
|
||||
* @param message
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public static String handleCheckParams(Map message, Map<String, Object> params) {
|
||||
String errorMsg = "";
|
||||
|
||||
String listType = Optional.ofNullable(params.get("listType")).orElse("").toString();
|
||||
String importType = Optional.ofNullable(params.get("importType")).orElse("").toString();
|
||||
if (params == null) {
|
||||
errorMsg = SalaryI18nUtil.getI18nLabel( 100582, "参数必传");
|
||||
} else if (StringUtils.isEmpty(listType)) {
|
||||
errorMsg = // SalaryI18nUtil.getI18nLabel( 100592, "导入类型必传") + "," +
|
||||
SalaryI18nUtil.getI18nLabel( 109712, "列表类型必传");
|
||||
} else {
|
||||
Optional<SalaryArchiveListTypeEnum> optionalListType = Arrays.stream(SalaryArchiveListTypeEnum.values()).filter(e -> e.getValue().equals(listType)).findFirst();
|
||||
if (optionalListType.isPresent()) {
|
||||
// 定薪列表导入有调薪导入和初始化导入
|
||||
if (optionalListType.get().getValue().equals(SalaryArchiveListTypeEnum.FIXED.getValue())) {
|
||||
Optional<SalaryArchiveImportTypeEnum> optional = Arrays.stream(SalaryArchiveImportTypeEnum.values()).filter(e -> e.getValue().equals(params.get("importType").toString())).findFirst();
|
||||
if (!optional.isPresent()) {
|
||||
errorMsg = SalaryI18nUtil.getI18nLabel( 100593, "导入类型不正确");
|
||||
} else {
|
||||
// message.setDataType(message.getDataType()
|
||||
// + "-" + SalaryI18nUtil.getI18nLabel( optionalListType.get().getLabelId(), optionalListType.get().getDefaultLabel())
|
||||
// + "-" + SalaryI18nUtil.getI18nLabel( optional.get().getLabelId(), optional.get().getDefaultLabel()));
|
||||
}
|
||||
} else {
|
||||
// message.setDataType(message.getDataType()
|
||||
// + "-" + SalaryI18nUtil.getI18nLabel( optionalListType.get().getLabelId(), optionalListType.get().getDefaultLabel()));
|
||||
}
|
||||
} else {
|
||||
errorMsg = SalaryI18nUtil.getI18nLabel( 109716, "列表类型不正确");
|
||||
}
|
||||
}
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查导入列
|
||||
*
|
||||
* @param importHandleParam
|
||||
* @param headers
|
||||
* @return
|
||||
*/
|
||||
public static String handleCheckHeaders(SalaryArchiveImportHandleParam importHandleParam, Map message, List<String> headers) {
|
||||
|
||||
List<String> headerList = headers;
|
||||
|
||||
List<String> mustHeaders = Lists.newArrayList();
|
||||
|
||||
mustHeaders.add(userNameI18n);
|
||||
mustHeaders.add(taxAgentI18n);
|
||||
// mustHeaders.add(incomeCategoryI18n);
|
||||
// mustHeaders.add(salarySobI18n);
|
||||
if (importHandleParam.isPendingList()) {
|
||||
mustHeaders.add(payStartDateI18n);
|
||||
mustHeaders.add(payEndDateI18n);
|
||||
} else if (importHandleParam.isFixedList()) {
|
||||
if (importHandleParam.isInit()) {
|
||||
mustHeaders.add(payStartDateI18n);
|
||||
mustHeaders.add(payEndDateI18n);
|
||||
mustHeaders.add(effectiveTimeI18n);
|
||||
} else if (importHandleParam.isSalaryItemAdjust()) {
|
||||
mustHeaders.add(adjustReasonI18n);
|
||||
mustHeaders.add(effectiveTimeI18n);
|
||||
}
|
||||
} else if (importHandleParam.isSuspendList()) {
|
||||
mustHeaders.add(payEndDateI18n);
|
||||
}
|
||||
// 缺少的必须列
|
||||
List<String> lackHeaders = mustHeaders.stream().filter(item -> !headerList.contains(item)).collect(Collectors.toList());
|
||||
String checkHeaderI18n = SalaryI18nUtil.getI18nLabel(101850, "缺少如下列,请检查:");
|
||||
|
||||
return CollectionUtils.isNotEmpty(lackHeaders) ? checkHeaderI18n + Joiner.on(",").join((Iterable<?>) lackHeaders) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建excel单元格注释
|
||||
*
|
||||
* @param excelComments
|
||||
* @param commentData
|
||||
* @param startRowIndex
|
||||
* @param endRowIndex
|
||||
* @param startColIndex
|
||||
* @param endColIndex
|
||||
*/
|
||||
public static void createExcelComment(List<ExcelComment> excelComments, String commentData, int startRowIndex, int endRowIndex, int startColIndex, int endColIndex) {
|
||||
ExcelComment excelComment = new ExcelComment();
|
||||
// 起始行,结束行,起始列,结束列
|
||||
// excelComment.setCommentSheet(new Integer[]{startRowIndex, endRowIndex, startColIndex, endColIndex});
|
||||
// excelComment.setCommentRange(new Integer[]{startRowIndex, endRowIndex, startColIndex, endColIndex});
|
||||
// excelComment.setCommentData(commentData);
|
||||
excelComments.add(excelComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化导入数据校验
|
||||
* 说明:如果一个人的多条记录中有一个错那么就全部弄到错误文档中
|
||||
*
|
||||
* @param isError
|
||||
* @param rowNo
|
||||
* @param map
|
||||
* @param excelComments
|
||||
* @param errorCount
|
||||
* @param successCount
|
||||
* @param errorData
|
||||
* @param initImportData
|
||||
* @param importHandleParam
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> validInitImportData(boolean isError, int rowNo, Map<String, Object> map, List<Map<String, String>> excelComments, int errorCount, int successCount, List<Map<String, Object>> errorData, List<SalaryArchiveInitImportDTO> initImportData, SalaryArchiveImportHandleParam importHandleParam) {
|
||||
Long employeeId = Long.valueOf(Optional.ofNullable(map.get("employeeId")).orElse("0").toString());
|
||||
Long taxAgentId = Long.valueOf(Optional.ofNullable(map.get("taxAgentId")).orElse("0").toString());
|
||||
Map<String, Object> validMap = new HashMap<>();
|
||||
validMap.put("errorCount", errorCount);
|
||||
validMap.put("successCount", successCount);
|
||||
if (employeeId.equals(0L) || taxAgentId.equals(0L)) {
|
||||
return validMap;
|
||||
}
|
||||
Optional<SalaryArchiveInitImportDTO> optionalInitImport = initImportData.stream().filter(f -> f.getEmployeeId().equals(employeeId) && f.getTaxAgentId().equals(taxAgentId)).findFirst();
|
||||
AtomicInteger finalErrorCount = new AtomicInteger(errorCount);
|
||||
AtomicInteger finalSuccessCount = new AtomicInteger(successCount);
|
||||
if (optionalInitImport.isPresent()) {
|
||||
SalaryArchiveInitImportDTO initImport = optionalInitImport.get();
|
||||
List<SalaryArchiveInitImportSameDTO> sames = initImport.getSames();
|
||||
sames.add(SalaryArchiveInitImportSameDTO.builder()
|
||||
.isError(isError)
|
||||
.rowNo(rowNo)
|
||||
.row(map)
|
||||
.build());
|
||||
Optional<SalaryArchiveInitImportSameDTO> optionalSame = sames.stream().filter(SalaryArchiveInitImportSameDTO::isError).findFirst();
|
||||
// 只要是其中一行有错误
|
||||
if (optionalSame.isPresent()) {
|
||||
sames.forEach(e -> {
|
||||
if (!e.isError()) {
|
||||
e.setError(Boolean.TRUE);
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", "rowindex" + salaryArchiveErr);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryArchiveErr, finalErrorCount.get() + 1, finalErrorCount.get() + 1, 0, 0);
|
||||
finalErrorCount.addAndGet(1);
|
||||
errorData.add(e.getRow());
|
||||
finalSuccessCount.addAndGet(-1);
|
||||
}
|
||||
});
|
||||
// 如果到目前为止都没错的话,则相互之间检验调整记录
|
||||
} else {
|
||||
int nums = sames.size();
|
||||
// 1.生效时间不可重复
|
||||
List<String> effectiveTimeList = sames.stream().map(m -> Optional.ofNullable(m.getRow().get("effectiveTime")).orElse("").toString()).distinct().collect(Collectors.toList());
|
||||
// 2.薪资项目共同决定是否重复
|
||||
List<String> rowSameList = sames.stream().map(m -> {
|
||||
Map<String, Object> row = m.getRow();
|
||||
return Optional.ofNullable(row.get("salaryItemVal")).orElse("").toString();
|
||||
}).distinct().collect(Collectors.toList());
|
||||
if (effectiveTimeList.size() != nums || rowSameList.size() != nums) {
|
||||
sames.forEach(e -> {
|
||||
if (!e.isError()) {
|
||||
e.setError(Boolean.TRUE);
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", "rowindex" + salaryArchiveErr);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryArchiveErr, finalErrorCount.get() + 1, finalErrorCount.get() + 1, 0, 0);
|
||||
finalErrorCount.addAndGet(1);
|
||||
errorData.add(e.getRow());
|
||||
finalSuccessCount.addAndGet(-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
initImport.setSames(sames);
|
||||
} else {
|
||||
SalaryArchiveInitImportDTO initImport = new SalaryArchiveInitImportDTO();
|
||||
initImport.setEmployeeId(employeeId);
|
||||
initImport.setTaxAgentId(taxAgentId);
|
||||
List<SalaryArchiveInitImportSameDTO> sames = Lists.newArrayList();
|
||||
sames.add(SalaryArchiveInitImportSameDTO.builder()
|
||||
.isError(isError)
|
||||
.rowNo(rowNo)
|
||||
.row(map)
|
||||
.build());
|
||||
initImport.setSames(sames);
|
||||
initImportData.add(initImport);
|
||||
}
|
||||
// 如果出现错误
|
||||
if (isError || errorCount != finalErrorCount.get() || successCount != finalSuccessCount.get()) {
|
||||
validMap.put("errorCount", finalErrorCount.get());
|
||||
validMap.put("successCount", finalSuccessCount.get());
|
||||
// 将前面添加好的数据给过滤掉
|
||||
List<Long> salaryArchiveIds = importHandleParam.getSalaryArchiveSaves().stream().filter(f -> f.getEmployeeId().equals(employeeId) && f.getTaxAgentId().equals(taxAgentId)).map(SalaryArchivePO::getId).collect(Collectors.toList());
|
||||
importHandleParam.setSalaryArchiveSaves(importHandleParam.getSalaryArchiveSaves().stream().filter(f -> !salaryArchiveIds.contains(f.getId())).collect(Collectors.toList()));
|
||||
importHandleParam.setSalaryArchiveItemSaves(importHandleParam.getSalaryArchiveItemSaves().stream().filter(f -> !salaryArchiveIds.contains(f.getSalaryArchiveId())).collect(Collectors.toList()));
|
||||
}
|
||||
return validMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验单行数据
|
||||
*
|
||||
* @param allTodoSalaryArchives
|
||||
* @param map
|
||||
* @param headers
|
||||
* @param effectiveTimeIndex
|
||||
* @param excelComments
|
||||
* @param errorCount
|
||||
* @param importHandleParam
|
||||
* @return
|
||||
*/
|
||||
public static boolean singleRowCheck(List<String> allTodoSalaryArchives, Map<String, Object> map, List<String> headers, int effectiveTimeIndex, List<Map<String, String>> excelComments, int errorCount, SalaryArchiveImportHandleParam importHandleParam) {
|
||||
boolean isError = false;
|
||||
String rowindex = "第" + map.get("index") + "行";
|
||||
// 1.姓名
|
||||
String userName = Optional.ofNullable(map.get(userNameI18n)).orElse("").toString();
|
||||
String deparmentName = Optional.ofNullable(map.get(departmentI18n)).orElse("").toString();
|
||||
String mobileName = Optional.ofNullable(map.get("手机号")).orElse("").toString();
|
||||
String jobNum = Optional.ofNullable(map.get(jobNumI18n)).orElse("").toString();
|
||||
String hrmStatus = Optional.ofNullable(map.get(hrStatusI18n)).orElse("").toString();
|
||||
// Optional<HrmStatus> optionalStatus = importHandleParam.getHrmStatusList().stream().filter(s -> s.getName().equals(hrmStatus)).findFirst();
|
||||
// String codeId = optionalStatus.map(status -> status.getCodeId() + "").orElse("");
|
||||
|
||||
List<DataCollectionEmployee> emps = importHandleParam.getEmployees().stream().filter(e ->
|
||||
(StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName))
|
||||
&& (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName))
|
||||
&& (StringUtils.isBlank(mobileName) || Objects.equals(e.getMobile(), mobileName))
|
||||
// && (StringUtils.isBlank(jobNum) || Objects.equals(e.getWorkcode(), jobNum))
|
||||
)
|
||||
// && (StringUtils.isBlank(hrmStatus) || Objects.equals(e.getPersonnelStatus(), codeId))
|
||||
// .map(DataCollectionEmployee::getEmployeeId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Long> employeeSameIds = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
||||
employeeSameIds = emps.stream().filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())).map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
||||
employeeSameIds = emps.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList());
|
||||
}
|
||||
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 && employeeSameIds.get(0) > 0 ? employeeSameIds.get(0) : null;
|
||||
|
||||
|
||||
|
||||
// 用于初始化导入数据校验
|
||||
map.put("employeeId", employeeId);
|
||||
// String incomeCategoryCellVal = Optional.ofNullable(map.get(incomeCategoryI18n)).orElse("").toString();
|
||||
// Integer incomeCategory = SalaryArchiveBO.getIncomeCategoryValueByLabel(incomeCategoryCellVal, importHandleParam.getCurrentEmployeeId(), importHandleParam.getTenantKey());
|
||||
// 薪资账套
|
||||
// String salarySobCellVal = Optional.ofNullable(map.get(salarySobI18n)).orElse("").toString();
|
||||
// 2.生效日期
|
||||
String effectiveTimeCellVal = Optional.ofNullable(map.get(effectiveTimeI18n)).orElse("").toString().replaceAll(" 00:00:00", "");
|
||||
// 免得失败后,会追加 00:00:00
|
||||
map.put(effectiveTimeI18n, effectiveTimeCellVal);
|
||||
map.put("effectiveTime", effectiveTimeCellVal);
|
||||
Date effectiveTime = SalaryDateUtil.checkDay(effectiveTimeCellVal) ? SalaryDateUtil.dateStrToLocalDate(effectiveTimeCellVal) : null;
|
||||
// 3.个税扣缴义务人
|
||||
String taxAgentCellVal = Optional.ofNullable(map.get(taxAgentI18n)).orElse("").toString();
|
||||
// 用于初始化导入的同一个人的记录校验
|
||||
map.put("taxAgent", taxAgentCellVal);
|
||||
Optional<TaxAgentManageRangeEmployeeDTO> optionalTaxAgent = importHandleParam.getTaxAgentList().stream().filter(m -> m.getTaxAgentName().equals(taxAgentCellVal)).findFirst();
|
||||
Long taxAgentId = optionalTaxAgent.map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId).orElse(null);
|
||||
|
||||
List<Long> finalEmployeeSameIds = employeeSameIds;
|
||||
Optional<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> optionalTaxAgentEmp = optionalTaxAgent.get().getEmployeeList().stream().filter(f -> finalEmployeeSameIds.contains(f.getEmployeeId())).findFirst();
|
||||
if (!optionalTaxAgentEmp.isPresent()) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + taxAgentRangeMsg);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, taxAgentRangeMsg, errorCount + 1, errorCount + 1, 0, 0);
|
||||
isError = true;
|
||||
return isError;
|
||||
} else {
|
||||
employeeId = optionalTaxAgentEmp.get().getEmployeeId();
|
||||
// 除了定薪中的初始化,其他导入存在相同的取第一条
|
||||
if (employeeId != null && taxAgentId != null && allTodoSalaryArchives.contains(employeeId + "-" + taxAgentId) && !importHandleParam.isInit()) {
|
||||
return isError;
|
||||
}
|
||||
if (employeeId != null && taxAgentId != null) {
|
||||
allTodoSalaryArchives.add(employeeId + "-" + taxAgentId);
|
||||
}
|
||||
}
|
||||
|
||||
// 用于初始化导入重复记录判错 ===start
|
||||
map.put("employeeId", employeeId);
|
||||
map.put("taxAgentId", taxAgentId);
|
||||
// 用于初始化导入重复记录判错 ===end
|
||||
|
||||
// 4.调整原因[薪资项目]
|
||||
String adjustReason = SalaryArchiveItemAdjustReasonEnum.getValueByDefaultLabel(Optional.ofNullable(map.get(adjustReasonI18n)).orElse("").toString());
|
||||
// 5.起始发薪日期
|
||||
String payStartDateCellVal = Optional.ofNullable(map.get(payStartDateI18n)).orElse("").toString().replaceAll(" 00:00:00", "");
|
||||
// 免得失败后,会追加 00:00:00
|
||||
map.put(payStartDateI18n, payStartDateCellVal);
|
||||
map.put("payStartDate", payStartDateCellVal);
|
||||
Date payStartDate = SalaryDateUtil.checkDay(payStartDateCellVal) ? SalaryDateUtil.dateStrToLocalDate(payStartDateCellVal) : null;
|
||||
// 6.最后发薪日期
|
||||
String payEndDateCellVal = Optional.ofNullable(map.get(payEndDateI18n)).orElse("").toString().replaceAll(" 00:00:00", "");
|
||||
// 免得失败后,会追加 00:00:00
|
||||
map.put(payEndDateI18n, payEndDateCellVal);
|
||||
map.put("payEndDate", payEndDateCellVal);
|
||||
Date payEndDate = SalaryDateUtil.checkDay(payEndDateCellVal) ? SalaryDateUtil.dateStrToLocalDate(payEndDateCellVal) : null;
|
||||
|
||||
// 构建薪资档案
|
||||
SalaryArchivePO finalSalaryArchive = buildSalaryArchive(employeeId, taxAgentId, importHandleParam);
|
||||
// 不满足构建条件
|
||||
if (finalSalaryArchive == null) {
|
||||
// SalaryI18nUtil.getI18nLabel( 100579, "姓名错误,系统内不存在该姓名")
|
||||
// SalaryI18nUtil.getI18nLabel( 101653, "该人员的薪资档案不存在,请先初始化"
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + listTypeErrMsg);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, listTypeErrMsg, errorCount + 1, errorCount + 1, 0, 0);
|
||||
isError = true;
|
||||
return isError;
|
||||
} else {
|
||||
map.put("salaryArchiveId", finalSalaryArchive.getId());
|
||||
}
|
||||
for (int j = 0; j < headers.size(); j++) {
|
||||
String header = headers.get(j);
|
||||
Object key = header;
|
||||
if (key == null) {
|
||||
continue;
|
||||
}
|
||||
String cellVal = Optional.ofNullable(map.get(key.toString())).orElse("").toString();
|
||||
|
||||
// 必填判空
|
||||
boolean isEmpty = StringUtils.isEmpty(cellVal) &&
|
||||
(userNameI18n.equals(key.toString()) || taxAgentI18n.equals(key.toString()) || incomeCategoryI18n.equals(key.toString()) || salarySobI18n.equals(key.toString())
|
||||
// 定薪列表初始化导入必填: 起始发薪日期、生效日期
|
||||
|| ((payStartDateI18n.equals(key.toString()) || effectiveTimeI18n.equals(key.toString())) && importHandleParam.isInit())
|
||||
// 定薪列表调薪必填: 调整原因、生效日期
|
||||
|| ((adjustReasonI18n.equals(key.toString()) || effectiveTimeI18n.equals(key.toString())) && importHandleParam.isSalaryItemAdjust())
|
||||
// 待停薪必填:最后发薪日期
|
||||
|| (payEndDateI18n.equals(key.toString()) && importHandleParam.isSuspendList()));
|
||||
boolean isNotEmpty = StringUtils.isNotEmpty(cellVal);
|
||||
// 判空
|
||||
if (isEmpty) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + notEmptyI18n);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, notEmptyI18n, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
}
|
||||
// 1.姓名列处理
|
||||
if (isNotEmpty && userNameI18n.equals(key.toString())) {
|
||||
if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + empRepeatMsg);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, empRepeatMsg, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
}
|
||||
// 2.个税扣缴义务人列处理
|
||||
} else if (isNotEmpty && taxAgentI18n.equals(key.toString())) {
|
||||
if (taxAgentId == null) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + taxAgentNoExist);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, taxAgentNoExist, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
}
|
||||
// 收入所得项目
|
||||
}
|
||||
// else if (isNotEmpty && incomeCategoryI18n.equals(key.toString())) {
|
||||
// if (incomeCategory == null) {
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, incomeCategoryNoExist, errorCount + 1, errorCount + 1, j, j);
|
||||
// isError = true;
|
||||
// } else {
|
||||
// finalSalaryArchive.setIncomeCategory(incomeCategory);
|
||||
// }
|
||||
// 薪资账套
|
||||
// }
|
||||
// else if (isNotEmpty && salarySobI18n.equals(key.toString())) {
|
||||
// List<String> salarySobNames = Arrays.stream(salarySobCellVal.split(",")).distinct().collect(Collectors.toList());
|
||||
// List<Long> salarySobIds = Lists.newArrayList();
|
||||
// importHandleParam.getSalarySobList().forEach(sob -> {
|
||||
// List<Integer> incomeCategorys = StringUtils.isEmpty(sob.getIncomeCategory()) ? Lists.newArrayList() : JsonUtil.parseList(sob.getIncomeCategory(), Integer.class);
|
||||
// if (salarySobNames.contains(sob.getName()) && incomeCategory != null && incomeCategorys.contains(incomeCategory)) {
|
||||
// salarySobIds.add(sob.getId());
|
||||
// salarySobNames.remove(sob.getName());
|
||||
// }
|
||||
// });
|
||||
// if (CollectionUtils.isNotEmpty(salarySobNames)) {
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, currSalarySobI18n + (StringUtils.isEmpty(incomeCategoryCellVal) ? "" : "[" + incomeCategoryCellVal + "]") + ": " + salarySobI18n + "[" + Joiner.on(",").join(salarySobNames) + "]" + noExist, errorCount + 1, errorCount + 1, j, j);
|
||||
// isError = true;
|
||||
// } else {
|
||||
// finalSalaryArchive.setIncomeCategory(incomeCategory);
|
||||
// importHandleParam.getSalaryArchiveSobSaves().addAll(SalaryArchiveBO.buildSalaryArchiveSob(finalSalaryArchive.getId(), salarySobIds, importHandleParam.getNowTime(), importHandleParam.getCurrentEmployeeId(), importHandleParam.getTenantKey()));
|
||||
// }
|
||||
// 3.生效时间处理(定薪的调薪\定薪的初始化)
|
||||
// }
|
||||
else if (isNotEmpty && effectiveTimeI18n.equals(key.toString()) && effectiveTime == null && importHandleParam.isFixedList()) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + effectiveTimeErr);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, effectiveTimeErr, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
// 4.调整原因列(定薪的调薪)
|
||||
} else if (isNotEmpty && adjustReasonI18n.equals(key.toString()) && StringUtils.isEmpty(adjustReason) && importHandleParam.isSalaryItemAdjust()) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + adjustReasonNoExist);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, adjustReasonNoExist, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
// 5.起始发薪日期处理(定薪的初始化\待定新)
|
||||
} else if (isNotEmpty && payStartDateI18n.equals(key.toString()) && (importHandleParam.isInit() || importHandleParam.isPendingList())) {
|
||||
if (payStartDate == null) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + dateErr);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, dateErr, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
}
|
||||
// 正确的话,并且定薪或待定薪的档案存在
|
||||
if (payStartDate != null) {
|
||||
if (payEndDate != null || finalSalaryArchive.getPayEndDate() != null) {
|
||||
Date payEndDateTemp = payEndDate != null ? payEndDate : (finalSalaryArchive.getPayEndDate() != null ? finalSalaryArchive.getPayEndDate() : null);
|
||||
// todo 1.定薪的允许编辑,若已存在已归档的核算数据则不可编辑
|
||||
|
||||
if (payEndDateTemp != null && payStartDate.after(payEndDateTemp)) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + payStartUnableAfterEnd);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, payStartUnableAfterEnd, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
}
|
||||
}
|
||||
// 2.待停薪只能不允许编辑起始发薪日期
|
||||
if (!importHandleParam.isSuspendList() && !isError) {
|
||||
finalSalaryArchive.setPayStartDate(payStartDate);
|
||||
}
|
||||
}
|
||||
// 6.最后发薪日期处理(待定薪\定薪的初始化\待停薪)
|
||||
} else if (payEndDateI18n.equals(key.toString()) && !importHandleParam.isSalaryItemAdjust()) {
|
||||
if (isNotEmpty) {
|
||||
if (payEndDate == null) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + dateErr);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, dateErr, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
}
|
||||
if (payEndDate != null) {
|
||||
if (payStartDate != null || finalSalaryArchive.getPayStartDate() != null) {
|
||||
Date payStartDateTemp = payStartDate != null ? payStartDate : (finalSalaryArchive.getPayStartDate() != null ? finalSalaryArchive.getPayStartDate() : null);
|
||||
// todo 1.定薪的允许编辑,若已存在已归档的核算数据则不可编辑
|
||||
|
||||
// 2.待停薪只能不允许编辑起始发薪日期
|
||||
if (importHandleParam.isSuspendList()) {
|
||||
payStartDateTemp = finalSalaryArchive.getPayStartDate();
|
||||
}
|
||||
if (payStartDateTemp != null && payStartDateTemp.after(payEndDate)) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + payStartUnableAfterEnd);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, payStartUnableAfterEnd, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
}
|
||||
}
|
||||
if (!isError) {
|
||||
finalSalaryArchive.setPayEndDate(payEndDate);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
finalSalaryArchive.setPayEndDate(null);
|
||||
}
|
||||
// 7.薪资项目列处理(待定薪\定薪的初始化\定薪的调薪)
|
||||
} else {
|
||||
isError = handleSalaryItem(isError, effectiveTimeIndex, excelComments, errorCount, j,
|
||||
effectiveTime, finalSalaryArchive, adjustReason, importHandleParam, key.toString(), cellVal, map);
|
||||
}
|
||||
}
|
||||
// 如果当前校验行没问题,修改起始发薪日期和最终发薪日期等
|
||||
if (!isError) {
|
||||
Optional<SalaryArchivePO> optionalUpdate = importHandleParam.getSalaryArchiveUpdates().stream().filter(f -> f.getId().equals(finalSalaryArchive.getId())).findFirst();
|
||||
boolean unEnable = finalSalaryArchive.getPayStartDate() != null && finalSalaryArchive.getPayEndDate() != null && finalSalaryArchive.getPayStartDate().after(finalSalaryArchive.getPayEndDate());
|
||||
if (optionalUpdate.isPresent() && !unEnable) {
|
||||
List<SalaryArchivePO> updates = importHandleParam.getSalaryArchiveUpdates().stream().filter(f -> !f.getId().equals(finalSalaryArchive.getId())).collect(Collectors.toList());
|
||||
updates.add(finalSalaryArchive);
|
||||
importHandleParam.setSalaryArchiveUpdates(updates);
|
||||
}
|
||||
Optional<SalaryArchivePO> optionalSave = importHandleParam.getSalaryArchiveSaves().stream().filter(f -> f.getId().equals(finalSalaryArchive.getId())).findFirst();
|
||||
if (optionalSave.isPresent() && !unEnable) {
|
||||
List<SalaryArchivePO> saves = importHandleParam.getSalaryArchiveSaves().stream().filter(f -> !f.getId().equals(finalSalaryArchive.getId())).collect(Collectors.toList());
|
||||
saves.add(finalSalaryArchive);
|
||||
importHandleParam.setSalaryArchiveSaves(saves);
|
||||
}
|
||||
} else {
|
||||
// 将前面添加好的数据给过滤掉
|
||||
importHandleParam.setSalaryArchiveSaves(importHandleParam.getSalaryArchiveSaves().stream().filter(f -> !finalSalaryArchive.getId().equals(f.getId())).collect(Collectors.toList()));
|
||||
importHandleParam.setSalaryArchiveUpdates(importHandleParam.getSalaryArchiveUpdates().stream().filter(f -> !finalSalaryArchive.getId().equals(f.getId())).collect(Collectors.toList()));
|
||||
importHandleParam.setSalaryArchiveItemDelSalaryItemIds(importHandleParam.getSalaryArchiveItemDelSalaryItemIds().stream().filter(f -> !finalSalaryArchive.getId().equals(f)).collect(Collectors.toList()));
|
||||
importHandleParam.setSalaryArchiveItemSaves(importHandleParam.getSalaryArchiveItemSaves().stream().filter(f -> !finalSalaryArchive.getId().equals(f.getSalaryArchiveId())).collect(Collectors.toList()));
|
||||
// importHandleParam.setSalaryArchiveSobSaves(importHandleParam.getSalaryArchiveSobSaves().stream().filter(f -> !finalSalaryArchive.getId().equals(f.getSalaryArchiveId())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return isError;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转日期
|
||||
* 兼容/和-
|
||||
*
|
||||
* @param effectiveTime
|
||||
* @return
|
||||
*/
|
||||
public static LocalDate dateStrToLocalDate(String effectiveTime) {
|
||||
LocalDate localDate = null;
|
||||
try {
|
||||
if (effectiveTime.contains("/")) {
|
||||
String[] strs = effectiveTime.split("/");
|
||||
localDate = LocalDate.of(Integer.parseInt(strs[0]), Integer.parseInt(strs[1]), Integer.parseInt(strs[2]));
|
||||
} else if (effectiveTime.contains("-")) {
|
||||
String[] strs = effectiveTime.replaceAll("-0", "-").split("-");
|
||||
// localDate = LocalDate.parse(effectiveTime, DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份日期超过最大会被改为最大
|
||||
localDate = LocalDate.of(Integer.parseInt(strs[0]), Integer.parseInt(strs[1]), Integer.parseInt(strs[2]));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
return localDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建薪资档案对象
|
||||
*
|
||||
* @param employeeId
|
||||
* @param taxAgentId
|
||||
* @param importHandleParam
|
||||
* @return
|
||||
*/
|
||||
public static SalaryArchivePO buildSalaryArchive(Long employeeId, Long taxAgentId, SalaryArchiveImportHandleParam importHandleParam) {
|
||||
SalaryArchivePO salaryArchive = importHandleParam.getSalaryArchivesMap().get(employeeId + "-" + taxAgentId);
|
||||
if (salaryArchive != null) {
|
||||
// 修改档案
|
||||
SalaryArchivePO sa = salaryArchive;
|
||||
boolean isEnabled =
|
||||
// 待定薪导入
|
||||
(sa.getRunStatus().equals(SalaryArchiveStatusEnum.PENDING.getValue()) && importHandleParam.isPendingList())
|
||||
// 调薪导入
|
||||
|| ((sa.getRunStatus().equals(SalaryArchiveStatusEnum.FIXED.getValue()) || sa.getRunStatus().equals(SalaryArchiveStatusEnum.SUSPEND.getValue())) && importHandleParam.isFixedList() && !importHandleParam.isInit())
|
||||
// 初始化导入
|
||||
|| importHandleParam.isInit()
|
||||
// 待停薪导入
|
||||
|| ((sa.getRunStatus().equals(SalaryArchiveStatusEnum.FIXED.getValue()) || sa.getRunStatus().equals(SalaryArchiveStatusEnum.SUSPEND.getValue())) && importHandleParam.isSuspendList());
|
||||
if (isEnabled) {
|
||||
if (importHandleParam.isInit()) {
|
||||
sa.setRunStatus(SalaryArchiveStatusEnum.FIXED.getValue());
|
||||
}
|
||||
// sa.setModifier(importHandleParam.getCurrentEmployeeId());
|
||||
salaryArchive = sa;
|
||||
|
||||
importHandleParam.getSalaryArchiveUpdates().add(salaryArchive);
|
||||
}
|
||||
} else if (employeeId != null && taxAgentId != null && importHandleParam.isInit()) {
|
||||
// 新增档案
|
||||
salaryArchive = SalaryArchivePO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.employeeId(employeeId)
|
||||
.taxAgentId(taxAgentId)
|
||||
.runStatus(SalaryArchiveStatusEnum.FIXED.getValue())
|
||||
.createTime(importHandleParam.getNowTime())
|
||||
.updateTime(importHandleParam.getNowTime())
|
||||
.creator(importHandleParam.getCurrentEmployeeId())
|
||||
// .modifier(importHandleParam.getCurrentEmployeeId())
|
||||
.deleteType(NumberUtils.INTEGER_ZERO)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
importHandleParam.getSalaryArchiveSaves().add(salaryArchive);
|
||||
}
|
||||
return salaryArchive;
|
||||
}
|
||||
|
||||
/**
|
||||
* 薪资项目处理
|
||||
*
|
||||
* @param isError
|
||||
* @param effectiveTimeIndex
|
||||
* @param excelComments
|
||||
* @param errorCount
|
||||
* @param j
|
||||
* @param effectiveTime
|
||||
* @param finalSalaryArchive
|
||||
* @param salaryItemAdjustReason
|
||||
* @param importHandleParam
|
||||
* @param key
|
||||
* @param cellVal
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public static boolean handleSalaryItem(boolean isError, int effectiveTimeIndex,
|
||||
List<Map<String, String>> excelComments, int errorCount, int j,
|
||||
Date effectiveTime, SalaryArchivePO finalSalaryArchive, String salaryItemAdjustReason, SalaryArchiveImportHandleParam importHandleParam,
|
||||
String key, String cellVal, Map<String, Object> map) {
|
||||
|
||||
String rowindex = "第" + map.get("index") + "行";
|
||||
// 薪资项目数据
|
||||
if (isError || importHandleParam.isSuspendList() || (importHandleParam.isSalaryItemAdjust() && effectiveTime == null) || finalSalaryArchive == null) {
|
||||
return isError;
|
||||
}
|
||||
Optional<SalaryItemPO> optionalSalaryItem = importHandleParam.getSalaryItems().stream().filter(e -> e.getName().equals(key)).findFirst();
|
||||
// 可以处理薪资项目的条件:有薪资项目+待定薪列表+定薪列表(调薪和初始化导入)
|
||||
boolean isEnable = optionalSalaryItem.isPresent() && (importHandleParam.isPendingList() || importHandleParam.isInit() || importHandleParam.isSalaryItemAdjust());
|
||||
if (isEnable) {
|
||||
SalaryItemPO salaryItemPO = optionalSalaryItem.get();
|
||||
// 数值类型判断
|
||||
boolean isNotNumber = salaryItemPO.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(cellVal) && !Pattern.matches(SalaryArchiveConstant.NUMBER_REGEX, cellVal);
|
||||
if (isNotNumber) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + numberErr);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, numberErr, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
return isError;
|
||||
}
|
||||
Long salaryItemId = salaryItemPO.getId();
|
||||
// 已生效
|
||||
List<SalaryArchiveItemPO> effectiveList = Optional.ofNullable(importHandleParam.getEffectiveItemListMap().get(finalSalaryArchive.getId() + "-" + salaryItemId)).orElse(Lists.newArrayList());
|
||||
// 当前已生效
|
||||
SalaryArchiveItemPO effectiveSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 0 ? effectiveList.get(0) : null;
|
||||
// 当前已生效的前一次调整
|
||||
SalaryArchiveItemPO effectiveBeforeSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 1 ? effectiveList.get(1) : null;
|
||||
// 未生效
|
||||
List<SalaryArchiveItemPO> ineffectiveItemList = importHandleParam.getIneffectiveItemListMap().get(finalSalaryArchive.getId() + "-" + salaryItemId);
|
||||
SalaryArchiveItemPO ineffectiveSalaryItem = CollectionUtils.isEmpty(ineffectiveItemList) ? null : ineffectiveItemList.get(0);
|
||||
// 待定薪和初始化:先删除后新增
|
||||
if (importHandleParam.isPendingList() || importHandleParam.isInit()) {
|
||||
// 已经生效的
|
||||
importHandleParam.getSalaryArchiveItemDelSalaryItemIds().addAll(effectiveList.stream().map(SalaryArchiveItemPO::getId).collect(Collectors.toList()));
|
||||
if (ineffectiveSalaryItem != null) {
|
||||
importHandleParam.getSalaryArchiveItemDelSalaryItemIds().add(ineffectiveSalaryItem.getId());
|
||||
}
|
||||
// 定薪列表调薪
|
||||
} else if (importHandleParam.isSalaryItemAdjust()) {
|
||||
SalaryItemAdjustValidDTO salaryItemAdjustValid = SalaryArchiveItemBO.handleSalaryItemAdjustValid(effectiveSalaryItem, effectiveBeforeSalaryItem, ineffectiveSalaryItem, effectiveTime, importHandleParam.getToday(), cellVal, importHandleParam.getSalaryArchiveItemDelSalaryItemIds());
|
||||
if (salaryItemAdjustValid.isBefore()) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + salaryItemNoBeforeCurrentEffectiveTime);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryItemNoBeforeCurrentEffectiveTime, errorCount + 1, errorCount + 1, effectiveTimeIndex, effectiveTimeIndex);
|
||||
isError = true;
|
||||
} else if (salaryItemAdjustValid.isSame()) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + salaryItemAdjustNoSame);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryItemAdjustNoSame, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
} else if (salaryItemAdjustValid.isSameIneffective()) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowindex + salaryItemAdjustNoSameIneffective);
|
||||
excelComments.add(errorMessageMap);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryItemAdjustNoSameIneffective, errorCount + 1, errorCount + 1, j, j);
|
||||
isError = true;
|
||||
}
|
||||
}
|
||||
// 导入时不需要处理的薪资项目
|
||||
boolean isInitNull = CollectionUtils.isEmpty(effectiveList) && CollectionUtils.isEmpty(ineffectiveItemList) && StringUtils.isEmpty(cellVal);
|
||||
if (!isError && !isInitNull && (importHandleParam.isPendingList() || importHandleParam.isInit() || importHandleParam.isSalaryItemAdjust())) {
|
||||
importHandleParam.getSalaryArchiveItemSaves().add(SalaryArchiveItemPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.salaryArchiveId(finalSalaryArchive.getId())
|
||||
.employeeId(finalSalaryArchive.getEmployeeId())
|
||||
.effectiveTime(effectiveTime == null ? new Date() : effectiveTime)
|
||||
// .adjustWay(SalaryArchiveAdjustWayEnum.IMPORT.getValue())
|
||||
.adjustReason(StringUtils.isEmpty(salaryItemAdjustReason) ? SalaryArchiveItemAdjustReasonEnum.INIT.getValue() : salaryItemAdjustReason)
|
||||
.salaryItemId(salaryItemId)
|
||||
.itemValue(cellVal)
|
||||
.description("")
|
||||
.operator(importHandleParam.getCurrentEmployeeId())
|
||||
.operateTime(importHandleParam.getNowTime())
|
||||
.createTime(importHandleParam.getNowTime())
|
||||
.updateTime(importHandleParam.getNowTime())
|
||||
.creator(importHandleParam.getCurrentEmployeeId())
|
||||
.deleteType(NumberUtils.INTEGER_ZERO)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build());
|
||||
}
|
||||
// 用于初始化导入,同一个人的多行记录之间的薪资项目是否调整
|
||||
map.put("salaryItemVal", Optional.ofNullable(map.get("salaryItemVal")).orElse("").toString() + salaryItemId + cellVal);
|
||||
}
|
||||
return isError;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SalaryArchiveExcelBO{}";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +1,436 @@
|
|||
package com.engine.salary.entity.salaryarchive.bo;
|
||||
|
||||
import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustValidDTO;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 薪资档案-薪资项目
|
||||
* @Author: wangxiangzhong
|
||||
* @Date: 2021-11-03 10:51
|
||||
*/
|
||||
public class SalaryArchiveItemBO {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SalaryArchiveItemBO{}";
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "SalaryArchiveItemBO{}";
|
||||
// }
|
||||
/**
|
||||
* 构建薪资项目基础信息表单
|
||||
*
|
||||
* @param isView
|
||||
* @param effectiveTime
|
||||
* @param adjustReason
|
||||
* @param description
|
||||
* @param employeeId
|
||||
* @param tenantKey
|
||||
* @return
|
||||
*/
|
||||
// public static WeaForm buildSalaryArchiveItemForm(boolean isView, Date effectiveTime, String adjustReason, String description, Long employeeId, String tenantKey) {
|
||||
// WeaForm salaryItemForm = SalaryFormatUtil.<SalaryArchiveItemBaseDTO>getInstance().buildForm(SalaryArchiveItemBaseDTO.class, SalaryArchiveItemBaseDTO.builder().build());
|
||||
// WeaFormItem descriptionItem = salaryItemForm.getItems().get("description");
|
||||
// if (!isView) {
|
||||
// Map<String, Object> otherParams = Maps.newHashMap();
|
||||
// otherParams.put("showCount", true);
|
||||
// otherParams.put("placeholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85987, "请输入"));
|
||||
// descriptionItem.setOtherParams(otherParams);
|
||||
// salaryItemForm.getItems().put("description", descriptionItem);
|
||||
// } else {
|
||||
// WeaFormItem effectiveTimeItem = salaryItemForm.getItems().get("effectiveTime");
|
||||
// effectiveTimeItem.setRequired(false);
|
||||
// effectiveTimeItem.setReadOnly(true);
|
||||
// salaryItemForm.getItems().put("effectiveTime", effectiveTimeItem);
|
||||
// WeaFormItem adjustReasonItem = salaryItemForm.getItems().get("adjustReason");
|
||||
// adjustReasonItem.setRequired(false);
|
||||
// adjustReasonItem.setReadOnly(true);
|
||||
// salaryItemForm.getItems().put("adjustReason", adjustReasonItem);
|
||||
// descriptionItem.setReadOnly(true);
|
||||
// salaryItemForm.getItems().put("description", descriptionItem);
|
||||
// }
|
||||
// // 控件数据
|
||||
// Map<String, Object> data = salaryItemForm.getData();
|
||||
// data.put("effectiveTime", effectiveTime + "");
|
||||
// data.put("adjustReason", adjustReason);
|
||||
// data.put("description", description);
|
||||
//
|
||||
// public static List<WeaTableColumn> buildRecordTableColumns(Long employeeId, String tenantKey) {
|
||||
// salaryItemForm.setData(data);
|
||||
// return salaryItemForm;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 构建薪资档案调整明细
|
||||
*
|
||||
* @param isView
|
||||
* @param tableData
|
||||
* @param salaryItemList
|
||||
* @param employeeId
|
||||
* @param tenantKey
|
||||
* @return
|
||||
*/
|
||||
// public static EditableTable<Map<String, Object>> buildSalaryArchiveItemAdjustDetailTable(boolean isView, List<Map<String, Object>> tableData, List<SalaryItemPO> salaryItemList, Long employeeId, String tenantKey) {
|
||||
// WeaTable<Map<String, Object>> adjustDetailTable = new WeaTable<>();
|
||||
// adjustDetailTable.setPageUid(UUID.randomUUID().toString());
|
||||
// adjustDetailTable.setModule("hrmsalary");
|
||||
//
|
||||
// List<Map<String, Object>> salaryItems = salaryItemList.stream().map(m -> {
|
||||
// Map<String, Object> salaryItemMap = new LinkedHashMap<>();
|
||||
// salaryItemMap.put("id", String.valueOf(m.getId()));
|
||||
// salaryItemMap.put("content", m.getName());
|
||||
// salaryItemMap.put("dataType", m.getDataType());
|
||||
// return salaryItemMap;
|
||||
// }).collect(Collectors.toList());
|
||||
//
|
||||
// Page<Map<String, Object>> page = new Page<>(0, 0, 0, false);
|
||||
// page.setRecords(tableData);
|
||||
// adjustDetailTable.setPage(page);
|
||||
// adjustDetailTable.setDisplayData(tableData);
|
||||
// adjustDetailTable.setTableType(isView ? WeaTableTypeEnum.NONE : WeaTableTypeEnum.CHECKBOX);
|
||||
//
|
||||
// EditableTable<Map<String, Object>> editableTable = new EditableTable<>(adjustDetailTable);
|
||||
// editableTable.setColumns(SalaryArchiveItemBO.buildRecordTableColumns(isView, employeeId, tenantKey));
|
||||
// editableTable.setComProps(SalaryArchiveItemBO.buildEditableTableItemMap(isView, salaryItems));
|
||||
// return editableTable;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 构建调薪记录表格
|
||||
*
|
||||
* @param isView
|
||||
* @param employeeId
|
||||
* @param tenantKey
|
||||
// * @return
|
||||
// */
|
||||
// public static List<WeaTableColumn> buildRecordTableColumns(boolean isView, Long employeeId, String tenantKey) {
|
||||
// List<WeaTableColumn> result = Lists.newArrayListWithExpectedSize(3);
|
||||
// result.add(new WeaTableColumnWapper(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84960, "薪资项目"), "salaryItem", "150", WeaAlignEnum.CENTER.getStringVal(), "salaryItem", true));
|
||||
// result.add(new WeaTableColumnWapper(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85433, "调整前"), "salaryBefore", "150", WeaAlignEnum.CENTER.getStringVal(), "salaryBefore"));
|
||||
// result.add(new WeaTableColumnWapper(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85434, "调整后"), "adjustAfter", "150", WeaAlignEnum.CENTER.getStringVal(), "adjustAfter", true));
|
||||
// result.add(new SalaryWeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84960, "薪资项目"), "salaryItem", "150", WeaAlignEnum.CENTER.getStringVal(), "salaryItem", !isView));
|
||||
// result.add(new SalaryWeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85433, "调整前"), "salaryBefore", "150", WeaAlignEnum.CENTER.getStringVal(), "salaryBefore"));
|
||||
// result.add(new SalaryWeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85434, "调整后"), "adjustAfter", "150", WeaAlignEnum.CENTER.getStringVal(), "adjustAfter", !isView));
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// public static Map<String, EditableTableItem> buildEditableTableItemMap(List<Map<String, Object>> salaryItems) {
|
||||
|
||||
/**
|
||||
* 构建调薪记录表格字段
|
||||
*
|
||||
* @param isView
|
||||
* @param salaryItems
|
||||
* @return
|
||||
*/
|
||||
// public static Map<String, EditableTableItem> buildEditableTableItemMap(boolean isView, List<Map<String, Object>> salaryItems) {
|
||||
// Map<String, EditableTableItem> resultMap = Maps.newHashMapWithExpectedSize(9);
|
||||
// resultMap.put("salaryItem", new EditableTableItem(EditableTableItemType.SELECT, "", salaryItems,true,false));
|
||||
// resultMap.put("salaryItem", new EditableTableItem(EditableTableItemType.SELECT, "", salaryItems, !isView, isView));
|
||||
// resultMap.put("salaryBefore", new EditableTableItem(EditableTableItemType.INPUT, "", true));
|
||||
// resultMap.put("adjustAfter", new EditableTableItem(EditableTableItemType.INPUT, "", null, true,false));
|
||||
// resultMap.put("adjustAfter", new EditableTableItem(EditableTableItemType.INPUT, "", null, !isView, isView));
|
||||
// return resultMap;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 处理调整记录
|
||||
*
|
||||
* @param list
|
||||
* @param hrmStatusList
|
||||
* @param listMap
|
||||
* @param employeeId
|
||||
* @param tenantKey
|
||||
*/
|
||||
// public static void handleSalaryItemAdjustRecord(List<SalaryItemAdjustRecordListDTO> list, List<HrmStatus> hrmStatusList, Map<String, List<SalaryArchiveItemPO>> listMap, Long employeeId, String tenantKey) {
|
||||
// Map<String, String> hrmStatusNameMap = SalaryEntityUtil.convert2Map(hrmStatusList, hrmStatus -> String.valueOf(hrmStatus.getCodeId()), HrmStatus::getName);
|
||||
// list.forEach(m -> {
|
||||
// List<SalaryArchiveItemPO> singleSalaryArchiveItems = Optional.ofNullable(listMap.get(m.getSalaryArchiveId() + "-" + m.getSalaryItemId())).orElse(Lists.newArrayList());
|
||||
// // 调整前
|
||||
// m.setAdjustAfter(CollectionUtils.isEmpty(singleSalaryArchiveItems) ? "" : singleSalaryArchiveItems.get(0).getItemValue());
|
||||
// if (!CollectionUtils.isEmpty(singleSalaryArchiveItems)) {
|
||||
// singleSalaryArchiveItems.removeIf(a -> a.getId().equals(m.getId()));
|
||||
// }
|
||||
// SalaryArchiveItemPO salaryArchiveItem = CollectionUtils.isEmpty(singleSalaryArchiveItems) ? null : singleSalaryArchiveItems.get(0);
|
||||
// // 调整后
|
||||
// m.setAdjustBefore(salaryArchiveItem == null ? "" : salaryArchiveItem.getItemValue());
|
||||
//
|
||||
// m.setEmployeeStatus(Optional.ofNullable(hrmStatusNameMap.get(m.getEmployeeStatus())).orElse(""));
|
||||
// m.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason(), employeeId, tenantKey));
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* 薪资项目调整记录列表的高级搜索
|
||||
*
|
||||
* @param conditionId
|
||||
* @param userStatusOptions
|
||||
* @param employeeId
|
||||
* @param tenantKey
|
||||
* @return
|
||||
*/
|
||||
// public static WeaSearchCondition getAdjustRecordSearchCondition(String conditionId, List<WeaSearchConditionOption> userStatusOptions, Long employeeId, String tenantKey) {
|
||||
// WeaSearchCondition weaSearchCondition = SalaryFormatUtil.<SalaryItemAdjustRecordSearchConditionDTO>getInstance()
|
||||
// .buildCondition(SalaryItemAdjustRecordSearchConditionDTO.class,
|
||||
// SalaryItemAdjustRecordSearchConditionDTO.builder()
|
||||
// .userStatusOptions(userStatusOptions)
|
||||
// .build(),
|
||||
// conditionId);
|
||||
// // 生效日期-添加范围
|
||||
// SalaryArchiveBO.addDatePickerRangeOtherParams(weaSearchCondition, "effectiveTime", employeeId, tenantKey);
|
||||
// // 操作日期-添加范围
|
||||
// SalaryArchiveBO.addDatePickerRangeOtherParams(weaSearchCondition, "operateTime", employeeId, tenantKey);
|
||||
// // 只保留常用条件
|
||||
// weaSearchCondition.setGroups(weaSearchCondition.getGroups().stream().filter(e -> "commonGroup".equals(e.getId())).collect(Collectors.toList()));
|
||||
// return weaSearchCondition;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 构建调薪记录表格
|
||||
*
|
||||
* @param adjustRecordTypeEnum
|
||||
* @param effectiveItemListMap
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
// public static WeaTable<SalaryItemAdjustRecordListDTO> buildSalaryItemAdjustRecordTable(SalaryArchiveAdjustRecordTypeEnum adjustRecordTypeEnum, Map<String, List<SalaryArchiveItemPO>> effectiveItemListMap, Page<SalaryItemAdjustRecordListDTO> page) {
|
||||
// WeaTable<SalaryItemAdjustRecordListDTO> weaTable = FormatManager.<SalaryItemAdjustRecordListDTO>getInstance().genTable(SalaryItemAdjustRecordListDTO.class, page);
|
||||
// if (adjustRecordTypeEnum.equals(SalaryArchiveAdjustRecordTypeEnum.ADJUSTRECORD)) {
|
||||
// /**
|
||||
// * 行记录按钮权限控制
|
||||
// * 说明:
|
||||
// * 1.早于当前已生效的则只有【查看】权限;
|
||||
// * 2.等于当前已生效的有【编辑】、【操作日志】权限;
|
||||
// * 3.未生效的有【编辑】、【删除】、【操作日志】权限;
|
||||
// */
|
||||
// for (int i = 0; i < page.getRecords().size(); i++) {
|
||||
// SalaryItemAdjustRecordListDTO salaryItemAdjustRecord = page.getRecords().get(i);
|
||||
// Optional<SalaryArchiveItemPO> optional = CollectionUtils.emptyIfNull(effectiveItemListMap.get(salaryItemAdjustRecord.getSalaryArchiveId() + "-" + salaryItemAdjustRecord.getSalaryItemId())).stream().findFirst();
|
||||
// Date effectiveDate = optional.map(SalaryArchiveItemPO::getEffectiveTime).orElse(null);
|
||||
// List<Permission> permissions = weaTable.getOperatesPermission().get(i);
|
||||
// for (int j = 0; j < permissions.size(); j++) {
|
||||
// Permission permission = permissions.get(j);
|
||||
// if (j > 0 && effectiveDate != null && salaryItemAdjustRecord.getEffectiveTime().isBefore(effectiveDate)) {
|
||||
// permission.setVisible(false);
|
||||
// permission.setDisabled(true);
|
||||
// } else if (effectiveDate != null
|
||||
// && ((j == 0 && !salaryItemAdjustRecord.getEffectiveTime().isBefore(effectiveDate))
|
||||
// || (j == 2 && salaryItemAdjustRecord.getEffectiveTime().equals(effectiveDate)))) {
|
||||
// permission.setVisible(false);
|
||||
// permission.setDisabled(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // 除了删除列表,其他不需要复选框
|
||||
// if (!adjustRecordTypeEnum.equals(SalaryArchiveAdjustRecordTypeEnum.ADJUSTRECORDFORDELETE)) {
|
||||
// weaTable.setTableType(WeaTableTypeEnum.NONE);
|
||||
// }
|
||||
// // 除了调薪列表,其他不需要操作列
|
||||
// if (!adjustRecordTypeEnum.equals(SalaryArchiveAdjustRecordTypeEnum.ADJUSTRECORD)) {
|
||||
// weaTable.setOperates(Collections.emptyList());
|
||||
// }
|
||||
// // 在外展示操作按钮
|
||||
// CollectionUtils.emptyIfNull(weaTable.getOperates()).forEach(operate -> {
|
||||
// if (operate.getIndex() < 2) {
|
||||
// operate.setOuter(Boolean.TRUE);
|
||||
// }
|
||||
// });
|
||||
// weaTable.setPageUid(adjustRecordTypeEnum.getPageUid());
|
||||
// weaTable.setModule("hrmsalary");
|
||||
// return weaTable;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 构建单个档案调薪记录表格
|
||||
*
|
||||
* @param effectiveItemListMap
|
||||
* @param salaryArchiveId
|
||||
* @param pageUid
|
||||
* @param listPage
|
||||
* @return
|
||||
*/
|
||||
// public static WeaTable<SingleSalaryItemAdjustRecordListDTO> buildSingleSalaryItemAdjustRecordTable(Map<String, List<SalaryArchiveItemPO>> effectiveItemListMap, Long salaryArchiveId, String pageUid, Page<SingleSalaryItemAdjustRecordListDTO> listPage) {
|
||||
// WeaTable<SingleSalaryItemAdjustRecordListDTO> weaTable = FormatManager.<SingleSalaryItemAdjustRecordListDTO>getInstance().genTable(SingleSalaryItemAdjustRecordListDTO.class, listPage);
|
||||
// weaTable.setModule("hrmsalary");
|
||||
// // 行记录按钮权限控制
|
||||
// for (int i = 0; i < listPage.getRecords().size(); i++) {
|
||||
// SingleSalaryItemAdjustRecordListDTO singleSalaryItemAdjustRecord = listPage.getRecords().get(i);
|
||||
// Optional<SalaryArchiveItemPO> optional = CollectionUtils.emptyIfNull(effectiveItemListMap.get(salaryArchiveId + "-" + singleSalaryItemAdjustRecord.getSalaryItemId())).stream().findFirst();
|
||||
// Date effectiveDate = optional.map(SalaryArchiveItemPO::getEffectiveTime).orElse(null);
|
||||
// List<Permission> permissions = weaTable.getOperatesPermission().get(i);
|
||||
// for (int j = 0; j < permissions.size(); j++) {
|
||||
// Permission permission = permissions.get(j);
|
||||
// if (SalaryArchiveAdjustWayEnum.BATCH.getValue().equals(singleSalaryItemAdjustRecord.getAdjustWay()) || (effectiveDate != null && singleSalaryItemAdjustRecord.getEffectiveTime().isBefore(effectiveDate))) {
|
||||
// permission.setVisible(false);
|
||||
// permission.setDisabled(true);
|
||||
// } else if (j > 0 && singleSalaryItemAdjustRecord.getEffectiveTime().equals(effectiveDate)) {
|
||||
// permission.setVisible(false);
|
||||
// permission.setDisabled(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // 在外展示操作按钮
|
||||
// weaTable.getOperates().get(0).setOuter(Boolean.TRUE);
|
||||
// weaTable.setPageUid(pageUid);
|
||||
// return weaTable;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 构建变更数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// public static ChangeData buildChangeData(SalaryArchivePO salaryArchive, SalaryArchiveItemSaveParam saveParam, List<SalaryArchiveItemDetailSaveParam> salaryArchiveItems, Map<String, List<SalaryArchiveItemPO>> effectiveItemListMap, Map<String, List<SalaryArchiveItemPO>> ineffectiveItemListMap, Long employeeId, String tenantKey) {
|
||||
// // 待保存生效时间
|
||||
// Date saveEffectiveTime = saveParam.getEffectiveTime();
|
||||
// // 当天
|
||||
// Date today = Date.now();
|
||||
// // 当前时间
|
||||
// LocalDateTime nowTime = LocalDateTime.now();
|
||||
//
|
||||
// List<Long> effectiveSalaryItemDels = Lists.newArrayList();
|
||||
// List<SalaryArchiveItemPO> salaryArchiveItemNews = Lists.newArrayList();
|
||||
// salaryArchiveItems.forEach(e -> {
|
||||
// boolean isNotNumber = e.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(e.getAdjustValue()) && !Pattern.matches(SalaryArchiveConstant.NUMBER_REGEX, e.getAdjustValue());
|
||||
// if (isNotNumber) {
|
||||
// throw new SalaryRunTimeException(e.getName() + ":" + SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100581, "请输入数字"));
|
||||
// }
|
||||
// // 已生效
|
||||
// List<SalaryArchiveItemPO> effectiveList = Optional.ofNullable(effectiveItemListMap.get(salaryArchive.getId() + "-" + e.getSalaryItemId())).orElse(Lists.newArrayList());
|
||||
// // 当前已生效
|
||||
// SalaryArchiveItemPO effectiveSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 0 ? effectiveList.get(0) : null;
|
||||
// // 当前已生效的前一次调整
|
||||
// SalaryArchiveItemPO effectiveBeforeSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 1 ? effectiveList.get(1) : null;
|
||||
// // 未生效
|
||||
// SalaryArchiveItemPO ineffectiveSalaryItem = CollectionUtils.isEmpty(ineffectiveItemListMap.get(salaryArchive.getId() + "-" + e.getSalaryItemId())) ? null : ineffectiveItemListMap.get(salaryArchive.getId() + "-" + e.getSalaryItemId()).get(0);
|
||||
// SalaryItemAdjustValidDTO salaryItemAdjustValid = handleSalaryItemAdjustValid(effectiveSalaryItem, effectiveBeforeSalaryItem, ineffectiveSalaryItem, saveEffectiveTime, today, e.getAdjustValue(), effectiveSalaryItemDels);
|
||||
// if (salaryItemAdjustValid.isBefore()) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100429, "生效日期不可早于当前已生效的调整日期"));
|
||||
// } else if (salaryItemAdjustValid.isSame()) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100432, "调整前后不可相同"));
|
||||
// } else if (salaryItemAdjustValid.isSameIneffective()) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100434, "与未生效的调整后不可相同"));
|
||||
// }
|
||||
//
|
||||
// salaryArchiveItemNews.add(SalaryArchiveItemBO.buildInsert(salaryArchive, e.getSalaryItemId(), e.getAdjustValue(), saveParam, nowTime, employeeId, tenantKey));
|
||||
// });
|
||||
// return ChangeData.builder()
|
||||
// .effectiveSalaryItemDels(effectiveSalaryItemDels)
|
||||
// .salaryArchiveItemNews(salaryArchiveItemNews)
|
||||
// .build();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 薪资项目调整校验处理
|
||||
*
|
||||
* @param effectiveSalaryItem
|
||||
* @param effectiveBeforeSalaryItem
|
||||
* @param ineffectiveSalaryItem
|
||||
* @param saveEffectiveTime
|
||||
* @param today
|
||||
* @param adjustValue
|
||||
* @param salaryArchiveItemDelIds
|
||||
* @return
|
||||
*/
|
||||
public static SalaryItemAdjustValidDTO handleSalaryItemAdjustValid(SalaryArchiveItemPO effectiveSalaryItem,
|
||||
SalaryArchiveItemPO effectiveBeforeSalaryItem,
|
||||
SalaryArchiveItemPO ineffectiveSalaryItem,
|
||||
Date saveEffectiveTime,
|
||||
Date today,
|
||||
String adjustValue,
|
||||
List<Long> salaryArchiveItemDelIds) {
|
||||
|
||||
boolean isBefore = false;
|
||||
boolean isSame = false;
|
||||
boolean isSameIneffective = false;
|
||||
if (effectiveSalaryItem != null) {
|
||||
// 当前已经生效的时间
|
||||
Date effectiveTime = effectiveSalaryItem.getEffectiveTime();
|
||||
// 1.1 如果早于<当前已生效
|
||||
if (saveEffectiveTime.before(effectiveTime)) {
|
||||
isBefore = true;
|
||||
// 1.2 如果等于当前已生效
|
||||
} else if (saveEffectiveTime.equals(effectiveTime)) {
|
||||
if (effectiveBeforeSalaryItem != null && effectiveBeforeSalaryItem.getItemValue().equals(adjustValue)) {
|
||||
isSame = true;
|
||||
}
|
||||
if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(adjustValue)) {
|
||||
isSameIneffective = true;
|
||||
}
|
||||
// 1.3 如果>已经生效且<=今天
|
||||
} else if (saveEffectiveTime.after(effectiveTime) && !saveEffectiveTime.after(today)) {
|
||||
if (effectiveSalaryItem.getItemValue().equals(adjustValue)) {
|
||||
isSame = true;
|
||||
}
|
||||
if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(adjustValue)) {
|
||||
isSameIneffective = true;
|
||||
}
|
||||
// 1.4 如果>今天
|
||||
} else if (saveEffectiveTime.after(today) && effectiveSalaryItem.getItemValue().equals(adjustValue)) {
|
||||
isSame = true;
|
||||
}
|
||||
} else if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(adjustValue)) {
|
||||
isSameIneffective = true;
|
||||
}
|
||||
boolean isError = isBefore || isSame || isSameIneffective;
|
||||
// 2.数据处理
|
||||
if (!isError && effectiveSalaryItem != null && saveEffectiveTime.equals(effectiveSalaryItem.getEffectiveTime())) {
|
||||
salaryArchiveItemDelIds.add(effectiveSalaryItem.getId());
|
||||
}
|
||||
if (!isError && ineffectiveSalaryItem != null && saveEffectiveTime.after(today)) {
|
||||
salaryArchiveItemDelIds.add(ineffectiveSalaryItem.getId());
|
||||
}
|
||||
return SalaryItemAdjustValidDTO.builder()
|
||||
.isBefore(isBefore)
|
||||
.isSame(isSame)
|
||||
.isSameIneffective(isSameIneffective)
|
||||
.salaryArchiveItemDelIds(salaryArchiveItemDelIds)
|
||||
.build();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 插入
|
||||
// *
|
||||
// * @param salaryArchive
|
||||
// * @param saveParam
|
||||
// * @param nowTime
|
||||
// * @param employeeId
|
||||
// * @param tenantKey
|
||||
// */
|
||||
// public static SalaryArchiveItemPO buildInsert(SalaryArchivePO salaryArchive, Long salaryItemId, String adjustValue, SalaryArchiveItemSaveParam saveParam, LocalDateTime nowTime, Long employeeId, String tenantKey) {
|
||||
// return SalaryArchiveItemPO.builder()
|
||||
// .id(IdGenerator.generate())
|
||||
// .salaryArchiveId(saveParam.getSalaryArchiveId())
|
||||
// .employeeId(salaryArchive.getEmployeeId())
|
||||
// .effectiveTime(saveParam.getEffectiveTime())
|
||||
// .adjustWay(SalaryArchiveAdjustWayEnum.SINGLE.getValue())
|
||||
// .adjustReason(saveParam.getAdjustReason().getValue())
|
||||
// .description(saveParam.getDescription())
|
||||
// .salaryItemId(salaryItemId)
|
||||
// // 调整后
|
||||
// .itemValue(adjustValue)
|
||||
// .operator(employeeId)
|
||||
// .operateTime(nowTime)
|
||||
// .createTime(LocalDateTime.now())
|
||||
// .updateTime(LocalDateTime.now())
|
||||
// .creator(employeeId)
|
||||
// .deleteType(NumberUtils.INTEGER_ZERO)
|
||||
// .tenantKey(tenantKey)
|
||||
// .build();
|
||||
// }
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ChangeData {
|
||||
|
||||
/**
|
||||
* 薪资档案-项目删除
|
||||
*/
|
||||
List<Long> effectiveSalaryItemDels;
|
||||
|
||||
/**
|
||||
* 薪资档案-项目新增
|
||||
*/
|
||||
List<SalaryArchiveItemPO> salaryArchiveItemNews;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,11 @@ public class SalaryArchiveInitImportDTO {
|
|||
*/
|
||||
private Long employeeId;
|
||||
|
||||
/**
|
||||
* 个税扣缴义务人id
|
||||
*/
|
||||
private Long taxAgentId;
|
||||
|
||||
/**
|
||||
* 同一个人的多条记录
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.engine.salary.entity.salaryarchive.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 薪资项目调整校验
|
||||
* @Author: wangxiangzhong
|
||||
* @Date: 2022/8/29 11:17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//"薪资项目调整校验")
|
||||
public class SalaryItemAdjustValidDTO {
|
||||
|
||||
//生效日期不可早于当前已生效的调整日期")
|
||||
private boolean isBefore;
|
||||
|
||||
//调整前后不可相同")
|
||||
private boolean isSame;
|
||||
|
||||
//与未生效的调整后不可相同")
|
||||
private boolean isSameIneffective;
|
||||
|
||||
//待删除的薪资档案项目id")
|
||||
private List<Long> salaryArchiveItemDelIds;
|
||||
}
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
package com.engine.salary.entity.salaryarchive.param;
|
||||
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
|
@ -17,6 +14,7 @@ import lombok.NoArgsConstructor;
|
|||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 薪资档案导入处理参数
|
||||
|
|
@ -45,10 +43,22 @@ public class SalaryArchiveImportHandleParam {
|
|||
* @see SalaryArchiveImportTypeEnum
|
||||
*/
|
||||
String importType;
|
||||
String listType;
|
||||
|
||||
//************************************************************/
|
||||
|
||||
Boolean openDevolution;
|
||||
//*****************************************************************/
|
||||
|
||||
Long currentEmployeeId;
|
||||
String tenantKey;
|
||||
|
||||
// 待定薪列表
|
||||
boolean isPendingList;
|
||||
// 定薪列表
|
||||
boolean isFixedList;
|
||||
// 待停薪列表
|
||||
boolean isSuspendList;
|
||||
boolean isInit;
|
||||
boolean isSalaryItemAdjust;
|
||||
|
||||
/**
|
||||
* 获取租户下所有的人员
|
||||
|
|
@ -56,14 +66,14 @@ public class SalaryArchiveImportHandleParam {
|
|||
List<DataCollectionEmployee> employees;
|
||||
|
||||
/**
|
||||
* 获取所有个税扣缴义务人
|
||||
* 租户下的人员状态
|
||||
*/
|
||||
Collection<TaxAgentPO> taxAgentList;
|
||||
// List<HrmStatus> hrmStatusList;
|
||||
|
||||
/**
|
||||
* 管理的个税扣缴义务人和人员范围
|
||||
* 获取所有个税扣缴义务人
|
||||
*/
|
||||
Collection<TaxAgentManageRangeEmployeeDTO> listTaxAgentAndEmployeeTree;
|
||||
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList;
|
||||
|
||||
/**
|
||||
* 获取所有可被引用的薪资项目
|
||||
|
|
@ -73,7 +83,7 @@ public class SalaryArchiveImportHandleParam {
|
|||
/**
|
||||
* 查询已有的薪资档案基本数据
|
||||
*/
|
||||
Collection<SalaryArchiveListDTO> salaryArchives;
|
||||
Map<String, SalaryArchivePO> salaryArchivesMap;
|
||||
|
||||
/**
|
||||
* 薪资项目id
|
||||
|
|
@ -83,22 +93,12 @@ public class SalaryArchiveImportHandleParam {
|
|||
/**
|
||||
* 查询已生效的薪资项目数据
|
||||
*/
|
||||
List<SalaryArchiveItemPO> effectiveItemList;
|
||||
Map<String, List<SalaryArchiveItemPO>> effectiveItemListMap;
|
||||
|
||||
/**
|
||||
* 查询未生效的薪资项目数据
|
||||
*/
|
||||
List<SalaryArchiveItemPO> ineffectiveItemList;
|
||||
|
||||
/**
|
||||
* 查询已生效的个税扣缴义务人数据
|
||||
*/
|
||||
List<SalaryArchiveTaxAgentPO> effectiveTaxAgentList;
|
||||
|
||||
/**
|
||||
* 查询未生效的个税扣缴义务人数据
|
||||
*/
|
||||
List<SalaryArchiveTaxAgentPO> ineffectiveTaxAgentList;
|
||||
Map<String, List<SalaryArchiveItemPO>> ineffectiveItemListMap;
|
||||
|
||||
/**
|
||||
* 当前时间
|
||||
|
|
@ -120,29 +120,23 @@ public class SalaryArchiveImportHandleParam {
|
|||
*/
|
||||
List<SalaryArchivePO> salaryArchiveUpdates;
|
||||
|
||||
|
||||
/**
|
||||
* 待保存薪资档案-个税扣缴义务人
|
||||
*/
|
||||
List<SalaryArchiveTaxAgentPO> salaryArchiveTaxAgentSaves;
|
||||
|
||||
/**
|
||||
* 待保存薪资档案-薪资项目
|
||||
*/
|
||||
List<SalaryArchiveItemPO> salaryArchiveItemSaves;
|
||||
|
||||
/**
|
||||
* 待删除薪资档案-个税扣缴义务人
|
||||
*/
|
||||
List<Long> salaryArchiveTaxAgentDelTaxAgentIds;
|
||||
|
||||
/**
|
||||
* 待删除薪资档案-薪资项目
|
||||
*/
|
||||
List<Long> salaryArchiveItemDelSalaryItemIds;
|
||||
|
||||
/**
|
||||
* 校验人员
|
||||
* 薪资账套
|
||||
*/
|
||||
Long employeeId;
|
||||
// List<SalarySobPO> salarySobList;
|
||||
|
||||
/**
|
||||
* 薪资档案-账套关联
|
||||
*/
|
||||
// List<SalaryArchiveSobPO> salaryArchiveSobSaves;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.salary.entity.salaryarchive.param;
|
||||
|
||||
import com.engine.salary.common.BaseQueryParam;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
|
@ -73,4 +74,7 @@ public class SalaryArchiveQueryParam extends BaseQueryParam {
|
|||
@JsonIgnore
|
||||
private List<String> runStatusList;
|
||||
|
||||
//列表类型:PENDING:待定薪;FIXED:发薪;SUSPEND:待停薪;STOP:停薪"
|
||||
private SalaryArchiveListTypeEnum listType;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.engine.salary.enums.salaryarchive;
|
||||
|
||||
/**
|
||||
* @Description: 薪资档案-调薪方式
|
||||
* @Author: wangxiangzhong
|
||||
* @Date: 2022/4/11 19:46
|
||||
*/
|
||||
public enum SalaryArchiveAdjustWayEnum {
|
||||
// 单个调薪
|
||||
SINGLE(1),
|
||||
// 导入调薪
|
||||
IMPORT(2),
|
||||
// 批量调薪
|
||||
BATCH(3);
|
||||
|
||||
private Integer value;
|
||||
|
||||
SalaryArchiveAdjustWayEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.engine.salary.enums.salaryarchive;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 薪资档案列表类型
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
|
|
@ -38,4 +40,13 @@ public enum SalaryArchiveListTypeEnum {
|
|||
public int getLabelId() {
|
||||
return labelId;
|
||||
}
|
||||
|
||||
public static SalaryArchiveListTypeEnum parseByValue(String value) {
|
||||
for (SalaryArchiveListTypeEnum enums : SalaryArchiveListTypeEnum.values()) {
|
||||
if (StringUtils.equals(enums.getValue(), value)) {
|
||||
return enums;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1034,6 +1034,12 @@
|
|||
<if test="param.salaryArchiveId != null">
|
||||
AND t.salary_archive_id = #{param.salaryArchiveId}
|
||||
</if>
|
||||
<if test="param.salaryArchivesIds != null and param.salaryArchivesIds.size()>0">
|
||||
AND t.salary_archive_id IN
|
||||
<foreach collection="param.salaryArchivesIds" open="(" item="salaryArchiveId" separator="," close=")">
|
||||
#{salaryArchiveId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.salaryItemId != null">
|
||||
AND t.salary_item_id = #{param.salaryItemId}
|
||||
</if>
|
||||
|
|
|
|||
|
|
@ -415,20 +415,20 @@
|
|||
</if>
|
||||
</foreach>
|
||||
</trim>
|
||||
<!-- <trim prefix="pay_start_date =case" suffix="end,">-->
|
||||
<!-- <foreach collection="collection" item="item" index="index">-->
|
||||
<!-- <if test="item.payStartDate!=null">-->
|
||||
<!-- when id=#{item.id} then #{item.payStartDate}-->
|
||||
<!-- </if>-->
|
||||
<!-- </foreach>-->
|
||||
<!-- </trim>-->
|
||||
<!-- <trim prefix="pay_end_date =case" suffix="end,">-->
|
||||
<!-- <foreach collection="collection" item="item" index="index">-->
|
||||
<!-- <if test="item.payEndDate!=null">-->
|
||||
<!-- when id=#{item.id} then #{item.payEndDate}-->
|
||||
<!-- </if>-->
|
||||
<!-- </foreach>-->
|
||||
<!-- </trim>-->
|
||||
<trim prefix="pay_start_date =case" suffix="end,">
|
||||
<foreach collection="collection" item="item" index="index">
|
||||
<if test="item.payStartDate!=null">
|
||||
when id=#{item.id} then #{item.payStartDate}
|
||||
</if>
|
||||
</foreach>
|
||||
</trim>
|
||||
<trim prefix="pay_end_date =case" suffix="end,">
|
||||
<foreach collection="collection" item="item" index="index">
|
||||
<if test="item.payEndDate!=null">
|
||||
when id=#{item.id} then #{item.payEndDate}
|
||||
</if>
|
||||
</foreach>
|
||||
</trim>
|
||||
</trim>
|
||||
where
|
||||
id in
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveQueryParam;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 薪资档案-导入导出
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public interface SalaryArchiveExcelService {
|
||||
|
||||
/**
|
||||
* 导出薪资档案列表
|
||||
*
|
||||
* @param map
|
||||
* @param queryParam
|
||||
* @param employeeId
|
||||
* @param tenantKey
|
||||
*/
|
||||
// XSSFWorkbook exportList(Map<String, Object> map, SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey);
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
XSSFWorkbook downloadTemplate(SalaryArchiveQueryParam queryParam);
|
||||
|
||||
Map<String, Object> batchImportEbatch(Map<String, Object> param);
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 薪资档案-薪资项目
|
||||
|
|
@ -118,4 +119,26 @@ public interface SalaryArchiveItemService {
|
|||
*/
|
||||
List<SalaryArchiveItemPO> getCurrentEffectiveItemListIngoreValue(Collection<Long> salaryArchivesIds, List<Long> salaryItemIds);
|
||||
|
||||
/**
|
||||
* 获取当前已生效
|
||||
*
|
||||
* @param salaryArchiveIds
|
||||
* @param isNoNeedSalaryItem
|
||||
* @param salaryItemIds
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<SalaryArchiveItemPO>> getEffectiveItemListMap(Collection<Long> salaryArchiveIds, boolean isNoNeedSalaryItem, Collection<Long> salaryItemIds);
|
||||
|
||||
/**
|
||||
* 获取当前未生效
|
||||
*
|
||||
* @param salaryArchiveIds
|
||||
* @param isNoNeedSalaryItem
|
||||
* @param salaryItemIds
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<SalaryArchiveItemPO>> getIneffectiveItemListMap(Collection<Long> salaryArchiveIds, boolean isNoNeedSalaryItem, Collection<Long> salaryItemIds);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
|||
import com.engine.salary.entity.taxagent.param.TaxAgentAdminChangeCheckParam;
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam;
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentSaveParam;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentEmployeePO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
|
||||
import com.engine.salary.enums.taxagent.TaxAgentRoleTypeEnum;
|
||||
|
|
@ -18,6 +19,13 @@ import java.util.Map;
|
|||
|
||||
public interface TaxAgentService {
|
||||
|
||||
/**
|
||||
* 获取租户下所有人员的基本信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TaxAgentEmployeePO> listEmployees();
|
||||
|
||||
/**
|
||||
* 获取当前登录人角色(返回最大角色,优先级为:总管理员-》管理员-》分管理员)
|
||||
*
|
||||
|
|
@ -28,6 +36,7 @@ public interface TaxAgentService {
|
|||
|
||||
/**
|
||||
* 是否需要分权
|
||||
*
|
||||
* @param currentEmployeeId
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -169,6 +178,7 @@ public interface TaxAgentService {
|
|||
|
||||
/**
|
||||
* 获取作为管理员的个税扣缴义务人的下拉列表
|
||||
*
|
||||
* @param chiefCanSeeAll
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -228,6 +238,7 @@ public interface TaxAgentService {
|
|||
|
||||
/**
|
||||
* 获取个税扣缴义务人下的人员范围
|
||||
*
|
||||
* @param taxAgentId
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -100,6 +100,11 @@ public class SICategoryServiceImpl extends Service implements SICategoryService
|
|||
if(categoryPO == null){
|
||||
throw new SalaryRunTimeException("自定义福利不存在");
|
||||
}
|
||||
// 判断是否启用
|
||||
Integer isUse = categoryPO.getIsUse();
|
||||
if(isUse == 1){
|
||||
throw new SalaryRunTimeException("编辑失败,请先关闭启用按钮!");
|
||||
}
|
||||
// 判断福利名称是否重复
|
||||
List<ICategoryPO> iCategoryPOS = getICategoryMapper().listByName(iCategoryFormDTO.getInsuranceName());
|
||||
if(CollectionUtils.isNotEmpty(iCategoryPOS)){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,720 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.biz.*;
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.constant.SalaryItemConstant;
|
||||
import com.engine.salary.entity.salaryarchive.bo.SalaryArchiveExcelBO;
|
||||
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportDTO;
|
||||
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO;
|
||||
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportHandleParam;
|
||||
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveQueryParam;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentEmployeePO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum;
|
||||
import com.engine.salary.mapper.archive.SalaryArchiveMapper;
|
||||
import com.engine.salary.service.*;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import com.engine.salary.util.excel.ExcelComment;
|
||||
import com.engine.salary.util.excel.ExcelParseHelper;
|
||||
import com.engine.salary.util.excel.ExcelSupport;
|
||||
import com.engine.salary.util.excel.ExcelUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX;
|
||||
|
||||
/**
|
||||
* @Description: 薪资档案
|
||||
* @Author: wangxiangzhong
|
||||
* @Date: 2021-11-03 10:51
|
||||
*/
|
||||
public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArchiveExcelService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SalaryArchiveExcelServiceImpl.class);
|
||||
|
||||
private SalaryArchiveMapper getSalaryArchiveMapper() {
|
||||
return MapperProxyFactory.getProxy(SalaryArchiveMapper.class);
|
||||
}
|
||||
|
||||
private SalaryArchiveItemService salaryArchiveItemService() {
|
||||
return ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
private SalaryArchiveService salaryArchiveService() {
|
||||
return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
private TaxAgentService getTaxAgentService() {
|
||||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private SalaryEmployeeService getSalaryEmployeeService() {
|
||||
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private SalaryArchiveBiz salaryArchiveMapper = new SalaryArchiveBiz();
|
||||
private EmployBiz employBiz = new EmployBiz();
|
||||
private SalaryArchiveItemBiz salaryArchiveItemMapper = new SalaryArchiveItemBiz();
|
||||
private SalaryArchiveTaxAgentBiz salaryArchiveTaxAgentMapper = new SalaryArchiveTaxAgentBiz();
|
||||
private SalaryArchiveDimissionBiz salaryArchiveDimissionMapper = new SalaryArchiveDimissionBiz();
|
||||
private SalaryItemBiz salaryItemMapper = new SalaryItemBiz();
|
||||
|
||||
// private SalaryArchiveSobService salaryArchiveSobService;
|
||||
//
|
||||
// private SalaryEmployeeService salaryEmployeeService;
|
||||
// @Autowired
|
||||
// private HrmCommonHrmStatusService hrmCommonHrmStatusService;
|
||||
// @Autowired
|
||||
// private BaseEnvInfoService baseEnvInfoService;
|
||||
|
||||
// @Override
|
||||
// public void exportList(Map<String, Object> map, SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey) {
|
||||
// // 待定薪列表
|
||||
// boolean isPendingList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.PENDING);
|
||||
// // 定薪列表
|
||||
// boolean isFixedList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.FIXED);
|
||||
// // 待停薪列表
|
||||
// boolean isSuspendList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.SUSPEND);
|
||||
// // 停薪列表
|
||||
// boolean isStopList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.STOP);
|
||||
// if (isPendingList) {
|
||||
// queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue()));
|
||||
// } else if (isFixedList) {
|
||||
// queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue()));
|
||||
// } else if (isSuspendList) {
|
||||
// queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.SUSPEND.getValue()));
|
||||
// } else if (isStopList) {
|
||||
// queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue(), SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue()));
|
||||
// }
|
||||
// String nameI18n = SalaryI18nUtil.getI18nLabel(85368, "薪资档案") +
|
||||
// SalaryI18nUtil.getI18nLabel(queryParam.getListType().getLabelId(), queryParam.getListType().getDefaultLabel());
|
||||
// String payStartDateI18n = SalaryI18nUtil.getI18nLabel(109527, "起始发薪日期");
|
||||
// String payEndDateI18n = SalaryI18nUtil.getI18nLabel(109329, "最后发薪日期");
|
||||
// String effectiveTimeI18n = SalaryI18nUtil.getI18nLabel(85904, "生效日期");
|
||||
//
|
||||
// List<ExcelSheetData> sheetList = new ArrayList<>();
|
||||
// ExcelSheetData excelSheetData = new ExcelSheetData();
|
||||
// // 1.工作簿名称
|
||||
//// excelSheetData.setSheetName(nameI18n);
|
||||
//// boolean enableHr = baseEnvInfoService.checkDisplayModule(HrmModuleConstancts.hr, tenantKey);
|
||||
// List<String> headerList = Lists.newArrayList();
|
||||
// headerList.add(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
|
||||
// headerList.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
|
||||
// headerList.add(SalaryI18nUtil.getI18nLabel(121908, "收入所得项目"));
|
||||
// headerList.add(SalaryI18nUtil.getI18nLabel(87889, "薪资账套"));
|
||||
// headerList.add(SalaryI18nUtil.getI18nLabel(86319, "入职日期"));
|
||||
// headerList.add(SalaryI18nUtil.getI18nLabel(86185, "部门"));
|
||||
// headerList.add(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
|
||||
// headerList.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
|
||||
//// if (enableHr) {
|
||||
//// headerList.add(SalaryI18nUtil.getI18nLabel(106277, "身份证号码"));
|
||||
//// }
|
||||
// headerList.add(SalaryI18nUtil.getI18nLabel(109332, "人事状态"));
|
||||
// headerList.add(payStartDateI18n);
|
||||
// headerList.add(payEndDateI18n);
|
||||
// if (isFixedList) {
|
||||
// headerList.add(effectiveTimeI18n);
|
||||
// }
|
||||
// // 获取所有可被引用的薪资项目
|
||||
// List<SalaryItemPO> salaryItems = salaryArchiveItemService.getCanAdjustSalaryItems(tenantKey);
|
||||
// for (SalaryItemPO salaryItem : salaryItems) {
|
||||
// headerList.add(salaryItem.getName());
|
||||
// }
|
||||
// // 2.表头
|
||||
// excelSheetData.setHeaders(Collections.singletonList(headerList.toArray(new String[]{})));
|
||||
// // 获取所有个税扣缴义务人
|
||||
// Collection<TaxAgentListDTO> taxAgentList = getTaxAgentService().findAll(tenantKey);
|
||||
// Collection<SalaryArchiveListDTO> salaryArchives = salaryArchiveMapper.list(queryParam, tenantKey);
|
||||
// boolean isSearchIdNo = enableHr && StringUtils.isNotEmpty(queryParam.getIdNo());
|
||||
// if (isSearchIdNo) {
|
||||
// Map<Long, String> idNoEmpMap = salaryEmployeeService
|
||||
// .mapByEmployeeIds(salaryArchives.stream().map(SalaryArchiveListDTO::getEmployeeId).distinct().collect(Collectors.toList()), tenantKey);
|
||||
// salaryArchives = salaryArchives.stream().filter(f -> Optional.ofNullable(idNoEmpMap.get(f.getEmployeeId())).orElse("").contains(queryParam.getIdNo()))
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
// // 开启分权并且不是薪酬模块总管理员
|
||||
// boolean isChief = getTaxAgentService().isChief(employeeId, tenantKey);
|
||||
// if (getTaxAgentService().isOpenDevolution(tenantKey) && !isChief) {
|
||||
// List<TaxAgentEmployeeDTO> taxAgentEmployees = getTaxAgentService().listTaxAgentAndEmployee(employeeId, tenantKey);
|
||||
// List<Long> taxAgentIdsAsAdmin = getTaxAgentService().listAllTaxAgentsAsAdmin(employeeId, tenantKey).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
||||
// salaryArchives = salaryArchives.stream().filter(f ->
|
||||
// // 作为管理员
|
||||
// taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
||||
// // 作为分管理员
|
||||
// || TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId())
|
||||
// || employeeId.equals(f.getModifier())
|
||||
// ).collect(Collectors.toList());
|
||||
// }
|
||||
// Map<Long, String> idNoEmpMap =
|
||||
// enableHr ? salaryEmployeeService.mapByEmployeeIds(salaryArchives.stream().map(SalaryArchiveListDTO::getEmployeeId).distinct().collect(Collectors.toList()), tenantKey)
|
||||
// : new HashMap<>();
|
||||
// List<Map<String, Object>> listMaps = salaryArchiveService
|
||||
// .buildSalaryArchiveData(salaryArchives, taxAgentList, salaryItems, idNoEmpMap, employeeId, tenantKey, Boolean.FALSE);
|
||||
// // 组装数据
|
||||
// List<List<Object>> rows = new ArrayList<>();
|
||||
// listMaps.forEach(e -> {
|
||||
// List<Object> row = new ArrayList<>();
|
||||
// row.add(Optional.ofNullable(e.get("username")).orElse("").toString());
|
||||
// row.add(e.get("taxAgentName").toString());
|
||||
// row.add(e.get("incomeCategory").toString());
|
||||
// row.add(e.get("salarySob").toString());
|
||||
// row.add(Optional.ofNullable(e.get("hiredate")).orElse("").toString());
|
||||
// row.add(Optional.ofNullable(e.get("departmentName")).orElse("").toString());
|
||||
// row.add(Optional.ofNullable(e.get("mobile")).orElse("").toString());
|
||||
// row.add(Optional.ofNullable(e.get("jobNum")).orElse("").toString());
|
||||
// if (enableHr) {
|
||||
// row.add(Optional.ofNullable(e.get("idNo")).orElse("").toString());
|
||||
// }
|
||||
// row.add(e.get("employeeStatus").toString());
|
||||
// row.add(e.get("payStartDate").toString());
|
||||
// row.add(e.get("payEndDate").toString());
|
||||
// if (isFixedList) {
|
||||
// row.add(Optional.ofNullable(e.get("effectiveTime")).orElse("").toString());
|
||||
// }
|
||||
// // 薪资项目数据
|
||||
// for (SalaryItemPO salaryItem : salaryItems) {
|
||||
// row.add(e.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) ? (e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) == null ? ""
|
||||
// : e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX).toString()) : "");
|
||||
// }
|
||||
// rows.add(row);
|
||||
// });
|
||||
// // 3.表数据
|
||||
// excelSheetData.setRows(rows);
|
||||
//
|
||||
// sheetList.add(excelSheetData);
|
||||
//
|
||||
// salaryBatchService.simpleExportExcel(ExportExcelInfo.builder()
|
||||
// .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 + SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now()))
|
||||
// .handlerName("exportSalaryArchive")
|
||||
// .dataType(nameI18n)
|
||||
// .function("exportSalaryArchive").build(), sheetList);
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook downloadTemplate(SalaryArchiveQueryParam queryParam) {
|
||||
// 待定薪列表
|
||||
boolean isPendingList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.PENDING);
|
||||
// 定薪列表
|
||||
boolean isFixedList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.FIXED);
|
||||
// 待停薪列表
|
||||
boolean isSuspendList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.SUSPEND);
|
||||
if (isPendingList) {
|
||||
queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue()));
|
||||
} else if (isFixedList) {
|
||||
queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue()));
|
||||
} else if (isSuspendList) {
|
||||
queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.SUSPEND.getValue()));
|
||||
}
|
||||
|
||||
boolean isInit = queryParam.getImportType().equals(SalaryArchiveImportTypeEnum.INIT.getValue());
|
||||
boolean isSalaryItemAdjust = queryParam.getImportType().equals(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue());
|
||||
// 名称
|
||||
String nameI18n = SalaryI18nUtil.getI18nLabel(101601, "薪资档案导入模板")
|
||||
+ SalaryI18nUtil.getI18nLabel(queryParam.getListType().getLabelId(), queryParam.getListType().getDefaultLabel());
|
||||
if (isFixedList) {
|
||||
// 初始化
|
||||
if (isInit) {
|
||||
nameI18n +=
|
||||
"-" + SalaryI18nUtil.getI18nLabel(SalaryArchiveImportTypeEnum.INIT.getLabelId(), SalaryArchiveImportTypeEnum.INIT.getDefaultLabel());
|
||||
// 调薪
|
||||
} else if (isSalaryItemAdjust) {
|
||||
nameI18n += "-" + SalaryI18nUtil
|
||||
.getI18nLabel(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getLabelId(), SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getDefaultLabel());
|
||||
}
|
||||
}
|
||||
String finalNameI18n = nameI18n;
|
||||
|
||||
// 获取所有可被引用的薪资项目
|
||||
List<SalaryItemPO> salaryItems = salaryArchiveItemService().getCanAdjustSalaryItems();
|
||||
// boolean enableHr = baseEnvInfoService.checkDisplayModule(HrmModuleConstancts.hr, tenantKey);
|
||||
List<Object> header = Lists.newArrayList();
|
||||
header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
|
||||
header.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
|
||||
// header.add(SalaryI18nUtil.getI18nLabel(121908, "收入所得项目"));
|
||||
// header.add(SalaryI18nUtil.getI18nLabel(87889, "薪资账套"));
|
||||
// header.add(SalaryI18nUtil.getI18nLabel(86319, "入职日期"));
|
||||
header.add(SalaryI18nUtil.getI18nLabel(86185, "部门"));
|
||||
header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
|
||||
header.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
|
||||
// if (enableHr) {
|
||||
// header.add(SalaryI18nUtil.getI18nLabel(106277, "身份证号码"));
|
||||
// }
|
||||
// header.add(SalaryI18nUtil.getI18nLabel(109332, "人事状态"));
|
||||
String payStartDateI18n = SalaryI18nUtil.getI18nLabel(109527, "起始发薪日期");
|
||||
String payEndDateI18n = SalaryI18nUtil.getI18nLabel(109329, "最后发薪日期");
|
||||
String adjustReasonI18n = SalaryI18nUtil.getI18nLabel(85431, "调整原因");
|
||||
String effectiveTimeI18n = SalaryI18nUtil.getI18nLabel(85904, "生效日期");
|
||||
if (isPendingList) {
|
||||
header.add(payStartDateI18n);
|
||||
header.add(payEndDateI18n);
|
||||
} else if (isFixedList) {
|
||||
if (isInit) {
|
||||
header.add(payStartDateI18n);
|
||||
header.add(payEndDateI18n);
|
||||
header.add(effectiveTimeI18n);
|
||||
} else if (isSalaryItemAdjust) {
|
||||
header.add(adjustReasonI18n);
|
||||
header.add(effectiveTimeI18n);
|
||||
}
|
||||
} else if (isSuspendList) {
|
||||
header.add(payStartDateI18n);
|
||||
header.add(payEndDateI18n);
|
||||
}
|
||||
for (SalaryItemPO salaryItem : salaryItems) {
|
||||
header.add(salaryItem.getName());
|
||||
}
|
||||
// 2.表头
|
||||
List<List<Object>> rows = new ArrayList<>();
|
||||
rows.add(header);
|
||||
// 获取所有个税扣缴义务人
|
||||
Collection<TaxAgentPO> taxAgentList = getTaxAgentService().listAll();
|
||||
Collection<SalaryArchiveListDTO> salaryArchives = getSalaryArchiveMapper().list(queryParam);
|
||||
// boolean isSearchIdNo = enableHr && StringUtils.isNotEmpty(queryParam.getIdNo());
|
||||
// if (isSearchIdNo) {
|
||||
// Map<Long, String> idNoEmpMap = salaryEmployeeService
|
||||
// .mapByEmployeeIds(salaryArchives.stream().map(SalaryArchiveListDTO::getEmployeeId).distinct().collect(Collectors.toList()), tenantKey);
|
||||
// salaryArchives = salaryArchives.stream().filter(f -> Optional.ofNullable(idNoEmpMap.get(f.getEmployeeId())).orElse("").contains(queryParam.getIdNo()))
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
// 开启分权并且不是薪酬模块总管理员
|
||||
|
||||
long employeeId = user.getUID();
|
||||
if (getTaxAgentService().isNeedAuth(employeeId)) {
|
||||
List<TaxAgentEmployeeDTO> taxAgentEmployees = getTaxAgentService().listTaxAgentAndEmployee(employeeId);
|
||||
List<Long> taxAgentIdsAsAdmin = getTaxAgentService().listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
||||
salaryArchives = salaryArchives.stream().filter(f ->
|
||||
// 作为管理员
|
||||
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
||||
// 作为分管理员
|
||||
// || TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId())
|
||||
// || employeeId.equals(f.getModifier())
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
Map<Long, String> idNoEmpMap =
|
||||
// enableHr ? salaryEmployeeService.mapByEmployeeIds(salaryArchives.stream().map(SalaryArchiveListDTO::getEmployeeId).distinct().collect(Collectors.toList()), tenantKey)
|
||||
// :
|
||||
new HashMap<>();
|
||||
if (queryParam.getHasData()) {
|
||||
List<Map<String, Object>> listMaps = salaryArchiveService()
|
||||
.buildSalaryArchiveData(salaryArchives, taxAgentList, salaryItems, Boolean.FALSE);
|
||||
// 组装数据
|
||||
listMaps.forEach(e -> {
|
||||
List<Object> row = new ArrayList<>();
|
||||
row.add(e.get("username").toString());
|
||||
row.add(e.get("taxAgentName").toString());
|
||||
// row.add(e.get("incomeCategory").toString());
|
||||
// row.add(e.get("salarySob").toString());
|
||||
// row.add(e.get("hiredate"));
|
||||
row.add(e.get("departmentName"));
|
||||
row.add(e.get("mobile") == null ? "" : e.get("mobile").toString());
|
||||
row.add(Optional.ofNullable(e.get("jobNum")).orElse("").toString());
|
||||
// if (enableHr) {
|
||||
// row.add(Optional.ofNullable(e.get("idNo")).orElse("").toString());
|
||||
// }
|
||||
// row.add(e.get("employeeStatus").toString());
|
||||
if (isPendingList) {
|
||||
row.add(e.get("payStartDate").toString());
|
||||
row.add(e.get("payEndDate").toString());
|
||||
} else if (isFixedList) {
|
||||
if (isInit) {
|
||||
row.add(e.get("payStartDate").toString());
|
||||
row.add(e.get("payEndDate").toString());
|
||||
row.add(Optional.ofNullable(e.get("effectiveTime")).orElse("").toString());
|
||||
} else if (isSalaryItemAdjust) {
|
||||
row.add(Optional.ofNullable(e.get("adjustReason")).orElse("").toString());
|
||||
row.add(Optional.ofNullable(e.get("effectiveTime")).orElse("").toString());
|
||||
}
|
||||
} else if (isSuspendList) {
|
||||
row.add(e.get("payStartDate").toString());
|
||||
row.add(e.get("payEndDate").toString());
|
||||
}
|
||||
// 薪资项目数据
|
||||
for (SalaryItemPO salaryItem : salaryItems) {
|
||||
row.add(e.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) ? (e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) == null ? ""
|
||||
: e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX).toString()) : "");
|
||||
}
|
||||
rows.add(row);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 4.注释
|
||||
List<ExcelComment> excelComments = Lists.newArrayList();
|
||||
String requireI18n = SalaryI18nUtil.getI18nLabel(100344, "必填");
|
||||
excelComments.add(new ExcelComment(0, 0, 3, 2, requireI18n));
|
||||
excelComments.add(new ExcelComment(1, 0, 4, 2, requireI18n));
|
||||
//收入所得项目
|
||||
// List<String> incomeCategoryOptions = Arrays.stream(IncomeCategoryEnum.values()).map(e ->
|
||||
// SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())
|
||||
// ).collect(Collectors.toList());
|
||||
// SalaryArchiveExcelBO
|
||||
// .createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(121922, "必填,可填写如:") + Joiner.on(",").join(incomeCategoryOptions), 0, 0, 2, 2);
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, requireI18n + ',' + SalaryI18nUtil.getI18nLabel(127641, "多个账套之间用,分隔"), 0, 0, 3, 3);
|
||||
// int i = enableHr ? 10 : 9;
|
||||
if (isPendingList) {
|
||||
excelComments.add(new ExcelComment(5, 0, 8, 2, SalaryI18nUtil.getI18nLabel(100458, "格式样例为'2022-01-01'、'2022/1/1'")));
|
||||
// excelComments.add(new ExcelComment(5, 0, 8, 2, SalaryI18nUtil.getI18nLabel(100458, "格式样例为'2022-01-01'、'2022/1/1'")));
|
||||
} else if (isFixedList) {
|
||||
if (isInit) {
|
||||
excelComments.add(new ExcelComment(5, 0, 8, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,格式样例为'2022-01-01'、'2022/1/1'")));
|
||||
excelComments.add(new ExcelComment(6, 0, 9, 2, SalaryI18nUtil.getI18nLabel(100458, "格式样例为'2022-01-01'、'2022/1/1'")));
|
||||
excelComments.add(new ExcelComment(7, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,格式样例为'2022-01-01'、'2022/1/1'")));
|
||||
} else if (isSalaryItemAdjust) {
|
||||
excelComments.add(new ExcelComment(5, 0, 8, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,可填写如:入职,转正,调薪,调岗调薪,离职,其他,初始化")));
|
||||
excelComments.add(new ExcelComment(6, 0, 9, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,格式样例为'2022-01-01'、'2022/1/1'")));
|
||||
}
|
||||
} else if (isSuspendList) {
|
||||
// SalaryArchiveExcelBO.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(109736, "格式样例为'2022-01-01'、'2022/1/1'"), 0, 0, i + 1, i + 1);
|
||||
}
|
||||
|
||||
return ExcelUtil.genWorkbookV2(rows, finalNameI18n, excelComments);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 导入薪资档案
|
||||
// */
|
||||
// @BatchImportHandler("importSalaryArchive")
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void importSalaryArchive() {
|
||||
// BatchDocumentMessage message = BatchImportContext.getBatchDocumentMessage();
|
||||
// log.info("【薪资档案】接收到上传的数据:{}", String.format("batchTaskId=%s, fileName=%s", message.getBatchTaskId(), message.getBatchFile().getName()));
|
||||
// // 租户key
|
||||
// String tenantKey = message.getTenantKey().toLowerCase();
|
||||
// try {
|
||||
// // 加密用
|
||||
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
|
||||
// // 接收到解析的数据
|
||||
// batchImportEbatch(message);
|
||||
// } catch (Exception e) {
|
||||
// log.error("【薪资档案】导入失败:{}", String.format("batchTaskId=%s,错误信息=%s", message.getBatchTaskId(), e.getMessage()));
|
||||
// } finally {
|
||||
// // 加密用
|
||||
// DSTenantKeyThreadVar.tenantKey.remove();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 导入的数据插入到数据库中
|
||||
*/
|
||||
public Map<String, Object> batchImportEbatch(Map<String, Object> params) {
|
||||
// 初始化国际化标签
|
||||
SalaryArchiveExcelBO.initI18n();
|
||||
|
||||
String imageId = params.get("imageId").toString();
|
||||
// 列表类型
|
||||
String listType = params.get("listType").toString();
|
||||
// 导入类型
|
||||
String importType = Util.null2String(params.get("importType"));
|
||||
// 2.构建导入需要的数据
|
||||
SalaryArchiveImportHandleParam importHandleParam = buildImportHandleParam(listType, importType);
|
||||
|
||||
InputStream fileInputStream = null;
|
||||
try {
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
||||
Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX);
|
||||
|
||||
|
||||
int total = 0;
|
||||
//excel数据
|
||||
List<Map<String, Object>> data = ExcelParseHelper.parse2Map(sheet, 1);
|
||||
if (data != null) {
|
||||
total += data.size();
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
// 错误excel内容
|
||||
// List<ExcelSheet> errorExcelSheets = new ArrayList<>();
|
||||
// 用于(初始化导入)的相同employeeId时的处理
|
||||
List<SalaryArchiveInitImportDTO> initImportData = Lists.newArrayList();
|
||||
// 用于(调薪和调整个税扣缴义务人)的相同employeeId时取第一条记录,如果是初始化导入则有重复
|
||||
List<String> allTodoSalaryArchives = Lists.newArrayList();
|
||||
// if (excelSheet.getHeader().size() == 0) {
|
||||
// continue;
|
||||
// }
|
||||
List<String> headers = ExcelSupport.getSheetHeader(sheet, 0);
|
||||
|
||||
// 错误提示
|
||||
List<Map<String, String>> excelComments = new ArrayList<>();
|
||||
HashMap message = new HashMap();
|
||||
boolean isValidHeader = checkHeaders(importHandleParam, message, headers);
|
||||
if (!isValidHeader) {
|
||||
excelComments.add(message);
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
apidatas.put("successCount", successCount);
|
||||
apidatas.put("errorCount", errorCount);
|
||||
apidatas.put("errorNotice", excelComments);
|
||||
return apidatas;
|
||||
}
|
||||
int effectiveTimeIndex = 0;
|
||||
for (int j = 0; j < headers.size(); j++) {
|
||||
String header = headers.get(j);
|
||||
String key = header;
|
||||
if (key.equals(SalaryI18nUtil.getI18nLabel(85904, "生效日期"))) {
|
||||
effectiveTimeIndex = j;
|
||||
}
|
||||
}
|
||||
// 错误sheet数据
|
||||
List<Map<String, Object>> errorData = new ArrayList<>();
|
||||
|
||||
Map<String, Object> map;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
index += 1;
|
||||
map = data.get(i);
|
||||
map.put("index", i + 2);
|
||||
// 3.校验行内容
|
||||
boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam);
|
||||
if (isError) {
|
||||
errorCount += 1;
|
||||
// 添加错误数据
|
||||
errorData.add(map);
|
||||
} else {
|
||||
successCount += 1;
|
||||
}
|
||||
// 初始化导入对重复记录校验
|
||||
if (importHandleParam.isInit()) {
|
||||
Map<String, Object> validMap = SalaryArchiveExcelBO
|
||||
.validInitImportData(isError, i, map, excelComments, errorCount, successCount, errorData, initImportData, importHandleParam);
|
||||
errorCount = Integer.parseInt(validMap.getOrDefault("errorCount", errorCount).toString());
|
||||
successCount = Integer.parseInt(validMap.getOrDefault("successCount", successCount).toString());
|
||||
}
|
||||
// 导入进度
|
||||
// if (index % 100 == 0 || index >= total) {
|
||||
// salaryBatchService.sendImportRate(message.getBizId(), total, index);
|
||||
// }
|
||||
}
|
||||
|
||||
// 如果sheet包含错误数据
|
||||
if (CollectionUtils.isNotEmpty(errorData)) {
|
||||
// salaryBatchService.createErrorExcelSheet(headers, errorData, excelSheet.getName(), excelComments, errorExcelSheets);
|
||||
}
|
||||
|
||||
// 4.数据入库处理
|
||||
handleImportData(importHandleParam);
|
||||
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
|
||||
apidatas.put("successCount", successCount);
|
||||
apidatas.put("errorCount", errorCount);
|
||||
apidatas.put("errorNotice", excelComments);
|
||||
return apidatas;
|
||||
|
||||
// 发送导入回调信息
|
||||
// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets);
|
||||
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInputStream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建导入处理参数
|
||||
*
|
||||
* @param listType
|
||||
* @param importType
|
||||
* @return
|
||||
*/
|
||||
private SalaryArchiveImportHandleParam buildImportHandleParam(String listType, String importType) {
|
||||
// 获取所有可被引用的薪资项目
|
||||
List<SalaryItemPO> salaryItems = salaryArchiveItemService().getCanAdjustSalaryItems();
|
||||
Collection<Long> salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList());
|
||||
// 获取所有个税扣缴义务人
|
||||
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService().listTaxAgentAndEmployeeTree((long) user.getUID());
|
||||
|
||||
// 待定薪列表
|
||||
boolean isPendingList = listType.equals(SalaryArchiveListTypeEnum.PENDING.getValue());
|
||||
// 定薪列表
|
||||
boolean isFixedList = listType.equals(SalaryArchiveListTypeEnum.FIXED.getValue());
|
||||
// 待停薪列表
|
||||
boolean isSuspendList = listType.equals(SalaryArchiveListTypeEnum.SUSPEND.getValue());
|
||||
|
||||
boolean isInit = isFixedList && importType.equals(SalaryArchiveImportTypeEnum.INIT.getValue());
|
||||
boolean isSalaryItemAdjust = isFixedList && importType.equals(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue());
|
||||
// 初始化导入是先删除后增的,起始可以只加载非加密的列
|
||||
boolean isNoNeedSalaryItem = isPendingList || isInit;
|
||||
|
||||
List<String> runStatusList = Lists.newArrayList();// 初始化导入是全量
|
||||
if (isPendingList) {
|
||||
runStatusList = Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue());
|
||||
} else if (isSalaryItemAdjust) {
|
||||
runStatusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue());
|
||||
} else if (isSuspendList) {
|
||||
runStatusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue());
|
||||
}
|
||||
List<SalaryArchivePO> salaryArchiveList = salaryArchiveService().listSome(SalaryArchivePO.builder().runStatusList(runStatusList).build());
|
||||
List<Long> salaryArchiveIds = salaryArchiveList.stream().map(SalaryArchivePO::getId).collect(Collectors.toList());
|
||||
Map<String, SalaryArchivePO> salaryArchivesMap = SalaryEntityUtil.convert2Map(salaryArchiveList, k -> k.getEmployeeId() + "-" + k.getTaxAgentId());
|
||||
|
||||
List<TaxAgentEmployeePO> employees = getTaxAgentService().listEmployees();
|
||||
|
||||
// 查询人员状态
|
||||
// List<HrmStatus> hrmStatusList = hrmCommonHrmStatusService.list(tenantKey);
|
||||
|
||||
return SalaryArchiveImportHandleParam.builder()
|
||||
.listType(listType)
|
||||
.importType(importType)
|
||||
.currentEmployeeId((long) user.getUID())
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
// 待定薪列表
|
||||
.isPendingList(isPendingList)
|
||||
// 定薪列表
|
||||
.isFixedList(isFixedList)
|
||||
// 待停薪列表
|
||||
.isSuspendList(isSuspendList)
|
||||
// 初始化导入
|
||||
.isInit(isInit)
|
||||
// 调薪导入
|
||||
.isSalaryItemAdjust(isSalaryItemAdjust)
|
||||
// 获取租户下所有的人员
|
||||
.employees(getSalaryEmployeeService().listAll())
|
||||
// .hrmStatusList(hrmStatusList)
|
||||
// 获取所有个税扣缴义务人
|
||||
.taxAgentList(taxAgentList)
|
||||
.salaryItems(salaryItems)
|
||||
// 查询已有的薪资档案基本数据
|
||||
.salaryArchivesMap(salaryArchivesMap)
|
||||
.salaryItemIds(salaryItemIds)
|
||||
// 查询已生效的薪资项目数据
|
||||
.effectiveItemListMap(
|
||||
isSuspendList ? Collections.emptyMap() : salaryArchiveItemService().getEffectiveItemListMap(salaryArchiveIds, isNoNeedSalaryItem, salaryItemIds))
|
||||
// 查询未生效的薪资项目数据
|
||||
.ineffectiveItemListMap(
|
||||
isSuspendList ? Collections.emptyMap() : salaryArchiveItemService().getIneffectiveItemListMap(salaryArchiveIds, isNoNeedSalaryItem, salaryItemIds))
|
||||
// 当前时间
|
||||
.nowTime(new Date())
|
||||
// 当天
|
||||
.today(new Date())
|
||||
// 待保存薪资档案
|
||||
.salaryArchiveSaves(Lists.newArrayList())
|
||||
// 待保存薪资档案-薪资项目
|
||||
.salaryArchiveItemSaves(Lists.newArrayList())
|
||||
// 待修改薪资档案-薪资项目
|
||||
.salaryArchiveUpdates(Lists.newArrayList())
|
||||
// 待删除薪资档案-薪资项目
|
||||
.salaryArchiveItemDelSalaryItemIds(Lists.newArrayList())
|
||||
// 薪资账套
|
||||
// .salarySobList(salaryArchiveService.getSalarySobList(employeeId, tenantKey))
|
||||
// 待保存薪资档案-薪资账套
|
||||
// .salaryArchiveSobSaves(Lists.newArrayList())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查参数
|
||||
*
|
||||
* @param message
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
private boolean checkParams(Map message, Map<String, Object> params) {
|
||||
boolean isValid = true;
|
||||
|
||||
String errorMsg = SalaryArchiveExcelBO.handleCheckParams(message, params);
|
||||
// 有错误信息发送
|
||||
if (StringUtils.isNotEmpty(errorMsg)) {
|
||||
// 发送导入回调信息
|
||||
// salaryBatchService.sendImportCallBackInfo(message, errorMsg);
|
||||
isValid = false;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查列头
|
||||
*
|
||||
* @param importHandleParam
|
||||
* @param message
|
||||
* @param headers
|
||||
* @return
|
||||
*/
|
||||
private boolean checkHeaders(SalaryArchiveImportHandleParam importHandleParam, Map message, List<String> headers) {
|
||||
boolean isValid = true;
|
||||
|
||||
String errorMsg = SalaryArchiveExcelBO.handleCheckHeaders(importHandleParam, message, headers);
|
||||
// 有错误信息发送
|
||||
if (StringUtils.isNotEmpty(errorMsg)) {
|
||||
message.put("message", errorMsg);
|
||||
// 发送导入回调信息
|
||||
// salaryBatchService.sendImportCallBackInfo(message, errorMsg);
|
||||
isValid = false;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据落库处理
|
||||
*
|
||||
* @param importHandleParam
|
||||
*/
|
||||
private void handleImportData(SalaryArchiveImportHandleParam importHandleParam) {
|
||||
List<SalaryArchivePO> salaryArchiveSaves = importHandleParam.getSalaryArchiveSaves();
|
||||
List<SalaryArchivePO> salaryArchiveUpdates = importHandleParam.getSalaryArchiveUpdates();
|
||||
List<SalaryArchiveItemPO> salaryArchiveItemSaves = importHandleParam.getSalaryArchiveItemSaves();
|
||||
List<Long> salaryArchiveItemDelSalaryItemIds = importHandleParam.getSalaryArchiveItemDelSalaryItemIds();
|
||||
// List<SalaryArchiveSobPO> salaryArchiveSobSaves = importHandleParam.getSalaryArchiveSobSaves();
|
||||
// 新增薪资档案
|
||||
if (CollectionUtils.isNotEmpty(salaryArchiveSaves)) {
|
||||
// 去除已经存在的,避免重复
|
||||
if (CollectionUtils.isNotEmpty(salaryArchiveUpdates)) {
|
||||
List<Long> salaryArchiveUpdateIds = salaryArchiveUpdates.stream().map(SalaryArchivePO::getId).distinct().collect(Collectors.toList());
|
||||
salaryArchiveSaves = salaryArchiveSaves.stream().filter(save -> !salaryArchiveUpdateIds.contains(save.getId())).collect(Collectors.toList());
|
||||
}
|
||||
// 薪资档案
|
||||
salaryArchiveMapper.batchInsert(salaryArchiveSaves);
|
||||
}
|
||||
// 修改薪资档案
|
||||
if (CollectionUtils.isNotEmpty(salaryArchiveUpdates)) {
|
||||
// 薪资档案
|
||||
salaryArchiveMapper.batchUpdate(salaryArchiveUpdates);
|
||||
}
|
||||
// 薪资档案-薪资项目
|
||||
if (CollectionUtils.isNotEmpty(salaryArchiveItemDelSalaryItemIds)) {
|
||||
salaryArchiveItemMapper.deleteBatchIds(salaryArchiveItemDelSalaryItemIds);
|
||||
}
|
||||
// 薪资档案-薪资项目
|
||||
if (CollectionUtils.isNotEmpty(salaryArchiveItemSaves)) {
|
||||
salaryArchiveItemMapper.batchInsert(salaryArchiveItemSaves);
|
||||
}
|
||||
|
||||
// 薪资档案-薪资账套
|
||||
// salaryArchiveSaves.addAll(salaryArchiveUpdates);
|
||||
// List<Long> salaryArchiveIds = salaryArchiveSaves.stream().map(SalaryArchivePO::getId).distinct().collect(Collectors.toList());
|
||||
// if (CollectionUtils.isNotEmpty(salaryArchiveIds) && CollectionUtils.isNotEmpty(salaryArchiveSaves)) {
|
||||
// this.salaryArchiveSobService.saveBatchBySalaryArchiveIdsAndSaves(salaryArchiveIds, salaryArchiveSobSaves, message.getTenantKey());
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import com.engine.salary.enums.UserStatusEnum;
|
|||
import com.engine.salary.enums.salaryarchive.SalaryArchiveItemAdjustReasonEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.service.SalaryArchiveItemService;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.excel.ExcelUtil;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
|
|
@ -62,6 +63,17 @@ public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchi
|
|||
.effectiveTime(new Date()).build());
|
||||
}
|
||||
|
||||
private List<SalaryArchiveItemPO> getIneffectiveSalaryItems(Collection<Long> salaryArchivesIds, Collection<Long> salaryItemIds) {
|
||||
// 薪资档案id
|
||||
List<Long> salaryArchiveIds = CollectionUtils.isEmpty(salaryArchivesIds) ? Collections.singletonList(0L) : (List<Long>) salaryArchivesIds;
|
||||
// 没有薪资项目时,给个不存在的,否则加载所有不合理
|
||||
salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds;
|
||||
return salaryArchiveItemMapper.getIneffectiveSalaryItems(SalaryArchiveItemQueryParam.builder()
|
||||
.salaryArchivesIds(salaryArchiveIds)
|
||||
.salaryItemIds(salaryItemIds)
|
||||
.effectiveTime(new Date()).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前已生效 gt
|
||||
*
|
||||
|
|
@ -88,12 +100,12 @@ public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchi
|
|||
@Override
|
||||
public List<SalaryArchiveItemPO> getCurrentEffectiveItemList(Collection<Long> salaryArchivesIds, Collection<Long> salaryItemIds) {
|
||||
// 没有薪资项目时,给个不存在的,否则加载所有不合理
|
||||
salaryItemIds = CollectionUtils.isEmpty(salaryItemIds)?Collections.singletonList(0L):salaryItemIds;
|
||||
salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds;
|
||||
// 薪资档案id
|
||||
List<Long> salaryArchiveIds = CollectionUtils.isEmpty(salaryArchivesIds) ? Collections.singletonList(0L) : (List<Long>) salaryArchivesIds;
|
||||
List<SalaryArchiveItemPO> salaryArchiveItems = this.getEffectiveItemList(salaryArchiveIds, salaryItemIds);
|
||||
return salaryArchiveItems.stream()
|
||||
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId()+"-"+f.getSalaryItemId()))), ArrayList::new));
|
||||
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,6 +128,48 @@ public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchi
|
|||
return salaryArchiveItems;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, List<SalaryArchiveItemPO>> getEffectiveItemListMap(Collection<Long> salaryArchiveIds, boolean isNoNeedSalaryItem, Collection<Long> salaryItemIds) {
|
||||
// 没有薪资项目时,给个不存在的,否则加载所有不合理
|
||||
salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds;
|
||||
// 薪资档案id
|
||||
List<Long> saIds = CollectionUtils.isEmpty(salaryArchiveIds) ? Collections.singletonList(0L) : (List<Long>) salaryArchiveIds;
|
||||
|
||||
List<SalaryArchiveItemPO> salaryArchiveItems = Lists.newArrayList();
|
||||
|
||||
if (isNoNeedSalaryItem) {
|
||||
salaryArchiveItems.addAll(getEffectiveItemList(saIds, salaryItemIds));
|
||||
} else {
|
||||
salaryArchiveItems = this.getEffectiveItemList(saIds, salaryItemIds);
|
||||
}
|
||||
|
||||
return SalaryEntityUtil.group2Map(salaryArchiveItems, k -> k.getSalaryArchiveId() + "-" + k.getSalaryItemId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<SalaryArchiveItemPO>> getIneffectiveItemListMap(Collection<Long> salaryArchiveIds, boolean isNoNeedSalaryItem, Collection<Long> salaryItemIds) {
|
||||
// 没有薪资项目时,给个不存在的,否则加载所有不合理
|
||||
salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds;
|
||||
// 薪资档案id
|
||||
Collection<Long> saIds = CollectionUtils.isEmpty(salaryArchiveIds) ? Collections.singletonList(0L) : salaryArchiveIds;
|
||||
List<SalaryArchiveItemPO> salaryArchiveItems = Lists.newArrayList();
|
||||
|
||||
if (isNoNeedSalaryItem) {
|
||||
salaryArchiveItems.addAll(getIneffectiveSalaryItems(saIds, salaryItemIds));
|
||||
} else {
|
||||
List<List<Long>> partition = Lists.partition((List) saIds, 1000);
|
||||
Collection<Long> finalSalaryItemIds = salaryItemIds;
|
||||
partition.forEach(part -> {
|
||||
salaryArchiveItems.addAll(getIneffectiveSalaryItems(saIds, finalSalaryItemIds));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return SalaryEntityUtil.group2Map(salaryArchiveItems, k -> k.getSalaryArchiveId() + "-" + k.getSalaryItemId());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SalaryArchiveItemPO> getCurrentEffectiveItemListIngoreValue(Collection<Long> salaryArchivesIds, List<Long> salaryItemIds) {
|
||||
// 没有薪资项目时,给个不存在的,否则加载所有不合理
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -132,6 +132,12 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
|
|||
|
||||
// private HrmCommonHrmStatusService hrmCommonHrmStatusService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<TaxAgentEmployeePO> listEmployees() {
|
||||
return getTaxAgentMapper().listEmployee();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaxAgentRoleTypeEnum getRoleType(Long currentEmployeeId) {
|
||||
TaxAgentRoleTypeEnum roleType = TaxAgentRoleTypeEnum.NONE;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ import com.engine.common.util.ServiceUtil;
|
|||
import com.engine.salary.entity.salaryarchive.dto.*;
|
||||
import com.engine.salary.entity.salaryarchive.param.*;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum;
|
||||
import com.engine.salary.util.ResponseResult;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.wrapper.SalaryArchiveItemWrapper;
|
||||
import com.engine.salary.wrapper.SalaryArchiveTaxAgentWrapper;
|
||||
|
|
@ -374,9 +377,40 @@ public class SalaryArchiveController {
|
|||
|
||||
XSSFWorkbook workbook = getSalaryArchiveWrapper(user).downloadTemplate(queryParam);
|
||||
|
||||
SalaryArchiveImportTypeEnum importTypeEnum = SalaryArchiveImportTypeEnum.parseByValue(queryParam.getImportType());
|
||||
SalaryArchiveListTypeEnum listTypeEnum = queryParam.getListType();
|
||||
|
||||
String fileName = "薪资档案导入模板-" + importTypeEnum.getDefaultLabel() + LocalDate.now();
|
||||
// 待定薪列表
|
||||
boolean isPendingList = listTypeEnum == SalaryArchiveListTypeEnum.PENDING;
|
||||
// 定薪列表
|
||||
boolean isFixedList = listTypeEnum == SalaryArchiveListTypeEnum.FIXED;
|
||||
// 待停薪列表
|
||||
boolean isSuspendList = listTypeEnum == SalaryArchiveListTypeEnum.SUSPEND;
|
||||
if (isPendingList) {
|
||||
queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue()));
|
||||
} else if (isFixedList) {
|
||||
queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue()));
|
||||
} else if (isSuspendList) {
|
||||
queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.SUSPEND.getValue()));
|
||||
}
|
||||
|
||||
boolean isInit = SalaryArchiveImportTypeEnum.INIT.getValue().equals(queryParam.getImportType());
|
||||
boolean isSalaryItemAdjust = SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue().equals(queryParam.getImportType());
|
||||
// 名称
|
||||
String finalNameI18n = SalaryI18nUtil.getI18nLabel(101601, "薪资档案导入模板-")
|
||||
+ SalaryI18nUtil.getI18nLabel(listTypeEnum.getLabelId(), listTypeEnum.getDefaultLabel());
|
||||
if (isFixedList) {
|
||||
// 初始化
|
||||
if (isInit) {
|
||||
finalNameI18n +=
|
||||
"-" + SalaryI18nUtil.getI18nLabel(SalaryArchiveImportTypeEnum.INIT.getLabelId(), SalaryArchiveImportTypeEnum.INIT.getDefaultLabel());
|
||||
// 调薪
|
||||
} else if (isSalaryItemAdjust) {
|
||||
finalNameI18n += "-" + SalaryI18nUtil
|
||||
.getI18nLabel(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getLabelId(), SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getDefaultLabel());
|
||||
}
|
||||
}
|
||||
|
||||
String fileName = finalNameI18n + LocalDate.now();
|
||||
|
||||
try {
|
||||
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
|
||||
|
|
@ -429,9 +463,7 @@ public class SalaryArchiveController {
|
|||
param.setHiredate(Arrays.asList(hiredate.split(",")));
|
||||
}
|
||||
String importType = request.getParameter("importType");
|
||||
if (StringUtils.isNotBlank(importType)) {
|
||||
param.setImportType(importType);
|
||||
}
|
||||
param.setImportType(importType);
|
||||
String hasData = request.getParameter("hasData");
|
||||
if (StringUtils.isNotBlank(hasData)) {
|
||||
param.setHasData(Boolean.valueOf(hasData));
|
||||
|
|
@ -444,6 +476,10 @@ public class SalaryArchiveController {
|
|||
if (StringUtils.isNotBlank(runStatusLists)) {
|
||||
param.setRunStatusList(Arrays.stream(runStatusLists.split(",")).collect(Collectors.toList()));
|
||||
}
|
||||
String listType = request.getParameter("listType");
|
||||
if (StringUtils.isNotBlank(listType)) {
|
||||
param.setListType(SalaryArchiveListTypeEnum.parseByValue(listType));
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
|
|
@ -474,9 +510,9 @@ public class SalaryArchiveController {
|
|||
@POST
|
||||
@Path("/importSalaryArchive")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String importSalaryArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveImportHandleParam importParam) {
|
||||
public String importSalaryArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String, Object> importParam) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<SalaryArchiveImportHandleParam, Map<String, Object>>(user).run(getSalaryArchiveWrapper(user)::importSalaryArchive, importParam);
|
||||
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getSalaryArchiveWrapper(user)::importSalaryArchive, importParam);
|
||||
}
|
||||
|
||||
//人员状态列表
|
||||
|
|
|
|||
|
|
@ -22,9 +22,11 @@ import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
|||
import com.engine.salary.enums.UserStatusEnum;
|
||||
import com.engine.salary.enums.salaryarchive.*;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.service.SalaryArchiveExcelService;
|
||||
import com.engine.salary.service.SalaryArchiveItemService;
|
||||
import com.engine.salary.service.SalaryArchiveService;
|
||||
import com.engine.salary.service.TaxAgentService;
|
||||
import com.engine.salary.service.impl.SalaryArchiveExcelServiceImpl;
|
||||
import com.engine.salary.service.impl.SalaryArchiveItemServiceImpl;
|
||||
import com.engine.salary.service.impl.SalaryArchiveServiceImpl;
|
||||
import com.engine.salary.service.impl.TaxAgentServiceImpl;
|
||||
|
|
@ -33,6 +35,7 @@ import com.engine.salary.util.page.PageInfo;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.hrm.User;
|
||||
|
|
@ -64,6 +67,11 @@ public class SalaryArchiveWrapper extends Service {
|
|||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private SalaryArchiveExcelService getSalaryArchiveExcelService(User user) {
|
||||
return ServiceUtil.getService(SalaryArchiveExcelServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 薪资档案列表(分页)
|
||||
*
|
||||
|
|
@ -447,12 +455,19 @@ public class SalaryArchiveWrapper extends Service {
|
|||
* @return
|
||||
*/
|
||||
public XSSFWorkbook downloadTemplate(SalaryArchiveQueryParam queryParam) {
|
||||
SalaryArchiveImportTypeEnum salaryArchiveImportTypeEnum = SalaryArchiveImportTypeEnum.parseByValue(queryParam.getImportType());
|
||||
if (salaryArchiveImportTypeEnum == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100593, "导入类型不正确"));
|
||||
if (queryParam.getListType() == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109712, "列表类型必传"));
|
||||
} else {
|
||||
// 定薪列表导入有调薪导入和初始化导入
|
||||
if (queryParam.getListType().equals(SalaryArchiveListTypeEnum.FIXED.getValue())) {
|
||||
Optional<SalaryArchiveImportTypeEnum> optional = Arrays.stream(SalaryArchiveImportTypeEnum.values())
|
||||
.filter(e -> StringUtils.isNotEmpty(queryParam.getImportType()) && e.getValue().equals(queryParam.getImportType())).findFirst();
|
||||
if (!optional.isPresent()) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100593, "导入类型不正确"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getSalaryArchiveService(user).downloadTemplate(SalaryArchiveImportTypeEnum.parseByValue(queryParam.getImportType()), queryParam);
|
||||
return getSalaryArchiveExcelService(user).downloadTemplate(queryParam);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -471,8 +486,8 @@ public class SalaryArchiveWrapper extends Service {
|
|||
* @param param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> importSalaryArchive(SalaryArchiveImportHandleParam param) {
|
||||
return getSalaryArchiveService(user).importSalaryArchive(param);
|
||||
public Map<String, Object> importSalaryArchive(Map<String, Object> param) {
|
||||
return getSalaryArchiveExcelService(user).batchImportEbatch(param);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue