优化请假定时任务
This commit is contained in:
@ -3,14 +3,17 @@ package com.ruoyi.task;
|
|||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
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.BgtProjectRecruit;
|
||||||
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
|
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
|
||||||
import com.ruoyi.bgt.domain.dto.BgtScoreDTO;
|
import com.ruoyi.bgt.domain.dto.BgtScoreDTO;
|
||||||
|
import com.ruoyi.bgt.service.IBgtMessageService;
|
||||||
import com.ruoyi.bgt.service.IBgtProjectRecruitApplyService;
|
import com.ruoyi.bgt.service.IBgtProjectRecruitApplyService;
|
||||||
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
|
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
|
||||||
import com.ruoyi.common.constants.WgzAndBgtMessageConstant;
|
import com.ruoyi.common.constants.WgzAndBgtMessageConstant;
|
||||||
import com.ruoyi.common.enums.RecruitApplyStatus;
|
import com.ruoyi.common.enums.RecruitApplyStatus;
|
||||||
import com.ruoyi.common.enums.RecruitStatus;
|
import com.ruoyi.common.enums.RecruitStatus;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.fbs.domain.FbsProjectTask;
|
import com.ruoyi.fbs.domain.FbsProjectTask;
|
||||||
import com.ruoyi.fbs.service.IFbsProjectTaskService;
|
import com.ruoyi.fbs.service.IFbsProjectTaskService;
|
||||||
import com.ruoyi.wgz.domain.WgzAttendance;
|
import com.ruoyi.wgz.domain.WgzAttendance;
|
||||||
@ -24,6 +27,8 @@ import com.ruoyi.wgz.service.IWgzScoreRecordService;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.reactive.TransactionalOperator;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@ -67,6 +72,12 @@ public class BusinessTask
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IWgzScoreRecordService wgzScoreRecordService;
|
private IWgzScoreRecordService wgzScoreRecordService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBgtMessageService iBgtMessageService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBgtProjectRecruitService iBgtProjectRecruitService;
|
||||||
|
|
||||||
public void ryNoParams()
|
public void ryNoParams()
|
||||||
{
|
{
|
||||||
Console.log("-------------------------------------------------------------------------");
|
Console.log("-------------------------------------------------------------------------");
|
||||||
@ -272,7 +283,7 @@ public class BusinessTask
|
|||||||
WgzAttendance attendance = new WgzAttendance()
|
WgzAttendance attendance = new WgzAttendance()
|
||||||
.setId(one.getId())
|
.setId(one.getId())
|
||||||
.setMissedOut(1)
|
.setMissedOut(1)
|
||||||
.setExceptionType("4,").setUpdateBy("系统").setCreateBy("系统");
|
.setExceptionType(one.getExceptionType()+"4,").setUpdateBy("系统").setCreateBy("系统");
|
||||||
lists.add(attendance);
|
lists.add(attendance);
|
||||||
//添加消息提醒
|
//添加消息提醒
|
||||||
WgzMessage wgzMessage = new WgzMessage().
|
WgzMessage wgzMessage = new WgzMessage().
|
||||||
@ -306,7 +317,12 @@ public class BusinessTask
|
|||||||
/**
|
/**
|
||||||
* 请假
|
* 请假
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
public void leave(){
|
public void leave(){
|
||||||
|
System.out.println("????????????????");
|
||||||
|
System.out.println("????????????????");
|
||||||
|
System.out.println("????????????????");
|
||||||
|
System.out.println("????????????????");
|
||||||
List<WgzLeave> updataList = new ArrayList<>();
|
List<WgzLeave> updataList = new ArrayList<>();
|
||||||
List<WgzAttendance> attendanceList = new ArrayList<>();
|
List<WgzAttendance> attendanceList = new ArrayList<>();
|
||||||
List<WgzMessage> messagesList = new ArrayList<>();
|
List<WgzMessage> messagesList = new ArrayList<>();
|
||||||
@ -335,51 +351,61 @@ public class BusinessTask
|
|||||||
setSubheading(WgzAndBgtMessageConstant.wgzMessage(mp,"118")).
|
setSubheading(WgzAndBgtMessageConstant.wgzMessage(mp,"118")).
|
||||||
setMessageLargeType(LARGE_OTHER).
|
setMessageLargeType(LARGE_OTHER).
|
||||||
setMessageSmallType(SMALL_SYSTEM);
|
setMessageSmallType(SMALL_SYSTEM);
|
||||||
messagesList.add(wgzMessage); }
|
messagesList.add(wgzMessage);
|
||||||
|
//状态超时需要把对应消息的状态变更为【不需要操作】
|
||||||
|
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(wgzLeave.getApplyKey());
|
||||||
|
iBgtMessageService.operation(
|
||||||
|
USERTYPE_WGZ,
|
||||||
|
SecurityUtils.getAppUserId(),
|
||||||
|
USERTYPE_BGT,
|
||||||
|
recruit.getUserId(),
|
||||||
|
wgzLeave.getId(),
|
||||||
|
SqlHelper.table(WgzLeave.class).getTableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (iWgzLeaveService.updateBatchById(updataList)){
|
//3、发送请假超时的消息,然后批量修改请假消息的状态为超时且发送超时消息
|
||||||
//3、发送请假超时的消息
|
if (!updataList.isEmpty()){
|
||||||
if (!iWgzMessageService.saveBatch(messagesList)){
|
iWgzLeaveService.updateBatchById(updataList);
|
||||||
log.error("批量添加请假超时消息失败!");
|
iWgzMessageService.saveBatch(messagesList);
|
||||||
}
|
}
|
||||||
//4、获取所有审批成功的请假消息,然后批量新增请假打卡数据到考勤表(如若需要日薪就需要连表查询)
|
//4、获取所有审批成功的请假消息,然后批量新增请假打卡数据到考勤表(如若需要日薪就需要连表查询)
|
||||||
List<WgzLeave> wgzLeaveListTwo = iWgzLeaveService.list(
|
List<WgzLeave> wgzLeaveListTwo = iWgzLeaveService.list(
|
||||||
Wrappers.<WgzLeave>lambdaQuery()
|
Wrappers.<WgzLeave>lambdaQuery()
|
||||||
.eq(WgzLeave::getAuditorType, "2")
|
.eq(WgzLeave::getAuditorType, "2")
|
||||||
);
|
);
|
||||||
for (WgzLeave wgzLeave : wgzLeaveListTwo) {
|
for (WgzLeave wgzLeave : wgzLeaveListTwo) {
|
||||||
//获取请假的具体天数(目前的请假是全天,没有分时间段)
|
//获取请假的具体天数(目前的请假是全天,没有分时间段)
|
||||||
List<LocalDate> formattedDates = getFormattedDates(wgzLeave.getStartTime(), wgzLeave.getEndTime());
|
List<LocalDate> formattedDates = getFormattedDates(wgzLeave.getStartTime(), wgzLeave.getEndTime());
|
||||||
//业务逻辑
|
//业务逻辑
|
||||||
for (LocalDate formattedDate : formattedDates) {
|
for (LocalDate formattedDate : formattedDates) {
|
||||||
//如果formattedDate小于当前日期,就跳过
|
//如果formattedDate小于当前日期,就跳过
|
||||||
if (formattedDate.isBefore(now)){
|
if (formattedDate.isBefore(now)){
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
//查询当前人、当前项目、当前打卡时间是否存在,如若存在就跳过
|
|
||||||
int count = iWgzAttendanceService.count(
|
|
||||||
Wrappers.<WgzAttendance>lambdaQuery()
|
|
||||||
.eq(WgzAttendance::getUserId, wgzLeave.getUserId())
|
|
||||||
.eq(WgzAttendance::getRecruitId, wgzLeave.getRecruitId())
|
|
||||||
.eq(WgzAttendance::getDate, formattedDate)
|
|
||||||
);
|
|
||||||
if (count > 0){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//获取到请假天数
|
|
||||||
WgzAttendance wgzAttendance = new WgzAttendance().
|
|
||||||
setRecruitId(wgzLeave.getRecruitId()).
|
|
||||||
setApplyKey(wgzLeave.getApplyKey()).
|
|
||||||
setUserId(wgzLeave.getUserId()).
|
|
||||||
setLeaveMarkId(wgzLeave.getId()).
|
|
||||||
setDate(formattedDate).
|
|
||||||
setExceptionType("6,");
|
|
||||||
attendanceList.add(wgzAttendance);
|
|
||||||
}
|
}
|
||||||
|
//查询当前人、当前项目、当前打卡时间是否存在,如若存在就跳过
|
||||||
|
int count = iWgzAttendanceService.count(
|
||||||
|
Wrappers.<WgzAttendance>lambdaQuery()
|
||||||
|
.eq(WgzAttendance::getUserId, wgzLeave.getUserId())
|
||||||
|
.eq(WgzAttendance::getRecruitId, wgzLeave.getRecruitId())
|
||||||
|
.eq(WgzAttendance::getDate, formattedDate)
|
||||||
|
);
|
||||||
|
if (count > 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//获取到请假天数
|
||||||
|
WgzAttendance wgzAttendance = new WgzAttendance().
|
||||||
|
setRecruitId(wgzLeave.getRecruitId()).
|
||||||
|
setApplyKey(wgzLeave.getApplyKey()).
|
||||||
|
setUserId(wgzLeave.getUserId()).
|
||||||
|
setLeaveMarkId(wgzLeave.getId()).
|
||||||
|
setDate(formattedDate).
|
||||||
|
setExceptionType("7,").setUpdateBy("系统").setCreateBy("系统");
|
||||||
|
attendanceList.add(wgzAttendance);
|
||||||
}
|
}
|
||||||
if (!iWgzAttendanceService.addAMissingCardRecord(attendanceList)){
|
}
|
||||||
log.error("批量添加上班缺卡信息失败!");
|
if (!attendanceList.isEmpty()){
|
||||||
}
|
iWgzAttendanceService.addAMissingCardRecord(attendanceList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class WgzAppUserApplyForPayrollSettlementDetails {
|
|||||||
@ApiModelProperty("结算人")
|
@ApiModelProperty("结算人")
|
||||||
private String auditorUserName;
|
private String auditorUserName;
|
||||||
|
|
||||||
@ApiModelProperty("结算时间")
|
@ApiModelProperty("申请时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@ApiModelProperty("工资金额")
|
@ApiModelProperty("工资金额")
|
||||||
|
@ -253,11 +253,11 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl<WgzLeaveMapper, WgzLeav
|
|||||||
//状态取消成功需要把对应消息的状态变更为【不需要操作】
|
//状态取消成功需要把对应消息的状态变更为【不需要操作】
|
||||||
iBgtMessageService.operation(
|
iBgtMessageService.operation(
|
||||||
USERTYPE_WGZ,
|
USERTYPE_WGZ,
|
||||||
recruit.getUserId(),
|
|
||||||
USERTYPE_BGT,
|
|
||||||
SecurityUtils.getAppUserId(),
|
SecurityUtils.getAppUserId(),
|
||||||
|
USERTYPE_BGT,
|
||||||
|
recruit.getUserId(),
|
||||||
we.getId(),
|
we.getId(),
|
||||||
SqlHelper.table(BgtProjectRecruitApply.class).getTableName()
|
SqlHelper.table(WgzLeave.class).getTableName()
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
|
Reference in New Issue
Block a user