84 lines
3.2 KiB
Java
84 lines
3.2 KiB
Java
package com.zhgd.xmgl.async;
|
||
|
||
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
|
||
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
|
||
import com.zhgd.xmgl.modules.worker.service.IWorkerDailyAttendanceStatisticsV2Service;
|
||
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;
|
||
import org.springframework.context.annotation.Lazy;
|
||
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;
|
||
@Lazy
|
||
@Autowired
|
||
private IWorkerDailyAttendanceStatisticsV2Service workerDailyAttendanceStatisticsV2Service;
|
||
|
||
@Async("countAttendanceExecutor")
|
||
public void getAfreshMonthAttendance(Map<String, Object> map) {
|
||
try {
|
||
//重新统计考勤
|
||
workerMonthAttendanceStatisticsService.getAfreshMonthAttendanceStatistics(map);
|
||
java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
Notice notice = new Notice();
|
||
notice.setAccountId(MapUtils.getLong(map, "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);
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 重新计算考勤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);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
}
|