Subversion Repositories SmartDukaan

Rev

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

Rev 37602 Rev 37631
Line 202... Line 202...
202
 
202
 
203
    @Autowired
203
    @Autowired
204
    private PartnerRegionRepository partnerRegionRepository;
204
    private PartnerRegionRepository partnerRegionRepository;
205
 
205
 
206
    @Autowired
206
    @Autowired
207
    private EmployeeAttendanceRepository employeeAttendanceRepository;
-
 
208
 
-
 
209
    @Autowired
-
 
210
    VivoImeiActivationService vivoImeiActivationService;
207
    VivoImeiActivationService vivoImeiActivationService;
211
 
208
 
212
    @Autowired
209
    @Autowired
213
    CarlcareImeiActivationService carlcareImeiActivationService;
210
    CarlcareImeiActivationService carlcareImeiActivationService;
214
 
211
 
Line 298... Line 295...
298
    private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
295
    private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
299
 
296
 
300
    @Autowired
297
    @Autowired
301
    private LiquidationService liquidationService;
298
    private LiquidationService liquidationService;
302
 
299
 
303
    private static final String[] STOCK_AGEING_MAIL_LIST = new String[]{"uday.singh@smartudkaan.com", "mohinder.mutreja@smartdukaan.com", "ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com", "kuldeep.kumar@smartdukaan.com"};
300
    private static final String[] STOCK_AGEING_MAIL_LIST = new String[]{"uday.singh@smartdukaan.com", "mohinder.mutreja@smartdukaan.com", "tarun.verma@smartdukaan.com", "kuldeep.kumar@smartdukaan.com"};
304
 
301
 
305
    private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[]{"kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "niranjan.kala@smartdukaan.com"};
302
    private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[]{"kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "niranjan.kala@smartdukaan.com"};
306
 
303
 
307
    private static final String[] INDENT_TERTIARY_MAIL_LIST = new String[]{"uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "vinay.p@smartdukaan.com", "deena.nath@smartdukaan.com", "shobhit.tandon@smartdukaan.com", "ritesh.chauhan1@smartdukaan.com"};
304
    private static final String[] INDENT_TERTIARY_MAIL_LIST = new String[]{"uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "vinay.p@smartdukaan.com", "deena.nath@smartdukaan.com", "shobhit.tandon@smartdukaan.com", "ritesh.chauhan1@smartdukaan.com"};
308
 
305
 
309
    private static final String[] EMPLOYEE_ATTENDANCE_MAIL_LIST = new String[]{"sm@smartdukaan.com", "sm@smartdukaan.com"};
-
 
310
 
-
 
311
    private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
306
    private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
312
 
307
 
313
    @Autowired
308
    @Autowired
314
    private ReporticoService reporticoService;
309
    private ReporticoService reporticoService;
315
 
310
 
Line 1798... Line 1793...
1798
            for (BilledImeiModel billedImeiModel : samsungModels) {
1793
            for (BilledImeiModel billedImeiModel : samsungModels) {
1799
                List<Serializable> row = Arrays.asList(billedImeiModel.getFofoId(), billedImeiModel.getStoreCode(), billedImeiModel.getStoreName(), billedImeiModel.getStoreCity(), billedImeiModel.getBrand(), billedImeiModel.getModelName(), billedImeiModel.getModelNumber(), billedImeiModel.getColor(), billedImeiModel.getSerialNumber(), billedImeiModel.getPcmDate() == null ? "PCM date Missing" : "Rebill Imeis");
1794
                List<Serializable> row = Arrays.asList(billedImeiModel.getFofoId(), billedImeiModel.getStoreCode(), billedImeiModel.getStoreName(), billedImeiModel.getStoreCity(), billedImeiModel.getBrand(), billedImeiModel.getModelName(), billedImeiModel.getModelNumber(), billedImeiModel.getColor(), billedImeiModel.getSerialNumber(), billedImeiModel.getPcmDate() == null ? "PCM date Missing" : "Rebill Imeis");
1800
                rows.add(row);
1795
                rows.add(row);
1801
            }
1796
            }
1802
            ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
1797
            ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
1803
            String[] sendToArray = new String[]{"kamini.sharma@smartdukaan.com", "praveen.sharma@smartdukaan.com"};
1798
            String[] sendToArray = new String[]{"kamini.sharma@smartdukaan.com"};
1804
            String fileName = "Imeis need Rebilling -" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
1799
            String fileName = "Imeis need Rebilling -" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
1805
            Utils.sendMailWithAttachment(googleMailSender, sendToArray, new String[]{"tarun.verma@smartdukaan.com"}, "Samsung Rebilling IMEI Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
1800
            Utils.sendMailWithAttachment(googleMailSender, sendToArray, new String[]{"tarun.verma@smartdukaan.com"}, "Samsung Rebilling IMEI Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
1806
        }
1801
        }
1807
    }
1802
    }
1808
 
1803
 
Line 2058... Line 2053...
2058
                "indentandtertiary-report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
2053
                "indentandtertiary-report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
2059
        mailOutboxService.queueMailWithAttachmentsViaGoogle(INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report", "PFA", "ScheduledTasks.sendIndentTertiary", attachment);
2054
        mailOutboxService.queueMailWithAttachmentsViaGoogle(INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report", "PFA", "ScheduledTasks.sendIndentTertiary", attachment);
2060
 
2055
 
2061
    }
2056
    }
2062
 
2057
 
2063
    public void sendAttendanceMorningAlert() throws Exception {
-
 
2064
        LocalDateTime moriningTime = LocalDate.now().atTime(10, 31);
-
 
2065
        List<AuthUser> authUsers = authRepository.selectAllActiveUser();
-
 
2066
        Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x -> x.isActive()).collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
-
 
2067
 
-
 
2068
        List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
-
 
2069
        Map<String, User> userMap = users.stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
-
 
2070
 
-
 
2071
        List<EmployeeAttendance> employeeAttendances = employeeAttendanceRepository.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now());
-
 
2072
 
-
 
2073
        Map<Integer, Optional<EmployeeAttendance>> employeeMorningAttendance = employeeAttendances.stream().collect(groupingBy(EmployeeAttendance::getUserId, Collectors.minBy(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))));
