Subversion Repositories SmartDukaan

Rev

Rev 34927 | Rev 34941 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34927 Rev 34939
Line 55... Line 55...
55
import java.time.format.DateTimeFormatter;
55
import java.time.format.DateTimeFormatter;
56
import java.time.temporal.ChronoUnit;
56
import java.time.temporal.ChronoUnit;
57
import java.util.*;
57
import java.util.*;
58
import java.util.stream.Collectors;
58
import java.util.stream.Collectors;
59
 
59
 
-
 
60
import static java.util.stream.Collectors.toList;
-
 
61
 
60
@Component
62
@Component
61
@Transactional(rollbackFor = {Throwable.class, ProfitMandiBusinessException.class})
63
@Transactional(rollbackFor = {Throwable.class, ProfitMandiBusinessException.class})
62
public class ScheduledTasksTest {
64
public class ScheduledTasksTest {
63
 
65
 
64
    private static final Logger LOGGER = LogManager.getLogger(ScheduledTasksTest.class);
66
    private static final Logger LOGGER = LogManager.getLogger(ScheduledTasksTest.class);
Line 75... Line 77...
75
 
77
 
76
    @Autowired
78
    @Autowired
77
    SDCreditService sdCreditService;
79
    SDCreditService sdCreditService;
78
 
80
 
79
    @Autowired
81
    @Autowired
-
 
82
    SmartCartSuggestionRepository smartCartSuggestionRepository;
-
 
83
 
-
 
84
    @Autowired
80
    UserRepository userRepository;
85
    UserRepository userRepository;
81
 
86
 
82
    @Autowired
87
    @Autowired
83
    CsService csService;
88
    CsService csService;
84
 
89
 
Line 159... Line 164...
159
 
164
 
160
    @Autowired
165
    @Autowired
161
    UserWalletHistoryRepository userWalletHistoryRepository;
166
    UserWalletHistoryRepository userWalletHistoryRepository;
162
 
167
 
163
    public void test() throws Exception {
168
    public void test() throws Exception {
164
        generateBiReport();
169
        createFofoSmartCartSuggestion();
165
        System.out.println("test end");
170
        System.out.println("test end");
166
 
171
 
167
    }
172
    }
168
 
173
 
169
    public void generateBiReport() throws Exception {
174
    public void generateBiReport() throws Exception {
Line 1485... Line 1490...
1485
                    .collect(Collectors.toSet());
1490
                    .collect(Collectors.toSet());
1486
        }
1491
        }
1487
 
1492
 
1488
    }
1493
    }
1489
 
1494
 
-
 
1495
    public void createFofoSmartCartSuggestion(){
-
 
1496
 
-
 
1497
        List<Integer> fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x->x.getId()).collect(toList());
-
 
1498
        LocalDateTime todayDate = LocalDate.now().atStartOfDay();
-
 
1499
        LocalDateTime fortyFiveAgoDate = todayDate.minusDays(45).with(LocalTime.MAX);
-
 
1500
        for(Integer fofoId :fofoIds){
-
 
1501
            smartCartSuggestionRepository.deleteByFofoId(fofoId);
-
 
1502
            List<SoldAllCatalogitemQtyByPartnerModel> soldAllCatalogitemQtyByPartnerModels = smartCartService.getAllSoldCatalogItemByPartner(fofoId,fortyFiveAgoDate,todayDate);
-
 
1503
            for(SoldAllCatalogitemQtyByPartnerModel soldAllCatalogitemQtyByPartnerModel : soldAllCatalogitemQtyByPartnerModels){
-
 
1504
               SmartCartSuggestion smartCartSuggestion = new SmartCartSuggestion();
-
 
1505
               smartCartSuggestion.setCatalogId(soldAllCatalogitemQtyByPartnerModel.getCatalogId());
-
 
1506
               smartCartSuggestion.setFofoId(fofoId);
-
 
1507
               smartCartSuggestion.setSoldQty(soldAllCatalogitemQtyByPartnerModel.getSoldQty());
-
 
1508
               smartCartSuggestion.setCreationDate(LocalDate.now());
-
 
1509
               smartCartSuggestionRepository.persist(smartCartSuggestion);
-
 
1510
            }
-
 
1511
        }
-
 
1512
 
-
 
1513
    }
-
 
1514
 
1490
 
1515
 
1491
}
1516
}