Subversion Repositories SmartDukaan

Rev

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

Rev 32430 Rev 32435
Line 34... Line 34...
34
import java.util.stream.Collectors;
34
import java.util.stream.Collectors;
35
 
35
 
36
@Component
36
@Component
37
public class PartnerStatsServiceImpl implements PartnerStatsService {
37
public class PartnerStatsServiceImpl implements PartnerStatsService {
38
 
38
 
39
	private static final Logger LOGGER = LogManager.getLogger(PartnerStatsServiceImpl.class);
39
    private static final Logger LOGGER = LogManager.getLogger(PartnerStatsServiceImpl.class);
40
 
40
 
41
	@Autowired
41
    @Autowired
42
	RetailerService retailerService;
42
    RetailerService retailerService;
43
 
43
 
44
	@Autowired
44
    @Autowired
45
	FofoStoreRepository fofoStoreRepository;
45
    FofoStoreRepository fofoStoreRepository;
46
 
46
 
47
	@Autowired
47
    @Autowired
48
	FofoOrderItemRepository fofoOrderItemRepository;
48
    FofoOrderItemRepository fofoOrderItemRepository;
49
 
49
 
50
	@Autowired
50
    @Autowired
51
	CsService csService;
51
    CsService csService;
52
 
52
 
53
	@Autowired
53
    @Autowired
54
	TicketRepository ticketRepository;
54
    TicketRepository ticketRepository;
55
 
55
 
56
	@Autowired
56
    @Autowired
57
	PartnerInvestmentService partnerInvestmentService;
57
    PartnerInvestmentService partnerInvestmentService;
58
 
58
 
59
	@Autowired
59
    @Autowired
60
	HygieneDataRepository hygieneDataRepository;
60
    HygieneDataRepository hygieneDataRepository;
61
 
61
 
62
	@Autowired
62
    @Autowired
63
	UserWalletRepository userWalletRepository;
63
    UserWalletRepository userWalletRepository;
64
 
64
 
65
	@Autowired
65
    @Autowired
66
	PartnerTypeChangeService partnerTypeChangeService;
66
    PartnerTypeChangeService partnerTypeChangeService;
67
 
67
 
68
	@Autowired
68
    @Autowired
69
	OrderRepository orderRepository;
69
    OrderRepository orderRepository;
70
 
70
 
71
	@Autowired
71
    @Autowired
72
	AuthRepository authRepository;
72
    AuthRepository authRepository;
73
 
73
 
74
	@Autowired
74
    @Autowired
75
	PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
75
    PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
76
 
76
 
77
	@Autowired
77
    @Autowired
78
	PositionRepository positionRepository;
78
    PositionRepository positionRepository;
79
 
79
 
80
	@Override
80
    @Override
81
	// @Cacheable(value = "partnerStats", cacheManager =
81
    // @Cacheable(value = "partnerStats", cacheManager =
82
	// "thirtyMinsTimeOutCacheManager")
82
    // "thirtyMinsTimeOutCacheManager")
83
	public Map<Integer, PartnerDetailModel> getAllPartnerStats() throws ProfitMandiBusinessException {
83
    public Map<Integer, PartnerDetailModel> getAllPartnerStats() throws ProfitMandiBusinessException {
84
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
84
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
85
		Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
85
        Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
86
				curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
86
                curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
87
 
87
 
88
		Map<Integer, Double> mtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1),
88
        Map<Integer, Double> mtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1),
89
				curDate.with(LocalTime.MAX), 0, false);
89
                curDate.with(LocalTime.MAX), 0, false);
90
 
90
 
91
		Map<Integer, Double> lmsSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
91
        Map<Integer, Double> lmsSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
92
				curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), 0, false);
92
                curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), 0, false);
93
 
93
 
94
		Map<Integer, Double> todaytertiary = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate,
94
        Map<Integer, Double> todaytertiary = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate,
95
				curDate.with(LocalTime.MAX), 0, false);
95
                curDate.with(LocalTime.MAX), 0, false);
96
 
96
 
