parent
cf2ab9c5ca
commit
9bf8a8b7c8
|
|
@ -21,7 +21,14 @@ public enum AttStatus {
|
|||
婚("17"),
|
||||
丧("18"),
|
||||
育("19"),
|
||||
陪("20");
|
||||
陪("20"),
|
||||
流("21"),
|
||||
哺("22"),
|
||||
节("23"),
|
||||
护("24"),
|
||||
其他("25")
|
||||
|
||||
;
|
||||
|
||||
private String code;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public interface AttSourceDataDao {
|
|||
* 查询月考勤情况
|
||||
* @return list bean
|
||||
*/
|
||||
List<AttMonthReportBean> selectAttMonthReport(@Param("pushDate")String pushDate);
|
||||
List<AttMonthReportBean> selectAttMonthReport(@Param("pushDate")String pushDate,@Param("attRuleDate")String attRuleDate);
|
||||
|
||||
/**
|
||||
* 新增月报表
|
||||
|
|
@ -154,4 +154,6 @@ public interface AttSourceDataDao {
|
|||
void insertWorkAbnormal(List<AttSourceDataBean> longBreakRecords);
|
||||
|
||||
int getFirstAttendanceData(String date);
|
||||
|
||||
void deleteAttMonthReport(String pushDate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,7 @@ import javax.annotation.Resource;
|
|||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
|
|
@ -76,7 +73,7 @@ public class AttTasks {
|
|||
/**
|
||||
* 历史考勤数据
|
||||
*/
|
||||
// @Scheduled(initialDelay = 6000,fixedDelay = 60000 * 30)
|
||||
@Scheduled(initialDelay = 6000,fixedDelay = 60000 * 30)
|
||||
@Async
|
||||
public void getHisAttTasks() {
|
||||
log.info("--------考勤定时器开启------");
|
||||
|
|
@ -84,8 +81,8 @@ public class AttTasks {
|
|||
return; // 如果任务已经执行过,直接返回
|
||||
}
|
||||
executed = true; // 设置标志位,表示任务已经执行过
|
||||
String startDate = "2024-12-21";
|
||||
String endDate = "2024-12-21";
|
||||
String startDate = "2025-01-03";
|
||||
String endDate = "2025-01-31";
|
||||
List<String> dateList = getStrDateListBetween(startDate, endDate);
|
||||
// List<String> dateList = new ArrayList<>();
|
||||
// dateList.add("2024-10-18");
|
||||
|
|
@ -93,6 +90,45 @@ public class AttTasks {
|
|||
log.info("--------考勤定时器完毕------");
|
||||
}
|
||||
|
||||
/**
|
||||
* 防止黔送离线数据每月前三天晚上将数据重新执行
|
||||
*/
|
||||
@Scheduled(cron = "0 30 22 1-3 * *")
|
||||
@Async
|
||||
public void getHisMonthAttTask() {
|
||||
// 获取当前日期
|
||||
LocalDate today = LocalDate.now();
|
||||
// 获取上个月的YearMonth实例
|
||||
YearMonth previousMonth = YearMonth.from(today).minusMonths(1);
|
||||
// 上个月的第一天
|
||||
LocalDate startOfPreviousMonth = previousMonth.atDay(1);
|
||||
// 上个月的最后一天
|
||||
LocalDate endOfPreviousMonth = previousMonth.atEndOfMonth();
|
||||
String startDate = startOfPreviousMonth.toString();
|
||||
String endDate = endOfPreviousMonth.toString();
|
||||
List<String> dateList = getStrDateListBetween(startDate, endDate);
|
||||
hisAttPush(dateList);
|
||||
log.info("--------考勤定时器完毕------");
|
||||
}
|
||||
|
||||
/**
|
||||
* 凌晨0-5点得到数据,算作昨天,将昨天的重新执行
|
||||
*/
|
||||
@Scheduled(cron = "0 5 6 * * ?")
|
||||
@Async
|
||||
public void getHisYesterdayAttTask() {
|
||||
// 获取今天的日期
|
||||
LocalDate today = LocalDate.now();
|
||||
// 计算昨天的日期
|
||||
LocalDate yesterday = today.minusDays(1);
|
||||
String startDate = yesterday.toString();
|
||||
String endDate = yesterday.toString();
|
||||
List<String> dateList = getStrDateListBetween(startDate, endDate);
|
||||
hisAttPush(dateList);
|
||||
log.info("--------考勤定时器完毕------");
|
||||
}
|
||||
|
||||
|
||||
public void hisAttPush(List<String> dateList) {
|
||||
// 创建固定大小的线程池
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
|
||||
|
|
@ -104,7 +140,7 @@ public class AttTasks {
|
|||
executorService.submit(() -> {
|
||||
for (String date : batch) {
|
||||
try {
|
||||
delHisData(date);
|
||||
// delHisData(date);
|
||||
pushAttData(date, 2);
|
||||
} catch (Exception e) {
|
||||
// 记录异常并继续处理下一个日期
|
||||
|
|
@ -142,9 +178,9 @@ public class AttTasks {
|
|||
*/
|
||||
private void pushAttData(String pushDate, int pushType) {
|
||||
//获取黔送云的考勤数据
|
||||
getQsyAttendanceData(pushDate, pushType);
|
||||
//获取考勤机中的考勤数据
|
||||
getMachineAttendanceData(pushDate, pushType);
|
||||
// getQsyAttendanceData(pushDate, pushType);
|
||||
// //获取考勤机中的考勤数据
|
||||
// getMachineAttendanceData(pushDate, pushType);
|
||||
// //查出每一个考勤组的应出勤天数以及考勤组的规则
|
||||
List<AttGroupBean> groupList = getGroupData(pushDate, pushType);
|
||||
// //新增默认考勤数据到考勤数据和修改表
|
||||
|
|
@ -1125,8 +1161,21 @@ public class AttTasks {
|
|||
List<AttDayReportBean> dayReportList = attSourceDataDao.selectAttDayReport(pushDate, pushType);
|
||||
//日报表新增
|
||||
attSourceDataDao.insertAttDayReport(dayReportList);
|
||||
String attRuleDate;
|
||||
//月报表查询
|
||||
List<AttMonthReportBean> monthReportList = attSourceDataDao.selectAttMonthReport(pushDate);
|
||||
if (pushType == 2) {
|
||||
//历史数据查询
|
||||
//如果是当月,将最新时间,将最新时间存进去,如果是之前月,将之前月的最后一天存进去
|
||||
// 当前日期时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 调用方法获取目标日期
|
||||
LocalDate targetDate = getTargetDate(now);
|
||||
attRuleDate = targetDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}else{
|
||||
//如果更新当天数据查询
|
||||
attRuleDate = DateUtil.today();
|
||||
}
|
||||
List<AttMonthReportBean> monthReportList = attSourceDataDao.selectAttMonthReport(pushDate,attRuleDate);
|
||||
//人员对应出月出勤天数
|
||||
monthReportList.forEach(c ->
|
||||
groupList.stream()
|
||||
|
|
@ -1134,8 +1183,33 @@ public class AttTasks {
|
|||
.findFirst()
|
||||
.ifPresent(v -> c.setRequiredDays(v.getAttWorkDayBean().getRequiredDays()))
|
||||
);
|
||||
//先将本月数据删除,重新生成
|
||||
attSourceDataDao.deleteAttMonthReport(pushDate);
|
||||
//月报表新增
|
||||
attSourceDataDao.insertAttMonthReport(monthReportList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前日期计算目标日期
|
||||
*
|
||||
* @param now 当前日期时间
|
||||
* @return 目标日期
|
||||
*/
|
||||
public static LocalDate getTargetDate(LocalDateTime now) {
|
||||
// 获取当前日期的年份和月份
|
||||
YearMonth currentYearMonth = YearMonth.from(now);
|
||||
|
||||
// 获取当前日期的月初日期
|
||||
LocalDate firstDayOfMonth = currentYearMonth.atDay(1);
|
||||
|
||||
// 判断是否是当月
|
||||
if (now.getMonth().equals(firstDayOfMonth.getMonth())) {
|
||||
// 如果是当月,返回当前日期的日期部分
|
||||
return now.toLocalDate();
|
||||
} else {
|
||||
// 如果是之前月份,返回该月份的最后一天
|
||||
return currentYearMonth.atEndOfMonth();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ public class WorkdayCalculator {
|
|||
|
||||
public static void main(String[] args) {
|
||||
|
||||
List<String> list= getWorkDay("1,1,1,1,1,0,0", 1, getHolidays(), "2024-12-01");
|
||||
List<String> list= getWorkDay("1,1,1,1,1,0,0", 1, getHolidays(), "2025-01-01");
|
||||
System.out.print(1);
|
||||
}
|
||||
|
||||
|
|
@ -70,15 +70,19 @@ public class WorkdayCalculator {
|
|||
|
||||
private static List<Holiday> getHolidays() {
|
||||
List<Holiday> holidays = new ArrayList<>();
|
||||
holidays.add(new Holiday("2024-12-01", "", "1"));
|
||||
holidays.add(new Holiday("2024-12-07", "", "1"));
|
||||
holidays.add(new Holiday("2024-12-08", "", "1"));
|
||||
holidays.add(new Holiday("2024-12-14", "", "1"));
|
||||
holidays.add(new Holiday("2024-12-15", "", "1"));
|
||||
holidays.add(new Holiday("2024-12-21", "", "1"));
|
||||
holidays.add(new Holiday("2024-12-22", "", "1"));
|
||||
holidays.add(new Holiday("2024-12-28", "", "1"));
|
||||
holidays.add(new Holiday("2024-12-29", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-01", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-04", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-05", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-11", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-12", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-18", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-19", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-25", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-26", "", "2"));
|
||||
holidays.add(new Holiday("2025-01-28", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-29", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-30", "", "1"));
|
||||
holidays.add(new Holiday("2025-01-31", "", "1"));
|
||||
return holidays;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ public class ExportFileController {
|
|||
writer.merge(rowNum + listData.size(), rowNum + listData.size() + 1, 0, 0,
|
||||
"说明", false);
|
||||
writer.merge(rowNum + listData.size(), rowNum + listData.size(), 1, 2 + days.size(),
|
||||
"1.考勤记录:出勤记“√”,出差记“Δ”,年休假记“年”,探亲假记“探”,事假记“事”,法定假记“法”,病假记“病”,产假记“产”,婚假记“婚”,丧假记“丧”,育儿假记“育”,陪护假记“陪”,补休记“补”,旷工记“旷”,迟到记“迟”,早退记“退”,省内工地记“工”,省外工地记“外”,出差需在备注栏备注清楚出差地点。", false);
|
||||
"1.考勤记录:出勤记“√”,出差记“Δ”,年休假记“年”,探亲假记“探”,事假记“事”,法定假记“法”,病假记“病”,产假记“产”,婚假记“婚”,丧假记“丧”,育儿假记“育”,陪护假记“陪”,补休记“补”,旷工记“旷”,迟到记“迟”,早退记“退”,流产假记“流”,哺乳假记“哺”,节育假记“节”,父母护理假记“护”,其他记“其他”,省内工地记“工”,省外工地记“外”,出差需在备注栏备注清楚出差地点。", false);
|
||||
writer.merge(rowNum + listData.size() + 1, rowNum + listData.size() + 1, 1, 2 + days.size(),
|
||||
"2.员工有关请假凭证,记录清楚准确,与本表于次月3日前一并报人力资源管理部门(专业分公司报送时间为30日前)。", false);
|
||||
writer.autoSizeColumn(3);
|
||||
|
|
@ -543,7 +543,7 @@ public class ExportFileController {
|
|||
headers.put("9", "打卡地异常");
|
||||
//工作外出单独一个,序号不占用考勤状态
|
||||
headers.put("99", "工作外出");
|
||||
Map<String, String> attStatus = getStringStringMap();
|
||||
Map<Long, String> attStatus = getStringStringMap();
|
||||
if (StringHelper.isNotEmpty(bean.getStartDate()) && StringHelper.isNotEmpty(bean.getEndDate())) {
|
||||
AttDataDetailsBean dayTable = new AttDataDetailsBean();
|
||||
dayTable.setStartDate(bean.getStartDate());
|
||||
|
|
@ -583,10 +583,10 @@ public class ExportFileController {
|
|||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("考勤日期", list.get(i).getAttCurrentDay());
|
||||
map.put("上班打卡时间", list.get(i).getToWorkAttCurrentTime());
|
||||
map.put("上班状态", attStatus.get(list.get(i).getToWorkAttStatus()));
|
||||
map.put("上班状态", attStatus.get(Long.parseLong(list.get(i).getToWorkAttStatus())));
|
||||
map.put("上班打卡地址", list.get(i).getToWorkAttAddress());
|
||||
map.put("下班打卡时间", list.get(i).getOffWorkAttCurrentTime());
|
||||
map.put("下班状态", attStatus.get(list.get(i).getOffWorkAttStatus()));
|
||||
map.put("下班状态", attStatus.get(Long.parseLong(list.get(i).getOffWorkAttStatus())));
|
||||
map.put("下班打卡地址", list.get(i).getOffWorkAttAddress());
|
||||
departmentData2.add(map);
|
||||
}
|
||||
|
|
@ -604,29 +604,32 @@ public class ExportFileController {
|
|||
|
||||
}
|
||||
|
||||
private Map<String, String> getStringStringMap() {
|
||||
Map<String, String> attStatus = new HashMap<>();
|
||||
attStatus.put("1", "正常");
|
||||
attStatus.put("2", "迟到");
|
||||
attStatus.put("3", "旷工");
|
||||
attStatus.put("4", "早退");
|
||||
attStatus.put("5", "轮休");
|
||||
attStatus.put("6", "请假");
|
||||
attStatus.put("7", "外出");
|
||||
attStatus.put("8", "出入异常");
|
||||
attStatus.put("9", "打卡地异常");
|
||||
attStatus.put("10", "出差");
|
||||
attStatus.put("11", "法定节假日");
|
||||
attStatus.put("12", "年休假");
|
||||
attStatus.put("13", "探亲假");
|
||||
attStatus.put("14", "事假");
|
||||
attStatus.put("15", "病假");
|
||||
attStatus.put("16", "产假");
|
||||
attStatus.put("17", "婚假");
|
||||
attStatus.put("18", "丧假");
|
||||
attStatus.put("19", "育儿假");
|
||||
attStatus.put("20", "陪护假");
|
||||
return attStatus;
|
||||
private Map<Long, String> getStringStringMap() {
|
||||
// Map<String, String> attStatus = new HashMap<>();
|
||||
//
|
||||
// attStatus.put("1", "正常");
|
||||
// attStatus.put("2", "迟到");
|
||||
// attStatus.put("3", "旷工");
|
||||
// attStatus.put("4", "早退");
|
||||
// attStatus.put("5", "轮休");
|
||||
// attStatus.put("6", "请假");
|
||||
// attStatus.put("7", "外出");
|
||||
// attStatus.put("8", "出入异常");
|
||||
// attStatus.put("9", "打卡地异常");
|
||||
// attStatus.put("10", "出差");
|
||||
// attStatus.put("11", "法定节假日");
|
||||
// attStatus.put("12", "年休假");
|
||||
// attStatus.put("13", "探亲假");
|
||||
// attStatus.put("14", "事假");
|
||||
// attStatus.put("15", "病假");
|
||||
// attStatus.put("16", "产假");
|
||||
// attStatus.put("17", "婚假");
|
||||
// attStatus.put("18", "丧假");
|
||||
// attStatus.put("19", "育儿假");
|
||||
// attStatus.put("20", "陪护假");
|
||||
List<MapVo> arrayList = attendanceDetailsService.getAttStatusList();
|
||||
return arrayList.stream()
|
||||
.collect(Collectors.toMap(MapVo::getId, MapVo::getName, (existing, replacement) -> existing));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -681,7 +684,7 @@ public class ExportFileController {
|
|||
map.put("序号", i + 1);
|
||||
map.put("姓名", attDayReportList.get(i).getUserName());
|
||||
map.put("所属部门", attDayReportList.get(i).getOrgName());
|
||||
map.put("考勤月", attDayReportList.get(i).getMonth());
|
||||
map.put("考勤月", title);
|
||||
map.put("应考勤天数", attDayReportList.get(i).getRequiredDays());
|
||||
map.put("正常打卡天数", attDayReportList.get(i).getNormalNum());
|
||||
map.put("迟到天数", attDayReportList.get(i).getLateNum());
|
||||
|
|
@ -709,12 +712,13 @@ public class ExportFileController {
|
|||
headers.put("9", "打卡地异常");
|
||||
headers.put("10", "出差详情");
|
||||
headers.put("99", "工作外出");
|
||||
Map<String, String> attStatus = getStringStringMap();
|
||||
Map<Long, String> attStatus = getStringStringMap();
|
||||
if (StringHelper.isNotEmpty(bean.getMonth())) {
|
||||
List<String> monthFirstAndLast = getMonthFirstAndLast(bean.getMonth());
|
||||
AttDetailBean dayTable = new AttDetailBean();
|
||||
dayTable.setStartDate(monthFirstAndLast.get(0));
|
||||
dayTable.setEndDate(monthFirstAndLast.get(1));
|
||||
dayTable.setName(bean.getUserName());
|
||||
if (bean.getOrgId() != null) {
|
||||
dayTable.setOrgId(String.valueOf(bean.getOrgId()));
|
||||
}else{
|
||||
|
|
@ -769,10 +773,10 @@ public class ExportFileController {
|
|||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("考勤日期", list.get(i).getAttCurrent());
|
||||
map.put("上班打卡时间", list.get(i).getGoWorkTime());
|
||||
map.put("上班状态", attStatus.get(String.valueOf(list.get(i).getGoWorkStatus())));
|
||||
map.put("上班状态", attStatus.get(Long.parseLong(String.valueOf(list.get(i).getGoWorkStatus()))));
|
||||
map.put("上班打卡地址", list.get(i).getGoWorkAddress());
|
||||
map.put("下班打卡时间", list.get(i).getOffWorkTime());
|
||||
map.put("下班状态", attStatus.get(String.valueOf(list.get(i).getOffWorkStatus())));
|
||||
map.put("下班状态", attStatus.get(Long.parseLong(String.valueOf(list.get(i).getOffWorkStatus()))));
|
||||
map.put("下班打卡地址", list.get(i).getOffWorkAddress());
|
||||
departmentData2.add(map);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
<insert id="insertAttMonthReport">
|
||||
<foreach collection="list" item="params" separator=";">
|
||||
replace into att_month_report(user_id, name, org_id, org_name, att_current_month,
|
||||
insert into att_month_report(user_id, name, org_id, org_name, att_current_month,
|
||||
required_days, normal_num, late_num, early_num, skipping_num,
|
||||
leave_num, address_error_num, ein_error_num, rest_num, out_num, business_trip_num)
|
||||
values (#{params.userId}, #{params.userName}, #{params.orgId}, #{params.orgName},
|
||||
|
|
@ -141,6 +141,11 @@
|
|||
from att_data_update
|
||||
where att_current_day = #{date};
|
||||
</delete>
|
||||
<delete id="deleteAttMonthReport">
|
||||
delete
|
||||
from att_month_report
|
||||
where att_current_month = DATE_FORMAT(#{pushDate}, '%Y-%m')
|
||||
</delete>
|
||||
|
||||
<select id="getQsyAttendances" resultType="com.bonus.system.att.entity.AttSourceDataBean">
|
||||
select name, id_number, '0' as orgId, '0' as orgName,
|
||||
|
|
@ -200,7 +205,7 @@
|
|||
</select>
|
||||
|
||||
<select id="selectAttMonthReport" resultType="com.bonus.system.att.entity.AttMonthReportBean">
|
||||
select v.org_id,
|
||||
select g.org_id,
|
||||
v.user_id,
|
||||
su.user_name,
|
||||
so.org_name,
|
||||
|
|
@ -222,9 +227,9 @@
|
|||
IFNULL( sum( IF ( toWorkAttStatus = 10, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 10, 0.5, 0 )), 0 ) AS businessTripNum
|
||||
from v_att_update_data v
|
||||
left join sys_user su on su.user_id = v.user_id
|
||||
left join sys_organization so on so.id = v.org_id
|
||||
left join att_setting_history g
|
||||
on g.user_id = v.user_id and g.current_day = CURRENT_DATE()
|
||||
on g.user_id = v.user_id and g.current_day = #{attRuleDate}
|
||||
left join sys_organization so on so.id = g.org_id
|
||||
where DATE_FORMAT(att_current_day, '%Y-%m') = DATE_FORMAT(#{pushDate}, '%Y-%m')
|
||||
and g.group_id is not null
|
||||
GROUP BY DATE_FORMAT(att_current_day, '%Y-%m'), v.user_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue