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