97
		Map<Integer, Long> last3daystertiary = fofoOrderItemRepository.selectQtyGroupByRetailer(curDate.minusDays(4),
97
        Map<Integer, Long> last3daystertiary = fofoOrderItemRepository.selectQtyGroupByRetailer(curDate.minusDays(4),
98
				curDate.minusDays(1).with(LocalTime.MAX), 0, false);
98
                curDate.minusDays(1).with(LocalTime.MAX), 0, false);
99
 
99
 
100
		Map<Integer, Long> ticketMap = ticketRepository.selectAllOpenTicketsGroupByRetailer();
100
        Map<Integer, Long> ticketMap = ticketRepository.selectAllOpenTicketsGroupByRetailer();
101
 
101
 
102
		Map<Integer, Double> secondaryMtd = orderRepository
102
        Map<Integer, Double> secondaryMtd = orderRepository
103
				.selectBillingDatesBetweenSumGroupByRetailerId(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
103
                .selectBillingDatesBetweenSumGroupByRetailerId(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
104
		Map<Integer, Double> secondarylmtd = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
104
        Map<Integer, Double> secondarylmtd = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
105
				curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1));
105
                curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1));
106
		Map<Integer, Double> secondarylms = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
106
        Map<Integer, Double> secondarylms = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
107
				curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1));
107
                curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1));
108
 
108
 
109
		LOGGER.info("secondarylmtd" + secondarylmtd);
109
        LOGGER.info("secondarylmtd" + secondarylmtd);
110
		LOGGER.info("secondarylms" + secondarylms);
110
        LOGGER.info("secondarylms" + secondarylms);
111
		List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
111
        List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
112
		Set<Integer> fofoIds = fofoStores.stream().filter(x->!x.isInternal()).map(x -> x.getId()).collect(Collectors.toSet());
112
        Set<Integer> fofoIds = fofoStores.stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toSet());
113
		Map<Integer, UserWallet> userWallet = userWalletRepository.selectByRetailerIds(fofoIds).stream()
113
        Map<Integer, UserWallet> userWallet = userWalletRepository.selectByRetailerIds(fofoIds).stream()
114
				.collect(Collectors.toMap(x -> x.getUserId(), x -> x));
114
                .collect(Collectors.toMap(x -> x.getUserId(), x -> x));
115
 
115
 
116
		Map<Integer, PartnerDetailModel> allPartnerStats = new HashMap<>();
116
        Map<Integer, PartnerDetailModel> allPartnerStats = new HashMap<>();
117
 
117
 
118
		List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
118
        List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
119
				.selectAll(curDate.withDayOfMonth(1).toLocalDate(), curDate.toLocalDate());
119
                .selectAll(curDate.withDayOfMonth(1).toLocalDate(), curDate.toLocalDate());
120
		Map<Integer, Long> investmentMaintainedDaysMap = partnerDailyInvestments.stream()
120
        Map<Integer, Long> investmentMaintainedDaysMap = partnerDailyInvestments.stream()
121
				.filter(x -> x.getShortPercentage() <= 10)
121
                .filter(x -> x.getShortPercentage() <= 10)
122
				.collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
122
                .collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
123
 
123
 
124
		LOGGER.info("investmentMaintainedDaysMap" + investmentMaintainedDaysMap);
124
        LOGGER.info("investmentMaintainedDaysMap" + investmentMaintainedDaysMap);
125
 
125
 
126
		Map<Integer, PartnerDailyInvestment> investmentMap = fofoStores.stream().map(x -> {
126
        Map<Integer, PartnerDailyInvestment> investmentMap = fofoStores.stream().map(x -> {
127
			try {
127
            try {
128
				return partnerInvestmentService.getInvestment(x.getId(), 0);
128
                return partnerInvestmentService.getInvestment(x.getId(), 0);
129
			} catch (Exception e) {
129
            } catch (Exception e) {
130
				LOGGER.info("Could not get invetment summary for {}", x);
130
                LOGGER.info("Could not get invetment summary for {}", x);
131
				return new PartnerDailyInvestment();
131
                return new PartnerDailyInvestment();
132
			}
132
            }
133
		}).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
133
        }).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
134
 
134
 
135
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM), true);
135
        Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM), true);
136
		Map<Integer, AuthUser> authUserMap = authRepository.selectAllAuthUserByIds(storeGuyMap.values().stream().flatMap(x->x.stream()).filter(Utils.distinctByKey(x->x)).collect(Collectors.toList())).stream().collect(Collectors.toMap(x->x.getId(),x->x));
136
        Map<String, AuthUser> authUserMap = authRepository.selectAll().stream().filter(x -> storeGuyMap.keySet().contains(x.getEmailId())).collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
137
 
137
        Map<Integer, Set<AuthUser>> partnerRbmsMap = new HashMap<>();
138
		Set<Integer> l1Rbms = positionRepository.selectPositionbyCategoryIdAndEscalationType(
138
        for (Map.Entry<String, Set<Integer>> storeGuySetEntry : storeGuyMap.entrySet()) {
139
				ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1).stream().map(x -> x.getAuthUserId()).collect(Collectors.toSet());
139
            //store
140
 
140
            for (Integer storeId : storeGuySetEntry.getValue()) {
141
		for (FofoStore store : fofoStores) {
141
                if (!partnerRbmsMap.containsKey(storeId)) {
142
			int fofoId = store.getId();
142
                    partnerRbmsMap.put(storeId, new HashSet<>());
143
 
143
                }
144
			int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
144
                partnerRbmsMap.get(storeId).add(authUserMap.get(storeGuySetEntry.getKey()));
145
					curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
145
            }
146
			int invalidHygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
146
        }
147
					curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
147
 
148
			int totalHygieneCount = hygieneCount + invalidHygieneCount;
148
        Set<Integer> l1Rbms = positionRepository.selectPositionbyCategoryIdAndEscalationType(
149
			PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
149
                ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1).stream().map(x -> x.getAuthUserId()).collect(Collectors.toSet());
150
 
150
        Set<Integer> l2Rbms = positionRepository.selectPositionbyCategoryIdAndEscalationType(
151
			Map<EscalationType, AuthUser> authuserEsclationTypeMap = csService
151
                ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L2).stream().map(x -> x.getAuthUserId()).collect(Collectors.toSet());
152
					.getAuthUserAndEsclationByPartnerId(fofoId);
152
 
153
			PartnerDetailModel pm = new PartnerDetailModel();
153
        for (FofoStore store : fofoStores) {
154
			pm.setFofoId(fofoId);
154
            int fofoId = store.getId();
155
			pm.setLmtd(lmtdSale.get(fofoId) == null ? 0 : lmtdSale.get(fofoId).intValue());
155
 
156
			pm.setMtd(mtdSale.get(fofoId) == null ? 0 : mtdSale.get(fofoId).intValue());
156
            int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
157
			pm.setLms(lmsSale.get(fofoId) == null ? 0 : lmsSale.get(fofoId).intValue());
157
                    curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
158
			pm.setSecondarymtd(secondaryMtd.get(fofoId) == null ? 0 : secondaryMtd.get(fofoId).intValue());
158
            int invalidHygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
159
			pm.setSecondarylmtd(secondarylmtd.get(fofoId) == null ? 0 : secondarylmtd.get(fofoId).intValue());
159
                    curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
160
			pm.setSecondarylms(secondarylms.get(fofoId) == null ? 0 : secondarylms.get(fofoId).intValue());
160
            int totalHygieneCount = hygieneCount + invalidHygieneCount;
161
			pm.setTodayTertiary(todaytertiary.get(fofoId) == null ? 0 : todaytertiary.get(fofoId).intValue());
161
            PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
162
			pm.setLastThreeDaytertiary(last3daystertiary.get(fofoId) == null ? 0 : last3daystertiary.get(fofoId));
162
 
163
			pm.setWalletAmount(userWallet.get(fofoId) == null ? 0 : userWallet.get(fofoId).getAmount());
163
            Map<EscalationType, AuthUser> authuserEsclationTypeMap = csService
164
			pm.setInvestment(investmentMap.get(fofoId));
164
                    .getAuthUserAndEsclationByPartnerId(fofoId);
165
			pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
165
            PartnerDetailModel pm = new PartnerDetailModel();
166
			pm.setHygiene(hygieneCount);
166
            pm.setFofoId(fofoId);
167
			pm.setInvestment_ok(
167
            pm.setLmtd(lmtdSale.get(fofoId) == null ? 0 : lmtdSale.get(fofoId).intValue());
168
					investmentMaintainedDaysMap.get(fofoId) == null ? 0 : investmentMaintainedDaysMap.get(fofoId));
168
            pm.setMtd(mtdSale.get(fofoId) == null ? 0 : mtdSale.get(fofoId).intValue());
169
			pm.setPartnerType(partnerType);
169
            pm.setLms(lmsSale.get(fofoId) == null ? 0 : lmsSale.get(fofoId).intValue());
170
			if (authuserEsclationTypeMap.get(EscalationType.L1) != null) {
170
            pm.setSecondarymtd(secondaryMtd.get(fofoId) == null ? 0 : secondaryMtd.get(fofoId).intValue());
171
				pm.setAuthUser(authuserEsclationTypeMap.get(EscalationType.L1).getName());
171
            pm.setSecondarylmtd(secondarylmtd.get(fofoId) == null ? 0 : secondarylmtd.get(fofoId).intValue());
172
			} else if (authuserEsclationTypeMap.get(EscalationType.L2) != null) {
172
            pm.setSecondarylms(secondarylms.get(fofoId) == null ? 0 : secondarylms.get(fofoId).intValue());
173
				pm.setAuthUser(authuserEsclationTypeMap.get(EscalationType.L2).getName());
173
            pm.setTodayTertiary(todaytertiary.get(fofoId) == null ? 0 : todaytertiary.get(fofoId).intValue());
174
			} else if (authuserEsclationTypeMap.get(EscalationType.L3) != null) {
174
            pm.setLastThreeDaytertiary(last3daystertiary.get(fofoId) == null ? 0 : last3daystertiary.get(fofoId));
175
				pm.setAuthUser(authuserEsclationTypeMap.get(EscalationType.L3).getName());
175
            pm.setWalletAmount(userWallet.get(fofoId) == null ? 0 : userWallet.get(fofoId).getAmount());
176
			} else if (authuserEsclationTypeMap.get(EscalationType.L4) != null) {
176
            pm.setInvestment(investmentMap.get(fofoId));
177
				pm.setAuthUser(authuserEsclationTypeMap.get(EscalationType.L4).getName());
177
            pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
178
			} else {
178
            pm.setHygiene(hygieneCount);
179
				pm.setAuthUser(" - ");
179
            pm.setInvestment_ok(
180
			}
180
                    investmentMaintainedDaysMap.get(fofoId) == null ? 0 : investmentMaintainedDaysMap.get(fofoId));
181
			pm.setTotalHygiene(totalHygieneCount);
181
            pm.setPartnerType(partnerType);
182
 
182
            if (authuserEsclationTypeMap.get(EscalationType.L1) != null) {
183
			pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
183
                pm.setAuthUser(authuserEsclationTypeMap.get(EscalationType.L1).getName());
184
			Set<Integer> rbmUserIds = storeGuyMap.get(fofoId);
184
            } else if (authuserEsclationTypeMap.get(EscalationType.L2) != null) {
185
			if (rbmUserIds == null || rbmUserIds.stream().noneMatch(x -> l1Rbms.contains(x))) {
185
                pm.setAuthUser(authuserEsclationTypeMap.get(EscalationType.L2).getName());
186
				pm.setRbms("-");
186
            } else if (authuserEsclationTypeMap.get(EscalationType.L3) != null) {
187
			} else {
187
                pm.setAuthUser(authuserEsclationTypeMap.get(EscalationType.L3).getName());
188
				rbmUserIds = rbmUserIds.stream().filter(x -> l1Rbms.contains(x)).collect(Collectors.toSet());
188
            } else if (authuserEsclationTypeMap.get(EscalationType.L4) != null) {
189
				String commaSeperatedRbms = rbmUserIds.stream().map(x->authUserMap.get(x).getFullName()).collect(Collectors.joining(","));
189
                pm.setAuthUser(authuserEsclationTypeMap.get(EscalationType.L4).getName());
190
				pm.setRbms(commaSeperatedRbms);
190
            } else {
191
			}
191
                pm.setAuthUser(" - ");
192
			allPartnerStats.put(fofoId, pm);
192
            }
193
			LOGGER.info("pm {}", pm);
193
            pm.setTotalHygiene(totalHygieneCount);
194
 
194
 
195
		}
195
            pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
196
		return allPartnerStats;
196
            Set<AuthUser> rbmAuths = partnerRbmsMap.get(fofoId);
197
	}
197
            if (rbmAuths == null) {
198
 
198
                pm.setRbms("-");
199
	@Override
199
            } else {
200
	// @Cacheable(value = "partnerAggregateStats", cacheManager =
200
                pm.setRbms(rbmAuths.stream().filter(x -> l1Rbms.contains(x.getId())).map(x -> x.getFullName()).collect(Collectors.joining(",")));
201
	// "oneDayCacheManager")
201
                if (pm.getRbms().equals("")) {
202
	public PartnerDetailModel getAggregateStats(List<PartnerDetailModel> partnerDetailModels)
202
                    pm.setRbms(rbmAuths.stream().filter(x -> l2Rbms.contains(x.getId())).map(x -> x.getFullName()).collect(Collectors.joining(",")));
203
			throws ProfitMandiBusinessException {
203
                }
204
		PartnerDetailModel pdm = new PartnerDetailModel();
204
                if (pm.getRbms().equals("")) {
205
		PartnerDailyInvestment aggregateInvestment = new PartnerDailyInvestment();
205
                    pm.setRbms("-");
206
		pdm.setInvestment(aggregateInvestment);
206
                }
207
		double totallmsAmount = 0;
207
            }
208
		double totallmtdAmount = 0;
208
            allPartnerStats.put(fofoId, pm);
209
		double totalmtdAmount = 0;
209
            LOGGER.info("pm {}", pm);
210
		double totalTodayTertiary = 0;
210
 
211
		int totalTicketCount = 0;
211
        }
212
 
212
        return allPartnerStats;
213
		int currentHygieneCount = 0;
213
    }
214
		int currentTotalHygieneCount = 0;
214
 
215
		if (partnerDetailModels != null && !partnerDetailModels.isEmpty()) {
215
    @Override
216
			for (PartnerDetailModel partnerDetailModel : partnerDetailModels) {
216
    // @Cacheable(value = "partnerAggregateStats", cacheManager =
217
				if (partnerDetailModel != null) {
217
    // "oneDayCacheManager")
218
					PartnerDailyInvestment pdi = partnerDetailModel.getInvestment();
218
    public PartnerDetailModel getAggregateStats(List<PartnerDetailModel> partnerDetailModels)
219
					totallmsAmount += partnerDetailModel.getLms();
219
            throws ProfitMandiBusinessException {
220
					totallmtdAmount += partnerDetailModel.getLmtd();
220
        PartnerDetailModel pdm = new PartnerDetailModel();
221
					totalmtdAmount += partnerDetailModel.getMtd();
221
        PartnerDailyInvestment aggregateInvestment = new PartnerDailyInvestment();
222
					totalTicketCount += partnerDetailModel.getTicket();
222
        pdm.setInvestment(aggregateInvestment);
223
					totalTodayTertiary += partnerDetailModel.getTodayTertiary();
223
        double totallmsAmount = 0;
224
					currentHygieneCount += partnerDetailModel.getHygiene();
224
        double totallmtdAmount = 0;
225
					currentTotalHygieneCount += partnerDetailModel.getTotalHygiene();
225
        double totalmtdAmount = 0;
226
					if (pdi != null) {
226
        double totalTodayTertiary = 0;
227
						aggregateInvestment.setActivatedStockAmount(
227
        int totalTicketCount = 0;
228
								aggregateInvestment.getActivatedStockAmount() + pdi.getActivatedStockAmount());
228
 
229
						aggregateInvestment.setGrnPendingAmount(
229
        int currentHygieneCount = 0;
230
								aggregateInvestment.getGrnPendingAmount() + pdi.getGrnPendingAmount());
230
        int currentTotalHygieneCount = 0;
231
						aggregateInvestment
231
        if (partnerDetailModels != null && !partnerDetailModels.isEmpty()) {
232
								.setInStockAmount(aggregateInvestment.getInStockAmount() + pdi.getInStockAmount());
232
            for (PartnerDetailModel partnerDetailModel : partnerDetailModels) {
233
						aggregateInvestment.setReturnInTransitAmount(
233
                if (partnerDetailModel != null) {
234
								aggregateInvestment.getReturnInTransitAmount() + pdi.getReturnInTransitAmount());
234
                    PartnerDailyInvestment pdi = partnerDetailModel.getInvestment();
235
						aggregateInvestment.setSalesAmount(aggregateInvestment.getSalesAmount() + pdi.getSalesAmount());
235
                    totallmsAmount += partnerDetailModel.getLms();
236
						aggregateInvestment
236
                    totallmtdAmount += partnerDetailModel.getLmtd();
237
								.setUnbilledAmount(aggregateInvestment.getUnbilledAmount() + pdi.getUnbilledAmount());
237
                    totalmtdAmount += partnerDetailModel.getMtd();
238
						aggregateInvestment
238
                    totalTicketCount += partnerDetailModel.getTicket();
239
								.setWalletAmount(aggregateInvestment.getWalletAmount() + pdi.getWalletAmount());
239
                    totalTodayTertiary += partnerDetailModel.getTodayTertiary();
240
					}
240
                    currentHygieneCount += partnerDetailModel.getHygiene();
241
				}
241
                    currentTotalHygieneCount += partnerDetailModel.getTotalHygiene();
242
 
242
                    if (pdi != null) {
243
				pdm.setHygiene(currentHygieneCount);
243
                        aggregateInvestment.setActivatedStockAmount(
244
				pdm.setTotalHygiene(currentTotalHygieneCount);
244
                                aggregateInvestment.getActivatedStockAmount() + pdi.getActivatedStockAmount());
245
				pdm.setLms((int) totallmsAmount);
245
                        aggregateInvestment.setGrnPendingAmount(
246
				pdm.setLmtd((int) totallmtdAmount);
246
                                aggregateInvestment.getGrnPendingAmount() + pdi.getGrnPendingAmount());
247
				pdm.setMtd((int) totalmtdAmount);
247
                        aggregateInvestment
248
				pdm.setTicket((int) totalTicketCount);
248
                                .setInStockAmount(aggregateInvestment.getInStockAmount() + pdi.getInStockAmount());
249
				pdm.setTodayTertiary((int) totalTodayTertiary);
249
                        aggregateInvestment.setReturnInTransitAmount(
250
				pdm.setCount(partnerDetailModels.size());
250
                                aggregateInvestment.getReturnInTransitAmount() + pdi.getReturnInTransitAmount());
251
			}
251
                        aggregateInvestment.setSalesAmount(aggregateInvestment.getSalesAmount() + pdi.getSalesAmount());
252
		}
252
                        aggregateInvestment
253
		return pdm;
253
                                .setUnbilledAmount(aggregateInvestment.getUnbilledAmount() + pdi.getUnbilledAmount());
254
	}
254
                        aggregateInvestment
-
 
255
                                .setWalletAmount(aggregateInvestment.getWalletAmount() + pdi.getWalletAmount());
-
 
256
                    }
-
 
257
                }
-
 
258
 
-
 
259
                pdm.setHygiene(currentHygieneCount);
-
 
260
                pdm.setTotalHygiene(currentTotalHygieneCount);
-
 
261
                pdm.setLms((int) totallmsAmount);
-
 
262
                pdm.setLmtd((int) totallmtdAmount);
-
 
263
                pdm.setMtd((int) totalmtdAmount);
-
 
264
                pdm.setTicket((int) totalTicketCount);
-
 
265
                pdm.setTodayTertiary((int) totalTodayTertiary);
-
 
266
                pdm.setCount(partnerDetailModels.size());
-
 
267
            }
-
 
268
        }
-
 
269
        return pdm;
-
 
270
    }
255
 
271
 
256
}
272
}