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