Subversion Repositories SmartDukaan

Rev

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

Rev 31569 Rev 32421
Line 1... Line 1...
1
package com.spice.profitmandi.service;
1
package com.spice.profitmandi.service;
2
 
2
 
3
import java.time.LocalDate;
3
import java.time.LocalDate;
4
import java.time.LocalDateTime;
4
import java.time.LocalDateTime;
5
import java.time.LocalTime;
5
import java.time.LocalTime;
6
import java.util.HashMap;
-
 
7
import java.util.List;
-
 
8
import java.util.Map;
-
 
9
import java.util.Set;
6
import java.util.*;
10
import java.util.stream.Collectors;
7
import java.util.stream.Collectors;
11
 
8
 
-
 
9
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
10
import com.spice.profitmandi.common.util.Utils;
-
 
11
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
12
import org.apache.logging.log4j.LogManager;
12
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
13
import org.apache.logging.log4j.Logger;
14
import org.springframework.beans.factory.annotation.Autowired;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.stereotype.Component;
15
import org.springframework.stereotype.Component;
16
 
16
 
Line 67... Line 67...
67
 
67
 
68
	@Autowired
68
	@Autowired
69
	OrderRepository orderRepository;
69
	OrderRepository orderRepository;
70
 
70
 
71
	@Autowired
71
	@Autowired
-
 
72
	AuthRepository authRepository;
-
 
73
 
-
 
74
	@Autowired
72
	PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
75
	PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
73
 
76
 
74
	@Override
77
	@Override
75
	// @Cacheable(value = "partnerStats", cacheManager =
78
	// @Cacheable(value = "partnerStats", cacheManager =
76
	// "thirtyMinsTimeOutCacheManager")
79
	// "thirtyMinsTimeOutCacheManager")
Line 124... Line 127...
124
				LOGGER.info("Could not get invetment summary for {}", x);
127
				LOGGER.info("Could not get invetment summary for {}", x);
125
				return new PartnerDailyInvestment();
128
				return new PartnerDailyInvestment();
126
			}
129
			}
127
		}).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
130
		}).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
128
 
131
 
-
 
132
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM), true);
-
 
133
		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));
-
 
134
 
129
		for (FofoStore store : fofoStores) {
135
		for (FofoStore store : fofoStores) {
130
			int fofoId = store.getId();
136
			int fofoId = store.getId();
-
 
137
 
131
			int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
138
			int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
132
					curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
139
					curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
133
			int invalidHygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
140
			int invalidHygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
134
					curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
141
					curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
135
			int totalHygieneCount = hygieneCount + invalidHygieneCount;
142
			int totalHygieneCount = hygieneCount + invalidHygieneCount;
Line 166... Line 173...
166
				pm.setAuthUser(" - ");
173
				pm.setAuthUser(" - ");
167
			}
174
			}
168
			pm.setTotalHygiene(totalHygieneCount);
175
			pm.setTotalHygiene(totalHygieneCount);
169
 
176
 
170
			pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
177
			pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
-
 
178
			Set<Integer> rbmUserIds = storeGuyMap.get(fofoId);
-
 
179
			if(rbmUserIds != null) {
-
 
180
				pm.setRbms("-");
-
 
181
			} else {
-
 
182
				String commaSeperatedRbms = rbmUserIds.stream().map(x->authUserMap.get(x).getFullName()).collect(Collectors.joining(","));
-
 
183
				pm.setRbms(commaSeperatedRbms);
-
 
184
			}
171
			allPartnerStats.put(fofoId, pm);
185
			allPartnerStats.put(fofoId, pm);
172
			LOGGER.info("pm {}", pm);
186
			LOGGER.info("pm {}", pm);
173
 
187
 
174
		}
188
		}
175
		return allPartnerStats;
189
		return allPartnerStats;