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