完善定时请假的逻辑
This commit is contained in:
@ -51,6 +51,9 @@ public class WgzAndBgtMessageConstant {
|
|||||||
//【下班缺卡】15-16
|
//【下班缺卡】15-16
|
||||||
public static final String WGZ_SYSTEM_HEADLINE_OFFDUTY = "您在【%s】有一次下班缺卡!";
|
public static final String WGZ_SYSTEM_HEADLINE_OFFDUTY = "您在【%s】有一次下班缺卡!";
|
||||||
public static final String WGZ_SYSTEM_SUBHEADING_OFFDUTY = "您在【%s】当天有一条下班缺卡,请注意核对!";
|
public static final String WGZ_SYSTEM_SUBHEADING_OFFDUTY = "您在【%s】当天有一条下班缺卡,请注意核对!";
|
||||||
|
//【请假超时】17-18
|
||||||
|
public static final String WGZ_SYSTEM_HEADLINE_TIMEOUT = "您【%s】的请假审批已超时未审核!";
|
||||||
|
public static final String WGZ_SYSTEM_SUBHEADING_TIMEOUT = "您在【%s】的请假审批流程未走完,现已超时取消,请注意核对!";
|
||||||
/**
|
/**
|
||||||
* 务工者给包工头提示
|
* 务工者给包工头提示
|
||||||
*/
|
*/
|
||||||
@ -111,6 +114,10 @@ public class WgzAndBgtMessageConstant {
|
|||||||
return String.format(WGZ_SYSTEM_HEADLINE_OFFDUTY,mp.get("data"));
|
return String.format(WGZ_SYSTEM_HEADLINE_OFFDUTY,mp.get("data"));
|
||||||
case "116":
|
case "116":
|
||||||
return String.format(WGZ_SYSTEM_SUBHEADING_OFFDUTY, mp.get("data"));
|
return String.format(WGZ_SYSTEM_SUBHEADING_OFFDUTY, mp.get("data"));
|
||||||
|
case "117":
|
||||||
|
return String.format(WGZ_SYSTEM_HEADLINE_TIMEOUT,mp.get("data"));
|
||||||
|
case "118":
|
||||||
|
return String.format(WGZ_SYSTEM_SUBHEADING_TIMEOUT, mp.get("data"));
|
||||||
//务工者向包工头申请报名
|
//务工者向包工头申请报名
|
||||||
case "201":
|
case "201":
|
||||||
return String.format(WGZ_HEADLINE_APPLY, mp.get("userName"), mp.get("post"));
|
return String.format(WGZ_HEADLINE_APPLY, mp.get("userName"), mp.get("post"));
|
||||||
|
@ -13,14 +13,18 @@ import com.ruoyi.common.enums.RecruitApplyStatus;
|
|||||||
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;
|
||||||
|
import com.ruoyi.wgz.domain.WgzLeave;
|
||||||
import com.ruoyi.wgz.domain.WgzMessage;
|
import com.ruoyi.wgz.domain.WgzMessage;
|
||||||
import com.ruoyi.wgz.service.IWgzAttendanceService;
|
import com.ruoyi.wgz.service.IWgzAttendanceService;
|
||||||
|
import com.ruoyi.wgz.service.IWgzLeaveService;
|
||||||
import com.ruoyi.wgz.service.IWgzMessageService;
|
import com.ruoyi.wgz.service.IWgzMessageService;
|
||||||
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 java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -53,6 +57,9 @@ public class BusinessTask
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IWgzAttendanceService iWgzAttendanceService;
|
private IWgzAttendanceService iWgzAttendanceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IWgzLeaveService iWgzLeaveService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 招工任务招工时间结束自动拒绝未选择的务工者
|
* 招工任务招工时间结束自动拒绝未选择的务工者
|
||||||
*/
|
*/
|
||||||
@ -217,4 +224,115 @@ public class BusinessTask
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请假
|
||||||
|
*/
|
||||||
|
public void leave(){
|
||||||
|
List<WgzLeave> updataList = new ArrayList<>();
|
||||||
|
List<WgzAttendance> attendanceList = new ArrayList<>();
|
||||||
|
List<WgzMessage> messagesList = new ArrayList<>();
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
Map<String, String> mp = new HashMap<>();
|
||||||
|
mp.put("data",now.toString());
|
||||||
|
//1、获取所有正在审核的请假消息,如果超时就批量改变状态为请假超时
|
||||||
|
List<WgzLeave> wgzLeaveList = iWgzLeaveService.list(
|
||||||
|
Wrappers.<WgzLeave>lambdaQuery()
|
||||||
|
.in(WgzLeave::getAuditorType, new String[]{"0", "1"})
|
||||||
|
);
|
||||||
|
for (WgzLeave wgzLeave : wgzLeaveList) {
|
||||||
|
LocalDate startTime = wgzLeave.getStartTime().toLocalDate();
|
||||||
|
// startTime大于等于now,那么就修改状态为请假超时
|
||||||
|
if (startTime.isEqual(now) || startTime.isAfter(now)){
|
||||||
|
WgzLeave st = new WgzLeave()
|
||||||
|
.setId(wgzLeave.getId())
|
||||||
|
.setAuditorType("5");
|
||||||
|
updataList.add(st);
|
||||||
|
//组装请假超时的消息
|
||||||
|
WgzMessage wgzMessage = new WgzMessage().
|
||||||
|
setSenderType(USERTYPE_SYSTEM).
|
||||||
|
setRecipientType(USERTYPE_WGZ).
|
||||||
|
setRecipientId(wgzLeave.getUserId()).
|
||||||
|
setHeadline(WgzAndBgtMessageConstant.wgzMessage(mp,"117")).
|
||||||
|
setSubheading(WgzAndBgtMessageConstant.wgzMessage(mp,"118")).
|
||||||
|
setMessageLargeType(LARGE_OTHER).
|
||||||
|
setMessageSmallType(SMALL_SYSTEM);
|
||||||
|
messagesList.add(wgzMessage); }
|
||||||
|
}
|
||||||
|
if (iWgzLeaveService.updateBatchById(updataList)){
|
||||||
|
//3、发送请假超时的消息
|
||||||
|
if (!iWgzMessageService.saveBatch(messagesList)){
|
||||||
|
log.error("批量添加请假超时消息失败!");
|
||||||
|
}
|
||||||
|
//4、获取所有审批成功的请假消息,然后批量新增请假打卡数据到考勤表(如若需要日薪就需要连表查询)
|
||||||
|
List<WgzLeave> wgzLeaveListTwo = iWgzLeaveService.list(
|
||||||
|
Wrappers.<WgzLeave>lambdaQuery()
|
||||||
|
.eq(WgzLeave::getAuditorType, "2")
|
||||||
|
);
|
||||||
|
for (WgzLeave wgzLeave : wgzLeaveListTwo) {
|
||||||
|
//获取请假的具体天数(目前的请假是全天,没有分时间段)
|
||||||
|
List<LocalDate> formattedDates = getFormattedDates(wgzLeave.getStartTime(), wgzLeave.getEndTime());
|
||||||
|
//业务逻辑
|
||||||
|
for (LocalDate formattedDate : formattedDates) {
|
||||||
|
//如果formattedDate小于当前日期,就跳过
|
||||||
|
if (formattedDate.isBefore(now)){
|
||||||
|
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()).
|
||||||
|
setUserId(wgzLeave.getUserId()).
|
||||||
|
setLeaveMarkId(wgzLeave.getId()).
|
||||||
|
setDate(formattedDate).
|
||||||
|
setExceptionType("6,");
|
||||||
|
attendanceList.add(wgzAttendance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!iWgzAttendanceService.addAMissingCardRecord(attendanceList)){
|
||||||
|
log.error("批量添加上班缺卡信息失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取两个LocalDateTime的年月日
|
||||||
|
*
|
||||||
|
* 2025-02-24 17:35:20
|
||||||
|
* 2025-02-24 17:35:20
|
||||||
|
* 得到2025-02-24
|
||||||
|
* 2025-02-24 17:35:20
|
||||||
|
* 2025-02-25 17:35:20
|
||||||
|
* 得到2025-02-24 2025-02-25
|
||||||
|
*/
|
||||||
|
public static List<LocalDate> getFormattedDates(LocalDateTime dateTime1, LocalDateTime dateTime2) {
|
||||||
|
// 获取两个 LocalDateTime 对象对应的 LocalDate 对象
|
||||||
|
LocalDate localDate1 = dateTime1.toLocalDate();
|
||||||
|
LocalDate localDate2 = dateTime2.toLocalDate();
|
||||||
|
|
||||||
|
// 创建一个集合来存储不同的日期
|
||||||
|
List<LocalDate> dates = new ArrayList<>();
|
||||||
|
if (!dates.contains(localDate1)) {
|
||||||
|
dates.add(localDate1);
|
||||||
|
}
|
||||||
|
if (!dates.contains(localDate2)) {
|
||||||
|
dates.add(localDate2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义日期格式化器
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
|
||||||
|
// 将日期集合格式化为字符串并使用空格连接
|
||||||
|
return dates;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.ruoyi.wgz.bo.req;
|
|||||||
|
|
||||||
import com.ruoyi.common.bo.PageReq;
|
import com.ruoyi.common.bo.PageReq;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
@ -11,5 +12,6 @@ import lombok.experimental.Accessors;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@ApiModel("日报打卡·日报记录请求对象")
|
@ApiModel("日报打卡·日报记录请求对象")
|
||||||
public class WgzAppDailyRecordReq extends PageReq {
|
public class WgzAppDailyRecordReq extends PageReq {
|
||||||
|
@ApiModelProperty(value = "务工者Id",hidden = true)
|
||||||
|
private Long userId;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,18 @@ import java.util.Map;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@ApiModel("日报日历结构返回对象")
|
@ApiModel("日报日历结构返回对象")
|
||||||
public class WgzUserDailyCalendarRes implements Serializable {
|
public class WgzUserDailyCalendarRes implements Serializable {
|
||||||
|
@ApiModelProperty("招工主题")
|
||||||
|
private String recruitName;
|
||||||
|
|
||||||
|
@ApiModelProperty("审批人ID")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("审批人名称")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@ApiModelProperty("审批人头像")
|
||||||
|
private String avatarName;
|
||||||
|
|
||||||
@ApiModelProperty("日报日历")
|
@ApiModelProperty("日报日历")
|
||||||
private Map<String, WgzAppAttachmentAcquisitionTwo> dailyCalendar;
|
private Map<String, WgzAppAttachmentAcquisitionTwo> dailyCalendar;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public interface WgzDailyClockMapper extends BaseMapperPlus<WgzDailyClock> {
|
|||||||
* @param page 分页对象
|
* @param page 分页对象
|
||||||
* @return 分页查询结果
|
* @return 分页查询结果
|
||||||
*/
|
*/
|
||||||
Page<WgzAppUserDailyRecordRes> userDailyRecordListPage(Page<WgzAppDailyRecordReq> page);
|
Page<WgzAppUserDailyRecordRes> userDailyRecordListPage(Page<WgzAppDailyRecordReq> page, @Param("req") WgzAppDailyRecordReq req);
|
||||||
|
|
||||||
Page<BgtDailyClockListVO> appQueryPageList(@Param("page") Page<BgtDailyClockListDTO> page, @Param("dto") BgtDailyClockListDTO dto);
|
Page<BgtDailyClockListVO> appQueryPageList(@Param("page") Page<BgtDailyClockListDTO> page, @Param("dto") BgtDailyClockListDTO dto);
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,9 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IBgtProjectRecruitService iBgtProjectRecruitService;
|
private IBgtProjectRecruitService iBgtProjectRecruitService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBgtUserService iBgtUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WgzDailyClock queryById(Long id){
|
public WgzDailyClock queryById(Long id){
|
||||||
return getById(id);
|
return getById(id);
|
||||||
@ -174,7 +177,19 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return new WgzUserDailyCalendarRes().setDailyCalendar(fh);
|
//4、获取当前务工者的招工信息的主题及招工创建人的基本信息
|
||||||
|
BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(SecurityUtils.getAppUserId());
|
||||||
|
BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getId());
|
||||||
|
BgtUser one = iBgtUserService.getOne(
|
||||||
|
new LambdaQueryWrapper<BgtUser>().
|
||||||
|
eq(BgtUser::getUserId, appById.getUserId())
|
||||||
|
);
|
||||||
|
return new WgzUserDailyCalendarRes().
|
||||||
|
setDailyCalendar(fh).
|
||||||
|
setRecruitName(appById.getRecruitName()).
|
||||||
|
setUserId(one.getUserId()).
|
||||||
|
setUsername(one.getUsername()).
|
||||||
|
setAvatarName(one.getAvatarName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -195,10 +210,11 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<WgzAppUserDailyRecordRes> userDailyRecord(WgzAppDailyRecordReq req) {
|
public TableDataInfo<WgzAppUserDailyRecordRes> userDailyRecord(WgzAppDailyRecordReq req) {
|
||||||
|
req.setUserId(SecurityUtils.getAppUserId());
|
||||||
Page<WgzAppDailyRecordReq> pe = new Page<>();
|
Page<WgzAppDailyRecordReq> pe = new Page<>();
|
||||||
pe.setCurrent(req.getPageNum());
|
pe.setCurrent(req.getPageNum());
|
||||||
pe.setSize(req.getPageSize());
|
pe.setSize(req.getPageSize());
|
||||||
return PageUtils.buildDataInfo(baseMapper.userDailyRecordListPage(pe));
|
return PageUtils.buildDataInfo(baseMapper.userDailyRecordListPage(pe,req));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,9 +40,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
a.auditor_type
|
a.auditor_type
|
||||||
FROM
|
FROM
|
||||||
wgz_daily_clock a
|
wgz_daily_clock a
|
||||||
LEFT JOIN bgt_user b ON (a.user_id = b.user_id and b.del_flag = 0)
|
LEFT JOIN wgz_user b ON (a.user_id = b.user_id and b.del_flag = 0)
|
||||||
WHERE
|
WHERE
|
||||||
a.del_flag = 0
|
a.user_id = #{req.userId} and a.del_flag = 0
|
||||||
ORDER BY
|
ORDER BY
|
||||||
a.id DESC
|
a.id DESC
|
||||||
</select>
|
</select>
|
||||||
|
Reference in New Issue
Block a user