|
|
@@ -1,60 +0,0 @@
|
|
|
-package com.izouma.nineth.service.scheduledTask;
|
|
|
-
|
|
|
-import com.izouma.nineth.domain.Collection;
|
|
|
-import com.izouma.nineth.repo.CollectionRepo;
|
|
|
-import io.jsonwebtoken.lang.Collections;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Configuration;
|
|
|
-import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
-import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
|
|
-import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
|
|
-
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneId;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-@Configuration
|
|
|
-@EnableScheduling
|
|
|
-public class PurchaseSubscribedTask implements SchedulingConfigurer {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private CollectionRepo collectionRepo;
|
|
|
-
|
|
|
-
|
|
|
- private List<Collection> collections = new ArrayList();
|
|
|
-
|
|
|
- @Override
|
|
|
- public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
|
|
-// taskRegistrar.addTriggerTask(() -> {
|
|
|
-// b:
|
|
|
-// if (Collections.isEmpty(collections)){
|
|
|
-// return;
|
|
|
-// }else {
|
|
|
-// for (Collection collection : collections) {
|
|
|
-// if (collection.getPurchaseTime().isBefore(LocalDateTime.now()) && collection.getPurchaseTime().isBefore(LocalDateTime.now().minusSeconds(2))){
|
|
|
-// collectionRepo.setState(collection.getId(),"PURCHASE");
|
|
|
-// collections.remove(0);
|
|
|
-// break b;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }, triggerContext -> {
|
|
|
-// if (Collections.isEmpty(collections)){
|
|
|
-// LocalDateTime startTime = LocalDateTime.now();
|
|
|
-// LocalDateTime endTime = startTime.plusMinutes(4);
|
|
|
-// List<Collection> collectionList = collectionRepo.findAllByPublishTimeLessThanEqualAndPurchaseTimeGreaterThanEqual(startTime, endTime);
|
|
|
-// if (Collections.isEmpty(collectionList)) {
|
|
|
-// return Date.from(endTime.minusSeconds(5).atZone(ZoneId.systemDefault()).toInstant());
|
|
|
-// }
|
|
|
-// collections = collectionList.stream().sorted(Comparator.comparing(Collection::getPurchaseTime)).collect(Collectors.toList());
|
|
|
-// }
|
|
|
-// return Date.from(collections.get(0).getPurchaseTime().minusSeconds(2).atZone(ZoneId.systemDefault()).toInstant());
|
|
|
-// });
|
|
|
- }
|
|
|
-}
|