| 21615 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 25649 |
tejbeer |
3 |
import com.google.gson.Gson;
|
| 28825 |
tejbeer |
4 |
import com.mongodb.DBObject;
|
| 25651 |
tejbeer |
5 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| 25683 |
tejbeer |
6 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 22481 |
ashik.ali |
7 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 29932 |
amit.gupta |
8 |
import com.spice.profitmandi.common.model.*;
|
| 25651 |
tejbeer |
9 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 26011 |
amit.gupta |
10 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 27355 |
tejbeer |
11 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 27636 |
tejbeer |
12 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 28471 |
tejbeer |
13 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 27660 |
tejbeer |
14 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
| 25651 |
tejbeer |
15 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 25649 |
tejbeer |
16 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| 29932 |
amit.gupta |
17 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 27529 |
tejbeer |
18 |
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
|
| 29720 |
manish |
19 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
| 27586 |
tejbeer |
20 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 29707 |
tejbeer |
21 |
import com.spice.profitmandi.dao.enumuration.catalog.UpgradeOfferStatus;
|
| 28409 |
tejbeer |
22 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 29707 |
tejbeer |
23 |
import com.spice.profitmandi.dao.model.SamsungUpgradeOfferModel;
|
| 29932 |
amit.gupta |
24 |
import com.spice.profitmandi.dao.model.*;
|
| 25976 |
amit.gupta |
25 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 27355 |
tejbeer |
26 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 29707 |
tejbeer |
27 |
import com.spice.profitmandi.dao.repository.catalog.SamsungUpgradeOfferRepository;
|
| 27632 |
tejbeer |
28 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 26090 |
amit.gupta |
29 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 28471 |
tejbeer |
30 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 27660 |
tejbeer |
31 |
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
|
| 26418 |
tejbeer |
32 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 29932 |
amit.gupta |
33 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
|
|
34 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 27529 |
tejbeer |
35 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
|
|
36 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| 29720 |
manish |
37 |
import com.spice.profitmandi.dao.repository.transaction.LineItemRepository;
|
| 27893 |
tejbeer |
38 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 28443 |
tejbeer |
39 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| 28468 |
tejbeer |
40 |
import com.spice.profitmandi.service.AdminUser;
|
|
|
41 |
import com.spice.profitmandi.service.FofoUser;
|
| 24336 |
amit.gupta |
42 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 26460 |
amit.gupta |
43 |
import com.spice.profitmandi.service.PartnerStatsService;
|
| 23844 |
amit.gupta |
44 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 25677 |
amit.gupta |
45 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 27876 |
amit.gupta |
46 |
import com.spice.profitmandi.service.offers.OfferService;
|
| 27586 |
tejbeer |
47 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 26005 |
amit.gupta |
48 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 22481 |
ashik.ali |
49 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
50 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 27529 |
tejbeer |
51 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 29932 |
amit.gupta |
52 |
import org.apache.logging.log4j.LogManager;
|
|
|
53 |
import org.apache.logging.log4j.Logger;
|
|
|
54 |
import org.json.JSONObject;
|
|
|
55 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
56 |
import org.springframework.beans.factory.annotation.Value;
|
|
|
57 |
import org.springframework.core.io.InputStreamResource;
|
|
|
58 |
import org.springframework.http.HttpHeaders;
|
|
|
59 |
import org.springframework.http.HttpStatus;
|
|
|
60 |
import org.springframework.http.ResponseEntity;
|
|
|
61 |
import org.springframework.stereotype.Controller;
|
|
|
62 |
import org.springframework.ui.Model;
|
|
|
63 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
64 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
65 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 22481 |
ashik.ali |
66 |
|
| 29932 |
amit.gupta |
67 |
import javax.servlet.http.HttpServletRequest;
|
|
|
68 |
import javax.transaction.Transactional;
|
|
|
69 |
import java.io.*;
|
|
|
70 |
import java.time.LocalDate;
|
|
|
71 |
import java.time.LocalDateTime;
|
|
|
72 |
import java.time.LocalTime;
|
|
|
73 |
import java.time.YearMonth;
|
|
|
74 |
import java.time.format.DateTimeFormatter;
|
|
|
75 |
import java.util.*;
|
|
|
76 |
import java.util.stream.Collectors;
|
|
|
77 |
|
| 21615 |
kshitij.so |
78 |
@Controller
|
| 25222 |
amit.gupta |
79 |
@Transactional(rollbackOn = Throwable.class)
|
| 21615 |
kshitij.so |
80 |
public class DashboardController {
|
| 23923 |
amit.gupta |
81 |
|
| 27727 |
tejbeer |
82 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com",
|
| 27778 |
tejbeer |
83 |
"niranjan.kala@smartdukaan.com", "hemant.kaura@smartdukaan.com", "amit.gupta@shop2020.in",
|
|
|
84 |
"tejbeer.kaur@shop2020.in");
|
| 27727 |
tejbeer |
85 |
|
| 23379 |
ashik.ali |
86 |
@Value("${web.api.host}")
|
|
|
87 |
private String webApiHost;
|
| 23923 |
amit.gupta |
88 |
|
| 24072 |
amit.gupta |
89 |
@Value("${web.api.scheme}")
|
|
|
90 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
91 |
|
| 24078 |
amit.gupta |
92 |
@Value("${web.api.root}")
|
|
|
93 |
private String webApiRoot;
|
|
|
94 |
|
| 23379 |
ashik.ali |
95 |
@Value("${web.api.port}")
|
|
|
96 |
private int webApiPort;
|
| 28430 |
tejbeer |
97 |
|
| 22481 |
ashik.ali |
98 |
@Autowired
|
| 28443 |
tejbeer |
99 |
private PriceDropRepository priceDropRepository;
|
|
|
100 |
|
|
|
101 |
@Autowired
|
| 22927 |
ashik.ali |
102 |
private CookiesProcessor cookiesProcessor;
|
| 26468 |
amit.gupta |
103 |
|
| 26460 |
amit.gupta |
104 |
@Autowired
|
| 28409 |
tejbeer |
105 |
private PendingOrderRepository pendingOrderRepository;
|
|
|
106 |
|
|
|
107 |
@Autowired
|
| 26460 |
amit.gupta |
108 |
private PartnerStatsService partnerStatsService;
|
| 23923 |
amit.gupta |
109 |
|
| 23568 |
govind |
110 |
@Autowired
|
| 26090 |
amit.gupta |
111 |
private CsService csService;
|
|
|
112 |
|
|
|
113 |
@Autowired
|
| 25653 |
amit.gupta |
114 |
private ResponseSender<?> responseSender;
|
| 26012 |
amit.gupta |
115 |
|
| 26005 |
amit.gupta |
116 |
@Autowired
|
|
|
117 |
RetailerService retailerService;
|
| 25214 |
amit.gupta |
118 |
|
|
|
119 |
@Autowired
|
| 28468 |
tejbeer |
120 |
private AdminUser adminUser;
|
|
|
121 |
|
|
|
122 |
@Autowired
|
| 23786 |
amit.gupta |
123 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
124 |
|
| 29932 |
amit.gupta |
125 |
|
| 23838 |
ashik.ali |
126 |
@Autowired
|
|
|
127 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
128 |
|
|
|
129 |
@Autowired
|
| 24880 |
govind |
130 |
private PartnerInvestmentService partnerInvestmentService;
|
| 24288 |
amit.gupta |
131 |
|
| 23884 |
amit.gupta |
132 |
@Autowired
|
| 25653 |
amit.gupta |
133 |
DocumentRepository documentRepository;
|
| 26236 |
amit.gupta |
134 |
|
| 26234 |
amit.gupta |
135 |
@Autowired
|
|
|
136 |
InventoryItemRepository inventoryItemRepository;
|
| 25683 |
tejbeer |
137 |
|
| 25677 |
amit.gupta |
138 |
@Autowired
|
|
|
139 |
InventoryService inventoryService;
|
| 23923 |
amit.gupta |
140 |
|
| 23884 |
amit.gupta |
141 |
@Autowired
|
| 28409 |
tejbeer |
142 |
private PendingOrderItemRepository pendingOrderItemRepository;
|
|
|
143 |
|
|
|
144 |
@Autowired
|
| 24203 |
amit.gupta |
145 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
146 |
|
| 24880 |
govind |
147 |
@Autowired
|
|
|
148 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 26012 |
amit.gupta |
149 |
|
| 26011 |
amit.gupta |
150 |
@Autowired
|
| 25566 |
tejbeer |
151 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 25136 |
amit.gupta |
152 |
|
| 24996 |
amit.gupta |
153 |
@Autowired
|
| 25649 |
tejbeer |
154 |
private HygieneDataRepository hygieneDataRepository;
|
|
|
155 |
|
|
|
156 |
@Autowired
|
|
|
157 |
private UserAccountRepository userAccountRepository;
|
|
|
158 |
|
|
|
159 |
@Autowired
|
|
|
160 |
private NotificationCampaignRepository notificationCampaignRepository;
|
|
|
161 |
|
|
|
162 |
@Autowired
|
| 25976 |
amit.gupta |
163 |
private AuthRepository authRepository;
|
| 24880 |
govind |
164 |
|
| 25649 |
tejbeer |
165 |
@Autowired
|
| 26071 |
tejbeer |
166 |
private FofoOrderRepository fofoOrderRepository;
|
|
|
167 |
|
|
|
168 |
@Autowired
|
| 25649 |
tejbeer |
169 |
private Gson gson;
|
|
|
170 |
|
| 26418 |
tejbeer |
171 |
@Autowired
|
|
|
172 |
TicketRepository ticketRepository;
|
|
|
173 |
|
|
|
174 |
@Autowired
|
| 27876 |
amit.gupta |
175 |
private OfferService offerService;
|
|
|
176 |
|
|
|
177 |
@Autowired
|
| 27355 |
tejbeer |
178 |
private ItemRepository itemRepository;
|
| 26588 |
tejbeer |
179 |
|
| 27509 |
tejbeer |
180 |
@Autowired
|
| 27529 |
tejbeer |
181 |
private SaholicInventoryCISRepository saholicInventoryCISRepository;
|
|
|
182 |
|
|
|
183 |
@Autowired
|
|
|
184 |
private MVCResponseSender mvcResponseSender;
|
|
|
185 |
|
|
|
186 |
@Autowired
|
|
|
187 |
private ReporticoCacheTableRepository reporticoCacheTableRepository;
|
|
|
188 |
|
| 27586 |
tejbeer |
189 |
@Autowired
|
|
|
190 |
private TransactionService transactionService;
|
|
|
191 |
|
| 27632 |
tejbeer |
192 |
@Autowired
|
|
|
193 |
private TagListingRepository tagListingRepository;
|
|
|
194 |
|
| 27660 |
tejbeer |
195 |
@Autowired
|
|
|
196 |
private TicketAssignedRepository ticketAssignedRepository;
|
|
|
197 |
|
| 27893 |
tejbeer |
198 |
@Autowired
|
|
|
199 |
private OrderRepository orderRepository;
|
| 28468 |
tejbeer |
200 |
|
|
|
201 |
@Autowired
|
|
|
202 |
private FofoUser fofoUser;
|
| 29875 |
tejbeer |
203 |
|
| 28471 |
tejbeer |
204 |
@Autowired
|
| 28825 |
tejbeer |
205 |
private ActivatedImeiRepository activatedImeiRepository;
|
|
|
206 |
|
|
|
207 |
@Autowired
|
|
|
208 |
private Mongo mongoClient;
|
|
|
209 |
|
|
|
210 |
@Autowired
|
| 29578 |
tejbeer |
211 |
private SchemeInOutRepository schemeInOutRepository;
|
| 29875 |
tejbeer |
212 |
|
| 29578 |
tejbeer |
213 |
@Autowired
|
| 29720 |
manish |
214 |
private LineItemRepository lineItemRepository;
|
| 29875 |
tejbeer |
215 |
|
| 29720 |
manish |
216 |
@Autowired
|
| 29578 |
tejbeer |
217 |
private FofoLineItemRepository fofoLineItemRepository;
|
|
|
218 |
|
|
|
219 |
@Autowired
|
| 28471 |
tejbeer |
220 |
private PositionRepository positionRepository;
|
| 29707 |
tejbeer |
221 |
|
|
|
222 |
@Autowired
|
|
|
223 |
private SamsungUpgradeOfferRepository samsungUpgradeOfferRepository;
|
| 23568 |
govind |
224 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 23923 |
amit.gupta |
225 |
|
| 25136 |
amit.gupta |
226 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
| 25726 |
amit.gupta |
227 |
public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
|
| 25740 |
amit.gupta |
228 |
boolean isAdmin = false;
|
|
|
229 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
230 |
|
|
|
231 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
232 |
model.addAttribute("webApiPort", webApiPort);
|
|
|
233 |
model.addAttribute("webApiScheme", webApiScheme);
|
|
|
234 |
model.addAttribute("webApiRoot", webApiRoot);
|
|
|
235 |
if (isAdmin) {
|
|
|
236 |
return "dashboard1";
|
| 26236 |
amit.gupta |
237 |
}
|
|
|
238 |
|
|
|
239 |
FofoStore fofoStore = null;
|
| 26234 |
amit.gupta |
240 |
try {
|
|
|
241 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
242 |
fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
|
|
243 |
if (!fofoStore.isActive()) {
|
|
|
244 |
return "redirect:/login";
|
|
|
245 |
}
|
| 25740 |
amit.gupta |
246 |
|
| 26234 |
amit.gupta |
247 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
|
|
248 |
model.addAttribute("partnerType", partnerType);
|
|
|
249 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
|
|
250 |
model.addAttribute("fofoStore", customRetailer);
|
|
|
251 |
model.addAttribute("partnerType", partnerType);
|
| 28468 |
tejbeer |
252 |
model.addAttribute("hasGift", fofoUser.hasGift(fofoId));
|
| 26234 |
amit.gupta |
253 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 25740 |
amit.gupta |
254 |
|
| 28468 |
tejbeer |
255 |
model.addAttribute("brandStockPrices", fofoUser.getBrandStockPrices(fofoId));
|
|
|
256 |
model.addAttribute("salesMap", fofoUser.getSales(fofoId));
|
| 26234 |
amit.gupta |
257 |
model.addAttribute("activatedImeis", inventoryItemRepository.selectCountByActivatedNotSold(fofoId));
|
|
|
258 |
// this.setInvestments
|
|
|
259 |
//
|
| 28272 |
tejbeer |
260 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
|
|
261 |
for (int i = 0; i <= 5; i++) {
|
|
|
262 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
263 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
264 |
}
|
|
|
265 |
LOGGER.info("monthValueMap" + monthValueMap);
|
|
|
266 |
model.addAttribute("monthValueMap", monthValueMap);
|
| 28468 |
tejbeer |
267 |
model.addAttribute("investments", fofoUser.getInvestments(fofoId));
|
| 26234 |
amit.gupta |
268 |
model.addAttribute("isInvestmentOk",
|
|
|
269 |
partnerInvestmentService.isInvestmentOk(fofoId, 10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
|
|
270 |
} catch (ProfitMandiBusinessException e) {
|
|
|
271 |
LOGGER.error("FofoStore Code not found of fofoId {}", fofoId);
|
| 25740 |
amit.gupta |
272 |
|
|
|
273 |
}
|
|
|
274 |
|
| 28430 |
tejbeer |
275 |
return "12dashboard34";
|
| 28272 |
tejbeer |
276 |
}
|
| 25740 |
amit.gupta |
277 |
|
| 27474 |
tejbeer |
278 |
@RequestMapping(value = "/getMonthSale", method = RequestMethod.GET)
|
|
|
279 |
public String getMonthsale(HttpServletRequest request, Model model) throws Exception {
|
|
|
280 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
281 |
int fofoId = loginDetails.getFofoId();
|
|
|
282 |
Map<Integer, MonthSaleModel> monthSaleMap = new HashMap<>();
|
|
|
283 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
284 |
int dayOfMonth = curDate.getDayOfMonth();
|
|
|
285 |
for (int i = 1; i <= 6; i++) {
|
|
|
286 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 27555 |
tejbeer |
287 |
int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
|
| 29875 |
tejbeer |
288 |
LOGGER.info("Start of previous Month {}, start of next month Month {}", startOfMonth,
|
|
|
289 |
startOfMonth.plusMonths(1));
|
| 27474 |
tejbeer |
290 |
double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth,
|
|
|
291 |
startOfMonth.plusMonths(1), loginDetails.getFofoId(), false).get(fofoId);
|
|
|
292 |
|
| 27574 |
tejbeer |
293 |
double mtdSales = fofoOrderItemRepository
|
|
|
294 |
.selectSumMopGroupByRetailer(startOfMonth,
|
|
|
295 |
startOfMonth.plusDays(Math.min(dayOfMonth, lengthOfMonth)), loginDetails.getFofoId(), false)
|
|
|
296 |
.get(fofoId);
|
| 27474 |
tejbeer |
297 |
|
|
|
298 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfMonth.toLocalDate());
|
|
|
299 |
|
|
|
300 |
MonthSaleModel ms = new MonthSaleModel();
|
| 28468 |
tejbeer |
301 |
ms.setMtdSales(fofoUser.format((long) mtdSales));
|
|
|
302 |
ms.setMonthlySales(fofoUser.format(((long) monthSales)));
|
| 27474 |
tejbeer |
303 |
ms.setPartnerType(partnerType);
|
| 27476 |
tejbeer |
304 |
ms.setMonth(startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
| 27474 |
tejbeer |
305 |
monthSaleMap.put(i, ms);
|
| 29875 |
tejbeer |
306 |
}
|
| 27474 |
tejbeer |
307 |
|
|
|
308 |
model.addAttribute("monthSales", monthSaleMap);
|
|
|
309 |
return "monthSales";
|
|
|
310 |
}
|
|
|
311 |
|
| 21615 |
kshitij.so |
312 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 25653 |
amit.gupta |
313 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
| 22927 |
ashik.ali |
314 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26011 |
amit.gupta |
315 |
String email = loginDetails.getEmailId();
|
| 28430 |
tejbeer |
316 |
int fofoId = loginDetails.getFofoId();
|
| 28409 |
tejbeer |
317 |
|
| 28430 |
tejbeer |
318 |
LocalDateTime startDate = LocalDate.now().withDayOfYear(1).atStartOfDay();
|
|
|
319 |
LocalDateTime endtDate = LocalDateTime.now();
|
| 29875 |
tejbeer |
320 |
OnlineDeliveredOrderSum onlineDeliveredOrderSum = pendingOrderItemRepository
|
|
|
321 |
.selectSumSellingPriceOnlineOrder(fofoId, startDate, endtDate);
|
|
|
322 |
LOGGER.info("onlineDeliveredOrderSum" + onlineDeliveredOrderSum.getSellingPrice());
|
| 28409 |
tejbeer |
323 |
|
| 28430 |
tejbeer |
324 |
long countOrder = pendingOrderRepository.pendingOrderCount(fofoId, OrderStatus.PROCESSING);
|
|
|
325 |
LOGGER.info("countOrder" + countOrder);
|
| 29875 |
tejbeer |
326 |
|
| 29720 |
manish |
327 |
ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
|
| 29875 |
tejbeer |
328 |
|
| 29720 |
manish |
329 |
orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
330 |
orderStatus.add(in.shop2020.model.v1.order.OrderStatus.BILLED);
|
|
|
331 |
orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH);
|
| 29932 |
amit.gupta |
332 |
orderStatus.add(in.shop2020.model.v1.order.OrderStatus.DELIVERY_SUCCESS);
|
| 29875 |
tejbeer |
333 |
|
| 29932 |
amit.gupta |
334 |
List<Order> order = orderRepository.selectGrnTimestampNull(fofoId, orderStatus);
|
|
|
335 |
List<LineItem> submittedLineItemIds = order.stream()
|
| 29875 |
tejbeer |
336 |
.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING)
|
| 29932 |
amit.gupta |
337 |
.map(x -> x.getLineItem()).collect(Collectors.toList());
|
|
|
338 |
List<LineItem> billedOrderIds = order.stream()
|
|
|
339 |
.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.BILLED).map(x -> x.getLineItem())
|
| 29875 |
tejbeer |
340 |
.collect(Collectors.toList());
|
| 29932 |
amit.gupta |
341 |
List<LineItem> shippedOrderIds = order.stream()
|
| 29875 |
tejbeer |
342 |
.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH)
|
| 29932 |
amit.gupta |
343 |
.map(x -> x.getLineItem()).collect(Collectors.toList());
|
|
|
344 |
List<LineItem> grnPendingLineItemIds = order.stream()
|
|
|
345 |
.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.DELIVERY_SUCCESS)
|
|
|
346 |
.map(x -> x.getLineItem()).collect(Collectors.toList());
|
| 29875 |
tejbeer |
347 |
|
|
|
348 |
LOGGER.info("billedOrderIds {}", billedOrderIds);
|
|
|
349 |
LOGGER.info("shippedOrderIds {}", shippedOrderIds);
|
|
|
350 |
|
| 29932 |
amit.gupta |
351 |
long grnPendingCount = grnPendingLineItemIds.stream().collect(Collectors.summingLong(LineItem::getQuantity));
|
|
|
352 |
long grnPendingValue = grnPendingLineItemIds.stream()
|
|
|
353 |
.collect(Collectors.summingLong(x -> x.getTotalPrice().longValue()));
|
|
|
354 |
model.addAttribute("grnPendingCount", grnPendingCount);
|
|
|
355 |
model.addAttribute("grnPendingValue", grnPendingValue);
|
| 29875 |
tejbeer |
356 |
|
|
|
357 |
|
| 29932 |
amit.gupta |
358 |
long submittedCount = submittedLineItemIds.stream().collect(Collectors.summingLong(LineItem::getQuantity));
|
|
|
359 |
long submittedValue = submittedLineItemIds.stream()
|
|
|
360 |
.collect(Collectors.summingLong(x -> x.getTotalPrice().longValue()));
|
|
|
361 |
model.addAttribute("submittedCount", submittedCount);
|
|
|
362 |
model.addAttribute("submittedValue", submittedValue);
|
| 29875 |
tejbeer |
363 |
|
| 29932 |
amit.gupta |
364 |
long billedCount = billedOrderIds.stream().collect(Collectors.summingLong(LineItem::getQuantity));
|
|
|
365 |
long billedValue = billedOrderIds.stream().collect(Collectors.summingLong(x -> x.getTotalPrice().longValue()));
|
|
|
366 |
model.addAttribute("billedValue", billedValue);
|
|
|
367 |
model.addAttribute("billedCount", billedCount);
|
|
|
368 |
LOGGER.info("billedCount {}", billedCount);
|
| 29875 |
tejbeer |
369 |
|
| 29932 |
amit.gupta |
370 |
long shippedCount = shippedOrderIds.stream().collect(Collectors.summingLong(LineItem::getQuantity));
|
|
|
371 |
model.addAttribute("shippedCount", shippedCount);
|
|
|
372 |
LOGGER.info("shippedCount {}", shippedCount);
|
|
|
373 |
long shippedValue = shippedOrderIds.stream()
|
|
|
374 |
.collect(Collectors.summingLong(x -> x.getTotalPrice().longValue()));
|
|
|
375 |
model.addAttribute("shippedValue", shippedValue);
|
| 29875 |
tejbeer |
376 |
|
| 28409 |
tejbeer |
377 |
model.addAttribute("countOrder", countOrder);
|
|
|
378 |
model.addAttribute("onlineDeliveredOrderSum", onlineDeliveredOrderSum.getSellingPrice());
|
| 25180 |
amit.gupta |
379 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
380 |
model.addAttribute("isAdmin", isAdmin);
|
| 23923 |
amit.gupta |
381 |
|
| 25274 |
amit.gupta |
382 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
383 |
model.addAttribute("webApiPort", webApiPort);
|
|
|
384 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 25544 |
amit.gupta |
385 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 25183 |
amit.gupta |
386 |
if (isAdmin) {
|
| 28468 |
tejbeer |
387 |
return adminUser.adminPanel(loginDetails.getFofoId(), email, model);
|
| 25180 |
amit.gupta |
388 |
} else {
|
| 25740 |
amit.gupta |
389 |
FofoStore fofoStore = null;
|
| 25180 |
amit.gupta |
390 |
try {
|
|
|
391 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 25544 |
amit.gupta |
392 |
if (!fofoStore.isActive()) {
|
|
|
393 |
return "redirect:/login";
|
|
|
394 |
}
|
| 25649 |
tejbeer |
395 |
|
| 25740 |
amit.gupta |
396 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
| 25566 |
tejbeer |
397 |
model.addAttribute("partnerType", partnerType);
|
| 25653 |
amit.gupta |
398 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
| 25180 |
amit.gupta |
399 |
model.addAttribute("fofoStore", fofoStore);
|
| 25566 |
tejbeer |
400 |
model.addAttribute("partnerType", partnerType);
|
| 28641 |
amit.gupta |
401 |
model.addAttribute("maa", loginDetails.getFofoId() == 175138885);
|
|
|
402 |
|
| 28468 |
tejbeer |
403 |
model.addAttribute("hasGift", fofoUser.hasGift(loginDetails.getFofoId()));
|
| 25180 |
amit.gupta |
404 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 26222 |
tejbeer |
405 |
model.addAttribute("retailers", new JSONObject().append("code", fofoStore.getCode())
|
| 26162 |
amit.gupta |
406 |
.append("partnerId", fofoStore.getId()).toString());
|
| 26460 |
amit.gupta |
407 |
model.addAttribute("activatedImeis",
|
|
|
408 |
inventoryItemRepository.selectCountByActivatedNotSold(loginDetails.getFofoId()));
|
| 26071 |
tejbeer |
409 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
410 |
Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository
|
|
|
411 |
.selectSumSaleGroupByFofoIdsForMobileOrAccessories(loginDetails.getFofoId(),
|
|
|
412 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
|
| 27701 |
tejbeer |
413 |
|
| 26071 |
tejbeer |
414 |
Double accesoriesStock = currentInventorySnapshotRepository
|
|
|
415 |
.selectSumStockGroupByFofoIdsForMobileOrAccessories(loginDetails.getFofoId(),
|
|
|
416 |
Optional.of(false))
|
|
|
417 |
.get(loginDetails.getFofoId());
|
| 25180 |
amit.gupta |
418 |
|
| 26071 |
tejbeer |
419 |
model.addAttribute("accesoriesStock", String.format("%.0f", accesoriesStock));
|
| 28468 |
tejbeer |
420 |
model.addAttribute("brandStockPrices", fofoUser.getBrandStockPrices(loginDetails.getFofoId()));
|
|
|
421 |
model.addAttribute("salesMap", fofoUser.getSales(loginDetails.getFofoId()));
|
|
|
422 |
ChartModel cm = fofoUser.getBrandChart(loginDetails.getFofoId());
|
| 26055 |
tejbeer |
423 |
|
|
|
424 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
425 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 27701 |
tejbeer |
426 |
|
| 27876 |
amit.gupta |
427 |
List<CreateOfferRequest> publishedOffers = offerService.getPublishedOffers(loginDetails.getFofoId(),
|
|
|
428 |
YearMonth.from(LocalDateTime.now()));
|
|
|
429 |
model.addAttribute("publishedOffers", publishedOffers);
|
| 28468 |
tejbeer |
430 |
model.addAttribute("investments", fofoUser.getInvestments(loginDetails.getFofoId()));
|
| 25544 |
amit.gupta |
431 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
|
|
|
432 |
10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
| 26460 |
amit.gupta |
433 |
|
| 25180 |
amit.gupta |
434 |
} catch (ProfitMandiBusinessException e) {
|
|
|
435 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
|
|
436 |
|
|
|
437 |
}
|
| 22481 |
ashik.ali |
438 |
}
|
| 25649 |
tejbeer |
439 |
|
|
|
440 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
| 25747 |
amit.gupta |
441 |
LocalDateTime lastMonthStart = currentMonthStart.minusMonths(1);
|
| 25653 |
amit.gupta |
442 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
|
|
443 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
|
| 25677 |
amit.gupta |
444 |
currentMonthEnd) / 2;
|
| 25747 |
amit.gupta |
445 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), lastMonthStart,
|
|
|
446 |
currentMonthStart) / 2;
|
|
|
447 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), LocalDateTime.MIN,
|
| 25677 |
amit.gupta |
448 |
currentMonthEnd) / 2;
|
|
|
449 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
|
|
450 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
|
|
451 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
| 25649 |
tejbeer |
452 |
|
| 25653 |
amit.gupta |
453 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true, currentMonthStart,
|
|
|
454 |
currentMonthEnd);
|
| 25651 |
tejbeer |
455 |
|
| 25653 |
amit.gupta |
456 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false,
|
|
|
457 |
currentMonthStart, currentMonthEnd);
|
|
|
458 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
|
|
459 |
invalidHygieneCount = 1;
|
|
|
460 |
}
|
| 28272 |
tejbeer |
461 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
|
|
462 |
for (int i = 0; i <= 5; i++) {
|
|
|
463 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
464 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
465 |
}
|
|
|
466 |
|
|
|
467 |
model.addAttribute("monthValueMap", monthValueMap);
|
|
|
468 |
model.addAttribute("month", 0);
|
|
|
469 |
|
| 25653 |
amit.gupta |
470 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| 25651 |
tejbeer |
471 |
|
| 25197 |
amit.gupta |
472 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
|
|
473 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
| 27884 |
tejbeer |
474 |
/*
|
|
|
475 |
* if (loginDetails.isReadOnly()) { return "dashboard-readonly"; } else { }
|
|
|
476 |
*/
|
| 28430 |
tejbeer |
477 |
|
| 27882 |
amit.gupta |
478 |
return "dashboard1";
|
| 28272 |
tejbeer |
479 |
|
| 21615 |
kshitij.so |
480 |
}
|
| 29875 |
tejbeer |
481 |
|
| 29720 |
manish |
482 |
@RequestMapping(value = "/getGrnPendingOrderStatus", method = RequestMethod.GET)
|
|
|
483 |
public String getGrnPendingOrderStatus(HttpServletRequest request, Model model) throws Exception {
|
| 29875 |
tejbeer |
484 |
|
| 29720 |
manish |
485 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
486 |
int fofoId = loginDetails.getFofoId();
|
| 29932 |
amit.gupta |
487 |
List<Order> order = orderRepository.selectGrnTimestampNull(fofoId, Arrays.asList(in.shop2020.model.v1.order.OrderStatus.DELIVERY_SUCCESS));
|
| 29746 |
manish |
488 |
|
| 29932 |
amit.gupta |
489 |
List<LineItem> grnPendingLineItemIds = order.stream()
|
|
|
490 |
.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.DELIVERY_SUCCESS)
|
|
|
491 |
.map(x -> x.getLineItem()).collect(Collectors.toList());
|
| 29875 |
tejbeer |
492 |
|
| 29932 |
amit.gupta |
493 |
Map<Integer, LineItem> grnPendingLineMap = grnPendingLineItemIds.stream()
|
|
|
494 |
.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
|
|
495 |
LOGGER.info("grnPendingLineMap {}", grnPendingLineMap);
|
|
|
496 |
model.addAttribute("grnPendingLineMap", grnPendingLineMap);
|
|
|
497 |
Map<Integer, Order> orderMap = order.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 29875 |
tejbeer |
498 |
|
| 29932 |
amit.gupta |
499 |
model.addAttribute("orderMap", orderMap);
|
| 29720 |
manish |
500 |
return "purchase-grn-order-status";
|
|
|
501 |
}
|
| 29875 |
tejbeer |
502 |
|
| 29720 |
manish |
503 |
@RequestMapping(value = "/getPendingOrderStatus", method = RequestMethod.GET)
|
|
|
504 |
public String getPendingOrderStatus(HttpServletRequest request, Model model) throws Exception {
|
| 29875 |
tejbeer |
505 |
|
| 29720 |
manish |
506 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
507 |
int fofoId = loginDetails.getFofoId();
|
| 29875 |
tejbeer |
508 |
ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
|
|
|
509 |
|
| 29720 |
manish |
510 |
orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 29875 |
tejbeer |
511 |
|
|
|
512 |
List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
|
|
|
513 |
List<Integer> submittedOrderIds = order.stream()
|
|
|
514 |
.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING)
|
|
|
515 |
.map(x -> x.getId()).collect(Collectors.toList());
|
|
|
516 |
model.addAttribute("submittedOrderIds", submittedOrderIds);
|
|
|
517 |
if (!submittedOrderIds.isEmpty()) {
|
|
|
518 |
|
|
|
519 |
List<LineItem> submittedLineItem = lineItemRepository.selectLineItem(submittedOrderIds);
|
|
|
520 |
Map<Integer, LineItem> submittedLineItemMap = submittedLineItem.stream()
|
|
|
521 |
.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
|
|
522 |
LOGGER.info("submittedLineItemMap {}", submittedLineItemMap);
|
|
|
523 |
model.addAttribute("submittedLineItemMap", submittedLineItemMap);
|
|
|
524 |
}
|
|
|
525 |
|
| 29720 |
manish |
526 |
return "purchase-pending-order-status";
|
|
|
527 |
}
|
| 29875 |
tejbeer |
528 |
|
| 29720 |
manish |
529 |
@RequestMapping(value = "/getBilledOrderStatus", method = RequestMethod.GET)
|
|
|
530 |
public String getBilledOrderStatus(HttpServletRequest request, Model model) throws Exception {
|
| 29875 |
tejbeer |
531 |
|
| 29720 |
manish |
532 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
533 |
int fofoId = loginDetails.getFofoId();
|
| 29875 |
tejbeer |
534 |
ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
|
| 29720 |
manish |
535 |
orderStatus.add(in.shop2020.model.v1.order.OrderStatus.BILLED);
|
| 29875 |
tejbeer |
536 |
|
|
|
537 |
List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
|
|
|
538 |
List<Integer> billedOrderIds = order.stream()
|
|
|
539 |
.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.BILLED).map(x -> x.getId())
|
|
|
540 |
.collect(Collectors.toList());
|
|
|
541 |
LOGGER.info("billedOrderIds {}", billedOrderIds);
|
|
|
542 |
model.addAttribute("billedOrderIds", billedOrderIds);
|
|
|
543 |
|
|
|
544 |
if (!billedOrderIds.isEmpty()) {
|
|
|
545 |
List<LineItem> billedLineItem = lineItemRepository.selectLineItem(billedOrderIds);
|
|
|
546 |
Map<Integer, LineItem> billedLineItemMap = billedLineItem.stream()
|
|
|
547 |
.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
|
|
548 |
LOGGER.info("billedLineItemMap {}", billedLineItemMap);
|
|
|
549 |
model.addAttribute("billedLineItemMap", billedLineItemMap);
|
|
|
550 |
}
|
|
|
551 |
|
| 29720 |
manish |
552 |
return "purchase-billed-order-status";
|
|
|
553 |
}
|
| 29875 |
tejbeer |
554 |
|
| 29720 |
manish |
555 |
@RequestMapping(value = "/getShippedOrderStatus", method = RequestMethod.GET)
|
|
|
556 |
public String getShippedOrderStatus(HttpServletRequest request, Model model) throws Exception {
|
| 29875 |
tejbeer |
557 |
|
| 29720 |
manish |
558 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
559 |
int fofoId = loginDetails.getFofoId();
|
| 29875 |
tejbeer |
560 |
ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
|
|
|
561 |
|
| 29720 |
manish |
562 |
orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH);
|
| 29875 |
tejbeer |
563 |
|
|
|
564 |
List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
|
|
|
565 |
List<Integer> shippedOrderIds = order.stream()
|
|
|
566 |
.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH)
|
|
|
567 |
.map(x -> x.getId()).collect(Collectors.toList());
|
|
|
568 |
model.addAttribute("shippedOrderIds", shippedOrderIds);
|
|
|
569 |
LOGGER.info("shippedOrderIds {}", shippedOrderIds);
|
|
|
570 |
|
|
|
571 |
if (!shippedOrderIds.isEmpty()) {
|
|
|
572 |
List<LineItem> shippedLineItem = lineItemRepository.selectLineItem(shippedOrderIds);
|
|
|
573 |
Map<Integer, LineItem> shippedLineItemMap = shippedLineItem.stream()
|
|
|
574 |
.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
|
|
575 |
LOGGER.info("shippedLineItemMap {}", shippedLineItemMap);
|
|
|
576 |
|
|
|
577 |
model.addAttribute("shippedLineItemMap", shippedLineItemMap);
|
|
|
578 |
}
|
| 29720 |
manish |
579 |
return "purchase-shipped-order-status";
|
|
|
580 |
}
|
| 23923 |
amit.gupta |
581 |
|
| 28272 |
tejbeer |
582 |
@RequestMapping(value = "/getMonthsInvestment", method = RequestMethod.GET)
|
|
|
583 |
public String getMonthsInvestment(HttpServletRequest request,
|
| 29932 |
amit.gupta |
584 |
@RequestParam(name = "month", required = true, defaultValue = "0") int month, Model model)
|
| 28272 |
tejbeer |
585 |
throws Exception {
|
|
|
586 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
587 |
int fofoId = loginDetails.getFofoId();
|
| 28468 |
tejbeer |
588 |
Map<String, Object> investment = fofoUser.getInvestmentsMonths(fofoId, month);
|
| 28430 |
tejbeer |
589 |
|
| 28272 |
tejbeer |
590 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
|
|
591 |
LocalDateTime lastMonthStart = currentMonthStart.minusMonths(1);
|
|
|
592 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
|
|
593 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
|
|
|
594 |
currentMonthEnd) / 2;
|
|
|
595 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), lastMonthStart,
|
|
|
596 |
currentMonthStart) / 2;
|
|
|
597 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), LocalDateTime.MIN,
|
|
|
598 |
currentMonthEnd) / 2;
|
|
|
599 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
|
|
600 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
|
|
601 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
|
|
602 |
|
| 28430 |
tejbeer |
603 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true,
|
|
|
604 |
currentMonthStart.minusMonths(month), currentMonthEnd.minusMonths(month));
|
| 28272 |
tejbeer |
605 |
|
|
|
606 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false,
|
| 28430 |
tejbeer |
607 |
currentMonthStart.minusMonths(month), currentMonthEnd.minusMonths(month));
|
| 28272 |
tejbeer |
608 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
|
|
609 |
invalidHygieneCount = 1;
|
|
|
610 |
}
|
|
|
611 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
|
|
612 |
for (int i = 0; i <= 5; i++) {
|
|
|
613 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
614 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
615 |
}
|
|
|
616 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| 28430 |
tejbeer |
617 |
model.addAttribute("monthValueMap", monthValueMap);
|
| 28272 |
tejbeer |
618 |
model.addAttribute("investments", investment);
|
|
|
619 |
model.addAttribute("monthDays", LocalDate.now().minusMonths(month).lengthOfMonth());
|
|
|
620 |
model.addAttribute("dayOfMonth", LocalDate.now().minusMonths(month).lengthOfMonth());
|
| 28430 |
tejbeer |
621 |
model.addAttribute("month", month);
|
| 28272 |
tejbeer |
622 |
return "performance";
|
|
|
623 |
}
|
|
|
624 |
|
| 27884 |
tejbeer |
625 |
@RequestMapping(value = "/investmentDetails", method = RequestMethod.GET)
|
|
|
626 |
public String getInvestmentDetails(HttpServletRequest request, Model model) throws Exception {
|
|
|
627 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
628 |
int fofoId = loginDetails.getFofoId();
|
| 28468 |
tejbeer |
629 |
ChartInvestmentModel cm = fofoUser.getInvestmentChart(fofoId);
|
| 27884 |
tejbeer |
630 |
model.addAttribute("chartPieMap", gson.toJson(cm));
|
|
|
631 |
|
|
|
632 |
LOGGER.info("InvestmentChart" + gson.toJson(cm));
|
|
|
633 |
LOGGER.info("InvestmentChart" + cm);
|
|
|
634 |
return "investmentdetails";
|
|
|
635 |
}
|
|
|
636 |
|
| 28430 |
tejbeer |
637 |
@RequestMapping(value = "/getlmsLineChart", method = RequestMethod.GET)
|
|
|
638 |
public String getlmsLineChart(HttpServletRequest request, Model model) throws Exception {
|
|
|
639 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
640 |
int fofoId = loginDetails.getFofoId();
|
| 28468 |
tejbeer |
641 |
ChartModel cm = fofoUser.getLmsLineChart(loginDetails.getFofoId());
|
| 28430 |
tejbeer |
642 |
|
|
|
643 |
LOGGER.info("linechartMap" + gson.toJson(cm));
|
|
|
644 |
model.addAttribute("linechartMap", gson.toJson(cm));
|
|
|
645 |
return "lmsLineChart";
|
|
|
646 |
}
|
|
|
647 |
|
| 28439 |
tejbeer |
648 |
@RequestMapping(value = "/getMonthlyPurchaseLineChart", method = RequestMethod.GET)
|
|
|
649 |
public String getMonthlyPurchaseLineChart(HttpServletRequest request, Model model) throws Exception {
|
|
|
650 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
651 |
int fofoId = loginDetails.getFofoId();
|
| 28468 |
tejbeer |
652 |
ChartModel cm = fofoUser.getPurchaseOrderChart(fofoId);
|
| 28439 |
tejbeer |
653 |
|
|
|
654 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
655 |
model.addAttribute("chartMap", gson.toJson(cm));
|
|
|
656 |
|
|
|
657 |
return "purchase_chart";
|
|
|
658 |
}
|
|
|
659 |
|
| 28430 |
tejbeer |
660 |
@RequestMapping(value = "/getBarChart", method = RequestMethod.GET)
|
|
|
661 |
public String getBarChart(HttpServletRequest request, Model model) throws Exception {
|
|
|
662 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
663 |
int fofoId = loginDetails.getFofoId();
|
| 28468 |
tejbeer |
664 |
ChartModel cm = fofoUser.getBrandChart(fofoId);
|
| 28430 |
tejbeer |
665 |
|
|
|
666 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
667 |
model.addAttribute("chartMap", gson.toJson(cm));
|
|
|
668 |
|
|
|
669 |
return "bar_chart";
|
|
|
670 |
}
|
|
|
671 |
|
| 28455 |
tejbeer |
672 |
@RequestMapping(value = "/getPriceDropDetails", method = RequestMethod.GET)
|
|
|
673 |
public String getPriceDropDetails(HttpServletRequest request,
|
| 29932 |
amit.gupta |
674 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
675 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
676 |
@RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model)
|
| 28455 |
tejbeer |
677 |
throws Exception {
|
|
|
678 |
|
|
|
679 |
LOGGER.info("params" + fofoId + brand + yearMonth);
|
|
|
680 |
|
|
|
681 |
List<PriceDropWithDetailsByYearMonthModel> priceDropdetailsList = priceDropRepository
|
|
|
682 |
.selectBrandPendingPriceDropWithDetailsByYearMonth(fofoId, brand, yearMonth);
|
|
|
683 |
|
|
|
684 |
LOGGER.info("priceDropdetailsList" + priceDropdetailsList);
|
|
|
685 |
|
|
|
686 |
model.addAttribute("priceDropdetailsList", priceDropdetailsList);
|
|
|
687 |
|
|
|
688 |
return "price-drop-details";
|
|
|
689 |
}
|
| 28825 |
tejbeer |
690 |
|
| 28641 |
amit.gupta |
691 |
@RequestMapping(value = "/getPriceDropDetailSixMonths", method = RequestMethod.GET)
|
|
|
692 |
public String getPriceDropDetailSixMonths(HttpServletRequest request,
|
| 29932 |
amit.gupta |
693 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
694 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
|
| 28641 |
amit.gupta |
695 |
throws Exception {
|
| 28455 |
tejbeer |
696 |
|
| 28641 |
amit.gupta |
697 |
LOGGER.info("params" + fofoId + brand);
|
|
|
698 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
699 |
LocalDateTime startfMonthSixMonth = curDate.withDayOfMonth(1).minusMonths(12);
|
|
|
700 |
LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(6);
|
|
|
701 |
|
|
|
702 |
List<PriceDropWithDetailsByYearMonthModel> priceDropdetailsList = priceDropRepository
|
| 28825 |
tejbeer |
703 |
.selectBrandPendingPriceDropWithDetailsAndSixMonth(fofoId, brand, startfMonthSixMonth, endMonthTotal);
|
| 28641 |
amit.gupta |
704 |
|
|
|
705 |
LOGGER.info("priceDropdetailsList" + priceDropdetailsList);
|
|
|
706 |
|
|
|
707 |
model.addAttribute("priceDropdetailsList", priceDropdetailsList);
|
|
|
708 |
|
|
|
709 |
return "price-drop-details";
|
|
|
710 |
}
|
|
|
711 |
|
| 28455 |
tejbeer |
712 |
@RequestMapping(value = "/getMonthlyPriceDrop", method = RequestMethod.GET)
|
|
|
713 |
public String getMonthlyPriceDropTabular(HttpServletRequest request, Model model) throws Exception {
|
|
|
714 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
715 |
int fofoId = loginDetails.getFofoId();
|
|
|
716 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
717 |
|
|
|
718 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| 28641 |
amit.gupta |
719 |
LocalDateTime startfMonthTotal = curDate.withDayOfMonth(1).minusMonths(12);
|
| 29875 |
tejbeer |
720 |
LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(5);
|
| 28455 |
tejbeer |
721 |
|
| 29875 |
tejbeer |
722 |
LOGGER.info("startfMonthTotal" + startfMonthTotal);
|
|
|
723 |
|
|
|
724 |
LOGGER.info("endMonthTotal" + endMonthTotal);
|
| 28641 |
amit.gupta |
725 |
List<YearMonth> yms = new ArrayList<YearMonth>();
|
| 28455 |
tejbeer |
726 |
|
| 29875 |
tejbeer |
727 |
for (int i = 0; i <= 5; i++) {
|
| 28641 |
amit.gupta |
728 |
yms.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
|
| 28455 |
tejbeer |
729 |
}
|
| 28641 |
amit.gupta |
730 |
Collections.reverse(yms);
|
|
|
731 |
model.addAttribute("yms", yms);
|
|
|
732 |
LOGGER.info("ym" + yms);
|
| 28455 |
tejbeer |
733 |
|
|
|
734 |
List<PriceDropYearMonthModel> priceDropYearMonthModels = priceDropRepository
|
|
|
735 |
.selectBrandPendingPriceDropByYearMonth(fofoId, startOfMonth);
|
|
|
736 |
|
| 28641 |
amit.gupta |
737 |
List<PriceDropBrandModel> priceDropBrandSixMonthTotals = priceDropRepository
|
|
|
738 |
.selectSixMonthBrandPriceDropByYearMonth(fofoId, startfMonthTotal, endMonthTotal);
|
|
|
739 |
|
| 28455 |
tejbeer |
740 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
|
|
741 |
|
|
|
742 |
Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
|
| 28641 |
amit.gupta |
743 |
|
|
|
744 |
LOGGER.info("priceDropBrandSixMonthTotals" + priceDropBrandSixMonthTotals);
|
| 28825 |
tejbeer |
745 |
|
|
|
746 |
Map<String, Double> priceDropBrandSixMonthMap = priceDropBrandSixMonthTotals.stream()
|
|
|
747 |
.collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getAmount()));
|
|
|
748 |
|
| 28641 |
amit.gupta |
749 |
model.addAttribute("priceDropBrandSixMonthMap", priceDropBrandSixMonthMap);
|
| 28455 |
tejbeer |
750 |
LOGGER.info("priceDropYearMonthModels" + priceDropYearMonthModels);
|
| 28641 |
amit.gupta |
751 |
|
| 28455 |
tejbeer |
752 |
for (PriceDropYearMonthModel pdm : priceDropYearMonthModels) {
|
| 28641 |
amit.gupta |
753 |
Map<YearMonth, Double> brandValue = new HashMap<>();
|
| 28455 |
tejbeer |
754 |
|
|
|
755 |
if (brandMonthValue.containsKey(pdm.getBrand())) {
|
|
|
756 |
brandValue = brandMonthValue.get(pdm.getBrand());
|
|
|
757 |
brandValue.put(YearMonth.parse(pdm.getYearMonth(), dateTimeFormatter), (double) pdm.getAmount());
|
|
|
758 |
} else {
|
|
|
759 |
|
|
|
760 |
brandValue.put(YearMonth.parse(pdm.getYearMonth(), dateTimeFormatter), (double) pdm.getAmount());
|
|
|
761 |
|
|
|
762 |
}
|
|
|
763 |
brandMonthValue.put(pdm.getBrand(), brandValue);
|
|
|
764 |
}
|
|
|
765 |
List<String> brands = new ArrayList<>();
|
|
|
766 |
brands.add("Accessories");
|
|
|
767 |
brands.add("Oppo");
|
|
|
768 |
brands.add("Vivo");
|
|
|
769 |
brands.add("Samsung");
|
|
|
770 |
brands.add("Realme");
|
| 28462 |
tejbeer |
771 |
brands.add("MI");
|
| 28455 |
tejbeer |
772 |
brands.add("Tecno");
|
|
|
773 |
brands.add("Itel");
|
|
|
774 |
brands.add("Nokia");
|
| 29578 |
tejbeer |
775 |
|
| 28455 |
tejbeer |
776 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
|
|
777 |
|
| 28825 |
tejbeer |
778 |
model.addAttribute("brands", brands);
|
|
|
779 |
|
| 28455 |
tejbeer |
780 |
for (String brand : brands) {
|
|
|
781 |
Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
|
| 29875 |
tejbeer |
782 |
for (int i = 5; i >= 0; i--) {
|
| 28455 |
tejbeer |
783 |
|
|
|
784 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
|
|
785 |
|
|
|
786 |
if (yearMonthValue != null) {
|
|
|
787 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
|
|
788 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
789 |
}
|
|
|
790 |
|
|
|
791 |
} else {
|
|
|
792 |
yearMonthValue = new HashMap<>();
|
|
|
793 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
794 |
}
|
|
|
795 |
}
|
|
|
796 |
|
|
|
797 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
|
|
798 |
|
|
|
799 |
brandMonthValue.put(brand, sortedMonthBrandValue);
|
|
|
800 |
|
|
|
801 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
|
|
802 |
|
|
|
803 |
}
|
|
|
804 |
|
| 29578 |
tejbeer |
805 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
|
|
806 |
model.addAttribute("fofoId", fofoId);
|
| 28455 |
tejbeer |
807 |
|
| 29578 |
tejbeer |
808 |
model.addAttribute("sortedBrandValue", sortedBrandValue);
|
| 28455 |
tejbeer |
809 |
|
| 29578 |
tejbeer |
810 |
return "price-drop-tabular";
|
|
|
811 |
}
|
| 28455 |
tejbeer |
812 |
|
| 29578 |
tejbeer |
813 |
@RequestMapping(value = "/getMonthlyActivation", method = RequestMethod.GET)
|
|
|
814 |
public String getMonthlyActivation(HttpServletRequest request, Model model) throws Exception {
|
|
|
815 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
816 |
int fofoId = loginDetails.getFofoId();
|
| 28455 |
tejbeer |
817 |
|
| 29578 |
tejbeer |
818 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
819 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
|
|
820 |
|
|
|
821 |
List<YearMonth> yms = new ArrayList<YearMonth>();
|
|
|
822 |
|
| 29580 |
tejbeer |
823 |
for (int i = 0; i <= 5; i++) {
|
| 29578 |
tejbeer |
824 |
yms.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
|
|
|
825 |
}
|
|
|
826 |
Collections.reverse(yms);
|
|
|
827 |
model.addAttribute("yms", yms);
|
|
|
828 |
LOGGER.info("ym" + yms);
|
|
|
829 |
|
|
|
830 |
List<ActivationYearMonthModel> pendingActivationModels = schemeInOutRepository
|
|
|
831 |
.selectPendingActivationGroupByBrandYearMonth(fofoId, startOfMonth);
|
|
|
832 |
|
|
|
833 |
List<ActivationBrandModel> pendingActivationBeforeSixMonth = schemeInOutRepository
|
|
|
834 |
.selectByYearMonthActivationGroupByBrand(fofoId, startOfMonth);
|
|
|
835 |
|
|
|
836 |
Map<String, Double> pendingActivationBeforeSixMonthMap = pendingActivationBeforeSixMonth.stream()
|
|
|
837 |
.collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getAmount()));
|
|
|
838 |
|
|
|
839 |
model.addAttribute("pendingActivationBeforeSixMonthMap", pendingActivationBeforeSixMonthMap);
|
|
|
840 |
|
|
|
841 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
|
|
842 |
|
|
|
843 |
Map<String, Map<YearMonth, Double>> activationBrandMonthMap = new HashMap<>();
|
|
|
844 |
|
|
|
845 |
for (ActivationYearMonthModel pam : pendingActivationModels) {
|
|
|
846 |
Map<YearMonth, Double> brandValue = new HashMap<>();
|
|
|
847 |
|
|
|
848 |
if (activationBrandMonthMap.containsKey(pam.getBrand())) {
|
|
|
849 |
brandValue = activationBrandMonthMap.get(pam.getBrand());
|
|
|
850 |
brandValue.put(YearMonth.parse(pam.getYearMonth(), dateTimeFormatter), (double) pam.getAmount());
|
|
|
851 |
} else {
|
|
|
852 |
|
|
|
853 |
brandValue.put(YearMonth.parse(pam.getYearMonth(), dateTimeFormatter), (double) pam.getAmount());
|
|
|
854 |
|
| 28455 |
tejbeer |
855 |
}
|
| 29578 |
tejbeer |
856 |
activationBrandMonthMap.put(pam.getBrand(), brandValue);
|
|
|
857 |
}
|
| 28455 |
tejbeer |
858 |
|
| 29578 |
tejbeer |
859 |
List<String> brands = new ArrayList<>();
|
|
|
860 |
brands.add("Oppo");
|
|
|
861 |
brands.add("Vivo");
|
|
|
862 |
brands.add("Samsung");
|
|
|
863 |
brands.add("Realme");
|
|
|
864 |
brands.add("MI");
|
|
|
865 |
brands.add("Tecno");
|
|
|
866 |
brands.add("Itel");
|
|
|
867 |
brands.add("Nokia");
|
|
|
868 |
brands.add("Lava");
|
|
|
869 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
|
|
870 |
|
|
|
871 |
model.addAttribute("brands", brands);
|
|
|
872 |
|
|
|
873 |
for (String brand : brands) {
|
|
|
874 |
Map<YearMonth, Double> yearMonthValue = activationBrandMonthMap.get(brand);
|
| 29580 |
tejbeer |
875 |
for (int i = 5; i >= 0; i--) {
|
| 29578 |
tejbeer |
876 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
|
|
877 |
if (yearMonthValue != null) {
|
|
|
878 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
|
|
879 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
880 |
}
|
|
|
881 |
|
|
|
882 |
} else {
|
|
|
883 |
yearMonthValue = new HashMap<>();
|
|
|
884 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
885 |
}
|
|
|
886 |
}
|
|
|
887 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
|
|
888 |
activationBrandMonthMap.put(brand, sortedMonthBrandValue);
|
|
|
889 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
| 28455 |
tejbeer |
890 |
}
|
|
|
891 |
|
| 29580 |
tejbeer |
892 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
| 29578 |
tejbeer |
893 |
model.addAttribute("sortedBrandValue", sortedBrandValue);
|
| 28455 |
tejbeer |
894 |
model.addAttribute("fofoId", fofoId);
|
| 29578 |
tejbeer |
895 |
return "activation-tabular";
|
|
|
896 |
}
|
| 28455 |
tejbeer |
897 |
|
| 29578 |
tejbeer |
898 |
@RequestMapping(value = "/getMonthlyActivationItemDetail", method = RequestMethod.GET)
|
|
|
899 |
public String getMonthlyActivationItemDetail(HttpServletRequest request,
|
| 29932 |
amit.gupta |
900 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
901 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
902 |
@RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model)
|
| 29578 |
tejbeer |
903 |
throws Exception {
|
| 28455 |
tejbeer |
904 |
|
| 29578 |
tejbeer |
905 |
LOGGER.info("params" + fofoId + brand + yearMonth);
|
|
|
906 |
|
|
|
907 |
List<ActivationItemDetailModel> activationItemDetails = schemeInOutRepository
|
|
|
908 |
.selectBrandPendingActivationItemDetails(fofoId, brand, yearMonth);
|
|
|
909 |
|
|
|
910 |
for (ActivationItemDetailModel activationItemDetail : activationItemDetails) {
|
|
|
911 |
|
|
|
912 |
List<FofoLineItem> flis = fofoLineItemRepository
|
|
|
913 |
.selectByInventoryItemId(activationItemDetail.getInventoryItemId());
|
|
|
914 |
|
|
|
915 |
LOGGER.info("flis" + flis);
|
|
|
916 |
|
|
|
917 |
int maxFofoOrderItemId = flis.stream().mapToInt(x -> x.getFofoOrderItemId()).max()
|
|
|
918 |
.orElseThrow(NoSuchElementException::new);
|
|
|
919 |
LOGGER.info("maxFofoOrderItemId" + maxFofoOrderItemId);
|
|
|
920 |
|
|
|
921 |
FofoOrderItem foi = fofoOrderItemRepository.selectById(maxFofoOrderItemId);
|
|
|
922 |
|
|
|
923 |
FofoOrder fo = fofoOrderRepository.selectByOrderId(foi.getOrderId());
|
|
|
924 |
|
|
|
925 |
activationItemDetail.setInvoiceNumber(fo.getInvoiceNumber());
|
|
|
926 |
|
|
|
927 |
}
|
|
|
928 |
LOGGER.info("activationItemDetails" + activationItemDetails);
|
|
|
929 |
|
|
|
930 |
model.addAttribute("activationItemDetails", activationItemDetails);
|
|
|
931 |
|
|
|
932 |
return "activation-pending-item-details";
|
| 28455 |
tejbeer |
933 |
}
|
|
|
934 |
|
| 29578 |
tejbeer |
935 |
@RequestMapping(value = "/getMonthlyActivationBeforeSixMonthsItemDetail", method = RequestMethod.GET)
|
|
|
936 |
public String getMonthlyActivationItemDetail(HttpServletRequest request,
|
| 29932 |
amit.gupta |
937 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
938 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
|
| 29578 |
tejbeer |
939 |
throws Exception {
|
|
|
940 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
941 |
|
|
|
942 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
|
|
943 |
|
|
|
944 |
List<ActivationItemDetailModel> activationItemDetails = schemeInOutRepository
|
|
|
945 |
.selectBrandPendingActivationItemDetailByYearMonth(fofoId, brand, startOfMonth);
|
|
|
946 |
|
|
|
947 |
for (ActivationItemDetailModel activationItemDetail : activationItemDetails) {
|
|
|
948 |
|
|
|
949 |
List<FofoLineItem> flis = fofoLineItemRepository
|
|
|
950 |
.selectByInventoryItemId(activationItemDetail.getInventoryItemId());
|
|
|
951 |
LOGGER.info("flis" + flis);
|
|
|
952 |
|
|
|
953 |
int maxFofoOrderItemId = flis.stream().mapToInt(x -> x.getFofoOrderItemId()).max()
|
|
|
954 |
.orElseThrow(NoSuchElementException::new);
|
|
|
955 |
LOGGER.info("maxFofoOrderItemId" + maxFofoOrderItemId);
|
|
|
956 |
|
|
|
957 |
FofoOrderItem foi = fofoOrderItemRepository.selectById(maxFofoOrderItemId);
|
|
|
958 |
|
|
|
959 |
FofoOrder fo = fofoOrderRepository.selectByOrderId(foi.getOrderId());
|
|
|
960 |
|
|
|
961 |
activationItemDetail.setInvoiceNumber(fo.getInvoiceNumber());
|
|
|
962 |
|
|
|
963 |
}
|
|
|
964 |
LOGGER.info("activationItemDetails" + activationItemDetails);
|
|
|
965 |
|
|
|
966 |
model.addAttribute("activationItemDetails", activationItemDetails);
|
|
|
967 |
|
|
|
968 |
return "activation-pending-item-details";
|
|
|
969 |
}
|
|
|
970 |
|
| 29707 |
tejbeer |
971 |
@RequestMapping(value = "/getMonthlySamsungUpgradeOffer", method = RequestMethod.GET)
|
|
|
972 |
public String getMonthlySamsungUpgradeOffer(HttpServletRequest request, Model model) throws Exception {
|
|
|
973 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
974 |
int fofoId = loginDetails.getFofoId();
|
|
|
975 |
|
|
|
976 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
977 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
|
|
978 |
|
|
|
979 |
List<YearMonth> yms = new ArrayList<YearMonth>();
|
|
|
980 |
|
|
|
981 |
for (int i = 0; i <= 5; i++) {
|
|
|
982 |
yms.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
|
|
|
983 |
}
|
|
|
984 |
Collections.reverse(yms);
|
|
|
985 |
model.addAttribute("yms", yms);
|
|
|
986 |
LOGGER.info("ym" + yms);
|
|
|
987 |
|
|
|
988 |
List<SamsungUpgradeOfferModel> suos = samsungUpgradeOfferRepository.selectUpgradeOfferGroupByYearMonth(fofoId,
|
|
|
989 |
UpgradeOfferStatus.approved, startOfMonth);
|
|
|
990 |
|
|
|
991 |
LOGGER.info("suos" + suos);
|
|
|
992 |
|
|
|
993 |
List<BrandAmountModel> beforeSixMonthOffers = samsungUpgradeOfferRepository
|
|
|
994 |
.selectUpgradeOfferByYearMonthGroupByBrand(fofoId, UpgradeOfferStatus.approved, startOfMonth);
|
|
|
995 |
|
|
|
996 |
Map<String, Double> pendingUpgradeOfferBeforeSixMonthMap = beforeSixMonthOffers.stream()
|
|
|
997 |
.collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getAmount()));
|
|
|
998 |
|
|
|
999 |
model.addAttribute("pendingUpgradeOfferBeforeSixMonthMap", pendingUpgradeOfferBeforeSixMonthMap);
|
|
|
1000 |
|
|
|
1001 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
|
|
1002 |
|
|
|
1003 |
Map<String, Map<YearMonth, Double>> upgradeOfferBrandMonthMap = new HashMap<>();
|
|
|
1004 |
|
|
|
1005 |
for (SamsungUpgradeOfferModel suo : suos) {
|
|
|
1006 |
Map<YearMonth, Double> brandValue = new HashMap<>();
|
|
|
1007 |
|
|
|
1008 |
if (upgradeOfferBrandMonthMap.containsKey(suo.getBrand())) {
|
|
|
1009 |
brandValue = upgradeOfferBrandMonthMap.get(suo.getBrand());
|
|
|
1010 |
brandValue.put(YearMonth.parse(suo.getYearMonth(), dateTimeFormatter), (double) suo.getAmount());
|
|
|
1011 |
} else {
|
|
|
1012 |
|
|
|
1013 |
brandValue.put(YearMonth.parse(suo.getYearMonth(), dateTimeFormatter), (double) suo.getAmount());
|
|
|
1014 |
|
|
|
1015 |
}
|
|
|
1016 |
upgradeOfferBrandMonthMap.put(suo.getBrand(), brandValue);
|
|
|
1017 |
}
|
|
|
1018 |
|
|
|
1019 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
|
|
1020 |
String brand = "Samsung";
|
|
|
1021 |
|
|
|
1022 |
Map<YearMonth, Double> yearMonthValue = upgradeOfferBrandMonthMap.get(brand);
|
|
|
1023 |
for (int i = 5; i >= 0; i--) {
|
|
|
1024 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
|
|
1025 |
if (yearMonthValue != null) {
|
|
|
1026 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
|
|
1027 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
1028 |
}
|
|
|
1029 |
|
|
|
1030 |
} else {
|
|
|
1031 |
yearMonthValue = new HashMap<>();
|
|
|
1032 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
1033 |
}
|
|
|
1034 |
}
|
|
|
1035 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
|
|
1036 |
upgradeOfferBrandMonthMap.put(brand, sortedMonthBrandValue);
|
|
|
1037 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
|
|
1038 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
|
|
1039 |
|
|
|
1040 |
model.addAttribute("brand", brand);
|
|
|
1041 |
model.addAttribute("sortedBrandValue", sortedBrandValue);
|
|
|
1042 |
model.addAttribute("fofoId", fofoId);
|
|
|
1043 |
return "upgrade-offer-tabular";
|
|
|
1044 |
|
|
|
1045 |
}
|
|
|
1046 |
|
|
|
1047 |
@RequestMapping(value = "/getMonthlyUpgradeOfferItemDetail", method = RequestMethod.GET)
|
|
|
1048 |
public String getMonthlyUpgradeOfferItemDetail(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1049 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
1050 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
1051 |
@RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model)
|
| 29707 |
tejbeer |
1052 |
throws Exception {
|
|
|
1053 |
|
|
|
1054 |
LOGGER.info("params" + fofoId + brand + yearMonth);
|
|
|
1055 |
List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository
|
|
|
1056 |
.selectUpgradeOfferItemDetails(fofoId, UpgradeOfferStatus.approved, brand, yearMonth);
|
|
|
1057 |
|
|
|
1058 |
model.addAttribute("offerItems", offerItems);
|
|
|
1059 |
|
|
|
1060 |
return "upgrade-offer-item-detail";
|
|
|
1061 |
}
|
|
|
1062 |
|
|
|
1063 |
@RequestMapping(value = "/getUpgradeOfferBeforeSixMonthItemDetail", method = RequestMethod.GET)
|
|
|
1064 |
public String getUpgradeOfferBeforeSixMonthItemDetail(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1065 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
1066 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
|
| 29707 |
tejbeer |
1067 |
throws Exception {
|
|
|
1068 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1069 |
|
|
|
1070 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
|
|
1071 |
|
|
|
1072 |
List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository
|
|
|
1073 |
.selectUpgradeOfferItemDetailByYearMonth(fofoId, UpgradeOfferStatus.approved, brand, startOfMonth);
|
|
|
1074 |
|
|
|
1075 |
model.addAttribute("offerItems", offerItems);
|
|
|
1076 |
|
|
|
1077 |
return "upgrade-offer-item-detail";
|
|
|
1078 |
}
|
|
|
1079 |
|
| 26468 |
amit.gupta |
1080 |
@RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
|
| 26418 |
tejbeer |
1081 |
public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId)
|
|
|
1082 |
throws Exception {
|
|
|
1083 |
|
|
|
1084 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
| 26963 |
amit.gupta |
1085 |
Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
|
| 26418 |
tejbeer |
1086 |
|
| 26468 |
amit.gupta |
1087 |
Map<Integer, PartnerDetailModel> fofoIdAndallValues = partnerStatsService.getAllPartnerStats();
|
|
|
1088 |
if (authId != 0) {
|
|
|
1089 |
List<Integer> fofoIds = pp.get(authId);
|
|
|
1090 |
fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
|
|
|
1091 |
.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
| 26474 |
amit.gupta |
1092 |
} else {
|
| 26418 |
tejbeer |
1093 |
}
|
|
|
1094 |
|
|
|
1095 |
model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
|
|
|
1096 |
model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
|
|
|
1097 |
|
|
|
1098 |
return "auth_user_partner_detail";
|
| 26468 |
amit.gupta |
1099 |
}
|
| 26418 |
tejbeer |
1100 |
|
| 27545 |
tejbeer |
1101 |
@RequestMapping(value = "/getWarehousePartners", method = RequestMethod.GET)
|
|
|
1102 |
public String warehousePartnersDetail(HttpServletRequest request, Model model, @RequestParam int warehouseId)
|
|
|
1103 |
throws Exception {
|
| 27701 |
tejbeer |
1104 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1105 |
String email = loginDetails.getEmailId();
|
| 28472 |
tejbeer |
1106 |
|
|
|
1107 |
Set<Integer> authfofoIds = new HashSet<>();
|
| 27701 |
tejbeer |
1108 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 28472 |
tejbeer |
1109 |
authfofoIds = storeGuyMap.get(email);
|
| 27545 |
tejbeer |
1110 |
|
| 28472 |
tejbeer |
1111 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
1112 |
if (authfofoIds == null) {
|
|
|
1113 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
|
|
1114 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
|
|
|
1115 |
.count() > 0) {
|
|
|
1116 |
authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
|
|
|
1117 |
.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
1118 |
}
|
|
|
1119 |
}
|
| 27701 |
tejbeer |
1120 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
|
|
1121 |
.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
|
|
|
1122 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
1123 |
|
| 27545 |
tejbeer |
1124 |
Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
|
| 28468 |
tejbeer |
1125 |
Map<Integer, PartnerDetailModel> fofoIdAndallValues = adminUser.getPartnersStatDataFromFile();
|
| 27545 |
tejbeer |
1126 |
if (warehouseId != 0) {
|
| 27701 |
tejbeer |
1127 |
List<Integer> fofoIds = warehouseIdFofoIdMap.get(warehouseId);
|
|
|
1128 |
/*
|
|
|
1129 |
* List<Integer> fofoIds =
|
|
|
1130 |
* fofoStoreRepository.selectActivePartnerByWarehouse(warehouseId).stream()
|
|
|
1131 |
* .map(x -> x.getId()).collect(Collectors.toList());
|
|
|
1132 |
*/
|
| 27545 |
tejbeer |
1133 |
fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
|
|
|
1134 |
.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
|
|
1135 |
} else {
|
| 28472 |
tejbeer |
1136 |
|
|
|
1137 |
List<Integer> fofoIds = new ArrayList<>(authfofoIds);
|
|
|
1138 |
fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
|
| 27701 |
tejbeer |
1139 |
.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
| 27545 |
tejbeer |
1140 |
}
|
| 29164 |
manish |
1141 |
ChartInvestmentModel cm = adminUser.getAllStatePartnerType(fofoIdAndallValues);
|
|
|
1142 |
model.addAttribute("chartPieMap", gson.toJson(cm));
|
| 27545 |
tejbeer |
1143 |
|
| 29164 |
manish |
1144 |
LOGGER.info("adminUserChart" + gson.toJson(cm));
|
|
|
1145 |
|
| 27545 |
tejbeer |
1146 |
model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
|
|
|
1147 |
model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
|
|
|
1148 |
|
|
|
1149 |
return "auth_user_partner_detail";
|
|
|
1150 |
}
|
|
|
1151 |
|
| 27509 |
tejbeer |
1152 |
@RequestMapping(value = "/getWarehouseWiseBrandStock", method = RequestMethod.GET)
|
| 27701 |
tejbeer |
1153 |
public String getWarehouseWiseBrandStock(HttpServletRequest request, Model model,
|
| 29932 |
amit.gupta |
1154 |
@RequestParam List<Integer> warehouseId) throws Exception {
|
| 27701 |
tejbeer |
1155 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1156 |
String email = loginDetails.getEmailId();
|
|
|
1157 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1158 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 28471 |
tejbeer |
1159 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| 27509 |
tejbeer |
1160 |
|
| 28471 |
tejbeer |
1161 |
if (authfofoIds == null) {
|
|
|
1162 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
|
|
1163 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
|
|
|
1164 |
.count() > 0) {
|
|
|
1165 |
authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
|
|
|
1166 |
.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
1167 |
}
|
|
|
1168 |
}
|
|
|
1169 |
|
| 27701 |
tejbeer |
1170 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
|
|
1171 |
.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
|
|
|
1172 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
1173 |
List<WarehouseWiseBrandStockModel> warehouseWiseBrandStock = new ArrayList<>();
|
|
|
1174 |
if (!warehouseId.contains(0)) {
|
|
|
1175 |
warehouseWiseBrandStock = saholicInventoryCISRepository.selectGroupByWarehouseAndBrand(warehouseId);
|
|
|
1176 |
} else {
|
|
|
1177 |
LOGGER.info("warehouseIdFofoIdMap" + warehouseIdFofoIdMap.keySet());
|
|
|
1178 |
warehouseWiseBrandStock = saholicInventoryCISRepository
|
|
|
1179 |
.selectGroupByWarehouseAndBrand(new ArrayList<>(warehouseIdFofoIdMap.keySet()));
|
|
|
1180 |
|
|
|
1181 |
}
|
| 27542 |
tejbeer |
1182 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27509 |
tejbeer |
1183 |
model.addAttribute("warehouseWiseBrandStock", warehouseWiseBrandStock);
|
| 27542 |
tejbeer |
1184 |
model.addAttribute("warehouseId", warehouseId);
|
| 27509 |
tejbeer |
1185 |
model.addAttribute("warehouseMap", warehouseMap);
|
| 27660 |
tejbeer |
1186 |
|
| 27509 |
tejbeer |
1187 |
return "warehouse_brand_stock";
|
|
|
1188 |
}
|
|
|
1189 |
|
| 27529 |
tejbeer |
1190 |
@RequestMapping(value = "/getWarehouseWiseData", method = RequestMethod.GET)
|
|
|
1191 |
public String getWarehouseWiseData(HttpServletRequest request, Model model) throws Exception {
|
|
|
1192 |
inventoryService.getItemAvailabilityAndIndent();
|
|
|
1193 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
1194 |
return "response";
|
|
|
1195 |
}
|
|
|
1196 |
|
| 27628 |
tejbeer |
1197 |
@RequestMapping(value = "/getPartnersStatData", method = RequestMethod.GET)
|
|
|
1198 |
public String getPartnersStatData(HttpServletRequest request, Model model) throws Exception {
|
|
|
1199 |
Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
|
|
|
1200 |
ObjectOutputStream oos = null;
|
|
|
1201 |
FileOutputStream fout = null;
|
|
|
1202 |
try {
|
|
|
1203 |
fout = new FileOutputStream("/tmp/partnerStat.tmp", false);
|
|
|
1204 |
oos = new ObjectOutputStream(fout);
|
|
|
1205 |
oos.writeObject(partnerStats);
|
|
|
1206 |
|
|
|
1207 |
} catch (Exception ex) {
|
|
|
1208 |
ex.printStackTrace();
|
|
|
1209 |
} finally {
|
|
|
1210 |
if (oos != null) {
|
|
|
1211 |
oos.close();
|
|
|
1212 |
}
|
|
|
1213 |
}
|
|
|
1214 |
ReporticoCacheTable rct = reporticoCacheTableRepository.selectByTableName("partnerStat");
|
|
|
1215 |
if (rct == null) {
|
|
|
1216 |
rct = new ReporticoCacheTable();
|
|
|
1217 |
rct.setTableName("partnerStat");
|
|
|
1218 |
|
|
|
1219 |
}
|
|
|
1220 |
rct.setLastCreatedTimestamp(LocalDateTime.now());
|
|
|
1221 |
reporticoCacheTableRepository.persist(rct);
|
|
|
1222 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
1223 |
return "response";
|
|
|
1224 |
}
|
|
|
1225 |
|
| 27539 |
tejbeer |
1226 |
@RequestMapping(value = "/getWarehouseWiseBrandAndCategory", method = RequestMethod.GET)
|
|
|
1227 |
public String getWarehouseWiseBrandAndCategory(HttpServletRequest request, Model model,
|
| 29932 |
amit.gupta |
1228 |
@RequestParam List<Integer> warehouseId, @RequestParam List<String> brands, @RequestParam String category)
|
| 27538 |
tejbeer |
1229 |
throws Exception {
|
| 27509 |
tejbeer |
1230 |
|
|
|
1231 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27529 |
tejbeer |
1232 |
List<String> listbrands = saholicInventoryCISRepository.selectAllBrand();
|
| 27538 |
tejbeer |
1233 |
List<String> listCategory = saholicInventoryCISRepository.selectAllSubCategory();
|
| 27539 |
tejbeer |
1234 |
|
| 27509 |
tejbeer |
1235 |
model.addAttribute("warehouseMap", warehouseMap);
|
| 27529 |
tejbeer |
1236 |
model.addAttribute("brands", listbrands);
|
| 27538 |
tejbeer |
1237 |
model.addAttribute("listCategory", listCategory);
|
|
|
1238 |
|
| 27529 |
tejbeer |
1239 |
model.addAttribute("selectedBrand", brands);
|
| 27538 |
tejbeer |
1240 |
model.addAttribute("selectedWarehouse", warehouseId);
|
| 27539 |
tejbeer |
1241 |
model.addAttribute("selectedCategory", category);
|
|
|
1242 |
|
| 27509 |
tejbeer |
1243 |
return "warehouse_brand_item_stock";
|
|
|
1244 |
}
|
|
|
1245 |
|
| 27538 |
tejbeer |
1246 |
@RequestMapping(value = "/getWarehouseWiseItemStock", method = RequestMethod.GET)
|
|
|
1247 |
public String getWarehouseWiseItemStock(HttpServletRequest request, Model model,
|
| 29932 |
amit.gupta |
1248 |
@RequestParam List<Integer> warehouseId, @RequestParam List<String> brands, @RequestParam String category)
|
| 27538 |
tejbeer |
1249 |
throws Exception {
|
| 27539 |
tejbeer |
1250 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1251 |
if (warehouseId.contains(0)) {
|
|
|
1252 |
warehouseId.addAll(warehouseMap.keySet());
|
|
|
1253 |
}
|
| 27538 |
tejbeer |
1254 |
List<WarehouseWiseitemStockModel> warehouseWiseItemStock = saholicInventoryCISRepository
|
|
|
1255 |
.selectWarehouseItemStock(warehouseId, brands, category);
|
| 27539 |
tejbeer |
1256 |
|
| 27538 |
tejbeer |
1257 |
model.addAttribute("warehouseWiseItemStock", warehouseWiseItemStock);
|
|
|
1258 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1259 |
return "warehouse_item_details";
|
|
|
1260 |
}
|
|
|
1261 |
|
| 27556 |
tejbeer |
1262 |
@RequestMapping(value = "/getWarehouseWiseBrandPartnerSale", method = RequestMethod.GET)
|
| 27591 |
tejbeer |
1263 |
public String getWarehouseWiseBrandPartnerSale(HttpServletRequest request, Model model, @RequestParam String brand)
|
|
|
1264 |
throws Exception {
|
| 27701 |
tejbeer |
1265 |
|
|
|
1266 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1267 |
String email = loginDetails.getEmailId();
|
|
|
1268 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1269 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
|
|
1270 |
|
| 28472 |
tejbeer |
1271 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
1272 |
if (authfofoIds == null) {
|
|
|
1273 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
|
|
1274 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
|
|
|
1275 |
.count() > 0) {
|
|
|
1276 |
authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
|
|
|
1277 |
.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
1278 |
}
|
|
|
1279 |
}
|
|
|
1280 |
|
| 27670 |
tejbeer |
1281 |
Map<Integer, WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
|
| 27701 |
tejbeer |
1282 |
.selectGroupByWarehouseBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds)).stream()
|
| 27670 |
tejbeer |
1283 |
.collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
|
|
|
1284 |
|
|
|
1285 |
List<WarehouseWiseBrandUnbilledActivatedModel> unbilledStock = fofoStoreRepository
|
| 27701 |
tejbeer |
1286 |
.selectUnbilledActivateStockGroupByWarehouse(brand, new ArrayList<>(authfofoIds));
|
| 27670 |
tejbeer |
1287 |
|
|
|
1288 |
for (WarehouseWiseBrandUnbilledActivatedModel un : unbilledStock) {
|
|
|
1289 |
WarehouseWiseBrandSaleModel bpt = warehouseWiseBrandPartnerSales.get(un.getWarehouseId());
|
|
|
1290 |
if (bpt != null) {
|
|
|
1291 |
bpt.setAmtd(un.getUnbilledMtd());
|
| 27676 |
tejbeer |
1292 |
bpt.setUamtdQty(un.getUnbilledQty());
|
| 27670 |
tejbeer |
1293 |
} else {
|
|
|
1294 |
bpt = new WarehouseWiseBrandSaleModel();
|
|
|
1295 |
bpt.setWarehouseId(un.getWarehouseId());
|
|
|
1296 |
bpt.setAmtd(un.getUnbilledMtd());
|
| 27677 |
tejbeer |
1297 |
bpt.setUamtdQty(un.getUnbilledQty());
|
| 27670 |
tejbeer |
1298 |
bpt.setLms(0);
|
|
|
1299 |
bpt.setLmtd(0);
|
|
|
1300 |
bpt.setMtd(0);
|
|
|
1301 |
bpt.setMtdQty(0);
|
|
|
1302 |
bpt.setLmtd(0);
|
|
|
1303 |
bpt.setLmtdQty(0);
|
|
|
1304 |
warehouseWiseBrandPartnerSales.put(un.getWarehouseId(), bpt);
|
|
|
1305 |
}
|
|
|
1306 |
}
|
| 27556 |
tejbeer |
1307 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27591 |
tejbeer |
1308 |
|
|
|
1309 |
Set<String> brands = inventoryService.getAllTagListingBrands();
|
|
|
1310 |
model.addAttribute("warehouseWiseBrandPartnerSales", warehouseWiseBrandPartnerSales);
|
| 27556 |
tejbeer |
1311 |
model.addAttribute("warehouseMap", warehouseMap);
|
| 27591 |
tejbeer |
1312 |
model.addAttribute("brands", brands);
|
|
|
1313 |
model.addAttribute("selectedbrand", brand);
|
|
|
1314 |
return "warehousewise_brand_partners_sale";
|
| 27556 |
tejbeer |
1315 |
}
|
|
|
1316 |
|
| 27594 |
tejbeer |
1317 |
@RequestMapping(value = "/getWarehouseWiseAccesoriesBrandPartnerSale", method = RequestMethod.GET)
|
|
|
1318 |
public String getWarehouseWiseAccesoriesBrandPartnerSale(HttpServletRequest request, Model model,
|
| 29932 |
amit.gupta |
1319 |
@RequestParam String brand) throws Exception {
|
| 27701 |
tejbeer |
1320 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1321 |
String email = loginDetails.getEmailId();
|
|
|
1322 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1323 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 28472 |
tejbeer |
1324 |
|
|
|
1325 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
1326 |
if (authfofoIds == null) {
|
|
|
1327 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
|
|
1328 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
|
|
|
1329 |
.count() > 0) {
|
|
|
1330 |
authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
|
|
|
1331 |
.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
1332 |
}
|
|
|
1333 |
}
|
| 27594 |
tejbeer |
1334 |
List<WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
|
| 27701 |
tejbeer |
1335 |
.selectGroupByWarehouseAccesoriesBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds));
|
| 27594 |
tejbeer |
1336 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1337 |
|
|
|
1338 |
Set<String> brands = inventoryService.getAllTagListingBrands();
|
|
|
1339 |
model.addAttribute("warehouseWiseBrandPartnerSales", warehouseWiseBrandPartnerSales);
|
|
|
1340 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1341 |
model.addAttribute("brands", brands);
|
|
|
1342 |
model.addAttribute("selectedbrand", brand);
|
|
|
1343 |
return "warehousewise_accessoriesbrand_sale";
|
|
|
1344 |
}
|
|
|
1345 |
|
| 27556 |
tejbeer |
1346 |
@RequestMapping(value = "/getWarehouseBrandWiseItemSale", method = RequestMethod.GET)
|
|
|
1347 |
public String getWarehouseBrandWiseItemSale(HttpServletRequest request, Model model,
|
| 29932 |
amit.gupta |
1348 |
@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
| 27556 |
tejbeer |
1349 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27701 |
tejbeer |
1350 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1351 |
String email = loginDetails.getEmailId();
|
|
|
1352 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1353 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 27670 |
tejbeer |
1354 |
Map<Integer, WarehouseBrandWiseItemSaleModel> branditemSalesMap = fofoStoreRepository
|
| 27701 |
tejbeer |
1355 |
.selectWarehouseBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds)).stream()
|
| 27670 |
tejbeer |
1356 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
|
|
1357 |
|
|
|
1358 |
List<WarehouseBrandItemUnbilledActivatedModel> unbilledItems = fofoStoreRepository
|
| 27701 |
tejbeer |
1359 |
.selectWarehouseBrandItemUnbilledActivateStock(warehouseId, brand, new ArrayList<>(authfofoIds));
|
| 27670 |
tejbeer |
1360 |
|
|
|
1361 |
for (WarehouseBrandItemUnbilledActivatedModel un : unbilledItems) {
|
|
|
1362 |
WarehouseBrandWiseItemSaleModel bpt = branditemSalesMap.get(un.getItemId());
|
|
|
1363 |
if (bpt != null) {
|
|
|
1364 |
bpt.setAmtd(un.getAmtd());
|
| 27676 |
tejbeer |
1365 |
bpt.setUamtdQty(un.getUnmtdQty());
|
| 27670 |
tejbeer |
1366 |
} else {
|
|
|
1367 |
bpt = new WarehouseBrandWiseItemSaleModel();
|
|
|
1368 |
bpt.setWarehouseId(un.getWarehouseId());
|
|
|
1369 |
bpt.setItemId(un.getItemId());
|
|
|
1370 |
bpt.setAmtd(un.getAmtd());
|
| 27677 |
tejbeer |
1371 |
bpt.setUamtdQty(un.getUnmtdQty());
|
| 27670 |
tejbeer |
1372 |
bpt.setBrand(un.getBrand());
|
|
|
1373 |
bpt.setModelName(un.getModelName());
|
|
|
1374 |
bpt.setModelNumber(un.getModelNumber());
|
|
|
1375 |
bpt.setColor(un.getColor());
|
|
|
1376 |
bpt.setLms(0);
|
|
|
1377 |
bpt.setLmtd(0);
|
|
|
1378 |
bpt.setMtd(0);
|
|
|
1379 |
bpt.setMtdQty(0);
|
|
|
1380 |
bpt.setLmtd(0);
|
|
|
1381 |
bpt.setLmtdQty(0);
|
|
|
1382 |
branditemSalesMap.put(un.getItemId(), bpt);
|
|
|
1383 |
}
|
|
|
1384 |
}
|
|
|
1385 |
model.addAttribute("branditemSales", branditemSalesMap);
|
| 27556 |
tejbeer |
1386 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1387 |
return "warehouse_partner_itemwise_sale";
|
|
|
1388 |
}
|
|
|
1389 |
|
| 27594 |
tejbeer |
1390 |
@RequestMapping(value = "/getWarehouseAccesoriesBrandWiseItemSale", method = RequestMethod.GET)
|
|
|
1391 |
public String getWarehouseAccesoriesBrandWiseItemSale(HttpServletRequest request, Model model,
|
| 29932 |
amit.gupta |
1392 |
@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
| 27594 |
tejbeer |
1393 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27701 |
tejbeer |
1394 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1395 |
String email = loginDetails.getEmailId();
|
|
|
1396 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1397 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 27594 |
tejbeer |
1398 |
List<WarehouseBrandWiseItemSaleModel> branditemSales = fofoStoreRepository
|
| 27701 |
tejbeer |
1399 |
.selectWarehouseAccesoriesBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds));
|
| 27594 |
tejbeer |
1400 |
model.addAttribute("branditemSales", branditemSales);
|
|
|
1401 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1402 |
return "warehouse_accessories_itemwsie_sale";
|
|
|
1403 |
}
|
|
|
1404 |
|
| 22354 |
ashik.ali |
1405 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 23923 |
amit.gupta |
1406 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 22354 |
ashik.ali |
1407 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
1408 |
return "contact-us";
|
|
|
1409 |
}
|
| 23923 |
amit.gupta |
1410 |
|
| 25649 |
tejbeer |
1411 |
@RequestMapping(value = "/notifications", method = RequestMethod.GET)
|
| 25683 |
tejbeer |
1412 |
public String getNotificationsWithType(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1413 |
@RequestParam(required = false) MessageType messageType,
|
|
|
1414 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
1415 |
@RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
|
| 25649 |
tejbeer |
1416 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26060 |
tejbeer |
1417 |
int userId = 0;
|
|
|
1418 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
1419 |
if (isAdmin) {
|
|
|
1420 |
userId = loginDetails.getFofoId();
|
|
|
1421 |
} else {
|
|
|
1422 |
userId = userAccountRepository.selectUserIdByRetailerId(loginDetails.getFofoId());
|
|
|
1423 |
}
|
| 25683 |
tejbeer |
1424 |
List<Notification> notifications = null;
|
|
|
1425 |
|
| 26086 |
tejbeer |
1426 |
List<NotificationCampaign> notificationCampaigns = notificationCampaignRepository.getNotifications(messageType,
|
|
|
1427 |
userId, offset, limit);
|
|
|
1428 |
LOGGER.info("messageType" + messageType);
|
| 28468 |
tejbeer |
1429 |
notifications = fofoUser.getNotifications(notificationCampaigns, messageType);
|
| 26086 |
tejbeer |
1430 |
|
| 25683 |
tejbeer |
1431 |
model.addAttribute("notifications", notifications);
|
|
|
1432 |
|
|
|
1433 |
LOGGER.info("notifications" + notifications);
|
|
|
1434 |
return "notification-template";
|
|
|
1435 |
}
|
|
|
1436 |
|
| 25651 |
tejbeer |
1437 |
@RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
|
|
|
1438 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1439 |
@RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, @RequestParam int cid)
|
| 25651 |
tejbeer |
1440 |
throws ProfitMandiBusinessException {
|
|
|
1441 |
Document document = documentRepository.selectById(documentId);
|
|
|
1442 |
NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
|
|
|
1443 |
if (nc.getDocumentId() == null) {
|
|
|
1444 |
throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
|
|
|
1445 |
}
|
|
|
1446 |
if (nc.getDocumentId() != documentId) {
|
|
|
1447 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, documentId, "RTLR_1014");
|
|
|
1448 |
}
|
|
|
1449 |
return responseSender.ok(document);
|
| 25649 |
tejbeer |
1450 |
}
|
|
|
1451 |
|
| 25651 |
tejbeer |
1452 |
@RequestMapping(value = "/notifyDocument/download", method = RequestMethod.GET)
|
|
|
1453 |
public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request, @RequestParam int cid, Model model)
|
|
|
1454 |
throws ProfitMandiBusinessException {
|
|
|
1455 |
|
|
|
1456 |
NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
|
|
|
1457 |
|
|
|
1458 |
if (nc.getDocumentId() == null) {
|
|
|
1459 |
throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
|
|
|
1460 |
}
|
|
|
1461 |
|
|
|
1462 |
Document document = documentRepository.selectById(nc.getDocumentId());
|
|
|
1463 |
|
|
|
1464 |
FileInputStream file = null;
|
|
|
1465 |
try {
|
|
|
1466 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
|
|
1467 |
} catch (FileNotFoundException e) {
|
|
|
1468 |
LOGGER.error("Retailer Document file not found : ", e);
|
|
|
1469 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
|
|
1470 |
}
|
|
|
1471 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
|
|
1472 |
// ByteArrayOutputStream();
|
|
|
1473 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
|
|
1474 |
|
|
|
1475 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
1476 |
String contentType = "";
|
|
|
1477 |
if (document.getContentType() == ContentType.JPEG) {
|
|
|
1478 |
contentType = "image/jpeg";
|
|
|
1479 |
} else if (document.getContentType() == ContentType.PNG) {
|
|
|
1480 |
contentType = "image/png";
|
|
|
1481 |
} else if (document.getContentType() == ContentType.PDF) {
|
|
|
1482 |
contentType = "application/pdf";
|
|
|
1483 |
}
|
|
|
1484 |
headers.set("Content-Type", contentType);
|
|
|
1485 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
|
|
1486 |
headers.setContentLength(document.getSize());
|
|
|
1487 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
|
|
1488 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
1489 |
}
|
| 26460 |
amit.gupta |
1490 |
|
| 27579 |
tejbeer |
1491 |
@RequestMapping(value = "/getItemWiseTertiary", method = RequestMethod.GET)
|
|
|
1492 |
public String getItemWiseTertiary(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1493 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model)
|
| 27579 |
tejbeer |
1494 |
throws ProfitMandiBusinessException {
|
|
|
1495 |
List<ItemWiseTertiaryModel> itemWiseTertiary = fofoOrderRepository.SelectItemWiseTertiary(fofoId);
|
|
|
1496 |
|
|
|
1497 |
LOGGER.info("itemWiseTertiary" + itemWiseTertiary);
|
| 27586 |
tejbeer |
1498 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1499 |
model.addAttribute("customRetailer", customRetailer);
|
| 27579 |
tejbeer |
1500 |
model.addAttribute("itemWiseTertiary", itemWiseTertiary);
|
|
|
1501 |
return "item-wise-tertiary";
|
|
|
1502 |
}
|
|
|
1503 |
|
| 27586 |
tejbeer |
1504 |
@RequestMapping(value = "/getItemWiseIndent", method = RequestMethod.GET)
|
|
|
1505 |
public String getItemWiseIndent(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1506 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model)
|
| 27586 |
tejbeer |
1507 |
throws ProfitMandiBusinessException {
|
|
|
1508 |
|
|
|
1509 |
List<Order> unbilledOrders = transactionService.getInTransitOrders(fofoId);
|
|
|
1510 |
model.addAttribute("unbilledOrders", unbilledOrders);
|
|
|
1511 |
|
|
|
1512 |
return "item-wise-indent";
|
|
|
1513 |
}
|
|
|
1514 |
|
| 27636 |
tejbeer |
1515 |
@RequestMapping(value = "/getPartnerInvestment", method = RequestMethod.GET)
|
|
|
1516 |
public String getPartnerInvestment(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1517 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 28468 |
tejbeer |
1518 |
Map<Integer, PartnerDetailModel> partnerStats = adminUser.getPartnersStatDataFromFile();
|
| 27636 |
tejbeer |
1519 |
PartnerDetailModel partnerDetailModel = partnerStats.get(fofoId);
|
|
|
1520 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1521 |
model.addAttribute("partnerDetailModel", partnerDetailModel);
|
|
|
1522 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
1523 |
return "partner-investment";
|
|
|
1524 |
}
|
| 27727 |
tejbeer |
1525 |
|
| 27704 |
amit.gupta |
1526 |
@RequestMapping(value = "/getPartnerPendingIndentItem", method = RequestMethod.GET)
|
|
|
1527 |
public String getPartnerPendingIndentItem(HttpServletRequest request, @RequestParam int warehouseId,
|
| 29932 |
amit.gupta |
1528 |
@RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
|
| 27704 |
amit.gupta |
1529 |
List<PartnerPendingIndentItemModel> partnerPendingIndent = fofoStoreRepository
|
|
|
1530 |
.selectPartnerPendingIndentItem(itemId, warehouseId);
|
| 27636 |
tejbeer |
1531 |
|
| 27704 |
amit.gupta |
1532 |
model.addAttribute("partnerPendingIndent", partnerPendingIndent);
|
|
|
1533 |
return "partner-pending-indent-item";
|
|
|
1534 |
}
|
|
|
1535 |
|
| 27636 |
tejbeer |
1536 |
@RequestMapping(value = "/getPatnerActivateStock", method = RequestMethod.GET)
|
|
|
1537 |
public String getPartnerActivateStockItem(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1538 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 27636 |
tejbeer |
1539 |
List<ActivateItemModel> activateStocks = new ArrayList<>();
|
|
|
1540 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByActivatedNotSold(fofoId);
|
|
|
1541 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1542 |
|
|
|
1543 |
for (InventoryItem inventoryItem : inventoryItems) {
|
|
|
1544 |
TagListing tagListing = tagListingRepository.selectByItemId(inventoryItem.getItemId());
|
|
|
1545 |
Item item = itemRepository.selectById(inventoryItem.getItemId());
|
|
|
1546 |
ActivateItemModel aim = new ActivateItemModel();
|
|
|
1547 |
aim.setFofoId(inventoryItem.getFofoId());
|
|
|
1548 |
aim.setQuantity(inventoryItem.getGoodQuantity());
|
|
|
1549 |
aim.setAmount(tagListing.getSellingPrice());
|
|
|
1550 |
aim.setItemDescription(item.getItemDescription());
|
|
|
1551 |
aim.setItemId(inventoryItem.getItemId());
|
|
|
1552 |
activateStocks.add(aim);
|
|
|
1553 |
}
|
|
|
1554 |
|
|
|
1555 |
model.addAttribute("activateStocks", activateStocks);
|
|
|
1556 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
1557 |
return "partner-activate-stock";
|
|
|
1558 |
}
|
|
|
1559 |
|
|
|
1560 |
@RequestMapping(value = "/getPatnerBrandWiseMTDSale", method = RequestMethod.GET)
|
|
|
1561 |
public String getPatnerBrandWiseMTDSale(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1562 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 27636 |
tejbeer |
1563 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1564 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1565 |
Map<String, Double> brandMtdAmount = fofoOrderItemRepository
|
|
|
1566 |
.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
|
| 27638 |
tejbeer |
1567 |
Map<String, Long> brandMtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(curDate.withDayOfMonth(1),
|
|
|
1568 |
curDate.with(LocalTime.MAX), fofoId);
|
| 27636 |
tejbeer |
1569 |
Double accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId,
|
|
|
1570 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false)).get(fofoId);
|
| 27638 |
tejbeer |
1571 |
Long accesoriesmtdqty = fofoOrderRepository.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId,
|
|
|
1572 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false)).get(fofoId);
|
|
|
1573 |
|
| 27636 |
tejbeer |
1574 |
LOGGER.info("accesoriesmtdsale" + accesoriesmtdsale);
|
|
|
1575 |
model.addAttribute("brandMtdAmount", brandMtdAmount);
|
| 27638 |
tejbeer |
1576 |
model.addAttribute("brandMtdQty", brandMtdQty);
|
| 27636 |
tejbeer |
1577 |
model.addAttribute("accesoriesmtdsale", accesoriesmtdsale);
|
| 27638 |
tejbeer |
1578 |
model.addAttribute("accesoriesmtdqty", accesoriesmtdqty);
|
|
|
1579 |
|
| 27636 |
tejbeer |
1580 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
1581 |
return "partner-brand-mtd-sale";
|
|
|
1582 |
}
|
|
|
1583 |
|
| 27637 |
tejbeer |
1584 |
@RequestMapping(value = "/getPatnerBrandWiseLMTDSale", method = RequestMethod.GET)
|
|
|
1585 |
public String getPatnerBrandWiseLMTDSale(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1586 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 27637 |
tejbeer |
1587 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1588 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1589 |
Map<String, Double> brandLMtdAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
|
|
1590 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
|
| 27638 |
tejbeer |
1591 |
Map<String, Long> brandLmtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
|
|
|
1592 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
|
| 27637 |
tejbeer |
1593 |
|
|
|
1594 |
Double accesorieslmtdsale = fofoOrderRepository
|
|
|
1595 |
.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1).minusMonths(1),
|
|
|
1596 |
curDate.with(LocalTime.MAX).minusMonths(1), Optional.of(false))
|
|
|
1597 |
.get(fofoId);
|
| 27638 |
tejbeer |
1598 |
Long accesorieslmtdqty = fofoOrderRepository.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId,
|
|
|
1599 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1),
|
|
|
1600 |
Optional.of(false)).get(fofoId);
|
|
|
1601 |
|
| 27637 |
tejbeer |
1602 |
model.addAttribute("brandLMtdAmount", brandLMtdAmount);
|
| 27638 |
tejbeer |
1603 |
model.addAttribute("brandLmtdQty", brandLmtdQty);
|
|
|
1604 |
model.addAttribute("accesorieslmtdqty", accesorieslmtdqty);
|
| 27637 |
tejbeer |
1605 |
model.addAttribute("accesorieslmtdsale", accesorieslmtdsale);
|
|
|
1606 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
1607 |
return "partner-brand-lmtd-sale";
|
|
|
1608 |
}
|
|
|
1609 |
|
| 27660 |
tejbeer |
1610 |
@RequestMapping(value = "/getPatnerBrandWiseLMSSale", method = RequestMethod.GET)
|
|
|
1611 |
public String getPatnerBrandWiseLMSSale(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1612 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 27660 |
tejbeer |
1613 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1614 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1615 |
int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
|
|
|
1616 |
|
|
|
1617 |
Map<String, Double> brandLMSAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
| 27893 |
tejbeer |
1618 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), fofoId);
|
| 27660 |
tejbeer |
1619 |
Map<String, Long> brandLmsQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
|
| 27893 |
tejbeer |
1620 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), fofoId);
|
| 27660 |
tejbeer |
1621 |
|
| 27893 |
tejbeer |
1622 |
Double accesorieslmssale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId,
|
|
|
1623 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), Optional.of(false)).get(fofoId);
|
| 27660 |
tejbeer |
1624 |
Long accesorieslmsqty = fofoOrderRepository
|
|
|
1625 |
.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId,
|
| 27893 |
tejbeer |
1626 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), Optional.of(false))
|
| 27660 |
tejbeer |
1627 |
.get(fofoId);
|
|
|
1628 |
|
|
|
1629 |
model.addAttribute("brandLMSAmount", brandLMSAmount);
|
|
|
1630 |
model.addAttribute("brandLmsQty", brandLmsQty);
|
|
|
1631 |
model.addAttribute("accesorieslmssale", accesorieslmssale);
|
|
|
1632 |
model.addAttribute("accesorieslmsqty", accesorieslmsqty);
|
|
|
1633 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
1634 |
return "partner-brand-lms-sale";
|
|
|
1635 |
}
|
|
|
1636 |
|
| 27640 |
tejbeer |
1637 |
@RequestMapping(value = "/getPatnerInStock", method = RequestMethod.GET)
|
|
|
1638 |
public String getPatnerInStock(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1639 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 27640 |
tejbeer |
1640 |
|
|
|
1641 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1642 |
|
| 27660 |
tejbeer |
1643 |
List<InStockBrandModel> mobileStocks = currentInventorySnapshotRepository
|
| 27640 |
tejbeer |
1644 |
.selectSumInStockMobileGroupByBrand(fofoId);
|
| 27660 |
tejbeer |
1645 |
List<InStockBrandModel> accesStock = currentInventorySnapshotRepository
|
| 27640 |
tejbeer |
1646 |
.selectSumInStockAccessoriesGroupByBrand(fofoId);
|
|
|
1647 |
|
| 27660 |
tejbeer |
1648 |
List<InStockBrandItemModel> stockItemlist = currentInventorySnapshotRepository
|
|
|
1649 |
.selectInStockItemsByBrand(fofoId);
|
|
|
1650 |
|
|
|
1651 |
Map<String, List<InStockBrandItemModel>> stockItemMap = stockItemlist.stream()
|
|
|
1652 |
.collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
|
|
1653 |
|
|
|
1654 |
model.addAttribute("stockItemMap", stockItemMap);
|
|
|
1655 |
model.addAttribute("mobileStock", mobileStocks);
|
|
|
1656 |
model.addAttribute("accesStock", accesStock);
|
| 27640 |
tejbeer |
1657 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
1658 |
return "partner-instock-item";
|
|
|
1659 |
}
|
|
|
1660 |
|
| 27660 |
tejbeer |
1661 |
@RequestMapping(value = "/getOpenTicketByFofoId", method = RequestMethod.GET)
|
|
|
1662 |
public String getOpenTicketByFofoId(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1663 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 27660 |
tejbeer |
1664 |
Map<Integer, AuthUser> ticketIdAuthUser = new HashMap<>();
|
|
|
1665 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1666 |
List<Integer> ticketIds = ticketRepository.selectAllOpenTicketByRetailer(fofoId).stream().map(x -> x.getId())
|
|
|
1667 |
.collect(Collectors.toList());
|
|
|
1668 |
List<TicketAssigned> ticketAssigns = ticketAssignedRepository.selectByTicketIds(ticketIds);
|
|
|
1669 |
|
|
|
1670 |
for (TicketAssigned ticketAssign : ticketAssigns) {
|
|
|
1671 |
AuthUser authUser = authRepository.selectById(ticketAssign.getAssineeId());
|
|
|
1672 |
ticketIdAuthUser.put(ticketAssign.getTicketId(), authUser);
|
|
|
1673 |
}
|
|
|
1674 |
model.addAttribute("ticketIdAuthUser", ticketIdAuthUser);
|
|
|
1675 |
model.addAttribute("ticketAssigns", ticketAssigns);
|
|
|
1676 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
1677 |
return "open-ticket";
|
|
|
1678 |
}
|
|
|
1679 |
|
| 27893 |
tejbeer |
1680 |
@RequestMapping(value = "/getPartnerSecondarySale", method = RequestMethod.GET)
|
|
|
1681 |
public String getPartnerSecondarySale(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1682 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, @RequestParam String timeValue, Model model)
|
| 27893 |
tejbeer |
1683 |
throws Exception {
|
|
|
1684 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1685 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1686 |
int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
|
|
|
1687 |
LocalDateTime startDate = null;
|
|
|
1688 |
LocalDateTime endDate = null;
|
|
|
1689 |
List<InStockBrandModel> secondarySale = null;
|
|
|
1690 |
Map<String, List<InStockBrandItemModel>> secondaryItemSale = null;
|
|
|
1691 |
|
|
|
1692 |
if (timeValue.equals("mtd")) {
|
|
|
1693 |
startDate = curDate.withDayOfMonth(1);
|
|
|
1694 |
endDate = curDate.with(LocalTime.MAX);
|
|
|
1695 |
secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
|
|
|
1696 |
secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId)
|
|
|
1697 |
.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
|
|
1698 |
LOGGER.info("secondarySalemtd" + secondarySale);
|
|
|
1699 |
} else if (timeValue.equals("lmtd")) {
|
|
|
1700 |
startDate = curDate.withDayOfMonth(1).minusMonths(1);
|
|
|
1701 |
endDate = curDate.with(LocalTime.MAX).minusMonths(1);
|
|
|
1702 |
secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId)
|
|
|
1703 |
.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
|
|
1704 |
|
|
|
1705 |
secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
|
|
|
1706 |
LOGGER.info("secondarySalelmtd" + secondarySale);
|
|
|
1707 |
|
|
|
1708 |
} else {
|
|
|
1709 |
startDate = curDate.withDayOfMonth(1).minusMonths(1);
|
|
|
1710 |
endDate = curDate.withDayOfMonth(1);
|
|
|
1711 |
secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId)
|
|
|
1712 |
.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
|
|
1713 |
|
|
|
1714 |
secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
|
|
|
1715 |
LOGGER.info("secondarySalelms" + secondarySale);
|
|
|
1716 |
|
|
|
1717 |
}
|
|
|
1718 |
|
|
|
1719 |
LOGGER.info("secondarySale" + secondarySale);
|
|
|
1720 |
model.addAttribute("secondarySale", secondarySale);
|
|
|
1721 |
model.addAttribute("secondaryItemSale", secondaryItemSale);
|
|
|
1722 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
1723 |
|
|
|
1724 |
return "partner-secondary-order";
|
|
|
1725 |
}
|
|
|
1726 |
|
| 28451 |
tejbeer |
1727 |
@RequestMapping(value = "/getMobileBrandWise", method = RequestMethod.GET)
|
|
|
1728 |
public String getMobileBrandWise(HttpServletRequest request, Model model) throws Exception {
|
|
|
1729 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1730 |
String email = loginDetails.getEmailId();
|
|
|
1731 |
|
|
|
1732 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
1733 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1734 |
|
|
|
1735 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
|
|
1736 |
if (emails.contains(authUser.getEmailId())) {
|
|
|
1737 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
|
|
1738 |
LOGGER.info("fofoIds" + fofoIds);
|
|
|
1739 |
}
|
|
|
1740 |
|
| 28471 |
tejbeer |
1741 |
if (fofoIds == null) {
|
|
|
1742 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
|
|
1743 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
|
|
|
1744 |
.count() > 0) {
|
|
|
1745 |
fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
|
|
|
1746 |
.map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
1747 |
}
|
|
|
1748 |
}
|
|
|
1749 |
|
| 28451 |
tejbeer |
1750 |
Map<String, BrandWisePartnerSaleModel> partnersBrandSaleMap = null;
|
|
|
1751 |
partnersBrandSaleMap = fofoStoreRepository.selectGroupByBrandWarehousePartnerSale(new ArrayList<>(fofoIds))
|
|
|
1752 |
.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x));
|
|
|
1753 |
|
|
|
1754 |
List<BrandWiseUnbilledActivateStockModel> unbilledActivatedStock = fofoStoreRepository
|
|
|
1755 |
.selectUnbilledActivateStockGroupByBrand(new ArrayList<>(fofoIds));
|
|
|
1756 |
for (BrandWiseUnbilledActivateStockModel un : unbilledActivatedStock) {
|
|
|
1757 |
BrandWisePartnerSaleModel bpt = partnersBrandSaleMap.get(un.getBrand());
|
|
|
1758 |
if (bpt != null) {
|
|
|
1759 |
bpt.setAmtd(un.getUnbilledMtd());
|
|
|
1760 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
|
|
1761 |
} else {
|
|
|
1762 |
bpt = new BrandWisePartnerSaleModel();
|
|
|
1763 |
bpt.setBrand(un.getBrand());
|
|
|
1764 |
bpt.setAmtd(un.getUnbilledMtd());
|
|
|
1765 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
|
|
1766 |
bpt.setLms(0);
|
|
|
1767 |
bpt.setLmtd(0);
|
|
|
1768 |
bpt.setMtd(0);
|
|
|
1769 |
bpt.setMtdQty(0);
|
|
|
1770 |
bpt.setLmtd(0);
|
|
|
1771 |
bpt.setLmtdQty(0);
|
|
|
1772 |
partnersBrandSaleMap.put(un.getBrand(), bpt);
|
|
|
1773 |
}
|
|
|
1774 |
}
|
|
|
1775 |
|
|
|
1776 |
model.addAttribute("brandSalesMap", partnersBrandSaleMap);
|
|
|
1777 |
|
|
|
1778 |
return "mobile-brand-wise-report";
|
|
|
1779 |
}
|
|
|
1780 |
|
|
|
1781 |
@RequestMapping(value = "/getAccessoriesBrandWise", method = RequestMethod.GET)
|
|
|
1782 |
public String getAccessoriesBrandWise(HttpServletRequest request, Model model) throws Exception {
|
|
|
1783 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1784 |
String email = loginDetails.getEmailId();
|
|
|
1785 |
|
|
|
1786 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
1787 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1788 |
|
|
|
1789 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
|
|
1790 |
if (emails.contains(authUser.getEmailId())) {
|
|
|
1791 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
|
|
1792 |
LOGGER.info("fofoIds" + fofoIds);
|
|
|
1793 |
}
|
|
|
1794 |
|
| 28471 |
tejbeer |
1795 |
if (fofoIds == null) {
|
|
|
1796 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
|
|
1797 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
|
|
|
1798 |
.count() > 0) {
|
|
|
1799 |
fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
|
|
|
1800 |
.map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
1801 |
}
|
|
|
1802 |
}
|
|
|
1803 |
|
| 28451 |
tejbeer |
1804 |
List<BrandWisePartnerSaleModel> accessoriesBrandSales = null;
|
|
|
1805 |
|
|
|
1806 |
accessoriesBrandSales = fofoStoreRepository
|
|
|
1807 |
.selectGroupByBrandAccesoriesWarehousePartnerSale(new ArrayList<>(fofoIds));
|
|
|
1808 |
|
|
|
1809 |
model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
|
|
|
1810 |
return "accessories-brand-wise-report";
|
|
|
1811 |
}
|
|
|
1812 |
|
|
|
1813 |
@RequestMapping(value = "/getMobileLMSGraph", method = RequestMethod.GET)
|
| 28461 |
tejbeer |
1814 |
public String getMobileLMSGraph(HttpServletRequest request, @RequestParam(required = false) int warehouseId,
|
| 29932 |
amit.gupta |
1815 |
@RequestParam(required = false) LocalDate date, @RequestParam List<Integer> fofoIds, Model model)
|
| 28451 |
tejbeer |
1816 |
throws Exception {
|
|
|
1817 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
|
|
1818 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
|
|
|
1819 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
1820 |
|
|
|
1821 |
ChartModel cm;
|
|
|
1822 |
if (warehouseId != 0) {
|
| 28468 |
tejbeer |
1823 |
cm = adminUser.getBrandWiseLms(Arrays.asList(warehouseId),
|
| 28451 |
tejbeer |
1824 |
fofoIds.stream().map(x -> x).collect(Collectors.toList()), date);
|
|
|
1825 |
} else {
|
| 28468 |
tejbeer |
1826 |
cm = adminUser.getBrandWiseLms(new ArrayList<>(warehouseIdFofoIdMap.keySet()),
|
| 28451 |
tejbeer |
1827 |
fofoIds.stream().map(x -> x).collect(Collectors.toList()), date);
|
|
|
1828 |
|
|
|
1829 |
}
|
|
|
1830 |
|
|
|
1831 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
1832 |
model.addAttribute("chartMap", gson.toJson(cm));
|
|
|
1833 |
return "brand-wise-mobile-lms-chart";
|
|
|
1834 |
}
|
|
|
1835 |
|
| 28461 |
tejbeer |
1836 |
@RequestMapping(value = "/getMobileLMSFilter", method = RequestMethod.GET)
|
|
|
1837 |
public String getMobileLMSFilter(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1838 |
@RequestParam(required = false, defaultValue = "0") int warehouseId,
|
|
|
1839 |
@RequestParam(required = false) LocalDate date, Model model) throws Exception {
|
| 28461 |
tejbeer |
1840 |
|
|
|
1841 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1842 |
String email = loginDetails.getEmailId();
|
| 28468 |
tejbeer |
1843 |
Map<String, Object> map = adminUser.getFilter(warehouseId, email, date);
|
| 28461 |
tejbeer |
1844 |
model.addAttribute("warehouseId", warehouseId);
|
|
|
1845 |
model.addAllAttributes(map);
|
|
|
1846 |
|
|
|
1847 |
return "chart-filter-lms";
|
|
|
1848 |
}
|
|
|
1849 |
|
|
|
1850 |
@RequestMapping(value = "/getMobileLMPFilter", method = RequestMethod.GET)
|
|
|
1851 |
public String getMobileLMPFilter(HttpServletRequest request,
|
| 29932 |
amit.gupta |
1852 |
@RequestParam(required = false, defaultValue = "0") int warehouseId,
|
|
|
1853 |
@RequestParam(required = false) LocalDate date, Model model) throws Exception {
|
| 28461 |
tejbeer |
1854 |
|
|
|
1855 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1856 |
String email = loginDetails.getEmailId();
|
| 28468 |
tejbeer |
1857 |
Map<String, Object> map = adminUser.getFilter(warehouseId, email, date);
|
| 28461 |
tejbeer |
1858 |
model.addAttribute("warehouseId", warehouseId);
|
|
|
1859 |
model.addAllAttributes(map);
|
|
|
1860 |
|
|
|
1861 |
return "chart-filter-lmp";
|
|
|
1862 |
}
|
|
|
1863 |
|
|
|
1864 |
@RequestMapping(value = "/getMobileLMPGraph", method = RequestMethod.GET)
|
|
|
1865 |
public String getMobileLMPGraph(HttpServletRequest request, @RequestParam(required = false) int warehouseId,
|
| 29932 |
amit.gupta |
1866 |
@RequestParam(required = false) LocalDate date, @RequestParam List<Integer> fofoIds, Model model)
|
| 28461 |
tejbeer |
1867 |
throws Exception {
|
|
|
1868 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
|
|
1869 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
|
|
|
1870 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
1871 |
|
|
|
1872 |
ChartModel cm;
|
|
|
1873 |
if (warehouseId != 0) {
|
| 28468 |
tejbeer |
1874 |
cm = adminUser.getBrandWiseLmp(Arrays.asList(warehouseId),
|
| 28461 |
tejbeer |
1875 |
fofoIds.stream().map(x -> x).collect(Collectors.toList()), date);
|
|
|
1876 |
} else {
|
| 28468 |
tejbeer |
1877 |
cm = adminUser.getBrandWiseLmp(new ArrayList<>(warehouseIdFofoIdMap.keySet()),
|
| 28461 |
tejbeer |
1878 |
fofoIds.stream().map(x -> x).collect(Collectors.toList()), date);
|
|
|
1879 |
|
|
|
1880 |
}
|
|
|
1881 |
|
|
|
1882 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
1883 |
model.addAttribute("chartMap", gson.toJson(cm));
|
|
|
1884 |
return "brand-wise-mobile-lmp-chart";
|
|
|
1885 |
}
|
|
|
1886 |
|
| 28825 |
tejbeer |
1887 |
@RequestMapping(value = "/getActivatedModelWarehouseWise", method = RequestMethod.GET)
|
|
|
1888 |
public String getActivatedModelWarehouseWise(HttpServletRequest request, Model model, @RequestParam String brand)
|
|
|
1889 |
throws Exception {
|
|
|
1890 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1891 |
List<Integer> fofoIds = getFofoIds(loginDetails);
|
|
|
1892 |
List<WarehouseWiseActivatedModel> warehouseWiseActivatedModels = activatedImeiRepository
|
|
|
1893 |
.selectActivatedModelGroupByWarehouse(brand, fofoIds);
|
|
|
1894 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1895 |
|
|
|
1896 |
List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
|
|
|
1897 |
|
|
|
1898 |
List<String> brands = mobileBrands.stream().map(x -> (String) x.get("name")).collect(Collectors.toList());
|
|
|
1899 |
LOGGER.info("brands" + brands.add("Redmi"));
|
|
|
1900 |
|
|
|
1901 |
model.addAttribute("warehouseWiseActivatedModels", warehouseWiseActivatedModels);
|
|
|
1902 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1903 |
model.addAttribute("brands", brands);
|
|
|
1904 |
model.addAttribute("selectedbrand", brand);
|
|
|
1905 |
return "warehousewise_activated_model";
|
|
|
1906 |
}
|
|
|
1907 |
|
|
|
1908 |
@RequestMapping(value = "/getActivatedModelByBrand", method = RequestMethod.GET)
|
|
|
1909 |
public String getActivatedModelByBrand(HttpServletRequest request, Model model) throws Exception {
|
|
|
1910 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1911 |
List<Integer> fofoIds = getFofoIds(loginDetails);
|
|
|
1912 |
List<BrandWiseActivatedModel> activatedModels = activatedImeiRepository
|
|
|
1913 |
.selectActivatedModelGroupByBrand(new ArrayList<>(fofoIds));
|
|
|
1914 |
model.addAttribute("activatedModels", activatedModels);
|
|
|
1915 |
return "activation-brandwise-report";
|
|
|
1916 |
}
|
|
|
1917 |
|
|
|
1918 |
@RequestMapping(value = "/getWarehouseBrandWiseItemActivatedModel", method = RequestMethod.GET)
|
|
|
1919 |
public String getWarehouseBrandWiseItemActivatedModel(HttpServletRequest request, Model model,
|
| 29932 |
amit.gupta |
1920 |
@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
| 28825 |
tejbeer |
1921 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1922 |
List<Integer> fofoIds = getFofoIds(loginDetails);
|
|
|
1923 |
|
|
|
1924 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1925 |
List<WarehouseBrandWiseItemActivatedModel> activatedItems = activatedImeiRepository
|
|
|
1926 |
.selectWarehouseBrandActivatedItem(warehouseId, brand, fofoIds);
|
|
|
1927 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1928 |
model.addAttribute("activatedItems", activatedItems);
|
|
|
1929 |
return "warehouse-activated-itemwise-model";
|
|
|
1930 |
|
|
|
1931 |
}
|
|
|
1932 |
|
|
|
1933 |
@RequestMapping(value = "/getActivatedImeiUpdationDate", method = RequestMethod.GET)
|
|
|
1934 |
public String getActivatedImeiUpdationDate(HttpServletRequest request, Model model) throws Exception {
|
|
|
1935 |
|
|
|
1936 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1937 |
|
|
|
1938 |
List<ActivationImeiUpdationModel> activationImeiUpdations = activatedImeiRepository
|
|
|
1939 |
.selectActivatedUpdationDate();
|
|
|
1940 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1941 |
model.addAttribute("activationImeiUpdations", activationImeiUpdations);
|
|
|
1942 |
return "activation-updation-timestamp";
|
|
|
1943 |
|
|
|
1944 |
}
|
|
|
1945 |
|
|
|
1946 |
private List<Integer> getFofoIds(LoginDetails loginDetails) throws ProfitMandiBusinessException {
|
|
|
1947 |
String email = loginDetails.getEmailId();
|
|
|
1948 |
|
|
|
1949 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
1950 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1951 |
|
|
|
1952 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
|
|
1953 |
if (emails.contains(authUser.getEmailId())) {
|
|
|
1954 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
|
|
1955 |
LOGGER.info("fofoIds" + fofoIds);
|
|
|
1956 |
}
|
|
|
1957 |
|
|
|
1958 |
if (fofoIds == null) {
|
|
|
1959 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
|
|
1960 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
|
|
|
1961 |
.count() > 0) {
|
|
|
1962 |
fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
|
|
|
1963 |
.map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
1964 |
}
|
|
|
1965 |
}
|
|
|
1966 |
return new ArrayList<>(fofoIds);
|
|
|
1967 |
}
|
|
|
1968 |
|
| 21615 |
kshitij.so |
1969 |
}
|