Files
platform/ruoyi-system/src/main/java/com/ruoyi/task/BusinessTask.java

466 lines
18 KiB
Java
Raw Normal View History

2025-02-24 19:13:17 +08:00
package com.ruoyi.task;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Console;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
2025-03-31 11:26:37 +08:00
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
2025-02-24 19:13:17 +08:00
import com.ruoyi.bgt.domain.BgtProjectRecruit;
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
2025-03-21 16:49:51 +08:00
import com.ruoyi.bgt.domain.dto.BgtScoreDTO;
2025-03-31 11:26:37 +08:00
import com.ruoyi.bgt.service.IBgtMessageService;
2025-02-24 19:13:17 +08:00
import com.ruoyi.bgt.service.IBgtProjectRecruitApplyService;
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
2025-05-15 11:15:01 +08:00
import com.ruoyi.common.constants.BgtMessageConstant;
2025-02-27 10:03:24 +08:00
import com.ruoyi.common.constants.WgzAndBgtMessageConstant;
2025-02-24 19:13:17 +08:00
import com.ruoyi.common.enums.RecruitApplyStatus;
2025-03-06 14:30:45 +08:00
import com.ruoyi.common.enums.RecruitStatus;
2025-02-27 10:03:24 +08:00
import com.ruoyi.fbs.domain.FbsProjectTask;
import com.ruoyi.fbs.service.IFbsProjectTaskService;
import com.ruoyi.wgz.domain.WgzAttendance;
2025-02-27 15:16:33 +08:00
import com.ruoyi.wgz.domain.WgzLeave;
2025-02-27 10:03:24 +08:00
import com.ruoyi.wgz.domain.WgzMessage;
2025-03-19 17:41:29 +08:00
import com.ruoyi.wgz.domain.WgzScoreRecord;
2025-02-27 10:03:24 +08:00
import com.ruoyi.wgz.service.IWgzAttendanceService;
2025-02-27 15:16:33 +08:00
import com.ruoyi.wgz.service.IWgzLeaveService;
2025-02-27 10:03:24 +08:00
import com.ruoyi.wgz.service.IWgzMessageService;
2025-03-19 17:41:29 +08:00
import com.ruoyi.wgz.service.IWgzScoreRecordService;
2025-02-27 10:03:24 +08:00
import lombok.extern.slf4j.Slf4j;
2025-02-24 19:13:17 +08:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
2025-03-31 11:26:37 +08:00
import org.springframework.transaction.annotation.Transactional;
2025-02-24 19:13:17 +08:00
2025-03-21 16:49:51 +08:00
import java.math.BigDecimal;
2025-02-24 19:13:17 +08:00
import java.time.LocalDate;
2025-02-27 15:16:33 +08:00
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
2025-02-27 10:03:24 +08:00
import java.util.*;
2025-02-24 19:13:17 +08:00
import java.util.stream.Collectors;
2025-02-27 10:03:24 +08:00
import static com.ruoyi.common.constants.WgzAndBgtMessageConstant.*;
2025-02-24 19:13:17 +08:00
/**
* 业务定时任务
*
2025-03-05 15:31:00 +08:00
* @author ruoyi businessTask.leave
2025-02-24 19:13:17 +08:00
*/
2025-02-27 10:03:24 +08:00
@Slf4j
2025-02-24 19:13:17 +08:00
@Component("businessTask")
public class BusinessTask
{
@Autowired
private IBgtProjectRecruitService recruitService;
@Autowired
private IBgtProjectRecruitApplyService recruitApplyService;
2025-02-27 10:03:24 +08:00
@Autowired
private IBgtProjectRecruitApplyService iBgtProjectRecruitApplyService;
@Autowired
private IFbsProjectTaskService iFbsProjectTaskService;
@Autowired
private IWgzMessageService iWgzMessageService;
@Autowired
private IWgzAttendanceService iWgzAttendanceService;
2025-02-27 15:16:33 +08:00
@Autowired
private IWgzLeaveService iWgzLeaveService;
2025-03-19 17:41:29 +08:00
@Autowired
private IWgzScoreRecordService wgzScoreRecordService;
2025-03-31 11:26:37 +08:00
@Autowired
private IBgtMessageService iBgtMessageService;
@Autowired
private IBgtProjectRecruitService iBgtProjectRecruitService;
2025-03-05 16:08:51 +08:00
public void ryNoParams()
{
Console.log("-------------------------------------------------------------------------");
Console.log("测试任务执行了");
Console.log("-------------------------------------------------------------------------");
}
2025-02-24 19:13:17 +08:00
/**
* 招工任务招工时间结束自动拒绝未选择的务工者
*/
public void recruitRefuse()
{
Console.log("开始招工拒绝任务");
2025-03-25 18:27:39 +08:00
List<String> status = Arrays.asList(RecruitApplyStatus.SIGN_UP.getCode(), RecruitApplyStatus.BGT_PASS.getCode(), RecruitApplyStatus.WGZ_PASS.getCode());
2025-02-24 19:13:17 +08:00
List<BgtProjectRecruit> recruitList = recruitService.list(Wrappers.<BgtProjectRecruit>lambdaQuery()
.lt(BgtProjectRecruit::getRecruitEndTime, LocalDate.now()));
if(CollectionUtil.isNotEmpty(recruitList)){
List<Long> recruitIds = recruitList.stream().map(BgtProjectRecruit::getId).collect(Collectors.toList());
2025-05-20 09:19:16 +08:00
recruitService.lambdaUpdate().in(BgtProjectRecruit::getId, recruitIds)
.set(BgtProjectRecruit::getStatus, RecruitStatus.OVERDUE.getCode()).update();
2025-05-15 11:15:01 +08:00
List<BgtProjectRecruitApply> list = recruitApplyService.list(Wrappers.<BgtProjectRecruitApply>lambdaQuery()
2025-02-24 19:13:17 +08:00
.in(BgtProjectRecruitApply::getRecruitId, recruitIds)
2025-05-15 11:15:01 +08:00
.in(BgtProjectRecruitApply::getStatus, status)
);
2025-05-20 09:19:16 +08:00
if(CollectionUtil.isNotEmpty(list)){
List<Long> recruitApplyIds = list.stream().map(BgtProjectRecruitApply::getId).collect(Collectors.toList());
recruitApplyService.lambdaUpdate()
.in(BgtProjectRecruitApply::getId, recruitApplyIds)
.set(BgtProjectRecruitApply::getStatus,RecruitApplyStatus.BGT_REFUSE.getCode())
.update();
//处理消息操作状态
List<Long> bgtMessageHandleIds = list.stream().filter(vo->RecruitApplyStatus.SIGN_UP.getCode().equals(vo.getStatus())).map(BgtProjectRecruitApply::getId).collect(Collectors.toList());
iBgtMessageService.operationBatch(bgtMessageHandleIds,SqlHelper.table(BgtProjectRecruitApply.class).getTableName(), BgtMessageConstant.BGT_LARGE_OTHER, BgtMessageConstant.BGT_SMALL_SIGN_UP );
List<BgtProjectRecruitApply> wgzMessageList = list.stream().filter(vo->RecruitApplyStatus.BGT_PASS.getCode().equals(vo.getStatus())).collect(Collectors.toList());
iWgzMessageService.operationBatchSignUp(wgzMessageList);
//发送消息
iWgzMessageService.operationBatchReject(list);
}
2025-02-24 19:13:17 +08:00
}
Console.log("招工拒绝任务结束,此次拒绝任务个数:"+recruitList.size());
}
2025-03-05 09:17:22 +08:00
/**
* 务工者同意并到了进场时间修改状态为进场
*/
public void entry()
{
Console.log("开始招工进场任务");
2025-03-20 16:41:38 +08:00
// recruitApplyService.lambdaUpdate()
// .le(BgtProjectRecruitApply::getEntryTime, LocalDate.now())
// .eq(BgtProjectRecruitApply::getStatus,RecruitApplyStatus.WGZ_PASS.getCode())
// .set(BgtProjectRecruitApply::getStatus,RecruitApplyStatus.BGT_REFUSE.getCode())
// .update();
2025-03-05 09:17:22 +08:00
Console.log("招工进场任务结束!");
}
2025-03-19 10:42:50 +08:00
/**
* 自动给两个月前的任务下的人员默认5分的评价
*/
public void score()
{
Console.log("开始进行务工评价任务");
//搜索时间在两个月前的已完结的任务
List<FbsProjectTask> taskList = iFbsProjectTaskService.list(Wrappers.<FbsProjectTask>lambdaQuery()
.eq(FbsProjectTask::getStatus, "2")
2025-05-28 09:36:37 +08:00
// .lt(FbsProjectTask::getTaskBeginTime, LocalDate.now().plusMonths(-2))
);
2025-03-19 10:42:50 +08:00
List<Long> taskIds = taskList.stream().map(FbsProjectTask::getId).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(taskIds)){
//任务下的招工
List<BgtProjectRecruit> recruitList = recruitService.list(Wrappers.<BgtProjectRecruit>lambdaQuery()
.in(BgtProjectRecruit::getTaskId, taskIds));
2025-03-21 16:49:51 +08:00
Map<Long, Long> map = recruitList.stream().collect(Collectors.toMap(BgtProjectRecruit::getId, BgtProjectRecruit::getUserId));
2025-03-19 10:42:50 +08:00
List<Long> recruitIds = recruitList.stream().map(BgtProjectRecruit::getId).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(recruitIds)){
//招工下的人员
List<BgtProjectRecruitApply> applyList = recruitApplyService.list(Wrappers.<BgtProjectRecruitApply>lambdaQuery()
.in(BgtProjectRecruitApply::getRecruitId, recruitIds));
//筛选已离场的
2025-05-28 09:36:37 +08:00
List<BgtProjectRecruitApply> outList = applyList.stream().filter(apply -> apply.getStatus().equals(RecruitApplyStatus.OUT_WORK.getCode()) && apply.getLeaveTime() != null).collect(Collectors.toList());
2025-03-21 16:49:51 +08:00
2025-03-19 17:41:29 +08:00
for (BgtProjectRecruitApply bgtProjectRecruitApply : outList) {
WgzScoreRecord byUserIdAndRecruitApplyId = wgzScoreRecordService.getByUserIdAndRecruitApplyId(bgtProjectRecruitApply.getUserId(), bgtProjectRecruitApply.getId());
2025-05-28 09:36:37 +08:00
//没有评分并且离场时间已经过了30天
if (byUserIdAndRecruitApplyId == null && bgtProjectRecruitApply.getLeaveTime().isBefore(LocalDate.now().plusDays(-30))) {
2025-03-21 16:49:51 +08:00
BgtScoreDTO bgtScoreDTO = new BgtScoreDTO();
bgtScoreDTO.setScore(new BigDecimal(5));
bgtScoreDTO.setRecruitId(bgtProjectRecruitApply.getRecruitId());
bgtScoreDTO.setRecruitApplyId(bgtProjectRecruitApply.getId());
bgtScoreDTO.setUserId(bgtProjectRecruitApply.getUserId());
bgtScoreDTO.setScoreBy(map.get(bgtProjectRecruitApply.getRecruitId()));
bgtScoreDTO.setContent("默认评分");
2025-04-16 17:31:18 +08:00
bgtScoreDTO.setCreateBy("系统");
bgtScoreDTO.setUpdateBy("系统");
2025-03-21 16:49:51 +08:00
iBgtProjectRecruitApplyService.score(bgtScoreDTO);
2025-03-19 17:41:29 +08:00
}
}
2025-03-19 10:42:50 +08:00
}
}
2025-03-19 17:41:29 +08:00
Console.log("务工评价任务结束!");
2025-03-19 10:42:50 +08:00
}
2025-02-27 10:03:24 +08:00
/**
* 上班缺卡
*/
public void workCardShortage(){
//1、获取所有正在进行中的任务
List<FbsProjectTask> ongoingTask = iFbsProjectTaskService.findOngoingTask();
2025-04-24 14:18:04 +08:00
if(CollectionUtil.isEmpty(ongoingTask)){
return;
}
2025-02-27 10:03:24 +08:00
//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())
2025-03-04 16:15:02 +08:00
.eq(BgtProjectRecruitApply::getStatus, "5")
2025-02-27 10:03:24 +08:00
);
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())
.setApplyKey(by.getId())
2025-02-27 10:03:24 +08:00
.setUserId(by.getUserId())
.setDailyWage(recruit.getRecruitAmount())
.setDate(now)
.setMissedIn(1)
2025-03-05 15:31:00 +08:00
.setExceptionType("3,").setUpdateBy("系统").setCreateBy("系统");
2025-02-27 10:03:24 +08:00
lists.add(attendance);
//添加消息提醒
WgzMessage wgzMessage = new WgzMessage().
setSenderType(USERTYPE_SYSTEM).
2025-03-05 16:08:51 +08:00
setRecipientType(WgzAndBgtMessageConstant.USERTYPE_WGZ).
2025-02-27 10:03:24 +08:00
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).
2025-03-05 15:31:00 +08:00
setMessageSmallType(SMALL_SYSTEM).setUpdateBy("系统").setCreateBy("系统");
2025-02-27 10:03:24 +08:00
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();
2025-04-24 14:18:04 +08:00
if(CollectionUtil.isEmpty(ongoingTask)){
return;
}
2025-02-27 10:03:24 +08:00
//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())
2025-03-04 16:15:02 +08:00
.eq(BgtProjectRecruitApply::getStatus, "5")
2025-02-27 10:03:24 +08:00
);
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)
2025-03-31 11:26:37 +08:00
.setExceptionType(one.getExceptionType()+"4,").setUpdateBy("系统").setCreateBy("系统");
2025-02-27 10:03:24 +08:00
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).
2025-03-05 15:31:00 +08:00
setMessageSmallType(SMALL_SYSTEM).setUpdateBy("系统").setCreateBy("系统");
2025-02-27 10:03:24 +08:00
messages.add(wgzMessage);
}
}
}
//4、批量添加缺卡信息
boolean b = iWgzAttendanceService.updateBatchById(lists);
if (!b){
log.error("批量修改下班缺卡消息失败!");
}
//5、批量添加缺卡消息
boolean b1 = iWgzMessageService.saveBatch(messages);
if (!b1){
log.error("批量添加下班缺卡消息失败!");
}
}
2025-02-27 15:16:33 +08:00
/**
* 请假
*/
2025-03-31 11:26:37 +08:00
@Transactional
2025-02-27 15:16:33 +08:00
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)){
2025-04-03 11:57:16 +08:00
// WgzLeave st = new WgzLeave()
// .setId(wgzLeave.getId())
// .setAuditorType("5");
wgzLeave.setAuditorType("5");
updataList.add(wgzLeave);
2025-02-27 15:16:33 +08:00
//组装请假超时的消息
WgzMessage wgzMessage = new WgzMessage().
setSenderType(USERTYPE_SYSTEM).
2025-03-05 16:08:51 +08:00
setRecipientType(WgzAndBgtMessageConstant.USERTYPE_WGZ).
2025-02-27 15:16:33 +08:00
setRecipientId(wgzLeave.getUserId()).
setHeadline(WgzAndBgtMessageConstant.wgzMessage(mp,"117")).
setSubheading(WgzAndBgtMessageConstant.wgzMessage(mp,"118")).
setMessageLargeType(LARGE_OTHER).
setMessageSmallType(SMALL_SYSTEM);
2025-04-03 11:57:16 +08:00
wgzMessage.setUpdateBy("系统").setCreateBy("系统");
2025-03-31 11:26:37 +08:00
messagesList.add(wgzMessage);
//状态超时需要把对应消息的状态变更为【不需要操作】
2025-04-03 11:47:51 +08:00
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(wgzLeave.getRecruitId());
2025-03-31 11:26:37 +08:00
iBgtMessageService.operation(
USERTYPE_WGZ,
2025-04-03 11:38:37 +08:00
wgzLeave.getUserId(),
2025-03-31 11:26:37 +08:00
USERTYPE_BGT,
recruit.getUserId(),
wgzLeave.getId(),
SqlHelper.table(WgzLeave.class).getTableName()
);
2025-02-27 15:16:33 +08:00
}
2025-03-31 11:26:37 +08:00
}
//3、发送请假超时的消息然后批量修改请假消息的状态为超时且发送超时消息
if (!updataList.isEmpty()){
iWgzLeaveService.updateBatchById(updataList);
iWgzMessageService.saveBatch(messagesList);
}
//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;
2025-02-27 15:16:33 +08:00
}
2025-03-31 11:26:37 +08:00
//查询当前人、当前项目、当前打卡时间是否存在,如若存在就跳过
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);
2025-02-27 15:16:33 +08:00
}
2025-03-31 11:26:37 +08:00
}
if (!attendanceList.isEmpty()){
iWgzAttendanceService.addAMissingCardRecord(attendanceList);
2025-02-27 15:16:33 +08:00
}
}
/**
* 获取两个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;
}
2025-02-24 19:13:17 +08:00
}