-
 
2074
        for (AuthUser authUser : authUsers) {
-
 
2075
            User user = userMap.get(authUser.getEmailId());
-
 
2076
            Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
-
 
2077
            LOGGER.info("AuthUser - {}, employeeAttendanceOptional {}", authUser.getName(), employeeAttendanceOptional);
-
 
2078
            if (employeeAttendanceOptional != null) {
-
 
2079
                LOGGER.info("employeeAttendanceOptional.orElse {}", employeeAttendanceOptional.orElse(null));
-
 
2080
                if (employeeAttendanceOptional.orElse(null) != null) {
-
 
2081
                    LOGGER.info("employeeAttendanceOptional.get().getCreateTimestamp() {}", employeeAttendanceOptional.get().getCreateTimestamp());
-
 
2082
                }
-
 
2083
            }
-
 
2084
            if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null || employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
-
 
2085
                LOGGER.info("Will Send Email to {}", authUser.getFullName());
-
 
2086
                String body = String.format(
-
 
2087
                        "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()) + ")");
-
 
2088
 
-
 
2089
                mailOutboxService.queueMailViaGoogle(new String[]{authUser.getEmailId()}, new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body, "ScheduledTasks.sendAttendanceMorningAlert");
-
 
2090
 
-
 
2091
            }
-
 
2092
        }
-
 
2093
 
-
 
2094
    }
-
 
2095
 
-
 
2096
    public void sendAttendanceEveningAlert() throws Exception {
-
 
2097
        List<AuthUser> authUsers = authRepository.selectAllActiveUser();
-
 
2098
        Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x -> x.isActive()).collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
-
 
2099
 
-
 
2100
        List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
-
 
2101
        Map<String, User> userMap = users.stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
-
 
2102
 
-
 
2103
        Map<Integer, List<EmployeeAttendance>> employeeAttendancesMap = employeeAttendanceRepository.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now()).stream().collect(groupingBy(x -> x.getUserId()));
-
 
2104
 
-
 
