Commit 57a3f1fe authored by 李灿灿's avatar 李灿灿

Merge branch 'feature-licancan' into 'develop'

Feature licancan

See merge request fangxinjiang/yifu!100
parents 62c09bbd 75b172b8
...@@ -119,6 +119,43 @@ public class LocalDateUtil { ...@@ -119,6 +119,43 @@ public class LocalDateUtil {
return flag; return flag;
} }
/**
* 定时任务判断是否过期专用方法
*
* @author licancan
* @param strDate
* @return {@link boolean}
*/
public static boolean isOverdueDate(String strDate){
boolean flag = false;
//在日期字符串非空时执行
if (!Common.isEmpty(strDate)) {
//这里需要把传进来的日期加上23:59:59,来判断是否过期
strDate = strDate + " 23:59:59";
//今日的开始时间
Date nowDate = new Date();
Date pastDate = null;
//格式化日期
SimpleDateFormat sdf = new SimpleDateFormat(NORM_DATETIME_PATTERN, Locale.CHINA);
try {
//将字符串转为日期格式,如果此处字符串为非合法日期就会抛出异常。
pastDate = sdf.parse(strDate);
//调用Date里面的after方法来做判断
flag = pastDate.after(nowDate);
if (flag) {
System.out.println("该日期晚于今日");
}else {
System.out.println("该日期早于今日");
}
} catch (ParseException e) {
e.printStackTrace();
}
}else {
System.out.println("日期参数不可为空");
}
return flag;
}
/** /**
* 比较两个时间的早晚 * 比较两个时间的早晚
* *
...@@ -300,7 +337,6 @@ public class LocalDateUtil { ...@@ -300,7 +337,6 @@ public class LocalDateUtil {
} }
public static void main(String[] args) { public static void main(String[] args) {
boolean hasOverlap = hasOverlap(parseLocalDate("2022-08-03"), parseLocalDate("2022-08-04"), parseLocalDate("2022-08-03"), parseLocalDate("2022-08-04")); System.out.println(isOverdueDate("2022-08-03"));
System.out.println(hasOverlap);
} }
} }
...@@ -94,22 +94,22 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -94,22 +94,22 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
*/ */
@Override @Override
public void updateOverdueByTask() { public void updateOverdueByTask() {
// 获取未失效的所有明细数据 // 获取未过期的所有明细数据
List<TInsuranceDetail> list = this.baseMapper.selectList(Wrappers.<TInsuranceDetail>query().lambda() List<TInsuranceDetail> list = this.baseMapper.selectList(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getIsEffect, CommonConstants.ZERO_INT) .eq(TInsuranceDetail::getIsOverdue, CommonConstants.ZERO_INT)
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT) .eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
); );
if (CollectionUtils.isNotEmpty(list)){ if (CollectionUtils.isNotEmpty(list)){
log.info("定时任务扫描到的有效数据是:{}条",list.size()); log.info("定时任务扫描到的未过期数据是:{}条",list.size());
list.stream().forEach(e -> { list.stream().forEach(e -> {
if (!LocalDateUtil.isFutureDate(e.getPolicyEnd().toString())){ if (!LocalDateUtil.isOverdueDate(e.getPolicyEnd().toString())){
e.setIsEffect(CommonConstants.ONE_INT); e.setIsOverdue(CommonConstants.ONE_INT);
e.setUpdateTime(LocalDateTime.now()); e.setUpdateTime(LocalDateTime.now());
} }
}); });
List<TInsuranceDetail> collect = list.stream().filter(e -> e.getIsEffect() == CommonConstants.ONE_INT).collect(Collectors.toList()); List<TInsuranceDetail> collect = list.stream().filter(e -> e.getIsOverdue() == CommonConstants.ONE_INT).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)){ if (CollectionUtils.isNotEmpty(collect)){
log.info("定时任务扫描到的已失效数据是:{}条",collect.size()); log.info("定时任务扫描到的已过期数据是:{}条",collect.size());
this.updateBatchById(collect); this.updateBatchById(collect);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment