东方骏驰人事花名册功能

东方骏驰
Chengliang 9 months ago
parent 05d0a85816
commit 97f0edc056

@ -0,0 +1,26 @@
package com.engine.kqsolution.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/9/11 9:45 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HrmStatusPO {
private Integer resourceId;
private String changeDate;
private Integer typeN;
}

@ -9,6 +9,7 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.pc.table.WeaTableType;
import com.engine.core.impl.Service;
import com.engine.kqsolution.entity.HistoryResourcePO;
import com.engine.kqsolution.entity.HrmStatusPO;
import com.engine.kqsolution.service.ResourceSnipService;
import com.engine.kqsolution.util.ExcelUtil;
import com.engine.kqsolution.util.ResourceSnipUtils;
@ -21,7 +22,11 @@ import weaver.general.Util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
@ -31,6 +36,9 @@ import java.util.*;
*/
public class ResourceSnipServiceImpl extends Service implements ResourceSnipService {
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@Override
public Map<String, Object> resourceSnip(String monthDate, String companyStartDate) {
Map<String, Object> resultMap = new HashMap<>(4);
@ -216,6 +224,15 @@ public class ResourceSnipServiceImpl extends Service implements ResourceSnipServ
String regresidentplace = bb.getPropValue("jcsecond", "regresidentplace");
String femdate = bb.getPropValue("jcsecond", "femdate");
LocalDate firstDayOfMonth = LocalDate.parse(companyStartDate + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate firstDay = firstDayOfMonth.withDayOfMonth(1);
LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
// 转换为字符串并打印结果
String firstDayStr = firstDay.format(DATE_FORMATTER);
String lastDayStr = lastDay.format(DATE_FORMATTER);
rs.executeQuery("select a.id,a.workcode,a.lastname,a.birthday,a.sex,a.subcompanyid1,a.departmentid,a.managerid,a.companystartdate,\n" +
"a.createdate,a.accumfundaccount,b."+account+" as account,b."+bankField+" as bankname,c."+femdate+" as femdate,\n" +
@ -223,7 +240,7 @@ public class ResourceSnipServiceImpl extends Service implements ResourceSnipServ
"a.nativeplace,b."+regresidentplace+" as regresidentplace from hrmresource a\n" +
"left join cus_fielddata b on a.id = b.id and b.scopeid = 1\n" +
"left join cus_fielddata c on a.id = c.id and c.scopeid = -1\n" +
"where a.companystartdate <= '2024-09-30'");
"where a.companystartdate <= '"+lastDayStr+"'");
List<HistoryResourcePO> historyResourceList = new ArrayList<>();
while (rs.next()) {
@ -245,7 +262,7 @@ public class ResourceSnipServiceImpl extends Service implements ResourceSnipServ
.startdate(Util.null2String(rs.getString("startdate")))
.endDate(Util.null2String(rs.getString("enddate")))
.jobTitle(ResourceSnipUtils.selectJobName(Util.null2String(rs.getString("jobtitle"))))
.status(Util.null2String(rs.getString("status")))
.status(ResourceSnipUtils.selectStatusName(Util.null2String(rs.getString("status"))))
.educationlevel(ResourceSnipUtils.selectEducName(Util.null2String(rs.getString("educationlevel"))))
.mobile(Util.null2String(rs.getString("mobile")))
.certificatenum(Util.null2String(rs.getString("certificatenum")))
@ -258,8 +275,100 @@ public class ResourceSnipServiceImpl extends Service implements ResourceSnipServ
//todo 数据处理
//3.花名册年月 选择 2024-09 查询数据 2024-9.30 之前所有入职人员 去掉离职日期是2024年9.01之前的数据(注意返聘情况)
resultMap.put("data",historyResourceList);
//3.1 选择日期前离职数据
List<HrmStatusPO> leaveList = new ArrayList<>();
rs.executeQuery("select resourceid,type_n,changedate from hrmstatushistory where type_n = 5 and changedate < '"+firstDayStr+"'");
while (rs.next()){
Integer resourceId = Util.getIntValue(rs.getString("resourceid"));
Integer typeN = Util.getIntValue(rs.getString("type_n"));
String changeDate = Util.null2String(rs.getString("changedate"));
leaveList.add(HrmStatusPO.builder().resourceId(resourceId).typeN(typeN).changeDate(changeDate).build());
}
List<HrmStatusPO> leaveResult = filterList(leaveList);
//3.2 返聘数据
List<HrmStatusPO> returnList = new ArrayList<>();
rs.executeQuery("select resourceid,type_n,changedate from hrmstatushistory where type_n = 7");
while(rs.next()) {
Integer resourceId = Util.getIntValue(rs.getString("resourceid"));
Integer typeN = Util.getIntValue(rs.getString("type_n"));
String changeDate = Util.null2String(rs.getString("changedate"));
returnList.add(HrmStatusPO.builder().resourceId(resourceId).typeN(typeN).changeDate(changeDate).build());
}
List<HrmStatusPO> returnResult = filterList(returnList);
//3.3 移除离职数据中存在返聘情况的人员 (返聘日期>离职日期)
List<HrmStatusPO> compareList = compareList(leaveResult, returnResult);
//3.4 查询数据中过滤人员
List<HistoryResourcePO> filteredList = historyResourceList.stream()
.filter(hrpo -> compareList.stream()
.noneMatch(hspo -> hspo.getResourceId().equals(hrpo.getResourceId())))
.collect(Collectors.toList());
//3.4 当月离职数据保留显示
List<HrmStatusPO> leaveMonthList = new ArrayList<>();
RecordSet rs1 = new RecordSet();
rs1.executeQuery("select resourceid,type_n,changedate from hrmstatushistory where type_n = 5 \n" +
"and changedate >= '"+firstDayStr+"' and changedate <= '"+lastDayStr+"'");
while (rs1.next()) {
Integer resourceId = Util.getIntValue(rs1.getString("resourceid"));
Integer typeN = Util.getIntValue(rs1.getString("type_n"));
String changeDate = Util.null2String(rs1.getString("changedate"));
leaveMonthList.add(HrmStatusPO.builder().resourceId(resourceId).typeN(typeN).changeDate(changeDate).build());
}
List<HrmStatusPO> leaveMonthResult = filterList(leaveMonthList);
Map<Integer, String> leaveMonthMap = leaveMonthResult.stream()
.collect(Collectors.toMap(HrmStatusPO::getResourceId, HrmStatusPO::getChangeDate));
filteredList.forEach(hrpo -> {
String newDate = leaveMonthMap.get(hrpo.getResourceId());
if (newDate != null) {
hrpo.setChangeDate(newDate);
}
});
resultMap.put("data",filteredList);
return resultMap;
}
private List<HrmStatusPO> filterList(List<HrmStatusPO> list) {
return list.stream()
.collect(Collectors.groupingBy(
HrmStatusPO::getResourceId,
Collectors.maxBy(Comparator.comparing(
po -> LocalDate.parse(po.getChangeDate(), DATE_FORMATTER)
))
))
.values()
.stream()
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
}
private List<HrmStatusPO> compareList(List<HrmStatusPO> leaveResult,List<HrmStatusPO> returnResult) {
Map<String, LocalDate> returnResultMap = returnResult.stream()
.collect(Collectors.toMap(
po -> po.getResourceId().toString(),
po -> LocalDate.parse(po.getChangeDate(), DATE_FORMATTER)
));
// 2. 更新 leaveResult移除不符合条件的条目
return leaveResult.stream()
.filter(leavePo -> {
LocalDate leaveDate = LocalDate.parse(leavePo.getChangeDate(), DATE_FORMATTER);
LocalDate returnDate = returnResultMap.get(leavePo.getResourceId().toString());
return returnDate == null || leaveDate.isAfter(returnDate);
})
.collect(Collectors.toList());
}
}

@ -3,6 +3,8 @@ package test;
import weaver.common.DateUtil;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
/**
* @Author weaver_cl
@ -14,11 +16,29 @@ public class MainTest {
public static void main(String[] args) {
LocalDate localDate = LocalDate.parse("2029-02"+"-01");
String fromDate = localDate.toString();
String toDate = localDate.withDayOfMonth(localDate.lengthOfMonth()).toString();
System.out.println(fromDate);
System.out.println(toDate);
String monthYear = "2023-02";
// 定义日期格式,适用于解析"yyyy-MM"格式的字符串
DateTimeFormatter monthYearFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
// 解析字符串为 LocalDate 对象(这里我们假设其表示该月的第一天)
LocalDate firstDayOfMonth = LocalDate.parse(monthYear + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// 获取本月的第一天
LocalDate firstDay = firstDayOfMonth.withDayOfMonth(1);
// 获取本月的最后一天
LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
// 定义输出格式
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 转换为字符串并打印结果
String firstDayStr = firstDay.format(outputFormatter);
String lastDayStr = lastDay.format(outputFormatter);
System.out.println("本月第一天: " + firstDayStr);
System.out.println("本月最后一天: " + lastDayStr);
}
public static double calculateActualWorkHours(double punchInHours) {

Loading…
Cancel
Save