Subversion Repositories SmartDukaan

Rev

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

Rev 34676 Rev 34677
Line 536... Line 536...
536
        for(Integer fofoId: retailerIds){
536
        for(Integer fofoId: retailerIds){
537
            String rbmName = "";
537
            String rbmName = "";
538
            int rbmL1 = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM,EscalationType.L1,fofoId);
538
            int rbmL1 = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM,EscalationType.L1,fofoId);
539
            if(rbmL1 != 0){
539
            if(rbmL1 != 0){
540
                 rbmName = authRepository.selectById(rbmL1).getFullName();
540
                 rbmName = authRepository.selectById(rbmL1).getFullName();
-
 
541
            }else {
-
 
542
                int rbmL2 = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L2, fofoId);
-
 
543
                if(rbmL2 != 0){
-
 
544
                    rbmName = authRepository.selectById(rbmL2).getFullName();
-
 
545
                }
541
            }
546
            }
542
            String bmName ="";
547
            String bmName ="";
543
            int bmId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_SALES,EscalationType.L2,fofoId);
548
            int bmId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_SALES,EscalationType.L2,fofoId);
544
            if(bmId !=0){
549
            if(bmId !=0){
545
                bmName = authRepository.selectById(bmId).getFullName();
550
                bmName = authRepository.selectById(bmId).getFullName();
Line 723... Line 728...
723
 
728
 
724
            //            generate investment info
729
            //            generate investment info
725
            FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
730
            FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
726
            float shortInvestment = partnerDailyInvestmentMap.get(fofoId) != null ? partnerDailyInvestmentMap.get(fofoId).getShortInvestment() : 0f;
731
            float shortInvestment = partnerDailyInvestmentMap.get(fofoId) != null ? partnerDailyInvestmentMap.get(fofoId).getShortInvestment() : 0f;
727
            float agreedInvestment = partnerDailyInvestmentMap.get(fofoId) != null ? partnerDailyInvestmentMap.get(fofoId).getMinInvestment() : 0f;
732
            float agreedInvestment = partnerDailyInvestmentMap.get(fofoId) != null ? partnerDailyInvestmentMap.get(fofoId).getMinInvestment() : 0f;
728
            float investmentLevel = partnerDailyInvestmentMap.get(fofoId) != null ? ((shortInvestment-agreedInvestment)/agreedInvestment)*100 : 0f;
733
            float investmentLevel = partnerDailyInvestmentMap.get(fofoId) != null
-
 
734
                    ? Math.abs(((shortInvestment - agreedInvestment) / agreedInvestment) * 100)
-
 
735
                    : 0f;
-
 
736
 
729
 
737
 
730
            List<Loan> fofoDefaultLoans = new ArrayList<>();
738
            List<Loan> fofoDefaultLoans = new ArrayList<>();
731
            if(defaultLoanMap != null){
739
            if(defaultLoanMap != null){
732
                 fofoDefaultLoans  =  defaultLoanMap.get(fofoId);
740
                 fofoDefaultLoans  =  defaultLoanMap.get(fofoId);
733
                LOGGER.info("fofoDefaultLoans {}",fofoDefaultLoans);
741
                LOGGER.info("fofoDefaultLoans {}",fofoDefaultLoans);
Line 743... Line 751...
743
            float activeLoan = loanRepository.selectActiveLoan(fofoId).stream().map(Loan::getPendingAmount).reduce(BigDecimal.ZERO,BigDecimal::add).floatValue();
751
            float activeLoan = loanRepository.selectActiveLoan(fofoId).stream().map(Loan::getPendingAmount).reduce(BigDecimal.ZERO,BigDecimal::add).floatValue();
744
 
752
 
745
 
753
 
746
            float poValue = partnerDailyInvestmentMap.get(fofoId) != null ?  partnerDailyInvestmentMap.get(fofoId).getUnbilledAmount() : 0f;
754
            float poValue = partnerDailyInvestmentMap.get(fofoId) != null ?  partnerDailyInvestmentMap.get(fofoId).getUnbilledAmount() : 0f;
747
 
755
 
748
            List<Order> billedAndPoOrder = orderRepository.selectOrders(Arrays.asList(fofoId),Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.ACCEPTED, OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH, OrderStatus.DELIVERY_SUCCESS),startOfToday,startOfToday.plusDays(1));
756
            List<Order> billedAndPoOrder = orderRepository.selectOrders(Arrays.asList(fofoId),Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.ACCEPTED, OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH, OrderStatus.DELIVERY_SUCCESS),currentMonthStartDate,startOfToday.plusDays(1));
749
            float poAndBilledValue = (float) billedAndPoOrder.stream().map(Order::getTotalAmount).reduce(0f,Float::sum);
757
            float poAndBilledValue = (float) billedAndPoOrder.stream().map(Order::getTotalAmount).reduce(0f,Float::sum);
750
 
758
 
751
            double purchaseMtd = secondaryMtd.getOrDefault(fofoId, 0.0);
759
            double purchaseMtd = secondaryMtd.getOrDefault(fofoId, 0.0);
752
 
760
 
753
            double todayRequiredDrr = rbmTargetService.calculateFofoIdTodayTarget(fofoId, purchaseMtd,LocalDate.now());
761
            double todayRequiredDrr = rbmTargetService.calculateFofoIdTodayTarget(fofoId, purchaseMtd,LocalDate.now());
Line 841... Line 849...
841
        //generate excel and sent to mail
849
        //generate excel and sent to mail
842
        List<List<String>> headerGroup = new ArrayList<>();
850
        List<List<String>> headerGroup = new ArrayList<>();
843
 
851
 
844
        List<String> headers1 = Arrays.asList(
852
        List<String> headers1 = Arrays.asList(
845
                "","","","",
853
                "","","","",
846
                "Retailer Detail", "", "", "", "", "", "", "", "",
854
                "Retailer Detail", "","", "", "", "", "", "", "", "",
847
                currentMonthStringValue, "", "", "", "", "", "",
-
 
848
                lastMonthStringValue, "", "", "", "", "", "",
-
 
-
 
855
 
849
                twoMonthAgoStringValue, "", "", "", "", "", "",
856
                twoMonthAgoStringValue, "", "", "", "", "", "",
-
 
857
                lastMonthStringValue, "", "", "", "", "", "",
-
 
858
                currentMonthStringValue, "", "", "", "", "", "",
850
 
859
 
851
                "","", "", "", "", "", "", "", "", "", "", "", "", "",
860
                "","", "", "", "", "", "", "", "", "", "", "", "", "",
852
 
861
 
853
                "", "", "", "", "", "", "", "", "", "", "", "", "",
862
                "", "", "", "", "", "", "", "", "", "", "", "", "",
854
                "", "", "", "", "", "", "", "", "", "", "", "", ""
863
                "", "", "", "", "", "", "", "", "", "", "", "", ""
855
 
864
 
856
        );
865
        );
857
 
866
 
858
        List<String> headers2 = Arrays.asList(
867
        List<String> headers2 = Arrays.asList(
859
                "Assessment","Zero billing","Billing needed","Counta",
868
                "Assessment","Zero billing","Billing needed","Counta",
860
                "Code", "Store Name", "City", "Area", "BM", "Sales Manager", "RBM", "Status", "Category",
869
                "BM","Partner Id","Code","Area",  "City", "Store Name", "Status","Category","Sales Manager", "RBM",
861
                "Secondary Target", "Secondary Achieved", "Returns", "Net Secondary", "Secondary %",
870
                "Secondary Target", "Secondary Achieved", "Returns", "Net Secondary", "Secondary %",
862
                "Tertiary Sale", "Unbilled",
871
                "Tertiary Sale", "Unbilled",
863
                "Secondary Target", "Secondary Achieved", "Returns", "Net Secondary", "Secondary %",
872
                "Secondary Target", "Secondary Achieved", "Returns", "Net Secondary", "Secondary %",
864
                "Tertiary Sale", "Unbilled",
873
                "Tertiary Sale", "Unbilled",
865
                "Secondary Target", "Secondary Achieved", "Returns", "Net Secondary", "Secondary %",
874
                "Secondary Target", "Secondary Achieved", "Returns", "Net Secondary", "Secondary %",
Line 888... Line 897...
888
            BiSecondaryModel twoAgo = monthlyData.getOrDefault(YearMonth.now().minusMonths(2), new BiSecondaryModel(0,0,0,0,0,0,0));
897
            BiSecondaryModel twoAgo = monthlyData.getOrDefault(YearMonth.now().minusMonths(2), new BiSecondaryModel(0,0,0,0,0,0,0));
889
 
898
 
890
            List<Object> row = new ArrayList<>();
899
            List<Object> row = new ArrayList<>();
891
            row.addAll(Arrays.asList(
900
            row.addAll(Arrays.asList(
892
                    assessmentMap.get(fofoId),zeroBillingMap.get(fofoId),billingNeededMap.get(fofoId),countAMap.get(fofoId),
901
                    assessmentMap.get(fofoId),zeroBillingMap.get(fofoId),billingNeededMap.get(fofoId),countAMap.get(fofoId),
893
                    retailer.getCode(), retailer.getStoreName(), retailer.getCity(), retailer.getArea(),
902
                    retailer.getBmName(),fofoId , retailer.getCode(), retailer.getArea(), retailer.getCity(),  retailer.getStoreName(), retailer.getStatus(),
894
                    retailer.getBmName(), retailer.getSalesManager(), retailer.getRbm(),
903
                    retailer.getCategory(),  retailer.getSalesManager(), retailer.getRbm()
895
                    retailer.getStatus(), retailer.getCategory()
-
 
-
 
904
 
896
            ));
905
            ));
897
 
906
 
-
 
907
 
898
            // Current Month
908
            // Two Months Ago
899
            row.addAll(Arrays.asList(
909
            row.addAll(Arrays.asList(
900
                    current.getSecondaryTarget(),
910
                    twoAgo.getSecondaryTarget(),
901
                    current.getSecondaryAchieved(),
911
                    twoAgo.getSecondaryAchieved(),
902
                    current.getSecondaryReturn(),
912
                    twoAgo.getSecondaryReturn(),
903
                    current.getNetSecondary(),
913
                    twoAgo.getNetSecondary(),
904
                    current.getSecondaryAchievedPercent(),
914
                    twoAgo.getSecondaryAchievedPercent(),
905
                    current.getTertiary(),
915
                    twoAgo.getTertiary(),
906
                    current.getTertiaryUnBilled()
916
                    twoAgo.getTertiaryUnBilled()
907
            ));
917
            ));
908
 
918
 
909
            // Last Month
919
            // Last Month
910
            row.addAll(Arrays.asList(
920
            row.addAll(Arrays.asList(
911
                    last.getSecondaryTarget(),
921
                    last.getSecondaryTarget(),
Line 915... Line 925...
915
                    last.getSecondaryAchievedPercent(),
925
                    last.getSecondaryAchievedPercent(),
916
                    last.getTertiary(),
926
                    last.getTertiary(),
917
                    last.getTertiaryUnBilled()
927
                    last.getTertiaryUnBilled()
918
            ));
928
            ));
919
 
929
 
920
            // Two Months Ago
930
            // Current Month
921
            row.addAll(Arrays.asList(
931
            row.addAll(Arrays.asList(
922
                    twoAgo.getSecondaryTarget(),
932
                    current.getSecondaryTarget(),
923
                    twoAgo.getSecondaryAchieved(),
933
                    current.getSecondaryAchieved(),
924
                    twoAgo.getSecondaryReturn(),
934
                    current.getSecondaryReturn(),
925
                    twoAgo.getNetSecondary(),
935
                    current.getNetSecondary(),
926
                    twoAgo.getSecondaryAchievedPercent(),
936
                    current.getSecondaryAchievedPercent(),
927
                    twoAgo.getTertiary(),
937
                    current.getTertiary(),
928
                    twoAgo.getTertiaryUnBilled()
938
                    current.getTertiaryUnBilled()
929
            ));
939
            ));
-
 
940
 
-
 
941
 
-
 
942
 
930
            FofoInvestmentModel fofoInvestmentModelValue = biInvestmentModelMap.get(fofoId);
943
            FofoInvestmentModel fofoInvestmentModelValue = biInvestmentModelMap.get(fofoId);
931
            if(fofoInvestmentModelValue != null){
944
            if(fofoInvestmentModelValue != null){
932
                row.addAll(Arrays.asList(
945
                row.addAll(Arrays.asList(
933
                        fofoInvestmentModelValue.getCounterPotential(),
946
                        fofoInvestmentModelValue.getCounterPotential(),
934
                        fofoInvestmentModelValue.getShortInvestment(),
947
                        fofoInvestmentModelValue.getShortInvestment(),