调薪记录

This commit is contained in:
钱涛 2023-10-17 18:04:47 +08:00
parent a34a5b9aa6
commit 5d7a6bc241
8 changed files with 145 additions and 33 deletions

View File

@ -140,7 +140,20 @@ public class SalaryArchiveItemBiz {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class);
return encryptUtil.decryptList(mapper.salaryItemAdjustRecordList(queryParam, salaryItemIds), SalaryItemAdjustRecordListDTO.class);
List<Long> salaryArchiveIds = queryParam.getSalaryArchiveIds();
if (CollectionUtils.isEmpty(salaryArchiveIds)) {
List<SalaryItemAdjustRecordListDTO> salaryItemAdjustRecordListDTOS = mapper.salaryItemAdjustRecordList(queryParam, salaryItemIds);
return encryptUtil.decryptList(salaryItemAdjustRecordListDTOS, SalaryItemAdjustRecordListDTO.class);
} else {
List<SalaryItemAdjustRecordListDTO> salaryItemAdjustRecordListDTOS = new ArrayList<>();
List<List<Long>> salaryArchiveIdsPartition = Lists.partition(salaryArchiveIds, 500);
salaryArchiveIdsPartition.forEach(l -> {
queryParam.setSalaryArchiveIds(l);
salaryItemAdjustRecordListDTOS.addAll(mapper.salaryItemAdjustRecordList(queryParam, salaryItemIds));
});
return encryptUtil.decryptList(salaryItemAdjustRecordListDTOS, SalaryItemAdjustRecordListDTO.class);
}
} finally {
sqlSession.close();
}
@ -161,7 +174,16 @@ public class SalaryArchiveItemBiz {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class);
List<SalaryItemAdjustRecordListDTO> salaryItemAdjustRecordListDTOS = mapper.salaryItemAdjustRecordList(queryParam, salaryItemIds);
List<Long> salaryArchiveIds = queryParam.getSalaryArchiveIds();
List<List<Long>> salaryArchiveIdsPartition = Lists.partition(salaryArchiveIds, 500);
List<SalaryItemAdjustRecordListDTO> salaryItemAdjustRecordListDTOS = new ArrayList<>();
salaryArchiveIdsPartition.forEach(l -> {
queryParam.setSalaryArchiveIds(l);
salaryItemAdjustRecordListDTOS.addAll(mapper.salaryItemAdjustRecordList(queryParam, salaryItemIds));
});
PageInfo<SalaryItemAdjustRecordListDTO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(),
salaryItemAdjustRecordListDTOS,
SalaryItemAdjustRecordListDTO.class);

View File

@ -30,6 +30,7 @@ public class SalaryItemAdjustRecordQueryParam extends BaseQueryParam {
//薪资档案id
private Long salaryArchiveId;
private List<Long> salaryArchiveIds;
//关键字姓名部门薪资项目名称
private String keyword;

View File

@ -114,6 +114,7 @@ public class SalaryArchivePO {
//---------条件-------
private Collection<Long> ids;
private Collection<Long> taxAgentIds;
private Collection<Long> employeeIds;
/**
* 状态

View File

@ -563,11 +563,10 @@
<if test="param.salaryArchiveId != null">
AND t1.salary_archive_id = #{param.salaryArchiveId}
</if>
<!-- 部门 -->
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND d.id IN
<foreach collection="param.departmentIds" open="(" item="id" separator="," close=")">
#{id}
<if test="param.salaryArchiveIds != null and param.salaryArchiveIds.size()>0">
AND t1.salary_archive_id IN
<foreach collection="param.salaryArchiveIds" open="(" item="salaryArchiveId" separator="," close=")">
#{salaryArchiveId}
</foreach>
</if>
<!-- 调整原因 -->
@ -637,7 +636,12 @@
<if test="param.salaryArchiveId != null">
AND t1.salary_archive_id = #{param.salaryArchiveId}
</if>
<if test="param.salaryArchiveIds != null and param.salaryArchiveIds.size()>0">
AND t1.salary_archive_id IN
<foreach collection="param.salaryArchiveIds" open="(" item="salaryArchiveId" separator="," close=")">
#{salaryArchiveId}
</foreach>
</if>
<if test="param.adjustReason != null and param.adjustReason != ''">
AND t1.adjust_reason = #{param.adjustReason}
</if>
@ -711,11 +715,10 @@
AND t1.salary_archive_id = #{param.salaryArchiveId}
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND d.id IN
<foreach collection="param.departmentIds" open="(" item="id" separator="," close=")">
#{id}
<if test="param.salaryArchiveIds != null and param.salaryArchiveIds.size()>0">
AND t1.salary_archive_id IN
<foreach collection="param.salaryArchiveIds" open="(" item="salaryArchiveId" separator="," close=")">
#{salaryArchiveId}
</foreach>
</if>
@ -737,7 +740,6 @@
#{id}
</foreach>
</if>
ORDER BY t1.effective_time DESC,t1.id DESC
</select>

View File

@ -658,6 +658,12 @@
#{id}
</foreach>
</if>
<if test="param.taxAgentIds != null and param.taxAgentIds.size()>0">
AND t.tax_agent_id IN
<foreach collection="param.taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
#{taxAgentId}
</foreach>
</if>
ORDER BY t.id DESC
</select>

View File

@ -6,6 +6,7 @@ import com.engine.salary.biz.SalaryArchiveBiz;
import com.engine.salary.biz.SalaryArchiveItemBiz;
import com.engine.salary.biz.SalaryItemBiz;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustRecordListDTO;
import com.engine.salary.entity.salaryarchive.param.*;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
@ -13,11 +14,14 @@ import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveFieldTypeEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveItemAdjustReasonEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.SalaryArchiveItemService;
import com.engine.salary.service.SalaryArchiveService;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
@ -62,6 +66,13 @@ public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchi
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SalaryArchiveService getSalaryArchiveService(User user) {
return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
/**
* 获取未生效 lt
*
@ -617,23 +628,60 @@ public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchi
List<SalaryItemPO> salaryItemList = getCanAdjustSalaryItems();
List<Long> salaryItemIds = salaryItemList.stream().map(SalaryItemPO::getId).collect(Collectors.toList());
// 获取记录
List<SalaryItemAdjustRecordListDTO> list = salaryArchiveItemMapper.salaryItemAdjustRecordList(queryParam, salaryItemIds);
long currentEmployeeId = user.getUID();
//是否开启分权
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
if (needAuth) {
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId);
List<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId, Collectors.toList());
if (CollectionUtils.isEmpty(taxAgentIds)) {
// return new PageInfo<SalaryItemAdjustRecordListDTO>();
}
List<SalaryArchivePO> salaryArchives = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentIds(taxAgentIds).build());
List<Long> salaryArchiveIds = SalaryEntityUtil.properties(salaryArchives, SalaryArchivePO::getId, Collectors.toList());
queryParam.setSalaryArchiveIds(salaryArchiveIds);
}
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL);
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
List<SalaryItemAdjustRecordListDTO> listResult = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(queryParam, salaryItemIds);
listResult = listResult.stream()
.filter(r -> {
DataCollectionEmployee employee = employeeMap.getOrDefault(r.getEmployeeId(), new DataCollectionEmployee());
String username = queryParam.getUsername();
List<Long> departmentIds = queryParam.getDepartmentIds();
List<Long> positionIds = queryParam.getPositionIds();
String userstatus = queryParam.getUserstatus();
r.setUsername(employee.getUsername());
r.setDepartmentName(employee.getDepartmentName());
r.setEmployeeStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(employee.getStatus())));
r.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(r.getAdjustReason()));
return (StringUtils.isBlank(username) || employee.getUsername().contains(username))
&& (CollectionUtils.isEmpty(departmentIds) || departmentIds.contains(employee.getDepartmentId()))
&& (CollectionUtils.isEmpty(positionIds) || positionIds.contains(employee.getJobtitleId()))
&& (StringUtils.isBlank(userstatus) || Objects.equals(employee.getStatus(), userstatus))
&& (CollectionUtils.isEmpty(positionIds) || positionIds.contains(employee.getJobtitleId()))
;
})
.collect(Collectors.toList());
List<SalaryItemAdjustRecordListDTO> listAll = salaryArchiveItemMapper.salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam.builder().build(), salaryItemIds);
// 人员信息赋值
list.forEach(m -> {
listResult.forEach(m -> {
if (!org.springframework.util.CollectionUtils.isEmpty(listAll)) {
listAll.removeIf(a -> a.getId().equals(m.getId()));
}
Optional<SalaryItemAdjustRecordListDTO> optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId()) && f.getSalaryItemId().equals(m.getSalaryItemId())).findFirst();
m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : "");
m.setEmployeeStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(m.getEmployeeStatus())));
m.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason()));
});
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<List<Object>> rows = new ArrayList<>();
rows.add(headerList);
for (SalaryItemAdjustRecordListDTO dto : list) {
for (SalaryItemAdjustRecordListDTO dto : listResult) {
List<Object> row = new ArrayList<>();
row.add(dto.getUsername());
row.add(dto.getEmployeeStatus());

View File

@ -56,10 +56,6 @@ public class SIReportController {
@Path("record/list")
@Produces(MediaType.APPLICATION_JSON)
public String recordList(@Context HttpServletRequest request, @Context HttpServletResponse response) {
// if (StringUtils.isEmpty(token)) {
// return WeaResult.success(null, SalrayCheckSecondAuthConstant.CHECK_SECOND_FAIL_NO_TOKEN);
// }
// Long employeeId = UserContext.getCurrentEmployeeId();
User user = HrmUserVarify.getUser(request, response);
SalaryItemAdjustRecordQueryParam salaryItemAdjustRecordQueryParam = new SalaryItemAdjustRecordQueryParam();
salaryItemAdjustRecordQueryParam.setEmployeeId((long)user.getUID());

View File

@ -11,6 +11,7 @@ import com.engine.salary.entity.salaryarchive.param.SalaryItemAdjustBeforeParam;
import com.engine.salary.entity.salaryarchive.param.SalaryItemAdjustRecordQueryParam;
import com.engine.salary.entity.salaryarchive.param.SingleSalaryItemAdjustRecordQueryParam;
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.po.TaxAgentPO;
import com.engine.salary.enums.UserStatusEnum;
@ -22,9 +23,11 @@ import com.engine.salary.service.impl.*;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.engine.salary.wrapper.proxy.SalaryArchiveItemWrapperProxy;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import weaver.hrm.User;
@ -229,8 +232,46 @@ public class SalaryArchiveItemWrapper extends Service implements SalaryArchiveIt
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
List<SalaryItemAdjustRecordListDTO> listAll = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam.builder().build(), salaryItemIds);
PageInfo<SalaryItemAdjustRecordListDTO> list = getSalaryArchiveItemService(user).salaryItemAdjustRecordListPage(queryParam, salaryItemIds);
List<SalaryItemAdjustRecordListDTO> listResult = list.getList();
long currentEmployeeId = user.getUID();
//是否开启分权
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
if (needAuth) {
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId);
List<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId, Collectors.toList());
if (CollectionUtils.isEmpty(taxAgentIds)) {
return new PageInfo<SalaryItemAdjustRecordListDTO>();
}
List<SalaryArchivePO> salaryArchives = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentIds(taxAgentIds).build());
List<Long> salaryArchiveIds = SalaryEntityUtil.properties(salaryArchives, SalaryArchivePO::getId, Collectors.toList());
queryParam.setSalaryArchiveIds(salaryArchiveIds);
}
List<SalaryItemAdjustRecordListDTO> listResult = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(queryParam, salaryItemIds);
listResult = listResult.stream()
.filter(r -> {
DataCollectionEmployee employee = employeeMap.getOrDefault(r.getEmployeeId(), new DataCollectionEmployee());
String username = queryParam.getUsername();
List<Long> departmentIds = queryParam.getDepartmentIds();
List<Long> positionIds = queryParam.getPositionIds();
String userstatus = queryParam.getUserstatus();
r.setUsername(employee.getUsername());
r.setDepartmentName(employee.getDepartmentName());
r.setEmployeeStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(employee.getStatus())));
r.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(r.getAdjustReason()));
return (StringUtils.isBlank(username) || employee.getUsername().contains(username))
&& (CollectionUtils.isEmpty(departmentIds) || departmentIds.contains(employee.getDepartmentId()))
&& (CollectionUtils.isEmpty(positionIds) || positionIds.contains(employee.getJobtitleId()))
&& (StringUtils.isBlank(userstatus) || Objects.equals(employee.getStatus(), userstatus))
&& (CollectionUtils.isEmpty(positionIds) || positionIds.contains(employee.getJobtitleId()))
;
})
.collect(Collectors.toList());
PageInfo<SalaryItemAdjustRecordListDTO> pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), listResult, SalaryItemAdjustRecordListDTO.class);
listResult = pageInfo.getList();
//获取上次更改的记录
listResult.forEach(m -> {
if (!CollectionUtils.isEmpty(listAll)) {
@ -238,19 +279,14 @@ public class SalaryArchiveItemWrapper extends Service implements SalaryArchiveIt
}
Optional<SalaryItemAdjustRecordListDTO> optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId()) && f.getSalaryItemId().equals(m.getSalaryItemId())).findFirst();
m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : "");
DataCollectionEmployee employee = employeeMap.getOrDefault(m.getEmployeeId(), new DataCollectionEmployee());
m.setUsername(employee.getUsername());
m.setDepartmentName(employee.getDepartmentName());
m.setEmployeeStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(employee.getStatus())));
m.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason()));
});
return list;
return pageInfo;
}
/**
* 我的调薪记录
*
* @param queryParam
* @return
*/