wisdomisite-java/src/main/java/com/zhgd/xmgl/async/AsyncAttendance.java

84 lines
3.2 KiB
Java
Raw Normal View History

2023-02-16 15:28:15 +08:00
package com.zhgd.xmgl.async;
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
2025-06-25 10:22:40 +08:00
import com.zhgd.xmgl.modules.worker.service.IWorkerDailyAttendanceStatisticsV2Service;
2023-02-16 15:28:15 +08:00
import com.zhgd.xmgl.modules.worker.service.IWorkerMonthAttendanceStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
2025-06-25 10:22:40 +08:00
import org.springframework.context.annotation.Lazy;
2023-02-16 15:28:15 +08:00
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
/**
* @program: wisdomSite
* @description: 考勤异步任务
* @author: Mr.Peng
* @create: 2021-06-07 14:33
**/
@Slf4j
@Component
public class AsyncAttendance {
@Autowired
private IWorkerMonthAttendanceStatisticsService workerMonthAttendanceStatisticsService;
@Autowired
private INoticeService noticeService;
2025-06-25 10:22:40 +08:00
@Lazy
@Autowired
private IWorkerDailyAttendanceStatisticsV2Service workerDailyAttendanceStatisticsV2Service;
2023-02-16 15:28:15 +08:00
@Async("countAttendanceExecutor")
2025-06-25 10:22:40 +08:00
public void getAfreshMonthAttendance(Map<String, Object> map) {
2023-02-16 15:28:15 +08:00
try {
//重新统计考勤
workerMonthAttendanceStatisticsService.getAfreshMonthAttendanceStatistics(map);
java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Notice notice = new Notice();
2025-06-25 10:22:40 +08:00
notice.setAccountId(MapUtils.getLong(map, "userId"));
notice.setMsg(MapUtils.getString(map, "startTime") + "" + MapUtils.getString(map, "endTime") + "的考勤已重新统计");
2023-02-16 15:28:15 +08:00
notice.setTitle("考勤统计提醒");
notice.setSendTime(format1.format(new Date()));
notice.setType("1");
2025-06-25 10:22:40 +08:00
noticeService.addNotice(notice, true);
2023-02-16 15:28:15 +08:00
log.info("--------------------------------重新统计考勤执行完成-------------------------------");
2025-06-25 10:22:40 +08:00
} catch (Exception e) {
2024-04-14 21:05:01 +08:00
log.error("error", e);
2023-02-16 15:28:15 +08:00
}
}
2025-06-25 10:22:40 +08:00
/**
* 重新计算考勤v2
*
* @param map
*/
@Async("countAttendanceExecutor")
public void recalculateAttendanceV2(Map<String, Object> map) {
try {
//重新统计考勤
workerDailyAttendanceStatisticsV2Service.recalculateAttendanceV2(map);
Long userId = MapUtils.getLong(map, "userId");
if (userId != null) {
java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Notice notice = new Notice();
notice.setAccountId(userId);
notice.setMsg(MapUtils.getString(map, "startTime") + "" + MapUtils.getString(map, "endTime") + "的考勤已重新统计");
notice.setTitle("考勤统计提醒");
notice.setSendTime(format1.format(new Date()));
notice.setType("1");
noticeService.addNotice(notice, true);
}
log.info("--------------------------------重新统计考勤执行完成-------------------------------");
} catch (Exception e) {
log.error("error", e);
}
2023-02-16 15:28:15 +08:00
2025-06-25 10:22:40 +08:00
}
2023-02-16 15:28:15 +08:00
}