| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.File;
|
3 |
import java.io.File;
|
| 4 |
import java.io.FileInputStream;
|
4 |
import java.io.FileInputStream;
|
| 5 |
import java.io.FileNotFoundException;
|
5 |
import java.io.FileNotFoundException;
|
| 6 |
import java.text.DecimalFormat;
|
- |
|
| 7 |
import java.time.LocalDate;
|
6 |
import java.time.LocalDate;
|
| 8 |
import java.time.LocalDateTime;
|
7 |
import java.time.LocalDateTime;
|
| 9 |
import java.time.LocalTime;
|
8 |
import java.time.LocalTime;
|
| 10 |
import java.time.ZoneOffset;
|
9 |
import java.time.ZoneOffset;
|
| 11 |
import java.util.ArrayList;
|
10 |
import java.util.ArrayList;
|
| Line 22... |
Line 21... |
| 22 |
import org.springframework.beans.factory.annotation.Autowired;
|
21 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23 |
import org.springframework.beans.factory.annotation.Value;
|
22 |
import org.springframework.beans.factory.annotation.Value;
|
| 24 |
import org.springframework.core.io.InputStreamResource;
|
23 |
import org.springframework.core.io.InputStreamResource;
|
| 25 |
import org.springframework.http.HttpHeaders;
|
24 |
import org.springframework.http.HttpHeaders;
|
| 26 |
import org.springframework.http.HttpStatus;
|
25 |
import org.springframework.http.HttpStatus;
|
| 27 |
import org.springframework.http.MediaType;
|
- |
|
| 28 |
import org.springframework.http.ResponseEntity;
|
26 |
import org.springframework.http.ResponseEntity;
|
| 29 |
import org.springframework.stereotype.Controller;
|
27 |
import org.springframework.stereotype.Controller;
|
| 30 |
import org.springframework.ui.Model;
|
28 |
import org.springframework.ui.Model;
|
| 31 |
import org.springframework.web.bind.annotation.RequestMapping;
|
29 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 32 |
import org.springframework.web.bind.annotation.RequestMethod;
|
30 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 33 |
import org.springframework.web.bind.annotation.RequestParam;
|
31 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 34 |
|
32 |
|
| 35 |
import com.google.gson.Gson;
|
33 |
import com.google.gson.Gson;
|
| 36 |
import com.mongodb.DBObject;
|
- |
|
| 37 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
34 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| 38 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
35 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 39 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
- |
|
| 40 |
import com.spice.profitmandi.common.model.Notification;
|
36 |
import com.spice.profitmandi.common.model.Notification;
|
| 41 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
37 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 42 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
- |
|
| 43 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
38 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 44 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
39 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
| 45 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
40 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 46 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
41 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| 47 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
- |
|
| 48 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
42 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
| 49 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
- |
|
| 50 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
43 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 51 |
import com.spice.profitmandi.dao.entity.fofo.HygieneData;
|
- |
|
| 52 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
44 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 53 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTarget;
|
- |
|
| 54 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
45 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 55 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
46 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 56 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
47 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
| 57 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
48 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 58 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
- |
|
| 59 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
49 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 60 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
50 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
- |
|
| 62 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
- |
|
| 63 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
51 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 64 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
52 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
| 65 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
- |
|
| 66 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
- |
|
| 67 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
53 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 68 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
54 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
| 69 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
55 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 70 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
56 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 71 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
57 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| 72 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
58 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 73 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
59 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| 74 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
60 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 75 |
import com.spice.profitmandi.dao.repository.fofo.TargetSlabRepository;
|
- |
|
| 76 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
- |
|
| 77 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
61 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 78 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
62 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 79 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
- |
|
| 80 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
- |
|
| 81 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
- |
|
| 82 |
import com.spice.profitmandi.web.model.LoginDetails;
|
63 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 83 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
64 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 84 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
- |
|
| 85 |
|
65 |
|
| 86 |
@Controller
|
66 |
@Controller
|
| 87 |
@Transactional(rollbackOn = Throwable.class)
|
67 |
@Transactional(rollbackOn = Throwable.class)
|
| 88 |
public class DashboardController {
|
68 |
public class DashboardController {
|
| 89 |
|
69 |
|
| Line 101... |
Line 81... |
| 101 |
|
81 |
|
| 102 |
@Autowired
|
82 |
@Autowired
|
| 103 |
private CookiesProcessor cookiesProcessor;
|
83 |
private CookiesProcessor cookiesProcessor;
|
| 104 |
|
84 |
|
| 105 |
@Autowired
|
85 |
@Autowired
|
| 106 |
private ResponseSender<?> responseSender;
|
- |
|
| 107 |
|
- |
|
| 108 |
@Autowired
|
- |
|
| 109 |
private ItemRepository itemRepository;
|
- |
|
| 110 |
|
- |
|
| 111 |
@Autowired
|
- |
|
| 112 |
private TargetSlabService targetSlabService;
|
- |
|
| 113 |
|
- |
|
| 114 |
@Autowired
|
- |
|
| 115 |
private PartnerTargetRepository partnerTargetRepository;
|
86 |
private PartnerTargetRepository partnerTargetRepository;
|
| 116 |
|
87 |
|
| 117 |
@Autowired
|
88 |
@Autowired
|
| 118 |
private TargetSlabRepository targetSlabRepository;
|
89 |
private ResponseSender<?> responseSender;
|
| 119 |
|
90 |
|
| 120 |
@Autowired
|
91 |
@Autowired
|
| 121 |
private RoleManager roleManager;
|
92 |
private RoleManager roleManager;
|
| 122 |
|
93 |
|
| 123 |
@Autowired
|
94 |
@Autowired
|
| Line 128... |
Line 99... |
| 128 |
|
99 |
|
| 129 |
@Autowired
|
100 |
@Autowired
|
| 130 |
private PartnerInvestmentService partnerInvestmentService;
|
101 |
private PartnerInvestmentService partnerInvestmentService;
|
| 131 |
|
102 |
|
| 132 |
@Autowired
|
103 |
@Autowired
|
| 133 |
private InsurancePolicyRepository insurancePolicyRepository;
|
- |
|
| 134 |
/*
|
- |
|
| 135 |
* @Autowired private ScanRepository scanRepository;
|
104 |
DocumentRepository documentRepository;
|
| 136 |
*/
|
- |
|
| 137 |
@Autowired
|
- |
|
| 138 |
private RechargeTransactionRepository rechargeTransactionRepository;
|
- |
|
| 139 |
|
- |
|
| 140 |
@Autowired
|
- |
|
| 141 |
private TransactionService transactionService;
|
- |
|
| 142 |
|
- |
|
| 143 |
@Autowired
|
- |
|
| 144 |
private InventoryService inventoryService;
|
- |
|
| 145 |
|
- |
|
| 146 |
@Autowired
|
- |
|
| 147 |
private MVCResponseSender mvcResponseSender;
|
- |
|
| 148 |
|
- |
|
| 149 |
@Autowired
|
- |
|
| 150 |
private NotificationPanelRepository notificationPanelRepository;
|
- |
|
| 151 |
|
105 |
|
| 152 |
@Autowired
|
106 |
@Autowired
|
| 153 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
107 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 154 |
|
108 |
|
| 155 |
@Autowired
|
109 |
@Autowired
|
| 156 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
110 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 157 |
|
111 |
|
| 158 |
@Autowired
|
112 |
@Autowired
|
| 159 |
private InsuranceProviderRepository insuranceProviderRepository;
|
- |
|
| 160 |
@Autowired
|
- |
|
| 161 |
private PartnerTypeChangeService partnerTypeChangeService;
|
113 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 162 |
|
114 |
|
| 163 |
@Autowired
|
115 |
@Autowired
|
| 164 |
private HygieneDataRepository hygieneDataRepository;
|
116 |
private HygieneDataRepository hygieneDataRepository;
|
| 165 |
|
117 |
|
| Line 171... |
Line 123... |
| 171 |
|
123 |
|
| 172 |
@Autowired
|
124 |
@Autowired
|
| 173 |
private NotificationCampaignRepository notificationCampaignRepository;
|
125 |
private NotificationCampaignRepository notificationCampaignRepository;
|
| 174 |
|
126 |
|
| 175 |
@Autowired
|
127 |
@Autowired
|
| 176 |
private DocumentRepository documentRepository;
|
- |
|
| 177 |
|
- |
|
| 178 |
@Autowired
|
- |
|
| 179 |
private Mongo mongoClient;
|
128 |
private Mongo mongoClient;
|
| 180 |
|
129 |
|
| 181 |
@Autowired
|
130 |
@Autowired
|
| 182 |
private Gson gson;
|
131 |
private Gson gson;
|
| 183 |
|
132 |
|
| Line 222... |
Line 171... |
| 222 |
investments.put("okDays", okInvestmentDays);
|
171 |
investments.put("okDays", okInvestmentDays);
|
| 223 |
return investments;
|
172 |
return investments;
|
| 224 |
}
|
173 |
}
|
| 225 |
|
174 |
|
| 226 |
private Map<String, Object> getSales(int fofoId) {
|
175 |
private Map<String, Object> getSales(int fofoId) {
|
| - |
|
176 |
|
| 227 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
177 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| 228 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
178 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 229 |
int monthLength = LocalDate.now().lengthOfMonth();
|
179 |
int monthLength = LocalDate.now().lengthOfMonth();
|
| 230 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId, curDate,
|
180 |
float todaySale = fofoOrderItemRepository.selectSumBetweenCreatedTime(fofoId, curDate,
|
| 231 |
curDate.with(LocalTime.MAX));
|
181 |
curDate.with(LocalTime.MAX));
|
| 232 |
List<FofoOrderItem> mtdFofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
182 |
float mtdSale = fofoOrderItemRepository.selectSumBetweenCreatedTime(fofoId, curDate.withDayOfMonth(1),
|
| 233 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
183 |
curDate.with(LocalTime.MAX));
|
| 234 |
double todaySale = fofoOrderItems.stream()
|
184 |
float lmtdSale = fofoOrderItemRepository.selectSumBetweenCreatedTime(fofoId,
|
| 235 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 236 |
double mtdSale = mtdFofoOrderItems.stream()
|
- |
|
| 237 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
185 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1));
|
| 238 |
|
186 |
|
| 239 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
187 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
| 240 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
188 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
| 241 |
if (partnerTargetDetails.isEmpty()) {
|
189 |
if (partnerTargetDetails.isEmpty()) {
|
| 242 |
partnerTargetDetails = partnerTargetRepository
|
190 |
partnerTargetDetails = partnerTargetRepository
|
| 243 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusMonths(2));
|
191 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusMonths(3));
|
| 244 |
}
|
192 |
}
|
| 245 |
|
193 |
|
| 246 |
List<Integer> targetIds = partnerTargetRepository
|
- |
|
| 247 |
.selectAllPartnerTargetForPartner(fofoId,
|
- |
|
| 248 |
partnerTargetDetails.stream().map(x -> x.getId()).collect(Collectors.toList()))
|
- |
|
| 249 |
.stream().map(x -> x.getTargetId()).collect(Collectors.toList());
|
- |
|
| 250 |
if (targetIds.size() > 0) {
|
- |
|
| 251 |
PartnerTarget target = partnerTargetRepository.selectAllPartnerTargetForPartner(fofoId, targetIds).get(0);
|
194 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| - |
|
195 |
|
| 252 |
double targetValue = (double) target.getTargetValue();
|
196 |
int currentRate = (int) (mtdSale / monthLength);
|
| - |
|
197 |
|
| 253 |
int remainingDays = monthLength - curDate.getDayOfMonth() + 1;
|
198 |
salesMap.put("requiredType", partnerType.next());
|
| 254 |
// Should not consider today's sale while evaluating today's target.
|
199 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
| 255 |
double todayTargetValue = Math.round((targetValue - (mtdSale - todaySale)) / remainingDays);
|
200 |
int requiredRate = (int) ((reqdAmount - mtdSale) / (monthLength - curDate.getDayOfMonth()));
|
| 256 |
DecimalFormat df = new DecimalFormat("#.##");
|
- |
|
| 257 |
String targetValueString = df.format(targetValue / 100000) + "Lac";
|
- |
|
| 258 |
salesMap.put("todayTarget", todayTargetValue);
|
201 |
salesMap.put("requiredRate", requiredRate);
|
| 259 |
salesMap.put("monthTarget", targetValueString);
|
202 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
| 260 |
} else {
|
- |
|
| 261 |
salesMap.put("todayTarget", 0d);
|
- |
|
| 262 |
salesMap.put("monthTarget", 0d);
|
- |
|
| 263 |
|
203 |
|
| 264 |
}
|
- |
|
| 265 |
salesMap.put("todaySale", todaySale);
|
204 |
salesMap.put("todaySale", todaySale);
|
| 266 |
salesMap.put("mtdSale", mtdSale);
|
205 |
salesMap.put("mtdSale", mtdSale);
|
| - |
|
206 |
salesMap.put("lmtdSale", lmtdSale);
|
| - |
|
207 |
|
| - |
|
208 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
| - |
|
209 |
salesMap.put("currentRate", currentRate);
|
| - |
|
210 |
salesMap.put("currentType", currentType);
|
| - |
|
211 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|
| 267 |
return salesMap;
|
212 |
return salesMap;
|
| 268 |
}
|
213 |
}
|
| 269 |
|
214 |
|
| 270 |
/*
|
215 |
/*
|
| 271 |
* private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws
|
216 |
* private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws
|
| Line 284... |
Line 229... |
| 284 |
* return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x,
|
229 |
* return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x,
|
| 285 |
* y) -> x.getRank() - y.getRank()) .collect(Collectors.toList()); }
|
230 |
* y) -> x.getRank() - y.getRank()) .collect(Collectors.toList()); }
|
| 286 |
*/
|
231 |
*/
|
| 287 |
|
232 |
|
| 288 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
233 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 289 |
public String dashboard(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
234 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
| 290 |
@RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
|
- |
|
| 291 |
|
- |
|
| 292 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
235 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 293 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
236 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 294 |
model.addAttribute("isAdmin", isAdmin);
|
237 |
model.addAttribute("isAdmin", isAdmin);
|
| 295 |
|
238 |
|
| 296 |
FofoStore fofoStore = null;
|
239 |
FofoStore fofoStore = null;
|
| Line 309... |
Line 252... |
| 309 |
}
|
252 |
}
|
| 310 |
|
253 |
|
| 311 |
LOGGER.info("partnerType {}", partnerType);
|
254 |
LOGGER.info("partnerType {}", partnerType);
|
| 312 |
|
255 |
|
| 313 |
model.addAttribute("partnerType", partnerType);
|
256 |
model.addAttribute("partnerType", partnerType);
|
| - |
|
257 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
| 314 |
model.addAttribute("fofoStore", fofoStore);
|
258 |
model.addAttribute("fofoStore", fofoStore);
|
| 315 |
model.addAttribute("partnerType", partnerType);
|
259 |
model.addAttribute("partnerType", partnerType);
|
| 316 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
260 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 317 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
261 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 318 |
|
262 |
|
| Line 329... |
Line 273... |
| 329 |
|
273 |
|
| 330 |
}
|
274 |
}
|
| 331 |
}
|
275 |
}
|
| 332 |
|
276 |
|
| 333 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
277 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
| 334 |
List<HygieneData> hygieneData = hygieneDataRepository
|
278 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
| - |
|
279 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
|
| - |
|
280 |
currentMonthEnd);
|
| - |
|
281 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
|
| - |
|
282 |
currentMonthEnd);
|
| 335 |
.selectAll(loginDetails.getFofoId(), currentMonthStart,
|
283 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
|
| - |
|
284 |
currentMonthEnd);
|
| - |
|
285 |
model.addAttribute("currentMonthRating", currentMonthRating);
|
| 336 |
LocalDateTime.now().plusMonths(1).withDayOfMonth(1))
|
286 |
model.addAttribute("lastMonthRating", lastMonthRating);
|
| 337 |
.stream().filter(x -> x.getDisposedTimestamp() != null).collect(Collectors.toList());
|
287 |
model.addAttribute("ratingTillDate", ratingTillDate);
|
| 338 |
|
288 |
|
| - |
|
289 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true, currentMonthStart,
|
| 339 |
LOGGER.info("hygieneData" + hygieneData);
|
290 |
currentMonthEnd);
|
| - |
|
291 |
|
| 340 |
int successHygieneData = hygieneData.stream().filter(x -> x.getHygieneRating() == true)
|
292 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false,
|
| 341 |
.collect(Collectors.toList()).size();
|
293 |
currentMonthStart, currentMonthEnd);
|
| 342 |
int unsuccessfullHygieneData = hygieneData.stream().filter(x -> x.getHygieneRating() == false)
|
294 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
| 343 |
.collect(Collectors.toList()).size();
|
295 |
invalidHygieneCount = 1;
|
| 344 |
|
296 |
}
|
| 345 |
model.addAttribute("successHygieneData", successHygieneData);
|
- |
|
| 346 |
model.addAttribute("fullHygieneData", successHygieneData + unsuccessfullHygieneData);
|
297 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| 347 |
|
298 |
|
| 348 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
299 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
| 349 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
300 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
| 350 |
return "dashboard1";
|
301 |
return "dashboard1";
|
| 351 |
}
|
302 |
}
|
| Line 475... |
Line 426... |
| 475 |
}
|
426 |
}
|
| 476 |
}
|
427 |
}
|
| 477 |
}
|
428 |
}
|
| 478 |
|
429 |
|
| 479 |
model.addAttribute("notifications", notifications);
|
430 |
model.addAttribute("notifications", notifications);
|
| - |
|
431 |
|
| - |
|
432 |
LOGGER.info("notifications" + notifications);
|
| 480 |
return "notification-template";
|
433 |
return "notification-template";
|
| 481 |
}
|
434 |
}
|
| 482 |
|
435 |
|
| 483 |
@RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
|
436 |
@RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
|
| 484 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
437 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
| Line 530... |
Line 483... |
| 530 |
headers.set("Content-Type", contentType);
|
483 |
headers.set("Content-Type", contentType);
|
| 531 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
484 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
| 532 |
headers.setContentLength(document.getSize());
|
485 |
headers.setContentLength(document.getSize());
|
| 533 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
486 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
| 534 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
487 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| 535 |
|
- |
|
| 536 |
// return
|
- |
|
| 537 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
- |
|
| 538 |
}
|
488 |
}
|
| 539 |
|
489 |
|
| 540 |
}
|
490 |
}
|