Subversion Repositories SmartDukaan

Rev

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

Rev 35929 Rev 35959
Line 94... Line 94...
94
import com.spice.profitmandi.service.integrations.pinelabs.dto.*;
94
import com.spice.profitmandi.service.integrations.pinelabs.dto.*;
95
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
95
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
96
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
96
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
97
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
97
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
98
import com.spice.profitmandi.service.inventory.*;
98
import com.spice.profitmandi.service.inventory.*;
-
 
99
import com.spice.profitmandi.service.mail.MailOutboxService;
99
import com.spice.profitmandi.service.offers.OfferService;
100
import com.spice.profitmandi.service.offers.OfferService;
100
import com.spice.profitmandi.service.order.OrderService;
101
import com.spice.profitmandi.service.order.OrderService;
101
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
102
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
102
import com.spice.profitmandi.service.pricing.PriceDropService;
103
import com.spice.profitmandi.service.pricing.PriceDropService;
103
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
104
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
Line 401... Line 402...
401
    @Autowired
402
    @Autowired
402
    @Qualifier(value = "googleMailSender")
403
    @Qualifier(value = "googleMailSender")
403
    private JavaMailSender googleMailSender;
404
    private JavaMailSender googleMailSender;
404
 
405
 
405
    @Autowired
406
    @Autowired
-
 
407
    private MailOutboxService mailOutboxService;
-
 
408
 
-
 
409
    @Autowired
406
    private InventoryService inventoryService;
410
    private InventoryService inventoryService;
407
 
411
 
408
    @Autowired
412
    @Autowired
409
    private AddressRepository addressRepository;
413
    private AddressRepository addressRepository;
410
 
414
 
Line 862... Line 866...
862
        ByteArrayOutputStream byteArrayOutputStream2 = FileUtil.getCSVByteStream(Arrays.asList("InventoryItemId", "Serial Number", "Item Id", "Brand", "Model Name", "ModelNumber", "Color", "Partner Id", "Partner Code", "Partner Name", "Activation Type", "City", "State", "Billing Date", "Exceed Days", "Max Ageing", "Activation Date"), partnerAgeingModels.stream().map(x -> Arrays.asList(x.getInventoryItemId(), x.getSerialNumber(), x.getItemId(), x.getBrand(), x.getModelName(), x.getModelNumber(), x.getColor(), x.getFofoId(), x.getFofoCode(), x.getFofoName(), x.getActivationType(), x.getFofoCity(), x.getFofoState(), FormattingUtils.formatDate(x.getBillingDate()), x.getExceedDays(), x.getMaxAgeingDays(), x.getActivationDate())).collect(Collectors.toList()));
866
        ByteArrayOutputStream byteArrayOutputStream2 = FileUtil.getCSVByteStream(Arrays.asList("InventoryItemId", "Serial Number", "Item Id", "Brand", "Model Name", "ModelNumber", "Color", "Partner Id", "Partner Code", "Partner Name", "Activation Type", "City", "State", "Billing Date", "Exceed Days", "Max Ageing", "Activation Date"), partnerAgeingModels.stream().map(x -> Arrays.asList(x.getInventoryItemId(), x.getSerialNumber(), x.getItemId(), x.getBrand(), x.getModelName(), x.getModelNumber(), x.getColor(), x.getFofoId(), x.getFofoCode(), x.getFofoName(), x.getActivationType(), x.getFofoCity(), x.getFofoState(), FormattingUtils.formatDate(x.getBillingDate()), x.getExceedDays(), x.getMaxAgeingDays(), x.getActivationDate())).collect(Collectors.toList()));
863
        Attachment attachment1 = new Attachment("secondary-alert.csv", new ByteArrayResource(byteArrayOutputStream.toByteArray()));
867
        Attachment attachment1 = new Attachment("secondary-alert.csv", new ByteArrayResource(byteArrayOutputStream.toByteArray()));
864
        Attachment attachment2 = new Attachment("tertiary-alert.csv", new ByteArrayResource(byteArrayOutputStream2.toByteArray()));
868
        Attachment attachment2 = new Attachment("tertiary-alert.csv", new ByteArrayResource(byteArrayOutputStream2.toByteArray()));
865
 
869
 
866
        String mailSubject = "Stock ageing Alert";
870
        String mailSubject = "Stock ageing Alert";
867
        Utils.sendMailWithAttachments(mailSender, new String[]{"deena.nath@smartdukaan.com"}, null, mailSubject, "PFA", attachment1, attachment2);
871
        mailOutboxService.queueMailWithAttachmentsViaGoogle(new String[]{"deena.nath@smartdukaan.com"}, null, mailSubject, "PFA", "ScheduledTasks.sendMailForAgeingAlert", attachment1, attachment2);
868
    }
872
    }
869
 
873
 
870
    public void rejectPriceDropsOfApprovedImeis() throws ProfitMandiBusinessException {
874
    public void rejectPriceDropsOfApprovedImeis() throws ProfitMandiBusinessException {
871
        priceDropService.rejectPriceDropsOfApprovedImeis();
875
        priceDropService.rejectPriceDropsOfApprovedImeis();
872
    }
876
    }
Line 1334... Line 1338...
1334
        return buffer.toByteArray();
1338
        return buffer.toByteArray();
1335
    }
1339
    }
1336
 
1340
 
1337
    private void whatsappTest() throws Exception {
1341
    private void whatsappTest() throws Exception {
1338
        //liquidationService.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
1342
        //liquidationService.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
1339
        Utils.sendMailWithAttachments(googleMailSender, new String[]{"ranu.rajput@smartdukaan.com"}, null, "Test Mail", "Mail is working");
1343
        mailOutboxService.queueMailViaGoogle(new String[]{"ranu.rajput@smartdukaan.com"}, null, "Test Mail", "Mail is working", "ScheduledTasks.whatsappTest");
1340
    }
1344
    }
1341
 
1345
 
1342
    private void debitLoanAmountFromWallet() {
1346
    private void debitLoanAmountFromWallet() {
1343
        List l1 = Arrays.asList(1234, 1420, 2694, 8129, 12182, 12880, 16289, 16462, 16551, 16625, 16819, 17606, 18902, 19152, 19663, 22409, 22410, 23924, 24058, 24206, 24215, 24220, 24459, 25977, 30585, 31590);
1347
        List l1 = Arrays.asList(1234, 1420, 2694, 8129, 12182, 12880, 16289, 16462, 16551, 16625, 16819, 17606, 18902, 19152, 19663, 22409, 22410, 23924, 24058, 24206, 24215, 24220, 24459, 25977, 30585, 31590);
1344
        l1.addAll(Arrays.asList(11849, 12702, 14554, 14643, 19166, 19638, 32824, 33467, 33954, 34017, 34514, 35128, 35229, 35355, 36007, 36351, 36435, 36586, 36608, 36612, 36665, 37076, 37495, 37678, 38519, 38563, 38638, 38690, 38815, 38840, 39015, 39084, 39142, 39379, 39384, 39586, 39636, 39657, 39755, 39788, 39908, 40054, 40220, 40534, 41731, 41962, 42692));
1348
        l1.addAll(Arrays.asList(11849, 12702, 14554, 14643, 19166, 19638, 32824, 33467, 33954, 34017, 34514, 35128, 35229, 35355, 36007, 36351, 36435, 36586, 36608, 36612, 36665, 37076, 37495, 37678, 38519, 38563, 38638, 38690, 38815, 38840, 39015, 39084, 39142, 39379, 39384, 39586, 39636, 39657, 39755, 39788, 39908, 40054, 40220, 40534, 41731, 41962, 42692));
Line 1878... Line 1882...
1878
        Attachment attachment = new Attachment(
1882
        Attachment attachment = new Attachment(
1879
                "ageing-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr);
1883
                "ageing-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr);
1880
        Attachment attachment1 = new Attachment(
1884
        Attachment attachment1 = new Attachment(
1881
                "pending-indent-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr1);
1885
                "pending-indent-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr1);
1882
 
1886
 
1883
        Utils.sendMailWithAttachments(googleMailSender, STOCK_AGEING_MAIL_LIST, null, "Stock Ageing Report", "PFA", attachment);
1887
        mailOutboxService.queueMailWithAttachmentsViaGoogle(STOCK_AGEING_MAIL_LIST, null, "Stock Ageing Report", "PFA", "ScheduledTasks.sendAgeingReport", attachment);
1884
        Utils.sendMailWithAttachments(googleMailSender, ITEMWISE_PENDING_INDENT_MAIL_LIST, null, "Itemwise Pending indent", "PFA", attachment1);
1888
        mailOutboxService.queueMailWithAttachmentsViaGoogle(ITEMWISE_PENDING_INDENT_MAIL_LIST, null, "Itemwise Pending indent", "PFA", "ScheduledTasks.sendAgeingReport", attachment1);
1885
 
1889
 
1886
        // Reports to be sent to mapped partners
1890
        // Reports to be sent to mapped partners
1887
        Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
1891
        Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
1888
 
1892
 
1889
        for (Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
1893
        for (Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
Line 1893... Line 1897...
1893
            params.put("MANUAL_email", String.join(",", storeGuyEntry.getValue()));
1897
            params.put("MANUAL_email", String.join(",", storeGuyEntry.getValue()));
1894
            InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "focostockreport.xml", params);
1898
            InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "focostockreport.xml", params);
1895
            Attachment attache = new Attachment(
1899
            Attachment attache = new Attachment(
1896
                    "Franchise-stock-report" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr3);
1900
                    "Franchise-stock-report" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr3);
1897
            System.out.println(storeGuyEntry.getValue());
1901
            System.out.println(storeGuyEntry.getValue());
1898
            Utils.sendMailWithAttachments(googleMailSender, new String[]{storeGuyEntry.getKey()}, null, "Franchise Stock Report", "PFA", attache);
1902
            mailOutboxService.queueMailWithAttachmentsViaGoogle(new String[]{storeGuyEntry.getKey()}, null, "Franchise Stock Report", "PFA", "ScheduledTasks.sendAgeingReport", attache);
1899
        }
1903
        }
1900
 
1904
 
1901
    }
1905
    }
1902
 
1906
 
1903
    public void sendIndentTertiary() throws Exception {
1907
    public void sendIndentTertiary() throws Exception {
1904
 
1908
 
1905
        InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "indentandtertiary.xml");
1909
        InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "indentandtertiary.xml");
1906
        Attachment attachment = new Attachment(
1910
        Attachment attachment = new Attachment(
1907
                "indentandtertiary-report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
1911
                "indentandtertiary-report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
1908
        Utils.sendMailWithAttachments(googleMailSender, INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report", "PFA", attachment);
1912
        mailOutboxService.queueMailWithAttachmentsViaGoogle(INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report", "PFA", "ScheduledTasks.sendIndentTertiary", attachment);
1909
 
1913
 
1910
    }
1914
    }
1911
 
1915
 
1912
    public void sendAttendanceMorningAlert() throws Exception {
1916
    public void sendAttendanceMorningAlert() throws Exception {
1913
        LocalDateTime moriningTime = LocalDate.now().atTime(10, 31);
1917
        LocalDateTime moriningTime = LocalDate.now().atTime(10, 31);
Line 1933... Line 1937...
1933
            if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null || employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
1937
            if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null || employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
1934
                LOGGER.info("Will Send Email to {}", authUser.getFullName());
1938
                LOGGER.info("Will Send Email to {}", authUser.getFullName());
1935
                String body = String.format(
1939
                String body = String.format(
1936
                        "Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day.\n\nRegards\nHR Team", authUser.getFullName(), (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? "" : "(Punched at " + FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp()) + ")");
1940
                        "Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day.\n\nRegards\nHR Team", authUser.getFullName(), (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? "" : "(Punched at " + FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp()) + ")");
1937
 
1941
 
1938
                Utils.sendMailWithAttachments(googleMailSender, new String[]{authUser.getEmailId()}, new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body);
1942
                mailOutboxService.queueMailViaGoogle(new String[]{authUser.getEmailId()}, new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body, "ScheduledTasks.sendAttendanceMorningAlert");
1939
 
1943
 
1940
            }
1944
            }
1941
        }
1945
        }
1942
 
1946
 
1943
    }
1947
    }
Line 1975... Line 1979...
1975
                    }
1979
                    }
1976
                }
1980
                }
1977
 
1981
 
1978
            }
1982
            }
1979
            if (body != null) {
1983
            if (body != null) {
1980
                Utils.sendMailWithAttachments(googleMailSender, new String[]{authUser.getEmailId()}, new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body);
1984
                mailOutboxService.queueMailViaGoogle(new String[]{authUser.getEmailId()}, new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body, "ScheduledTasks.sendAttendanceEveningAlert");
1981
            }
1985
            }
1982
        }
1986
        }
1983
 
1987
 
1984
        this.sendMailToHR();
1988
        this.sendMailToHR();
1985
 
1989
 
Line 1990... Line 1994...
1990
        String reporticoDate = FormattingUtils.formatReporitcoDate(LocalDateTime.now());
1994
        String reporticoDate = FormattingUtils.formatReporitcoDate(LocalDateTime.now());
1991
        map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
1995
        map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
1992
        map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
1996
        map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
1993
        InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "employeeattendance.xml");
1997
        InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "employeeattendance.xml");
1994
        Attachment attachment = new Attachment("attendance-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
1998
        Attachment attachment = new Attachment("attendance-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
1995
        Utils.sendMailWithAttachments(googleMailSender, EMPLOYEE_ATTENDANCE_MAIL_LIST, null, "Attendance - " + FormattingUtils.formatDate(LocalDateTime.now()), "PFA Attendance", attachment);
1999
        mailOutboxService.queueMailWithAttachmentsViaGoogle(EMPLOYEE_ATTENDANCE_MAIL_LIST, null, "Attendance - " + FormattingUtils.formatDate(LocalDateTime.now()), "PFA Attendance", "ScheduledTasks.sendMailToHR", attachment);
1996
    }
2000
    }
1997
 
2001
 
1998
    public void checkPartnerActiveStore() throws Exception {
2002
    public void checkPartnerActiveStore() throws Exception {
1999
 
2003
 
2000
        List<FofoStore> fofoStores = fofoStoreRepository.selectByStatus(true);
2004
        List<FofoStore> fofoStores = fofoStoreRepository.selectByStatus(true);
Line 3846... Line 3850...
3846
 
3850
 
3847
            String[] ccTo = {"tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com"};
3851
            String[] ccTo = {"tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com"};
3848
 
3852
 
3849
            String subject = "Dispatch held orders of - " + (orders.get(0).getRetailerName());
3853
            String subject = "Dispatch held orders of - " + (orders.get(0).getRetailerName());
3850
            String message = String.format("Dear Team, \n" + "kindly note the material for the " + orders.get(0).getRetailerName() + "of Rs." + totalAmount + "is unhold now and needs to be dispatched.");
3854
            String message = String.format("Dear Team, \n" + "kindly note the material for the " + orders.get(0).getRetailerName() + "of Rs." + totalAmount + "is unhold now and needs to be dispatched.");
3851
            Utils.sendMailWithAttachments(mailSender, emailTo, ccTo, subject, message);
3855
            mailOutboxService.queueMailViaGoogle(emailTo, ccTo, subject, message, "ScheduledTasks.sendUnholdEmail");
3852
        }
3856
        }
3853
 
3857
 
3854
 
3858
 
3855
    }
3859
    }
3856
 
3860
 
