wisdomisite-java/src/main/java/com/zhgd/xmgl/async/AsyncAttendance.java
2023-02-16 15:28:15 +08:00

53 lines
1.8 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.IWorkerMonthAttendanceStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
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;
@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){
e.printStackTrace();
}
}
}