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