2105
        for (AuthUser authUser : authUsers) {
-
 
2106
            User user = userMap.get(authUser.getEmailId());
-
 
2107
            String body = null;
-
 
2108
            List<EmployeeAttendance> employeeAttendances = employeeAttendancesMap.get(user.getId());
-
 
2109
            if (employeeAttendances == null) {
-
 
2110
                body = String.format(
-
 
2111
                        "Dear %s,\n No attendance has been registered by you today. You have been marked absent for the day.\n\nRegards\nHR Team", authUser.getFullName());
-
 
2112
            } else {
-
 
2113
                List<LocalDateTime> punchTimes = employeeAttendances.stream().sorted(Comparator.comparing(EmployeeAttendance::getCreateTimestamp)).map(x -> x.getCreateTimestamp()).collect(Collectors.toList());
-
 
2114
                if (punchTimes.size() == 1) {
-
 
2115
                    // body = String.format("Dear %s,\n Pls note that you haven't punched out yet.
-
 
2116
                    // You have been marked absent for half the day. You may contact your manager
-
 
2117
                    // and get it regularise.\n\nRegards\nHR Team", authUser.getFullName());
-
 
2118
                } else {
-
 
2119
                    LocalDateTime firstPunch = punchTimes.get(0);
-
 
2120
                    LocalDateTime lastPunch = punchTimes.get(punchTimes.size() - 1);
-
 
2121
                    Duration duration = Duration.between(firstPunch, lastPunch);
-
 
2122
                    boolean hoursCompleted = lastPunch.isAfter(firstPunch.plusHours(8).plusMinutes(30));
-
 
2123
                    if (!hoursCompleted) {
-
 
2124
                        body = String.format(
-
 
2125
                                "Dear %s,\n Pls note that you haven't completed 8.30 Hrs (%d.%d Hrs). You have been marked absent for half the day.\n\nRegards\nHR Team", authUser.getFullName(), duration.toHours(), duration.toMinutes() - duration.toHours() * 60);
-
 
2126
                    }
-
 
2127
                }
-
 
2128
 
-
 
2129
            }
-
 
2130
            if (body != null) {
-
 
2131
                mailOutboxService.queueMailViaGoogle(new String[]{authUser.getEmailId()}, new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body, "ScheduledTasks.sendAttendanceEveningAlert");
-
 
2132
            }
-
 
2133
        }
-
 
2134
 
-
 
2135
        this.sendMailToHR();
-
 
2136
 
-
 
2137
    }
-
 
2138
 
-
 
2139
    private void sendMailToHR() throws Exception {
-
 
2140
        Map<String, String> map = new HashMap<>();
-
 
2141
        String reporticoDate = FormattingUtils.formatReporitcoDate(LocalDateTime.now());
-
 
2142
        map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
-
 
2143
        map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
-
 
2144
        InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "employeeattendance.xml");
-
 
2145
        Attachment attachment = new Attachment("attendance-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
-
 
2146
        mailOutboxService.queueMailWithAttachmentsViaGoogle(EMPLOYEE_ATTENDANCE_MAIL_LIST, null, "Attendance - " + FormattingUtils.formatDate(LocalDateTime.now()), "PFA Attendance", "ScheduledTasks.sendMailToHR", attachment);
-
 
2147
    }
-
 
2148
 
-
 
2149
    public void checkPartnerActiveStore() throws Exception {
2058
    public void checkPartnerActiveStore() throws Exception {
2150
 
2059
 
2151
        List<FofoStore> fofoStores = fofoStoreRepository.selectByStatus(true);
2060
        List<FofoStore> fofoStores = fofoStoreRepository.selectByStatus(true);
2152
 
2061
 
2153
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
2062
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
Line 2508... Line 2417...
2508
                        Customer customer = customerRepository.selectById(po.getCustomerId());
2417
                        Customer customer = customerRepository.selectById(po.getCustomerId());
2509
                        String[] customerEmail = null;
2418
                        String[] customerEmail = null;
2510
                        if (customer.getEmailId() != null) {
2419
                        if (customer.getEmailId() != null) {
2511
                            customerEmail = new String[]{customer.getEmailId()};
2420
                            customerEmail = new String[]{customer.getEmailId()};
2512
                        }
2421
                        }
2513
                        List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "sm@smartdukaan.com", "tejbeer.kaur@shop2020.in", customRetailer.getEmail());
2422
                        List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "tejbeer.kaur@shop2020.in", customRetailer.getEmail());
2514
                        List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
2423
                        List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
2515
                        if (authUserEmails != null) {
2424
                        if (authUserEmails != null) {
2516
                            authUserEmails = new ArrayList<>();
2425
                            authUserEmails = new ArrayList<>();
2517
                        }
2426
                        }
