Subversion Repositories SmartDukaan

Rev

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

Rev 36463 Rev 36472
Line 1177... Line 1177...
1177
    PurSaleService purSaleService;
1177
    PurSaleService purSaleService;
1178
 
1178
 
1179
    @Autowired
1179
    @Autowired
1180
    CatalogRepository catalogRepository;
1180
    CatalogRepository catalogRepository;
1181
 
1181
 
1182
    private void rolloutOppoPayout() throws Exception {
-
 
1183
        //List<Integer> schemeIds = Arrays.asList(5540, 5542, 5544,5918, 5919, 5920, 5921, 5922);
-
 
1184
        List<Integer> schemeIds = Arrays.asList(5540, 5542, 5544, 5545, 5550, 5555, 5556, 5557, 5564, 5565, 5566, 5567, 5569, 5570, 5582, 5590, 5592, 5593, 5594,
-
 
1185
                5595, 5598, 5602, 5604, 5605, 5606, 5607, 5608, 5611, 5618, 5620, 5621, 5622, 5623, 5624, 5625, 5626, 5629, 5631,
-
 
1186
                5633, 5634, 5635, 5637, 5644, 5649, 5655, 5659, 5662, 5668, 5672, 5674, 5679, 5683, 5684, 5685, 5688, 5689, 5690,
-
 
1187
                5692, 5694, 5697, 5699, 5700, 5706, 5718, 5729, 5730, 5754, 5756, 5758, 5759, 5761, 5762, 5766, 5769, 5771, 5772,
-
 
1188
                5773, 5774, 5775, 5776, 5781, 5782, 5783, 5786, 5788, 5790, 5795, 5800, 5803, 5804, 5807, 5809, 5815, 5816, 5819,
-
 
1189
                5820, 5821, 5822, 5823, 5824, 5825, 5826, 5827, 5828, 5829, 5830, 5832, 5833, 5834, 5835, 5836, 5837, 5839, 5840,
-
 
1190
                5841, 5842, 5843, 5844, 5845, 5846, 5847, 5848, 5849, 5850, 5851, 5852, 5853, 5854, 5855, 5857, 5859, 5860, 5863,
-
 
1191
                5864, 5866, 5869, 5870, 5871, 5872, 5873, 5874, 5875, 5877, 5878, 5879, 5880, 5885, 5888, 5889, 5891, 5892, 5894,
-
 
1192
                5899, 5901, 5903, 5905, 5908, 5910, 5913, 5916, 5917, 5918, 5919, 5920, 5921, 5922, 5923, 5924, 5925, 5926, 5927,
-
 
1193
                5928, 5929, 5930, 5931, 5932, 5933, 5934, 5935, 5936, 5938, 5939, 5940, 5941, 5942, 5943, 5944, 5945, 5946, 5947,
-
 
1194
                5948, 5949, 5950, 5951, 5952, 5953, 5954, 5955, 5956, 5957, 5958, 5959, 5960, 5961, 5962, 5963, 5964, 5965, 5966,
-
 
1195
                5967, 5968, 5969, 5970, 5971, 5972, 5973, 5974, 5975, 5976, 5977, 5979, 5980, 5981, 5982, 5983, 5984, 5985, 5986,
-
 
1196
                5987, 5989, 5990, 5991, 5992, 5996, 5997, 5998, 5999, 6000, 6001, 6002, 6003, 6004, 6005, 6006, 6007, 6008, 6010,
-
 
1197
                6011, 6012, 6013, 6014, 6015, 6016, 6017, 6018, 6019, 6020, 6021, 6022, 6023, 6024, 6025, 6026, 6028, 6029, 6030,
-
 
1198
                6031, 6032, 6033, 6034, 6035, 6036, 6037, 6038, 6039, 6040, 6041, 6042, 6043, 6044, 6045, 6046, 6047, 6048, 6049,
-
 
1199
                6050, 6051, 6052, 6053, 6054, 6055, 6056, 6057, 6058, 6059, 6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068,
-
 
1200
                6069, 6070, 6071, 6072, 6073, 6078, 6079, 6080, 6081, 6082, 6083, 6084, 6085, 6086, 6087, 6088, 6089, 6091, 6092,
-
 
1201
                6093, 6094, 6095, 6098, 6102);
-
 
1202
        Map<Integer, List<SchemeInOut>> inventoryItemSiosMap = schemeInOutRepository.selectBySchemeIds(new HashSet<>(schemeIds)).stream().collect(Collectors.groupingBy(x -> x.getInventoryItemId()));
-
 
1203
        Map<Integer, InventoryItem> inventoryItemMap = inventoryItemRepository.selectByIds(inventoryItemSiosMap.keySet()).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
-
 
1204
        Set<Integer> itemIds = itemRepository.selectAllByBrand("Oppo", 10006).stream().map(x -> x.getId()).collect(toSet());
-
 
1205
        List<InventoryItem> filteredInventoryItems = inventoryItemMap.values().stream().filter(x -> itemIds.contains(x.getItemId())).collect(Collectors.toList());
-
 
1206
 
-
 
1207
        Map<Integer, List<InventoryItem>> purchaseInventoryItemsMap = filteredInventoryItems.stream().filter(x -> x.getCreateTimestamp().isAfter(YearMonth.now().atDay(1).atStartOfDay())).collect(Collectors.groupingBy(x -> x.getPurchaseId()));
-
 
1208
        List<Purchase> purchases = purchaseRepository.selectAllByIds(new ArrayList<>(purchaseInventoryItemsMap.keySet()));
-
 
1209
        for (Purchase purchase : purchases) {
-
 
1210
            String invoiceNumber = purchase.getPurchaseReference();
-
 
1211
            LocalDateTime billingTime = orderRepository.selectByInvoiceNumber(invoiceNumber).get(0).getBillingTimestamp();
-
 
1212
            if (billingTime.isAfter(YearMonth.now().atDay(1).atStartOfDay())) {
-
 
1213
                schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
-
 
1214
            }
-
 
1215
        }
-
 
1216
 
-
 
1217
        for (InventoryItem filteredInventoryItem : filteredInventoryItems) {
-
 
1218
            //System.out.println("Serial Number is - " + filteredInventoryItem.getSerialNumber());
-
 
1219
            List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(filteredInventoryItem.getId());
-
 
1220
            ScanRecord scanRecord = scanRecords.stream().filter(x -> x.getType().equals(ScanType.SALE)).findFirst().orElse(null);
-
 
1221
            if (scanRecord == null) {
-
 
1222
                continue;
-
 
1223
            }
-
 
1224
            schemeService.processSchemeOut(scanRecord.getOrderId(), scanRecord.getFofoId());
-
 
1225
        }
-
 
1226
    }
