|
|
@ -1,111 +1,111 @@ |
|
|
|
//package com.acupuncture.web.controller.web;
|
|
|
|
//
|
|
|
|
//import cn.hutool.core.bean.BeanUtil;
|
|
|
|
//import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
//import cn.hutool.core.date.DateUtil;
|
|
|
|
//import cn.hutool.core.util.IdUtil;
|
|
|
|
//import com.acupuncture.common.annotation.Anonymous;
|
|
|
|
//import com.acupuncture.common.core.redis.RedisCache;
|
|
|
|
//import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder;
|
|
|
|
//import com.acupuncture.system.domain.dto.FmsFollowupDto;
|
|
|
|
//import com.acupuncture.system.domain.po.FmsFollowupTask;
|
|
|
|
//import com.acupuncture.system.domain.po.FmsFollowupTaskExample;
|
|
|
|
//import com.acupuncture.system.domain.po.FmsPatientQueueRelation;
|
|
|
|
//import com.acupuncture.system.domain.vo.FmsFollowupVo;
|
|
|
|
//import com.acupuncture.system.domain.vo.UmsDataSourceVo;
|
|
|
|
//import com.acupuncture.system.persist.dao.FmsFollowupDao;
|
|
|
|
//import com.acupuncture.system.persist.dao.UmsDataSourceDao;
|
|
|
|
//import com.acupuncture.system.persist.mapper.FmsFollowupTaskMapper;
|
|
|
|
//import com.acupuncture.system.persist.mapper.FmsPatientQueueRelationMapper;
|
|
|
|
//import com.acupuncture.system.service.FmsFollowupQueueService;
|
|
|
|
//import com.acupuncture.system.service.FmsFollowupService;
|
|
|
|
//import io.swagger.annotations.Api;
|
|
|
|
//import io.swagger.annotations.ApiOperation;
|
|
|
|
//import lombok.Data;
|
|
|
|
//import lombok.extern.slf4j.Slf4j;
|
|
|
|
//import org.apache.catalina.connector.Response;
|
|
|
|
//import org.quartz.TriggerUtils;
|
|
|
|
//import org.quartz.impl.triggers.CronTriggerImpl;
|
|
|
|
//import org.quartz.spi.OperableTrigger;
|
|
|
|
//import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
//import org.springframework.transaction.annotation.Propagation;
|
|
|
|
//import org.springframework.transaction.annotation.Transactional;
|
|
|
|
//import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
//import org.springframework.web.bind.annotation.RestController;
|
|
|
|
//
|
|
|
|
//import javax.annotation.Resource;
|
|
|
|
//import javax.servlet.http.HttpServletRequest;
|
|
|
|
//import javax.servlet.http.HttpServletResponse;
|
|
|
|
//import java.util.*;
|
|
|
|
//import java.util.regex.Matcher;
|
|
|
|
//import java.util.regex.Pattern;
|
|
|
|
//
|
|
|
|
///**
|
|
|
|
// * @Author zzc
|
|
|
|
// * @Package com.acupuncture.web.controller.web
|
|
|
|
// * @Date 2025/2/13 8:50
|
|
|
|
// * @description:
|
|
|
|
// */
|
|
|
|
//@Slf4j
|
|
|
|
//@Api(tags = "定时任务相关")
|
|
|
|
//@RestController
|
|
|
|
//@RequestMapping("/task")
|
|
|
|
//@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
//public class TaskController {
|
|
|
|
//
|
|
|
|
// @Resource
|
|
|
|
// private FmsFollowupDao fmsFollowupDao;
|
|
|
|
// @Resource
|
|
|
|
// private FmsFollowupService fmsFollowupService;
|
|
|
|
// @Resource
|
|
|
|
// private FmsFollowupTaskMapper fmsFollowupTaskMapper;
|
|
|
|
// @Resource
|
|
|
|
// private UmsDataSourceDao umsDataSourceDao;
|
|
|
|
// @Resource
|
|
|
|
// private RedisCache redisCache;
|
|
|
|
// @Resource
|
|
|
|
// private FmsFollowupQueueService fmsFollowupQueueService;
|
|
|
|
//
|
|
|
|
// @ApiOperation("定时任务添加随访工单")
|
|
|
|
// @PostMapping("/task")
|
|
|
|
// @Scheduled(fixedDelay = 10000)
|
|
|
|
// @Anonymous
|
|
|
|
// public void task() {
|
|
|
|
// // TODO 生成工单第一次生成之后2周的,往后只生成之后一周。第一次随访时间: ( 患者的出院时间 - 7 + 轮次时间) 到 (患者的出院时间 + 7 + 轮次时间 )
|
|
|
|
// //查询租户,根据租户循环切换数据源,定时处理所有医院的随访工单
|
|
|
|
//// UmsDataSourceVo.Result result1 = new UmsDataSourceVo.Result();
|
|
|
|
//// result1.setDataSourceKey("MASTER");
|
|
|
|
//// changeDataSource(result1);
|
|
|
|
//// List<UmsDataSourceVo.Result> query = umsDataSourceDao.query(null);
|
|
|
|
//// if (CollectionUtil.isEmpty(query)) {
|
|
|
|
//// return;
|
|
|
|
//// }
|
|
|
|
// //查询公共队列
|
|
|
|
// List<Object> queueResults = redisCache.getCacheList("common_followup_queue");
|
|
|
|
// List<FmsFollowupVo.FollowupQueueVO> followupQueueVOS = new ArrayList<>();
|
|
|
|
// if (CollectionUtil.isEmpty(queueResults)) {
|
|
|
|
//
|
|
|
|
// followupQueueVOS = fmsFollowupQueueService.queryCommonQueue(null);
|
|
|
|
package com.acupuncture.web.task; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.acupuncture.common.annotation.Anonymous; |
|
|
|
import com.acupuncture.common.core.redis.RedisCache; |
|
|
|
import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; |
|
|
|
import com.acupuncture.system.domain.dto.FmsFollowupDto; |
|
|
|
import com.acupuncture.system.domain.po.FmsFollowupTask; |
|
|
|
import com.acupuncture.system.domain.po.FmsFollowupTaskExample; |
|
|
|
import com.acupuncture.system.domain.po.FmsPatientQueueRelation; |
|
|
|
import com.acupuncture.system.domain.vo.FmsFollowupVo; |
|
|
|
import com.acupuncture.system.domain.vo.UmsDataSourceVo; |
|
|
|
import com.acupuncture.system.persist.dao.FmsFollowupDao; |
|
|
|
import com.acupuncture.system.persist.dao.UmsDataSourceDao; |
|
|
|
import com.acupuncture.system.persist.mapper.FmsFollowupTaskMapper; |
|
|
|
import com.acupuncture.system.persist.mapper.FmsPatientQueueRelationMapper; |
|
|
|
import com.acupuncture.system.service.FmsFollowupQueueService; |
|
|
|
import com.acupuncture.system.service.FmsFollowupService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.quartz.TriggerUtils; |
|
|
|
import org.quartz.impl.triggers.CronTriggerImpl; |
|
|
|
import org.quartz.spi.OperableTrigger; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author zzc |
|
|
|
* @Package com.acupuncture.web.controller.web |
|
|
|
* @Date 2025/2/13 8:50 |
|
|
|
* @description: |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Api(tags = "定时任务相关") |
|
|
|
@RestController |
|
|
|
@RequestMapping("/task") |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
public class TaskController { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private FmsFollowupDao fmsFollowupDao; |
|
|
|
@Resource |
|
|
|
private FmsFollowupService fmsFollowupService; |
|
|
|
@Resource |
|
|
|
private FmsFollowupTaskMapper fmsFollowupTaskMapper; |
|
|
|
@Resource |
|
|
|
private UmsDataSourceDao umsDataSourceDao; |
|
|
|
@Resource |
|
|
|
private FmsPatientQueueRelationMapper fmsPatientQueueRelationMapper; |
|
|
|
@Resource |
|
|
|
private RedisCache redisCache; |
|
|
|
@Resource |
|
|
|
private FmsFollowupQueueService fmsFollowupQueueService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理业务 |
|
|
|
* |
|
|
|
* @param tenandId 租户用户 |
|
|
|
* @param commonQueue 公共队列 |
|
|
|
*/ |
|
|
|
public void doTask(Long tenandId, List<FmsFollowupVo.FollowupQueueVO> commonQueue) { |
|
|
|
//查询从库队列
|
|
|
|
//1. 查询队列
|
|
|
|
List<FmsFollowupVo.FollowupQueueVO> slavelQueueList = fmsFollowupDao.selectQueueList(null, null, null, null); |
|
|
|
|
|
|
|
//合并公共队列和从库的队列
|
|
|
|
slavelQueueList.addAll(commonQueue); |
|
|
|
|
|
|
|
//查询每个队列的对象
|
|
|
|
for (FmsFollowupVo.FollowupQueueVO queue : slavelQueueList) { |
|
|
|
FmsFollowupDto.FollowupPatientQueryDTO followupPatientQueryDTO = new FmsFollowupDto.FollowupPatientQueryDTO(); |
|
|
|
followupPatientQueryDTO.setQueueId(queue.getId()); |
|
|
|
followupPatientQueryDTO.setTenantId(queue.getTenantId()); |
|
|
|
List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupService.queryPatient(followupPatientQueryDTO); |
|
|
|
log.info("查询每个队列的对象:{}", patientList); |
|
|
|
} |
|
|
|
|
|
|
|
//定时任务
|
|
|
|
|
|
|
|
// //循环租户
|
|
|
|
// for (UmsDataSourceVo.Result tenant : tenantList) {
|
|
|
|
// if ("MASTER".equals(tenant.getDataSourceKey())) {
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
//// List<FmsFollowupVo.FollowupQueueVO> queueResults = fmsFollowupDao.queryCommonQueue(null);
|
|
|
|
// //切换数据源
|
|
|
|
//// for (UmsDataSourceVo.Result result : query) {
|
|
|
|
//// if ("MASTER".equals(result.getDataSourceKey()) || "PROD_YY".equals(result.getDataSourceKey())) {
|
|
|
|
//// continue;
|
|
|
|
//// }
|
|
|
|
//// changeDataSource(result);
|
|
|
|
// changeDataSource(tenant);
|
|
|
|
// {
|
|
|
|
// //获取随访患者列表,根据患者出院日时间和队列添加工单
|
|
|
|
// //1. 查询队列
|
|
|
|
// List<FmsFollowupVo.FollowupQueueVO> queueList = fmsFollowupDao.selectQueueList(null, null, null, null);
|
|
|
|
//
|
|
|
|
// if (CollectionUtil.isEmpty(queueList)) {
|
|
|
|
// if (CollectionUtil.isEmpty(queueResults)) {
|
|
|
|
// queueList = followupQueueVOS;
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// if (CollectionUtil.isEmpty(queueResults)) {
|
|
|
|
// if (CollectionUtil.isEmpty(followupQueueVOS)) {
|
|
|
|
// queueList.addAll(followupQueueVOS);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
@ -117,8 +117,9 @@ |
|
|
|
// FmsFollowupDto.FollowupPatientQueryDTO followupPatientQueryDTO = new FmsFollowupDto.FollowupPatientQueryDTO();
|
|
|
|
// followupPatientQueryDTO.setQueueId(followupQueueVO.getId());
|
|
|
|
// followupPatientQueryDTO.setTenantId(followupQueueVO.getTenantId());
|
|
|
|
//// changeDataSource(result);
|
|
|
|
// List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupService.queryTaskPatient(followupPatientQueryDTO);
|
|
|
|
// changeDataSource(result);
|
|
|
|
//
|
|
|
|
// List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupService.queryPatient(followupPatientQueryDTO);
|
|
|
|
//// List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupDao.queryPatient(followupQueueVO.getId(), null, null);
|
|
|
|
// if (CollectionUtil.isEmpty(patientList)) {
|
|
|
|
// continue;
|
|
|
@ -149,6 +150,7 @@ |
|
|
|
// //3. 判断随访类型
|
|
|
|
// if (followupQueueVO.getFollowupType() == 0) {
|
|
|
|
// //单次
|
|
|
|
//
|
|
|
|
// //判断是否已有该次随访
|
|
|
|
// FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample();
|
|
|
|
// fmsFollowupTaskExample.createCriteria().andTimesEqualTo(1).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId());
|
|
|
@ -196,7 +198,7 @@ |
|
|
|
// fmsFollowupTask.setEndTime(instance1.getTime());
|
|
|
|
// fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge());
|
|
|
|
// fmsFollowupTask.setFollowupTime(dateList.get(0));
|
|
|
|
//// changeDataSource(result);
|
|
|
|
// changeDataSource(result);
|
|
|
|
// fmsFollowupTaskMapper.insertSelective(fmsFollowupTask);
|
|
|
|
//
|
|
|
|
// } else {
|
|
|
@ -247,97 +249,117 @@ |
|
|
|
// instance.add(Calendar.DATE, followWindowAdys / 2);
|
|
|
|
//
|
|
|
|
// fmsFollowupTask.setEndTime(instance.getTime());
|
|
|
|
//// changeDataSource(result);
|
|
|
|
// changeDataSource(result);
|
|
|
|
// fmsFollowupTask.setPatientId(followupPatient.getId());
|
|
|
|
// fmsFollowupTaskMapper.insertSelective(fmsFollowupTask);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// private static void changeDataSource(UmsDataSourceVo.Result result) {
|
|
|
|
// try {
|
|
|
|
// DynamicDataSourceContextHolder.setDataSourceType(result.getDataSourceKey());
|
|
|
|
// } finally {
|
|
|
|
// DynamicDataSourceContextHolder.clearDataSourceType();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// public String getName(String url) {
|
|
|
|
// Pattern pattern = Pattern.compile("jdbc:mysql://[^/]+/([^?]+)");
|
|
|
|
// Matcher matcher = pattern.matcher(url);
|
|
|
|
// if (matcher.find()) {
|
|
|
|
// String dbName = matcher.group(1); // 输出 acupuncture_yfyy
|
|
|
|
// System.out.println("数据库名称: " + dbName);
|
|
|
|
// return dbName;
|
|
|
|
// }
|
|
|
|
// return "";
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * 法用于计算在指定时间范围内触发器的触发时间点。具体步骤如下:
|
|
|
|
// * 初始化一个空列表 lst 存储触发时间点。
|
|
|
|
// * 克隆传入的触发器 trigg,并检查其下一个触发时间是否为空。如果为空,则设置开始时间和结束时间,并计算首次触发时间。
|
|
|
|
// * 使用 while 循环遍历触发器的触发时间点,直到没有更多触发时间或超出指定范围。
|
|
|
|
// * 如果触发时间在指定范围内,则将其添加到列表中,并更新触发器状态。
|
|
|
|
// *
|
|
|
|
// * @param trigg cron表达式
|
|
|
|
// * @param from 患者出院时间
|
|
|
|
// * @param to 患者出院时间 + 随访总月数
|
|
|
|
// * @return
|
|
|
|
// */
|
|
|
|
// public static List<Date> computeFireTimesBetween(OperableTrigger trigg, org.quartz.Calendar cal, Date from, Date to) {
|
|
|
|
// LinkedList<Date> lst = new LinkedList();
|
|
|
|
// OperableTrigger t = (OperableTrigger) trigg.clone();
|
|
|
|
// if (t.getNextFireTime() == null) {
|
|
|
|
// t.setStartTime(from);
|
|
|
|
// t.setEndTime(to);
|
|
|
|
// t.computeFirstFireTime(cal);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// while (true) {
|
|
|
|
// Date d = t.getNextFireTime();
|
|
|
|
// if (d == null) {
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (d.before(from)) {
|
|
|
|
// t.triggered(cal);
|
|
|
|
// } else {
|
|
|
|
// if (d.after(to)) {
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// lst.add(d);
|
|
|
|
// t.triggered(cal);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return Collections.unmodifiableList(lst);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * 返回当前时间之后的第一个date及对应顺序
|
|
|
|
// *
|
|
|
|
// * @param dateList key 为顺序,value 为时间
|
|
|
|
// * @return
|
|
|
|
// */
|
|
|
|
// public static DateComparator getDate(List<Date> dateList) {
|
|
|
|
// Date today = new Date();
|
|
|
|
// DateComparator dateComparator = new DateComparator();
|
|
|
|
// for (int i = 0; i < dateList.size(); i++) {
|
|
|
|
// Date date = dateList.get(i);
|
|
|
|
// if (date.after(today)) {
|
|
|
|
// dateComparator.setDate(date);
|
|
|
|
// dateComparator.setIndex(i + 1);
|
|
|
|
// return dateComparator;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return dateComparator;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @Data
|
|
|
|
// public static class DateComparator {
|
|
|
|
// private Date date;
|
|
|
|
// private Integer index;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("定时任务添加随访工单") |
|
|
|
@PostMapping("/task") |
|
|
|
@Scheduled(cron = "0 0 0 * * ?") |
|
|
|
@Anonymous |
|
|
|
public void task() { |
|
|
|
// TODO 生成工单第一次生成之后2周的,往后只生成之后一周。第一次随访时间: ( 患者的出院时间 - 7 + 轮次时间) 到 (患者的出院时间 + 7 + 轮次时间 )
|
|
|
|
|
|
|
|
//查询租户,根据租户循环切换数据源,定时处理所有医院的随访工单
|
|
|
|
List<UmsDataSourceVo.Result> tenantList = umsDataSourceDao.query(null); |
|
|
|
if (CollectionUtil.isEmpty(tenantList)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
//过滤掉没有数据源的租户
|
|
|
|
tenantList = tenantList.stream().filter(result -> StrUtil.isNotEmpty(result.getDataSourceKey())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
//查询公共队列
|
|
|
|
List<FmsFollowupVo.FollowupQueueVO> followupQueueVOS = fmsFollowupQueueService.queryCommonQueue(null); |
|
|
|
|
|
|
|
//循环租户
|
|
|
|
for (UmsDataSourceVo.Result tenant : tenantList) { |
|
|
|
//切换数据源
|
|
|
|
DynamicDataSourceContextHolder.setDataSourceType(tenant.getDataSourceKey()); |
|
|
|
|
|
|
|
//处理从库业务
|
|
|
|
doTask(tenant.getTenantId(), followupQueueVOS); |
|
|
|
|
|
|
|
//销毁数据源
|
|
|
|
DynamicDataSourceContextHolder.clearDataSourceType(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private static void changeDataSource(UmsDataSourceVo.Result result) { |
|
|
|
DynamicDataSourceContextHolder.setDataSourceType(result.getDataSourceKey()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 法用于计算在指定时间范围内触发器的触发时间点。具体步骤如下: |
|
|
|
* 初始化一个空列表 lst 存储触发时间点。 |
|
|
|
* 克隆传入的触发器 trigg,并检查其下一个触发时间是否为空。如果为空,则设置开始时间和结束时间,并计算首次触发时间。 |
|
|
|
* 使用 while 循环遍历触发器的触发时间点,直到没有更多触发时间或超出指定范围。 |
|
|
|
* 如果触发时间在指定范围内,则将其添加到列表中,并更新触发器状态。 |
|
|
|
* |
|
|
|
* @param trigg cron表达式 |
|
|
|
* @param from 患者出院时间 |
|
|
|
* @param to 患者出院时间 + 随访总月数 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static List<Date> computeFireTimesBetween(OperableTrigger trigg, org.quartz.Calendar cal, Date from, Date to) { |
|
|
|
LinkedList<Date> lst = new LinkedList(); |
|
|
|
OperableTrigger t = (OperableTrigger) trigg.clone(); |
|
|
|
if (t.getNextFireTime() == null) { |
|
|
|
t.setStartTime(from); |
|
|
|
t.setEndTime(to); |
|
|
|
t.computeFirstFireTime(cal); |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
Date d = t.getNextFireTime(); |
|
|
|
if (d == null) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (d.before(from)) { |
|
|
|
t.triggered(cal); |
|
|
|
} else { |
|
|
|
if (d.after(to)) { |
|
|
|
break; |
|
|
|
} |
|
|
|
lst.add(d); |
|
|
|
t.triggered(cal); |
|
|
|
} |
|
|
|
} |
|
|
|
return Collections.unmodifiableList(lst); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 返回当前时间之后的第一个date及对应顺序 |
|
|
|
* |
|
|
|
* @param dateList key 为顺序,value 为时间 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static DateComparator getDate(List<Date> dateList) { |
|
|
|
Date today = new Date(); |
|
|
|
DateComparator dateComparator = new DateComparator(); |
|
|
|
for (int i = 0; i < dateList.size(); i++) { |
|
|
|
Date date = dateList.get(i); |
|
|
|
if (date.after(today)) { |
|
|
|
dateComparator.setDate(date); |
|
|
|
dateComparator.setIndex(i + 1); |
|
|
|
return dateComparator; |
|
|
|
} |
|
|
|
} |
|
|
|
return dateComparator; |
|
|
|
} |
|
|
|
|
|
|
|
@Data |
|
|
|
public static class DateComparator { |
|
|
|
private Date date; |
|
|
|
private Integer index; |
|
|
|
} |
|
|
|
} |
|
|
|