xzy-fix-处理Employee_statuses历史数据
This commit is contained in:
parent
6dcecfb1c1
commit
b2b0abcaf5
|
|
@ -70,4 +70,15 @@ public class SalarySobRangeBiz {
|
|||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateEmployeeStatuses(SalarySobRangePO item) {
|
||||
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
|
||||
try {
|
||||
SalarySobRangeMapper mapper = sqlSession.getMapper(SalarySobRangeMapper.class);
|
||||
mapper.updateEmployeeStatuses(item);
|
||||
sqlSession.commit();
|
||||
} finally {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,61 +36,61 @@ public class SalarySobRangeBO {
|
|||
* @return
|
||||
*/
|
||||
public static List<SalarySobRangeEmpQueryParam> convert2EmployeeQueryParam(List<SalarySobRangePO> salarySobRanges) {
|
||||
if (CollectionUtils.isEmpty(salarySobRanges)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<SalarySobRangeEmpQueryParam> resultParams = Lists.newArrayListWithExpectedSize(salarySobRanges.size());
|
||||
salarySobRanges.stream().forEach( item -> {
|
||||
List<String> employeeStatus= new ArrayList<>();
|
||||
List<SalaryEmployeeStatusEnum> salaryEmployeeStatusEnums = SalaryEmployeeStatusEnum.parseByValues(item.getEmployeeStatuses());
|
||||
salaryEmployeeStatusEnums.stream().forEach(e -> e.name().toLowerCase());
|
||||
if(salaryEmployeeStatusEnums.contains((SalaryEmployeeStatusEnum.ALL.name().toLowerCase()))){
|
||||
employeeStatus = Collections.emptyList();
|
||||
}else if (employeeStatus.contains(SalaryEmployeeStatusEnum.NORMAL.name().toLowerCase())) {
|
||||
employeeStatus = UserStatusEnum.getNormalStatus();
|
||||
}else if (employeeStatus.equals(SalaryEmployeeStatusEnum.UNAVAILABLE.name().toLowerCase())) {
|
||||
employeeStatus = UserStatusEnum.getUnavailableStatus();
|
||||
}
|
||||
TargetTypeEnum targetTypeEnum = TargetTypeEnum.parseByValue(item.getTargetType());
|
||||
SalarySobRangeEmpQueryParam queryParam = SalarySobRangeEmpQueryParam.builder()
|
||||
.targetType(Optional.ofNullable(targetTypeEnum).map(TargetTypeEnum::name).orElse(StringUtils.EMPTY))
|
||||
.targetIds(SalaryEntityUtil.properties(salarySobRanges, SalarySobRangePO::getTargetId))
|
||||
.employeeStatus(employeeStatus)
|
||||
.build();
|
||||
resultParams.add(queryParam);
|
||||
});
|
||||
return resultParams;
|
||||
|
||||
|
||||
|
||||
|
||||
// Map<Integer, List<SalarySobRangePO>> rangeMap = SalaryEntityUtil.group2Map(salarySobRanges, SalarySobRangePO::getTargetType);
|
||||
// List<SalarySobRangeEmpQueryParam> resultParams = Lists.newArrayListWithExpectedSize(rangeMap.size());
|
||||
// rangeMap.forEach((targetType, salarySobRangePOS) -> {
|
||||
// List<String> employeeStatus = salarySobRangePOS.stream()
|
||||
// .map(e -> SalaryEmployeeStatusEnum.parseByValue(e.getEmployeeStatus()))
|
||||
// .filter(Objects::nonNull)
|
||||
// .map(e -> e.name().toLowerCase())
|
||||
// .distinct()
|
||||
// .collect(Collectors.toList());
|
||||
// if (employeeStatus.contains(SalaryEmployeeStatusEnum.ALL.name().toLowerCase())) {
|
||||
// if (CollectionUtils.isEmpty(salarySobRanges)) {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
// List<SalarySobRangeEmpQueryParam> resultParams = Lists.newArrayListWithExpectedSize(salarySobRanges.size());
|
||||
// salarySobRanges.stream().forEach( item -> {
|
||||
// List<String> employeeStatus= new ArrayList<>();
|
||||
// List<SalaryEmployeeStatusEnum> salaryEmployeeStatusEnums = SalaryEmployeeStatusEnum.parseByValues(item.getEmployeeStatuses());
|
||||
// salaryEmployeeStatusEnums.stream().forEach(e -> e.name().toLowerCase());
|
||||
// if(salaryEmployeeStatusEnums.contains((SalaryEmployeeStatusEnum.ALL.name().toLowerCase()))){
|
||||
// employeeStatus = Collections.emptyList();
|
||||
// }
|
||||
// if (employeeStatus.contains(SalaryEmployeeStatusEnum.NORMAL.name().toLowerCase())) {
|
||||
// }else if (employeeStatus.contains(SalaryEmployeeStatusEnum.NORMAL.name().toLowerCase())) {
|
||||
// employeeStatus = UserStatusEnum.getNormalStatus();
|
||||
// }
|
||||
// if (employeeStatus.contains(SalaryEmployeeStatusEnum.UNAVAILABLE.name().toLowerCase())) {
|
||||
// }else if (employeeStatus.equals(SalaryEmployeeStatusEnum.UNAVAILABLE.name().toLowerCase())) {
|
||||
// employeeStatus = UserStatusEnum.getUnavailableStatus();
|
||||
// }
|
||||
// TargetTypeEnum targetTypeEnum = TargetTypeEnum.parseByValue(targetType);
|
||||
// TargetTypeEnum targetTypeEnum = TargetTypeEnum.parseByValue(item.getTargetType());
|
||||
// SalarySobRangeEmpQueryParam queryParam = SalarySobRangeEmpQueryParam.builder()
|
||||
// .targetType(Optional.ofNullable(targetTypeEnum).map(TargetTypeEnum::name).orElse(StringUtils.EMPTY))
|
||||
// .targetIds(SalaryEntityUtil.properties(salarySobRangePOS, SalarySobRangePO::getTargetId))
|
||||
// .targetIds(SalaryEntityUtil.properties(salarySobRanges, SalarySobRangePO::getTargetId))
|
||||
// .employeeStatus(employeeStatus)
|
||||
// .build();
|
||||
// resultParams.add(queryParam);
|
||||
// });
|
||||
// return resultParams;
|
||||
|
||||
|
||||
|
||||
|
||||
Map<Integer, List<SalarySobRangePO>> rangeMap = SalaryEntityUtil.group2Map(salarySobRanges, SalarySobRangePO::getTargetType);
|
||||
List<SalarySobRangeEmpQueryParam> resultParams = Lists.newArrayListWithExpectedSize(rangeMap.size());
|
||||
rangeMap.forEach((targetType, salarySobRangePOS) -> {
|
||||
List<String> employeeStatus = salarySobRangePOS.stream()
|
||||
.map(e -> SalaryEmployeeStatusEnum.parseByValue(e.getEmployeeStatus()))
|
||||
.filter(Objects::nonNull)
|
||||
.map(e -> e.name().toLowerCase())
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
if (employeeStatus.contains(SalaryEmployeeStatusEnum.ALL.name().toLowerCase())) {
|
||||
employeeStatus = Collections.emptyList();
|
||||
}
|
||||
if (employeeStatus.contains(SalaryEmployeeStatusEnum.NORMAL.name().toLowerCase())) {
|
||||
employeeStatus = UserStatusEnum.getNormalStatus();
|
||||
}
|
||||
if (employeeStatus.contains(SalaryEmployeeStatusEnum.UNAVAILABLE.name().toLowerCase())) {
|
||||
employeeStatus = UserStatusEnum.getUnavailableStatus();
|
||||
}
|
||||
TargetTypeEnum targetTypeEnum = TargetTypeEnum.parseByValue(targetType);
|
||||
SalarySobRangeEmpQueryParam queryParam = SalarySobRangeEmpQueryParam.builder()
|
||||
.targetType(Optional.ofNullable(targetTypeEnum).map(TargetTypeEnum::name).orElse(StringUtils.EMPTY))
|
||||
.targetIds(SalaryEntityUtil.properties(salarySobRangePOS, SalarySobRangePO::getTargetId))
|
||||
.employeeStatus(employeeStatus)
|
||||
.build();
|
||||
resultParams.add(queryParam);
|
||||
});
|
||||
return resultParams;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 关联人员
|
||||
|
|
@ -57,7 +56,7 @@ public class SalarySobRangePO {
|
|||
* 人员状态使用逗号分隔
|
||||
* @see SalaryEmployeeStatusEnum
|
||||
*/
|
||||
private List<Integer> employeeStatuses;
|
||||
private String employeeStatuses;
|
||||
|
||||
/**
|
||||
* 是包含还是排除 0:排除、1:包含
|
||||
|
|
|
|||
|
|
@ -84,6 +84,15 @@ public enum UserStatusEnum implements BaseEnum {
|
|||
return Arrays.asList(FIRE.getValue().toString(), DEPARTURE.getValue().toString(), RETIRED.getValue().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getAllStatus() {
|
||||
return Arrays.asList(TRIAL.getValue().toString(), FORMAL.getValue().toString(), TEMPORARY.getValue().toString(), DELAY.getValue().toString(),FIRE.getValue().toString(), DEPARTURE.getValue().toString(), RETIRED.getValue().toString());
|
||||
}
|
||||
|
||||
public static List<UserStatusEnum> getEffectiveList() {
|
||||
return Arrays.stream(UserStatusEnum.values()).filter(v -> v != INVALID).collect(Collectors.toList());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,4 +85,9 @@ public interface SalarySobRangeMapper {
|
|||
*/
|
||||
List<Long> listEmployeeIds(@Param("params") Collection<SalarySobRangeEmpQueryParam> params);
|
||||
|
||||
/**
|
||||
* 更新人员状态使用逗号分割
|
||||
* @param item
|
||||
*/
|
||||
void updateEmployeeStatuses(@Param("param") SalarySobRangePO item);
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
, t.update_time
|
||||
, t.delete_type
|
||||
, t.tenant_key
|
||||
, t.employee_statuses
|
||||
</sql>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
|
|
@ -399,6 +400,10 @@
|
|||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateEmployeeStatuses">
|
||||
UPDATE hrsa_salary_sob_range set employee_statuses = #{param.employeeStatuses} WHERE id = #{param.id}
|
||||
</update>
|
||||
|
||||
<select id="listEmployeeIds" resultType="long">
|
||||
SELECT id FROM hrmresource em
|
||||
WHERE em.status not in (7)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,14 @@ public interface SalarySobRangeService {
|
|||
*/
|
||||
List<SalarySobRangePO> listBySalarySobIdAndIncludeType(Long salarySobId, Integer includeType);
|
||||
|
||||
/***
|
||||
* @description 获取所有的薪资账套的人员范围
|
||||
* @return List<SalarySangePO>
|
||||
* @author Harryxzy
|
||||
* @date 2022/10/8 16:12
|
||||
*/
|
||||
List<SalarySobRangePO> listAllSalarySobRange();
|
||||
|
||||
/**
|
||||
* 根据查询条件查询薪资账套的人员范围
|
||||
*
|
||||
|
|
@ -65,4 +73,10 @@ public interface SalarySobRangeService {
|
|||
* @param salarySobIds 薪资账套id
|
||||
*/
|
||||
void deleteBySalarySobIds(Collection<Long> salarySobIds);
|
||||
|
||||
/**
|
||||
* 更新人员状态从status中存到statuses中
|
||||
* @param item
|
||||
*/
|
||||
void updateEmployeeStatuses(SalarySobRangePO item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,11 @@ public class SalarySobRangeServiceImpl extends Service implements SalarySobRange
|
|||
return salarySobRangeBiz.listSome(SalarySobRangePO.builder().salarySobId(salarySobId).includeType(includeType).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SalarySobRangePO> listAllSalarySobRange() {
|
||||
return salarySobRangeBiz.listSome(SalarySobRangePO.builder().build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<SalarySobRangeListDTO> listPageByParamAndIncludeType(SalarySobRangeQueryParam queryParam, Integer includeType) {
|
||||
// 查询人员范围
|
||||
|
|
@ -190,4 +195,9 @@ public class SalarySobRangeServiceImpl extends Service implements SalarySobRange
|
|||
public void deleteBySalarySobIds(Collection<Long> salarySobIds) {
|
||||
salarySobRangeBiz.deleteBySalarySobIds(salarySobIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEmployeeStatuses(SalarySobRangePO item) {
|
||||
salarySobRangeBiz.updateEmployeeStatuses(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package com.engine.salary.util;
|
||||
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobRangePO;
|
||||
import com.engine.salary.enums.UserStatusEnum;
|
||||
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
|
||||
import com.engine.salary.service.impl.SalarySobRangeServiceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Harryxzy
|
||||
* @date 2022/10/08 16:06
|
||||
* @description 薪资账套工具
|
||||
*/
|
||||
public class SalarySobUtil {
|
||||
|
||||
|
||||
// 处理历史数据将薪资账套中将关联人员状态转换为List
|
||||
public static void handleEmployeeStatusHistory(){
|
||||
// 根据薪资账套查询人员
|
||||
SalarySobRangeServiceImpl salarySobRangeService = new SalarySobRangeServiceImpl();
|
||||
List<SalarySobRangePO> salarySobRangePOS = salarySobRangeService.listAllSalarySobRange();
|
||||
if(salarySobRangePOS != null){
|
||||
// 判断是否已经转换过
|
||||
SalarySobRangePO salarySobRangePO = salarySobRangePOS.get(0);
|
||||
if(salarySobRangePO.getEmployeeStatuses() == null || salarySobRangePO.getEmployeeStatuses().equals("")){
|
||||
salarySobRangePOS.stream().forEach(item ->{
|
||||
List<String> employeeStatus = new ArrayList<>();
|
||||
if(item.getEmployeeStatus() == SalaryEmployeeStatusEnum.ALL.getValue()){
|
||||
// 全部
|
||||
employeeStatus.addAll(UserStatusEnum.getAllStatus());
|
||||
}else if(item.getEmployeeStatus() == SalaryEmployeeStatusEnum.NORMAL.getValue()){
|
||||
// 在职
|
||||
employeeStatus.addAll(UserStatusEnum.getNormalStatus());
|
||||
}else if(item.getEmployeeStatus() == SalaryEmployeeStatusEnum.UNAVAILABLE.getValue()){
|
||||
// 离职
|
||||
employeeStatus.addAll(UserStatusEnum.getUnavailableStatus());
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i=0; i<employeeStatus.size(); i++){
|
||||
sb.append(employeeStatus.get(i));
|
||||
if(i+1!=employeeStatus.size()){
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
item.setEmployeeStatuses(sb.toString());
|
||||
salarySobRangeService.updateEmployeeStatuses(item);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ import com.engine.salary.service.impl.SalarySobServiceImpl;
|
|||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.SalarySobUtil;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.wrapper.proxy.SalaryAcctRecordWrapperProxy;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
|
@ -56,6 +57,10 @@ public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecord
|
|||
// private ComInfoCache comInfoCache;
|
||||
|
||||
public PageInfo<SalaryAcctRecordListDTO> listPage(SalaryAcctRecordQueryParam queryParam) {
|
||||
|
||||
// 处理历史数据将薪资账套中将关联人员状态转换为List
|
||||
SalarySobUtil.handleEmployeeStatusHistory();
|
||||
|
||||
EmployBiz employBiz = new EmployBiz();
|
||||
// 查询薪资核算记录(分页)
|
||||
PageInfo<SalaryAcctRecordPO> page = getSalaryAcctRecordService(user).listPageByParam(queryParam);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.engine.salary.service.impl.SalarySobServiceImpl;
|
|||
import com.engine.salary.service.impl.TaxAgentServiceImpl;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.SalarySobUtil;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -51,6 +52,9 @@ public class SalarySobWrapper extends Service {
|
|||
*/
|
||||
public PageInfo<SalarySobListDTO> listPage(SalarySobListQueryParam queryParam) {
|
||||
|
||||
// 处理历史数据将薪资账套中将关联人员状态转换为List
|
||||
SalarySobUtil.handleEmployeeStatusHistory();
|
||||
|
||||
// 查询薪资账套
|
||||
PageInfo<SalarySobPO> page = getSalarySobService(user).listPageByParam(queryParam);
|
||||
// 薪资账套po转换成薪资账套列表dto
|
||||
|
|
|
|||
Loading…
Reference in New Issue