Line 4275... Line 4279...
4275
            if (!filteredRows.isEmpty()) {
4279
            if (!filteredRows.isEmpty()) {
4276
                String messageText = this.getMessageForDueDateCross(filteredRows);
4280
                String messageText = this.getMessageForDueDateCross(filteredRows);
4277
                String[] email = new String[]{storeGuyEntry.getKey(),"neeraj.gupta@smartdukaan.com"};
4281
                String[] email = new String[]{storeGuyEntry.getKey(),"neeraj.gupta@smartdukaan.com"};
4278
 
4282
 
4279
                if (attachment1 != null) {
4283
                if (attachment1 != null) {
4280
                    Utils.sendMailWithAttachments(googleMailSender, email, null, null, "Partner Credit Report", messageText, true, attachment1);
4284
                    mailOutboxService.queueMailWithAttachmentsViaGoogle(email, null, null, "Partner Credit Report", messageText, true, "ScheduledTasks.sendDueDateCrossLoanAlert", attachment1);
4281
                } else {
4285
                } else {
4282
                    this.sendMailOfHtmlFormat(googleMailSender, email, messageText, null, "Due Date Cross");
4286
                    this.sendMailOfHtmlFormat(googleMailSender, email, messageText, null, "Due Date Cross");
4283
 
4287
 
4284
                }
4288
                }
4285
 
4289
 
Line 4294... Line 4298...
4294
            attachment = new Utils.Attachment("partnner-credit.csv", new ByteArrayResource(byteArrayOutputStream.toByteArray()));
4298
            attachment = new Utils.Attachment("partnner-credit.csv", new ByteArrayResource(byteArrayOutputStream.toByteArray()));
4295
 
4299
 
4296
        }
4300
        }
4297
 
4301
 
4298
        if (attachment != null) {
4302
        if (attachment != null) {
4299
            Utils.sendMailWithAttachments(googleMailSender, new String[]{"sdtech@smartdukaan.com"}, null, null, "Partner Credit Report", messageText, true, attachment);
4303
            mailOutboxService.queueMailWithAttachmentsViaGoogle(new String[]{"sdtech@smartdukaan.com"}, null, null, "Partner Credit Report", messageText, true, "ScheduledTasks.sendDueDateCrossLoanAlert", attachment);
4300
        } else {
4304
        } else {
4301
            this.sendMailOfHtmlFormat(googleMailSender, new String[]{"sdtech@smartdukaan.com"}, messageText, null, "Due Date Cross");
4305
            this.sendMailOfHtmlFormat(googleMailSender, new String[]{"sdtech@smartdukaan.com"}, messageText, null, "Due Date Cross");
4302
        }
4306
        }
4303
 
4307
 
4304
 
4308
 
Line 5437... Line 5441...
5437
        String body = "Dear Team,\n\n" +
5441
        String body = "Dear Team,\n\n" +
5438
                "This is a gentle reminder to kindly update the brand-wise market share data for the current quarter.\n\n" +
5442
                "This is a gentle reminder to kindly update the brand-wise market share data for the current quarter.\n\n" +
5439
                "Best regards,\n" +
5443
                "Best regards,\n" +
5440
                "SmartDukaan Team";
5444
                "SmartDukaan Team";
5441
 
5445
 
5442
        Utils.sendMailWithAttachments(
5446
        mailOutboxService.queueMailViaGoogle(
5443
                googleMailSender,
-
 
5444
                new String[]{"sm.@smartdukaan.com"},
5447
                new String[]{"sm.@smartdukaan.com"},
5445
                new String[]{"tech@smartdukaan.com"},
5448
                new String[]{"tech@smartdukaan.com"},
5446
                subject,
5449
                subject,
5447
                body
5450
                body,
-
 
5451
                "ScheduledTasks.sendUpdateMobileBrandMarketShareQuaterlyMail"
5448
        );
5452
        );
5449
    }
5453
    }
5450
 
5454
 
5451
 
5455
 
5452
}
5456
}