上下班缺卡定时任务
This commit is contained in:
@ -3,24 +3,35 @@ package com.ruoyi.task;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
||||
import com.ruoyi.bgt.domain.BgtProjectRecruit;
|
||||
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
|
||||
import com.ruoyi.bgt.service.IBgtProjectRecruitApplyService;
|
||||
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
|
||||
import com.ruoyi.common.constants.WgzAndBgtMessageConstant;
|
||||
import com.ruoyi.common.enums.RecruitApplyStatus;
|
||||
import com.ruoyi.fbs.domain.FbsProjectTask;
|
||||
import com.ruoyi.fbs.service.IFbsProjectTaskService;
|
||||
import com.ruoyi.wgz.domain.WgzAttendance;
|
||||
import com.ruoyi.wgz.domain.WgzMessage;
|
||||
import com.ruoyi.wgz.service.IWgzAttendanceService;
|
||||
import com.ruoyi.wgz.service.IWgzMessageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ruoyi.common.constants.WgzAndBgtMessageConstant.*;
|
||||
|
||||
/**
|
||||
* 业务定时任务
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("businessTask")
|
||||
public class BusinessTask
|
||||
{
|
||||
@ -29,6 +40,19 @@ public class BusinessTask
|
||||
|
||||
@Autowired
|
||||
private IBgtProjectRecruitApplyService recruitApplyService;
|
||||
|
||||
@Autowired
|
||||
private IBgtProjectRecruitApplyService iBgtProjectRecruitApplyService;
|
||||
|
||||
@Autowired
|
||||
private IFbsProjectTaskService iFbsProjectTaskService;
|
||||
|
||||
@Autowired
|
||||
private IWgzMessageService iWgzMessageService;
|
||||
|
||||
@Autowired
|
||||
private IWgzAttendanceService iWgzAttendanceService;
|
||||
|
||||
/**
|
||||
* 招工任务招工时间结束自动拒绝未选择的务工者
|
||||
*/
|
||||
@ -49,4 +73,148 @@ public class BusinessTask
|
||||
Console.log("招工拒绝任务结束,此次拒绝任务个数:"+recruitList.size());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上班缺卡
|
||||
*/
|
||||
public void workCardShortage(){
|
||||
//1、获取所有正在进行中的任务
|
||||
List<FbsProjectTask> ongoingTask = iFbsProjectTaskService.findOngoingTask();
|
||||
//2、获取所有招工信息
|
||||
List<Long> taskIds = new ArrayList<>();
|
||||
for (FbsProjectTask fbsProjectTask : ongoingTask) {
|
||||
taskIds.add(fbsProjectTask.getId());
|
||||
}
|
||||
List<BgtProjectRecruit> applyList = recruitService.list(
|
||||
Wrappers.<BgtProjectRecruit>lambdaQuery()
|
||||
.in(BgtProjectRecruit::getTaskId, taskIds)
|
||||
);
|
||||
//3、获取每个招工下面的员工,然后判断他们是否上班缺卡
|
||||
LocalDate now = LocalDate.now();
|
||||
List<WgzAttendance> lists = new ArrayList<>();
|
||||
List<WgzMessage> messages = new ArrayList<>();
|
||||
Map<String, String> mp = new HashMap<>();
|
||||
mp.put("data",now.toString());
|
||||
for (BgtProjectRecruit recruit : applyList) {
|
||||
List<BgtProjectRecruitApply> recruitApply = iBgtProjectRecruitApplyService.list(
|
||||
Wrappers.<BgtProjectRecruitApply>lambdaQuery()
|
||||
.eq(BgtProjectRecruitApply::getRecruitId, recruit.getId())
|
||||
);
|
||||
for (BgtProjectRecruitApply by : recruitApply) {
|
||||
int count = iWgzAttendanceService.count(
|
||||
Wrappers.<WgzAttendance>lambdaQuery()
|
||||
.eq(WgzAttendance::getUserId, by.getUserId())
|
||||
.eq(WgzAttendance::getRecruitId, by.getRecruitId())
|
||||
.eq(WgzAttendance::getDate, now)
|
||||
);
|
||||
//表示有上班缺卡,添加缺卡信息
|
||||
if (count == 0) {
|
||||
//添加缺卡信息
|
||||
WgzAttendance attendance = new WgzAttendance()
|
||||
.setRecruitId(by.getRecruitId())
|
||||
.setUserId(by.getUserId())
|
||||
.setDailyWage(recruit.getRecruitAmount())
|
||||
.setDate(now)
|
||||
.setMissedIn(1)
|
||||
.setExceptionType("3,");
|
||||
lists.add(attendance);
|
||||
//添加消息提醒
|
||||
WgzMessage wgzMessage = new WgzMessage().
|
||||
setSenderType(USERTYPE_SYSTEM).
|
||||
setRecipientType(USERTYPE_WGZ).
|
||||
setRecipientId(by.getUserId()).
|
||||
setHeadline(WgzAndBgtMessageConstant.wgzMessage(mp,"113")).
|
||||
setSubheading(WgzAndBgtMessageConstant.wgzMessage(mp,"114")).
|
||||
// setTableId(apply.getId()).
|
||||
// setTableName(SqlHelper.table(BgtProjectRecruitApply.class).getTableName()).
|
||||
setMessageLargeType(LARGE_OTHER).
|
||||
setMessageSmallType(SMALL_SYSTEM);
|
||||
messages.add(wgzMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
//4、批量添加缺卡信息
|
||||
Boolean b = iWgzAttendanceService.addAMissingCardRecord(lists);
|
||||
if (!b){
|
||||
log.error("批量添加上班缺卡信息失败!");
|
||||
}
|
||||
//5、批量添加缺卡消息
|
||||
boolean b1 = iWgzMessageService.saveBatch(messages);
|
||||
if (!b1){
|
||||
log.error("批量添加上班缺卡消息失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下班缺卡
|
||||
*/
|
||||
public void missingCard(){
|
||||
//1、获取所有正在进行中的任务
|
||||
List<FbsProjectTask> ongoingTask = iFbsProjectTaskService.findOngoingTask();
|
||||
//2、获取所有招工信息
|
||||
List<Long> taskIds = new ArrayList<>();
|
||||
for (FbsProjectTask fbsProjectTask : ongoingTask) {
|
||||
taskIds.add(fbsProjectTask.getId());
|
||||
}
|
||||
List<BgtProjectRecruit> applyList = recruitService.list(
|
||||
Wrappers.<BgtProjectRecruit>lambdaQuery()
|
||||
.in(BgtProjectRecruit::getTaskId, taskIds)
|
||||
);
|
||||
//3、获取每个招工下面的员工,然后判断他们是否上班缺卡
|
||||
LocalDate now = LocalDate.now();
|
||||
List<WgzAttendance> lists = new ArrayList<>();
|
||||
List<WgzMessage> messages = new ArrayList<>();
|
||||
Map<String, String> mp = new HashMap<>();
|
||||
mp.put("data",now.toString());
|
||||
for (BgtProjectRecruit recruit : applyList) {
|
||||
List<BgtProjectRecruitApply> recruitApply = iBgtProjectRecruitApplyService.list(
|
||||
Wrappers.<BgtProjectRecruitApply>lambdaQuery()
|
||||
.eq(BgtProjectRecruitApply::getRecruitId, recruit.getId())
|
||||
);
|
||||
for (BgtProjectRecruitApply by : recruitApply) {
|
||||
WgzAttendance one = iWgzAttendanceService.getOne(
|
||||
Wrappers.<WgzAttendance>lambdaQuery()
|
||||
.eq(WgzAttendance::getUserId, by.getUserId())
|
||||
.eq(WgzAttendance::getRecruitId, by.getRecruitId())
|
||||
.eq(WgzAttendance::getDate, now)
|
||||
.isNull(WgzAttendance::getLeaveMarkId)
|
||||
.isNull(WgzAttendance::getClockOutTime)
|
||||
);
|
||||
//表示有下班缺卡,添加缺卡信息
|
||||
if (one != null) {
|
||||
//添加缺卡信息
|
||||
WgzAttendance attendance = new WgzAttendance()
|
||||
.setId(one.getId())
|
||||
.setMissedOut(1)
|
||||
.setExceptionType("4,");
|
||||
lists.add(attendance);
|
||||
//添加消息提醒
|
||||
WgzMessage wgzMessage = new WgzMessage().
|
||||
setSenderType(USERTYPE_SYSTEM).
|
||||
setRecipientType(USERTYPE_WGZ).
|
||||
setRecipientId(by.getUserId()).
|
||||
setHeadline(WgzAndBgtMessageConstant.wgzMessage(mp,"115")).
|
||||
setSubheading(WgzAndBgtMessageConstant.wgzMessage(mp,"116")).
|
||||
// setTableId(apply.getId()).
|
||||
// setTableName(SqlHelper.table(BgtProjectRecruitApply.class).getTableName()).
|
||||
setMessageLargeType(LARGE_OTHER).
|
||||
setMessageSmallType(SMALL_SYSTEM);
|
||||
messages.add(wgzMessage);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//4、批量添加缺卡信息
|
||||
boolean b = iWgzAttendanceService.updateBatchById(lists);
|
||||
if (!b){
|
||||
log.error("批量修改下班缺卡消息失败!");
|
||||
}
|
||||
//5、批量添加缺卡消息
|
||||
boolean b1 = iWgzMessageService.saveBatch(messages);
|
||||
if (!b1){
|
||||
log.error("批量添加下班缺卡消息失败!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user