2518
                        authUserEmails.addAll(bccTo);
2427
                        authUserEmails.addAll(bccTo);
Line 3622... Line 3531...
3622
 
3531
 
3623
        List<Integer> assignTo = Arrays.asList(15, 9, 54, 53);
3532
        List<Integer> assignTo = Arrays.asList(15, 9, 54, 53);
3624
 
3533
 
3625
        Map<Integer, AuthUser> assignAuthUserMap = authRepository.selectByIds(assignTo).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
3534
        Map<Integer, AuthUser> assignAuthUserMap = authRepository.selectByIds(assignTo).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
3626
 
3535
 
3627
        List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "sm@smartdukaan.com");
3536
        List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com");
3628
        LOGGER.info("partnerProblem" + partnerProblems);
3537
        LOGGER.info("partnerProblem" + partnerProblems);
3629
        StringBuilder sb = new StringBuilder();
3538
        StringBuilder sb = new StringBuilder();
3630
        sb.append("<htl><body>");
3539
        sb.append("<htl><body>");
3631
        sb.append(
3540
        sb.append(
3632
                "<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");
3541
                "<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");
Line 4258... Line 4167...
4258
 
4167
 
4259
            }
4168
            }
4260
 
4169
 
4261
        }
4170
        }
4262
        String messageText = this.getMessageForDueDateExtend(defaultLoans);
4171
        String messageText = this.getMessageForDueDateExtend(defaultLoans);
4263
        this.sendMailOfHtmlFormat(googleMailSender, new String[]{"puneet.wahi@smartdukaan.com", "rahul.latwal@smartdukaan.com", "dilbag.singh@smartdukaan.com"}, messageText, null, subject);
4172
        this.sendMailOfHtmlFormat(googleMailSender, new String[]{"dilbag.singh@smartdukaan.com"}, messageText, null, subject);
4264
 
4173
 
4265
        for (Loan defaultLoan : defaultLoans) {
4174
        for (Loan defaultLoan : defaultLoans) {
4266
            double principal = defaultLoan.getPendingAmount().doubleValue();
4175
            double principal = defaultLoan.getPendingAmount().doubleValue();
4267
            double interest = defaultLoan.getInterestAccrued().doubleValue() - defaultLoan.getInterestPaid().doubleValue();
4176
            double interest = defaultLoan.getInterestAccrued().doubleValue() - defaultLoan.getInterestPaid().doubleValue();
4268
            double total = principal + interest;
4177
            double total = principal + interest;
Line 5069... Line 4978...
5069
                    sb.append("</tr>\n");
4978
                    sb.append("</tr>\n");
5070
 
4979
 
5071
                }
4980
                }
5072
 
4981
 
5073
                this.sendMailOfHtmlFormat(googleMailSender, new String[]{email}, sb.toString(), null, subject);
4982
                this.sendMailOfHtmlFormat(googleMailSender, new String[]{email}, sb.toString(), null, subject);
5074
                // this.sendMailOfHtmlFormat("tejbeer.kaur@smartdukaan.com", sb.toString(),
-
 
5075
                // null, subject);
-
 
5076
 
4983
 
5077
            }
4984
            }
5078
 
4985
 
5079
        }
4986
        }
5080
 
4987
 
Line 5544... Line 5451...
5544
                "This is a gentle reminder to kindly update the brand-wise market share data for the current quarter.\n\n" +
5451
                "This is a gentle reminder to kindly update the brand-wise market share data for the current quarter.\n\n" +
5545
                "Best regards,\n" +
5452
                "Best regards,\n" +
5546
                "SmartDukaan Team";
5453
                "SmartDukaan Team";
5547
 
5454
 
5548
        mailOutboxService.queueMailViaGoogle(
5455
        mailOutboxService.queueMailViaGoogle(
5549
                new String[]{"sm.@smartdukaan.com"},
-
 
5550
                new String[]{"tech@smartdukaan.com"},
5456
                new String[]{"tech@smartdukaan.com"},
-
 
5457
                null,
5551
                subject,
5458
                subject,
5552
                body,
5459
                body,
5553
                "ScheduledTasks.sendUpdateMobileBrandMarketShareQuaterlyMail"
5460
                "ScheduledTasks.sendUpdateMobileBrandMarketShareQuaterlyMail"
5554
        );
5461
        );
5555
    }
5462
    }