2 changed files with 62 additions and 0 deletions
@ -0,0 +1,56 @@ |
|||
package com.jwtech.quartz.task; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import com.kms.enterprise.domain.BsSgcYxjdDynamicCredit; |
|||
import com.kms.enterprise.mapper.BsSgcYxjdDynamicCreditMapper; |
|||
import com.kms.enterprise.service.BsSgcYxjdDynamicCreditService; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.time.LocalDate; |
|||
import java.time.ZoneId; |
|||
import java.time.temporal.ChronoUnit; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Component("CreditPublicityTask") |
|||
public class CreditPublicityTask { |
|||
|
|||
@Resource |
|||
private BsSgcYxjdDynamicCreditMapper bsSgcYxjdDynamicCreditMapper; |
|||
|
|||
|
|||
public void creditPublicity() { |
|||
LambdaQueryWrapper<BsSgcYxjdDynamicCredit> queryWrapper = Wrappers.lambdaQuery(BsSgcYxjdDynamicCredit.class).eq(BsSgcYxjdDynamicCredit::getStatus, "3") |
|||
.isNull(BsSgcYxjdDynamicCredit::getNoticeBeginTime); |
|||
|
|||
List<BsSgcYxjdDynamicCredit> creditList = bsSgcYxjdDynamicCreditMapper.selectList(queryWrapper); |
|||
|
|||
creditList.stream().forEach(x->x.setNoticeBeginTime(new Date())); |
|||
|
|||
LambdaQueryWrapper<BsSgcYxjdDynamicCredit> lambdaQueryWrapper = Wrappers.lambdaQuery(BsSgcYxjdDynamicCredit.class).eq(BsSgcYxjdDynamicCredit::getStatus, "3") |
|||
.isNotNull(BsSgcYxjdDynamicCredit::getNoticeBeginTime); |
|||
List<BsSgcYxjdDynamicCredit> list = bsSgcYxjdDynamicCreditMapper.selectList(lambdaQueryWrapper); |
|||
|
|||
for (BsSgcYxjdDynamicCredit credit : list) { |
|||
LocalDate now = LocalDate.now(); |
|||
Date beginTime = credit.getNoticeBeginTime(); |
|||
LocalDate targetDate = beginTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
|||
|
|||
long daysBetween = ChronoUnit.DAYS.between(now, targetDate); |
|||
|
|||
if (daysBetween >= 5) { |
|||
credit.setStatus("4"); |
|||
bsSgcYxjdDynamicCreditMapper.updateById(credit); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
} |
Loading…
Reference in new issue