| Line 140... |
Line 140... |
| 140 |
|
140 |
|
| 141 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
141 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 142 |
|
142 |
|
| 143 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
143 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
| 144 |
public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
|
144 |
public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
|
| - |
|
145 |
boolean isAdmin = false;
|
| - |
|
146 |
model.addAttribute("isAdmin", isAdmin);
|
| - |
|
147 |
|
| - |
|
148 |
model.addAttribute("webApiHost", webApiHost);
|
| - |
|
149 |
model.addAttribute("webApiPort", webApiPort);
|
| - |
|
150 |
model.addAttribute("webApiScheme", webApiScheme);
|
| - |
|
151 |
model.addAttribute("webApiRoot", webApiRoot);
|
| - |
|
152 |
if (isAdmin) {
|
| 145 |
return "dashboard1";
|
153 |
return "dashboard1";
|
| - |
|
154 |
} else {
|
| - |
|
155 |
FofoStore fofoStore = null;
|
| - |
|
156 |
try {
|
| - |
|
157 |
fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| - |
|
158 |
if (!fofoStore.isActive()) {
|
| - |
|
159 |
return "redirect:/login";
|
| - |
|
160 |
}
|
| - |
|
161 |
|
| - |
|
162 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
| - |
|
163 |
model.addAttribute("partnerType", partnerType);
|
| - |
|
164 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
| - |
|
165 |
model.addAttribute("fofoStore", fofoStore);
|
| - |
|
166 |
model.addAttribute("partnerType", partnerType);
|
| - |
|
167 |
model.addAttribute("hasGift", hasGift(fofoId));
|
| - |
|
168 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| - |
|
169 |
|
| - |
|
170 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
| - |
|
171 |
model.addAttribute("salesMap", this.getSales(fofoId));
|
| - |
|
172 |
// this.setInvestments
|
| - |
|
173 |
//
|
| - |
|
174 |
model.addAttribute("investments", this.getInvestments(fofoId));
|
| - |
|
175 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(fofoId,
|
| - |
|
176 |
10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
| - |
|
177 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
178 |
LOGGER.error("FofoStore Code not found of fofoId {}", fofoId);
|
| - |
|
179 |
|
| - |
|
180 |
}
|
| - |
|
181 |
}
|
| - |
|
182 |
|
| - |
|
183 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
| - |
|
184 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
| - |
|
185 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart,
|
| - |
|
186 |
currentMonthEnd) / 2;
|
| - |
|
187 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart,
|
| - |
|
188 |
currentMonthEnd) / 2;
|
| - |
|
189 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart,
|
| - |
|
190 |
currentMonthEnd) / 2;
|
| - |
|
191 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
| - |
|
192 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
| - |
|
193 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
| - |
|
194 |
|
| - |
|
195 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(fofoId, true, currentMonthStart,
|
| - |
|
196 |
currentMonthEnd);
|
| - |
|
197 |
|
| - |
|
198 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(fofoId, false,
|
| - |
|
199 |
currentMonthStart, currentMonthEnd);
|
| - |
|
200 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
| - |
|
201 |
invalidHygieneCount = 1;
|
| - |
|
202 |
}
|
| - |
|
203 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| - |
|
204 |
|
| - |
|
205 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
| - |
|
206 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
| - |
|
207 |
return "12dashboard34";
|
| 146 |
}
|
208 |
}
|
| 147 |
|
209 |
|
| 148 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
210 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
| 149 |
Map<String, Object> investments = new LinkedHashMap<>();
|
211 |
Map<String, Object> investments = new LinkedHashMap<>();
|
| 150 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 1);
|
212 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 1);
|
| Line 233... |
Line 295... |
| 233 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
295 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
| 234 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
296 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 235 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
297 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 236 |
model.addAttribute("isAdmin", isAdmin);
|
298 |
model.addAttribute("isAdmin", isAdmin);
|
| 237 |
|
299 |
|
| 238 |
FofoStore fofoStore = null;
|
- |
|
| 239 |
model.addAttribute("webApiHost", webApiHost);
|
300 |
model.addAttribute("webApiHost", webApiHost);
|
| 240 |
model.addAttribute("webApiPort", webApiPort);
|
301 |
model.addAttribute("webApiPort", webApiPort);
|
| 241 |
model.addAttribute("webApiScheme", webApiScheme);
|
302 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 242 |
model.addAttribute("webApiRoot", webApiRoot);
|
303 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 243 |
if (isAdmin) {
|
304 |
if (isAdmin) {
|
| 244 |
return "dashboard1";
|
305 |
return "dashboard1";
|
| 245 |
} else {
|
306 |
} else {
|
| - |
|
307 |
FofoStore fofoStore = null;
|
| 246 |
try {
|
308 |
try {
|
| 247 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
309 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 248 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
- |
|
| 249 |
if (!fofoStore.isActive()) {
|
310 |
if (!fofoStore.isActive()) {
|
| 250 |
return "redirect:/login";
|
311 |
return "redirect:/login";
|
| 251 |
}
|
312 |
}
|
| 252 |
|
313 |
|
| 253 |
LOGGER.info("partnerType {}", partnerType);
|
314 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
| 254 |
|
- |
|
| 255 |
model.addAttribute("partnerType", partnerType);
|
315 |
model.addAttribute("partnerType", partnerType);
|
| 256 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
316 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
| 257 |
model.addAttribute("fofoStore", fofoStore);
|
317 |
model.addAttribute("fofoStore", fofoStore);
|
| 258 |
model.addAttribute("partnerType", partnerType);
|
318 |
model.addAttribute("partnerType", partnerType);
|
| 259 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
319 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|