| 21615 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 25649 |
tejbeer |
3 |
import com.google.gson.Gson;
|
| 28825 |
tejbeer |
4 |
import com.mongodb.DBObject;
|
| 25651 |
tejbeer |
5 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| 25683 |
tejbeer |
6 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 22481 |
ashik.ali |
7 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 31337 |
amit.gupta |
8 |
import com.spice.profitmandi.common.model.*;
|
| 25651 |
tejbeer |
9 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 36890 |
aman |
10 |
import com.spice.profitmandi.dao.entity.ContactUs;
|
| 35247 |
vikas |
11 |
import com.spice.profitmandi.dao.entity.StoreSalesTarget;
|
| 26011 |
amit.gupta |
12 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 27355 |
tejbeer |
13 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 32308 |
amit.gupta |
14 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 27636 |
tejbeer |
15 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 33501 |
ranu |
16 |
import com.spice.profitmandi.dao.entity.cs.PartnerRegion;
|
| 28471 |
tejbeer |
17 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 36268 |
ranu |
18 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
| 27660 |
tejbeer |
19 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
| 25651 |
tejbeer |
20 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 25649 |
tejbeer |
21 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| 31337 |
amit.gupta |
22 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 29720 |
manish |
23 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
| 27586 |
tejbeer |
24 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 29707 |
tejbeer |
25 |
import com.spice.profitmandi.dao.enumuration.catalog.UpgradeOfferStatus;
|
| 36481 |
ranu |
26 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 31259 |
tejbeer |
27 |
import com.spice.profitmandi.dao.enumuration.fofo.Milestone;
|
| 28409 |
tejbeer |
28 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 36849 |
ranu |
29 |
import com.spice.profitmandi.dao.model.SamsungUpgradeOfferModel;
|
| 36816 |
aman |
30 |
import com.spice.profitmandi.dao.model.*;
|
| 34973 |
aman |
31 |
import com.spice.profitmandi.dao.model.warehouse.LMSGraphRequest;
|
| 36890 |
aman |
32 |
import com.spice.profitmandi.dao.repository.ContactUsRepository;
|
| 25976 |
amit.gupta |
33 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 34617 |
amit.gupta |
34 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 31662 |
amit.gupta |
35 |
import com.spice.profitmandi.dao.repository.cs.*;
|
| 31337 |
amit.gupta |
36 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
|
|
37 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 27529 |
tejbeer |
38 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
|
|
39 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| 29720 |
manish |
40 |
import com.spice.profitmandi.dao.repository.transaction.LineItemRepository;
|
| 27893 |
tejbeer |
41 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 28443 |
tejbeer |
42 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| 35104 |
vikas |
43 |
import com.spice.profitmandi.dao.service.SaleRewardService;
|
| 28468 |
tejbeer |
44 |
import com.spice.profitmandi.service.AdminUser;
|
|
|
45 |
import com.spice.profitmandi.service.FofoUser;
|
| 24336 |
amit.gupta |
46 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 26460 |
amit.gupta |
47 |
import com.spice.profitmandi.service.PartnerStatsService;
|
| 32336 |
jai.hind |
48 |
import com.spice.profitmandi.service.SshServer.SSHService;
|
| 23844 |
amit.gupta |
49 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 34176 |
tejus.loha |
50 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| 32934 |
amit.gupta |
51 |
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
|
| 25677 |
amit.gupta |
52 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 27876 |
amit.gupta |
53 |
import com.spice.profitmandi.service.offers.OfferService;
|
| 32308 |
amit.gupta |
54 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 27586 |
tejbeer |
55 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 26005 |
amit.gupta |
56 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 22481 |
ashik.ali |
57 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
58 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 27529 |
tejbeer |
59 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 31337 |
amit.gupta |
60 |
import org.apache.logging.log4j.LogManager;
|
|
|
61 |
import org.apache.logging.log4j.Logger;
|
|
|
62 |
import org.json.JSONObject;
|
|
|
63 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
64 |
import org.springframework.beans.factory.annotation.Value;
|
|
|
65 |
import org.springframework.core.io.InputStreamResource;
|
|
|
66 |
import org.springframework.http.HttpHeaders;
|
|
|
67 |
import org.springframework.http.HttpStatus;
|
|
|
68 |
import org.springframework.http.ResponseEntity;
|
|
|
69 |
import org.springframework.stereotype.Controller;
|
| 35437 |
amit |
70 |
import org.springframework.transaction.annotation.Transactional;
|
| 31337 |
amit.gupta |
71 |
import org.springframework.ui.Model;
|
| 32336 |
jai.hind |
72 |
import org.springframework.web.bind.annotation.*;
|
| 32407 |
amit.gupta |
73 |
|
| 31337 |
amit.gupta |
74 |
import javax.servlet.http.HttpServletRequest;
|
|
|
75 |
import java.io.File;
|
|
|
76 |
import java.io.FileInputStream;
|
|
|
77 |
import java.io.FileNotFoundException;
|
|
|
78 |
import java.time.LocalDate;
|
|
|
79 |
import java.time.LocalDateTime;
|
|
|
80 |
import java.time.LocalTime;
|
|
|
81 |
import java.time.YearMonth;
|
|
|
82 |
import java.time.format.DateTimeFormatter;
|
|
|
83 |
import java.util.*;
|
|
|
84 |
import java.util.Map.Entry;
|
|
|
85 |
import java.util.stream.Collectors;
|
| 32407 |
amit.gupta |
86 |
|
| 31337 |
amit.gupta |
87 |
import static in.shop2020.model.v1.order.OrderStatus.*;
|
| 32407 |
amit.gupta |
88 |
|
| 21615 |
kshitij.so |
89 |
@Controller
|
| 35458 |
amit |
90 |
@Transactional(rollbackFor = Throwable.class)
|
| 21615 |
kshitij.so |
91 |
public class DashboardController {
|
| 23923 |
amit.gupta |
92 |
|
| 36870 |
ranu |
93 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com", "amit.gupta@smartdukaan.com", "ranu.rajput@smartdukaan.com", "vikas.jangra@smartdukaan.com", "tanay.gupta@smartdukaan.com", "rudy.kanwar@smartdukaan.com");
|
| 27727 |
tejbeer |
94 |
|
| 31751 |
tejbeer |
95 |
@Value("${web.api.host}")
|
|
|
96 |
private String webApiHost;
|
| 23923 |
amit.gupta |
97 |
|
| 31751 |
tejbeer |
98 |
@Value("${web.api.scheme}")
|
|
|
99 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
100 |
|
| 31751 |
tejbeer |
101 |
@Autowired
|
|
|
102 |
private CsService1 csService1;
|
| 31662 |
amit.gupta |
103 |
|
| 31751 |
tejbeer |
104 |
@Value("${web.api.root}")
|
|
|
105 |
private String webApiRoot;
|
| 24078 |
amit.gupta |
106 |
|
| 31751 |
tejbeer |
107 |
@Value("${web.api.port}")
|
|
|
108 |
private int webApiPort;
|
| 28430 |
tejbeer |
109 |
|
| 31751 |
tejbeer |
110 |
@Autowired
|
|
|
111 |
private PriceDropRepository priceDropRepository;
|
| 28443 |
tejbeer |
112 |
|
| 31751 |
tejbeer |
113 |
@Autowired
|
|
|
114 |
private CookiesProcessor cookiesProcessor;
|
| 26468 |
amit.gupta |
115 |
|
| 31751 |
tejbeer |
116 |
@Autowired
|
|
|
117 |
private PendingOrderRepository pendingOrderRepository;
|
| 28409 |
tejbeer |
118 |
|
| 31751 |
tejbeer |
119 |
@Autowired
|
|
|
120 |
private PartnerStatsService partnerStatsService;
|
| 23923 |
amit.gupta |
121 |
|
| 31751 |
tejbeer |
122 |
@Autowired
|
|
|
123 |
private CsService csService;
|
| 26090 |
amit.gupta |
124 |
|
| 31751 |
tejbeer |
125 |
@Autowired
|
|
|
126 |
private ResponseSender<?> responseSender;
|
| 26012 |
amit.gupta |
127 |
|
| 31751 |
tejbeer |
128 |
@Autowired
|
|
|
129 |
RetailerService retailerService;
|
| 25214 |
amit.gupta |
130 |
|
| 31751 |
tejbeer |
131 |
@Autowired
|
|
|
132 |
private AdminUser adminUser;
|
| 28468 |
tejbeer |
133 |
|
| 31751 |
tejbeer |
134 |
@Autowired
|
|
|
135 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
136 |
|
| 31751 |
tejbeer |
137 |
@Autowired
|
|
|
138 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
139 |
|
| 31751 |
tejbeer |
140 |
@Autowired
|
|
|
141 |
private PartnerInvestmentService partnerInvestmentService;
|
| 24288 |
amit.gupta |
142 |
|
| 31751 |
tejbeer |
143 |
@Autowired
|
|
|
144 |
DocumentRepository documentRepository;
|
| 26236 |
amit.gupta |
145 |
|
| 31751 |
tejbeer |
146 |
@Autowired
|
|
|
147 |
InventoryItemRepository inventoryItemRepository;
|
| 25683 |
tejbeer |
148 |
|
| 31751 |
tejbeer |
149 |
@Autowired
|
|
|
150 |
InventoryService inventoryService;
|
| 23923 |
amit.gupta |
151 |
|
| 31751 |
tejbeer |
152 |
@Autowired
|
|
|
153 |
private PendingOrderItemRepository pendingOrderItemRepository;
|
| 28409 |
tejbeer |
154 |
|
| 31751 |
tejbeer |
155 |
@Autowired
|
|
|
156 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 24203 |
amit.gupta |
157 |
|
| 31751 |
tejbeer |
158 |
@Autowired
|
|
|
159 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 26012 |
amit.gupta |
160 |
|
| 31751 |
tejbeer |
161 |
@Autowired
|
|
|
162 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 25136 |
amit.gupta |
163 |
|
| 31751 |
tejbeer |
164 |
@Autowired
|
|
|
165 |
private HygieneDataRepository hygieneDataRepository;
|
| 25649 |
tejbeer |
166 |
|
| 31751 |
tejbeer |
167 |
@Autowired
|
|
|
168 |
private UserAccountRepository userAccountRepository;
|
| 25649 |
tejbeer |
169 |
|
| 31751 |
tejbeer |
170 |
@Autowired
|
|
|
171 |
private NotificationCampaignRepository notificationCampaignRepository;
|
| 25649 |
tejbeer |
172 |
|
| 31751 |
tejbeer |
173 |
@Autowired
|
|
|
174 |
private AuthRepository authRepository;
|
| 24880 |
govind |
175 |
|
| 31751 |
tejbeer |
176 |
@Autowired
|
|
|
177 |
private FofoOrderRepository fofoOrderRepository;
|
| 26071 |
tejbeer |
178 |
|
| 31751 |
tejbeer |
179 |
@Autowired
|
|
|
180 |
private Gson gson;
|
| 25649 |
tejbeer |
181 |
|
| 31751 |
tejbeer |
182 |
@Autowired
|
|
|
183 |
TicketRepository ticketRepository;
|
| 26418 |
tejbeer |
184 |
|
| 31751 |
tejbeer |
185 |
@Autowired
|
|
|
186 |
private OfferService offerService;
|
| 27876 |
amit.gupta |
187 |
|
| 31751 |
tejbeer |
188 |
@Autowired
|
|
|
189 |
private ItemRepository itemRepository;
|
| 26588 |
tejbeer |
190 |
|
| 31751 |
tejbeer |
191 |
@Autowired
|
|
|
192 |
private SaholicInventoryCISRepository saholicInventoryCISRepository;
|
| 27529 |
tejbeer |
193 |
|
| 31751 |
tejbeer |
194 |
@Autowired
|
|
|
195 |
private MVCResponseSender mvcResponseSender;
|
| 27529 |
tejbeer |
196 |
|
| 31751 |
tejbeer |
197 |
@Autowired
|
| 36890 |
aman |
198 |
private ContactUsRepository contactUsRepository;
|
|
|
199 |
|
|
|
200 |
@Autowired
|
| 31751 |
tejbeer |
201 |
private ReporticoCacheTableRepository reporticoCacheTableRepository;
|
| 27529 |
tejbeer |
202 |
|
| 31751 |
tejbeer |
203 |
@Autowired
|
|
|
204 |
private TransactionService transactionService;
|
| 27586 |
tejbeer |
205 |
|
| 31751 |
tejbeer |
206 |
@Autowired
|
|
|
207 |
private TagListingRepository tagListingRepository;
|
| 27632 |
tejbeer |
208 |
|
| 31751 |
tejbeer |
209 |
@Autowired
|
|
|
210 |
private TicketAssignedRepository ticketAssignedRepository;
|
| 27660 |
tejbeer |
211 |
|
| 31751 |
tejbeer |
212 |
@Autowired
|
|
|
213 |
private OrderRepository orderRepository;
|
| 28468 |
tejbeer |
214 |
|
| 31751 |
tejbeer |
215 |
@Autowired
|
|
|
216 |
private FofoUser fofoUser;
|
| 29875 |
tejbeer |
217 |
|
| 31751 |
tejbeer |
218 |
@Autowired
|
|
|
219 |
private ActivatedImeiRepository activatedImeiRepository;
|
| 28825 |
tejbeer |
220 |
|
| 31751 |
tejbeer |
221 |
@Autowired
|
|
|
222 |
private Mongo mongoClient;
|
| 28825 |
tejbeer |
223 |
|
| 31751 |
tejbeer |
224 |
@Autowired
|
|
|
225 |
private SchemeInOutRepository schemeInOutRepository;
|
| 29875 |
tejbeer |
226 |
|
| 31751 |
tejbeer |
227 |
@Autowired
|
|
|
228 |
private LineItemRepository lineItemRepository;
|
| 29875 |
tejbeer |
229 |
|
| 31751 |
tejbeer |
230 |
@Autowired
|
|
|
231 |
private FofoLineItemRepository fofoLineItemRepository;
|
| 29578 |
tejbeer |
232 |
|
| 31751 |
tejbeer |
233 |
@Autowired
|
|
|
234 |
private PositionRepository positionRepository;
|
| 29707 |
tejbeer |
235 |
|
| 31751 |
tejbeer |
236 |
@Autowired
|
|
|
237 |
private MonthlyTargetRepository monthlyTargetRepository;
|
| 31285 |
tejbeer |
238 |
|
| 31751 |
tejbeer |
239 |
@Autowired
|
|
|
240 |
private SamsungUpgradeOfferRepository samsungUpgradeOfferRepository;
|
|
|
241 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 32836 |
amit.gupta |
242 |
|
| 32407 |
amit.gupta |
243 |
@Autowired
|
|
|
244 |
private SSHService sshService;
|
| 35119 |
aman |
245 |
|
| 34176 |
tejus.loha |
246 |
@Autowired
|
|
|
247 |
BrandsService brandsService;
|
| 32407 |
amit.gupta |
248 |
|
| 35104 |
vikas |
249 |
@Autowired
|
|
|
250 |
SaleRewardService saleRewardService;
|
|
|
251 |
|
| 35119 |
aman |
252 |
@Autowired
|
|
|
253 |
SchemeService schemeService;
|
|
|
254 |
@Autowired
|
|
|
255 |
PrintResourceRegionRepository printResourceRegionRepository;
|
|
|
256 |
@Autowired
|
|
|
257 |
PartnerRegionRepository partnerRegionRepository;
|
|
|
258 |
@Autowired
|
|
|
259 |
PrintResourceRepository printResourceRepository;
|
|
|
260 |
@Autowired
|
|
|
261 |
CatalogRepository catalogRepository;
|
|
|
262 |
@Autowired
|
|
|
263 |
OfferRepository offerRepository;
|
|
|
264 |
@Autowired
|
|
|
265 |
OfferPayoutRepository offerPayoutRepository;
|
|
|
266 |
@Value("${google.api.key}")
|
|
|
267 |
private String googleApiKey;
|
|
|
268 |
|
| 31751 |
tejbeer |
269 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
|
|
270 |
public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
|
|
|
271 |
boolean isAdmin = false;
|
|
|
272 |
model.addAttribute("isAdmin", isAdmin);
|
| 25740 |
amit.gupta |
273 |
|
| 31751 |
tejbeer |
274 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
275 |
model.addAttribute("webApiPort", webApiPort);
|
|
|
276 |
model.addAttribute("webApiScheme", webApiScheme);
|
|
|
277 |
model.addAttribute("webApiRoot", webApiRoot);
|
|
|
278 |
if (isAdmin) {
|
|
|
279 |
return "dashboard1";
|
|
|
280 |
}
|
| 26236 |
amit.gupta |
281 |
|
| 31751 |
tejbeer |
282 |
FofoStore fofoStore = null;
|
|
|
283 |
try {
|
|
|
284 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
285 |
fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
|
|
286 |
if (!fofoStore.isActive()) {
|
|
|
287 |
return "redirect:/login";
|
|
|
288 |
}
|
| 25740 |
amit.gupta |
289 |
|
| 31751 |
tejbeer |
290 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
|
|
291 |
model.addAttribute("partnerType", partnerType);
|
|
|
292 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
|
|
293 |
model.addAttribute("fofoStore", customRetailer);
|
|
|
294 |
model.addAttribute("partnerType", partnerType);
|
|
|
295 |
model.addAttribute("hasGift", fofoUser.hasGift(fofoId));
|
|
|
296 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 25740 |
amit.gupta |
297 |
|
| 31884 |
tejbeer |
298 |
model.addAttribute("brandStockPrices", fofoUser.getBrandStockPrices(fofoId, false));
|
| 31751 |
tejbeer |
299 |
model.addAttribute("salesMap", fofoUser.getSales(fofoId));
|
|
|
300 |
model.addAttribute("activatedImeis", inventoryItemRepository.selectCountByActivatedNotSold(fofoId));
|
|
|
301 |
// this.setInvestments
|
|
|
302 |
//
|
|
|
303 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
|
|
304 |
for (int i = 0; i <= 5; i++) {
|
|
|
305 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
306 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
307 |
}
|
|
|
308 |
LOGGER.info("monthValueMap" + monthValueMap);
|
| 34176 |
tejus.loha |
309 |
Set<String> brands = brandsService.getBrandsToDisplay(3).stream().map(x -> x.getName()).collect(Collectors.toSet());
|
|
|
310 |
brands.addAll(itemRepository.selectAllBrands(ProfitMandiConstants.LED_CATEGORY_ID));
|
|
|
311 |
brands.addAll(itemRepository.selectAllBrands(ProfitMandiConstants.SMART_WATCH_CATEGORY_ID));
|
|
|
312 |
brands.add("Live Demo");
|
|
|
313 |
model.addAttribute("brands", brands);
|
| 31751 |
tejbeer |
314 |
model.addAttribute("monthValueMap", monthValueMap);
|
|
|
315 |
model.addAttribute("investments", fofoUser.getInvestments(fofoId));
|
|
|
316 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(fofoId, ProfitMandiConstants.MIN_INVESTMENT_PERCENTAGE, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
|
|
317 |
} catch (ProfitMandiBusinessException e) {
|
|
|
318 |
LOGGER.error("FofoStore Code not found of fofoId {}", fofoId);
|
| 25740 |
amit.gupta |
319 |
|
| 31751 |
tejbeer |
320 |
}
|
| 25740 |
amit.gupta |
321 |
|
| 31751 |
tejbeer |
322 |
return "12dashboard34";
|
|
|
323 |
}
|
| 25740 |
amit.gupta |
324 |
|
| 31751 |
tejbeer |
325 |
@RequestMapping(value = "/getMonthSale", method = RequestMethod.GET)
|
|
|
326 |
public String getMonthsale(HttpServletRequest request, Model model) throws Exception {
|
|
|
327 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
328 |
int fofoId = loginDetails.getFofoId();
|
|
|
329 |
Map<Integer, MonthSaleModel> monthSaleMap = new HashMap<>();
|
|
|
330 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
331 |
int dayOfMonth = curDate.getDayOfMonth();
|
| 34781 |
amit.gupta |
332 |
YearMonth yearMonth = YearMonth.now();
|
| 35284 |
aman |
333 |
for (int i = 0; i <= 6; i++) {
|
| 31751 |
tejbeer |
334 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
|
|
335 |
int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
|
|
|
336 |
LOGGER.info("Start of previous Month {}, start of next month Month {}", startOfMonth, startOfMonth.plusMonths(1));
|
|
|
337 |
double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusMonths(1), loginDetails.getFofoId(), false).get(fofoId);
|
| 35284 |
aman |
338 |
LOGGER.info("Month sales - {}", monthSales);
|
| 31751 |
tejbeer |
339 |
double mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusDays(Math.min(dayOfMonth, lengthOfMonth)), loginDetails.getFofoId(), false).get(fofoId);
|
| 27474 |
tejbeer |
340 |
|
| 34781 |
amit.gupta |
341 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnMonth(fofoId, yearMonth.minusMonths(i));
|
| 27474 |
tejbeer |
342 |
|
| 31751 |
tejbeer |
343 |
MonthSaleModel ms = new MonthSaleModel();
|
|
|
344 |
ms.setMtdSales(fofoUser.format((long) mtdSales));
|
|
|
345 |
ms.setMonthlySales(fofoUser.format(((long) monthSales)));
|
|
|
346 |
ms.setPartnerType(partnerType);
|
|
|
347 |
ms.setMonth(startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
348 |
monthSaleMap.put(i, ms);
|
|
|
349 |
}
|
| 27474 |
tejbeer |
350 |
|
| 31751 |
tejbeer |
351 |
model.addAttribute("monthSales", monthSaleMap);
|
|
|
352 |
return "monthSales";
|
|
|
353 |
}
|
| 27474 |
tejbeer |
354 |
|
| 35064 |
aman |
355 |
@RequestMapping(value = "/getBrandwisePartnerSale", method = RequestMethod.GET)
|
|
|
356 |
@ResponseBody
|
| 35284 |
aman |
357 |
public List<Map<String, Object>> getBrandwisePartnerSale(
|
|
|
358 |
HttpServletRequest request,
|
|
|
359 |
@RequestParam(name = "month", required = true, defaultValue = "0") int month,
|
|
|
360 |
Model model) throws Exception {
|
|
|
361 |
|
| 35064 |
aman |
362 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
363 |
int fofoId = loginDetails.getFofoId();
|
| 35284 |
aman |
364 |
|
|
|
365 |
List<BrandWisePartnerSaleModel> mobileList =
|
|
|
366 |
fofoStoreRepository.selectBrandWiseMonthlyPartnerSale(Collections.singletonList(fofoId), month);
|
|
|
367 |
|
|
|
368 |
List<BrandWisePartnerSaleModel> accList =
|
|
|
369 |
fofoStoreRepository.selectBrandWiseMonthlyPartnerAccessoriesSale(Collections.singletonList(fofoId), month);
|
|
|
370 |
|
| 35064 |
aman |
371 |
List<Map<String, Object>> response = new ArrayList<>();
|
| 35284 |
aman |
372 |
|
|
|
373 |
for (BrandWisePartnerSaleModel m : mobileList) {
|
| 35064 |
aman |
374 |
Map<String, Object> row = new HashMap<>();
|
|
|
375 |
row.put("brand", m.getBrand());
|
| 36242 |
aman |
376 |
row.put("lmtd", fofoUser.format(m.getLmtd()));
|
|
|
377 |
row.put("lmtdQty", m.getLmtdQty());
|
| 35064 |
aman |
378 |
row.put("mtd", fofoUser.format(m.getMtd()));
|
|
|
379 |
row.put("mtdQty", m.getMtdQty());
|
|
|
380 |
response.add(row);
|
|
|
381 |
}
|
|
|
382 |
|
| 35284 |
aman |
383 |
long accLmtd = 0;
|
| 36242 |
aman |
384 |
long accLmtdQty = 0;
|
| 35284 |
aman |
385 |
long accMtd = 0;
|
|
|
386 |
long accMtdQty = 0;
|
|
|
387 |
for (BrandWisePartnerSaleModel a : accList) {
|
|
|
388 |
accLmtd += a.getLmtd();
|
| 36242 |
aman |
389 |
accLmtdQty += a.getLmtdQty();
|
| 35284 |
aman |
390 |
accMtd += a.getMtd();
|
|
|
391 |
accMtdQty += a.getMtdQty();
|
|
|
392 |
}
|
|
|
393 |
if (!accList.isEmpty()) {
|
|
|
394 |
Map<String, Object> accRow = new HashMap<>();
|
|
|
395 |
accRow.put("brand", "Accessories");
|
|
|
396 |
accRow.put("lmtd", fofoUser.format(accLmtd));
|
| 36242 |
aman |
397 |
accRow.put("lmtdQty", accLmtdQty);
|
| 35284 |
aman |
398 |
accRow.put("mtd", fofoUser.format(accMtd));
|
|
|
399 |
accRow.put("mtdQty", accMtdQty);
|
|
|
400 |
response.add(accRow);
|
|
|
401 |
}
|
| 35064 |
aman |
402 |
|
|
|
403 |
return response;
|
|
|
404 |
}
|
|
|
405 |
|
| 35284 |
aman |
406 |
|
| 35064 |
aman |
407 |
@RequestMapping(value = "/getBrandItemwisePartnerSale", method = RequestMethod.GET)
|
|
|
408 |
@ResponseBody
|
|
|
409 |
public List<BrandItemWisePartnerSaleModel> getBrandItemwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, @RequestParam(name = "brand") String brand, @RequestParam(name = "fofoId") Integer fofoId, Model model) throws Exception {
|
|
|
410 |
List<BrandItemWisePartnerSaleModel> brandItemWisePartnerSaleModels = fofoStoreRepository.selectPartnerBrandItemMonthlySale(Collections.singletonList(fofoId), month, brand);
|
|
|
411 |
LOGGER.info("brandItemWisePartnerSaleModels {}", brandItemWisePartnerSaleModels);
|
|
|
412 |
return brandItemWisePartnerSaleModels;
|
|
|
413 |
}
|
|
|
414 |
|
| 35119 |
aman |
415 |
@RequestMapping(value = "/getBrandItemwisePartnerSecondarySale", method = RequestMethod.GET)
|
|
|
416 |
@ResponseBody
|
|
|
417 |
public List<BrandItemWisePartnerSaleModel> getBrandItemwisePartnerSecondarySale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, @RequestParam(name = "brand") String brand, @RequestParam(name = "fofoId") Integer fofoId, Model model) throws Exception {
|
|
|
418 |
List<BrandItemWisePartnerSaleModel> brandItemWisePartnerSaleModels = fofoStoreRepository.selectPartnerBrandItemMonthlySecondarySale(Collections.singletonList(fofoId), month, brand);
|
|
|
419 |
LOGGER.info("brandItemWisePartnerSaleModels {}", brandItemWisePartnerSaleModels);
|
|
|
420 |
return brandItemWisePartnerSaleModels;
|
|
|
421 |
}
|
| 35064 |
aman |
422 |
|
| 35583 |
ranu |
423 |
@RequestMapping(value = "/dasboard/getDateWiseBulletins", method = RequestMethod.GET)
|
|
|
424 |
public String getDateWiseBulletins(HttpServletRequest request,
|
|
|
425 |
@RequestParam("date") String date,
|
|
|
426 |
Model model) throws Exception {
|
| 32308 |
amit.gupta |
427 |
|
| 37095 |
ranu |
428 |
// Callers on the partner-facing domain don't always carry the fofo admin
|
|
|
429 |
// cookies (FOFO_ID / EMAIL_ID / ROLE_IDS) — cookiesProcessor would then
|
|
|
430 |
// throw ProfitMandiBusinessException and the global handler would turn it
|
|
|
431 |
// into a 400. Bulletins are per-position, so a session-less request has
|
|
|
432 |
// nothing to show — return an empty bulletin list instead of failing.
|
|
|
433 |
LoginDetails loginDetails;
|
|
|
434 |
try {
|
|
|
435 |
loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
436 |
} catch (ProfitMandiBusinessException e) {
|
|
|
437 |
model.addAttribute("bulletins", new LinkedHashMap<>());
|
|
|
438 |
return "bulletin-list";
|
|
|
439 |
}
|
| 35583 |
ranu |
440 |
String email = loginDetails.getEmailId();
|
|
|
441 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| 37095 |
ranu |
442 |
List<Position> positions = authUser == null
|
|
|
443 |
? new ArrayList<>()
|
|
|
444 |
: positionRepository.selectAllByAuthUserId(authUser.getId());
|
| 35583 |
ranu |
445 |
LocalDate selectedDate = LocalDate.parse(date);
|
|
|
446 |
|
| 36849 |
ranu |
447 |
// Short-circuit when the caller has no Position rows. getTodayBulletin's
|
|
|
448 |
// `positions` parameter is @NotEmpty validated — handing it an empty list
|
|
|
449 |
// throws "List should not be empty" and 500s the dashboard. A user with
|
|
|
450 |
// no positions simply has no bulletins to see, so render an empty page.
|
| 37096 |
ranu |
451 |
//
|
|
|
452 |
// Bulletin fetch is best-effort: it fans out to several sub-services
|
|
|
453 |
// (catalog offers / schemes / web offers / prebooking). If any one of
|
|
|
454 |
// them throws, we'd otherwise bubble a 500/400 to the caller. For this
|
|
|
455 |
// endpoint we prefer to degrade to an empty list rather than fail the
|
|
|
456 |
// page — the frontend renders nothing, which is what the user asked for.
|
|
|
457 |
Map<ProfitMandiConstants.BULLETIN_TYPE_ENUM, List<BulletinOfferModal>> dbBulletins;
|
|
|
458 |
if (positions == null || positions.isEmpty()) {
|
|
|
459 |
dbBulletins = new HashMap<>();
|
|
|
460 |
} else {
|
|
|
461 |
try {
|
|
|
462 |
dbBulletins = adminUser.getTodayBulletin(positions, selectedDate.atStartOfDay());
|
|
|
463 |
} catch (Exception e) {
|
|
|
464 |
LOGGER.warn("getTodayBulletin failed for date={} authUserId={}: {}",
|
|
|
465 |
date, authUser != null ? authUser.getId() : null, e.getMessage());
|
|
|
466 |
dbBulletins = new HashMap<>();
|
|
|
467 |
}
|
|
|
468 |
}
|
| 35583 |
ranu |
469 |
|
| 35585 |
ranu |
470 |
// Final ordered map (STRICT enum order)
|
| 35583 |
ranu |
471 |
Map<ProfitMandiConstants.BULLETIN_TYPE_ENUM, List<BulletinOfferModal>> bulletins =
|
|
|
472 |
new LinkedHashMap<>();
|
|
|
473 |
|
|
|
474 |
for (ProfitMandiConstants.BULLETIN_TYPE_ENUM type :
|
|
|
475 |
ProfitMandiConstants.BULLETIN_TYPE_ENUM.values()) {
|
| 35585 |
ranu |
476 |
|
|
|
477 |
List<BulletinOfferModal> list = dbBulletins.get(type);
|
|
|
478 |
|
|
|
479 |
if (list != null && !list.isEmpty()) {
|
|
|
480 |
bulletins.put(type, list); // only add if has data
|
|
|
481 |
}
|
| 35583 |
ranu |
482 |
}
|
|
|
483 |
|
|
|
484 |
model.addAttribute("bulletins", bulletins);
|
|
|
485 |
return "bulletin-list";
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
|
| 31751 |
tejbeer |
489 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
|
|
490 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
|
|
491 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
492 |
String email = loginDetails.getEmailId();
|
|
|
493 |
int fofoId = loginDetails.getFofoId();
|
|
|
494 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
495 |
model.addAttribute("isAdmin", isAdmin);
|
| 23923 |
amit.gupta |
496 |
|
| 31751 |
tejbeer |
497 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
498 |
model.addAttribute("webApiPort", webApiPort);
|
|
|
499 |
model.addAttribute("webApiScheme", webApiScheme);
|
|
|
500 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 33063 |
ranu |
501 |
model.addAttribute("googleApiKey", googleApiKey);
|
| 33501 |
ranu |
502 |
|
| 31751 |
tejbeer |
503 |
if (isAdmin) {
|
|
|
504 |
return adminUser.adminPanel(loginDetails.getFofoId(), email, model);
|
|
|
505 |
} else {
|
| 33705 |
amit.gupta |
506 |
FofoStore fofoStore;
|
|
|
507 |
List<PartnerRegion> partnerRegion = partnerRegionRepository.selectByfofoId(fofoId);
|
|
|
508 |
LocalDateTime currentDate = LocalDateTime.now();
|
|
|
509 |
List<PrintResource> printResources = printResourceRepository.selectPrintResourcesByFofoRegion(partnerRegion.get(0).getRegionId(), currentDate);
|
|
|
510 |
LOGGER.info("printresourcesList {}", printResources);
|
|
|
511 |
model.addAttribute("printResources", printResources);
|
| 31751 |
tejbeer |
512 |
try {
|
|
|
513 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
|
|
514 |
if (!fofoStore.isActive()) {
|
|
|
515 |
return "redirect:/login";
|
|
|
516 |
}
|
| 30346 |
tejbeer |
517 |
|
| 31751 |
tejbeer |
518 |
LocalDateTime startDate = LocalDate.now().withDayOfYear(1).atStartOfDay();
|
|
|
519 |
LocalDateTime endtDate = LocalDateTime.now();
|
|
|
520 |
OnlineDeliveredOrderSum onlineDeliveredOrderSum = pendingOrderItemRepository.selectSumSellingPriceOnlineOrder(fofoId, startDate, endtDate);
|
|
|
521 |
LOGGER.info("onlineDeliveredOrderSum" + onlineDeliveredOrderSum.getSellingPrice());
|
| 30455 |
amit.gupta |
522 |
|
| 31751 |
tejbeer |
523 |
long countOrder = pendingOrderRepository.pendingOrderCount(fofoId, OrderStatus.PROCESSING);
|
|
|
524 |
LOGGER.info("countOrder" + countOrder);
|
| 30455 |
amit.gupta |
525 |
|
| 31751 |
tejbeer |
526 |
ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
|
| 30455 |
amit.gupta |
527 |
|
| 31751 |
tejbeer |
528 |
orderStatus.add(SUBMITTED_FOR_PROCESSING);
|
|
|
529 |
orderStatus.add(BILLED);
|
|
|
530 |
orderStatus.add(SHIPPED_FROM_WH);
|
|
|
531 |
orderStatus.add(DELIVERY_SUCCESS);
|
| 30455 |
amit.gupta |
532 |
|
| 31751 |
tejbeer |
533 |
List<Order> openOrders = orderRepository.selectGrnTimestampNull(fofoId, orderStatus);
|
|
|
534 |
List<LineItem> submittedLineItemIds = openOrders.stream().filter(x -> x.getStatus().equals(SUBMITTED_FOR_PROCESSING)).map(x -> x.getLineItem()).collect(Collectors.toList());
|
|
|
535 |
List<LineItem> billedOrderIds = openOrders.stream().filter(x -> x.getStatus().equals(BILLED)).map(x -> x.getLineItem()).collect(Collectors.toList());
|
|
|
536 |
List<LineItem> shippedOrderIds = openOrders.stream().filter(x -> x.getStatus().equals(SHIPPED_FROM_WH)).map(x -> x.getLineItem()).collect(Collectors.toList());
|
|
|
537 |
List<LineItem> grnPendingLineItemIds = openOrders.stream().filter(x -> x.getStatus().equals(DELIVERY_SUCCESS)).map(x -> x.getLineItem()).collect(Collectors.toList());
|
| 30455 |
amit.gupta |
538 |
|
| 31751 |
tejbeer |
539 |
long imeiActivationPendingCount = 0;
|
|
|
540 |
long imeiActivationPendingValue = 0;
|
| 33310 |
amit.gupta |
541 |
//Only delivered orders should be visible
|
| 34176 |
tejus.loha |
542 |
List<Integer> grnPendingOrderIds = openOrders.stream().filter(x -> x.getStatus().equals(DELIVERY_SUCCESS)).map(x -> x.getId()).collect(Collectors.toList());
|
| 31751 |
tejbeer |
543 |
if (grnPendingOrderIds.size() > 0) {
|
|
|
544 |
List<ImeiActivationTimestampModel> imeiActivationTimestampModels = activatedImeiRepository.selectActivatedImeisByOrders(grnPendingOrderIds);
|
|
|
545 |
imeiActivationPendingCount = imeiActivationTimestampModels.size();
|
|
|
546 |
imeiActivationPendingValue = imeiActivationTimestampModels.stream().collect(Collectors.summingDouble(x -> x.getSellingPrice())).longValue();
|
|
|
547 |
}
|
| 30455 |
amit.gupta |
548 |
|
| 31751 |
tejbeer |
549 |
long grnPendingCount = grnPendingLineItemIds.stream().collect(Collectors.summingLong(LineItem::getQuantity));
|
|
|
550 |
long grnPendingValue = grnPendingLineItemIds.stream().collect(Collectors.summingLong(x -> x.getTotalPrice().longValue()));
|
|
|
551 |
model.addAttribute("grnPendingCount", grnPendingCount);
|
|
|
552 |
model.addAttribute("grnPendingValue", grnPendingValue);
|
| 30455 |
amit.gupta |
553 |
|
| 31751 |
tejbeer |
554 |
long submittedCount = submittedLineItemIds.stream().collect(Collectors.summingLong(LineItem::getQuantity));
|
|
|
555 |
long submittedValue = submittedLineItemIds.stream().collect(Collectors.summingLong(x -> x.getTotalPrice().longValue()));
|
|
|
556 |
model.addAttribute("submittedCount", submittedCount);
|
|
|
557 |
model.addAttribute("submittedValue", submittedValue);
|
| 30455 |
amit.gupta |
558 |
|
| 31751 |
tejbeer |
559 |
long billedCount = billedOrderIds.stream().collect(Collectors.summingLong(LineItem::getQuantity));
|
|
|
560 |
long billedValue = billedOrderIds.stream().collect(Collectors.summingLong(x -> x.getTotalPrice().longValue()));
|
|
|
561 |
model.addAttribute("billedValue", billedValue);
|
|
|
562 |
model.addAttribute("billedCount", billedCount);
|
|
|
563 |
LOGGER.info("billedCount {}", billedCount);
|
| 30455 |
amit.gupta |
564 |
|
| 31751 |
tejbeer |
565 |
long shippedCount = shippedOrderIds.stream().collect(Collectors.summingLong(LineItem::getQuantity));
|
|
|
566 |
model.addAttribute("shippedCount", shippedCount);
|
|
|
567 |
LOGGER.info("shippedCount {}", shippedCount);
|
|
|
568 |
long shippedValue = shippedOrderIds.stream().collect(Collectors.summingLong(x -> x.getTotalPrice().longValue()));
|
|
|
569 |
model.addAttribute("shippedValue", shippedValue);
|
| 30455 |
amit.gupta |
570 |
|
| 31751 |
tejbeer |
571 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 30455 |
amit.gupta |
572 |
|
| 31751 |
tejbeer |
573 |
LocalDateTime currentMonthStart = curDate.withDayOfMonth(1);
|
|
|
574 |
LocalDateTime lastMonthStart = currentMonthStart.minusMonths(1);
|
|
|
575 |
LocalDateTime currentMonthEnd = currentMonthStart.withDayOfMonth(1);
|
| 30455 |
amit.gupta |
576 |
|
| 31751 |
tejbeer |
577 |
LOGGER.info("lastMonthStart" + lastMonthStart);
|
|
|
578 |
LOGGER.info("currentMonthEnd" + currentMonthEnd);
|
| 30455 |
amit.gupta |
579 |
|
| 32308 |
amit.gupta |
580 |
Scheme staticScheme = schemeService.getStaticScheme(fofoId);
|
|
|
581 |
double schemeAchievement = 0;
|
|
|
582 |
String schemeCategory = null;
|
|
|
583 |
if (staticScheme != null) {
|
| 32313 |
tejbeer |
584 |
Map<Integer, Double> schemeAchievementMap = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(staticScheme.getStartDateTime(), staticScheme.getEndDateTime());
|
|
|
585 |
if (schemeAchievementMap.get(fofoId) != null) {
|
|
|
586 |
schemeAchievement = schemeAchievementMap.get(fofoId);
|
| 35099 |
amit |
587 |
if (staticScheme.getTarget() >= 1500000 && staticScheme.getTarget() < 2500000) {
|
|
|
588 |
schemeCategory = "Silver Club";
|
| 33705 |
amit.gupta |
589 |
} else if (staticScheme.getTarget() < 3000000) {
|
|
|
590 |
schemeCategory = "Gold Club";
|
|
|
591 |
} else if (staticScheme.getTarget() < 6000000) {
|
|
|
592 |
schemeCategory = "Rising Star Club";
|
|
|
593 |
} else if (staticScheme.getTarget() < 8000000) {
|
|
|
594 |
schemeCategory = "Super Star Club";
|
| 35099 |
amit |
595 |
} else if (staticScheme.getTarget() < 10000000) {
|
| 33705 |
amit.gupta |
596 |
schemeCategory = "Diamond Club";
|
| 35099 |
amit |
597 |
} else if (staticScheme.getTarget() < 20000000) {
|
| 33705 |
amit.gupta |
598 |
schemeCategory = "Platinum Club";
|
| 32313 |
tejbeer |
599 |
} else {
|
| 33705 |
amit.gupta |
600 |
schemeCategory = "Premium Club";
|
| 32313 |
tejbeer |
601 |
}
|
| 32308 |
amit.gupta |
602 |
}
|
|
|
603 |
}
|
|
|
604 |
|
|
|
605 |
|
| 31751 |
tejbeer |
606 |
model.addAttribute("countOrder", countOrder);
|
|
|
607 |
model.addAttribute("onlineDeliveredOrderSum", onlineDeliveredOrderSum.getSellingPrice());
|
| 30455 |
amit.gupta |
608 |
|
| 31751 |
tejbeer |
609 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
|
|
610 |
model.addAttribute("partnerType", partnerType);
|
|
|
611 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
|
|
612 |
model.addAttribute("fofoStore", fofoStore);
|
|
|
613 |
model.addAttribute("partnerType", partnerType);
|
|
|
614 |
model.addAttribute("hasGift", fofoUser.hasGift(loginDetails.getFofoId()));
|
|
|
615 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
|
|
616 |
model.addAttribute("retailers", new JSONObject().append("code", fofoStore.getCode()).append("partnerId", fofoStore.getId()).toString());
|
|
|
617 |
model.addAttribute("activatedImeis", inventoryItemRepository.selectCountByActivatedNotSold(loginDetails.getFofoId()));
|
|
|
618 |
model.addAttribute("imeiActivationPendingCount", imeiActivationPendingCount);
|
|
|
619 |
model.addAttribute("imeiActivationPendingValue", imeiActivationPendingValue);
|
| 30053 |
manish |
620 |
|
| 31751 |
tejbeer |
621 |
Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(loginDetails.getFofoId(), curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
|
| 27701 |
tejbeer |
622 |
|
| 31751 |
tejbeer |
623 |
Double accesoriesStock = currentInventorySnapshotRepository.selectSumStockGroupByFofoIdsForMobileOrAccessories(loginDetails.getFofoId(), Optional.of(false)).get(loginDetails.getFofoId());
|
| 25180 |
amit.gupta |
624 |
|
| 31751 |
tejbeer |
625 |
model.addAttribute("accesoriesStock", String.format("%.0f", accesoriesStock));
|
| 32308 |
amit.gupta |
626 |
model.addAttribute("staticScheme", staticScheme);
|
|
|
627 |
model.addAttribute("schemeCategory", schemeCategory);
|
|
|
628 |
model.addAttribute("schemeAchievement", schemeAchievement);
|
| 31884 |
tejbeer |
629 |
model.addAttribute("brandStockPrices", fofoUser.getBrandStockPrices(loginDetails.getFofoId(), false));
|
| 31751 |
tejbeer |
630 |
model.addAttribute("salesMap", fofoUser.getSales(loginDetails.getFofoId()));
|
| 34388 |
tejus.loha |
631 |
ChartModel cm = fofoUser.getBrandChart(loginDetails.getFofoId(),null,null,false);
|
| 26055 |
tejbeer |
632 |
|
| 31751 |
tejbeer |
633 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
634 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 27701 |
tejbeer |
635 |
|
| 34617 |
amit.gupta |
636 |
List<CreateOfferRequest> createOffers = offerService.getPublishedOffers(loginDetails.getFofoId(), YearMonth.from(LocalDateTime.now()));
|
|
|
637 |
|
| 35395 |
amit |
638 |
// Batch fetch all catalog IDs to avoid N+1 queries
|
|
|
639 |
Set<Integer> allCatalogIds = createOffers.stream()
|
|
|
640 |
.flatMap(offer -> offer.getTargetSlabs().stream())
|
|
|
641 |
.flatMap(slab -> slab.getItemCriteriaPayouts().stream())
|
| 34617 |
amit.gupta |
642 |
.map(ItemCriteriaPayout::getItemCriteria)
|
| 35395 |
amit |
643 |
.flatMap(criteria -> criteria.getCatalogIds().stream())
|
|
|
644 |
.collect(Collectors.toSet());
|
| 34617 |
amit.gupta |
645 |
|
| 35395 |
amit |
646 |
final Map<Integer, String> catalogBrandMap = new HashMap<>();
|
|
|
647 |
if (!allCatalogIds.isEmpty()) {
|
|
|
648 |
try {
|
|
|
649 |
catalogBrandMap.putAll(catalogRepository.selectAllByIds(new ArrayList<>(allCatalogIds)).stream()
|
|
|
650 |
.collect(Collectors.toMap(c -> c.getId(), c -> c.getBrand())));
|
|
|
651 |
} catch (ProfitMandiBusinessException e) {
|
|
|
652 |
LOGGER.error("Error fetching catalogs by IDs", e);
|
|
|
653 |
}
|
|
|
654 |
}
|
|
|
655 |
|
|
|
656 |
List<CreateOfferRequest> publishedOffers = createOffers.stream()
|
|
|
657 |
.filter(createOffer -> createOffer.getTargetSlabs().stream()
|
|
|
658 |
.flatMap(slab -> slab.getItemCriteriaPayouts().stream())
|
|
|
659 |
.map(ItemCriteriaPayout::getItemCriteria)
|
|
|
660 |
.flatMap(criteria -> criteria.getCatalogIds().stream())
|
|
|
661 |
.noneMatch(catalogId -> "Live Demo".equals(catalogBrandMap.get(catalogId))))
|
|
|
662 |
.collect(Collectors.toList());
|
|
|
663 |
|
| 31751 |
tejbeer |
664 |
model.addAttribute("publishedOffers", publishedOffers);
|
|
|
665 |
model.addAttribute("investments", fofoUser.getInvestments(loginDetails.getFofoId()));
|
|
|
666 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(), ProfitMandiConstants.MIN_INVESTMENT_PERCENTAGE, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
| 26460 |
amit.gupta |
667 |
|
| 32626 |
amit.gupta |
668 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), DateRangeModel.of(currentMonthStart, currentMonthEnd)) / 2;
|
|
|
669 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), DateRangeModel.of(lastMonthStart, currentMonthStart)) / 2;
|
|
|
670 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), DateRangeModel.withEndDate(currentMonthEnd)) / 2;
|
| 31751 |
tejbeer |
671 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
|
|
672 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
|
|
673 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
| 30455 |
amit.gupta |
674 |
|
| 31751 |
tejbeer |
675 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true, currentMonthStart, currentMonthEnd);
|
| 30455 |
amit.gupta |
676 |
|
| 31751 |
tejbeer |
677 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false, currentMonthStart, currentMonthEnd);
|
|
|
678 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
|
|
679 |
invalidHygieneCount = 1;
|
|
|
680 |
}
|
|
|
681 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
| 33401 |
ranu |
682 |
for (int i = 0; i <= 12; i++) {
|
| 31751 |
tejbeer |
683 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
684 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
685 |
}
|
| 30455 |
amit.gupta |
686 |
|
| 31751 |
tejbeer |
687 |
MonthlyTarget monthlyTarget = monthlyTargetRepository.selectByDateAndFofoId(YearMonth.now(), fofoId);
|
|
|
688 |
model.addAttribute("monthlyTarget", monthlyTarget);
|
| 34176 |
tejus.loha |
689 |
Set<String> brands = brandsService.getBrandsToDisplay(3).stream().map(x -> x.getName()).collect(Collectors.toSet());
|
| 34181 |
tejus.loha |
690 |
|
| 34176 |
tejus.loha |
691 |
model.addAttribute("brands", brands);
|
| 31751 |
tejbeer |
692 |
model.addAttribute("monthValueMap", monthValueMap);
|
|
|
693 |
model.addAttribute("month", 0);
|
| 33409 |
ranu |
694 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| 31751 |
tejbeer |
695 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
|
|
696 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
| 35104 |
vikas |
697 |
Map<String, Object> rewardsMap = saleRewardService.findByFofoAndRegionId(fofoId, partnerRegion.get(0).getRegionId());
|
| 35247 |
vikas |
698 |
StoreSalesTarget targetData = saleRewardService.findTargetsByFofoId(fofoId);
|
| 35104 |
vikas |
699 |
model.addAttribute("rewardsMap", rewardsMap);
|
| 35247 |
vikas |
700 |
model.addAttribute("targetData", targetData);
|
| 35104 |
vikas |
701 |
model.addAttribute("regionId", partnerRegion.get(0).getRegionId());
|
| 30455 |
amit.gupta |
702 |
|
| 35104 |
vikas |
703 |
|
|
|
704 |
|
| 32308 |
amit.gupta |
705 |
} catch (
|
| 32407 |
amit.gupta |
706 |
ProfitMandiBusinessException e) {
|
| 31751 |
tejbeer |
707 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
| 25180 |
amit.gupta |
708 |
|
| 31751 |
tejbeer |
709 |
}
|
|
|
710 |
return "dashboard1";
|
|
|
711 |
}
|
| 25649 |
tejbeer |
712 |
|
| 31751 |
tejbeer |
713 |
}
|
| 29875 |
tejbeer |
714 |
|
| 31751 |
tejbeer |
715 |
@RequestMapping(value = "/getGrnPendingOrderStatus", method = RequestMethod.GET)
|
|
|
716 |
public String getGrnPendingOrderStatus(HttpServletRequest request, Model model) throws Exception {
|
| 29875 |
tejbeer |
717 |
|
| 31751 |
tejbeer |
718 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
719 |
int fofoId = loginDetails.getFofoId();
|
|
|
720 |
List<Order> grnPendingOrders = orderRepository.selectGrnTimestampNull(fofoId, Arrays.asList(in.shop2020.model.v1.order.OrderStatus.DELIVERY_SUCCESS));
|
| 29746 |
manish |
721 |
|
| 31751 |
tejbeer |
722 |
model.addAttribute("grnPendingOrders", grnPendingOrders);
|
|
|
723 |
return "purchase-grn-order-status";
|
|
|
724 |
}
|
| 29875 |
tejbeer |
725 |
|
| 31751 |
tejbeer |
726 |
@RequestMapping(value = "/getPendingOrderStatus", method = RequestMethod.GET)
|
|
|
727 |
public String getPendingOrderStatus(HttpServletRequest request, Model model) throws Exception {
|
| 29875 |
tejbeer |
728 |
|
| 31751 |
tejbeer |
729 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
730 |
int fofoId = loginDetails.getFofoId();
|
|
|
731 |
ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
|
| 29875 |
tejbeer |
732 |
|
| 31751 |
tejbeer |
733 |
orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 29875 |
tejbeer |
734 |
|
| 31751 |
tejbeer |
735 |
List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
|
|
|
736 |
List<Integer> submittedOrderIds = order.stream().filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING).map(x -> x.getId()).collect(Collectors.toList());
|
|
|
737 |
model.addAttribute("submittedOrderIds", submittedOrderIds);
|
|
|
738 |
if (!submittedOrderIds.isEmpty()) {
|
| 29875 |
tejbeer |
739 |
|
| 31751 |
tejbeer |
740 |
List<LineItem> submittedLineItem = lineItemRepository.selectLineItem(submittedOrderIds);
|
|
|
741 |
Map<Integer, LineItem> submittedLineItemMap = submittedLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
| 33075 |
amit.gupta |
742 |
//LOGGER.info("submittedLineItemMap {}", submittedLineItemMap);
|
| 31751 |
tejbeer |
743 |
model.addAttribute("submittedLineItemMap", submittedLineItemMap);
|
|
|
744 |
}
|
| 29875 |
tejbeer |
745 |
|
| 31751 |
tejbeer |
746 |
return "purchase-pending-order-status";
|
|
|
747 |
}
|
| 29875 |
tejbeer |
748 |
|
| 31751 |
tejbeer |
749 |
@RequestMapping(value = "/getBilledOrderStatus", method = RequestMethod.GET)
|
|
|
750 |
public String getBilledOrderStatus(HttpServletRequest request, Model model) throws Exception {
|
| 29875 |
tejbeer |
751 |
|
| 31751 |
tejbeer |
752 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
753 |
int fofoId = loginDetails.getFofoId();
|
|
|
754 |
ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
|
|
|
755 |
orderStatus.add(in.shop2020.model.v1.order.OrderStatus.BILLED);
|
| 29875 |
tejbeer |
756 |
|
| 31751 |
tejbeer |
757 |
List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
|
|
|
758 |
List<Integer> billedOrderIds = order.stream().filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.BILLED).map(x -> x.getId()).collect(Collectors.toList());
|
|
|
759 |
LOGGER.info("billedOrderIds {}", billedOrderIds);
|
|
|
760 |
model.addAttribute("billedOrderIds", billedOrderIds);
|
| 29875 |
tejbeer |
761 |
|
| 31751 |
tejbeer |
762 |
if (!billedOrderIds.isEmpty()) {
|
|
|
763 |
List<LineItem> billedLineItem = lineItemRepository.selectLineItem(billedOrderIds);
|
|
|
764 |
Map<Integer, LineItem> billedLineItemMap = billedLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
|
|
765 |
LOGGER.info("billedLineItemMap {}", billedLineItemMap);
|
|
|
766 |
model.addAttribute("billedLineItemMap", billedLineItemMap);
|
|
|
767 |
}
|
| 29875 |
tejbeer |
768 |
|
| 31751 |
tejbeer |
769 |
return "purchase-billed-order-status";
|
|
|
770 |
}
|
| 29875 |
tejbeer |
771 |
|
| 31751 |
tejbeer |
772 |
@RequestMapping(value = "/getShippedOrderStatus", method = RequestMethod.GET)
|
|
|
773 |
public String getShippedOrderStatus(HttpServletRequest request, Model model) throws Exception {
|
| 29875 |
tejbeer |
774 |
|
| 31751 |
tejbeer |
775 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
776 |
int fofoId = loginDetails.getFofoId();
|
|
|
777 |
ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
|
| 29875 |
tejbeer |
778 |
|
| 31751 |
tejbeer |
779 |
orderStatus.add(SHIPPED_FROM_WH);
|
| 29875 |
tejbeer |
780 |
|
| 31751 |
tejbeer |
781 |
List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
|
|
|
782 |
List<Integer> shippedOrderIds = order.stream().filter(x -> x.getPartnerGrnTimestamp() == null).map(x -> x.getId()).collect(Collectors.toList());
|
|
|
783 |
model.addAttribute("shippedOrderIds", shippedOrderIds);
|
|
|
784 |
LOGGER.info("shippedOrderIds {}", shippedOrderIds);
|
| 29875 |
tejbeer |
785 |
|
| 31751 |
tejbeer |
786 |
if (!shippedOrderIds.isEmpty()) {
|
|
|
787 |
List<LineItem> shippedLineItem = lineItemRepository.selectLineItem(shippedOrderIds);
|
|
|
788 |
Map<Integer, LineItem> shippedLineItemMap = shippedLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
|
|
789 |
LOGGER.info("shippedLineItemMap {}", shippedLineItemMap);
|
| 29875 |
tejbeer |
790 |
|
| 31751 |
tejbeer |
791 |
model.addAttribute("shippedLineItemMap", shippedLineItemMap);
|
|
|
792 |
}
|
|
|
793 |
return "purchase-shipped-order-status";
|
|
|
794 |
}
|
| 23923 |
amit.gupta |
795 |
|
| 31337 |
amit.gupta |
796 |
|
| 31353 |
amit.gupta |
797 |
|
| 31751 |
tejbeer |
798 |
@RequestMapping(value = "/partnerTotalIncomeByMonth/{yearMonth}", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
799 |
public String getPartnerTotalIncomeByMonth(HttpServletRequest request, @PathVariable int yearMonth, Model model) throws
|
|
|
800 |
Exception {
|
| 30224 |
tejbeer |
801 |
|
| 31751 |
tejbeer |
802 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 34813 |
aman |
803 |
Map<String, Object> data = retailerService
|
|
|
804 |
.computeIncomeMap(loginDetails.getFofoId(), yearMonth);
|
|
|
805 |
// long pendingIncome = 0;
|
|
|
806 |
// long partnerPurchaseIn = 0;
|
|
|
807 |
// long partnerCreditedSale = 0;
|
|
|
808 |
// long partnerFrontIncome = 0;
|
|
|
809 |
//
|
|
|
810 |
// LocalDateTime startOfMonth = LocalDate.now().minusMonths(yearMonth).withDayOfMonth(1).atStartOfDay();
|
|
|
811 |
// LocalDateTime endOfMonth = startOfMonth.plusMonths(1).toLocalDate().atStartOfDay();
|
|
|
812 |
//
|
|
|
813 |
// AllPurchaseInventoryModel partnerlPendingSaleAmount = schemeInOutRepository.selectAllPendingSaleInventoryByFofoId(loginDetails.getFofoId(), startOfMonth, endOfMonth);
|
|
|
814 |
// AllPurchaseInventoryModel partnerCreditedSaleAmount = schemeInOutRepository.selectAllCreditedSaleInventoryByFofoId(loginDetails.getFofoId(), startOfMonth, endOfMonth);
|
|
|
815 |
// AllPurchaseInventoryModel partnerPurchaseInAmount = schemeInOutRepository.selectAllPurchaseInventoryByFofoId(loginDetails.getFofoId(), startOfMonth, endOfMonth);
|
|
|
816 |
//
|
|
|
817 |
// AllPurchaseInventoryModel partnerFrontIncomes = schemeInOutRepository.selectFrontIncomeByFofoId(loginDetails.getFofoId(), startOfMonth, endOfMonth);
|
|
|
818 |
//
|
|
|
819 |
// List<OfferPayoutImeiIncomeModel> offerPayoutImeiIncomeModels = offerPayoutRepository.getTotalPayoutsByPartnerPeriod(YearMonth.of(startOfMonth.getYear(), startOfMonth.getMonth()), loginDetails.getFofoId(), null, null);
|
|
|
820 |
//
|
|
|
821 |
// long additionalIncome = offerPayoutImeiIncomeModels.stream().collect(Collectors.summingDouble(x -> x.getSalePayout() + x.getPurchasePayout())).longValue();
|
|
|
822 |
// // AllPurchaseInventoryModel partnerAdditionalIncome =
|
|
|
823 |
// // offerRepository.selectPurchaseIncome(loginDetails.getFofoId(), startOfMonth,
|
|
|
824 |
// // endOfMonth);
|
|
|
825 |
//
|
|
|
826 |
// LOGGER.info("partnerfrontIncomes" + partnerFrontIncomes);
|
|
|
827 |
//
|
|
|
828 |
// LOGGER.info("partnerCreditedSaleAmount" + partnerCreditedSaleAmount);
|
|
|
829 |
// LOGGER.info("partnerPurchaseInAmount" + partnerPurchaseInAmount);
|
|
|
830 |
// LOGGER.info("partnerlPendingSaleAmount" + partnerlPendingSaleAmount);
|
|
|
831 |
//
|
|
|
832 |
// if (partnerlPendingSaleAmount != null) {
|
|
|
833 |
//
|
|
|
834 |
// pendingIncome = partnerlPendingSaleAmount.getAmount();
|
|
|
835 |
//
|
|
|
836 |
// LOGGER.info("pendingIncome" + pendingIncome);
|
|
|
837 |
//
|
|
|
838 |
// }
|
|
|
839 |
//
|
|
|
840 |
// if (partnerCreditedSaleAmount != null) {
|
|
|
841 |
//
|
|
|
842 |
// partnerCreditedSale = partnerCreditedSaleAmount.getAmount();
|
|
|
843 |
//
|
|
|
844 |
// LOGGER.info("partnerCreditedSale" + partnerCreditedSale);
|
|
|
845 |
//
|
|
|
846 |
// }
|
|
|
847 |
// if (partnerFrontIncomes != null) {
|
|
|
848 |
//
|
|
|
849 |
// partnerFrontIncome = partnerFrontIncomes.getAmount();
|
|
|
850 |
// LOGGER.info("partnerPurchaseIn" + partnerPurchaseIn);
|
|
|
851 |
//
|
|
|
852 |
// }
|
|
|
853 |
// if (partnerPurchaseInAmount != null) {
|
|
|
854 |
//
|
|
|
855 |
// partnerPurchaseIn = partnerPurchaseInAmount.getAmount();
|
|
|
856 |
// LOGGER.info("partnerPurchaseIn" + partnerPurchaseIn);
|
|
|
857 |
//
|
|
|
858 |
// }
|
|
|
859 |
//
|
|
|
860 |
// LOGGER.info("partnerPurchaseInTT" + partnerPurchaseIn);
|
|
|
861 |
// LOGGER.info("partnerCreditedSaleTT" + partnerCreditedSale);
|
|
|
862 |
// LOGGER.info("pendingIncomeTT" + pendingIncome);
|
|
|
863 |
//
|
|
|
864 |
// long totalIncome = partnerCreditedSale + partnerPurchaseIn + pendingIncome + partnerFrontIncome + additionalIncome;
|
|
|
865 |
//
|
|
|
866 |
// long creditedIncome = partnerCreditedSale + partnerPurchaseIn + partnerFrontIncome + additionalIncome;
|
|
|
867 |
//
|
|
|
868 |
// long pendingTotalIncome = pendingIncome;
|
|
|
869 |
// LOGGER.info("totalIncome" + totalIncome);
|
|
|
870 |
// LOGGER.info("creditedIncome" + creditedIncome);
|
|
|
871 |
// LOGGER.info("pendingTotalIncome" + pendingTotalIncome);
|
|
|
872 |
//
|
|
|
873 |
model.addAttribute("totalIncome", data.get("totalIncome"));
|
|
|
874 |
model.addAttribute("creditedIncome", data.get("creditedIncome"));
|
|
|
875 |
model.addAttribute("pendingTotalIncome", data.get("pendingIncome"));
|
|
|
876 |
//
|
|
|
877 |
// Map<Integer, String> monthValueMap = new HashMap<>();
|
|
|
878 |
// for (int i = 0; i <= 5; i++) {
|
|
|
879 |
// LocalDateTime monthStart = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
880 |
// monthValueMap.put(i, monthStart.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
881 |
// }
|
|
|
882 |
//
|
|
|
883 |
model.addAttribute("month", data.get("monthIndex"));
|
|
|
884 |
model.addAttribute("monthValueMap", data.get("monthValueMap"));
|
|
|
885 |
LOGGER.info("income data", data);
|
|
|
886 |
model.addAttribute("data", data);
|
| 31751 |
tejbeer |
887 |
return "partner-total-income";
|
|
|
888 |
}
|
| 30224 |
tejbeer |
889 |
|
| 31751 |
tejbeer |
890 |
@RequestMapping(value = "/getMonthsInvestment", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
891 |
public String getMonthsInvestment(HttpServletRequest request,
|
|
|
892 |
@RequestParam(name = "month", required = true, defaultValue = "0") int month, Model model) throws Exception {
|
| 31751 |
tejbeer |
893 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
894 |
int fofoId = loginDetails.getFofoId();
|
|
|
895 |
Map<String, Object> investment = fofoUser.getInvestmentsMonths(fofoId, month);
|
| 28430 |
tejbeer |
896 |
|
| 31751 |
tejbeer |
897 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
|
|
898 |
LocalDateTime lastMonthStart = currentMonthStart.minusMonths(1);
|
|
|
899 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
| 32626 |
amit.gupta |
900 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), DateRangeModel.of(currentMonthStart, currentMonthEnd)) / 2;
|
|
|
901 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), DateRangeModel.of(lastMonthStart, currentMonthStart)) / 2;
|
|
|
902 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), DateRangeModel.withEndDate(currentMonthEnd)) / 2;
|
| 31751 |
tejbeer |
903 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
|
|
904 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
|
|
905 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
| 28272 |
tejbeer |
906 |
|
| 31751 |
tejbeer |
907 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true, currentMonthStart.minusMonths(month), currentMonthEnd.minusMonths(month));
|
| 28272 |
tejbeer |
908 |
|
| 31751 |
tejbeer |
909 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false, currentMonthStart.minusMonths(month), currentMonthEnd.minusMonths(month));
|
|
|
910 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
|
|
911 |
invalidHygieneCount = 1;
|
|
|
912 |
}
|
|
|
913 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
|
|
914 |
for (int i = 0; i <= 5; i++) {
|
|
|
915 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
916 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
917 |
}
|
|
|
918 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
|
|
919 |
model.addAttribute("monthValueMap", monthValueMap);
|
|
|
920 |
model.addAttribute("investments", investment);
|
|
|
921 |
model.addAttribute("monthDays", LocalDate.now().minusMonths(month).lengthOfMonth());
|
|
|
922 |
model.addAttribute("dayOfMonth", LocalDate.now().minusMonths(month).lengthOfMonth());
|
|
|
923 |
model.addAttribute("month", month);
|
|
|
924 |
return "performance";
|
|
|
925 |
}
|
| 28272 |
tejbeer |
926 |
|
| 31751 |
tejbeer |
927 |
@RequestMapping(value = "/investmentDetails", method = RequestMethod.GET)
|
|
|
928 |
public String getInvestmentDetails(HttpServletRequest request, Model model) throws Exception {
|
|
|
929 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
930 |
int fofoId = loginDetails.getFofoId();
|
|
|
931 |
ChartInvestmentModel cm = fofoUser.getInvestmentChart(fofoId);
|
|
|
932 |
model.addAttribute("chartPieMap", gson.toJson(cm));
|
| 27884 |
tejbeer |
933 |
|
| 31751 |
tejbeer |
934 |
LOGGER.info("InvestmentChart" + gson.toJson(cm));
|
|
|
935 |
LOGGER.info("InvestmentChart" + cm);
|
|
|
936 |
return "investmentdetails";
|
|
|
937 |
}
|
| 27884 |
tejbeer |
938 |
|
| 31751 |
tejbeer |
939 |
@RequestMapping(value = "/getlmsLineChart", method = RequestMethod.GET)
|
| 34528 |
ranu |
940 |
public String getlmsLineChart(HttpServletRequest request, Model model, @RequestParam(name = "fofoId", defaultValue = "0") int fofoId) throws Exception {
|
|
|
941 |
if (fofoId == 0) {
|
|
|
942 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
943 |
fofoId = loginDetails.getFofoId();
|
|
|
944 |
}
|
| 28430 |
tejbeer |
945 |
|
| 34528 |
ranu |
946 |
ChartModel cm = fofoUser.getLmsLineChart(fofoId);
|
|
|
947 |
|
| 31751 |
tejbeer |
948 |
LOGGER.info("linechartMap" + gson.toJson(cm));
|
|
|
949 |
model.addAttribute("linechartMap", gson.toJson(cm));
|
|
|
950 |
return "lmsLineChart";
|
|
|
951 |
}
|
| 28430 |
tejbeer |
952 |
|
| 31751 |
tejbeer |
953 |
@RequestMapping(value = "/getMonthlyPurchaseLineChart", method = RequestMethod.GET)
|
| 34528 |
ranu |
954 |
public String getMonthlyPurchaseLineChart(HttpServletRequest request, Model model, @RequestParam(name = "fofoId", defaultValue = "0") int fofoId) throws Exception {
|
|
|
955 |
if (fofoId == 0) {
|
|
|
956 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
957 |
fofoId = loginDetails.getFofoId();
|
|
|
958 |
}
|
| 31751 |
tejbeer |
959 |
ChartModel cm = fofoUser.getPurchaseOrderChart(fofoId);
|
| 28439 |
tejbeer |
960 |
|
| 31751 |
tejbeer |
961 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
962 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 28439 |
tejbeer |
963 |
|
| 31751 |
tejbeer |
964 |
return "purchase_chart";
|
|
|
965 |
}
|
| 28439 |
tejbeer |
966 |
|
| 31751 |
tejbeer |
967 |
@RequestMapping(value = "/getBarChart", method = RequestMethod.GET)
|
| 34388 |
tejus.loha |
968 |
public String getBarChart(HttpServletRequest request, @RequestParam(required = false) LocalDate from, @RequestParam(required = false) LocalDate to,@RequestParam(required = false) Boolean isQuantity ,Model model) throws Exception {
|
| 31751 |
tejbeer |
969 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
970 |
int fofoId = loginDetails.getFofoId();
|
| 34388 |
tejus.loha |
971 |
LocalDateTime curDate = from == null ? LocalDate.now().atStartOfDay().withDayOfMonth(1) : from.atStartOfDay();
|
|
|
972 |
LocalDateTime lastDate = to == null ? LocalDate.now().atStartOfDay().with(LocalTime.MAX) : to.atStartOfDay();
|
|
|
973 |
isQuantity = isQuantity==null?false:isQuantity;
|
|
|
974 |
ChartModel cm = fofoUser.getBrandChart(fofoId, from, to,isQuantity);
|
|
|
975 |
LOGGER.info("from" + curDate);
|
|
|
976 |
LOGGER.info("to" + lastDate);
|
| 31751 |
tejbeer |
977 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
978 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 34388 |
tejus.loha |
979 |
model.addAttribute("from", curDate.toLocalDate());
|
|
|
980 |
model.addAttribute("to", lastDate.toLocalDate());
|
|
|
981 |
model.addAttribute("fofoId", fofoId);
|
|
|
982 |
model.addAttribute("isQuantity",isQuantity);
|
| 31751 |
tejbeer |
983 |
return "bar_chart";
|
|
|
984 |
}
|
| 28430 |
tejbeer |
985 |
|
| 34388 |
tejus.loha |
986 |
@GetMapping(value = "/brandWiseFofoSaleData")
|
|
|
987 |
public String getBarChartModelWise(HttpServletRequest request,
|
|
|
988 |
@RequestParam LocalDate from,
|
|
|
989 |
@RequestParam LocalDate to,
|
|
|
990 |
@RequestParam String brand,
|
|
|
991 |
@RequestParam boolean isQuantity,
|
|
|
992 |
@RequestParam int fofoId, Model model) throws Exception {
|
|
|
993 |
ChartModel cm = fofoUser.getModelBrandChart(fofoId, brand, from, to,isQuantity);
|
|
|
994 |
|
|
|
995 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
996 |
|
|
|
997 |
model.addAttribute("chartMap", gson.toJson(cm));
|
|
|
998 |
return "bar_chart_model_wise";
|
|
|
999 |
}
|
|
|
1000 |
|
| 31751 |
tejbeer |
1001 |
@RequestMapping(value = "/getPriceDropDetails", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1002 |
public String getPriceDropDetails(HttpServletRequest request,
|
|
|
1003 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
1004 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
1005 |
@RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model) throws
|
|
|
1006 |
Exception {
|
| 28455 |
tejbeer |
1007 |
|
| 31751 |
tejbeer |
1008 |
LOGGER.info("params" + fofoId + brand + yearMonth);
|
| 28455 |
tejbeer |
1009 |
|
| 31751 |
tejbeer |
1010 |
List<PriceDropWithDetailsByYearMonthModel> priceDropdetailsList = priceDropRepository.selectBrandPendingPriceDropWithDetailsByYearMonth(fofoId, brand, yearMonth);
|
| 28455 |
tejbeer |
1011 |
|
| 31751 |
tejbeer |
1012 |
LOGGER.info("priceDropdetailsList" + priceDropdetailsList);
|
| 28455 |
tejbeer |
1013 |
|
| 31751 |
tejbeer |
1014 |
model.addAttribute("priceDropdetailsList", priceDropdetailsList);
|
| 28455 |
tejbeer |
1015 |
|
| 31751 |
tejbeer |
1016 |
return "price-drop-details";
|
|
|
1017 |
}
|
| 28825 |
tejbeer |
1018 |
|
| 31751 |
tejbeer |
1019 |
@RequestMapping(value = "/getPriceDropDetailSixMonths", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1020 |
public String getPriceDropDetailSixMonths(HttpServletRequest request,
|
|
|
1021 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
1022 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model) throws Exception {
|
| 28455 |
tejbeer |
1023 |
|
| 31751 |
tejbeer |
1024 |
LOGGER.info("params" + fofoId + brand);
|
|
|
1025 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1026 |
LocalDateTime startfMonthSixMonth = curDate.withDayOfMonth(1).minusMonths(12);
|
|
|
1027 |
LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(6);
|
| 28641 |
amit.gupta |
1028 |
|
| 31751 |
tejbeer |
1029 |
List<PriceDropWithDetailsByYearMonthModel> priceDropdetailsList = priceDropRepository.selectBrandPendingPriceDropWithDetailsAndSixMonth(fofoId, brand, startfMonthSixMonth, endMonthTotal);
|
| 28641 |
amit.gupta |
1030 |
|
| 31751 |
tejbeer |
1031 |
LOGGER.info("priceDropdetailsList" + priceDropdetailsList);
|
| 28641 |
amit.gupta |
1032 |
|
| 31751 |
tejbeer |
1033 |
model.addAttribute("priceDropdetailsList", priceDropdetailsList);
|
| 28641 |
amit.gupta |
1034 |
|
| 31751 |
tejbeer |
1035 |
return "price-drop-details";
|
|
|
1036 |
}
|
| 28641 |
amit.gupta |
1037 |
|
| 31751 |
tejbeer |
1038 |
@RequestMapping(value = "/getMonthlyPriceDrop", method = RequestMethod.GET)
|
| 34528 |
ranu |
1039 |
public String getMonthlyPriceDropTabular(HttpServletRequest request, Model model, @RequestParam(name = "fofoId", defaultValue = "0") int fofoId) throws Exception {
|
| 31751 |
tejbeer |
1040 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 34528 |
ranu |
1041 |
if (fofoId == 0) {
|
|
|
1042 |
fofoId = loginDetails.getFofoId();
|
|
|
1043 |
}
|
|
|
1044 |
|
| 31751 |
tejbeer |
1045 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 28455 |
tejbeer |
1046 |
|
| 31751 |
tejbeer |
1047 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
|
|
1048 |
LocalDateTime startfMonthTotal = curDate.withDayOfMonth(1).minusMonths(12);
|
|
|
1049 |
LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(5);
|
| 28455 |
tejbeer |
1050 |
|
| 31751 |
tejbeer |
1051 |
LOGGER.info("startfMonthTotal" + startfMonthTotal);
|
| 29875 |
tejbeer |
1052 |
|
| 31751 |
tejbeer |
1053 |
LOGGER.info("endMonthTotal" + endMonthTotal);
|
|
|
1054 |
List<YearMonth> yms = new ArrayList<YearMonth>();
|
| 28455 |
tejbeer |
1055 |
|
| 31751 |
tejbeer |
1056 |
for (int i = 0; i <= 5; i++) {
|
|
|
1057 |
yms.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
|
|
|
1058 |
}
|
|
|
1059 |
Collections.reverse(yms);
|
|
|
1060 |
model.addAttribute("yms", yms);
|
|
|
1061 |
LOGGER.info("ym" + yms);
|
| 28455 |
tejbeer |
1062 |
|
| 31751 |
tejbeer |
1063 |
List<PriceDropYearMonthModel> priceDropYearMonthModels = priceDropRepository.selectBrandPendingPriceDropByYearMonth(fofoId, startOfMonth);
|
| 28455 |
tejbeer |
1064 |
|
| 31751 |
tejbeer |
1065 |
List<PriceDropBrandModel> priceDropBrandSixMonthTotals = priceDropRepository.selectSixMonthBrandPriceDropByYearMonth(fofoId, startfMonthTotal, endMonthTotal);
|
| 28641 |
amit.gupta |
1066 |
|
| 31751 |
tejbeer |
1067 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
| 28455 |
tejbeer |
1068 |
|
| 31751 |
tejbeer |
1069 |
Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
|
| 28641 |
amit.gupta |
1070 |
|
| 31751 |
tejbeer |
1071 |
LOGGER.info("priceDropBrandSixMonthTotals" + priceDropBrandSixMonthTotals);
|
| 28825 |
tejbeer |
1072 |
|
| 31751 |
tejbeer |
1073 |
Map<String, Double> priceDropBrandSixMonthMap = priceDropBrandSixMonthTotals.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getAmount()));
|
| 28825 |
tejbeer |
1074 |
|
| 31751 |
tejbeer |
1075 |
model.addAttribute("priceDropBrandSixMonthMap", priceDropBrandSixMonthMap);
|
|
|
1076 |
LOGGER.info("priceDropYearMonthModels" + priceDropYearMonthModels);
|
| 28641 |
amit.gupta |
1077 |
|
| 31751 |
tejbeer |
1078 |
for (PriceDropYearMonthModel pdm : priceDropYearMonthModels) {
|
|
|
1079 |
Map<YearMonth, Double> brandValue = new HashMap<>();
|
| 28455 |
tejbeer |
1080 |
|
| 31751 |
tejbeer |
1081 |
if (brandMonthValue.containsKey(pdm.getBrand())) {
|
|
|
1082 |
brandValue = brandMonthValue.get(pdm.getBrand());
|
|
|
1083 |
brandValue.put(YearMonth.parse(pdm.getYearMonth(), dateTimeFormatter), (double) pdm.getAmount());
|
|
|
1084 |
} else {
|
| 28455 |
tejbeer |
1085 |
|
| 31751 |
tejbeer |
1086 |
brandValue.put(YearMonth.parse(pdm.getYearMonth(), dateTimeFormatter), (double) pdm.getAmount());
|
| 28455 |
tejbeer |
1087 |
|
| 31751 |
tejbeer |
1088 |
}
|
|
|
1089 |
brandMonthValue.put(pdm.getBrand(), brandValue);
|
|
|
1090 |
}
|
|
|
1091 |
List<String> brands = new ArrayList<>();
|
|
|
1092 |
brands.add("Accessories");
|
|
|
1093 |
brands.add("Oppo");
|
|
|
1094 |
brands.add("Vivo");
|
|
|
1095 |
brands.add("Samsung");
|
|
|
1096 |
brands.add("Realme");
|
|
|
1097 |
brands.add("MI");
|
|
|
1098 |
brands.add("Tecno");
|
|
|
1099 |
brands.add("Itel");
|
|
|
1100 |
brands.add("Nokia");
|
| 29578 |
tejbeer |
1101 |
|
| 31751 |
tejbeer |
1102 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
| 28455 |
tejbeer |
1103 |
|
| 31751 |
tejbeer |
1104 |
model.addAttribute("brands", brands);
|
| 28825 |
tejbeer |
1105 |
|
| 31751 |
tejbeer |
1106 |
for (String brand : brands) {
|
|
|
1107 |
Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
|
|
|
1108 |
for (int i = 5; i >= 0; i--) {
|
| 28455 |
tejbeer |
1109 |
|
| 31751 |
tejbeer |
1110 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 28455 |
tejbeer |
1111 |
|
| 31751 |
tejbeer |
1112 |
if (yearMonthValue != null) {
|
|
|
1113 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
|
|
1114 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
1115 |
}
|
| 28455 |
tejbeer |
1116 |
|
| 31751 |
tejbeer |
1117 |
} else {
|
|
|
1118 |
yearMonthValue = new HashMap<>();
|
|
|
1119 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
1120 |
}
|
|
|
1121 |
}
|
| 28455 |
tejbeer |
1122 |
|
| 31751 |
tejbeer |
1123 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
| 28455 |
tejbeer |
1124 |
|
| 31751 |
tejbeer |
1125 |
brandMonthValue.put(brand, sortedMonthBrandValue);
|
| 28455 |
tejbeer |
1126 |
|
| 31751 |
tejbeer |
1127 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
| 28455 |
tejbeer |
1128 |
|
| 31751 |
tejbeer |
1129 |
}
|
| 28455 |
tejbeer |
1130 |
|
| 31751 |
tejbeer |
1131 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
|
|
1132 |
model.addAttribute("fofoId", fofoId);
|
| 28455 |
tejbeer |
1133 |
|
| 31751 |
tejbeer |
1134 |
model.addAttribute("sortedBrandValue", sortedBrandValue);
|
| 28455 |
tejbeer |
1135 |
|
| 31751 |
tejbeer |
1136 |
return "price-drop-tabular";
|
|
|
1137 |
}
|
| 28455 |
tejbeer |
1138 |
|
| 31751 |
tejbeer |
1139 |
@RequestMapping(value = "/getMonthlyActivation", method = RequestMethod.GET)
|
| 34528 |
ranu |
1140 |
public String getMonthlyActivation(HttpServletRequest request, Model model, @RequestParam(name = "fofoId", defaultValue = "0") int fofoId) throws Exception {
|
| 31751 |
tejbeer |
1141 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 34528 |
ranu |
1142 |
if (fofoId == 0) {
|
|
|
1143 |
fofoId = loginDetails.getFofoId();
|
|
|
1144 |
}
|
| 28455 |
tejbeer |
1145 |
|
| 31751 |
tejbeer |
1146 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1147 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| 29578 |
tejbeer |
1148 |
|
| 31751 |
tejbeer |
1149 |
List<YearMonth> yms = new ArrayList<YearMonth>();
|
| 29578 |
tejbeer |
1150 |
|
| 31751 |
tejbeer |
1151 |
for (int i = 0; i <= 5; i++) {
|
|
|
1152 |
yms.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
|
|
|
1153 |
}
|
|
|
1154 |
Collections.reverse(yms);
|
|
|
1155 |
model.addAttribute("yms", yms);
|
|
|
1156 |
LOGGER.info("ym" + yms);
|
| 29578 |
tejbeer |
1157 |
|
| 31751 |
tejbeer |
1158 |
List<ActivationYearMonthModel> pendingActivationModels = schemeInOutRepository.selectPendingActivationGroupByBrandYearMonth(fofoId, startOfMonth);
|
| 29578 |
tejbeer |
1159 |
|
| 31751 |
tejbeer |
1160 |
List<ActivationBrandModel> pendingActivationBeforeSixMonth = schemeInOutRepository.selectByYearMonthActivationGroupByBrand(fofoId, startOfMonth);
|
| 29578 |
tejbeer |
1161 |
|
| 31751 |
tejbeer |
1162 |
Map<String, Double> pendingActivationBeforeSixMonthMap = pendingActivationBeforeSixMonth.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getAmount()));
|
| 29578 |
tejbeer |
1163 |
|
| 31751 |
tejbeer |
1164 |
model.addAttribute("pendingActivationBeforeSixMonthMap", pendingActivationBeforeSixMonthMap);
|
| 29578 |
tejbeer |
1165 |
|
| 31751 |
tejbeer |
1166 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
| 29578 |
tejbeer |
1167 |
|
| 31751 |
tejbeer |
1168 |
Map<String, Map<YearMonth, Double>> activationBrandMonthMap = new HashMap<>();
|
| 29578 |
tejbeer |
1169 |
|
| 31751 |
tejbeer |
1170 |
for (ActivationYearMonthModel pam : pendingActivationModels) {
|
|
|
1171 |
Map<YearMonth, Double> brandValue = new HashMap<>();
|
| 29578 |
tejbeer |
1172 |
|
| 31751 |
tejbeer |
1173 |
if (activationBrandMonthMap.containsKey(pam.getBrand())) {
|
|
|
1174 |
brandValue = activationBrandMonthMap.get(pam.getBrand());
|
|
|
1175 |
brandValue.put(YearMonth.parse(pam.getYearMonth(), dateTimeFormatter), (double) pam.getAmount());
|
|
|
1176 |
} else {
|
| 29578 |
tejbeer |
1177 |
|
| 31751 |
tejbeer |
1178 |
brandValue.put(YearMonth.parse(pam.getYearMonth(), dateTimeFormatter), (double) pam.getAmount());
|
| 29578 |
tejbeer |
1179 |
|
| 31751 |
tejbeer |
1180 |
}
|
|
|
1181 |
activationBrandMonthMap.put(pam.getBrand(), brandValue);
|
|
|
1182 |
}
|
| 28455 |
tejbeer |
1183 |
|
| 31751 |
tejbeer |
1184 |
List<String> brands = new ArrayList<>();
|
|
|
1185 |
brands.add("Oppo");
|
|
|
1186 |
brands.add("Vivo");
|
|
|
1187 |
brands.add("Samsung");
|
|
|
1188 |
brands.add("Realme");
|
|
|
1189 |
brands.add("MI");
|
|
|
1190 |
brands.add("Tecno");
|
|
|
1191 |
brands.add("Itel");
|
|
|
1192 |
brands.add("Nokia");
|
|
|
1193 |
brands.add("Lava");
|
|
|
1194 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
| 29578 |
tejbeer |
1195 |
|
| 31751 |
tejbeer |
1196 |
model.addAttribute("brands", brands);
|
| 29578 |
tejbeer |
1197 |
|
| 31751 |
tejbeer |
1198 |
for (String brand : brands) {
|
|
|
1199 |
Map<YearMonth, Double> yearMonthValue = activationBrandMonthMap.get(brand);
|
|
|
1200 |
for (int i = 5; i >= 0; i--) {
|
|
|
1201 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
|
|
1202 |
if (yearMonthValue != null) {
|
|
|
1203 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
|
|
1204 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
1205 |
}
|
| 29578 |
tejbeer |
1206 |
|
| 31751 |
tejbeer |
1207 |
} else {
|
|
|
1208 |
yearMonthValue = new HashMap<>();
|
|
|
1209 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
1210 |
}
|
|
|
1211 |
}
|
|
|
1212 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
|
|
1213 |
activationBrandMonthMap.put(brand, sortedMonthBrandValue);
|
|
|
1214 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
|
|
1215 |
}
|
| 28455 |
tejbeer |
1216 |
|
| 31751 |
tejbeer |
1217 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
|
|
1218 |
model.addAttribute("sortedBrandValue", sortedBrandValue);
|
|
|
1219 |
model.addAttribute("fofoId", fofoId);
|
|
|
1220 |
return "activation-tabular";
|
|
|
1221 |
}
|
| 28455 |
tejbeer |
1222 |
|
| 31751 |
tejbeer |
1223 |
@RequestMapping(value = "/getMonthlyActivationItemDetail", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1224 |
public String getMonthlyActivationItemDetail(HttpServletRequest request,
|
|
|
1225 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
1226 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
1227 |
@RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model) throws
|
|
|
1228 |
Exception {
|
| 28455 |
tejbeer |
1229 |
|
| 31751 |
tejbeer |
1230 |
LOGGER.info("params" + fofoId + brand + yearMonth);
|
| 29578 |
tejbeer |
1231 |
|
| 31751 |
tejbeer |
1232 |
List<ActivationItemDetailModel> activationItemDetails = schemeInOutRepository.selectBrandPendingActivationItemDetails(fofoId, brand, yearMonth);
|
| 29578 |
tejbeer |
1233 |
|
| 35395 |
amit |
1234 |
if (!activationItemDetails.isEmpty()) {
|
|
|
1235 |
// Batch fetch to avoid N+1 queries
|
|
|
1236 |
List<Integer> inventoryItemIds = activationItemDetails.stream()
|
|
|
1237 |
.map(ActivationItemDetailModel::getInventoryItemId)
|
|
|
1238 |
.collect(Collectors.toList());
|
| 29578 |
tejbeer |
1239 |
|
| 35395 |
amit |
1240 |
Map<Integer, List<FofoLineItem>> lineItemsByInventoryId;
|
|
|
1241 |
try {
|
|
|
1242 |
lineItemsByInventoryId = fofoLineItemRepository
|
|
|
1243 |
.selectByInventoryItemIds(inventoryItemIds).stream()
|
|
|
1244 |
.collect(Collectors.groupingBy(FofoLineItem::getInventoryItemId));
|
|
|
1245 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1246 |
LOGGER.error("Error fetching FofoLineItems by inventory IDs", e);
|
|
|
1247 |
lineItemsByInventoryId = new HashMap<>();
|
|
|
1248 |
}
|
| 29578 |
tejbeer |
1249 |
|
| 35395 |
amit |
1250 |
// Get max FofoOrderItemId for each inventory item
|
|
|
1251 |
Set<Integer> fofoOrderItemIds = lineItemsByInventoryId.values().stream()
|
|
|
1252 |
.map(list -> list.stream().mapToInt(FofoLineItem::getFofoOrderItemId).max().orElse(-1))
|
|
|
1253 |
.filter(id -> id > 0)
|
|
|
1254 |
.collect(Collectors.toSet());
|
| 29578 |
tejbeer |
1255 |
|
| 35395 |
amit |
1256 |
Map<Integer, FofoOrderItem> fofoOrderItemMap;
|
|
|
1257 |
try {
|
|
|
1258 |
fofoOrderItemMap = fofoOrderItemRepository
|
|
|
1259 |
.selectByIds(new ArrayList<>(fofoOrderItemIds)).stream()
|
|
|
1260 |
.collect(Collectors.toMap(FofoOrderItem::getId, foi -> foi));
|
|
|
1261 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1262 |
LOGGER.error("Error fetching FofoOrderItems by IDs", e);
|
|
|
1263 |
fofoOrderItemMap = new HashMap<>();
|
|
|
1264 |
}
|
| 29578 |
tejbeer |
1265 |
|
| 35395 |
amit |
1266 |
Set<Integer> orderIds = fofoOrderItemMap.values().stream()
|
|
|
1267 |
.map(FofoOrderItem::getOrderId)
|
|
|
1268 |
.collect(Collectors.toSet());
|
| 29578 |
tejbeer |
1269 |
|
| 35395 |
amit |
1270 |
Map<Integer, FofoOrder> fofoOrderMap = new HashMap<>();
|
|
|
1271 |
try {
|
|
|
1272 |
fofoOrderMap = fofoOrderRepository
|
|
|
1273 |
.selectAllByOrderIds(new ArrayList<>(orderIds)).stream()
|
|
|
1274 |
.collect(Collectors.toMap(FofoOrder::getId, fo -> fo));
|
|
|
1275 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1276 |
LOGGER.error("Error fetching FofoOrders by order IDs", e);
|
|
|
1277 |
}
|
| 29578 |
tejbeer |
1278 |
|
| 35395 |
amit |
1279 |
for (ActivationItemDetailModel activationItemDetail : activationItemDetails) {
|
|
|
1280 |
List<FofoLineItem> flis = lineItemsByInventoryId.get(activationItemDetail.getInventoryItemId());
|
|
|
1281 |
if (flis != null && !flis.isEmpty()) {
|
|
|
1282 |
int maxFofoOrderItemId = flis.stream().mapToInt(FofoLineItem::getFofoOrderItemId).max().orElse(-1);
|
|
|
1283 |
FofoOrderItem foi = fofoOrderItemMap.get(maxFofoOrderItemId);
|
|
|
1284 |
if (foi != null) {
|
|
|
1285 |
FofoOrder fo = fofoOrderMap.get(foi.getOrderId());
|
|
|
1286 |
if (fo != null) {
|
|
|
1287 |
activationItemDetail.setInvoiceNumber(fo.getInvoiceNumber());
|
|
|
1288 |
}
|
|
|
1289 |
}
|
|
|
1290 |
}
|
|
|
1291 |
}
|
| 31751 |
tejbeer |
1292 |
}
|
|
|
1293 |
LOGGER.info("activationItemDetails" + activationItemDetails);
|
| 29578 |
tejbeer |
1294 |
|
| 31751 |
tejbeer |
1295 |
model.addAttribute("activationItemDetails", activationItemDetails);
|
| 29578 |
tejbeer |
1296 |
|
| 31751 |
tejbeer |
1297 |
return "activation-pending-item-details";
|
|
|
1298 |
}
|
| 28455 |
tejbeer |
1299 |
|
| 31751 |
tejbeer |
1300 |
@RequestMapping(value = "/getMonthlyActivationBeforeSixMonthsItemDetail", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1301 |
public String getMonthlyActivationItemDetail(HttpServletRequest request,
|
|
|
1302 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
1303 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model) throws Exception {
|
| 31751 |
tejbeer |
1304 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 29578 |
tejbeer |
1305 |
|
| 31751 |
tejbeer |
1306 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| 29578 |
tejbeer |
1307 |
|
| 31751 |
tejbeer |
1308 |
List<ActivationItemDetailModel> activationItemDetails = schemeInOutRepository.selectBrandPendingActivationItemDetailByYearMonth(fofoId, brand, startOfMonth);
|
| 29578 |
tejbeer |
1309 |
|
| 35395 |
amit |
1310 |
if (!activationItemDetails.isEmpty()) {
|
|
|
1311 |
// Batch fetch to avoid N+1 queries
|
|
|
1312 |
List<Integer> inventoryItemIds = activationItemDetails.stream()
|
|
|
1313 |
.map(ActivationItemDetailModel::getInventoryItemId)
|
|
|
1314 |
.collect(Collectors.toList());
|
| 29578 |
tejbeer |
1315 |
|
| 35395 |
amit |
1316 |
Map<Integer, List<FofoLineItem>> lineItemsByInventoryId;
|
|
|
1317 |
try {
|
|
|
1318 |
lineItemsByInventoryId = fofoLineItemRepository
|
|
|
1319 |
.selectByInventoryItemIds(inventoryItemIds).stream()
|
|
|
1320 |
.collect(Collectors.groupingBy(FofoLineItem::getInventoryItemId));
|
|
|
1321 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1322 |
LOGGER.error("Error fetching FofoLineItems by inventory IDs", e);
|
|
|
1323 |
lineItemsByInventoryId = new HashMap<>();
|
|
|
1324 |
}
|
| 29578 |
tejbeer |
1325 |
|
| 35395 |
amit |
1326 |
Set<Integer> fofoOrderItemIds = lineItemsByInventoryId.values().stream()
|
|
|
1327 |
.map(list -> list.stream().mapToInt(FofoLineItem::getFofoOrderItemId).max().orElse(-1))
|
|
|
1328 |
.filter(id -> id > 0)
|
|
|
1329 |
.collect(Collectors.toSet());
|
| 29578 |
tejbeer |
1330 |
|
| 35395 |
amit |
1331 |
Map<Integer, FofoOrderItem> fofoOrderItemMap;
|
|
|
1332 |
try {
|
|
|
1333 |
fofoOrderItemMap = fofoOrderItemRepository
|
|
|
1334 |
.selectByIds(new ArrayList<>(fofoOrderItemIds)).stream()
|
|
|
1335 |
.collect(Collectors.toMap(FofoOrderItem::getId, foi -> foi));
|
|
|
1336 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1337 |
LOGGER.error("Error fetching FofoOrderItems by IDs", e);
|
|
|
1338 |
fofoOrderItemMap = new HashMap<>();
|
|
|
1339 |
}
|
| 29578 |
tejbeer |
1340 |
|
| 35395 |
amit |
1341 |
Set<Integer> orderIds = fofoOrderItemMap.values().stream()
|
|
|
1342 |
.map(FofoOrderItem::getOrderId)
|
|
|
1343 |
.collect(Collectors.toSet());
|
| 29578 |
tejbeer |
1344 |
|
| 35395 |
amit |
1345 |
Map<Integer, FofoOrder> fofoOrderMap = new HashMap<>();
|
|
|
1346 |
try {
|
|
|
1347 |
fofoOrderMap = fofoOrderRepository
|
|
|
1348 |
.selectAllByOrderIds(new ArrayList<>(orderIds)).stream()
|
|
|
1349 |
.collect(Collectors.toMap(FofoOrder::getId, fo -> fo));
|
|
|
1350 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1351 |
LOGGER.error("Error fetching FofoOrders by order IDs", e);
|
|
|
1352 |
}
|
| 29578 |
tejbeer |
1353 |
|
| 35395 |
amit |
1354 |
for (ActivationItemDetailModel activationItemDetail : activationItemDetails) {
|
|
|
1355 |
List<FofoLineItem> flis = lineItemsByInventoryId.get(activationItemDetail.getInventoryItemId());
|
|
|
1356 |
if (flis != null && !flis.isEmpty()) {
|
|
|
1357 |
int maxFofoOrderItemId = flis.stream().mapToInt(FofoLineItem::getFofoOrderItemId).max().orElse(-1);
|
|
|
1358 |
FofoOrderItem foi = fofoOrderItemMap.get(maxFofoOrderItemId);
|
|
|
1359 |
if (foi != null) {
|
|
|
1360 |
FofoOrder fo = fofoOrderMap.get(foi.getOrderId());
|
|
|
1361 |
if (fo != null) {
|
|
|
1362 |
activationItemDetail.setInvoiceNumber(fo.getInvoiceNumber());
|
|
|
1363 |
}
|
|
|
1364 |
}
|
|
|
1365 |
}
|
|
|
1366 |
}
|
| 31751 |
tejbeer |
1367 |
}
|
|
|
1368 |
LOGGER.info("activationItemDetails" + activationItemDetails);
|
| 29578 |
tejbeer |
1369 |
|
| 31751 |
tejbeer |
1370 |
model.addAttribute("activationItemDetails", activationItemDetails);
|
| 29578 |
tejbeer |
1371 |
|
| 31751 |
tejbeer |
1372 |
return "activation-pending-item-details";
|
|
|
1373 |
}
|
| 29578 |
tejbeer |
1374 |
|
| 31751 |
tejbeer |
1375 |
@RequestMapping(value = "/getMonthlySamsungUpgradeOffer", method = RequestMethod.GET)
|
|
|
1376 |
public String getMonthlySamsungUpgradeOffer(HttpServletRequest request, Model model) throws Exception {
|
|
|
1377 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1378 |
int fofoId = loginDetails.getFofoId();
|
| 29707 |
tejbeer |
1379 |
|
| 31751 |
tejbeer |
1380 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1381 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| 29707 |
tejbeer |
1382 |
|
| 31751 |
tejbeer |
1383 |
List<YearMonth> yms = new ArrayList<YearMonth>();
|
| 29707 |
tejbeer |
1384 |
|
| 31751 |
tejbeer |
1385 |
for (int i = 0; i <= 5; i++) {
|
|
|
1386 |
yms.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
|
|
|
1387 |
}
|
|
|
1388 |
Collections.reverse(yms);
|
|
|
1389 |
model.addAttribute("yms", yms);
|
|
|
1390 |
LOGGER.info("ym" + yms);
|
| 29707 |
tejbeer |
1391 |
|
| 31751 |
tejbeer |
1392 |
List<SamsungUpgradeOfferModel> suos = samsungUpgradeOfferRepository.selectUpgradeOfferGroupByYearMonth(fofoId, UpgradeOfferStatus.approved, startOfMonth);
|
| 29707 |
tejbeer |
1393 |
|
| 31751 |
tejbeer |
1394 |
LOGGER.info("suos" + suos);
|
| 29707 |
tejbeer |
1395 |
|
| 31751 |
tejbeer |
1396 |
List<BrandAmountModel> beforeSixMonthOffers = samsungUpgradeOfferRepository.selectUpgradeOfferByYearMonthGroupByBrand(fofoId, UpgradeOfferStatus.approved, startOfMonth);
|
| 29707 |
tejbeer |
1397 |
|
| 31751 |
tejbeer |
1398 |
Map<String, Double> pendingUpgradeOfferBeforeSixMonthMap = beforeSixMonthOffers.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getAmount()));
|
| 29707 |
tejbeer |
1399 |
|
| 31751 |
tejbeer |
1400 |
model.addAttribute("pendingUpgradeOfferBeforeSixMonthMap", pendingUpgradeOfferBeforeSixMonthMap);
|
| 29707 |
tejbeer |
1401 |
|
| 31751 |
tejbeer |
1402 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
| 29707 |
tejbeer |
1403 |
|
| 31751 |
tejbeer |
1404 |
Map<String, Map<YearMonth, Double>> upgradeOfferBrandMonthMap = new HashMap<>();
|
| 29707 |
tejbeer |
1405 |
|
| 31751 |
tejbeer |
1406 |
for (SamsungUpgradeOfferModel suo : suos) {
|
|
|
1407 |
Map<YearMonth, Double> brandValue = new HashMap<>();
|
| 29707 |
tejbeer |
1408 |
|
| 31751 |
tejbeer |
1409 |
if (upgradeOfferBrandMonthMap.containsKey(suo.getBrand())) {
|
|
|
1410 |
brandValue = upgradeOfferBrandMonthMap.get(suo.getBrand());
|
|
|
1411 |
brandValue.put(YearMonth.parse(suo.getYearMonth(), dateTimeFormatter), (double) suo.getAmount());
|
|
|
1412 |
} else {
|
| 29707 |
tejbeer |
1413 |
|
| 31751 |
tejbeer |
1414 |
brandValue.put(YearMonth.parse(suo.getYearMonth(), dateTimeFormatter), (double) suo.getAmount());
|
| 29707 |
tejbeer |
1415 |
|
| 31751 |
tejbeer |
1416 |
}
|
|
|
1417 |
upgradeOfferBrandMonthMap.put(suo.getBrand(), brandValue);
|
|
|
1418 |
}
|
| 29707 |
tejbeer |
1419 |
|
| 31751 |
tejbeer |
1420 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
|
|
1421 |
String brand = "Samsung";
|
| 29707 |
tejbeer |
1422 |
|
| 31751 |
tejbeer |
1423 |
Map<YearMonth, Double> yearMonthValue = upgradeOfferBrandMonthMap.get(brand);
|
|
|
1424 |
for (int i = 5; i >= 0; i--) {
|
|
|
1425 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
|
|
1426 |
if (yearMonthValue != null) {
|
|
|
1427 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
|
|
1428 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
1429 |
}
|
| 29707 |
tejbeer |
1430 |
|
| 31751 |
tejbeer |
1431 |
} else {
|
|
|
1432 |
yearMonthValue = new HashMap<>();
|
|
|
1433 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
1434 |
}
|
|
|
1435 |
}
|
|
|
1436 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
|
|
1437 |
upgradeOfferBrandMonthMap.put(brand, sortedMonthBrandValue);
|
|
|
1438 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
|
|
1439 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
| 29707 |
tejbeer |
1440 |
|
| 31751 |
tejbeer |
1441 |
model.addAttribute("brand", brand);
|
|
|
1442 |
model.addAttribute("sortedBrandValue", sortedBrandValue);
|
|
|
1443 |
model.addAttribute("fofoId", fofoId);
|
|
|
1444 |
return "upgrade-offer-tabular";
|
| 29707 |
tejbeer |
1445 |
|
| 31751 |
tejbeer |
1446 |
}
|
| 29707 |
tejbeer |
1447 |
|
| 31751 |
tejbeer |
1448 |
@RequestMapping(value = "/getMonthlyUpgradeOfferItemDetail", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1449 |
public String getMonthlyUpgradeOfferItemDetail(HttpServletRequest request,
|
|
|
1450 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
1451 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
1452 |
@RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model) throws
|
|
|
1453 |
Exception {
|
| 29707 |
tejbeer |
1454 |
|
| 31751 |
tejbeer |
1455 |
LOGGER.info("params" + fofoId + brand + yearMonth);
|
|
|
1456 |
List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository.selectUpgradeOfferItemDetails(fofoId, UpgradeOfferStatus.approved, brand, yearMonth);
|
| 29707 |
tejbeer |
1457 |
|
| 31751 |
tejbeer |
1458 |
model.addAttribute("offerItems", offerItems);
|
| 29707 |
tejbeer |
1459 |
|
| 31751 |
tejbeer |
1460 |
return "upgrade-offer-item-detail";
|
|
|
1461 |
}
|
| 29707 |
tejbeer |
1462 |
|
| 31751 |
tejbeer |
1463 |
@RequestMapping(value = "/getUpgradeOfferBeforeSixMonthItemDetail", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1464 |
public String getUpgradeOfferBeforeSixMonthItemDetail(HttpServletRequest request,
|
|
|
1465 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
1466 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model) throws Exception {
|
| 31751 |
tejbeer |
1467 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 29707 |
tejbeer |
1468 |
|
| 31751 |
tejbeer |
1469 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| 29707 |
tejbeer |
1470 |
|
| 31751 |
tejbeer |
1471 |
List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository.selectUpgradeOfferItemDetailByYearMonth(fofoId, UpgradeOfferStatus.approved, brand, startOfMonth);
|
| 29707 |
tejbeer |
1472 |
|
| 31751 |
tejbeer |
1473 |
model.addAttribute("offerItems", offerItems);
|
| 29707 |
tejbeer |
1474 |
|
| 31751 |
tejbeer |
1475 |
return "upgrade-offer-item-detail";
|
|
|
1476 |
}
|
| 29707 |
tejbeer |
1477 |
|
| 31751 |
tejbeer |
1478 |
@RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1479 |
public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId) throws
|
|
|
1480 |
Exception {
|
| 26418 |
tejbeer |
1481 |
|
| 31751 |
tejbeer |
1482 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
|
|
1483 |
Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
|
| 26418 |
tejbeer |
1484 |
|
| 31751 |
tejbeer |
1485 |
Map<Integer, PartnerDetailModel> fofoIdAndallValues = partnerStatsService.getAllPartnerStats();
|
|
|
1486 |
if (authId != 0) {
|
|
|
1487 |
List<Integer> fofoIds = pp.get(authId);
|
|
|
1488 |
fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey())).collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
|
|
1489 |
} else {
|
|
|
1490 |
}
|
| 26418 |
tejbeer |
1491 |
|
| 36268 |
ranu |
1492 |
// Build escalation map: fofoId -> escalation label (from open tickets)
|
|
|
1493 |
Set<Integer> escalationSubCatIds = new HashSet<>(Arrays.asList(
|
|
|
1494 |
ProfitMandiConstants.RBM_L2_ESCALATION,
|
|
|
1495 |
ProfitMandiConstants.RBM_L3_ESCALATION,
|
|
|
1496 |
ProfitMandiConstants.SALES_ESCALATION));
|
|
|
1497 |
Map<Integer, String> escalationMap = new HashMap<>();
|
|
|
1498 |
List<Integer> partnerFofoIds = new ArrayList<>(fofoIdAndallValues.keySet());
|
|
|
1499 |
if (!partnerFofoIds.isEmpty()) {
|
|
|
1500 |
List<Ticket> openTickets = ticketRepository.selectAllOpenTickets(partnerFofoIds);
|
|
|
1501 |
for (Ticket t : openTickets) {
|
|
|
1502 |
if (t.getCloseTimestamp() == null && escalationSubCatIds.contains(t.getSubCategoryId())) {
|
|
|
1503 |
String label;
|
|
|
1504 |
if (t.getSubCategoryId() == ProfitMandiConstants.RBM_L2_ESCALATION) {
|
|
|
1505 |
label = "RBM L2 Escalation";
|
|
|
1506 |
} else if (t.getSubCategoryId() == ProfitMandiConstants.RBM_L3_ESCALATION) {
|
|
|
1507 |
label = "RBM L3 Escalation";
|
|
|
1508 |
} else {
|
|
|
1509 |
label = "Sales Escalation";
|
|
|
1510 |
}
|
|
|
1511 |
// If partner already has an escalation, keep higher priority (Sales > L3 > L2)
|
|
|
1512 |
String existing = escalationMap.get(t.getFofoId());
|
|
|
1513 |
if (existing == null || label.contains("Sales") || (label.contains("L3") && !existing.contains("Sales"))) {
|
|
|
1514 |
escalationMap.put(t.getFofoId(), label);
|
|
|
1515 |
}
|
|
|
1516 |
}
|
|
|
1517 |
}
|
|
|
1518 |
}
|
|
|
1519 |
model.addAttribute("escalationMap", escalationMap);
|
|
|
1520 |
|
| 31751 |
tejbeer |
1521 |
model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
|
|
|
1522 |
model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
|
| 26418 |
tejbeer |
1523 |
|
| 31751 |
tejbeer |
1524 |
return "auth_user_partner_detail";
|
|
|
1525 |
}
|
| 26418 |
tejbeer |
1526 |
|
| 31751 |
tejbeer |
1527 |
@RequestMapping(value = "/getWarehousePartners", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1528 |
public String warehousePartnersDetail(HttpServletRequest request, Model model, @RequestParam int warehouseId) throws
|
|
|
1529 |
Exception {
|
| 31751 |
tejbeer |
1530 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1531 |
String email = loginDetails.getEmailId();
|
| 28472 |
tejbeer |
1532 |
|
| 35480 |
amit |
1533 |
Set<Integer> authfofoIds = csService1.getAuthFofoIds(email, true);
|
|
|
1534 |
if (authfofoIds == null) {
|
|
|
1535 |
authfofoIds = new HashSet<>();
|
|
|
1536 |
}
|
| 31751 |
tejbeer |
1537 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
|
|
|
1538 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
| 27701 |
tejbeer |
1539 |
|
| 35099 |
amit |
1540 |
if (!warehouseIdFofoIdMap.containsKey(7573)) {
|
|
|
1541 |
warehouseIdFofoIdMap.put(7573, new ArrayList<>());
|
|
|
1542 |
}
|
|
|
1543 |
|
| 31751 |
tejbeer |
1544 |
Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
|
|
|
1545 |
Map<Integer, PartnerDetailModel> fofoIdAndallValues = adminUser.getPartnersStatDataFromFile();
|
| 35480 |
amit |
1546 |
if (fofoIdAndallValues == null) {
|
|
|
1547 |
fofoIdAndallValues = new HashMap<>();
|
|
|
1548 |
}
|
| 31751 |
tejbeer |
1549 |
if (warehouseId != 0) {
|
|
|
1550 |
List<Integer> fofoIds = warehouseIdFofoIdMap.get(warehouseId);
|
| 35480 |
amit |
1551 |
if (fofoIds != null) {
|
|
|
1552 |
fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey())).collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
|
|
1553 |
}
|
| 35854 |
amit |
1554 |
} else {
|
|
|
1555 |
Set<Integer> finalAuthfofoIds = authfofoIds;
|
|
|
1556 |
fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> finalAuthfofoIds.contains(x.getKey())).collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
| 31751 |
tejbeer |
1557 |
}
|
|
|
1558 |
ChartInvestmentModel cm = adminUser.getAllStatePartnerType(fofoIdAndallValues);
|
|
|
1559 |
model.addAttribute("chartPieMap", gson.toJson(cm));
|
| 27545 |
tejbeer |
1560 |
|
| 31751 |
tejbeer |
1561 |
LOGGER.info("adminUserChart" + gson.toJson(cm));
|
| 29164 |
manish |
1562 |
|
| 31751 |
tejbeer |
1563 |
Map<Integer, MonthlyTarget> monthlyTargetMap = monthlyTargetRepository.selectByDate(YearMonth.now()).stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 31211 |
tejbeer |
1564 |
|
| 36268 |
ranu |
1565 |
// Build escalation map from open tickets
|
|
|
1566 |
Set<Integer> escalationSubCatIds2 = new HashSet<>(Arrays.asList(
|
|
|
1567 |
ProfitMandiConstants.RBM_L2_ESCALATION,
|
|
|
1568 |
ProfitMandiConstants.RBM_L3_ESCALATION,
|
|
|
1569 |
ProfitMandiConstants.SALES_ESCALATION));
|
|
|
1570 |
Map<Integer, String> escalationMap = new HashMap<>();
|
|
|
1571 |
List<Integer> partnerFofoIds2 = new ArrayList<>(fofoIdAndallValues.keySet());
|
|
|
1572 |
if (!partnerFofoIds2.isEmpty()) {
|
|
|
1573 |
List<Ticket> openTickets = ticketRepository.selectAllOpenTickets(partnerFofoIds2);
|
|
|
1574 |
for (Ticket t : openTickets) {
|
|
|
1575 |
if (t.getCloseTimestamp() == null && escalationSubCatIds2.contains(t.getSubCategoryId())) {
|
|
|
1576 |
String label;
|
|
|
1577 |
if (t.getSubCategoryId() == ProfitMandiConstants.RBM_L2_ESCALATION) {
|
|
|
1578 |
label = "RBM L2 Escalation";
|
|
|
1579 |
} else if (t.getSubCategoryId() == ProfitMandiConstants.RBM_L3_ESCALATION) {
|
|
|
1580 |
label = "RBM L3 Escalation";
|
|
|
1581 |
} else {
|
|
|
1582 |
label = "Sales Escalation";
|
|
|
1583 |
}
|
|
|
1584 |
String existing = escalationMap.get(t.getFofoId());
|
|
|
1585 |
if (existing == null || label.contains("L3") || (label.contains("Sales") && !existing.contains("L3"))) {
|
|
|
1586 |
escalationMap.put(t.getFofoId(), label);
|
|
|
1587 |
}
|
|
|
1588 |
}
|
|
|
1589 |
}
|
|
|
1590 |
}
|
|
|
1591 |
model.addAttribute("escalationMap", escalationMap);
|
|
|
1592 |
|
| 31751 |
tejbeer |
1593 |
model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
|
|
|
1594 |
model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
|
|
|
1595 |
model.addAttribute("monthlyTargetMap", monthlyTargetMap);
|
| 27545 |
tejbeer |
1596 |
|
| 31751 |
tejbeer |
1597 |
List<PartnerType> partnerTypes = Arrays.asList(PartnerType.values()).stream().filter(x -> !x.equals(PartnerType.ALL)).collect(Collectors.toList());
|
| 31211 |
tejbeer |
1598 |
|
| 31751 |
tejbeer |
1599 |
model.addAttribute("partnerTypes", partnerTypes);
|
| 31154 |
tejbeer |
1600 |
|
| 31751 |
tejbeer |
1601 |
return "auth_user_partner_detail";
|
|
|
1602 |
}
|
| 27545 |
tejbeer |
1603 |
|
| 31662 |
amit.gupta |
1604 |
|
| 31751 |
tejbeer |
1605 |
@RequestMapping(value = "/getWarehouseWiseBrandStock", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1606 |
public String getWarehouseWiseBrandStock(HttpServletRequest request, Model
|
|
|
1607 |
model, @RequestParam List<Integer> warehouseId) throws Exception {
|
| 31751 |
tejbeer |
1608 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1609 |
String email = loginDetails.getEmailId();
|
| 36481 |
ranu |
1610 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
1611 |
List<Position> positions = positionRepository.selectAllByAuthUserId(authUser.getId());
|
| 35099 |
amit |
1612 |
|
| 36481 |
ranu |
1613 |
boolean isRbmL3OrAbove = positions.stream().anyMatch(pos ->
|
|
|
1614 |
pos.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_RBM
|
|
|
1615 |
&& pos.getEscalationType() != null
|
|
|
1616 |
&& pos.getEscalationType() != EscalationType.L1
|
|
|
1617 |
&& pos.getEscalationType() != EscalationType.L2);
|
|
|
1618 |
|
|
|
1619 |
Set<Integer> fofoIds;
|
|
|
1620 |
if (isRbmL3OrAbove) {
|
|
|
1621 |
fofoIds = fofoStoreRepository.selectActiveStores().stream()
|
|
|
1622 |
.map(x -> x.getId()).collect(Collectors.toSet());
|
|
|
1623 |
} else {
|
|
|
1624 |
fofoIds = csService1.getAuthFofoIds(email, true);
|
|
|
1625 |
}
|
|
|
1626 |
|
|
|
1627 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
|
|
1628 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream()
|
|
|
1629 |
.collect(Collectors.groupingBy(FofoStore::getWarehouseId,
|
|
|
1630 |
Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
1631 |
|
| 35099 |
amit |
1632 |
if (!warehouseIdFofoIdMap.containsKey(7573)) {
|
|
|
1633 |
warehouseIdFofoIdMap.put(7573, new ArrayList<>());
|
|
|
1634 |
}
|
| 36725 |
ranu |
1635 |
if (!warehouseIdFofoIdMap.containsKey(10516)) {
|
|
|
1636 |
warehouseIdFofoIdMap.put(10516, new ArrayList<>());
|
|
|
1637 |
}
|
| 36480 |
ranu |
1638 |
if (!warehouseIdFofoIdMap.containsKey(7678)) {
|
|
|
1639 |
warehouseIdFofoIdMap.put(7678, new ArrayList<>());
|
|
|
1640 |
}
|
| 31751 |
tejbeer |
1641 |
List<WarehouseWiseBrandStockModel> warehouseWiseBrandStock = new ArrayList<>();
|
|
|
1642 |
if (!warehouseId.contains(0)) {
|
|
|
1643 |
warehouseWiseBrandStock = saholicInventoryCISRepository.selectGroupByWarehouseAndBrand(warehouseId);
|
|
|
1644 |
} else {
|
|
|
1645 |
LOGGER.info("warehouseIdFofoIdMap" + warehouseIdFofoIdMap.keySet());
|
|
|
1646 |
warehouseWiseBrandStock = saholicInventoryCISRepository.selectGroupByWarehouseAndBrand(new ArrayList<>(warehouseIdFofoIdMap.keySet()));
|
| 27701 |
tejbeer |
1647 |
|
| 31751 |
tejbeer |
1648 |
}
|
|
|
1649 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1650 |
model.addAttribute("warehouseWiseBrandStock", warehouseWiseBrandStock);
|
|
|
1651 |
model.addAttribute("warehouseId", warehouseId);
|
|
|
1652 |
model.addAttribute("warehouseMap", warehouseMap);
|
| 27660 |
tejbeer |
1653 |
|
| 31751 |
tejbeer |
1654 |
return "warehouse_brand_stock";
|
|
|
1655 |
}
|
| 27509 |
tejbeer |
1656 |
|
| 31751 |
tejbeer |
1657 |
@RequestMapping(value = "/getWarehouseWiseData", method = RequestMethod.GET)
|
|
|
1658 |
public String getWarehouseWiseData(HttpServletRequest request, Model model) throws Exception {
|
|
|
1659 |
inventoryService.getItemAvailabilityAndIndent();
|
|
|
1660 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
1661 |
return "response";
|
|
|
1662 |
}
|
| 27529 |
tejbeer |
1663 |
|
| 31751 |
tejbeer |
1664 |
@RequestMapping(value = "/getWarehouseWiseBrandAndCategory", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1665 |
public String getWarehouseWiseBrandAndCategory(HttpServletRequest request, Model
|
|
|
1666 |
model, @RequestParam List<Integer> warehouseId, @RequestParam List<String> brands, @RequestParam String
|
|
|
1667 |
category) throws Exception {
|
| 27509 |
tejbeer |
1668 |
|
| 31751 |
tejbeer |
1669 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1670 |
List<String> listbrands = saholicInventoryCISRepository.selectAllBrand();
|
|
|
1671 |
List<String> listCategory = saholicInventoryCISRepository.selectAllSubCategory();
|
| 27539 |
tejbeer |
1672 |
|
| 31751 |
tejbeer |
1673 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1674 |
model.addAttribute("brands", listbrands);
|
|
|
1675 |
model.addAttribute("listCategory", listCategory);
|
| 27538 |
tejbeer |
1676 |
|
| 31751 |
tejbeer |
1677 |
model.addAttribute("selectedBrand", brands);
|
|
|
1678 |
model.addAttribute("selectedWarehouse", warehouseId);
|
|
|
1679 |
model.addAttribute("selectedCategory", category);
|
| 27539 |
tejbeer |
1680 |
|
| 31751 |
tejbeer |
1681 |
return "warehouse_brand_item_stock";
|
|
|
1682 |
}
|
| 27509 |
tejbeer |
1683 |
|
| 31751 |
tejbeer |
1684 |
@RequestMapping(value = "/getWarehouseWiseItemStock", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1685 |
public String getWarehouseWiseItemStock(HttpServletRequest request, Model
|
| 34176 |
tejus.loha |
1686 |
model, @RequestParam(name = "warehouseId") List<Integer> warehouseIds, @RequestParam List<String> brands, @RequestParam String
|
| 32836 |
amit.gupta |
1687 |
category) throws Exception {
|
| 31751 |
tejbeer |
1688 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 32836 |
amit.gupta |
1689 |
if (warehouseIds.contains(0)) {
|
|
|
1690 |
warehouseIds.addAll(warehouseMap.keySet());
|
| 31751 |
tejbeer |
1691 |
}
|
| 32836 |
amit.gupta |
1692 |
List<WarehouseWiseitemStockModel> warehouseWiseItemStock = saholicInventoryCISRepository.selectWarehouseItemStock(warehouseIds, brands, category);
|
| 27539 |
tejbeer |
1693 |
|
| 31751 |
tejbeer |
1694 |
model.addAttribute("warehouseWiseItemStock", warehouseWiseItemStock);
|
|
|
1695 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1696 |
return "warehouse_item_details";
|
|
|
1697 |
}
|
| 27538 |
tejbeer |
1698 |
|
| 31751 |
tejbeer |
1699 |
@RequestMapping(value = "/getWarehouseWiseBrandPartnerSale", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1700 |
public String getWarehouseWiseBrandPartnerSale(HttpServletRequest request, Model model, @RequestParam String
|
|
|
1701 |
brand) throws Exception {
|
| 27701 |
tejbeer |
1702 |
|
| 31751 |
tejbeer |
1703 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1704 |
String email = loginDetails.getEmailId();
|
| 27701 |
tejbeer |
1705 |
|
| 31751 |
tejbeer |
1706 |
Set<Integer> authfofoIds = csService1.getAuthFofoIds(email, true);
|
| 28472 |
tejbeer |
1707 |
|
| 31751 |
tejbeer |
1708 |
Map<Integer, WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository.selectGroupByWarehouseBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds)).stream().collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
|
| 27670 |
tejbeer |
1709 |
|
| 31751 |
tejbeer |
1710 |
List<WarehouseWiseBrandUnbilledActivatedModel> unbilledStock = fofoStoreRepository.selectUnbilledActivateStockGroupByWarehouse(brand, new ArrayList<>(authfofoIds));
|
| 27670 |
tejbeer |
1711 |
|
| 31751 |
tejbeer |
1712 |
for (WarehouseWiseBrandUnbilledActivatedModel un : unbilledStock) {
|
|
|
1713 |
WarehouseWiseBrandSaleModel bpt = warehouseWiseBrandPartnerSales.get(un.getWarehouseId());
|
|
|
1714 |
if (bpt != null) {
|
|
|
1715 |
bpt.setAmtd(un.getUnbilledMtd());
|
|
|
1716 |
bpt.setUamtdQty(un.getUnbilledQty());
|
|
|
1717 |
} else {
|
|
|
1718 |
bpt = new WarehouseWiseBrandSaleModel();
|
|
|
1719 |
bpt.setWarehouseId(un.getWarehouseId());
|
|
|
1720 |
bpt.setAmtd(un.getUnbilledMtd());
|
|
|
1721 |
bpt.setUamtdQty(un.getUnbilledQty());
|
|
|
1722 |
bpt.setLms(0);
|
|
|
1723 |
bpt.setLmtd(0);
|
|
|
1724 |
bpt.setMtd(0);
|
|
|
1725 |
bpt.setMtdQty(0);
|
|
|
1726 |
bpt.setLmtd(0);
|
|
|
1727 |
bpt.setLmtdQty(0);
|
|
|
1728 |
warehouseWiseBrandPartnerSales.put(un.getWarehouseId(), bpt);
|
|
|
1729 |
}
|
|
|
1730 |
}
|
|
|
1731 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27591 |
tejbeer |
1732 |
|
| 31751 |
tejbeer |
1733 |
Set<String> brands = inventoryService.getAllTagListingBrands();
|
|
|
1734 |
model.addAttribute("warehouseWiseBrandPartnerSales", warehouseWiseBrandPartnerSales);
|
|
|
1735 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1736 |
model.addAttribute("brands", brands);
|
|
|
1737 |
model.addAttribute("selectedbrand", brand);
|
|
|
1738 |
return "warehousewise_brand_partners_sale";
|
|
|
1739 |
}
|
| 27556 |
tejbeer |
1740 |
|
| 31751 |
tejbeer |
1741 |
@RequestMapping(value = "/getWarehouseWiseAccesoriesBrandPartnerSale", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1742 |
public String getWarehouseWiseAccesoriesBrandPartnerSale(HttpServletRequest request, Model
|
|
|
1743 |
model, @RequestParam String brand) throws Exception {
|
| 31751 |
tejbeer |
1744 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1745 |
String email = loginDetails.getEmailId();
|
|
|
1746 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1747 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 28472 |
tejbeer |
1748 |
|
| 31751 |
tejbeer |
1749 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
1750 |
if (authfofoIds == null) {
|
| 35395 |
amit |
1751 |
List<Position> positions1 = positionRepository.selectAllByAuthUserId(authUser.getId());
|
| 31751 |
tejbeer |
1752 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER).count() > 0) {
|
|
|
1753 |
authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
1754 |
}
|
|
|
1755 |
}
|
|
|
1756 |
List<WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository.selectGroupByWarehouseAccesoriesBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds));
|
|
|
1757 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27594 |
tejbeer |
1758 |
|
| 31751 |
tejbeer |
1759 |
Set<String> brands = inventoryService.getAllTagListingBrands();
|
|
|
1760 |
model.addAttribute("warehouseWiseBrandPartnerSales", warehouseWiseBrandPartnerSales);
|
|
|
1761 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1762 |
model.addAttribute("brands", brands);
|
|
|
1763 |
model.addAttribute("selectedbrand", brand);
|
|
|
1764 |
return "warehousewise_accessoriesbrand_sale";
|
|
|
1765 |
}
|
| 27594 |
tejbeer |
1766 |
|
| 31751 |
tejbeer |
1767 |
@RequestMapping(value = "/getWarehouseBrandWiseItemSale", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1768 |
public String getWarehouseBrandWiseItemSale(HttpServletRequest request, Model
|
|
|
1769 |
model, @RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
| 31751 |
tejbeer |
1770 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1771 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1772 |
String email = loginDetails.getEmailId();
|
|
|
1773 |
Set<Integer> authfofoIds = csService1.getAuthFofoIds(email, true);
|
|
|
1774 |
Map<Integer, WarehouseBrandWiseItemSaleModel> branditemSalesMap = fofoStoreRepository.selectWarehouseBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds)).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 27670 |
tejbeer |
1775 |
|
| 31751 |
tejbeer |
1776 |
List<WarehouseBrandItemUnbilledActivatedModel> unbilledItems = fofoStoreRepository.selectWarehouseBrandItemUnbilledActivateStock(warehouseId, brand, new ArrayList<>(authfofoIds));
|
| 27670 |
tejbeer |
1777 |
|
| 31751 |
tejbeer |
1778 |
for (WarehouseBrandItemUnbilledActivatedModel un : unbilledItems) {
|
|
|
1779 |
WarehouseBrandWiseItemSaleModel bpt = branditemSalesMap.get(un.getItemId());
|
|
|
1780 |
if (bpt != null) {
|
|
|
1781 |
bpt.setAmtd(un.getAmtd());
|
|
|
1782 |
bpt.setUamtdQty(un.getUnmtdQty());
|
|
|
1783 |
} else {
|
|
|
1784 |
bpt = new WarehouseBrandWiseItemSaleModel();
|
|
|
1785 |
bpt.setWarehouseId(un.getWarehouseId());
|
|
|
1786 |
bpt.setItemId(un.getItemId());
|
|
|
1787 |
bpt.setAmtd(un.getAmtd());
|
|
|
1788 |
bpt.setUamtdQty(un.getUnmtdQty());
|
|
|
1789 |
bpt.setBrand(un.getBrand());
|
|
|
1790 |
bpt.setModelName(un.getModelName());
|
|
|
1791 |
bpt.setModelNumber(un.getModelNumber());
|
|
|
1792 |
bpt.setColor(un.getColor());
|
|
|
1793 |
bpt.setLms(0);
|
|
|
1794 |
bpt.setLmtd(0);
|
|
|
1795 |
bpt.setMtd(0);
|
|
|
1796 |
bpt.setMtdQty(0);
|
|
|
1797 |
bpt.setLmtd(0);
|
|
|
1798 |
bpt.setLmtdQty(0);
|
|
|
1799 |
branditemSalesMap.put(un.getItemId(), bpt);
|
|
|
1800 |
}
|
|
|
1801 |
}
|
|
|
1802 |
model.addAttribute("branditemSales", branditemSalesMap);
|
|
|
1803 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1804 |
return "warehouse_partner_itemwise_sale";
|
|
|
1805 |
}
|
| 27556 |
tejbeer |
1806 |
|
| 31751 |
tejbeer |
1807 |
@RequestMapping(value = "/getWarehouseAccesoriesBrandWiseItemSale", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
1808 |
public String getWarehouseAccesoriesBrandWiseItemSale(HttpServletRequest request, Model
|
|
|
1809 |
model, @RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
| 31751 |
tejbeer |
1810 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1811 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1812 |
String email = loginDetails.getEmailId();
|
|
|
1813 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1814 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
|
|
1815 |
List<WarehouseBrandWiseItemSaleModel> branditemSales = fofoStoreRepository.selectWarehouseAccesoriesBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds));
|
|
|
1816 |
model.addAttribute("branditemSales", branditemSales);
|
|
|
1817 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1818 |
return "warehouse_accessories_itemwsie_sale";
|
|
|
1819 |
}
|
| 27594 |
tejbeer |
1820 |
|
| 36890 |
aman |
1821 |
// Users allowed to add / edit / delete contact-us entries.
|
|
|
1822 |
private static final Set<String> CONTACT_US_EDITORS = new HashSet<>(Arrays.asList(
|
|
|
1823 |
"kangan.monga@smartdukaan.com",
|
|
|
1824 |
"gaurav.mathur1@smartdukaan.com"));
|
|
|
1825 |
|
|
|
1826 |
private boolean isContactUsEditor(LoginDetails loginDetails) {
|
|
|
1827 |
return loginDetails != null && loginDetails.getEmailId() != null
|
|
|
1828 |
&& CONTACT_US_EDITORS.contains(loginDetails.getEmailId().trim().toLowerCase());
|
|
|
1829 |
}
|
|
|
1830 |
|
| 31751 |
tejbeer |
1831 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
|
|
1832 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 36890 |
aman |
1833 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 31751 |
tejbeer |
1834 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 36890 |
aman |
1835 |
// Defensive: never let a DB hiccup turn the contact page into a 500.
|
|
|
1836 |
// The table is provisioned by ContactUsTableBootstrap, but if a query
|
|
|
1837 |
// still fails we render the page with empty lists rather than crashing.
|
|
|
1838 |
try {
|
|
|
1839 |
model.addAttribute("mainContacts", contactUsRepository.findActiveBySection(ContactUs.SECTION_MAIN));
|
|
|
1840 |
model.addAttribute("escalationContacts", contactUsRepository.findActiveBySection(ContactUs.SECTION_ESCALATION));
|
|
|
1841 |
} catch (Exception e) {
|
|
|
1842 |
LOGGER.error("Failed loading contact_us data; rendering empty contact list", e);
|
|
|
1843 |
model.addAttribute("mainContacts", java.util.Collections.emptyList());
|
|
|
1844 |
model.addAttribute("escalationContacts", java.util.Collections.emptyList());
|
|
|
1845 |
}
|
|
|
1846 |
model.addAttribute("contactUsEditor", isContactUsEditor(loginDetails));
|
| 31751 |
tejbeer |
1847 |
return "contact-us";
|
|
|
1848 |
}
|
| 23923 |
amit.gupta |
1849 |
|
| 36890 |
aman |
1850 |
@RequestMapping(value = "/contactUs/save", method = RequestMethod.POST)
|
|
|
1851 |
@ResponseBody
|
|
|
1852 |
public Map<String, Object> saveContactUs(HttpServletRequest request,
|
|
|
1853 |
@RequestParam(name = "id", defaultValue = "0") int id,
|
|
|
1854 |
@RequestParam(name = "section") String section,
|
|
|
1855 |
@RequestParam(name = "area", defaultValue = "") String area,
|
|
|
1856 |
@RequestParam(name = "baseArea", defaultValue = "") String baseArea,
|
|
|
1857 |
@RequestParam(name = "name", defaultValue = "") String name,
|
|
|
1858 |
@RequestParam(name = "designation", defaultValue = "") String designation,
|
|
|
1859 |
@RequestParam(name = "mobile", defaultValue = "") String mobile,
|
| 37019 |
aman |
1860 |
@RequestParam(name = "email", defaultValue = "") String email,
|
|
|
1861 |
@RequestParam(name = "position", defaultValue = "") String position,
|
|
|
1862 |
@RequestParam(name = "afterId", defaultValue = "0") int afterId) throws Exception {
|
| 36890 |
aman |
1863 |
Map<String, Object> response = new HashMap<>();
|
|
|
1864 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1865 |
if (!isContactUsEditor(loginDetails)) {
|
|
|
1866 |
response.put("success", false);
|
|
|
1867 |
response.put("message", "You are not authorised to edit contacts.");
|
|
|
1868 |
return response;
|
|
|
1869 |
}
|
|
|
1870 |
|
|
|
1871 |
if (!ContactUs.SECTION_MAIN.equals(section) && !ContactUs.SECTION_ESCALATION.equals(section)) {
|
|
|
1872 |
response.put("success", false);
|
|
|
1873 |
response.put("message", "Invalid section.");
|
|
|
1874 |
return response;
|
|
|
1875 |
}
|
|
|
1876 |
if (name == null || name.trim().isEmpty()) {
|
|
|
1877 |
response.put("success", false);
|
|
|
1878 |
response.put("message", "Name is required.");
|
|
|
1879 |
return response;
|
|
|
1880 |
}
|
|
|
1881 |
|
|
|
1882 |
ContactUs contact;
|
|
|
1883 |
if (id > 0) {
|
|
|
1884 |
contact = contactUsRepository.selectById(id);
|
|
|
1885 |
if (contact == null || !contact.isActive()) {
|
|
|
1886 |
response.put("success", false);
|
|
|
1887 |
response.put("message", "Contact not found.");
|
|
|
1888 |
return response;
|
|
|
1889 |
}
|
|
|
1890 |
} else {
|
|
|
1891 |
contact = new ContactUs();
|
|
|
1892 |
contact.setSection(section);
|
|
|
1893 |
contact.setSortOrder(contactUsRepository.maxSortOrder(section) + 10);
|
|
|
1894 |
}
|
|
|
1895 |
contact.setArea(area == null ? "" : area.trim());
|
|
|
1896 |
contact.setBaseArea(baseArea == null ? "" : baseArea.trim());
|
|
|
1897 |
contact.setName(name.trim());
|
|
|
1898 |
contact.setDesignation(designation == null ? "" : designation.trim());
|
|
|
1899 |
contact.setMobile(mobile == null || mobile.trim().isEmpty() ? "-" : mobile.trim());
|
|
|
1900 |
contact.setEmail(email == null ? "" : email.trim());
|
|
|
1901 |
contactUsRepository.persist(contact);
|
|
|
1902 |
|
| 37019 |
aman |
1903 |
// Position control: place the new/edited contact within its section. A NEW contact defaults
|
|
|
1904 |
// to the bottom; an EDIT keeps its place unless the editor explicitly chose a new position.
|
|
|
1905 |
String pos = (position == null || position.trim().isEmpty())
|
|
|
1906 |
? (id > 0 ? "KEEP" : "BOTTOM")
|
|
|
1907 |
: position.trim().toUpperCase();
|
|
|
1908 |
if (!"KEEP".equals(pos)) {
|
|
|
1909 |
repositionInSection(section, contact.getId(), pos, afterId);
|
|
|
1910 |
}
|
|
|
1911 |
|
| 36890 |
aman |
1912 |
response.put("success", true);
|
|
|
1913 |
return response;
|
|
|
1914 |
}
|
|
|
1915 |
|
|
|
1916 |
@RequestMapping(value = "/contactUs/delete", method = RequestMethod.POST)
|
|
|
1917 |
@ResponseBody
|
|
|
1918 |
public Map<String, Object> deleteContactUs(HttpServletRequest request,
|
|
|
1919 |
@RequestParam(name = "id") int id) throws Exception {
|
|
|
1920 |
Map<String, Object> response = new HashMap<>();
|
|
|
1921 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1922 |
if (!isContactUsEditor(loginDetails)) {
|
|
|
1923 |
response.put("success", false);
|
|
|
1924 |
response.put("message", "You are not authorised to edit contacts.");
|
|
|
1925 |
return response;
|
|
|
1926 |
}
|
|
|
1927 |
ContactUs contact = contactUsRepository.selectById(id);
|
|
|
1928 |
if (contact == null) {
|
|
|
1929 |
response.put("success", false);
|
|
|
1930 |
response.put("message", "Contact not found.");
|
|
|
1931 |
return response;
|
|
|
1932 |
}
|
|
|
1933 |
contact.setActive(false);
|
|
|
1934 |
contactUsRepository.persist(contact);
|
|
|
1935 |
response.put("success", true);
|
|
|
1936 |
return response;
|
|
|
1937 |
}
|
|
|
1938 |
|
| 37019 |
aman |
1939 |
@RequestMapping(value = "/contactUs/reorder", method = RequestMethod.POST)
|
|
|
1940 |
@ResponseBody
|
|
|
1941 |
public Map<String, Object> reorderContactUs(HttpServletRequest request,
|
|
|
1942 |
@RequestParam(name = "id") int id,
|
|
|
1943 |
@RequestParam(name = "direction") String direction) throws Exception {
|
|
|
1944 |
Map<String, Object> response = new HashMap<>();
|
|
|
1945 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1946 |
if (!isContactUsEditor(loginDetails)) {
|
|
|
1947 |
response.put("success", false);
|
|
|
1948 |
response.put("message", "You are not authorised to edit contacts.");
|
|
|
1949 |
return response;
|
|
|
1950 |
}
|
|
|
1951 |
ContactUs contact = contactUsRepository.selectById(id);
|
|
|
1952 |
if (contact == null || !contact.isActive()) {
|
|
|
1953 |
response.put("success", false);
|
|
|
1954 |
response.put("message", "Contact not found.");
|
|
|
1955 |
return response;
|
|
|
1956 |
}
|
|
|
1957 |
boolean up = "UP".equalsIgnoreCase(direction);
|
|
|
1958 |
List<ContactUs> list = contactUsRepository.findActiveBySection(contact.getSection());
|
|
|
1959 |
int idx = indexOfContact(list, id);
|
|
|
1960 |
int target = up ? idx - 1 : idx + 1;
|
|
|
1961 |
if (idx < 0 || target < 0 || target >= list.size()) {
|
|
|
1962 |
// Already at the top/bottom edge - nothing to move.
|
|
|
1963 |
response.put("success", true);
|
|
|
1964 |
return response;
|
|
|
1965 |
}
|
|
|
1966 |
ContactUs tmp = list.get(idx);
|
|
|
1967 |
list.set(idx, list.get(target));
|
|
|
1968 |
list.set(target, tmp);
|
|
|
1969 |
renumberSequential(list);
|
|
|
1970 |
response.put("success", true);
|
|
|
1971 |
return response;
|
|
|
1972 |
}
|
|
|
1973 |
|
|
|
1974 |
/**
|
|
|
1975 |
* Places {@code contactId} within its section per {@code position} (TOP | BOTTOM | AFTER) and
|
|
|
1976 |
* renumbers the whole section's sort_order to a clean 10, 20, 30 … sequence, so ordering is
|
|
|
1977 |
* always gap-free and deterministic. {@code afterId} is only consulted for AFTER.
|
|
|
1978 |
*/
|
|
|
1979 |
private void repositionInSection(String section, int contactId, String position, int afterId) {
|
|
|
1980 |
List<ContactUs> list = contactUsRepository.findActiveBySection(section);
|
|
|
1981 |
int movingIdx = indexOfContact(list, contactId);
|
|
|
1982 |
if (movingIdx < 0) {
|
|
|
1983 |
return; // not found (should not happen immediately after persist)
|
|
|
1984 |
}
|
|
|
1985 |
ContactUs moving = list.remove(movingIdx);
|
|
|
1986 |
int index;
|
|
|
1987 |
if ("TOP".equals(position)) {
|
|
|
1988 |
index = 0;
|
|
|
1989 |
} else if ("AFTER".equals(position)) {
|
|
|
1990 |
int anchorIdx = indexOfContact(list, afterId);
|
|
|
1991 |
index = (anchorIdx >= 0) ? anchorIdx + 1 : list.size();
|
|
|
1992 |
} else { // BOTTOM
|
|
|
1993 |
index = list.size();
|
|
|
1994 |
}
|
|
|
1995 |
list.add(index, moving);
|
|
|
1996 |
renumberSequential(list);
|
|
|
1997 |
}
|
|
|
1998 |
|
|
|
1999 |
/** Assigns sort_order 10, 20, 30 … in list order, persisting only rows whose order changed. */
|
|
|
2000 |
private void renumberSequential(List<ContactUs> orderedContacts) {
|
|
|
2001 |
for (int i = 0; i < orderedContacts.size(); i++) {
|
|
|
2002 |
ContactUs c = orderedContacts.get(i);
|
|
|
2003 |
int newOrder = (i + 1) * 10;
|
|
|
2004 |
if (c.getSortOrder() != newOrder) {
|
|
|
2005 |
c.setSortOrder(newOrder);
|
|
|
2006 |
contactUsRepository.persist(c);
|
|
|
2007 |
}
|
|
|
2008 |
}
|
|
|
2009 |
}
|
|
|
2010 |
|
|
|
2011 |
private int indexOfContact(List<ContactUs> list, int id) {
|
|
|
2012 |
for (int i = 0; i < list.size(); i++) {
|
|
|
2013 |
if (list.get(i).getId() == id) {
|
|
|
2014 |
return i;
|
|
|
2015 |
}
|
|
|
2016 |
}
|
|
|
2017 |
return -1;
|
|
|
2018 |
}
|
|
|
2019 |
|
| 31751 |
tejbeer |
2020 |
@RequestMapping(value = "/notifications", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2021 |
public String getNotificationsWithType(HttpServletRequest request, @RequestParam(required = false) MessageType
|
|
|
2022 |
messageType, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
2023 |
@RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
|
| 31751 |
tejbeer |
2024 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2025 |
int userId = 0;
|
|
|
2026 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
2027 |
if (isAdmin) {
|
|
|
2028 |
userId = loginDetails.getFofoId();
|
|
|
2029 |
} else {
|
|
|
2030 |
userId = userAccountRepository.selectUserIdByRetailerId(loginDetails.getFofoId());
|
|
|
2031 |
}
|
|
|
2032 |
List<Notification> notifications = null;
|
| 25683 |
tejbeer |
2033 |
|
| 31751 |
tejbeer |
2034 |
List<NotificationCampaign> notificationCampaigns = notificationCampaignRepository.getNotifications(messageType, userId, offset, limit);
|
| 35943 |
amit |
2035 |
LOGGER.debug("messageType {}", messageType);
|
| 34176 |
tejus.loha |
2036 |
if (messageType != null) {
|
|
|
2037 |
notifications = fofoUser.getNotifications(notificationCampaigns, messageType);
|
| 26086 |
tejbeer |
2038 |
|
| 34176 |
tejus.loha |
2039 |
model.addAttribute("notifications", notifications);
|
| 25683 |
tejbeer |
2040 |
|
| 35943 |
amit |
2041 |
LOGGER.debug("notifications count {}", notifications.size());
|
| 34176 |
tejus.loha |
2042 |
}
|
| 31751 |
tejbeer |
2043 |
return "notification-template";
|
|
|
2044 |
}
|
| 25683 |
tejbeer |
2045 |
|
| 31751 |
tejbeer |
2046 |
@RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2047 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
|
|
2048 |
@RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, @RequestParam int cid) throws
|
|
|
2049 |
ProfitMandiBusinessException {
|
| 31751 |
tejbeer |
2050 |
Document document = documentRepository.selectById(documentId);
|
|
|
2051 |
NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
|
|
|
2052 |
if (nc.getDocumentId() == null) {
|
|
|
2053 |
throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
|
|
|
2054 |
}
|
|
|
2055 |
if (nc.getDocumentId() != documentId) {
|
|
|
2056 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, documentId, "RTLR_1014");
|
|
|
2057 |
}
|
|
|
2058 |
return responseSender.ok(document);
|
|
|
2059 |
}
|
| 25649 |
tejbeer |
2060 |
|
| 32934 |
amit.gupta |
2061 |
@Autowired
|
|
|
2062 |
PsiSmartService psiSmartService;
|
| 34176 |
tejus.loha |
2063 |
|
| 32934 |
amit.gupta |
2064 |
@RequestMapping(value = "/psi/auth-endpoint", method = RequestMethod.GET)
|
| 32935 |
amit.gupta |
2065 |
public ResponseEntity<?> getPartnerPSIUrl(HttpServletRequest request) throws Exception {
|
| 32934 |
amit.gupta |
2066 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2067 |
CustomRetailer customRetailer = retailerService.getAllFofoRetailers().get(loginDetails.getFofoId());
|
|
|
2068 |
return responseSender.ok(psiSmartService.getRegistrationEndPoint(customRetailer.getMobileNumber()));
|
|
|
2069 |
}
|
|
|
2070 |
|
| 31751 |
tejbeer |
2071 |
@RequestMapping(value = "/notifyDocument/download", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2072 |
public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request, @RequestParam int cid, Model model) throws
|
|
|
2073 |
ProfitMandiBusinessException {
|
| 25651 |
tejbeer |
2074 |
|
| 31751 |
tejbeer |
2075 |
NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
|
| 25651 |
tejbeer |
2076 |
|
| 31751 |
tejbeer |
2077 |
if (nc.getDocumentId() == null) {
|
|
|
2078 |
throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
|
|
|
2079 |
}
|
| 25651 |
tejbeer |
2080 |
|
| 31751 |
tejbeer |
2081 |
Document document = documentRepository.selectById(nc.getDocumentId());
|
| 25651 |
tejbeer |
2082 |
|
| 31751 |
tejbeer |
2083 |
FileInputStream file = null;
|
|
|
2084 |
try {
|
|
|
2085 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
|
|
2086 |
} catch (FileNotFoundException e) {
|
|
|
2087 |
LOGGER.error("Retailer Document file not found : ", e);
|
|
|
2088 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
|
|
2089 |
}
|
| 32308 |
amit.gupta |
2090 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
|
|
2091 |
// ByteArrayOutputStream();
|
|
|
2092 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
| 25651 |
tejbeer |
2093 |
|
| 31751 |
tejbeer |
2094 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
2095 |
String contentType = "";
|
|
|
2096 |
if (document.getContentType() == ContentType.JPEG) {
|
|
|
2097 |
contentType = "image/jpeg";
|
|
|
2098 |
} else if (document.getContentType() == ContentType.PNG) {
|
|
|
2099 |
contentType = "image/png";
|
|
|
2100 |
} else if (document.getContentType() == ContentType.PDF) {
|
|
|
2101 |
contentType = "application/pdf";
|
|
|
2102 |
}
|
|
|
2103 |
headers.set("Content-Type", contentType);
|
|
|
2104 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
|
|
2105 |
headers.setContentLength(document.getSize());
|
|
|
2106 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
|
|
2107 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
2108 |
}
|
| 26460 |
amit.gupta |
2109 |
|
| 31751 |
tejbeer |
2110 |
@RequestMapping(value = "/getItemWiseTertiary", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2111 |
public String getItemWiseTertiary(HttpServletRequest request,
|
|
|
2112 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws ProfitMandiBusinessException {
|
| 31751 |
tejbeer |
2113 |
List<ItemWiseTertiaryModel> itemWiseTertiary = fofoOrderRepository.SelectItemWiseTertiary(fofoId);
|
| 27579 |
tejbeer |
2114 |
|
| 31751 |
tejbeer |
2115 |
LOGGER.info("itemWiseTertiary" + itemWiseTertiary);
|
|
|
2116 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2117 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2118 |
model.addAttribute("itemWiseTertiary", itemWiseTertiary);
|
|
|
2119 |
return "item-wise-tertiary";
|
|
|
2120 |
}
|
| 27579 |
tejbeer |
2121 |
|
| 31751 |
tejbeer |
2122 |
@RequestMapping(value = "/getItemWiseIndent", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2123 |
public String getItemWiseIndent(HttpServletRequest request,
|
|
|
2124 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws ProfitMandiBusinessException {
|
| 27586 |
tejbeer |
2125 |
|
| 31751 |
tejbeer |
2126 |
List<Order> unbilledOrders = transactionService.getInTransitOrders(fofoId);
|
|
|
2127 |
model.addAttribute("unbilledOrders", unbilledOrders);
|
| 27586 |
tejbeer |
2128 |
|
| 31751 |
tejbeer |
2129 |
return "item-wise-indent";
|
|
|
2130 |
}
|
| 27586 |
tejbeer |
2131 |
|
| 31751 |
tejbeer |
2132 |
@RequestMapping(value = "/getPartnerInvestment", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2133 |
public String getPartnerInvestment(HttpServletRequest request,
|
|
|
2134 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 31751 |
tejbeer |
2135 |
Map<Integer, PartnerDetailModel> partnerStats = adminUser.getPartnersStatDataFromFile();
|
|
|
2136 |
PartnerDetailModel partnerDetailModel = partnerStats.get(fofoId);
|
|
|
2137 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2138 |
model.addAttribute("partnerDetailModel", partnerDetailModel);
|
|
|
2139 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2140 |
return "partner-investment";
|
|
|
2141 |
}
|
| 27727 |
tejbeer |
2142 |
|
| 31751 |
tejbeer |
2143 |
@RequestMapping(value = "/getPartnerPendingIndentItem", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2144 |
public String getPartnerPendingIndentItem(HttpServletRequest request, @RequestParam int warehouseId,
|
|
|
2145 |
@RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
|
| 31751 |
tejbeer |
2146 |
List<PartnerPendingIndentItemModel> partnerPendingIndent = fofoStoreRepository.selectPartnerPendingIndentItem(itemId, warehouseId);
|
| 27636 |
tejbeer |
2147 |
|
| 31751 |
tejbeer |
2148 |
model.addAttribute("partnerPendingIndent", partnerPendingIndent);
|
|
|
2149 |
return "partner-pending-indent-item";
|
|
|
2150 |
}
|
| 27704 |
amit.gupta |
2151 |
|
| 31751 |
tejbeer |
2152 |
@RequestMapping(value = "/getPatnerActivateStock", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2153 |
public String getPartnerActivateStockItem(HttpServletRequest request,
|
|
|
2154 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 31751 |
tejbeer |
2155 |
List<ActivateItemModel> activateStocks = new ArrayList<>();
|
|
|
2156 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByActivatedNotSold(fofoId);
|
|
|
2157 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| 27636 |
tejbeer |
2158 |
|
| 31751 |
tejbeer |
2159 |
for (InventoryItem inventoryItem : inventoryItems) {
|
|
|
2160 |
TagListing tagListing = tagListingRepository.selectByItemId(inventoryItem.getItemId());
|
|
|
2161 |
Item item = itemRepository.selectById(inventoryItem.getItemId());
|
|
|
2162 |
ActivateItemModel aim = new ActivateItemModel();
|
|
|
2163 |
aim.setFofoId(inventoryItem.getFofoId());
|
|
|
2164 |
aim.setQuantity(inventoryItem.getGoodQuantity());
|
|
|
2165 |
aim.setAmount(tagListing.getSellingPrice());
|
|
|
2166 |
aim.setItemDescription(item.getItemDescription());
|
|
|
2167 |
aim.setItemId(inventoryItem.getItemId());
|
|
|
2168 |
activateStocks.add(aim);
|
|
|
2169 |
}
|
| 27636 |
tejbeer |
2170 |
|
| 31751 |
tejbeer |
2171 |
model.addAttribute("activateStocks", activateStocks);
|
|
|
2172 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2173 |
return "partner-activate-stock";
|
|
|
2174 |
}
|
| 27636 |
tejbeer |
2175 |
|
| 31751 |
tejbeer |
2176 |
@RequestMapping(value = "/getPatnerBrandWiseMTDSale", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2177 |
public String getPatnerBrandWiseMTDSale(HttpServletRequest request,
|
|
|
2178 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 31751 |
tejbeer |
2179 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
2180 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2181 |
Map<String, Double> brandMtdAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
|
|
|
2182 |
Map<String, Long> brandMtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
|
|
|
2183 |
Double accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false)).get(fofoId);
|
|
|
2184 |
Long accesoriesmtdqty = fofoOrderRepository.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false)).get(fofoId);
|
| 27638 |
tejbeer |
2185 |
|
| 31751 |
tejbeer |
2186 |
LOGGER.info("accesoriesmtdsale" + accesoriesmtdsale);
|
|
|
2187 |
model.addAttribute("brandMtdAmount", brandMtdAmount);
|
|
|
2188 |
model.addAttribute("brandMtdQty", brandMtdQty);
|
|
|
2189 |
model.addAttribute("accesoriesmtdsale", accesoriesmtdsale);
|
|
|
2190 |
model.addAttribute("accesoriesmtdqty", accesoriesmtdqty);
|
| 27638 |
tejbeer |
2191 |
|
| 31751 |
tejbeer |
2192 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2193 |
return "partner-brand-mtd-sale";
|
|
|
2194 |
}
|
| 27636 |
tejbeer |
2195 |
|
| 31751 |
tejbeer |
2196 |
@RequestMapping(value = "/getPatnerBrandWiseLMTDSale", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2197 |
public String getPatnerBrandWiseLMTDSale(HttpServletRequest request,
|
|
|
2198 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 31751 |
tejbeer |
2199 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
2200 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2201 |
Map<String, Double> brandLMtdAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
|
|
2202 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
|
|
|
2203 |
Map<String, Long> brandLmtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
|
|
|
2204 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
|
| 27637 |
tejbeer |
2205 |
|
| 31751 |
tejbeer |
2206 |
Double accesorieslmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), Optional.of(false)).get(fofoId);
|
|
|
2207 |
Long accesorieslmtdqty = fofoOrderRepository.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), Optional.of(false)).get(fofoId);
|
| 27638 |
tejbeer |
2208 |
|
| 31751 |
tejbeer |
2209 |
model.addAttribute("brandLMtdAmount", brandLMtdAmount);
|
|
|
2210 |
model.addAttribute("brandLmtdQty", brandLmtdQty);
|
|
|
2211 |
model.addAttribute("accesorieslmtdqty", accesorieslmtdqty);
|
|
|
2212 |
model.addAttribute("accesorieslmtdsale", accesorieslmtdsale);
|
|
|
2213 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2214 |
return "partner-brand-lmtd-sale";
|
|
|
2215 |
}
|
| 27637 |
tejbeer |
2216 |
|
| 31751 |
tejbeer |
2217 |
@RequestMapping(value = "/getPatnerBrandWiseLMSSale", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2218 |
public String getPatnerBrandWiseLMSSale(HttpServletRequest request,
|
|
|
2219 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 31751 |
tejbeer |
2220 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
2221 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2222 |
int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
|
| 27660 |
tejbeer |
2223 |
|
| 31751 |
tejbeer |
2224 |
Map<String, Double> brandLMSAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
|
|
2225 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), fofoId);
|
|
|
2226 |
Map<String, Long> brandLmsQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
|
|
|
2227 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), fofoId);
|
| 27660 |
tejbeer |
2228 |
|
| 31751 |
tejbeer |
2229 |
Double accesorieslmssale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), Optional.of(false)).get(fofoId);
|
|
|
2230 |
Long accesorieslmsqty = fofoOrderRepository.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), Optional.of(false)).get(fofoId);
|
| 27660 |
tejbeer |
2231 |
|
| 31751 |
tejbeer |
2232 |
model.addAttribute("brandLMSAmount", brandLMSAmount);
|
|
|
2233 |
model.addAttribute("brandLmsQty", brandLmsQty);
|
|
|
2234 |
model.addAttribute("accesorieslmssale", accesorieslmssale);
|
|
|
2235 |
model.addAttribute("accesorieslmsqty", accesorieslmsqty);
|
|
|
2236 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2237 |
return "partner-brand-lms-sale";
|
|
|
2238 |
}
|
| 27660 |
tejbeer |
2239 |
|
| 31751 |
tejbeer |
2240 |
@RequestMapping(value = "/getPatnerInStock", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2241 |
public String getPatnerInStock(HttpServletRequest request,
|
|
|
2242 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 27640 |
tejbeer |
2243 |
|
| 31751 |
tejbeer |
2244 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| 27640 |
tejbeer |
2245 |
|
| 31751 |
tejbeer |
2246 |
List<InStockBrandModel> mobileStocks = currentInventorySnapshotRepository.selectSumInStockMobileGroupByBrand(fofoId);
|
|
|
2247 |
List<InStockBrandModel> accesStock = currentInventorySnapshotRepository.selectSumInStockAccessoriesGroupByBrand(fofoId);
|
| 27640 |
tejbeer |
2248 |
|
| 31751 |
tejbeer |
2249 |
List<InStockBrandItemModel> stockItemlist = currentInventorySnapshotRepository.selectInStockItemsByBrand(fofoId);
|
| 27660 |
tejbeer |
2250 |
|
| 31751 |
tejbeer |
2251 |
Map<String, List<InStockBrandItemModel>> stockItemMap = stockItemlist.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
| 27660 |
tejbeer |
2252 |
|
| 31751 |
tejbeer |
2253 |
model.addAttribute("stockItemMap", stockItemMap);
|
|
|
2254 |
model.addAttribute("mobileStock", mobileStocks);
|
|
|
2255 |
model.addAttribute("accesStock", accesStock);
|
|
|
2256 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2257 |
return "partner-instock-item";
|
|
|
2258 |
}
|
| 27640 |
tejbeer |
2259 |
|
| 31751 |
tejbeer |
2260 |
@RequestMapping(value = "/getOpenTicketByFofoId", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2261 |
public String getOpenTicketByFofoId(HttpServletRequest request,
|
|
|
2262 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 31751 |
tejbeer |
2263 |
Map<Integer, AuthUser> ticketIdAuthUser = new HashMap<>();
|
|
|
2264 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2265 |
List<Integer> ticketIds = ticketRepository.selectAllOpenTicketByRetailer(fofoId).stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
2266 |
List<TicketAssigned> ticketAssigns = ticketAssignedRepository.selectByTicketIds(ticketIds);
|
| 27660 |
tejbeer |
2267 |
|
| 35395 |
amit |
2268 |
if (!ticketAssigns.isEmpty()) {
|
|
|
2269 |
// Batch fetch AuthUsers to avoid N+1 queries
|
|
|
2270 |
Set<Integer> assigneeIds = ticketAssigns.stream()
|
|
|
2271 |
.map(TicketAssigned::getAssineeId)
|
|
|
2272 |
.collect(Collectors.toSet());
|
|
|
2273 |
|
|
|
2274 |
Map<Integer, AuthUser> authUserMap = authRepository.selectByIds(new ArrayList<>(assigneeIds)).stream()
|
|
|
2275 |
.collect(Collectors.toMap(AuthUser::getId, au -> au));
|
|
|
2276 |
|
|
|
2277 |
for (TicketAssigned ticketAssign : ticketAssigns) {
|
|
|
2278 |
AuthUser authUser = authUserMap.get(ticketAssign.getAssineeId());
|
|
|
2279 |
if (authUser != null) {
|
|
|
2280 |
ticketIdAuthUser.put(ticketAssign.getTicketId(), authUser);
|
|
|
2281 |
}
|
|
|
2282 |
}
|
| 31751 |
tejbeer |
2283 |
}
|
|
|
2284 |
model.addAttribute("ticketIdAuthUser", ticketIdAuthUser);
|
|
|
2285 |
model.addAttribute("ticketAssigns", ticketAssigns);
|
|
|
2286 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2287 |
return "open-ticket";
|
|
|
2288 |
}
|
| 27660 |
tejbeer |
2289 |
|
| 31751 |
tejbeer |
2290 |
@RequestMapping(value = "/getPartnerSecondarySale", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2291 |
public String getPartnerSecondarySale(HttpServletRequest request,
|
|
|
2292 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, @RequestParam String timeValue, Model model) throws
|
|
|
2293 |
Exception {
|
| 31751 |
tejbeer |
2294 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
2295 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2296 |
int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
|
|
|
2297 |
LocalDateTime startDate = null;
|
|
|
2298 |
LocalDateTime endDate = null;
|
|
|
2299 |
List<InStockBrandModel> secondarySale = null;
|
|
|
2300 |
Map<String, List<InStockBrandItemModel>> secondaryItemSale = null;
|
| 27893 |
tejbeer |
2301 |
|
| 31751 |
tejbeer |
2302 |
if (timeValue.equals("mtd")) {
|
|
|
2303 |
startDate = curDate.withDayOfMonth(1);
|
|
|
2304 |
endDate = curDate.with(LocalTime.MAX);
|
|
|
2305 |
secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
|
|
|
2306 |
secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId).stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
|
|
2307 |
LOGGER.info("secondarySalemtd" + secondarySale);
|
|
|
2308 |
} else if (timeValue.equals("lmtd")) {
|
|
|
2309 |
startDate = curDate.withDayOfMonth(1).minusMonths(1);
|
|
|
2310 |
endDate = curDate.with(LocalTime.MAX).minusMonths(1);
|
|
|
2311 |
secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId).stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
| 27893 |
tejbeer |
2312 |
|
| 31751 |
tejbeer |
2313 |
secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
|
|
|
2314 |
LOGGER.info("secondarySalelmtd" + secondarySale);
|
| 27893 |
tejbeer |
2315 |
|
| 31751 |
tejbeer |
2316 |
} else {
|
|
|
2317 |
startDate = curDate.withDayOfMonth(1).minusMonths(1);
|
|
|
2318 |
endDate = curDate.withDayOfMonth(1);
|
|
|
2319 |
secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId).stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
| 27893 |
tejbeer |
2320 |
|
| 31751 |
tejbeer |
2321 |
secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
|
|
|
2322 |
LOGGER.info("secondarySalelms" + secondarySale);
|
| 27893 |
tejbeer |
2323 |
|
| 31751 |
tejbeer |
2324 |
}
|
| 27893 |
tejbeer |
2325 |
|
| 31751 |
tejbeer |
2326 |
LOGGER.info("secondarySale" + secondarySale);
|
|
|
2327 |
model.addAttribute("secondarySale", secondarySale);
|
|
|
2328 |
model.addAttribute("secondaryItemSale", secondaryItemSale);
|
|
|
2329 |
model.addAttribute("customRetailer", customRetailer);
|
| 27893 |
tejbeer |
2330 |
|
| 31751 |
tejbeer |
2331 |
return "partner-secondary-order";
|
|
|
2332 |
}
|
| 27893 |
tejbeer |
2333 |
|
| 31751 |
tejbeer |
2334 |
@RequestMapping(value = "/getMobileBrandWise", method = RequestMethod.GET)
|
|
|
2335 |
public String getMobileBrandWise(HttpServletRequest request, Model model) throws Exception {
|
|
|
2336 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2337 |
String email = loginDetails.getEmailId();
|
| 28451 |
tejbeer |
2338 |
|
| 31751 |
tejbeer |
2339 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
2340 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
| 28451 |
tejbeer |
2341 |
|
| 31751 |
tejbeer |
2342 |
Map<String, BrandWisePartnerSaleModel> partnersBrandSaleMap = null;
|
|
|
2343 |
partnersBrandSaleMap = fofoStoreRepository.selectGroupByBrandWarehousePartnerSale(new ArrayList<>(fofoIds)).stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x));
|
| 28451 |
tejbeer |
2344 |
|
| 31751 |
tejbeer |
2345 |
List<BrandWiseUnbilledActivateStockModel> unbilledActivatedStock = fofoStoreRepository.selectUnbilledActivateStockGroupByBrand(new ArrayList<>(fofoIds));
|
|
|
2346 |
for (BrandWiseUnbilledActivateStockModel un : unbilledActivatedStock) {
|
|
|
2347 |
BrandWisePartnerSaleModel bpt = partnersBrandSaleMap.get(un.getBrand());
|
|
|
2348 |
if (bpt != null) {
|
|
|
2349 |
bpt.setAmtd(un.getUnbilledMtd());
|
|
|
2350 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
|
|
2351 |
} else {
|
|
|
2352 |
bpt = new BrandWisePartnerSaleModel();
|
|
|
2353 |
bpt.setBrand(un.getBrand());
|
|
|
2354 |
bpt.setAmtd(un.getUnbilledMtd());
|
|
|
2355 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
|
|
2356 |
bpt.setLms(0);
|
|
|
2357 |
bpt.setLmtd(0);
|
|
|
2358 |
bpt.setMtd(0);
|
|
|
2359 |
bpt.setMtdQty(0);
|
|
|
2360 |
bpt.setLmtd(0);
|
|
|
2361 |
bpt.setLmtdQty(0);
|
|
|
2362 |
partnersBrandSaleMap.put(un.getBrand(), bpt);
|
|
|
2363 |
}
|
|
|
2364 |
}
|
| 28451 |
tejbeer |
2365 |
|
| 31751 |
tejbeer |
2366 |
model.addAttribute("brandSalesMap", partnersBrandSaleMap);
|
| 28451 |
tejbeer |
2367 |
|
| 31751 |
tejbeer |
2368 |
return "mobile-brand-wise-report";
|
|
|
2369 |
}
|
| 28451 |
tejbeer |
2370 |
|
| 31751 |
tejbeer |
2371 |
@RequestMapping(value = "/getAccessoriesBrandWise", method = RequestMethod.GET)
|
|
|
2372 |
public String getAccessoriesBrandWise(HttpServletRequest request, Model model) throws Exception {
|
|
|
2373 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2374 |
String email = loginDetails.getEmailId();
|
| 28451 |
tejbeer |
2375 |
|
| 31751 |
tejbeer |
2376 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
| 28451 |
tejbeer |
2377 |
|
| 31751 |
tejbeer |
2378 |
List<BrandWisePartnerSaleModel> accessoriesBrandSales = null;
|
| 28451 |
tejbeer |
2379 |
|
| 31751 |
tejbeer |
2380 |
accessoriesBrandSales = fofoStoreRepository.selectGroupByBrandAccesoriesWarehousePartnerSale(new ArrayList<>(fofoIds));
|
| 28451 |
tejbeer |
2381 |
|
| 31751 |
tejbeer |
2382 |
model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
|
|
|
2383 |
return "accessories-brand-wise-report";
|
|
|
2384 |
}
|
| 28451 |
tejbeer |
2385 |
|
| 34973 |
aman |
2386 |
@PostMapping("/getMobileLMSGraph")
|
|
|
2387 |
public String getMobileLMSGraph(@RequestBody LMSGraphRequest lmsGraphRequest, Model model) throws Exception {
|
|
|
2388 |
LocalDate startDate = lmsGraphRequest.getDate().toLocalDate();
|
|
|
2389 |
LocalDate endLocalDate = lmsGraphRequest.getEndDate().toLocalDate();
|
| 28451 |
tejbeer |
2390 |
|
| 34973 |
aman |
2391 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository.selectActivePartnersByRetailerIds(lmsGraphRequest.getFofoIds())
|
|
|
2392 |
.stream()
|
|
|
2393 |
.collect(Collectors.groupingBy(FofoStore::getWarehouseId,
|
|
|
2394 |
Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
2395 |
|
| 31751 |
tejbeer |
2396 |
ChartModel cm;
|
| 34973 |
aman |
2397 |
if (lmsGraphRequest.getWarehouseId() != 0) {
|
|
|
2398 |
cm = adminUser.getBrandWiseLms(
|
|
|
2399 |
Arrays.asList(lmsGraphRequest.getWarehouseId()),
|
|
|
2400 |
lmsGraphRequest.getFofoIds(),
|
|
|
2401 |
startDate,
|
|
|
2402 |
endLocalDate,
|
|
|
2403 |
lmsGraphRequest.getFilterType()
|
|
|
2404 |
);
|
| 31751 |
tejbeer |
2405 |
} else {
|
| 34973 |
aman |
2406 |
cm = adminUser.getBrandWiseLms(
|
|
|
2407 |
new ArrayList<>(warehouseIdFofoIdMap.keySet()),
|
|
|
2408 |
lmsGraphRequest.getFofoIds(),
|
|
|
2409 |
startDate,
|
|
|
2410 |
endLocalDate,
|
|
|
2411 |
lmsGraphRequest.getFilterType()
|
|
|
2412 |
);
|
| 31751 |
tejbeer |
2413 |
}
|
| 28451 |
tejbeer |
2414 |
|
| 34973 |
aman |
2415 |
LOGGER.info("chartMap: " + gson.toJson(cm));
|
| 31751 |
tejbeer |
2416 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 34973 |
aman |
2417 |
|
| 31751 |
tejbeer |
2418 |
return "brand-wise-mobile-lms-chart";
|
|
|
2419 |
}
|
| 28451 |
tejbeer |
2420 |
|
| 34973 |
aman |
2421 |
|
| 31751 |
tejbeer |
2422 |
@RequestMapping(value = "/getMobileLMSFilter", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2423 |
public String getMobileLMSFilter(HttpServletRequest request,
|
|
|
2424 |
@RequestParam(required = false, defaultValue = "0") int warehouseId,
|
|
|
2425 |
@RequestParam(required = false) LocalDateTime date, @RequestParam(required = false) LocalDateTime endDate, Model
|
|
|
2426 |
model) throws Exception {
|
| 28461 |
tejbeer |
2427 |
|
| 31751 |
tejbeer |
2428 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2429 |
String email = loginDetails.getEmailId();
|
| 28461 |
tejbeer |
2430 |
|
| 31751 |
tejbeer |
2431 |
if (date == null) {
|
|
|
2432 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 28461 |
tejbeer |
2433 |
|
| 31751 |
tejbeer |
2434 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
|
|
2435 |
date = startOfMonth.toLocalDate().atStartOfDay();
|
|
|
2436 |
}
|
| 28461 |
tejbeer |
2437 |
|
| 31751 |
tejbeer |
2438 |
if (endDate == null) {
|
|
|
2439 |
LocalDateTime curDate = LocalDate.now().atTime(LocalTime.MAX);
|
| 30279 |
tejbeer |
2440 |
|
| 31751 |
tejbeer |
2441 |
endDate = curDate;
|
| 30279 |
tejbeer |
2442 |
|
| 31751 |
tejbeer |
2443 |
}
|
| 30279 |
tejbeer |
2444 |
|
| 31751 |
tejbeer |
2445 |
Map<String, Object> map = adminUser.getFilter(warehouseId, email, date, endDate);
|
|
|
2446 |
model.addAttribute("warehouseId", warehouseId);
|
|
|
2447 |
model.addAllAttributes(map);
|
| 28461 |
tejbeer |
2448 |
|
| 31751 |
tejbeer |
2449 |
return "chart-filter-lms";
|
|
|
2450 |
}
|
| 28461 |
tejbeer |
2451 |
|
| 35514 |
amit |
2452 |
@PostMapping("/getMobileLMPGraph")
|
|
|
2453 |
public String getMobileLMPGraph(@RequestBody LMSGraphRequest lmpGraphRequest, Model model) throws Exception {
|
|
|
2454 |
LocalDate startDate = lmpGraphRequest.getDate().toLocalDate();
|
|
|
2455 |
LocalDate endLocalDate = lmpGraphRequest.getEndDate().toLocalDate();
|
| 28461 |
tejbeer |
2456 |
|
| 35514 |
amit |
2457 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository.selectActivePartnersByRetailerIds(lmpGraphRequest.getFofoIds())
|
|
|
2458 |
.stream()
|
|
|
2459 |
.collect(Collectors.groupingBy(FofoStore::getWarehouseId,
|
|
|
2460 |
Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
2461 |
|
| 31751 |
tejbeer |
2462 |
ChartModel cm;
|
| 35514 |
amit |
2463 |
if (lmpGraphRequest.getWarehouseId() != 0) {
|
|
|
2464 |
cm = adminUser.getBrandWiseLmp(
|
|
|
2465 |
Arrays.asList(lmpGraphRequest.getWarehouseId()),
|
|
|
2466 |
lmpGraphRequest.getFofoIds(),
|
|
|
2467 |
startDate,
|
|
|
2468 |
endLocalDate,
|
|
|
2469 |
lmpGraphRequest.getFilterType()
|
|
|
2470 |
);
|
| 31751 |
tejbeer |
2471 |
} else {
|
| 35514 |
amit |
2472 |
cm = adminUser.getBrandWiseLmp(
|
|
|
2473 |
new ArrayList<>(warehouseIdFofoIdMap.keySet()),
|
|
|
2474 |
lmpGraphRequest.getFofoIds(),
|
|
|
2475 |
startDate,
|
|
|
2476 |
endLocalDate,
|
|
|
2477 |
lmpGraphRequest.getFilterType()
|
|
|
2478 |
);
|
| 31751 |
tejbeer |
2479 |
}
|
| 28461 |
tejbeer |
2480 |
|
| 35514 |
amit |
2481 |
LOGGER.info("chartMap: " + gson.toJson(cm));
|
| 31751 |
tejbeer |
2482 |
model.addAttribute("chartMap", gson.toJson(cm));
|
|
|
2483 |
return "brand-wise-mobile-lmp-chart";
|
|
|
2484 |
}
|
| 28461 |
tejbeer |
2485 |
|
| 31751 |
tejbeer |
2486 |
@RequestMapping(value = "/getSaleCountByMilestone", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2487 |
public String getSaleCountByMilestone(HttpServletRequest request,
|
|
|
2488 |
@RequestParam(required = false, defaultValue = "0") int warehouseId, Model model) throws Exception {
|
| 31259 |
tejbeer |
2489 |
|
| 31751 |
tejbeer |
2490 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2491 |
String email = loginDetails.getEmailId();
|
|
|
2492 |
Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
|
| 31259 |
tejbeer |
2493 |
|
| 31751 |
tejbeer |
2494 |
Set<Integer> fofoIdlist = fofoStoreRepository.selectActiveStores().stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toSet());
|
| 32792 |
shampa |
2495 |
Set<Integer> fofoIds = null;
|
| 34176 |
tejus.loha |
2496 |
if (authFofoIds != null) {
|
| 32792 |
shampa |
2497 |
fofoIds = authFofoIds.stream().filter(x -> fofoIdlist.contains(x)).collect(Collectors.toSet());
|
|
|
2498 |
}
|
| 31267 |
tejbeer |
2499 |
|
| 32792 |
shampa |
2500 |
|
| 31751 |
tejbeer |
2501 |
Map<Integer, Double> last3MonthSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
|
|
2502 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(2), LocalDateTime.now(), 0, false);
|
| 31318 |
tejbeer |
2503 |
|
| 31751 |
tejbeer |
2504 |
if (fofoIds != null && fofoIds.size() > 0) {
|
|
|
2505 |
if (warehouseId != 0) {
|
|
|
2506 |
fofoIds = fofoStoreRepository.selectPartnerByfofoIdAndWarehouse(new ArrayList<>(fofoIds), warehouseId).stream().map(x -> x).collect(Collectors.toSet());
|
|
|
2507 |
}
|
|
|
2508 |
Map<Integer, PartnerDetailModel> partnerStats = adminUser.getPartnersStatDataFromFile();
|
|
|
2509 |
if (partnerStats != null) {
|
|
|
2510 |
List<PartnerDetailModel> partnerDetails = fofoIds.stream().filter(x -> partnerStats.containsKey(x)).map(x -> partnerStats.get(x)).collect(Collectors.toList());
|
|
|
2511 |
Map<Milestone, List<Integer>> avg3Monthlms = new HashMap<>();
|
|
|
2512 |
if (!last3MonthSale.isEmpty()) {
|
|
|
2513 |
int days = 60 + LocalDateTime.now().getDayOfMonth();
|
|
|
2514 |
for (Entry<Integer, Double> last3MonthEntry : last3MonthSale.entrySet()) {
|
|
|
2515 |
if (fofoIds.contains(last3MonthEntry.getKey())) {
|
|
|
2516 |
Double monthSale = last3MonthEntry.getValue();
|
|
|
2517 |
if (monthSale == null) {
|
|
|
2518 |
monthSale = (double) 0;
|
| 31319 |
tejbeer |
2519 |
|
| 31751 |
tejbeer |
2520 |
}
|
|
|
2521 |
double avg3MonthSale = (monthSale / days) * 30;
|
|
|
2522 |
Milestone milestone = Milestone.get((int) avg3MonthSale);
|
| 31318 |
tejbeer |
2523 |
|
| 31751 |
tejbeer |
2524 |
List<Integer> values = null;
|
| 31318 |
tejbeer |
2525 |
|
| 31751 |
tejbeer |
2526 |
if (avg3Monthlms.containsKey(milestone)) {
|
| 31319 |
tejbeer |
2527 |
|
| 31751 |
tejbeer |
2528 |
values = avg3Monthlms.get(milestone);
|
|
|
2529 |
values.add(last3MonthEntry.getKey());
|
|
|
2530 |
avg3Monthlms.put(milestone, values);
|
| 31267 |
tejbeer |
2531 |
|
| 31751 |
tejbeer |
2532 |
} else {
|
|
|
2533 |
values = new ArrayList<>();
|
| 31267 |
tejbeer |
2534 |
|
| 31751 |
tejbeer |
2535 |
values.add(last3MonthEntry.getKey());
|
|
|
2536 |
avg3Monthlms.put(milestone, values);
|
| 31267 |
tejbeer |
2537 |
|
| 31751 |
tejbeer |
2538 |
}
|
|
|
2539 |
}
|
| 31267 |
tejbeer |
2540 |
|
| 31751 |
tejbeer |
2541 |
}
|
| 31263 |
tejbeer |
2542 |
|
| 31751 |
tejbeer |
2543 |
}
|
| 31285 |
tejbeer |
2544 |
|
| 31751 |
tejbeer |
2545 |
if (partnerDetails != null) {
|
| 31318 |
tejbeer |
2546 |
|
| 31751 |
tejbeer |
2547 |
Map<Milestone, List<Integer>> mtdMap = partnerDetails.stream().collect(Collectors.groupingBy(x -> Milestone.get(x.getMtd()), Collectors.mapping(x -> x.getFofoId(), Collectors.toList())));
|
|
|
2548 |
Map<Milestone, List<Integer>> lmtdMap = partnerDetails.stream().collect(Collectors.groupingBy(x -> Milestone.get(x.getLmtd()), Collectors.mapping(x -> x.getFofoId(), Collectors.toList())));
|
| 31260 |
tejbeer |
2549 |
|
| 31751 |
tejbeer |
2550 |
Map<Milestone, List<Integer>> lmsMap = partnerDetails.stream().collect(Collectors.groupingBy(x -> Milestone.get(x.getLms()), Collectors.mapping(x -> x.getFofoId(), Collectors.toList())));
|
| 31259 |
tejbeer |
2551 |
|
| 31751 |
tejbeer |
2552 |
model.addAttribute("mtdMap", mtdMap);
|
|
|
2553 |
model.addAttribute("lmtdMap", lmtdMap);
|
|
|
2554 |
model.addAttribute("avg3Monthlms", avg3Monthlms);
|
|
|
2555 |
model.addAttribute("lmsMap", lmsMap);
|
|
|
2556 |
}
|
| 31267 |
tejbeer |
2557 |
|
| 31751 |
tejbeer |
2558 |
}
|
|
|
2559 |
}
|
| 31273 |
tejbeer |
2560 |
|
| 31751 |
tejbeer |
2561 |
model.addAttribute("warehouseMap", ProfitMandiConstants.WAREHOUSE_MAP);
|
|
|
2562 |
model.addAttribute("warehouseId", warehouseId);
|
|
|
2563 |
model.addAttribute("milestones", Milestone.values());
|
| 31273 |
tejbeer |
2564 |
|
| 31751 |
tejbeer |
2565 |
return "sale-milestone";
|
| 31273 |
tejbeer |
2566 |
|
| 31751 |
tejbeer |
2567 |
}
|
| 31273 |
tejbeer |
2568 |
|
| 31751 |
tejbeer |
2569 |
@RequestMapping(value = "/getPurchaseCountByMileStone", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2570 |
public String getPurchaseCountByMileStone(HttpServletRequest request,
|
|
|
2571 |
@RequestParam(required = false, defaultValue = "0") int warehouseId, Model model) throws Exception {
|
| 31273 |
tejbeer |
2572 |
|
| 31751 |
tejbeer |
2573 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2574 |
String email = loginDetails.getEmailId();
|
| 31320 |
tejbeer |
2575 |
|
| 31751 |
tejbeer |
2576 |
Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
|
| 31320 |
tejbeer |
2577 |
|
| 31751 |
tejbeer |
2578 |
Set<Integer> fofoIdlist = fofoStoreRepository.selectActiveStores().stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toSet());
|
| 32792 |
shampa |
2579 |
Set<Integer> fofoIds = null;
|
| 34176 |
tejus.loha |
2580 |
if (authFofoIds != null) {
|
| 32792 |
shampa |
2581 |
fofoIds = authFofoIds.stream().filter(x -> fofoIdlist.contains(x)).collect(Collectors.toSet());
|
|
|
2582 |
}
|
| 31273 |
tejbeer |
2583 |
|
| 31751 |
tejbeer |
2584 |
Map<Integer, Double> last3MonthS = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
|
|
|
2585 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(2), LocalDateTime.now());
|
| 31320 |
tejbeer |
2586 |
|
| 31751 |
tejbeer |
2587 |
if (fofoIds != null && fofoIds.size() > 0) {
|
|
|
2588 |
if (warehouseId != 0) {
|
|
|
2589 |
fofoIds = fofoStoreRepository.selectPartnerByfofoIdAndWarehouse(new ArrayList<>(fofoIds), warehouseId).stream().map(x -> x).collect(Collectors.toSet());
|
|
|
2590 |
}
|
|
|
2591 |
Map<Integer, PartnerDetailModel> partnerStats = adminUser.getPartnersStatDataFromFile();
|
|
|
2592 |
if (partnerStats != null) {
|
|
|
2593 |
List<PartnerDetailModel> partnerDetails = fofoIds.stream().filter(x -> partnerStats.containsKey(x)).map(x -> partnerStats.get(x)).collect(Collectors.toList());
|
|
|
2594 |
Map<Milestone, List<Integer>> avg3MonthS = new HashMap<>();
|
|
|
2595 |
if (!last3MonthS.isEmpty()) {
|
|
|
2596 |
int days = 60 + LocalDateTime.now().getDayOfMonth();
|
|
|
2597 |
for (Entry<Integer, Double> last3MonthSEntry : last3MonthS.entrySet()) {
|
|
|
2598 |
if (fofoIds.contains(last3MonthSEntry.getKey())) {
|
|
|
2599 |
Double monthSec = last3MonthSEntry.getValue();
|
|
|
2600 |
if (monthSec == null) {
|
|
|
2601 |
monthSec = (double) 0;
|
| 31320 |
tejbeer |
2602 |
|
| 31751 |
tejbeer |
2603 |
}
|
|
|
2604 |
double avg3MonthSale = (monthSec / days) * 30;
|
|
|
2605 |
Milestone milestone = Milestone.get((int) avg3MonthSale);
|
| 31320 |
tejbeer |
2606 |
|
| 31751 |
tejbeer |
2607 |
List<Integer> values = null;
|
|
|
2608 |
if (avg3MonthS.containsKey(milestone)) {
|
|
|
2609 |
values = avg3MonthS.get(milestone);
|
|
|
2610 |
values.add(last3MonthSEntry.getKey());
|
| 31273 |
tejbeer |
2611 |
|
| 31751 |
tejbeer |
2612 |
avg3MonthS.put(milestone, values);
|
|
|
2613 |
} else {
|
| 31273 |
tejbeer |
2614 |
|
| 31751 |
tejbeer |
2615 |
values = new ArrayList<>();
|
| 31273 |
tejbeer |
2616 |
|
| 31751 |
tejbeer |
2617 |
values.add(last3MonthSEntry.getKey());
|
| 31273 |
tejbeer |
2618 |
|
| 31751 |
tejbeer |
2619 |
avg3MonthS.put(milestone, values);
|
| 31273 |
tejbeer |
2620 |
|
| 31751 |
tejbeer |
2621 |
}
|
|
|
2622 |
}
|
| 31273 |
tejbeer |
2623 |
|
| 31751 |
tejbeer |
2624 |
}
|
| 31267 |
tejbeer |
2625 |
|
| 31751 |
tejbeer |
2626 |
}
|
| 31259 |
tejbeer |
2627 |
|
| 31751 |
tejbeer |
2628 |
if (partnerDetails != null) {
|
|
|
2629 |
Map<Milestone, List<Integer>> smtdMap = partnerDetails.stream().collect(Collectors.groupingBy(x -> Milestone.get(x.getSecondarymtd()), Collectors.mapping(x -> x.getFofoId(), Collectors.toList())));
|
|
|
2630 |
Map<Milestone, List<Integer>> slmtdMap = partnerDetails.stream().collect(Collectors.groupingBy(x -> Milestone.get(x.getSecondarylmtd()), Collectors.mapping(x -> x.getFofoId(), Collectors.toList())));
|
|
|
2631 |
Map<Milestone, List<Integer>> lmsMap = partnerDetails.stream().collect(Collectors.groupingBy(x -> Milestone.get(x.getSecondarylms()), Collectors.mapping(x -> x.getFofoId(), Collectors.toList())));
|
| 31259 |
tejbeer |
2632 |
|
| 31751 |
tejbeer |
2633 |
model.addAttribute("smtdMap", smtdMap);
|
|
|
2634 |
model.addAttribute("slmtdMap", slmtdMap);
|
|
|
2635 |
model.addAttribute("avg3MonthS", avg3MonthS);
|
|
|
2636 |
model.addAttribute("lmsMap", lmsMap);
|
| 31259 |
tejbeer |
2637 |
|
| 31751 |
tejbeer |
2638 |
}
|
| 28825 |
tejbeer |
2639 |
|
| 31751 |
tejbeer |
2640 |
}
|
|
|
2641 |
}
|
| 28825 |
tejbeer |
2642 |
|
| 31751 |
tejbeer |
2643 |
model.addAttribute("warehouseMap", ProfitMandiConstants.WAREHOUSE_MAP);
|
|
|
2644 |
model.addAttribute("warehouseId", warehouseId);
|
|
|
2645 |
model.addAttribute("milestones", Milestone.values());
|
| 28825 |
tejbeer |
2646 |
|
| 31751 |
tejbeer |
2647 |
return "purchase-milestone";
|
| 28825 |
tejbeer |
2648 |
|
| 31751 |
tejbeer |
2649 |
}
|
| 31152 |
tejbeer |
2650 |
|
| 31751 |
tejbeer |
2651 |
@RequestMapping(value = "/getActivatedModelWarehouseWise", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2652 |
public String getActivatedModelWarehouseWise(HttpServletRequest request, Model model, @RequestParam String
|
|
|
2653 |
brand) throws Exception {
|
| 31751 |
tejbeer |
2654 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2655 |
List<Integer> fofoIds = getFofoIds(loginDetails);
|
|
|
2656 |
List<WarehouseWiseActivatedModel> warehouseWiseActivatedModels = activatedImeiRepository.selectActivatedModelGroupByWarehouse(brand, fofoIds);
|
|
|
2657 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 28825 |
tejbeer |
2658 |
|
| 31751 |
tejbeer |
2659 |
List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
|
| 28825 |
tejbeer |
2660 |
|
| 31751 |
tejbeer |
2661 |
List<String> brands = mobileBrands.stream().map(x -> (String) x.get("name")).collect(Collectors.toList());
|
|
|
2662 |
LOGGER.info("brands" + brands.add("Redmi"));
|
| 28825 |
tejbeer |
2663 |
|
| 31751 |
tejbeer |
2664 |
model.addAttribute("warehouseWiseActivatedModels", warehouseWiseActivatedModels);
|
|
|
2665 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
2666 |
model.addAttribute("brands", brands);
|
|
|
2667 |
model.addAttribute("selectedbrand", brand);
|
|
|
2668 |
return "warehousewise_activated_model";
|
|
|
2669 |
}
|
| 28825 |
tejbeer |
2670 |
|
| 31751 |
tejbeer |
2671 |
@RequestMapping(value = "/getActivatedModelByBrand", method = RequestMethod.GET)
|
|
|
2672 |
public String getActivatedModelByBrand(HttpServletRequest request, Model model) throws Exception {
|
|
|
2673 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2674 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(loginDetails.getEmailId(), true);
|
| 28825 |
tejbeer |
2675 |
|
| 31751 |
tejbeer |
2676 |
List<BrandWiseActivatedModel> activatedModels = activatedImeiRepository.selectActivatedModelGroupByBrand(new ArrayList<>(fofoIds));
|
|
|
2677 |
model.addAttribute("activatedModels", activatedModels);
|
|
|
2678 |
return "activation-brandwise-report";
|
|
|
2679 |
}
|
| 28825 |
tejbeer |
2680 |
|
| 31751 |
tejbeer |
2681 |
@RequestMapping(value = "/getWarehouseBrandWiseItemActivatedModel", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2682 |
public String getWarehouseBrandWiseItemActivatedModel(HttpServletRequest request, Model
|
|
|
2683 |
model, @RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
| 31751 |
tejbeer |
2684 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2685 |
List<Integer> fofoIds = getFofoIds(loginDetails);
|
| 28825 |
tejbeer |
2686 |
|
| 31751 |
tejbeer |
2687 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
2688 |
List<WarehouseBrandWiseItemActivatedModel> activatedItems = activatedImeiRepository.selectWarehouseBrandActivatedItem(warehouseId, brand, fofoIds);
|
|
|
2689 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
2690 |
model.addAttribute("activatedItems", activatedItems);
|
|
|
2691 |
return "warehouse-activated-itemwise-model";
|
| 28825 |
tejbeer |
2692 |
|
| 31751 |
tejbeer |
2693 |
}
|
| 28825 |
tejbeer |
2694 |
|
| 31751 |
tejbeer |
2695 |
@RequestMapping(value = "/getActivatedImeiUpdationDate", method = RequestMethod.GET)
|
|
|
2696 |
public String getActivatedImeiUpdationDate(HttpServletRequest request, Model model) throws Exception {
|
| 28825 |
tejbeer |
2697 |
|
| 31751 |
tejbeer |
2698 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 35466 |
amit |
2699 |
List<String> brands = ProfitMandiConstants.BRANDS;
|
| 28825 |
tejbeer |
2700 |
|
| 31751 |
tejbeer |
2701 |
List<ActivationImeiUpdationModel> activationImeiUpdations = activatedImeiRepository.selectActivatedUpdationDate();
|
| 35466 |
amit |
2702 |
|
|
|
2703 |
// Create a map for quick lookup of existing results
|
|
|
2704 |
Map<String, ActivationImeiUpdationModel> resultMap = activationImeiUpdations.stream()
|
|
|
2705 |
.collect(Collectors.toMap(
|
|
|
2706 |
m -> m.getWarehouseId() + "_" + m.getBrand(),
|
|
|
2707 |
m -> m
|
|
|
2708 |
));
|
|
|
2709 |
|
|
|
2710 |
// Merge with master data - add missing combinations with null timestamp
|
|
|
2711 |
List<ActivationImeiUpdationModel> completeList = new ArrayList<>();
|
|
|
2712 |
for (Integer warehouseId : warehouseMap.keySet()) {
|
|
|
2713 |
for (String brand : brands) {
|
|
|
2714 |
String key = warehouseId + "_" + brand;
|
|
|
2715 |
ActivationImeiUpdationModel existing = resultMap.get(key);
|
|
|
2716 |
if (existing != null) {
|
|
|
2717 |
completeList.add(existing);
|
|
|
2718 |
} else {
|
|
|
2719 |
completeList.add(new ActivationImeiUpdationModel(warehouseId, brand, null));
|
|
|
2720 |
}
|
|
|
2721 |
}
|
|
|
2722 |
}
|
|
|
2723 |
|
| 31751 |
tejbeer |
2724 |
model.addAttribute("warehouseMap", warehouseMap);
|
| 35466 |
amit |
2725 |
model.addAttribute("activationImeiUpdations", completeList);
|
| 31751 |
tejbeer |
2726 |
return "activation-updation-timestamp";
|
| 28825 |
tejbeer |
2727 |
|
| 31751 |
tejbeer |
2728 |
}
|
| 31285 |
tejbeer |
2729 |
|
| 31751 |
tejbeer |
2730 |
private List<Integer> getFofoIds(LoginDetails loginDetails) throws ProfitMandiBusinessException {
|
|
|
2731 |
String email = loginDetails.getEmailId();
|
| 31287 |
tejbeer |
2732 |
|
| 31751 |
tejbeer |
2733 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
2734 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 31287 |
tejbeer |
2735 |
|
| 31751 |
tejbeer |
2736 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
|
|
2737 |
if (emails.contains(authUser.getEmailId())) {
|
|
|
2738 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
|
|
2739 |
LOGGER.info("fofoIds" + fofoIds);
|
|
|
2740 |
}
|
| 31287 |
tejbeer |
2741 |
|
| 31751 |
tejbeer |
2742 |
if (fofoIds == null) {
|
| 35395 |
amit |
2743 |
List<Position> positions1 = positionRepository.selectAllByAuthUserId(authUser.getId());
|
| 31751 |
tejbeer |
2744 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER).count() > 0) {
|
|
|
2745 |
fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
2746 |
}
|
|
|
2747 |
}
|
|
|
2748 |
return new ArrayList<>(fofoIds);
|
|
|
2749 |
}
|
| 31287 |
tejbeer |
2750 |
|
| 31751 |
tejbeer |
2751 |
@RequestMapping(value = "/getMonthWiseSale", method = RequestMethod.GET)
|
| 32836 |
amit.gupta |
2752 |
public String getPartnerSaleByMonth(HttpServletRequest request, @RequestParam List<Integer> fofoIds, Model
|
|
|
2753 |
model) throws Exception {
|
| 31287 |
tejbeer |
2754 |
|
| 31751 |
tejbeer |
2755 |
YearMonth now = YearMonth.now();
|
|
|
2756 |
YearMonth ym = YearMonth.now().minusMonths(12);
|
|
|
2757 |
List<YearMonth> list = new ArrayList<>();
|
|
|
2758 |
while (!now.isBefore(ym)) {
|
|
|
2759 |
list.add(now);
|
|
|
2760 |
now = now.minusMonths(1);
|
|
|
2761 |
}
|
| 31287 |
tejbeer |
2762 |
|
| 31751 |
tejbeer |
2763 |
model.addAttribute("yearMonth", list);
|
| 31287 |
tejbeer |
2764 |
|
| 31751 |
tejbeer |
2765 |
List<PartnerMonthlySaleModel> partnerMonthlySaleModels = fofoOrderItemRepository.selectPartnerMonthlySale(fofoIds, LocalDateTime.now().minusMonths(12).withDayOfMonth(1));
|
|
|
2766 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
|
|
2767 |
Map<Integer, Map<YearMonth, Double>> partnerMonthSaleMap = new HashMap<>();
|
|
|
2768 |
if (!partnerMonthlySaleModels.isEmpty()) {
|
| 31287 |
tejbeer |
2769 |
|
| 31751 |
tejbeer |
2770 |
partnerMonthSaleMap = partnerMonthlySaleModels.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.toMap(
|
|
|
2771 |
x -> YearMonth.parse(x.getYearMonth(), dateTimeFormatter), x -> (double) x.getAmount())));
|
|
|
2772 |
}
|
| 31297 |
tejbeer |
2773 |
|
| 31751 |
tejbeer |
2774 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers().entrySet().stream().filter(x -> fofoIds.contains(x.getKey())).collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
| 31297 |
tejbeer |
2775 |
|
| 31751 |
tejbeer |
2776 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 31297 |
tejbeer |
2777 |
|
| 31751 |
tejbeer |
2778 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 31297 |
tejbeer |
2779 |
|
| 31751 |
tejbeer |
2780 |
model.addAttribute("partnerMonthSaleMap", partnerMonthSaleMap);
|
|
|
2781 |
return "monthly-partner-sale";
|
| 31297 |
tejbeer |
2782 |
|
| 31751 |
tejbeer |
2783 |
}
|
| 31297 |
tejbeer |
2784 |
|
| 35541 |
amit |
2785 |
@RequestMapping(value = "/getMonthWisePurchase", method = RequestMethod.POST)
|
| 35543 |
amit |
2786 |
public String getMonthWisePurchase(HttpServletRequest request, @RequestBody List<Integer> fofoIds, Model
|
| 32836 |
amit.gupta |
2787 |
model) throws Exception {
|
| 31751 |
tejbeer |
2788 |
|
|
|
2789 |
YearMonth now = YearMonth.now();
|
|
|
2790 |
YearMonth ym = YearMonth.now().minusMonths(12);
|
|
|
2791 |
List<YearMonth> list = new ArrayList<>();
|
|
|
2792 |
while (!now.isBefore(ym)) {
|
|
|
2793 |
list.add(now);
|
|
|
2794 |
now = now.minusMonths(1);
|
|
|
2795 |
}
|
|
|
2796 |
|
|
|
2797 |
model.addAttribute("yearMonth", list);
|
|
|
2798 |
|
|
|
2799 |
List<PartnerMonthlySaleModel> partnerMonthlySaleModels = orderRepository.selectSecondaryGroupByYearMonth(
|
| 32445 |
amit.gupta |
2800 |
fofoIds, LocalDate.now().withDayOfMonth(1).atStartOfDay().minusMonths(12), LocalDateTime.now());
|
| 31751 |
tejbeer |
2801 |
Map<Integer, Map<YearMonth, Double>> partnerMonthPurchaseMap = partnerMonthlySaleModels.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.groupingBy(
|
|
|
2802 |
y -> YearMonth.parse(y.getYearMonth(), DateTimeFormatter.ofPattern("MM-yyyy")), Collectors.summingDouble(x -> x.getAmount()))));
|
|
|
2803 |
|
|
|
2804 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers().entrySet().stream().filter(x -> fofoIds.contains(x.getKey())).collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
|
|
2805 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
|
|
2806 |
model.addAttribute("partnerMonthPurchaseMap", partnerMonthPurchaseMap);
|
|
|
2807 |
return "monthly-partner-purchase";
|
|
|
2808 |
|
|
|
2809 |
}
|
| 32407 |
amit.gupta |
2810 |
|
| 32336 |
jai.hind |
2811 |
@GetMapping("/restartServer")
|
| 32407 |
amit.gupta |
2812 |
public String RestartServer(HttpServletRequest request, Model model) throws Exception {
|
|
|
2813 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2814 |
if (Arrays.asList("amit.gupta@smartdukaan.com", "shivam.gupta@smartdukaan.com", "vinay.p@smartdukaan.com").contains(loginDetails.getEmailId())) {
|
|
|
2815 |
String ipAddress = "45.79.106.95";
|
|
|
2816 |
int port = 22;
|
|
|
2817 |
String username = "root";
|
|
|
2818 |
String password = "spic@2015shop2020";
|
| 32408 |
amit.gupta |
2819 |
String restartServices = "./restart-services.sh";
|
|
|
2820 |
sshService.executeCommand(ipAddress, port, username, password, restartServices);
|
| 32407 |
amit.gupta |
2821 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
2822 |
} else {
|
|
|
2823 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
|
|
2824 |
}
|
| 32337 |
jai.hind |
2825 |
return "response";
|
|
|
2826 |
}
|
| 32336 |
jai.hind |
2827 |
|
| 32337 |
jai.hind |
2828 |
@GetMapping("/rebootServer")
|
| 32407 |
amit.gupta |
2829 |
public String rebootServer(HttpServletRequest request, Model model) throws Exception {
|
|
|
2830 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
2831 |
if (Arrays.asList("amit.gupta@smartdukaan.com", "shivam.gupta@smartdukaan.com", "vinay.p@smartdukaan.com").contains(loginDetails.getEmailId())) {
|
|
|
2832 |
String ipAddress = "45.79.106.95";
|
|
|
2833 |
int port = 22;
|
|
|
2834 |
String username = "root";
|
|
|
2835 |
String password = "spic@2015shop2020";
|
|
|
2836 |
String rebootCommand = "reboot";
|
| 32337 |
jai.hind |
2837 |
|
| 32408 |
amit.gupta |
2838 |
sshService.executeCommand(ipAddress, port, username, password, rebootCommand);
|
| 32407 |
amit.gupta |
2839 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
2840 |
} else {
|
|
|
2841 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
|
|
2842 |
}
|
| 32336 |
jai.hind |
2843 |
return "response";
|
|
|
2844 |
}
|
| 32407 |
amit.gupta |
2845 |
|
| 32336 |
jai.hind |
2846 |
@GetMapping("/getRestartServer")
|
| 32407 |
amit.gupta |
2847 |
public String getRestartServer(HttpServletRequest request, Model model) {
|
|
|
2848 |
return "restart-server-page";
|
| 32336 |
jai.hind |
2849 |
}
|
| 21615 |
kshitij.so |
2850 |
}
|