-
 
1227
 
-
 
1228
    @Autowired
1182
    @Autowired
1229
    AbmReportSender abmReportSender;
1183
    AbmReportSender abmReportSender;
1230
 
1184
 
1231
    public void sendOverDueReport() {
1185
    public void sendOverDueReport() {
1232
        List<Loan> loans = loanRepository.selectAllActiveLoan();
1186
        List<Loan> loans = loanRepository.selectAllActiveLoan();
Line 1478... Line 1432...
1478
    private void compensateAlreadyFixedLoans() {
1432
    private void compensateAlreadyFixedLoans() {
1479
        int[] alreadyFixedLoanIds = {106138, 106139, 106140, 106141, 106142, 106143, 106144, 106145, 106146, 106147};
1433
        int[] alreadyFixedLoanIds = {106138, 106139, 106140, 106141, 106142, 106143, 106144, 106145, 106146, 106147};
1480
        System.out.println("Compensating " + alreadyFixedLoanIds.length + " already-fixed loans");
1434
        System.out.println("Compensating " + alreadyFixedLoanIds.length + " already-fixed loans");
1481
 
1435
 
1482
        int done = 0, failed = 0;
1436
        int done = 0, failed = 0;
-
 
1437
 
1483
        for (int loanId : alreadyFixedLoanIds) {
1438
        for (int loanId : alreadyFixedLoanIds) {
1484
            try {
1439
            try {
1485
                Loan loan = loanRepository.selectByLoanId(loanId);
1440
                Loan loan = loanRepository.selectByLoanId(loanId);
1486
                if (loan == null) {
1441
                if (loan == null) {
1487
                    System.out.println("SKIP compensate loan " + loanId + " - not found");
1442
                    System.out.println("SKIP compensate loan " + loanId + " - not found");
Line 2722... Line 2677...
2722
        if (cc != null) {
2677
        if (cc != null) {
2723
            helper.setCc(cc);
2678
            helper.setCc(cc);
2724
        }
2679
        }
2725
        InternetAddress senderAddress = new InternetAddress("sdtech@smartdukaan.com", "Smart Dukaan");
2680
        InternetAddress senderAddress = new InternetAddress("sdtech@smartdukaan.com", "Smart Dukaan");
2726
        helper.setFrom(senderAddress);
2681
        helper.setFrom(senderAddress);
2727
        gmailRelaySender.send(message);
2682
        sender.send(message);
2728
    }
2683
    }
2729
 
2684
 
2730
    public void sendNotification() throws Exception {
2685
    public void sendNotification() throws Exception {
2731
        LOGGER.info("FCM sendNotification");
2686
        LOGGER.info("FCM sendNotification");
2732
        List<PushNotifications> pushNotifications = pushNotificationRepository.selectAllPendingNotifications();
2687
        List<PushNotifications> pushNotifications = pushNotificationRepository.selectAllPendingNotifications();