| 21615 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 25651 |
tejbeer |
3 |
import java.io.File;
|
|
|
4 |
import java.io.FileInputStream;
|
|
|
5 |
import java.io.FileNotFoundException;
|
| 27628 |
tejbeer |
6 |
import java.io.FileOutputStream;
|
|
|
7 |
import java.io.ObjectInputStream;
|
|
|
8 |
import java.io.ObjectOutputStream;
|
| 24288 |
amit.gupta |
9 |
import java.time.LocalDate;
|
| 24276 |
amit.gupta |
10 |
import java.time.LocalDateTime;
|
| 24880 |
govind |
11 |
import java.time.LocalTime;
|
| 28272 |
tejbeer |
12 |
import java.time.Month;
|
| 27555 |
tejbeer |
13 |
import java.time.YearMonth;
|
| 25649 |
tejbeer |
14 |
import java.time.ZoneOffset;
|
| 27474 |
tejbeer |
15 |
import java.time.format.DateTimeFormatter;
|
| 24339 |
amit.gupta |
16 |
import java.util.ArrayList;
|
| 26027 |
amit.gupta |
17 |
import java.util.Arrays;
|
| 28430 |
tejbeer |
18 |
import java.util.Collection;
|
| 27701 |
tejbeer |
19 |
import java.util.Comparator;
|
| 26011 |
amit.gupta |
20 |
import java.util.HashMap;
|
| 26090 |
amit.gupta |
21 |
import java.util.HashSet;
|
| 25136 |
amit.gupta |
22 |
import java.util.LinkedHashMap;
|
| 28430 |
tejbeer |
23 |
import java.util.LinkedHashSet;
|
| 23884 |
amit.gupta |
24 |
import java.util.List;
|
| 24880 |
govind |
25 |
import java.util.Map;
|
| 26055 |
tejbeer |
26 |
import java.util.Map.Entry;
|
| 26071 |
tejbeer |
27 |
import java.util.Optional;
|
| 26090 |
amit.gupta |
28 |
import java.util.Set;
|
| 28430 |
tejbeer |
29 |
import java.util.TreeMap;
|
| 24880 |
govind |
30 |
import java.util.stream.Collectors;
|
| 23568 |
govind |
31 |
|
| 22086 |
amit.gupta |
32 |
import javax.servlet.http.HttpServletRequest;
|
| 25221 |
amit.gupta |
33 |
import javax.transaction.Transactional;
|
| 22086 |
amit.gupta |
34 |
|
| 28435 |
tejbeer |
35 |
import org.apache.commons.collections4.OrderedMap;
|
| 23786 |
amit.gupta |
36 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
37 |
import org.apache.logging.log4j.Logger;
|
| 28430 |
tejbeer |
38 |
import org.bouncycastle.crypto.tls.HashAlgorithm;
|
| 26158 |
amit.gupta |
39 |
import org.json.JSONObject;
|
| 22481 |
ashik.ali |
40 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23379 |
ashik.ali |
41 |
import org.springframework.beans.factory.annotation.Value;
|
| 25651 |
tejbeer |
42 |
import org.springframework.core.io.InputStreamResource;
|
|
|
43 |
import org.springframework.http.HttpHeaders;
|
|
|
44 |
import org.springframework.http.HttpStatus;
|
| 25649 |
tejbeer |
45 |
import org.springframework.http.ResponseEntity;
|
| 21615 |
kshitij.so |
46 |
import org.springframework.stereotype.Controller;
|
| 22073 |
ashik.ali |
47 |
import org.springframework.ui.Model;
|
| 21615 |
kshitij.so |
48 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
49 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 25649 |
tejbeer |
50 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21615 |
kshitij.so |
51 |
|
| 28430 |
tejbeer |
52 |
import com.google.common.collect.ArrayListMultimap;
|
|
|
53 |
import com.google.common.collect.Multimap;
|
| 25649 |
tejbeer |
54 |
import com.google.gson.Gson;
|
| 25677 |
amit.gupta |
55 |
import com.mongodb.DBObject;
|
| 25651 |
tejbeer |
56 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| 25683 |
tejbeer |
57 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 26065 |
amit.gupta |
58 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
| 22481 |
ashik.ali |
59 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 27636 |
tejbeer |
60 |
import com.spice.profitmandi.common.model.ActivateItemModel;
|
| 27884 |
tejbeer |
61 |
import com.spice.profitmandi.common.model.Axis;
|
| 25677 |
amit.gupta |
62 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
| 27884 |
tejbeer |
63 |
import com.spice.profitmandi.common.model.ChartInvestmentModel;
|
| 26055 |
tejbeer |
64 |
import com.spice.profitmandi.common.model.ChartModel;
|
| 26005 |
amit.gupta |
65 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 27884 |
tejbeer |
66 |
import com.spice.profitmandi.common.model.Data;
|
|
|
67 |
import com.spice.profitmandi.common.model.DataInvestmentModel;
|
| 26055 |
tejbeer |
68 |
import com.spice.profitmandi.common.model.DataModel;
|
| 28430 |
tejbeer |
69 |
|
| 26055 |
tejbeer |
70 |
import com.spice.profitmandi.common.model.DatasetModel;
|
| 28434 |
tejbeer |
71 |
import com.spice.profitmandi.common.model.HoverModel;
|
| 27884 |
tejbeer |
72 |
import com.spice.profitmandi.common.model.Legend;
|
| 26055 |
tejbeer |
73 |
import com.spice.profitmandi.common.model.LegendModel;
|
| 25649 |
tejbeer |
74 |
import com.spice.profitmandi.common.model.Notification;
|
| 28409 |
tejbeer |
75 |
import com.spice.profitmandi.common.model.OnlineDeliveredOrderSum;
|
| 27884 |
tejbeer |
76 |
import com.spice.profitmandi.common.model.OptionModel;
|
| 26055 |
tejbeer |
77 |
import com.spice.profitmandi.common.model.OptionsModel;
|
| 27884 |
tejbeer |
78 |
import com.spice.profitmandi.common.model.PieLables;
|
| 28430 |
tejbeer |
79 |
import com.spice.profitmandi.common.model.PluginsModel;
|
| 24203 |
amit.gupta |
80 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 27884 |
tejbeer |
81 |
import com.spice.profitmandi.common.model.ScalesModel;
|
| 26055 |
tejbeer |
82 |
import com.spice.profitmandi.common.model.TitleModel;
|
| 28434 |
tejbeer |
83 |
import com.spice.profitmandi.common.model.Tooltips;
|
| 25651 |
tejbeer |
84 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 25649 |
tejbeer |
85 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
| 26011 |
amit.gupta |
86 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
|
|
87 |
import com.spice.profitmandi.dao.entity.auth.Menu;
|
| 27355 |
tejbeer |
88 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 27636 |
tejbeer |
89 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 26011 |
amit.gupta |
90 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 27660 |
tejbeer |
91 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
| 25651 |
tejbeer |
92 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 25649 |
tejbeer |
93 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| 22654 |
ashik.ali |
94 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 27636 |
tejbeer |
95 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 24288 |
amit.gupta |
96 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 25214 |
amit.gupta |
97 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 25566 |
tejbeer |
98 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 28409 |
tejbeer |
99 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
|
|
|
100 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
|
| 27529 |
tejbeer |
101 |
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
|
| 27586 |
tejbeer |
102 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 26418 |
tejbeer |
103 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| 26024 |
amit.gupta |
104 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 26418 |
tejbeer |
105 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
| 28409 |
tejbeer |
106 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 27628 |
tejbeer |
107 |
import com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel;
|
| 27670 |
tejbeer |
108 |
import com.spice.profitmandi.dao.model.BrandWiseUnbilledActivateStockModel;
|
| 26674 |
tejbeer |
109 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| 27660 |
tejbeer |
110 |
import com.spice.profitmandi.dao.model.InStockBrandItemModel;
|
| 27640 |
tejbeer |
111 |
import com.spice.profitmandi.dao.model.InStockBrandModel;
|
| 27579 |
tejbeer |
112 |
import com.spice.profitmandi.dao.model.ItemWiseTertiaryModel;
|
| 27474 |
tejbeer |
113 |
import com.spice.profitmandi.dao.model.MonthSaleModel;
|
| 26418 |
tejbeer |
114 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
| 27599 |
tejbeer |
115 |
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
|
| 28439 |
tejbeer |
116 |
import com.spice.profitmandi.dao.model.SecondaryOrderBilledLmsModel;
|
| 25649 |
tejbeer |
117 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
|
|
118 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 27670 |
tejbeer |
119 |
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
|
| 27556 |
tejbeer |
120 |
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel;
|
| 27628 |
tejbeer |
121 |
import com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel;
|
| 27591 |
tejbeer |
122 |
import com.spice.profitmandi.dao.model.WarehouseWiseBrandStockModel;
|
| 27670 |
tejbeer |
123 |
import com.spice.profitmandi.dao.model.WarehouseWiseBrandUnbilledActivatedModel;
|
| 27509 |
tejbeer |
124 |
import com.spice.profitmandi.dao.model.WarehouseWiseStockModel;
|
|
|
125 |
import com.spice.profitmandi.dao.model.WarehouseWiseitemStockModel;
|
| 25976 |
amit.gupta |
126 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 26011 |
amit.gupta |
127 |
import com.spice.profitmandi.dao.repository.auth.MenuCategoryRepository;
|
|
|
128 |
import com.spice.profitmandi.dao.repository.auth.MenuRepository;
|
| 27355 |
tejbeer |
129 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 26588 |
tejbeer |
130 |
import com.spice.profitmandi.dao.repository.catalog.OfferMarginRepository;
|
|
|
131 |
import com.spice.profitmandi.dao.repository.catalog.OfferPartnerRepository;
|
|
|
132 |
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
|
| 27632 |
tejbeer |
133 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 26090 |
amit.gupta |
134 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 26418 |
tejbeer |
135 |
import com.spice.profitmandi.dao.repository.cs.PartnersPositionRepository;
|
| 26011 |
amit.gupta |
136 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 27660 |
tejbeer |
137 |
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
|
| 26011 |
amit.gupta |
138 |
import com.spice.profitmandi.dao.repository.cs.TicketCategoryRepository;
|
| 26418 |
tejbeer |
139 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 25651 |
tejbeer |
140 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 22481 |
ashik.ali |
141 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 26418 |
tejbeer |
142 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 24996 |
amit.gupta |
143 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 25649 |
tejbeer |
144 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
|
|
145 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
|
|
146 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
| 24203 |
amit.gupta |
147 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24880 |
govind |
148 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 26071 |
tejbeer |
149 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 25649 |
tejbeer |
150 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| 26234 |
amit.gupta |
151 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 24288 |
amit.gupta |
152 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 25214 |
amit.gupta |
153 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| 27474 |
tejbeer |
154 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
| 25566 |
tejbeer |
155 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 28409 |
tejbeer |
156 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
|
|
|
157 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
|
| 27529 |
tejbeer |
158 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
|
|
159 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| 27509 |
tejbeer |
160 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventorySnapshotRepository;
|
| 27893 |
tejbeer |
161 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 24336 |
amit.gupta |
162 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 26460 |
amit.gupta |
163 |
import com.spice.profitmandi.service.PartnerStatsService;
|
| 23844 |
amit.gupta |
164 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 25677 |
amit.gupta |
165 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 27876 |
amit.gupta |
166 |
import com.spice.profitmandi.service.offers.OfferService;
|
| 27586 |
tejbeer |
167 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 26005 |
amit.gupta |
168 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 22481 |
ashik.ali |
169 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
170 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 27529 |
tejbeer |
171 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22481 |
ashik.ali |
172 |
|
| 21615 |
kshitij.so |
173 |
@Controller
|
| 25222 |
amit.gupta |
174 |
@Transactional(rollbackOn = Throwable.class)
|
| 21615 |
kshitij.so |
175 |
public class DashboardController {
|
| 23923 |
amit.gupta |
176 |
|
| 26460 |
amit.gupta |
177 |
private static final double ONE_LAC = 1 * 1000 * 100;
|
|
|
178 |
private static final double TWO_LAC = 2 * 1000 * 100;
|
|
|
179 |
private static final double FOUR_LAC = 4 * 1000 * 100;
|
|
|
180 |
|
| 27727 |
tejbeer |
181 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com",
|
| 27778 |
tejbeer |
182 |
"niranjan.kala@smartdukaan.com", "hemant.kaura@smartdukaan.com", "amit.gupta@shop2020.in",
|
|
|
183 |
"tejbeer.kaur@shop2020.in");
|
| 27727 |
tejbeer |
184 |
|
| 23379 |
ashik.ali |
185 |
@Value("${web.api.host}")
|
|
|
186 |
private String webApiHost;
|
| 23923 |
amit.gupta |
187 |
|
| 24072 |
amit.gupta |
188 |
@Value("${web.api.scheme}")
|
|
|
189 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
190 |
|
| 24078 |
amit.gupta |
191 |
@Value("${web.api.root}")
|
|
|
192 |
private String webApiRoot;
|
|
|
193 |
|
| 23379 |
ashik.ali |
194 |
@Value("${web.api.port}")
|
|
|
195 |
private int webApiPort;
|
| 28430 |
tejbeer |
196 |
|
| 22481 |
ashik.ali |
197 |
@Autowired
|
| 22927 |
ashik.ali |
198 |
private CookiesProcessor cookiesProcessor;
|
| 26468 |
amit.gupta |
199 |
|
| 26460 |
amit.gupta |
200 |
@Autowired
|
| 28409 |
tejbeer |
201 |
private PendingOrderRepository pendingOrderRepository;
|
|
|
202 |
|
|
|
203 |
@Autowired
|
| 26460 |
amit.gupta |
204 |
private PartnerStatsService partnerStatsService;
|
| 23923 |
amit.gupta |
205 |
|
| 23568 |
govind |
206 |
@Autowired
|
| 26011 |
amit.gupta |
207 |
private MenuRepository menuRepository;
|
| 26012 |
amit.gupta |
208 |
|
| 26011 |
amit.gupta |
209 |
@Autowired
|
|
|
210 |
private MenuCategoryRepository menuCategoryRepository;
|
|
|
211 |
|
|
|
212 |
@Autowired
|
| 26090 |
amit.gupta |
213 |
private CsService csService;
|
|
|
214 |
|
|
|
215 |
@Autowired
|
| 25214 |
amit.gupta |
216 |
private PartnerTargetRepository partnerTargetRepository;
|
|
|
217 |
|
|
|
218 |
@Autowired
|
| 25653 |
amit.gupta |
219 |
private ResponseSender<?> responseSender;
|
| 26012 |
amit.gupta |
220 |
|
| 26005 |
amit.gupta |
221 |
@Autowired
|
|
|
222 |
RetailerService retailerService;
|
| 25214 |
amit.gupta |
223 |
|
|
|
224 |
@Autowired
|
| 23786 |
amit.gupta |
225 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
226 |
|
| 23838 |
ashik.ali |
227 |
@Autowired
|
|
|
228 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
229 |
|
|
|
230 |
@Autowired
|
| 24880 |
govind |
231 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 23923 |
amit.gupta |
232 |
|
| 23884 |
amit.gupta |
233 |
@Autowired
|
| 24880 |
govind |
234 |
private PartnerInvestmentService partnerInvestmentService;
|
| 24288 |
amit.gupta |
235 |
|
| 23884 |
amit.gupta |
236 |
@Autowired
|
| 25653 |
amit.gupta |
237 |
DocumentRepository documentRepository;
|
| 26236 |
amit.gupta |
238 |
|
| 26234 |
amit.gupta |
239 |
@Autowired
|
|
|
240 |
InventoryItemRepository inventoryItemRepository;
|
| 25683 |
tejbeer |
241 |
|
| 25677 |
amit.gupta |
242 |
@Autowired
|
|
|
243 |
InventoryService inventoryService;
|
| 23923 |
amit.gupta |
244 |
|
| 23884 |
amit.gupta |
245 |
@Autowired
|
| 28409 |
tejbeer |
246 |
private PendingOrderItemRepository pendingOrderItemRepository;
|
|
|
247 |
|
|
|
248 |
@Autowired
|
| 24203 |
amit.gupta |
249 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
250 |
|
| 24880 |
govind |
251 |
@Autowired
|
|
|
252 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 26012 |
amit.gupta |
253 |
|
| 26011 |
amit.gupta |
254 |
@Autowired
|
|
|
255 |
private TicketCategoryRepository ticketCategoryRepository;
|
| 24880 |
govind |
256 |
|
|
|
257 |
@Autowired
|
| 25566 |
tejbeer |
258 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 25136 |
amit.gupta |
259 |
|
| 24996 |
amit.gupta |
260 |
@Autowired
|
| 25649 |
tejbeer |
261 |
private HygieneDataRepository hygieneDataRepository;
|
|
|
262 |
|
|
|
263 |
@Autowired
|
|
|
264 |
private UserCampaignRepository userCampaignRepository;
|
| 26012 |
amit.gupta |
265 |
|
| 26011 |
amit.gupta |
266 |
@Autowired
|
|
|
267 |
private PositionRepository positionRepository;
|
| 27474 |
tejbeer |
268 |
@Autowired
|
|
|
269 |
private PartnerTypeChangeRepository partnerTypeChangeRepository;
|
| 25649 |
tejbeer |
270 |
|
|
|
271 |
@Autowired
|
| 26418 |
tejbeer |
272 |
private PartnersPositionRepository partnerPositionRepository;
|
|
|
273 |
|
|
|
274 |
@Autowired
|
| 25649 |
tejbeer |
275 |
private UserAccountRepository userAccountRepository;
|
|
|
276 |
|
|
|
277 |
@Autowired
|
|
|
278 |
private NotificationCampaignRepository notificationCampaignRepository;
|
|
|
279 |
|
|
|
280 |
@Autowired
|
| 24996 |
amit.gupta |
281 |
private Mongo mongoClient;
|
| 26012 |
amit.gupta |
282 |
|
| 25976 |
amit.gupta |
283 |
@Autowired
|
|
|
284 |
private AuthRepository authRepository;
|
| 24880 |
govind |
285 |
|
| 25649 |
tejbeer |
286 |
@Autowired
|
| 26071 |
tejbeer |
287 |
private FofoOrderRepository fofoOrderRepository;
|
|
|
288 |
|
|
|
289 |
@Autowired
|
| 25649 |
tejbeer |
290 |
private Gson gson;
|
|
|
291 |
|
| 26418 |
tejbeer |
292 |
@Autowired
|
|
|
293 |
TicketRepository ticketRepository;
|
|
|
294 |
|
|
|
295 |
@Autowired
|
|
|
296 |
private LeadRepository leadRepository;
|
|
|
297 |
|
| 26588 |
tejbeer |
298 |
@Autowired
|
|
|
299 |
private OfferRepository offerRepository;
|
|
|
300 |
|
|
|
301 |
@Autowired
|
|
|
302 |
private OfferPartnerRepository offerPartnerRepository;
|
|
|
303 |
|
|
|
304 |
@Autowired
|
| 27876 |
amit.gupta |
305 |
private OfferService offerService;
|
|
|
306 |
|
|
|
307 |
@Autowired
|
| 26588 |
tejbeer |
308 |
private OfferMarginRepository offerMarginRepository;
|
| 27529 |
tejbeer |
309 |
|
| 27355 |
tejbeer |
310 |
@Autowired
|
|
|
311 |
private ItemRepository itemRepository;
|
| 26588 |
tejbeer |
312 |
|
| 27509 |
tejbeer |
313 |
@Autowired
|
|
|
314 |
private SaholicInventorySnapshotRepository saholicInventorySnapshotRepository;
|
| 27529 |
tejbeer |
315 |
|
|
|
316 |
@Autowired
|
|
|
317 |
private SaholicInventoryCISRepository saholicInventoryCISRepository;
|
|
|
318 |
|
|
|
319 |
@Autowired
|
|
|
320 |
private MVCResponseSender mvcResponseSender;
|
|
|
321 |
|
|
|
322 |
@Autowired
|
|
|
323 |
private ReporticoCacheTableRepository reporticoCacheTableRepository;
|
|
|
324 |
|
| 27586 |
tejbeer |
325 |
@Autowired
|
|
|
326 |
private TransactionService transactionService;
|
|
|
327 |
|
| 27632 |
tejbeer |
328 |
@Autowired
|
|
|
329 |
private TagListingRepository tagListingRepository;
|
|
|
330 |
|
| 27660 |
tejbeer |
331 |
@Autowired
|
|
|
332 |
private TicketAssignedRepository ticketAssignedRepository;
|
|
|
333 |
|
| 27893 |
tejbeer |
334 |
@Autowired
|
|
|
335 |
private OrderRepository orderRepository;
|
| 23568 |
govind |
336 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 23923 |
amit.gupta |
337 |
|
| 25136 |
amit.gupta |
338 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
| 25726 |
amit.gupta |
339 |
public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
|
| 25740 |
amit.gupta |
340 |
boolean isAdmin = false;
|
|
|
341 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
342 |
|
|
|
343 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
344 |
model.addAttribute("webApiPort", webApiPort);
|
|
|
345 |
model.addAttribute("webApiScheme", webApiScheme);
|
|
|
346 |
model.addAttribute("webApiRoot", webApiRoot);
|
|
|
347 |
if (isAdmin) {
|
|
|
348 |
return "dashboard1";
|
| 26236 |
amit.gupta |
349 |
}
|
|
|
350 |
|
|
|
351 |
FofoStore fofoStore = null;
|
| 26234 |
amit.gupta |
352 |
try {
|
|
|
353 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
354 |
fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
|
|
355 |
if (!fofoStore.isActive()) {
|
|
|
356 |
return "redirect:/login";
|
|
|
357 |
}
|
| 25740 |
amit.gupta |
358 |
|
| 26234 |
amit.gupta |
359 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
|
|
360 |
model.addAttribute("partnerType", partnerType);
|
|
|
361 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
|
|
362 |
model.addAttribute("fofoStore", customRetailer);
|
|
|
363 |
model.addAttribute("partnerType", partnerType);
|
|
|
364 |
model.addAttribute("hasGift", hasGift(fofoId));
|
|
|
365 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 25740 |
amit.gupta |
366 |
|
| 27884 |
tejbeer |
367 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
| 26234 |
amit.gupta |
368 |
model.addAttribute("salesMap", this.getSales(fofoId));
|
|
|
369 |
model.addAttribute("activatedImeis", inventoryItemRepository.selectCountByActivatedNotSold(fofoId));
|
|
|
370 |
// this.setInvestments
|
|
|
371 |
//
|
| 28272 |
tejbeer |
372 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
|
|
373 |
for (int i = 0; i <= 5; i++) {
|
|
|
374 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
375 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
376 |
}
|
|
|
377 |
LOGGER.info("monthValueMap" + monthValueMap);
|
|
|
378 |
model.addAttribute("monthValueMap", monthValueMap);
|
| 26234 |
amit.gupta |
379 |
model.addAttribute("investments", this.getInvestments(fofoId));
|
|
|
380 |
model.addAttribute("isInvestmentOk",
|
|
|
381 |
partnerInvestmentService.isInvestmentOk(fofoId, 10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
|
|
382 |
} catch (ProfitMandiBusinessException e) {
|
|
|
383 |
LOGGER.error("FofoStore Code not found of fofoId {}", fofoId);
|
| 25740 |
amit.gupta |
384 |
|
|
|
385 |
}
|
|
|
386 |
|
| 28430 |
tejbeer |
387 |
return "12dashboard34";
|
| 28272 |
tejbeer |
388 |
}
|
| 25740 |
amit.gupta |
389 |
|
| 28272 |
tejbeer |
390 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
|
|
391 |
Map<String, Object> investments = new LinkedHashMap<>();
|
|
|
392 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
|
|
|
393 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
|
|
|
394 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
|
|
395 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
|
|
396 |
if (yesterdayInvestment == null) {
|
|
|
397 |
yesterdayInvestment = new PartnerDailyInvestment();
|
| 25740 |
amit.gupta |
398 |
}
|
| 26460 |
amit.gupta |
399 |
|
| 28272 |
tejbeer |
400 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
|
|
401 |
currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
|
|
402 |
|
|
|
403 |
long okInvestmentDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() <= 10)
|
|
|
404 |
.collect(Collectors.counting());
|
|
|
405 |
investments.put("today", investment.getTotalInvestment());
|
|
|
406 |
investments.put("investment", investment);
|
|
|
407 |
investments.put("inStock", investment.getInStockAmount());
|
|
|
408 |
investments.put("minimum", investment.getMinInvestmentString());
|
|
|
409 |
investments.put("short", investment.getShortPercentage());
|
|
|
410 |
investments.put("activated_stock", investment.getActivatedStockAmount());
|
|
|
411 |
investments.put("okDays", okInvestmentDays);
|
|
|
412 |
return investments;
|
| 25136 |
amit.gupta |
413 |
}
|
|
|
414 |
|
| 28272 |
tejbeer |
415 |
private Map<String, Object> getInvestmentsMonths(int fofoId, int month) throws Exception {
|
| 25136 |
amit.gupta |
416 |
Map<String, Object> investments = new LinkedHashMap<>();
|
| 26233 |
amit.gupta |
417 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
|
| 28272 |
tejbeer |
418 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1).minusMonths(month);
|
|
|
419 |
|
| 25136 |
amit.gupta |
420 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
|
|
421 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
|
|
422 |
if (yesterdayInvestment == null) {
|
|
|
423 |
yesterdayInvestment = new PartnerDailyInvestment();
|
|
|
424 |
}
|
|
|
425 |
|
|
|
426 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
|
|
427 |
currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
|
|
428 |
|
| 25140 |
amit.gupta |
429 |
long okInvestmentDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() <= 10)
|
| 25136 |
amit.gupta |
430 |
.collect(Collectors.counting());
|
| 25140 |
amit.gupta |
431 |
investments.put("today", investment.getTotalInvestment());
|
|
|
432 |
investments.put("investment", investment);
|
|
|
433 |
investments.put("inStock", investment.getInStockAmount());
|
| 25182 |
amit.gupta |
434 |
investments.put("minimum", investment.getMinInvestmentString());
|
| 25140 |
amit.gupta |
435 |
investments.put("short", investment.getShortPercentage());
|
| 26267 |
amit.gupta |
436 |
investments.put("activated_stock", investment.getActivatedStockAmount());
|
| 25649 |
tejbeer |
437 |
investments.put("okDays", okInvestmentDays);
|
| 25136 |
amit.gupta |
438 |
return investments;
|
|
|
439 |
}
|
|
|
440 |
|
| 25221 |
amit.gupta |
441 |
private Map<String, Object> getSales(int fofoId) {
|
| 25653 |
amit.gupta |
442 |
|
| 25221 |
amit.gupta |
443 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| 25140 |
amit.gupta |
444 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 25214 |
amit.gupta |
445 |
int monthLength = LocalDate.now().lengthOfMonth();
|
| 26012 |
amit.gupta |
446 |
Double todaySale = fofoOrderItemRepository
|
| 27084 |
amit.gupta |
447 |
.selectSumMopGroupByRetailer(curDate, curDate.with(LocalTime.MAX), fofoId, false).get(fofoId);
|
| 26012 |
amit.gupta |
448 |
Double mtdSale = fofoOrderItemRepository
|
| 27084 |
amit.gupta |
449 |
.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId, false)
|
| 26012 |
amit.gupta |
450 |
.get(fofoId);
|
| 27352 |
tejbeer |
451 |
Double lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1).minusMonths(1),
|
|
|
452 |
curDate.with(LocalTime.MAX).minusMonths(1), fofoId, false).get(fofoId);
|
| 25214 |
amit.gupta |
453 |
|
|
|
454 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
|
|
455 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
| 25544 |
amit.gupta |
456 |
if (partnerTargetDetails.isEmpty()) {
|
| 25372 |
tejbeer |
457 |
partnerTargetDetails = partnerTargetRepository
|
| 25653 |
amit.gupta |
458 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusMonths(3));
|
| 25372 |
tejbeer |
459 |
}
|
| 25214 |
amit.gupta |
460 |
|
| 25653 |
amit.gupta |
461 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| 25214 |
amit.gupta |
462 |
|
| 25664 |
amit.gupta |
463 |
int currentRate = (int) (mtdSale / curDate.getDayOfMonth());
|
| 25653 |
amit.gupta |
464 |
|
|
|
465 |
salesMap.put("requiredType", partnerType.next());
|
|
|
466 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
|
|
467 |
int requiredRate = (int) ((reqdAmount - mtdSale) / (monthLength - curDate.getDayOfMonth()));
|
| 27859 |
tejbeer |
468 |
if (partnerType.equals(PartnerType.PLATINUM) && requiredRate < currentRate) {
|
|
|
469 |
requiredRate = currentRate;
|
|
|
470 |
}
|
| 25653 |
amit.gupta |
471 |
salesMap.put("requiredRate", requiredRate);
|
|
|
472 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
|
|
473 |
|
| 25858 |
amit.gupta |
474 |
salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
|
|
|
475 |
salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
|
| 26012 |
amit.gupta |
476 |
salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
|
| 26065 |
amit.gupta |
477 |
|
| 27352 |
tejbeer |
478 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
| 25653 |
amit.gupta |
479 |
salesMap.put("currentRate", currentRate);
|
|
|
480 |
salesMap.put("currentType", currentType);
|
|
|
481 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|
| 25136 |
amit.gupta |
482 |
return salesMap;
|
|
|
483 |
}
|
|
|
484 |
|
| 27474 |
tejbeer |
485 |
@RequestMapping(value = "/getMonthSale", method = RequestMethod.GET)
|
|
|
486 |
public String getMonthsale(HttpServletRequest request, Model model) throws Exception {
|
|
|
487 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
488 |
int fofoId = loginDetails.getFofoId();
|
|
|
489 |
Map<Integer, MonthSaleModel> monthSaleMap = new HashMap<>();
|
|
|
490 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
491 |
int dayOfMonth = curDate.getDayOfMonth();
|
|
|
492 |
for (int i = 1; i <= 6; i++) {
|
|
|
493 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 27555 |
tejbeer |
494 |
int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
|
| 27474 |
tejbeer |
495 |
double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth,
|
|
|
496 |
startOfMonth.plusMonths(1), loginDetails.getFofoId(), false).get(fofoId);
|
|
|
497 |
|
| 27574 |
tejbeer |
498 |
double mtdSales = fofoOrderItemRepository
|
|
|
499 |
.selectSumMopGroupByRetailer(startOfMonth,
|
|
|
500 |
startOfMonth.plusDays(Math.min(dayOfMonth, lengthOfMonth)), loginDetails.getFofoId(), false)
|
|
|
501 |
.get(fofoId);
|
| 27474 |
tejbeer |
502 |
|
|
|
503 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfMonth.toLocalDate());
|
|
|
504 |
|
|
|
505 |
MonthSaleModel ms = new MonthSaleModel();
|
|
|
506 |
ms.setMtdSales(this.format((long) mtdSales));
|
|
|
507 |
ms.setMonthlySales(this.format(((long) monthSales)));
|
|
|
508 |
ms.setPartnerType(partnerType);
|
| 27476 |
tejbeer |
509 |
ms.setMonth(startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
| 27474 |
tejbeer |
510 |
monthSaleMap.put(i, ms);
|
|
|
511 |
|
|
|
512 |
}
|
|
|
513 |
model.addAttribute("monthSales", monthSaleMap);
|
|
|
514 |
return "monthSales";
|
|
|
515 |
}
|
|
|
516 |
|
|
|
517 |
private String format(long value) {
|
|
|
518 |
String finalval = null;
|
|
|
519 |
|
|
|
520 |
if (value >= 100000 && value < 10000000) {
|
|
|
521 |
long reminder = value / 100000;
|
|
|
522 |
long quitonent = value % 100000;
|
|
|
523 |
finalval = reminder + "." + quitonent;
|
|
|
524 |
String secondval = String.valueOf(quitonent);
|
|
|
525 |
if (secondval.length() >= 2) {
|
|
|
526 |
secondval = secondval.substring(0, 2);
|
|
|
527 |
finalval = reminder + "." + secondval;
|
|
|
528 |
}
|
|
|
529 |
return String.valueOf(finalval) + " Lacs";
|
|
|
530 |
} else if (value >= 1000 && value < 100000) {
|
|
|
531 |
long reminder = value / 1000;
|
|
|
532 |
long quitonent = value % 1000;
|
|
|
533 |
finalval = reminder + "." + quitonent;
|
|
|
534 |
String secondval = String.valueOf(quitonent);
|
|
|
535 |
if (secondval.length() >= 2) {
|
|
|
536 |
secondval = secondval.substring(0, 2);
|
|
|
537 |
finalval = reminder + "." + secondval;
|
|
|
538 |
}
|
|
|
539 |
return String.valueOf(finalval) + " K";
|
|
|
540 |
} else if (value >= 10000000 && value < 1000000000) {
|
|
|
541 |
long reminder = value / 10000000;
|
|
|
542 |
long quitonent = value % 10000000;
|
|
|
543 |
finalval = reminder + "." + quitonent;
|
|
|
544 |
String secondval = String.valueOf(quitonent);
|
|
|
545 |
if (secondval.length() >= 2) {
|
|
|
546 |
secondval = secondval.substring(0, 2);
|
|
|
547 |
finalval = reminder + "." + secondval;
|
|
|
548 |
}
|
|
|
549 |
return String.valueOf(finalval) + " Cr";
|
|
|
550 |
}
|
|
|
551 |
return String.valueOf(finalval);
|
|
|
552 |
|
|
|
553 |
}
|
|
|
554 |
|
| 27702 |
tejbeer |
555 |
private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
|
|
|
556 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
|
| 25175 |
amit.gupta |
557 |
|
| 27702 |
tejbeer |
558 |
List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
|
|
|
559 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
|
|
560 |
|
|
|
561 |
mobileBrands.stream().forEach(x -> {
|
|
|
562 |
String brand = (String) x.get("name");
|
|
|
563 |
if (brandStockPricesMap.containsKey(brand)) {
|
|
|
564 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
|
|
565 |
brandStockPrice.setBrandUrl((String) x.get("url"));
|
|
|
566 |
brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
|
|
567 |
brandStockPrices.add(brandStockPrice);
|
|
|
568 |
}
|
|
|
569 |
});
|
|
|
570 |
|
|
|
571 |
return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x, y) -> x.getRank() - y.getRank())
|
|
|
572 |
.collect(Collectors.toList());
|
|
|
573 |
}
|
|
|
574 |
|
| 21615 |
kshitij.so |
575 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 25653 |
amit.gupta |
576 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
| 22927 |
ashik.ali |
577 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26011 |
amit.gupta |
578 |
String email = loginDetails.getEmailId();
|
| 28430 |
tejbeer |
579 |
int fofoId = loginDetails.getFofoId();
|
| 28409 |
tejbeer |
580 |
|
| 28430 |
tejbeer |
581 |
LocalDateTime startDate = LocalDate.now().withDayOfYear(1).atStartOfDay();
|
|
|
582 |
LocalDateTime endtDate = LocalDateTime.now();
|
|
|
583 |
OnlineDeliveredOrderSum onlineDeliveredOrderSum = pendingOrderItemRepository
|
|
|
584 |
.selectSumSellingPriceOnlineOrder(fofoId, startDate, endtDate);
|
| 28409 |
tejbeer |
585 |
|
| 28430 |
tejbeer |
586 |
LOGGER.info("onlineDeliveredOrderSum" + onlineDeliveredOrderSum.getSellingPrice());
|
|
|
587 |
|
|
|
588 |
long countOrder = pendingOrderRepository.pendingOrderCount(fofoId, OrderStatus.PROCESSING);
|
|
|
589 |
LOGGER.info("countOrder" + countOrder);
|
|
|
590 |
|
| 28409 |
tejbeer |
591 |
model.addAttribute("countOrder", countOrder);
|
|
|
592 |
model.addAttribute("onlineDeliveredOrderSum", onlineDeliveredOrderSum.getSellingPrice());
|
| 25180 |
amit.gupta |
593 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
594 |
model.addAttribute("isAdmin", isAdmin);
|
| 23923 |
amit.gupta |
595 |
|
| 25274 |
amit.gupta |
596 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
597 |
model.addAttribute("webApiPort", webApiPort);
|
|
|
598 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 25544 |
amit.gupta |
599 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 25183 |
amit.gupta |
600 |
if (isAdmin) {
|
| 26011 |
amit.gupta |
601 |
return adminPanel(loginDetails.getFofoId(), email, model);
|
| 25180 |
amit.gupta |
602 |
} else {
|
| 25740 |
amit.gupta |
603 |
FofoStore fofoStore = null;
|
| 25180 |
amit.gupta |
604 |
try {
|
|
|
605 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 25544 |
amit.gupta |
606 |
if (!fofoStore.isActive()) {
|
|
|
607 |
return "redirect:/login";
|
|
|
608 |
}
|
| 25649 |
tejbeer |
609 |
|
| 25740 |
amit.gupta |
610 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
| 25566 |
tejbeer |
611 |
model.addAttribute("partnerType", partnerType);
|
| 25653 |
amit.gupta |
612 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
| 25180 |
amit.gupta |
613 |
model.addAttribute("fofoStore", fofoStore);
|
| 25566 |
tejbeer |
614 |
model.addAttribute("partnerType", partnerType);
|
| 25180 |
amit.gupta |
615 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
|
|
616 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 26222 |
tejbeer |
617 |
model.addAttribute("retailers", new JSONObject().append("code", fofoStore.getCode())
|
| 26162 |
amit.gupta |
618 |
.append("partnerId", fofoStore.getId()).toString());
|
| 26460 |
amit.gupta |
619 |
model.addAttribute("activatedImeis",
|
|
|
620 |
inventoryItemRepository.selectCountByActivatedNotSold(loginDetails.getFofoId()));
|
| 26071 |
tejbeer |
621 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
622 |
Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository
|
|
|
623 |
.selectSumSaleGroupByFofoIdsForMobileOrAccessories(loginDetails.getFofoId(),
|
|
|
624 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
|
| 27701 |
tejbeer |
625 |
|
| 26071 |
tejbeer |
626 |
Double accesoriesStock = currentInventorySnapshotRepository
|
|
|
627 |
.selectSumStockGroupByFofoIdsForMobileOrAccessories(loginDetails.getFofoId(),
|
|
|
628 |
Optional.of(false))
|
|
|
629 |
.get(loginDetails.getFofoId());
|
| 25180 |
amit.gupta |
630 |
|
| 26071 |
tejbeer |
631 |
model.addAttribute("accesoriesStock", String.format("%.0f", accesoriesStock));
|
| 27702 |
tejbeer |
632 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 25180 |
amit.gupta |
633 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
| 26055 |
tejbeer |
634 |
ChartModel cm = this.getBrandChart(loginDetails.getFofoId());
|
|
|
635 |
|
|
|
636 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
637 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 27701 |
tejbeer |
638 |
|
| 27876 |
amit.gupta |
639 |
List<CreateOfferRequest> publishedOffers = offerService.getPublishedOffers(loginDetails.getFofoId(),
|
|
|
640 |
YearMonth.from(LocalDateTime.now()));
|
|
|
641 |
model.addAttribute("publishedOffers", publishedOffers);
|
| 25180 |
amit.gupta |
642 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
| 25544 |
amit.gupta |
643 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
|
|
|
644 |
10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
| 26460 |
amit.gupta |
645 |
|
| 25180 |
amit.gupta |
646 |
} catch (ProfitMandiBusinessException e) {
|
|
|
647 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
|
|
648 |
|
|
|
649 |
}
|
| 22481 |
ashik.ali |
650 |
}
|
| 25649 |
tejbeer |
651 |
|
|
|
652 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
| 25747 |
amit.gupta |
653 |
LocalDateTime lastMonthStart = currentMonthStart.minusMonths(1);
|
| 25653 |
amit.gupta |
654 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
|
|
655 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
|
| 25677 |
amit.gupta |
656 |
currentMonthEnd) / 2;
|
| 25747 |
amit.gupta |
657 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), lastMonthStart,
|
|
|
658 |
currentMonthStart) / 2;
|
|
|
659 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), LocalDateTime.MIN,
|
| 25677 |
amit.gupta |
660 |
currentMonthEnd) / 2;
|
|
|
661 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
|
|
662 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
|
|
663 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
| 25649 |
tejbeer |
664 |
|
| 25653 |
amit.gupta |
665 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true, currentMonthStart,
|
|
|
666 |
currentMonthEnd);
|
| 25651 |
tejbeer |
667 |
|
| 25653 |
amit.gupta |
668 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false,
|
|
|
669 |
currentMonthStart, currentMonthEnd);
|
|
|
670 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
|
|
671 |
invalidHygieneCount = 1;
|
|
|
672 |
}
|
| 28272 |
tejbeer |
673 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
|
|
674 |
for (int i = 0; i <= 5; i++) {
|
|
|
675 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
676 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
677 |
}
|
|
|
678 |
|
|
|
679 |
model.addAttribute("monthValueMap", monthValueMap);
|
|
|
680 |
model.addAttribute("month", 0);
|
|
|
681 |
|
| 25653 |
amit.gupta |
682 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| 25651 |
tejbeer |
683 |
|
| 25197 |
amit.gupta |
684 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
|
|
685 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
| 27884 |
tejbeer |
686 |
/*
|
|
|
687 |
* if (loginDetails.isReadOnly()) { return "dashboard-readonly"; } else { }
|
|
|
688 |
*/
|
| 28430 |
tejbeer |
689 |
|
| 27882 |
amit.gupta |
690 |
return "dashboard1";
|
| 28272 |
tejbeer |
691 |
|
| 21615 |
kshitij.so |
692 |
}
|
| 23923 |
amit.gupta |
693 |
|
| 28272 |
tejbeer |
694 |
@RequestMapping(value = "/getMonthsInvestment", method = RequestMethod.GET)
|
|
|
695 |
public String getMonthsInvestment(HttpServletRequest request,
|
|
|
696 |
@RequestParam(name = "month", required = true, defaultValue = "0") int month, Model model)
|
|
|
697 |
throws Exception {
|
|
|
698 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
699 |
int fofoId = loginDetails.getFofoId();
|
|
|
700 |
Map<String, Object> investment = getInvestmentsMonths(fofoId, month);
|
| 28430 |
tejbeer |
701 |
|
| 28272 |
tejbeer |
702 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
|
|
703 |
LocalDateTime lastMonthStart = currentMonthStart.minusMonths(1);
|
|
|
704 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
|
|
705 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
|
|
|
706 |
currentMonthEnd) / 2;
|
|
|
707 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), lastMonthStart,
|
|
|
708 |
currentMonthStart) / 2;
|
|
|
709 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), LocalDateTime.MIN,
|
|
|
710 |
currentMonthEnd) / 2;
|
|
|
711 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
|
|
712 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
|
|
713 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
|
|
714 |
|
| 28430 |
tejbeer |
715 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true,
|
|
|
716 |
currentMonthStart.minusMonths(month), currentMonthEnd.minusMonths(month));
|
| 28272 |
tejbeer |
717 |
|
|
|
718 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false,
|
| 28430 |
tejbeer |
719 |
currentMonthStart.minusMonths(month), currentMonthEnd.minusMonths(month));
|
| 28272 |
tejbeer |
720 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
|
|
721 |
invalidHygieneCount = 1;
|
|
|
722 |
}
|
|
|
723 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
|
|
724 |
for (int i = 0; i <= 5; i++) {
|
|
|
725 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
|
|
726 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
727 |
}
|
|
|
728 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| 28430 |
tejbeer |
729 |
model.addAttribute("monthValueMap", monthValueMap);
|
| 28272 |
tejbeer |
730 |
model.addAttribute("investments", investment);
|
|
|
731 |
model.addAttribute("monthDays", LocalDate.now().minusMonths(month).lengthOfMonth());
|
|
|
732 |
model.addAttribute("dayOfMonth", LocalDate.now().minusMonths(month).lengthOfMonth());
|
| 28430 |
tejbeer |
733 |
model.addAttribute("month", month);
|
| 28272 |
tejbeer |
734 |
return "performance";
|
|
|
735 |
}
|
|
|
736 |
|
| 27884 |
tejbeer |
737 |
@RequestMapping(value = "/investmentDetails", method = RequestMethod.GET)
|
|
|
738 |
public String getInvestmentDetails(HttpServletRequest request, Model model) throws Exception {
|
|
|
739 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
740 |
int fofoId = loginDetails.getFofoId();
|
|
|
741 |
ChartInvestmentModel cm = this.getInvestmentChart(fofoId);
|
|
|
742 |
model.addAttribute("chartPieMap", gson.toJson(cm));
|
|
|
743 |
|
|
|
744 |
LOGGER.info("InvestmentChart" + gson.toJson(cm));
|
|
|
745 |
LOGGER.info("InvestmentChart" + cm);
|
|
|
746 |
return "investmentdetails";
|
|
|
747 |
}
|
|
|
748 |
|
| 28430 |
tejbeer |
749 |
@RequestMapping(value = "/getlmsLineChart", method = RequestMethod.GET)
|
|
|
750 |
public String getlmsLineChart(HttpServletRequest request, Model model) throws Exception {
|
|
|
751 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
752 |
int fofoId = loginDetails.getFofoId();
|
|
|
753 |
ChartModel cm = this.getLmsLineChart(loginDetails.getFofoId());
|
|
|
754 |
|
|
|
755 |
LOGGER.info("linechartMap" + gson.toJson(cm));
|
|
|
756 |
model.addAttribute("linechartMap", gson.toJson(cm));
|
|
|
757 |
|
|
|
758 |
return "lmsLineChart";
|
|
|
759 |
}
|
|
|
760 |
|
| 28439 |
tejbeer |
761 |
@RequestMapping(value = "/getMonthlyPurchaseLineChart", method = RequestMethod.GET)
|
|
|
762 |
public String getMonthlyPurchaseLineChart(HttpServletRequest request, Model model) throws Exception {
|
|
|
763 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
764 |
int fofoId = loginDetails.getFofoId();
|
|
|
765 |
ChartModel cm = this.getPurchaseOrderChart(fofoId);
|
|
|
766 |
|
|
|
767 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
768 |
model.addAttribute("chartMap", gson.toJson(cm));
|
|
|
769 |
|
|
|
770 |
return "purchase_chart";
|
|
|
771 |
}
|
|
|
772 |
|
| 28430 |
tejbeer |
773 |
@RequestMapping(value = "/getBarChart", method = RequestMethod.GET)
|
|
|
774 |
public String getBarChart(HttpServletRequest request, Model model) throws Exception {
|
|
|
775 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
776 |
int fofoId = loginDetails.getFofoId();
|
|
|
777 |
ChartModel cm = this.getBrandChart(fofoId);
|
|
|
778 |
|
|
|
779 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
780 |
model.addAttribute("chartMap", gson.toJson(cm));
|
|
|
781 |
|
|
|
782 |
return "bar_chart";
|
|
|
783 |
}
|
|
|
784 |
|
| 27884 |
tejbeer |
785 |
private ChartInvestmentModel getInvestmentChart(int fofoId) throws ProfitMandiBusinessException {
|
|
|
786 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
|
| 27900 |
tejbeer |
787 |
|
| 27884 |
tejbeer |
788 |
Map<String, Float> investmentWalletAmount = new HashMap<>();
|
|
|
789 |
investmentWalletAmount.put("Wallet", investment.getWalletAmount());
|
| 28272 |
tejbeer |
790 |
investmentWalletAmount.put("InStocks", investment.getInStockAmount() - investment.getActivatedStockAmount());
|
| 27900 |
tejbeer |
791 |
investmentWalletAmount.put("Unbilled Order", investment.getUnbilledAmount());
|
| 27884 |
tejbeer |
792 |
investmentWalletAmount.put("GrnPending", investment.getGrnPendingAmount());
|
|
|
793 |
investmentWalletAmount.put("ReturnInTransit", investment.getReturnInTransitAmount());
|
|
|
794 |
|
| 27900 |
tejbeer |
795 |
if (investment.getShortInvestment() > 0) {
|
|
|
796 |
investmentWalletAmount.put("Short Investment", investment.getShortInvestment());
|
|
|
797 |
}
|
|
|
798 |
|
| 27884 |
tejbeer |
799 |
ChartInvestmentModel cm = new ChartInvestmentModel();
|
|
|
800 |
|
|
|
801 |
HashSet<String> labels = new HashSet<String>();
|
|
|
802 |
labels.addAll(investmentWalletAmount.keySet());
|
|
|
803 |
|
|
|
804 |
List<String> labelList = new ArrayList<>(labels);
|
|
|
805 |
List<String> backgroundColor = new ArrayList<>();
|
| 27900 |
tejbeer |
806 |
List<Float> labelsValue = new ArrayList<>();
|
| 27884 |
tejbeer |
807 |
List<Float> values = new ArrayList<>();
|
|
|
808 |
for (String label : labelList) {
|
|
|
809 |
values.add(investmentWalletAmount.get(label));
|
|
|
810 |
if (label.equals("Wallet")) {
|
|
|
811 |
backgroundColor.add("pink");
|
|
|
812 |
}
|
| 27900 |
tejbeer |
813 |
if (label.equals("Short Investment")) {
|
|
|
814 |
backgroundColor.add("red");
|
|
|
815 |
}
|
| 28015 |
tejbeer |
816 |
if (label.equals("InStocks")) {
|
| 27900 |
tejbeer |
817 |
backgroundColor.add("#9ACD32");
|
| 27884 |
tejbeer |
818 |
}
|
| 27900 |
tejbeer |
819 |
if (label.equals("Unbilled Order")) {
|
|
|
820 |
backgroundColor.add("blue");
|
| 27884 |
tejbeer |
821 |
}
|
|
|
822 |
|
|
|
823 |
if (label.equals("ReturnInTransit")) {
|
|
|
824 |
backgroundColor.add("orange");
|
|
|
825 |
}
|
|
|
826 |
if (label.equals("GrnPending")) {
|
|
|
827 |
backgroundColor.add("yellow");
|
|
|
828 |
}
|
|
|
829 |
|
|
|
830 |
}
|
|
|
831 |
|
|
|
832 |
Data data = new Data();
|
|
|
833 |
data.setData(values);
|
|
|
834 |
data.setBackgroundColor(backgroundColor);
|
|
|
835 |
data.setLabel("DataSet 1");
|
|
|
836 |
|
|
|
837 |
PieLables label = new PieLables();
|
|
|
838 |
label.setFontColor("White");
|
|
|
839 |
label.setFontSize(15);
|
|
|
840 |
|
|
|
841 |
Legend legend = new Legend();
|
|
|
842 |
legend.setLabels(label);
|
|
|
843 |
legend.setPosition("left");
|
|
|
844 |
|
|
|
845 |
List<Data> dataList = new ArrayList<>();
|
|
|
846 |
dataList.add(data);
|
|
|
847 |
|
|
|
848 |
DataInvestmentModel datasets = new DataInvestmentModel();
|
|
|
849 |
datasets.setDatasets(dataList);
|
|
|
850 |
datasets.setLabels(labels);
|
|
|
851 |
|
|
|
852 |
OptionModel om = new OptionModel();
|
|
|
853 |
om.setLegend(legend);
|
|
|
854 |
cm.setType("pie");
|
|
|
855 |
cm.setData(datasets);
|
|
|
856 |
cm.setOptions(om);
|
|
|
857 |
|
|
|
858 |
return cm;
|
|
|
859 |
}
|
|
|
860 |
|
| 28439 |
tejbeer |
861 |
private ChartModel getPurchaseOrderChart(int fofoId) throws ProfitMandiBusinessException {
|
|
|
862 |
|
|
|
863 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
864 |
|
|
|
865 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(1);
|
|
|
866 |
|
|
|
867 |
List<SecondaryOrderBilledLmsModel> soblms = orderRepository.selectAllBilledOrderGroupByBrandFofoId(fofoId,
|
|
|
868 |
curDate.withDayOfMonth(1).minusMonths(6));
|
|
|
869 |
|
|
|
870 |
LOGGER.info("soblms" + soblms);
|
|
|
871 |
Map<String, Map<YearMonth, Double>> brandMonthValueMap = new HashMap<>();
|
|
|
872 |
for (SecondaryOrderBilledLmsModel orderBilledLmsMode : soblms) {
|
|
|
873 |
Map<YearMonth, Double> yearMonthMap = new HashMap<>();
|
|
|
874 |
yearMonthMap.put(YearMonth.from(startOfMonth), (double) orderBilledLmsMode.getFirstMonthValue());
|
|
|
875 |
yearMonthMap.put(YearMonth.from(startOfMonth.minusNanos(1)),
|
|
|
876 |
(double) orderBilledLmsMode.getSecondMonthValue());
|
|
|
877 |
|
|
|
878 |
yearMonthMap.put(YearMonth.from(startOfMonth.minusMonths(2)),
|
|
|
879 |
(double) orderBilledLmsMode.getThirdMonthValue());
|
|
|
880 |
yearMonthMap.put(YearMonth.from(startOfMonth.minusMonths(3)),
|
|
|
881 |
(double) orderBilledLmsMode.getFourthMonthValue());
|
|
|
882 |
yearMonthMap.put(YearMonth.from(startOfMonth.minusMonths(4)),
|
|
|
883 |
(double) orderBilledLmsMode.getFifthMonthValue());
|
|
|
884 |
yearMonthMap.put(YearMonth.from(startOfMonth.minusMonths(5)),
|
|
|
885 |
(double) orderBilledLmsMode.getSixthMonthValue());
|
|
|
886 |
Map<YearMonth, Double> sortedYearMonthMap = new TreeMap<YearMonth, Double>(yearMonthMap);
|
|
|
887 |
brandMonthValueMap.put(orderBilledLmsMode.getBrand(), sortedYearMonthMap);
|
|
|
888 |
|
|
|
889 |
}
|
|
|
890 |
LOGGER.info("brandMonthValueMap" + brandMonthValueMap);
|
|
|
891 |
|
|
|
892 |
List<String> brands = new ArrayList<>();
|
|
|
893 |
brands.add("Accessories");
|
|
|
894 |
brands.add("Oppo");
|
|
|
895 |
brands.add("Vivo");
|
|
|
896 |
brands.add("Samsung");
|
|
|
897 |
brands.add("Realme");
|
|
|
898 |
brands.add("Mi");
|
|
|
899 |
brands.add("Tecno");
|
|
|
900 |
brands.add("Itel");
|
|
|
901 |
brands.add("Lava");
|
|
|
902 |
brands.add("Nokia");
|
|
|
903 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
|
|
904 |
|
|
|
905 |
for (String brand : brands) {
|
|
|
906 |
Map<YearMonth, Double> coll = brandMonthValueMap.get(brand);
|
|
|
907 |
LOGGER.info("coll" + coll);
|
|
|
908 |
List<Double> valueList = new ArrayList<>();
|
|
|
909 |
|
|
|
910 |
if (coll != null) {
|
|
|
911 |
|
|
|
912 |
valueList.addAll(coll.values());
|
|
|
913 |
}
|
|
|
914 |
sortedBrandValue.put(brand, valueList);
|
|
|
915 |
|
|
|
916 |
}
|
|
|
917 |
LinkedHashSet<String> labels = new LinkedHashSet<String>();
|
|
|
918 |
|
|
|
919 |
for (int i = 6; i >= 1; i--) {
|
|
|
920 |
|
|
|
921 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
|
|
922 |
labels.add(startMonth.format(DateTimeFormatter.ofPattern("MMM''uu")).toString());
|
|
|
923 |
|
|
|
924 |
LOGGER.info("labels" + labels);
|
|
|
925 |
}
|
|
|
926 |
|
|
|
927 |
LOGGER.info("labels" + labels);
|
|
|
928 |
|
|
|
929 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
|
|
930 |
List<DatasetModel> datasets = new ArrayList<>();
|
|
|
931 |
List<String> colorList = new ArrayList<>();
|
|
|
932 |
colorList.add("slateblue");
|
|
|
933 |
colorList.add("darkgreen");
|
|
|
934 |
colorList.add("darkorange");
|
|
|
935 |
colorList.add("#654321");
|
|
|
936 |
colorList.add("deeppink");
|
|
|
937 |
|
|
|
938 |
colorList.add("darkred");
|
|
|
939 |
|
|
|
940 |
colorList.add("burlywood");
|
|
|
941 |
colorList.add("goldenrod");
|
|
|
942 |
colorList.add("slategray");
|
|
|
943 |
colorList.add("darkviolet");
|
|
|
944 |
colorList.add("cornsilk");
|
|
|
945 |
|
|
|
946 |
List<String> borderList = new ArrayList<>();
|
|
|
947 |
borderList.add("lightskyblue");
|
|
|
948 |
borderList.add("green");
|
|
|
949 |
borderList.add("orange");
|
|
|
950 |
borderList.add("#DB8C44");
|
|
|
951 |
borderList.add("pink");
|
|
|
952 |
borderList.add("red");
|
|
|
953 |
|
|
|
954 |
borderList.add("slategray");
|
|
|
955 |
borderList.add("burlywood");
|
|
|
956 |
borderList.add("goldenrod");
|
|
|
957 |
borderList.add("darkviolet");
|
|
|
958 |
borderList.add("cornsilk");
|
|
|
959 |
|
|
|
960 |
int i = 0;
|
|
|
961 |
|
|
|
962 |
for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
|
|
|
963 |
|
|
|
964 |
DatasetModel purchaseModel = new DatasetModel();
|
|
|
965 |
purchaseModel.setLabel(brandValue.getKey());
|
|
|
966 |
purchaseModel.setBackgroundColor(borderList.get(i));
|
|
|
967 |
if (brandValue.getValue().isEmpty()) {
|
|
|
968 |
|
|
|
969 |
purchaseModel.setData(Arrays.asList(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
|
|
|
970 |
} else {
|
|
|
971 |
purchaseModel.setData(brandValue.getValue());
|
|
|
972 |
}
|
|
|
973 |
purchaseModel.setType("line");
|
|
|
974 |
purchaseModel.setOrder(1);
|
|
|
975 |
purchaseModel.setFill("false");
|
|
|
976 |
purchaseModel.setBorderColor(colorList.get(i));
|
|
|
977 |
datasets.add(purchaseModel);
|
|
|
978 |
|
|
|
979 |
i++;
|
|
|
980 |
}
|
|
|
981 |
|
|
|
982 |
DataModel dm = new DataModel();
|
|
|
983 |
dm.setDatasets(datasets);
|
|
|
984 |
dm.setLabels(labels);
|
|
|
985 |
|
|
|
986 |
LegendModel lm = new LegendModel();
|
|
|
987 |
lm.setPosition("top");
|
|
|
988 |
|
|
|
989 |
Tooltips tooltips = new Tooltips();
|
|
|
990 |
tooltips.setBodyFontSize(15);
|
|
|
991 |
tooltips.setTitleFontSize(15);
|
|
|
992 |
tooltips.setMode("index");
|
|
|
993 |
tooltips.setIntersect(false);
|
|
|
994 |
|
|
|
995 |
HoverModel hover = new HoverModel();
|
|
|
996 |
hover.setIntersect(false);
|
|
|
997 |
hover.setMode("index");
|
|
|
998 |
|
|
|
999 |
TitleModel tm = new TitleModel();
|
|
|
1000 |
tm.setText("Brand Wise Monthly Purchase");
|
|
|
1001 |
tm.setDisplay(true);
|
|
|
1002 |
tm.setFontSize(20);
|
|
|
1003 |
tm.setFontColor("#111");
|
|
|
1004 |
|
|
|
1005 |
OptionsModel om = new OptionsModel();
|
|
|
1006 |
om.setResponsive(true);
|
|
|
1007 |
om.setLegend(lm);
|
|
|
1008 |
om.setTitle(tm);
|
|
|
1009 |
om.setTooltips(tooltips);
|
|
|
1010 |
om.setHover(hover);
|
|
|
1011 |
|
|
|
1012 |
ChartModel cm = new ChartModel();
|
|
|
1013 |
cm.setType("line");
|
|
|
1014 |
cm.setData(dm);
|
|
|
1015 |
cm.setOptions(om);
|
|
|
1016 |
|
|
|
1017 |
LOGGER.info("cm" + cm);
|
|
|
1018 |
|
|
|
1019 |
return cm;
|
|
|
1020 |
|
|
|
1021 |
}
|
|
|
1022 |
|
| 28430 |
tejbeer |
1023 |
private ChartModel getLmsLineChart(int fofoId) throws ProfitMandiBusinessException {
|
|
|
1024 |
|
|
|
1025 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1026 |
|
|
|
1027 |
Map<YearMonth, Map<String, Double>> monthValueMap = new HashMap<>();
|
|
|
1028 |
|
|
|
1029 |
for (int i = 1; i <= 6; i++) {
|
|
|
1030 |
|
|
|
1031 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
|
|
1032 |
|
|
|
1033 |
Map<String, Double> lmsBrandWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
|
|
1034 |
curDate.withDayOfMonth(1).minusMonths(i), curDate.withDayOfMonth(1).minusMonths(i - 1), fofoId);
|
|
|
1035 |
|
|
|
1036 |
Map<Integer, Double> accesorieslmsSale = fofoOrderRepository
|
|
|
1037 |
.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1).minusMonths(i),
|
|
|
1038 |
curDate.withDayOfMonth(1).minusMonths(i - 1), Optional.of(false));
|
|
|
1039 |
LOGGER.info("lmsBrandWiseSale" + lmsBrandWiseSale);
|
|
|
1040 |
|
|
|
1041 |
lmsBrandWiseSale.put("Accessories", accesorieslmsSale.get(fofoId));
|
|
|
1042 |
|
|
|
1043 |
monthValueMap.put(YearMonth.from(startOfMonth), lmsBrandWiseSale);
|
|
|
1044 |
}
|
|
|
1045 |
LOGGER.info("monthmap" + monthValueMap);
|
|
|
1046 |
|
|
|
1047 |
Map<YearMonth, Map<String, Double>> sortedMonthValueMap = new TreeMap(monthValueMap);
|
|
|
1048 |
LOGGER.info("monthmap" + sortedMonthValueMap);
|
|
|
1049 |
|
|
|
1050 |
Multimap<String, Map<YearMonth, Double>> brandMonthValueMap = ArrayListMultimap.create();
|
|
|
1051 |
|
|
|
1052 |
for (Entry<YearMonth, Map<String, Double>> month : sortedMonthValueMap.entrySet()) {
|
|
|
1053 |
|
|
|
1054 |
for (Entry<String, Double> val : month.getValue().entrySet()) {
|
|
|
1055 |
Map<YearMonth, Double> yearValue = new HashMap<>();
|
|
|
1056 |
|
|
|
1057 |
yearValue.put(month.getKey(), val.getValue() == null ? 0 : val.getValue());
|
|
|
1058 |
brandMonthValueMap.put(val.getKey(), yearValue);
|
|
|
1059 |
|
|
|
1060 |
}
|
|
|
1061 |
}
|
|
|
1062 |
|
|
|
1063 |
LOGGER.info("map" + brandMonthValueMap);
|
| 28435 |
tejbeer |
1064 |
|
| 28430 |
tejbeer |
1065 |
List<String> brands = new ArrayList<>();
|
| 28435 |
tejbeer |
1066 |
brands.add("Accessories");
|
|
|
1067 |
brands.add("Oppo");
|
|
|
1068 |
brands.add("Vivo");
|
|
|
1069 |
brands.add("Samsung");
|
|
|
1070 |
brands.add("Realme");
|
|
|
1071 |
brands.add("Mi");
|
|
|
1072 |
brands.add("Tecno");
|
|
|
1073 |
brands.add("Itel");
|
|
|
1074 |
brands.add("Lava");
|
|
|
1075 |
brands.add("Nokia");
|
|
|
1076 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
| 28430 |
tejbeer |
1077 |
|
|
|
1078 |
for (String brand : brands) {
|
|
|
1079 |
Collection<Map<YearMonth, Double>> coll = brandMonthValueMap.get(brand);
|
|
|
1080 |
LOGGER.info("coll" + coll);
|
|
|
1081 |
|
|
|
1082 |
List<Double> valueList = new ArrayList<>();
|
|
|
1083 |
for (Map<YearMonth, Double> col : coll) {
|
|
|
1084 |
|
|
|
1085 |
valueList.addAll(col.values());
|
|
|
1086 |
}
|
|
|
1087 |
|
| 28435 |
tejbeer |
1088 |
sortedBrandValue.put(brand, valueList);
|
| 28430 |
tejbeer |
1089 |
|
|
|
1090 |
}
|
|
|
1091 |
|
| 28435 |
tejbeer |
1092 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
| 28430 |
tejbeer |
1093 |
LinkedHashSet<String> labels = new LinkedHashSet<String>();
|
|
|
1094 |
for (Entry<YearMonth, Map<String, Double>> val : sortedMonthValueMap.entrySet()) {
|
|
|
1095 |
labels.add(val.getKey().format(DateTimeFormatter.ofPattern("MMM''uu")).toString());
|
| 28435 |
tejbeer |
1096 |
|
| 28430 |
tejbeer |
1097 |
}
|
|
|
1098 |
|
|
|
1099 |
List<String> labelList = new ArrayList<>(labels);
|
|
|
1100 |
List<Double> lmsValues = new ArrayList<>();
|
| 28439 |
tejbeer |
1101 |
|
| 28430 |
tejbeer |
1102 |
List<DatasetModel> datasets = new ArrayList<>();
|
|
|
1103 |
List<String> colorList = new ArrayList<>();
|
| 28435 |
tejbeer |
1104 |
colorList.add("slateblue");
|
|
|
1105 |
colorList.add("darkgreen");
|
| 28430 |
tejbeer |
1106 |
colorList.add("darkorange");
|
|
|
1107 |
colorList.add("#654321");
|
|
|
1108 |
colorList.add("deeppink");
|
| 28439 |
tejbeer |
1109 |
|
| 28430 |
tejbeer |
1110 |
colorList.add("darkred");
|
| 28439 |
tejbeer |
1111 |
|
| 28432 |
tejbeer |
1112 |
colorList.add("burlywood");
|
|
|
1113 |
colorList.add("goldenrod");
|
|
|
1114 |
colorList.add("slategray");
|
|
|
1115 |
colorList.add("darkviolet");
|
|
|
1116 |
colorList.add("cornsilk");
|
| 28435 |
tejbeer |
1117 |
|
| 28430 |
tejbeer |
1118 |
List<String> borderList = new ArrayList<>();
|
| 28435 |
tejbeer |
1119 |
borderList.add("lightskyblue");
|
|
|
1120 |
borderList.add("green");
|
| 28430 |
tejbeer |
1121 |
borderList.add("orange");
|
|
|
1122 |
borderList.add("#DB8C44");
|
|
|
1123 |
borderList.add("pink");
|
|
|
1124 |
borderList.add("red");
|
| 28439 |
tejbeer |
1125 |
|
| 28432 |
tejbeer |
1126 |
borderList.add("slategray");
|
| 28433 |
tejbeer |
1127 |
borderList.add("burlywood");
|
|
|
1128 |
borderList.add("goldenrod");
|
| 28432 |
tejbeer |
1129 |
borderList.add("darkviolet");
|
| 28433 |
tejbeer |
1130 |
borderList.add("cornsilk");
|
| 28430 |
tejbeer |
1131 |
|
| 28435 |
tejbeer |
1132 |
int i = 0;
|
| 28430 |
tejbeer |
1133 |
|
| 28435 |
tejbeer |
1134 |
for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
|
|
|
1135 |
|
| 28430 |
tejbeer |
1136 |
DatasetModel lineLmsChart = new DatasetModel();
|
|
|
1137 |
lineLmsChart.setLabel(brandValue.getKey());
|
|
|
1138 |
lineLmsChart.setBackgroundColor(borderList.get(i));
|
| 28435 |
tejbeer |
1139 |
if (brandValue.getValue().isEmpty()) {
|
|
|
1140 |
|
| 28439 |
tejbeer |
1141 |
lineLmsChart.setData(Arrays.asList(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
|
| 28435 |
tejbeer |
1142 |
} else {
|
|
|
1143 |
lineLmsChart.setData(brandValue.getValue());
|
|
|
1144 |
}
|
| 28430 |
tejbeer |
1145 |
lineLmsChart.setType("line");
|
|
|
1146 |
lineLmsChart.setOrder(1);
|
|
|
1147 |
lineLmsChart.setFill("false");
|
|
|
1148 |
lineLmsChart.setBorderColor(colorList.get(i));
|
|
|
1149 |
datasets.add(lineLmsChart);
|
| 28435 |
tejbeer |
1150 |
|
| 28430 |
tejbeer |
1151 |
i++;
|
|
|
1152 |
}
|
|
|
1153 |
|
|
|
1154 |
DataModel dm = new DataModel();
|
|
|
1155 |
dm.setDatasets(datasets);
|
|
|
1156 |
dm.setLabels(labels);
|
|
|
1157 |
|
|
|
1158 |
LegendModel lm = new LegendModel();
|
|
|
1159 |
lm.setPosition("top");
|
| 28435 |
tejbeer |
1160 |
|
| 28434 |
tejbeer |
1161 |
Tooltips tooltips = new Tooltips();
|
|
|
1162 |
tooltips.setBodyFontSize(15);
|
|
|
1163 |
tooltips.setTitleFontSize(15);
|
|
|
1164 |
tooltips.setMode("index");
|
|
|
1165 |
tooltips.setIntersect(false);
|
| 28435 |
tejbeer |
1166 |
|
| 28434 |
tejbeer |
1167 |
HoverModel hover = new HoverModel();
|
|
|
1168 |
hover.setIntersect(false);
|
|
|
1169 |
hover.setMode("index");
|
| 28435 |
tejbeer |
1170 |
|
| 28430 |
tejbeer |
1171 |
TitleModel tm = new TitleModel();
|
|
|
1172 |
tm.setText("Brand Wise LMS");
|
|
|
1173 |
tm.setDisplay(true);
|
| 28434 |
tejbeer |
1174 |
tm.setFontSize(20);
|
| 28435 |
tejbeer |
1175 |
tm.setFontColor("#111");
|
|
|
1176 |
|
|
|
1177 |
OptionsModel om = new OptionsModel();
|
| 28430 |
tejbeer |
1178 |
om.setResponsive(true);
|
|
|
1179 |
om.setLegend(lm);
|
|
|
1180 |
om.setTitle(tm);
|
| 28434 |
tejbeer |
1181 |
om.setTooltips(tooltips);
|
|
|
1182 |
om.setHover(hover);
|
| 28430 |
tejbeer |
1183 |
|
|
|
1184 |
ChartModel cm = new ChartModel();
|
|
|
1185 |
cm.setType("line");
|
|
|
1186 |
cm.setData(dm);
|
|
|
1187 |
cm.setOptions(om);
|
|
|
1188 |
|
|
|
1189 |
LOGGER.info("cm" + cm);
|
|
|
1190 |
|
|
|
1191 |
return cm;
|
|
|
1192 |
|
|
|
1193 |
}
|
|
|
1194 |
|
| 26055 |
tejbeer |
1195 |
private ChartModel getBrandChart(int fofoId) {
|
|
|
1196 |
|
|
|
1197 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1198 |
|
|
|
1199 |
LOGGER.info("cur Date" + curDate.withDayOfMonth(1));
|
|
|
1200 |
|
|
|
1201 |
LOGGER.info("curDateYear" + curDate.with(LocalTime.MAX));
|
|
|
1202 |
|
| 27900 |
tejbeer |
1203 |
Map<String, Double> brandwisesale = fofoOrderItemRepository
|
| 28435 |
tejbeer |
1204 |
.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
|
| 26244 |
tejbeer |
1205 |
|
| 27900 |
tejbeer |
1206 |
LOGGER.info("brandwisesale" + brandwisesale);
|
| 27884 |
tejbeer |
1207 |
|
| 26244 |
tejbeer |
1208 |
Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
|
| 28435 |
tejbeer |
1209 |
fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
|
| 27900 |
tejbeer |
1210 |
brandwisesale.put("Accessories", accesoriesmtdsale.get(fofoId));
|
| 28272 |
tejbeer |
1211 |
|
| 27884 |
tejbeer |
1212 |
Map<String, Double> activatedImeisWithSellingPriceMTD = fofoOrderRepository
|
| 28435 |
tejbeer |
1213 |
.selectValueOfActivatedImeis(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId).stream()
|
|
|
1214 |
.collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
|
| 27900 |
tejbeer |
1215 |
|
| 27978 |
tejbeer |
1216 |
activatedImeisWithSellingPriceMTD.put("Lava", brandwisesale.get("Lava"));
|
|
|
1217 |
|
| 27884 |
tejbeer |
1218 |
Map<String, Double> activatedImeisWithSellingPriceLMTD = fofoOrderRepository
|
| 28435 |
tejbeer |
1219 |
.selectValueOfActivatedImeis(curDate.withDayOfMonth(1).minusMonths(1),
|
|
|
1220 |
curDate.with(LocalTime.MAX).minusMonths(1), fofoId)
|
|
|
1221 |
.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
|
| 26055 |
tejbeer |
1222 |
Map<String, Double> lmtdBrandWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
| 28435 |
tejbeer |
1223 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
|
| 27978 |
tejbeer |
1224 |
activatedImeisWithSellingPriceLMTD.put("Lava", lmtdBrandWiseSale.get("Lava"));
|
| 26055 |
tejbeer |
1225 |
|
| 26244 |
tejbeer |
1226 |
Map<Integer, Double> accesorieslmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
|
| 28435 |
tejbeer |
1227 |
fofoId, curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1),
|
|
|
1228 |
Optional.of(false));
|
| 27884 |
tejbeer |
1229 |
|
|
|
1230 |
lmtdBrandWiseSale.put("Accessories", accesorieslmtdsale.get(fofoId));
|
|
|
1231 |
|
| 26055 |
tejbeer |
1232 |
ChartModel cm = new ChartModel();
|
|
|
1233 |
|
| 28435 |
tejbeer |
1234 |
HashSet<String> labels = new HashSet<String>();
|
|
|
1235 |
labels.addAll(brandwisesale.keySet());
|
|
|
1236 |
labels.addAll(lmtdBrandWiseSale.keySet());
|
| 26055 |
tejbeer |
1237 |
|
| 28435 |
tejbeer |
1238 |
List<String> labelList = new ArrayList<>(labels);
|
| 27884 |
tejbeer |
1239 |
|
| 28435 |
tejbeer |
1240 |
List<Double> mtdActivatedImeisValues = new ArrayList<>();
|
| 27884 |
tejbeer |
1241 |
|
| 28435 |
tejbeer |
1242 |
List<Double> mtdValues = new ArrayList<>();
|
|
|
1243 |
List<Double> lmtdUnActivatedImeisValues = new ArrayList<>();
|
|
|
1244 |
List<Double> lmtdActivatedImeisValues = new ArrayList<>();
|
|
|
1245 |
List<Double> mtdUnActivatedImeisValues = new ArrayList<>();
|
|
|
1246 |
List<Double> lmtdValues = new ArrayList<>();
|
|
|
1247 |
for (String label : labelList) {
|
|
|
1248 |
mtdActivatedImeisValues.add(activatedImeisWithSellingPriceMTD.get(label) == null ? 0
|
|
|
1249 |
: activatedImeisWithSellingPriceMTD.get(label));
|
|
|
1250 |
lmtdActivatedImeisValues.add(activatedImeisWithSellingPriceLMTD.get(label) == null ? 0
|
|
|
1251 |
: activatedImeisWithSellingPriceLMTD.get(label));
|
| 26055 |
tejbeer |
1252 |
|
| 28435 |
tejbeer |
1253 |
mtdValues.add(brandwisesale.get(label) == null ? 0 : brandwisesale.get(label));
|
|
|
1254 |
if (brandwisesale.get(label) != null) {
|
|
|
1255 |
mtdUnActivatedImeisValues
|
|
|
1256 |
.add(brandwisesale.get(label) - (activatedImeisWithSellingPriceMTD.get(label) == null ? 0
|
|
|
1257 |
: activatedImeisWithSellingPriceMTD.get(label)));
|
|
|
1258 |
} else {
|
|
|
1259 |
mtdUnActivatedImeisValues.add(0.0);
|
|
|
1260 |
}
|
|
|
1261 |
if (lmtdBrandWiseSale.get(label) != null) {
|
|
|
1262 |
lmtdUnActivatedImeisValues
|
|
|
1263 |
.add(lmtdBrandWiseSale.get(label) - (activatedImeisWithSellingPriceLMTD.get(label) == null ? 0
|
|
|
1264 |
: activatedImeisWithSellingPriceLMTD.get(label)));
|
|
|
1265 |
} else {
|
|
|
1266 |
lmtdUnActivatedImeisValues.add(0.0);
|
|
|
1267 |
}
|
| 26055 |
tejbeer |
1268 |
|
| 28435 |
tejbeer |
1269 |
lmtdValues.add(lmtdBrandWiseSale.get(label) == null ? 0 : lmtdBrandWiseSale.get(label));
|
|
|
1270 |
}
|
|
|
1271 |
DatasetModel dsmtotal = new DatasetModel();
|
|
|
1272 |
dsmtotal.setLabel("MTD");
|
|
|
1273 |
dsmtotal.setBackgroundColor("blue");
|
|
|
1274 |
dsmtotal.setBorderColor("blue");
|
|
|
1275 |
dsmtotal.setData(mtdValues);
|
|
|
1276 |
dsmtotal.setStack("stack0");
|
|
|
1277 |
dsmtotal.setOrder(1);
|
| 26055 |
tejbeer |
1278 |
|
| 28435 |
tejbeer |
1279 |
DatasetModel dsmUnactivated = new DatasetModel();
|
|
|
1280 |
dsmUnactivated.setLabel("MTD Unactivated");
|
|
|
1281 |
dsmUnactivated.setBackgroundColor("red");
|
|
|
1282 |
dsmUnactivated.setBorderColor("red");
|
|
|
1283 |
dsmUnactivated.setData(mtdUnActivatedImeisValues);
|
|
|
1284 |
dsmUnactivated.setStack("stack0");
|
|
|
1285 |
dsmUnactivated.setOrder(1);
|
| 27884 |
tejbeer |
1286 |
|
| 28435 |
tejbeer |
1287 |
LOGGER.info("mtdValuesMoney" + mtdValues);
|
| 27884 |
tejbeer |
1288 |
|
| 28435 |
tejbeer |
1289 |
DatasetModel mtdActivatedImeis = new DatasetModel();
|
|
|
1290 |
mtdActivatedImeis.setLabel("MTD Activation");
|
|
|
1291 |
mtdActivatedImeis.setBorderColor("#00008b");
|
|
|
1292 |
mtdActivatedImeis.setData(mtdActivatedImeisValues);
|
|
|
1293 |
mtdActivatedImeis.setBackgroundColor("#00008b");
|
|
|
1294 |
mtdActivatedImeis.setStack("stack0");
|
|
|
1295 |
mtdActivatedImeis.setOrder(1);
|
| 27884 |
tejbeer |
1296 |
|
| 28435 |
tejbeer |
1297 |
DatasetModel lmtddsmtotal = new DatasetModel();
|
|
|
1298 |
lmtddsmtotal.setLabel("LMTD");
|
|
|
1299 |
lmtddsmtotal.setBackgroundColor("blue");
|
|
|
1300 |
lmtddsmtotal.setData(lmtdValues);
|
|
|
1301 |
lmtddsmtotal.setBorderColor("blue");
|
|
|
1302 |
lmtddsmtotal.setStack("stack1");
|
|
|
1303 |
lmtddsmtotal.setOrder(1);
|
| 27884 |
tejbeer |
1304 |
|
| 28435 |
tejbeer |
1305 |
DatasetModel lmtdUnActivated = new DatasetModel();
|
|
|
1306 |
lmtdUnActivated.setLabel("LMTD Unactivation");
|
|
|
1307 |
lmtdUnActivated.setBackgroundColor("red");
|
|
|
1308 |
lmtdUnActivated.setBorderColor("red");
|
|
|
1309 |
lmtdUnActivated.setData(lmtdUnActivatedImeisValues);
|
|
|
1310 |
lmtdUnActivated.setStack("stack1");
|
|
|
1311 |
lmtdUnActivated.setOrder(1);
|
| 27884 |
tejbeer |
1312 |
|
| 28435 |
tejbeer |
1313 |
DatasetModel LmtdActivatedImeis = new DatasetModel();
|
|
|
1314 |
LmtdActivatedImeis.setLabel("LMTD Activation");
|
|
|
1315 |
LmtdActivatedImeis.setBackgroundColor("#87ceeb");
|
|
|
1316 |
LmtdActivatedImeis.setBorderColor("#87ceeb");
|
|
|
1317 |
LmtdActivatedImeis.setData(lmtdActivatedImeisValues);
|
|
|
1318 |
LmtdActivatedImeis.setStack("stack1");
|
|
|
1319 |
LmtdActivatedImeis.setOrder(1);
|
| 27930 |
amit.gupta |
1320 |
|
| 28435 |
tejbeer |
1321 |
DatasetModel linemtdChart = new DatasetModel();
|
|
|
1322 |
linemtdChart.setLabel("MTD");
|
|
|
1323 |
linemtdChart.setBackgroundColor("#006400");
|
|
|
1324 |
linemtdChart.setBorderColor("#006400");
|
|
|
1325 |
linemtdChart.setData(mtdValues);
|
|
|
1326 |
linemtdChart.setType("line");
|
|
|
1327 |
linemtdChart.setOrder(2);
|
|
|
1328 |
linemtdChart.setFill("false");
|
| 27930 |
amit.gupta |
1329 |
|
| 28435 |
tejbeer |
1330 |
DatasetModel lineLmtdChart = new DatasetModel();
|
|
|
1331 |
lineLmtdChart.setLabel("LMTD");
|
|
|
1332 |
lineLmtdChart.setBackgroundColor("hotpink");
|
|
|
1333 |
lineLmtdChart.setBorderColor("hotpink");
|
|
|
1334 |
lineLmtdChart.setData(lmtdValues);
|
|
|
1335 |
lineLmtdChart.setType("line");
|
|
|
1336 |
lineLmtdChart.setOrder(3);
|
|
|
1337 |
lineLmtdChart.setFill("false");
|
| 27930 |
amit.gupta |
1338 |
|
| 28435 |
tejbeer |
1339 |
List<DatasetModel> datasets = new ArrayList<>();
|
|
|
1340 |
datasets.add(mtdActivatedImeis);
|
|
|
1341 |
datasets.add(dsmUnactivated);
|
|
|
1342 |
datasets.add(LmtdActivatedImeis);
|
|
|
1343 |
datasets.add(lmtdUnActivated);
|
|
|
1344 |
datasets.add(linemtdChart);
|
|
|
1345 |
datasets.add(lineLmtdChart);
|
| 27884 |
tejbeer |
1346 |
|
| 28435 |
tejbeer |
1347 |
DataModel dm = new DataModel();
|
|
|
1348 |
dm.setDatasets(datasets);
|
|
|
1349 |
dm.setLabels(labels);
|
| 27884 |
tejbeer |
1350 |
|
| 28435 |
tejbeer |
1351 |
Tooltips tooltips = new Tooltips();
|
|
|
1352 |
tooltips.setBodyFontSize(10);
|
|
|
1353 |
tooltips.setTitleFontSize(10);
|
|
|
1354 |
tooltips.setMode("index");
|
|
|
1355 |
tooltips.setIntersect(false);
|
| 26055 |
tejbeer |
1356 |
|
| 28435 |
tejbeer |
1357 |
HoverModel hover = new HoverModel();
|
|
|
1358 |
hover.setIntersect(false);
|
|
|
1359 |
hover.setMode("index");
|
| 26055 |
tejbeer |
1360 |
|
| 28435 |
tejbeer |
1361 |
LegendModel lm = new LegendModel();
|
|
|
1362 |
lm.setPosition("top");
|
| 26055 |
tejbeer |
1363 |
|
| 28435 |
tejbeer |
1364 |
TitleModel tm = new TitleModel();
|
|
|
1365 |
tm.setText("Brand Wise Sales");
|
|
|
1366 |
tm.setDisplay(true);
|
|
|
1367 |
tm.setFontSize(20);
|
|
|
1368 |
tm.setFontColor("#111");
|
| 27884 |
tejbeer |
1369 |
|
| 28435 |
tejbeer |
1370 |
List<Axis> xAxes = new ArrayList<>();
|
|
|
1371 |
Axis xAxis = new Axis();
|
|
|
1372 |
xAxis.setStacked(true);
|
|
|
1373 |
xAxes.add(xAxis);
|
| 27884 |
tejbeer |
1374 |
|
| 28435 |
tejbeer |
1375 |
List<Axis> yAxes = new ArrayList<>();
|
|
|
1376 |
Axis yAxis = new Axis();
|
|
|
1377 |
yAxis.setStacked(false);
|
|
|
1378 |
yAxes.add(yAxis);
|
| 27884 |
tejbeer |
1379 |
|
| 28435 |
tejbeer |
1380 |
ScalesModel sm = new ScalesModel();
|
|
|
1381 |
sm.setxAxes(xAxes);
|
| 26055 |
tejbeer |
1382 |
|
| 28435 |
tejbeer |
1383 |
OptionsModel om = new OptionsModel();
|
|
|
1384 |
om.setLegend(lm);
|
|
|
1385 |
om.setTitle(tm);
|
|
|
1386 |
om.setScales(sm);
|
|
|
1387 |
om.setHover(hover);
|
|
|
1388 |
om.setTooltips(tooltips);
|
| 26055 |
tejbeer |
1389 |
|
| 28435 |
tejbeer |
1390 |
cm.setType("bar");
|
|
|
1391 |
cm.setData(dm);
|
|
|
1392 |
cm.setOptions(om);
|
| 27884 |
tejbeer |
1393 |
|
| 28435 |
tejbeer |
1394 |
LOGGER.info("cm" + cm);
|
| 26055 |
tejbeer |
1395 |
|
| 28435 |
tejbeer |
1396 |
return cm;
|
| 26055 |
tejbeer |
1397 |
|
| 28435 |
tejbeer |
1398 |
}
|
|
|
1399 |
|
| 26418 |
tejbeer |
1400 |
private String adminPanel(int fofoId, String email, Model model) throws Exception {
|
| 26022 |
amit.gupta |
1401 |
List<Menu> menus = null;
|
| 26011 |
amit.gupta |
1402 |
try {
|
|
|
1403 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
1404 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
| 27545 |
tejbeer |
1405 |
Map<Integer, PartnerDetailModel> warehousePartnerDetailMap = null;
|
| 27628 |
tejbeer |
1406 |
ReporticoCacheTable rctSaholic = null;
|
|
|
1407 |
ReporticoCacheTable rctPartneStat = null;
|
|
|
1408 |
|
| 27509 |
tejbeer |
1409 |
Map<Integer, WarehouseWiseStockModel> warehouseStockMap = new HashMap<>();
|
| 27701 |
tejbeer |
1410 |
LinkedHashMap<Integer, WarehouseWiseStockModel> warehouseStockSortedMap = new LinkedHashMap<>();
|
|
|
1411 |
|
| 27509 |
tejbeer |
1412 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27539 |
tejbeer |
1413 |
LinkedHashMap<Integer, String> wm = new LinkedHashMap<Integer, String>();
|
| 27701 |
tejbeer |
1414 |
|
| 27670 |
tejbeer |
1415 |
Map<String, BrandWisePartnerSaleModel> partnersBrandSaleMap = null;
|
| 27594 |
tejbeer |
1416 |
List<BrandWisePartnerSaleModel> accessoriesBrandSales = null;
|
| 27701 |
tejbeer |
1417 |
|
| 27819 |
tejbeer |
1418 |
Map<AuthUser, Long> authUserTicketCount = null;
|
|
|
1419 |
|
| 27539 |
tejbeer |
1420 |
for (Map.Entry<Integer, String> entry : warehouseMap.entrySet()) {
|
|
|
1421 |
wm.put(entry.getKey(), entry.getValue());
|
|
|
1422 |
}
|
|
|
1423 |
|
|
|
1424 |
wm.put(0, "Total Values");
|
|
|
1425 |
long stockValue = 0;
|
|
|
1426 |
long stockQty = 0;
|
|
|
1427 |
long pendingIndent = 0;
|
| 27542 |
tejbeer |
1428 |
long tertiary = 0;
|
| 26418 |
tejbeer |
1429 |
|
| 27701 |
tejbeer |
1430 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 27727 |
tejbeer |
1431 |
|
| 27701 |
tejbeer |
1432 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
| 27727 |
tejbeer |
1433 |
if (emails.contains(authUser.getEmailId())) {
|
|
|
1434 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
| 27930 |
amit.gupta |
1435 |
LOGGER.info("fofoIds" + fofoIds);
|
| 27727 |
tejbeer |
1436 |
}
|
| 27556 |
tejbeer |
1437 |
|
| 27701 |
tejbeer |
1438 |
if (fofoIds != null) {
|
| 27539 |
tejbeer |
1439 |
|
| 27701 |
tejbeer |
1440 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
|
|
1441 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream()
|
|
|
1442 |
.collect(Collectors.groupingBy(FofoStore::getWarehouseId,
|
|
|
1443 |
Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
1444 |
// warehouseStock
|
|
|
1445 |
List<WarehouseWiseStockModel> warehouseStocks = saholicInventoryCISRepository
|
|
|
1446 |
.selectGroupByWarehouse(new ArrayList<>(warehouseIdFofoIdMap.keySet()));
|
|
|
1447 |
|
|
|
1448 |
warehouseStockMap = warehouseStocks.stream().collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
|
|
|
1449 |
|
|
|
1450 |
if (!warehouseStockMap.isEmpty()) {
|
|
|
1451 |
for (Entry<Integer, WarehouseWiseStockModel> warehouseStock : warehouseStockMap.entrySet()) {
|
|
|
1452 |
stockValue += warehouseStock.getValue().getStockValue();
|
|
|
1453 |
stockQty += warehouseStock.getValue().getStockQty();
|
|
|
1454 |
pendingIndent += warehouseStock.getValue().getPendingIndent();
|
|
|
1455 |
tertiary += warehouseStock.getValue().getTertiary();
|
| 27539 |
tejbeer |
1456 |
}
|
| 27701 |
tejbeer |
1457 |
WarehouseWiseStockModel ws = new WarehouseWiseStockModel();
|
|
|
1458 |
ws.setStockQty(stockQty);
|
|
|
1459 |
ws.setStockValue(stockValue);
|
|
|
1460 |
ws.setPendingIndent(pendingIndent);
|
|
|
1461 |
ws.setTertiary(tertiary);
|
|
|
1462 |
ws.setWarehouseId(0);
|
|
|
1463 |
warehouseStockMap.put(0, ws);
|
| 27591 |
tejbeer |
1464 |
|
| 27701 |
tejbeer |
1465 |
}
|
| 27670 |
tejbeer |
1466 |
|
| 27701 |
tejbeer |
1467 |
warehouseStockMap.entrySet().stream().sorted(Map.Entry.comparingByKey(Comparator.reverseOrder()))
|
|
|
1468 |
.forEachOrdered(x -> warehouseStockSortedMap.put(x.getKey(), x.getValue()));
|
| 27670 |
tejbeer |
1469 |
|
| 27701 |
tejbeer |
1470 |
rctSaholic = reporticoCacheTableRepository.selectByTableName("SaholicInventoryCIS");
|
|
|
1471 |
|
|
|
1472 |
// warehouseStock
|
|
|
1473 |
warehousePartnerDetailMap = this.getWarehousePartnerDetail(warehouseIdFofoIdMap);
|
|
|
1474 |
rctPartneStat = reporticoCacheTableRepository.selectByTableName("partnerStat");
|
|
|
1475 |
|
|
|
1476 |
partnersBrandSaleMap = fofoStoreRepository
|
|
|
1477 |
.selectGroupByBrandWarehousePartnerSale(new ArrayList<>(fofoIds)).stream()
|
|
|
1478 |
.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
|
|
|
1479 |
|
|
|
1480 |
List<BrandWiseUnbilledActivateStockModel> unbilledActivatedStock = fofoStoreRepository
|
|
|
1481 |
.selectUnbilledActivateStockGroupByBrand(new ArrayList<>(fofoIds));
|
|
|
1482 |
for (BrandWiseUnbilledActivateStockModel un : unbilledActivatedStock) {
|
|
|
1483 |
BrandWisePartnerSaleModel bpt = partnersBrandSaleMap.get(un.getBrand());
|
|
|
1484 |
if (bpt != null) {
|
|
|
1485 |
bpt.setAmtd(un.getUnbilledMtd());
|
|
|
1486 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
|
|
1487 |
} else {
|
|
|
1488 |
bpt = new BrandWisePartnerSaleModel();
|
|
|
1489 |
bpt.setBrand(un.getBrand());
|
|
|
1490 |
bpt.setAmtd(un.getUnbilledMtd());
|
|
|
1491 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
|
|
1492 |
bpt.setLms(0);
|
|
|
1493 |
bpt.setLmtd(0);
|
|
|
1494 |
bpt.setMtd(0);
|
|
|
1495 |
bpt.setMtdQty(0);
|
|
|
1496 |
bpt.setLmtd(0);
|
|
|
1497 |
bpt.setLmtdQty(0);
|
|
|
1498 |
partnersBrandSaleMap.put(un.getBrand(), bpt);
|
| 27670 |
tejbeer |
1499 |
}
|
| 26418 |
tejbeer |
1500 |
}
|
| 27701 |
tejbeer |
1501 |
accessoriesBrandSales = fofoStoreRepository
|
|
|
1502 |
.selectGroupByBrandAccesoriesWarehousePartnerSale(new ArrayList<>(fofoIds));
|
| 28272 |
tejbeer |
1503 |
Set<CustomRetailer> positionRetailers = fofoIds.stream()
|
|
|
1504 |
.map(x -> retailerService.getAllFofoRetailers().get(x)).filter(x -> x != null)
|
|
|
1505 |
.collect(Collectors.toSet());
|
| 27931 |
amit.gupta |
1506 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
|
|
1507 |
model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
|
|
|
1508 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
| 26418 |
tejbeer |
1509 |
}
|
|
|
1510 |
|
| 27819 |
tejbeer |
1511 |
if (positions.size() > 0) {
|
|
|
1512 |
if (positions.stream()
|
|
|
1513 |
.filter(x -> x.getEscalationType().equals(EscalationType.L3)
|
|
|
1514 |
|| x.getEscalationType().equals(EscalationType.L4)
|
|
|
1515 |
|| x.getEscalationType().equals(EscalationType.L5))
|
|
|
1516 |
.count() > 0) {
|
|
|
1517 |
authUserTicketCount = ticketRepository.selectAllAuthUserTicketCount(Optional.of(false));
|
|
|
1518 |
}
|
|
|
1519 |
}
|
|
|
1520 |
|
| 27415 |
tejbeer |
1521 |
if (Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in", "manish.tiwari@smartdukaan.com")
|
| 27701 |
tejbeer |
1522 |
.contains(email))
|
|
|
1523 |
|
|
|
1524 |
{
|
| 26029 |
amit.gupta |
1525 |
menus = menuRepository.selectAll();
|
|
|
1526 |
} else if (positions.size() > 0) {
|
| 27108 |
amit.gupta |
1527 |
if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L5)).count() > 0) {
|
| 26028 |
amit.gupta |
1528 |
menus = menuRepository.selectAll();
|
| 27893 |
tejbeer |
1529 |
} else {
|
|
|
1530 |
List<Integer> menuIds = menuCategoryRepository.selectAllByPositions(positions).stream()
|
|
|
1531 |
.map(x -> x.getMenuId()).collect(Collectors.toList());
|
|
|
1532 |
if (menuIds.size() > 0) {
|
|
|
1533 |
menus = menuRepository.selectAllByIds(menuIds);
|
| 26028 |
amit.gupta |
1534 |
}
|
| 26022 |
amit.gupta |
1535 |
}
|
| 27930 |
amit.gupta |
1536 |
}
|
| 28272 |
tejbeer |
1537 |
/*
|
|
|
1538 |
* List<Position> salesPositions = positions.stream() .filter(x ->
|
|
|
1539 |
* x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES)
|
|
|
1540 |
* .collect(Collectors.toList()); if (salesPositions.size() > 0) {
|
|
|
1541 |
* Set<CustomRetailer> positionRetailers = new HashSet<>();
|
|
|
1542 |
* csService.getPositionCustomRetailerMap(salesPositions).values().forEach(
|
|
|
1543 |
* customRetailers -> { positionRetailers.addAll(customRetailers); }); }
|
|
|
1544 |
*/
|
|
|
1545 |
if (fofoIds == null) {
|
|
|
1546 |
List<Position> warehousePositions = positions.stream()
|
|
|
1547 |
.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_WAREHOUSE)
|
| 26090 |
amit.gupta |
1548 |
.collect(Collectors.toList());
|
| 28272 |
tejbeer |
1549 |
if (warehousePositions.size() > 0) {
|
| 26090 |
amit.gupta |
1550 |
Set<CustomRetailer> positionRetailers = new HashSet<>();
|
| 28272 |
tejbeer |
1551 |
csService.getPositionCustomRetailerMap(warehousePositions).values().forEach(customRetailers -> {
|
| 26090 |
amit.gupta |
1552 |
positionRetailers.addAll(customRetailers);
|
|
|
1553 |
});
|
| 28272 |
tejbeer |
1554 |
model.addAttribute("reporticoProjectMap", ReporticoProject.warehouseReporticoMap);
|
|
|
1555 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
|
|
1556 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
| 26090 |
amit.gupta |
1557 |
}
|
| 28272 |
tejbeer |
1558 |
}
|
|
|
1559 |
model.addAttribute("authId", authUser.getId());
|
| 26028 |
amit.gupta |
1560 |
|
| 27628 |
tejbeer |
1561 |
model.addAttribute("rctPartneStat", rctPartneStat);
|
|
|
1562 |
|
|
|
1563 |
model.addAttribute("reporticoDate", rctSaholic);
|
| 27545 |
tejbeer |
1564 |
model.addAttribute("warehousePartnerDetailMap", warehousePartnerDetailMap);
|
| 27539 |
tejbeer |
1565 |
model.addAttribute("warehouseMap", wm);
|
| 27819 |
tejbeer |
1566 |
|
|
|
1567 |
model.addAttribute("authUserTicketCount", authUserTicketCount);
|
| 27701 |
tejbeer |
1568 |
model.addAttribute("warehouseStockMap", warehouseStockSortedMap);
|
| 27670 |
tejbeer |
1569 |
model.addAttribute("brandSalesMap", partnersBrandSaleMap);
|
| 27556 |
tejbeer |
1570 |
|
| 27594 |
tejbeer |
1571 |
model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
|
|
|
1572 |
|
| 26012 |
amit.gupta |
1573 |
} catch (ProfitMandiBusinessException e) {
|
| 26011 |
amit.gupta |
1574 |
}
|
| 26028 |
amit.gupta |
1575 |
List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
|
| 26422 |
tejbeer |
1576 |
LOGGER.info("menu" + menuList);
|
| 26022 |
amit.gupta |
1577 |
model.addAttribute("menu", menuList);
|
| 26012 |
amit.gupta |
1578 |
return "admin";
|
|
|
1579 |
}
|
|
|
1580 |
|
| 26468 |
amit.gupta |
1581 |
@RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
|
| 26418 |
tejbeer |
1582 |
public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId)
|
|
|
1583 |
throws Exception {
|
|
|
1584 |
|
|
|
1585 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
| 26963 |
amit.gupta |
1586 |
Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
|
| 26418 |
tejbeer |
1587 |
|
| 26468 |
amit.gupta |
1588 |
Map<Integer, PartnerDetailModel> fofoIdAndallValues = partnerStatsService.getAllPartnerStats();
|
|
|
1589 |
if (authId != 0) {
|
|
|
1590 |
List<Integer> fofoIds = pp.get(authId);
|
|
|
1591 |
fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
|
|
|
1592 |
.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
| 26474 |
amit.gupta |
1593 |
} else {
|
| 26418 |
tejbeer |
1594 |
}
|
|
|
1595 |
|
|
|
1596 |
model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
|
|
|
1597 |
model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
|
|
|
1598 |
|
|
|
1599 |
return "auth_user_partner_detail";
|
| 26468 |
amit.gupta |
1600 |
}
|
| 26418 |
tejbeer |
1601 |
|
| 27545 |
tejbeer |
1602 |
@RequestMapping(value = "/getWarehousePartners", method = RequestMethod.GET)
|
|
|
1603 |
public String warehousePartnersDetail(HttpServletRequest request, Model model, @RequestParam int warehouseId)
|
|
|
1604 |
throws Exception {
|
| 27701 |
tejbeer |
1605 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1606 |
String email = loginDetails.getEmailId();
|
|
|
1607 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1608 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 27545 |
tejbeer |
1609 |
|
| 27701 |
tejbeer |
1610 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
|
|
1611 |
.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
|
|
|
1612 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
1613 |
|
| 27545 |
tejbeer |
1614 |
Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
|
| 27628 |
tejbeer |
1615 |
Map<Integer, PartnerDetailModel> fofoIdAndallValues = this.getPartnersStatDataFromFile();
|
| 27545 |
tejbeer |
1616 |
if (warehouseId != 0) {
|
| 27701 |
tejbeer |
1617 |
List<Integer> fofoIds = warehouseIdFofoIdMap.get(warehouseId);
|
|
|
1618 |
/*
|
|
|
1619 |
* List<Integer> fofoIds =
|
|
|
1620 |
* fofoStoreRepository.selectActivePartnerByWarehouse(warehouseId).stream()
|
|
|
1621 |
* .map(x -> x.getId()).collect(Collectors.toList());
|
|
|
1622 |
*/
|
| 27545 |
tejbeer |
1623 |
fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
|
|
|
1624 |
.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
|
|
1625 |
} else {
|
| 27701 |
tejbeer |
1626 |
fofoIdAndallValues = fofoIdAndallValues.entrySet().stream()
|
|
|
1627 |
.filter(x -> new ArrayList<>(authfofoIds).contains(x.getKey()))
|
|
|
1628 |
.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
|
| 27545 |
tejbeer |
1629 |
}
|
|
|
1630 |
|
|
|
1631 |
model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
|
|
|
1632 |
model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
|
|
|
1633 |
|
|
|
1634 |
return "auth_user_partner_detail";
|
|
|
1635 |
}
|
|
|
1636 |
|
| 27509 |
tejbeer |
1637 |
@RequestMapping(value = "/getWarehouseWiseBrandStock", method = RequestMethod.GET)
|
| 27701 |
tejbeer |
1638 |
public String getWarehouseWiseBrandStock(HttpServletRequest request, Model model,
|
|
|
1639 |
@RequestParam List<Integer> warehouseId) throws Exception {
|
|
|
1640 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1641 |
String email = loginDetails.getEmailId();
|
|
|
1642 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1643 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 27509 |
tejbeer |
1644 |
|
| 27701 |
tejbeer |
1645 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
|
|
1646 |
.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
|
|
|
1647 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
|
|
1648 |
List<WarehouseWiseBrandStockModel> warehouseWiseBrandStock = new ArrayList<>();
|
|
|
1649 |
if (!warehouseId.contains(0)) {
|
|
|
1650 |
warehouseWiseBrandStock = saholicInventoryCISRepository.selectGroupByWarehouseAndBrand(warehouseId);
|
|
|
1651 |
} else {
|
|
|
1652 |
LOGGER.info("warehouseIdFofoIdMap" + warehouseIdFofoIdMap.keySet());
|
|
|
1653 |
warehouseWiseBrandStock = saholicInventoryCISRepository
|
|
|
1654 |
.selectGroupByWarehouseAndBrand(new ArrayList<>(warehouseIdFofoIdMap.keySet()));
|
|
|
1655 |
|
|
|
1656 |
}
|
| 27542 |
tejbeer |
1657 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27509 |
tejbeer |
1658 |
model.addAttribute("warehouseWiseBrandStock", warehouseWiseBrandStock);
|
| 27542 |
tejbeer |
1659 |
model.addAttribute("warehouseId", warehouseId);
|
| 27509 |
tejbeer |
1660 |
model.addAttribute("warehouseMap", warehouseMap);
|
| 27660 |
tejbeer |
1661 |
|
| 27509 |
tejbeer |
1662 |
return "warehouse_brand_stock";
|
|
|
1663 |
}
|
|
|
1664 |
|
| 27529 |
tejbeer |
1665 |
@RequestMapping(value = "/getWarehouseWiseData", method = RequestMethod.GET)
|
|
|
1666 |
public String getWarehouseWiseData(HttpServletRequest request, Model model) throws Exception {
|
|
|
1667 |
inventoryService.getItemAvailabilityAndIndent();
|
|
|
1668 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
1669 |
return "response";
|
|
|
1670 |
}
|
|
|
1671 |
|
| 27701 |
tejbeer |
1672 |
public Map<Integer, PartnerDetailModel> getWarehousePartnerDetail(Map<Integer, List<Integer>> warehousePartnerMap)
|
|
|
1673 |
throws Exception {
|
| 27628 |
tejbeer |
1674 |
|
|
|
1675 |
Map<Integer, PartnerDetailModel> warehouseIdAndallValues = new LinkedHashMap<>();
|
| 27701 |
tejbeer |
1676 |
// Map<Integer, List<FofoStore>> warehousePartnerMap =
|
|
|
1677 |
// fofoStoreRepository.getWarehousePartnerMap();
|
| 27628 |
tejbeer |
1678 |
Map<Integer, PartnerDetailModel> partnerStats = this.getPartnersStatDataFromFile();
|
| 27701 |
tejbeer |
1679 |
List<Integer> allfofoIds = new ArrayList<>();
|
| 27628 |
tejbeer |
1680 |
if (partnerStats != null) {
|
| 27701 |
tejbeer |
1681 |
for (Entry<Integer, List<Integer>> warehouse : warehousePartnerMap.entrySet()) {
|
|
|
1682 |
List<Integer> fofoIds = warehouse.getValue().stream().map(x -> x).collect(Collectors.toList());
|
|
|
1683 |
allfofoIds.addAll(fofoIds);
|
| 27628 |
tejbeer |
1684 |
List<PartnerDetailModel> partnerDetails = fofoIds.stream().map(x -> partnerStats.get(x))
|
|
|
1685 |
.collect(Collectors.toList());
|
| 27634 |
tejbeer |
1686 |
if (partnerDetails != null && !partnerDetails.isEmpty()) {
|
|
|
1687 |
PartnerDetailModel partnerDetailModel = partnerStatsService.getAggregateStats(partnerDetails);
|
|
|
1688 |
warehouseIdAndallValues.put(warehouse.getKey(), partnerDetailModel);
|
|
|
1689 |
}
|
| 27628 |
tejbeer |
1690 |
|
|
|
1691 |
}
|
| 27701 |
tejbeer |
1692 |
List<PartnerDetailModel> allPartnerDetails = allfofoIds.stream().map(x -> partnerStats.get(x))
|
|
|
1693 |
.collect(Collectors.toList());
|
|
|
1694 |
LOGGER.info("allPartnerDetails" + allPartnerDetails);
|
| 27628 |
tejbeer |
1695 |
PartnerDetailModel partnerDetailModel = partnerStatsService
|
| 27701 |
tejbeer |
1696 |
.getAggregateStats(new ArrayList<>(allPartnerDetails));
|
| 27628 |
tejbeer |
1697 |
warehouseIdAndallValues.put(0, partnerDetailModel);
|
|
|
1698 |
}
|
|
|
1699 |
return warehouseIdAndallValues;
|
|
|
1700 |
}
|
|
|
1701 |
|
|
|
1702 |
@RequestMapping(value = "/getPartnersStatData", method = RequestMethod.GET)
|
|
|
1703 |
public String getPartnersStatData(HttpServletRequest request, Model model) throws Exception {
|
|
|
1704 |
Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
|
|
|
1705 |
ObjectOutputStream oos = null;
|
|
|
1706 |
FileOutputStream fout = null;
|
|
|
1707 |
try {
|
|
|
1708 |
fout = new FileOutputStream("/tmp/partnerStat.tmp", false);
|
|
|
1709 |
oos = new ObjectOutputStream(fout);
|
|
|
1710 |
oos.writeObject(partnerStats);
|
|
|
1711 |
|
|
|
1712 |
} catch (Exception ex) {
|
|
|
1713 |
ex.printStackTrace();
|
|
|
1714 |
} finally {
|
|
|
1715 |
if (oos != null) {
|
|
|
1716 |
oos.close();
|
|
|
1717 |
}
|
|
|
1718 |
}
|
|
|
1719 |
ReporticoCacheTable rct = reporticoCacheTableRepository.selectByTableName("partnerStat");
|
|
|
1720 |
if (rct == null) {
|
|
|
1721 |
rct = new ReporticoCacheTable();
|
|
|
1722 |
rct.setTableName("partnerStat");
|
|
|
1723 |
|
|
|
1724 |
}
|
|
|
1725 |
rct.setLastCreatedTimestamp(LocalDateTime.now());
|
|
|
1726 |
reporticoCacheTableRepository.persist(rct);
|
|
|
1727 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
1728 |
return "response";
|
|
|
1729 |
}
|
|
|
1730 |
|
|
|
1731 |
public Map<Integer, PartnerDetailModel> getPartnersStatDataFromFile() throws Exception {
|
|
|
1732 |
ObjectInputStream objectinputstream = null;
|
|
|
1733 |
Map<Integer, PartnerDetailModel> partnerStat = null;
|
|
|
1734 |
try {
|
|
|
1735 |
FileInputStream streamIn = new FileInputStream("/tmp/partnerStat.tmp");
|
|
|
1736 |
objectinputstream = new ObjectInputStream(streamIn);
|
|
|
1737 |
partnerStat = (Map<Integer, PartnerDetailModel>) objectinputstream.readObject();
|
|
|
1738 |
|
|
|
1739 |
LOGGER.info("partnerStat" + partnerStat);
|
|
|
1740 |
objectinputstream.close();
|
|
|
1741 |
|
|
|
1742 |
} catch (Exception e) {
|
|
|
1743 |
LOGGER.info("exceptionddd" + e);
|
|
|
1744 |
|
|
|
1745 |
e.printStackTrace();
|
|
|
1746 |
|
|
|
1747 |
} finally {
|
|
|
1748 |
if (objectinputstream != null) {
|
|
|
1749 |
objectinputstream.close();
|
|
|
1750 |
LOGGER.info("clofddd" + partnerStat);
|
|
|
1751 |
|
|
|
1752 |
}
|
|
|
1753 |
}
|
|
|
1754 |
return partnerStat;
|
|
|
1755 |
|
|
|
1756 |
}
|
|
|
1757 |
|
| 27539 |
tejbeer |
1758 |
@RequestMapping(value = "/getWarehouseWiseBrandAndCategory", method = RequestMethod.GET)
|
|
|
1759 |
public String getWarehouseWiseBrandAndCategory(HttpServletRequest request, Model model,
|
| 27538 |
tejbeer |
1760 |
@RequestParam List<Integer> warehouseId, @RequestParam List<String> brands, @RequestParam String category)
|
|
|
1761 |
throws Exception {
|
| 27509 |
tejbeer |
1762 |
|
|
|
1763 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27529 |
tejbeer |
1764 |
List<String> listbrands = saholicInventoryCISRepository.selectAllBrand();
|
| 27538 |
tejbeer |
1765 |
List<String> listCategory = saholicInventoryCISRepository.selectAllSubCategory();
|
| 27539 |
tejbeer |
1766 |
|
| 27509 |
tejbeer |
1767 |
model.addAttribute("warehouseMap", warehouseMap);
|
| 27529 |
tejbeer |
1768 |
model.addAttribute("brands", listbrands);
|
| 27538 |
tejbeer |
1769 |
model.addAttribute("listCategory", listCategory);
|
|
|
1770 |
|
| 27529 |
tejbeer |
1771 |
model.addAttribute("selectedBrand", brands);
|
| 27538 |
tejbeer |
1772 |
model.addAttribute("selectedWarehouse", warehouseId);
|
| 27539 |
tejbeer |
1773 |
model.addAttribute("selectedCategory", category);
|
|
|
1774 |
|
| 27509 |
tejbeer |
1775 |
return "warehouse_brand_item_stock";
|
|
|
1776 |
}
|
|
|
1777 |
|
| 27538 |
tejbeer |
1778 |
@RequestMapping(value = "/getWarehouseWiseItemStock", method = RequestMethod.GET)
|
|
|
1779 |
public String getWarehouseWiseItemStock(HttpServletRequest request, Model model,
|
|
|
1780 |
@RequestParam List<Integer> warehouseId, @RequestParam List<String> brands, @RequestParam String category)
|
|
|
1781 |
throws Exception {
|
| 27539 |
tejbeer |
1782 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1783 |
if (warehouseId.contains(0)) {
|
|
|
1784 |
warehouseId.addAll(warehouseMap.keySet());
|
|
|
1785 |
}
|
| 27538 |
tejbeer |
1786 |
List<WarehouseWiseitemStockModel> warehouseWiseItemStock = saholicInventoryCISRepository
|
|
|
1787 |
.selectWarehouseItemStock(warehouseId, brands, category);
|
| 27539 |
tejbeer |
1788 |
|
| 27538 |
tejbeer |
1789 |
model.addAttribute("warehouseWiseItemStock", warehouseWiseItemStock);
|
|
|
1790 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1791 |
return "warehouse_item_details";
|
|
|
1792 |
}
|
|
|
1793 |
|
| 26114 |
amit.gupta |
1794 |
private String getWarehouses(Set<CustomRetailer> positionRetailers) {
|
|
|
1795 |
Map<Integer, String> warehouses = new HashMap<>();
|
| 26222 |
tejbeer |
1796 |
positionRetailers.stream().forEach(x -> {
|
|
|
1797 |
if (x.getWarehouseId() != 0) {
|
| 26171 |
amit.gupta |
1798 |
warehouses.put(x.getWarehouseId(), ProfitMandiConstants.WAREHOUSE_MAP.get(x.getWarehouseId()));
|
|
|
1799 |
}
|
|
|
1800 |
});
|
| 26114 |
amit.gupta |
1801 |
return gson.toJson(warehouses);
|
|
|
1802 |
|
|
|
1803 |
}
|
|
|
1804 |
|
| 27556 |
tejbeer |
1805 |
@RequestMapping(value = "/getWarehouseWiseBrandPartnerSale", method = RequestMethod.GET)
|
| 27591 |
tejbeer |
1806 |
public String getWarehouseWiseBrandPartnerSale(HttpServletRequest request, Model model, @RequestParam String brand)
|
|
|
1807 |
throws Exception {
|
| 27701 |
tejbeer |
1808 |
|
|
|
1809 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1810 |
String email = loginDetails.getEmailId();
|
|
|
1811 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1812 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
|
|
1813 |
|
| 27670 |
tejbeer |
1814 |
Map<Integer, WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
|
| 27701 |
tejbeer |
1815 |
.selectGroupByWarehouseBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds)).stream()
|
| 27670 |
tejbeer |
1816 |
.collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
|
|
|
1817 |
|
|
|
1818 |
List<WarehouseWiseBrandUnbilledActivatedModel> unbilledStock = fofoStoreRepository
|
| 27701 |
tejbeer |
1819 |
.selectUnbilledActivateStockGroupByWarehouse(brand, new ArrayList<>(authfofoIds));
|
| 27670 |
tejbeer |
1820 |
|
|
|
1821 |
for (WarehouseWiseBrandUnbilledActivatedModel un : unbilledStock) {
|
|
|
1822 |
WarehouseWiseBrandSaleModel bpt = warehouseWiseBrandPartnerSales.get(un.getWarehouseId());
|
|
|
1823 |
if (bpt != null) {
|
|
|
1824 |
bpt.setAmtd(un.getUnbilledMtd());
|
| 27676 |
tejbeer |
1825 |
bpt.setUamtdQty(un.getUnbilledQty());
|
| 27670 |
tejbeer |
1826 |
} else {
|
|
|
1827 |
bpt = new WarehouseWiseBrandSaleModel();
|
|
|
1828 |
bpt.setWarehouseId(un.getWarehouseId());
|
|
|
1829 |
bpt.setAmtd(un.getUnbilledMtd());
|
| 27677 |
tejbeer |
1830 |
bpt.setUamtdQty(un.getUnbilledQty());
|
| 27670 |
tejbeer |
1831 |
bpt.setLms(0);
|
|
|
1832 |
bpt.setLmtd(0);
|
|
|
1833 |
bpt.setMtd(0);
|
|
|
1834 |
bpt.setMtdQty(0);
|
|
|
1835 |
bpt.setLmtd(0);
|
|
|
1836 |
bpt.setLmtdQty(0);
|
|
|
1837 |
warehouseWiseBrandPartnerSales.put(un.getWarehouseId(), bpt);
|
|
|
1838 |
}
|
|
|
1839 |
}
|
| 27556 |
tejbeer |
1840 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27591 |
tejbeer |
1841 |
|
|
|
1842 |
Set<String> brands = inventoryService.getAllTagListingBrands();
|
|
|
1843 |
model.addAttribute("warehouseWiseBrandPartnerSales", warehouseWiseBrandPartnerSales);
|
| 27556 |
tejbeer |
1844 |
model.addAttribute("warehouseMap", warehouseMap);
|
| 27591 |
tejbeer |
1845 |
model.addAttribute("brands", brands);
|
|
|
1846 |
model.addAttribute("selectedbrand", brand);
|
|
|
1847 |
return "warehousewise_brand_partners_sale";
|
| 27556 |
tejbeer |
1848 |
}
|
|
|
1849 |
|
| 27594 |
tejbeer |
1850 |
@RequestMapping(value = "/getWarehouseWiseAccesoriesBrandPartnerSale", method = RequestMethod.GET)
|
|
|
1851 |
public String getWarehouseWiseAccesoriesBrandPartnerSale(HttpServletRequest request, Model model,
|
|
|
1852 |
@RequestParam String brand) throws Exception {
|
| 27701 |
tejbeer |
1853 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1854 |
String email = loginDetails.getEmailId();
|
|
|
1855 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1856 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 27594 |
tejbeer |
1857 |
List<WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
|
| 27701 |
tejbeer |
1858 |
.selectGroupByWarehouseAccesoriesBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds));
|
| 27594 |
tejbeer |
1859 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1860 |
|
|
|
1861 |
Set<String> brands = inventoryService.getAllTagListingBrands();
|
|
|
1862 |
model.addAttribute("warehouseWiseBrandPartnerSales", warehouseWiseBrandPartnerSales);
|
|
|
1863 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1864 |
model.addAttribute("brands", brands);
|
|
|
1865 |
model.addAttribute("selectedbrand", brand);
|
|
|
1866 |
return "warehousewise_accessoriesbrand_sale";
|
|
|
1867 |
}
|
|
|
1868 |
|
| 27556 |
tejbeer |
1869 |
@RequestMapping(value = "/getWarehouseBrandWiseItemSale", method = RequestMethod.GET)
|
|
|
1870 |
public String getWarehouseBrandWiseItemSale(HttpServletRequest request, Model model,
|
|
|
1871 |
@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
|
|
1872 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27701 |
tejbeer |
1873 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1874 |
String email = loginDetails.getEmailId();
|
|
|
1875 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1876 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 27670 |
tejbeer |
1877 |
Map<Integer, WarehouseBrandWiseItemSaleModel> branditemSalesMap = fofoStoreRepository
|
| 27701 |
tejbeer |
1878 |
.selectWarehouseBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds)).stream()
|
| 27670 |
tejbeer |
1879 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
|
|
1880 |
|
|
|
1881 |
List<WarehouseBrandItemUnbilledActivatedModel> unbilledItems = fofoStoreRepository
|
| 27701 |
tejbeer |
1882 |
.selectWarehouseBrandItemUnbilledActivateStock(warehouseId, brand, new ArrayList<>(authfofoIds));
|
| 27670 |
tejbeer |
1883 |
|
|
|
1884 |
for (WarehouseBrandItemUnbilledActivatedModel un : unbilledItems) {
|
|
|
1885 |
WarehouseBrandWiseItemSaleModel bpt = branditemSalesMap.get(un.getItemId());
|
|
|
1886 |
if (bpt != null) {
|
|
|
1887 |
bpt.setAmtd(un.getAmtd());
|
| 27676 |
tejbeer |
1888 |
bpt.setUamtdQty(un.getUnmtdQty());
|
| 27670 |
tejbeer |
1889 |
} else {
|
|
|
1890 |
bpt = new WarehouseBrandWiseItemSaleModel();
|
|
|
1891 |
bpt.setWarehouseId(un.getWarehouseId());
|
|
|
1892 |
bpt.setItemId(un.getItemId());
|
|
|
1893 |
bpt.setAmtd(un.getAmtd());
|
| 27677 |
tejbeer |
1894 |
bpt.setUamtdQty(un.getUnmtdQty());
|
| 27670 |
tejbeer |
1895 |
bpt.setBrand(un.getBrand());
|
|
|
1896 |
bpt.setModelName(un.getModelName());
|
|
|
1897 |
bpt.setModelNumber(un.getModelNumber());
|
|
|
1898 |
bpt.setColor(un.getColor());
|
|
|
1899 |
bpt.setLms(0);
|
|
|
1900 |
bpt.setLmtd(0);
|
|
|
1901 |
bpt.setMtd(0);
|
|
|
1902 |
bpt.setMtdQty(0);
|
|
|
1903 |
bpt.setLmtd(0);
|
|
|
1904 |
bpt.setLmtdQty(0);
|
|
|
1905 |
branditemSalesMap.put(un.getItemId(), bpt);
|
|
|
1906 |
}
|
|
|
1907 |
}
|
|
|
1908 |
model.addAttribute("branditemSales", branditemSalesMap);
|
| 27556 |
tejbeer |
1909 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1910 |
return "warehouse_partner_itemwise_sale";
|
|
|
1911 |
}
|
|
|
1912 |
|
| 27594 |
tejbeer |
1913 |
@RequestMapping(value = "/getWarehouseAccesoriesBrandWiseItemSale", method = RequestMethod.GET)
|
|
|
1914 |
public String getWarehouseAccesoriesBrandWiseItemSale(HttpServletRequest request, Model model,
|
|
|
1915 |
@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
|
|
1916 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27701 |
tejbeer |
1917 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1918 |
String email = loginDetails.getEmailId();
|
|
|
1919 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
1920 |
Set<Integer> authfofoIds = storeGuyMap.get(email);
|
| 27594 |
tejbeer |
1921 |
List<WarehouseBrandWiseItemSaleModel> branditemSales = fofoStoreRepository
|
| 27701 |
tejbeer |
1922 |
.selectWarehouseAccesoriesBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds));
|
| 27594 |
tejbeer |
1923 |
model.addAttribute("branditemSales", branditemSales);
|
|
|
1924 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1925 |
return "warehouse_accessories_itemwsie_sale";
|
|
|
1926 |
}
|
|
|
1927 |
|
| 26012 |
amit.gupta |
1928 |
private List<Menu> prepareMenu(List<Menu> menus) {
|
|
|
1929 |
List<Menu> returnMenu = new ArrayList<>();
|
|
|
1930 |
Map<Menu, List<Menu>> subMenuMap = new HashMap<Menu, List<Menu>>();
|
|
|
1931 |
for (Menu menu : menus) {
|
|
|
1932 |
if (menu.get_parent() == null) {
|
| 26014 |
amit.gupta |
1933 |
if (!subMenuMap.containsKey(menu)) {
|
| 26012 |
amit.gupta |
1934 |
subMenuMap.put(menu, new ArrayList<>());
|
| 26011 |
amit.gupta |
1935 |
}
|
|
|
1936 |
} else {
|
| 26012 |
amit.gupta |
1937 |
Menu parentMenu = menu.get_parent();
|
|
|
1938 |
if (!subMenuMap.containsKey(parentMenu)) {
|
|
|
1939 |
subMenuMap.put(parentMenu, new ArrayList<>());
|
| 26011 |
amit.gupta |
1940 |
}
|
| 26012 |
amit.gupta |
1941 |
subMenuMap.get(parentMenu).add(menu);
|
| 26011 |
amit.gupta |
1942 |
}
|
|
|
1943 |
}
|
| 26012 |
amit.gupta |
1944 |
subMenuMap.entrySet().stream().forEach(entry -> {
|
|
|
1945 |
entry.getKey().setSubMenus(entry.getValue());
|
|
|
1946 |
returnMenu.add(entry.getKey());
|
|
|
1947 |
});
|
|
|
1948 |
return returnMenu;
|
| 26005 |
amit.gupta |
1949 |
}
|
|
|
1950 |
|
| 24288 |
amit.gupta |
1951 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
1952 |
private boolean hasGift(int fofoId) {
|
|
|
1953 |
try {
|
| 24288 |
amit.gupta |
1954 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
1955 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
1956 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1957 |
return false;
|
|
|
1958 |
}
|
|
|
1959 |
}
|
| 24288 |
amit.gupta |
1960 |
|
| 22354 |
ashik.ali |
1961 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 23923 |
amit.gupta |
1962 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 22354 |
ashik.ali |
1963 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
1964 |
return "contact-us";
|
|
|
1965 |
}
|
| 23923 |
amit.gupta |
1966 |
|
| 25649 |
tejbeer |
1967 |
@RequestMapping(value = "/notifications", method = RequestMethod.GET)
|
| 25683 |
tejbeer |
1968 |
public String getNotificationsWithType(HttpServletRequest request,
|
|
|
1969 |
@RequestParam(required = false) MessageType messageType,
|
| 25649 |
tejbeer |
1970 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
1971 |
@RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
|
|
|
1972 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26060 |
tejbeer |
1973 |
int userId = 0;
|
|
|
1974 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
1975 |
if (isAdmin) {
|
|
|
1976 |
userId = loginDetails.getFofoId();
|
|
|
1977 |
} else {
|
|
|
1978 |
userId = userAccountRepository.selectUserIdByRetailerId(loginDetails.getFofoId());
|
|
|
1979 |
}
|
| 25683 |
tejbeer |
1980 |
List<Notification> notifications = null;
|
|
|
1981 |
|
| 26086 |
tejbeer |
1982 |
List<NotificationCampaign> notificationCampaigns = notificationCampaignRepository.getNotifications(messageType,
|
|
|
1983 |
userId, offset, limit);
|
|
|
1984 |
LOGGER.info("messageType" + messageType);
|
|
|
1985 |
notifications = getNotifications(notificationCampaigns, messageType);
|
|
|
1986 |
|
| 25683 |
tejbeer |
1987 |
model.addAttribute("notifications", notifications);
|
|
|
1988 |
|
|
|
1989 |
LOGGER.info("notifications" + notifications);
|
|
|
1990 |
return "notification-template";
|
|
|
1991 |
}
|
|
|
1992 |
|
|
|
1993 |
public List<Notification> getNotifications(List<NotificationCampaign> nc, MessageType messageType)
|
|
|
1994 |
throws ProfitMandiBusinessException {
|
|
|
1995 |
List<Notification> notifications = new ArrayList<>();
|
|
|
1996 |
Document document = null;
|
|
|
1997 |
if (messageType != null) {
|
|
|
1998 |
for (NotificationCampaign notificationCampaign : nc) {
|
|
|
1999 |
if (notificationCampaign.getMessageType() == messageType) {
|
| 25649 |
tejbeer |
2000 |
Notification ns = new Notification();
|
|
|
2001 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
|
|
2002 |
SimpleCampaignParams.class);
|
|
|
2003 |
Campaign campaign = new SimpleCampaign(scp);
|
|
|
2004 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
|
|
2005 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
|
|
2006 |
ns.setType(campaign.getType());
|
|
|
2007 |
ns.setMessage(campaign.getMessage());
|
|
|
2008 |
ns.setTitle(campaign.getTitle());
|
| 25651 |
tejbeer |
2009 |
if (notificationCampaign.getDocumentId() != null) {
|
|
|
2010 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
|
|
2011 |
ns.setDocumentName(document.getDisplayName());
|
|
|
2012 |
}
|
| 25683 |
tejbeer |
2013 |
ns.setUrl(campaign.getUrl());
|
| 25649 |
tejbeer |
2014 |
ns.setShowImage(campaign.getShowImage());
|
|
|
2015 |
ns.setImageUrl(campaign.getImageUrl());
|
| 25683 |
tejbeer |
2016 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
|
|
2017 |
ns.setMessageType(notificationCampaign.getMessageType());
|
| 25649 |
tejbeer |
2018 |
ns.setCreated(
|
|
|
2019 |
notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30))
|
|
|
2020 |
* 1000);
|
|
|
2021 |
if (LocalDateTime.now().isAfter(expire)) {
|
|
|
2022 |
ns.setExpired(true);
|
|
|
2023 |
} else {
|
|
|
2024 |
ns.setExpired(false);
|
|
|
2025 |
}
|
|
|
2026 |
notifications.add(ns);
|
|
|
2027 |
}
|
|
|
2028 |
}
|
| 25683 |
tejbeer |
2029 |
} else {
|
|
|
2030 |
for (NotificationCampaign notificationCampaign : nc) {
|
|
|
2031 |
|
|
|
2032 |
Notification ns = new Notification();
|
|
|
2033 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
|
|
2034 |
SimpleCampaignParams.class);
|
|
|
2035 |
Campaign campaign = new SimpleCampaign(scp);
|
|
|
2036 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
|
|
2037 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
|
|
2038 |
ns.setType(campaign.getType());
|
|
|
2039 |
ns.setMessage(campaign.getMessage());
|
|
|
2040 |
ns.setTitle(campaign.getTitle());
|
|
|
2041 |
if (notificationCampaign.getDocumentId() != null) {
|
|
|
2042 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
|
|
2043 |
ns.setDocumentName(document.getDisplayName());
|
|
|
2044 |
}
|
|
|
2045 |
ns.setUrl(campaign.getUrl());
|
|
|
2046 |
ns.setShowImage(campaign.getShowImage());
|
|
|
2047 |
ns.setImageUrl(campaign.getImageUrl());
|
|
|
2048 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
|
|
2049 |
ns.setMessageType(notificationCampaign.getMessageType());
|
|
|
2050 |
ns.setCreated(notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30))
|
|
|
2051 |
* 1000);
|
|
|
2052 |
if (LocalDateTime.now().isAfter(expire)) {
|
|
|
2053 |
ns.setExpired(true);
|
|
|
2054 |
} else {
|
|
|
2055 |
ns.setExpired(false);
|
|
|
2056 |
}
|
|
|
2057 |
notifications.add(ns);
|
|
|
2058 |
}
|
|
|
2059 |
|
| 25649 |
tejbeer |
2060 |
}
|
| 25683 |
tejbeer |
2061 |
return notifications;
|
| 25651 |
tejbeer |
2062 |
|
|
|
2063 |
}
|
| 25649 |
tejbeer |
2064 |
|
| 25651 |
tejbeer |
2065 |
@RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
|
|
|
2066 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
|
|
2067 |
@RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, @RequestParam int cid)
|
|
|
2068 |
throws ProfitMandiBusinessException {
|
|
|
2069 |
Document document = documentRepository.selectById(documentId);
|
|
|
2070 |
NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
|
|
|
2071 |
if (nc.getDocumentId() == null) {
|
|
|
2072 |
throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
|
|
|
2073 |
}
|
|
|
2074 |
if (nc.getDocumentId() != documentId) {
|
|
|
2075 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, documentId, "RTLR_1014");
|
|
|
2076 |
}
|
|
|
2077 |
return responseSender.ok(document);
|
| 25649 |
tejbeer |
2078 |
}
|
|
|
2079 |
|
| 25651 |
tejbeer |
2080 |
@RequestMapping(value = "/notifyDocument/download", method = RequestMethod.GET)
|
|
|
2081 |
public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request, @RequestParam int cid, Model model)
|
|
|
2082 |
throws ProfitMandiBusinessException {
|
|
|
2083 |
|
|
|
2084 |
NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
|
|
|
2085 |
|
|
|
2086 |
if (nc.getDocumentId() == null) {
|
|
|
2087 |
throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
|
|
|
2088 |
}
|
|
|
2089 |
|
|
|
2090 |
Document document = documentRepository.selectById(nc.getDocumentId());
|
|
|
2091 |
|
|
|
2092 |
FileInputStream file = null;
|
|
|
2093 |
try {
|
|
|
2094 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
|
|
2095 |
} catch (FileNotFoundException e) {
|
|
|
2096 |
LOGGER.error("Retailer Document file not found : ", e);
|
|
|
2097 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
|
|
2098 |
}
|
|
|
2099 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
|
|
2100 |
// ByteArrayOutputStream();
|
|
|
2101 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
|
|
2102 |
|
|
|
2103 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
2104 |
String contentType = "";
|
|
|
2105 |
if (document.getContentType() == ContentType.JPEG) {
|
|
|
2106 |
contentType = "image/jpeg";
|
|
|
2107 |
} else if (document.getContentType() == ContentType.PNG) {
|
|
|
2108 |
contentType = "image/png";
|
|
|
2109 |
} else if (document.getContentType() == ContentType.PDF) {
|
|
|
2110 |
contentType = "application/pdf";
|
|
|
2111 |
}
|
|
|
2112 |
headers.set("Content-Type", contentType);
|
|
|
2113 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
|
|
2114 |
headers.setContentLength(document.getSize());
|
|
|
2115 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
|
|
2116 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
2117 |
}
|
| 26460 |
amit.gupta |
2118 |
|
|
|
2119 |
public Map<Integer, PartnerDetailModel> getL2AuthUserPartnerDetail() throws Exception {
|
| 26445 |
amit.gupta |
2120 |
LOGGER.info("getL2AuthUserPartnerDetail Started");
|
| 26460 |
amit.gupta |
2121 |
Map<Integer, List<Integer>> L2L1Mapping = csService.getL2L1Mapping();
|
| 26422 |
tejbeer |
2122 |
Map<Integer, Integer> authIdAndleadsCountMap = new HashMap<>();
|
|
|
2123 |
for (Entry<Integer, List<Integer>> l2l1 : L2L1Mapping.entrySet()) {
|
|
|
2124 |
List<Integer> authIds = l2l1.getValue();
|
|
|
2125 |
authIds.add(l2l1.getKey());
|
|
|
2126 |
|
|
|
2127 |
List<Lead> leads = leadRepository.selectByAssignAuthIdsAndStatus(authIds, LeadStatus.followUp);
|
| 26433 |
tejbeer |
2128 |
LOGGER.info("authIdAndleadsCountMap" + authIdAndleadsCountMap);
|
| 26422 |
tejbeer |
2129 |
AuthUser auth = authRepository.selectById(l2l1.getKey());
|
| 26431 |
tejbeer |
2130 |
if (!leads.isEmpty()) {
|
|
|
2131 |
authIdAndleadsCountMap.put(auth.getId(), leads.size());
|
|
|
2132 |
} else {
|
|
|
2133 |
authIdAndleadsCountMap.put(auth.getId(), 0);
|
|
|
2134 |
}
|
| 26422 |
tejbeer |
2135 |
}
|
| 26468 |
amit.gupta |
2136 |
|
| 26460 |
amit.gupta |
2137 |
Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
|
| 27352 |
tejbeer |
2138 |
List<Integer> unmappedPartners = partnerStats.entrySet().stream().map(x -> x.getKey())
|
|
|
2139 |
.collect(Collectors.toList());
|
| 26433 |
tejbeer |
2140 |
LOGGER.info("authIdAndleadsCountMap" + authIdAndleadsCountMap);
|
| 26422 |
tejbeer |
2141 |
|
| 26460 |
amit.gupta |
2142 |
Map<Integer, PartnerDetailModel> authIdAndallValues = new LinkedHashMap<>();
|
| 26422 |
tejbeer |
2143 |
|
| 26460 |
amit.gupta |
2144 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
|
|
2145 |
for (int authUserId : pp.keySet()) {
|
|
|
2146 |
if (L2L1Mapping.keySet().contains(authUserId)) {
|
|
|
2147 |
List<Integer> fofoIds = pp.get(authUserId);
|
| 26997 |
amit.gupta |
2148 |
unmappedPartners.removeAll(fofoIds);
|
| 26468 |
amit.gupta |
2149 |
List<PartnerDetailModel> partnerDetails = fofoIds.stream().map(x -> partnerStats.get(x))
|
|
|
2150 |
.collect(Collectors.toList());
|
| 27632 |
tejbeer |
2151 |
LOGGER.info("authUserId {}, partnerDetails2 {}" + authUserId, partnerDetails);
|
| 26460 |
amit.gupta |
2152 |
PartnerDetailModel partnerDetailModel = partnerStatsService.getAggregateStats(partnerDetails);
|
|
|
2153 |
authIdAndallValues.put(authUserId, partnerDetailModel);
|
| 26422 |
tejbeer |
2154 |
}
|
|
|
2155 |
}
|
| 26997 |
amit.gupta |
2156 |
List<PartnerDetailModel> unmappedPartnerDetails = unmappedPartners.stream().map(x -> partnerStats.get(x))
|
|
|
2157 |
.collect(Collectors.toList());
|
| 26468 |
amit.gupta |
2158 |
PartnerDetailModel partnerDetailModel = partnerStatsService
|
|
|
2159 |
.getAggregateStats(new ArrayList<>(partnerStats.values()));
|
| 27000 |
amit.gupta |
2160 |
authIdAndallValues.put(-1, partnerStatsService.getAggregateStats(unmappedPartnerDetails));
|
| 26460 |
amit.gupta |
2161 |
authIdAndallValues.put(0, partnerDetailModel);
|
| 26422 |
tejbeer |
2162 |
return authIdAndallValues;
|
|
|
2163 |
}
|
|
|
2164 |
|
| 27579 |
tejbeer |
2165 |
@RequestMapping(value = "/getItemWiseTertiary", method = RequestMethod.GET)
|
|
|
2166 |
public String getItemWiseTertiary(HttpServletRequest request,
|
|
|
2167 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model)
|
|
|
2168 |
throws ProfitMandiBusinessException {
|
|
|
2169 |
List<ItemWiseTertiaryModel> itemWiseTertiary = fofoOrderRepository.SelectItemWiseTertiary(fofoId);
|
|
|
2170 |
|
|
|
2171 |
LOGGER.info("itemWiseTertiary" + itemWiseTertiary);
|
| 27586 |
tejbeer |
2172 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2173 |
model.addAttribute("customRetailer", customRetailer);
|
| 27579 |
tejbeer |
2174 |
model.addAttribute("itemWiseTertiary", itemWiseTertiary);
|
|
|
2175 |
return "item-wise-tertiary";
|
|
|
2176 |
}
|
|
|
2177 |
|
| 27586 |
tejbeer |
2178 |
@RequestMapping(value = "/getItemWiseIndent", method = RequestMethod.GET)
|
|
|
2179 |
public String getItemWiseIndent(HttpServletRequest request,
|
|
|
2180 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model)
|
|
|
2181 |
throws ProfitMandiBusinessException {
|
|
|
2182 |
|
|
|
2183 |
List<Order> unbilledOrders = transactionService.getInTransitOrders(fofoId);
|
|
|
2184 |
model.addAttribute("unbilledOrders", unbilledOrders);
|
|
|
2185 |
|
|
|
2186 |
return "item-wise-indent";
|
|
|
2187 |
}
|
|
|
2188 |
|
| 27636 |
tejbeer |
2189 |
@RequestMapping(value = "/getPartnerInvestment", method = RequestMethod.GET)
|
|
|
2190 |
public String getPartnerInvestment(HttpServletRequest request,
|
|
|
2191 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
2192 |
Map<Integer, PartnerDetailModel> partnerStats = this.getPartnersStatDataFromFile();
|
|
|
2193 |
PartnerDetailModel partnerDetailModel = partnerStats.get(fofoId);
|
|
|
2194 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2195 |
model.addAttribute("partnerDetailModel", partnerDetailModel);
|
|
|
2196 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2197 |
return "partner-investment";
|
|
|
2198 |
}
|
| 27727 |
tejbeer |
2199 |
|
| 27704 |
amit.gupta |
2200 |
@RequestMapping(value = "/getPartnerPendingIndentItem", method = RequestMethod.GET)
|
|
|
2201 |
public String getPartnerPendingIndentItem(HttpServletRequest request, @RequestParam int warehouseId,
|
|
|
2202 |
@RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
|
|
|
2203 |
List<PartnerPendingIndentItemModel> partnerPendingIndent = fofoStoreRepository
|
|
|
2204 |
.selectPartnerPendingIndentItem(itemId, warehouseId);
|
| 27636 |
tejbeer |
2205 |
|
| 27704 |
amit.gupta |
2206 |
model.addAttribute("partnerPendingIndent", partnerPendingIndent);
|
|
|
2207 |
return "partner-pending-indent-item";
|
|
|
2208 |
}
|
|
|
2209 |
|
| 27636 |
tejbeer |
2210 |
@RequestMapping(value = "/getPatnerActivateStock", method = RequestMethod.GET)
|
|
|
2211 |
public String getPartnerActivateStockItem(HttpServletRequest request,
|
|
|
2212 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
2213 |
List<ActivateItemModel> activateStocks = new ArrayList<>();
|
|
|
2214 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByActivatedNotSold(fofoId);
|
|
|
2215 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2216 |
|
|
|
2217 |
for (InventoryItem inventoryItem : inventoryItems) {
|
|
|
2218 |
TagListing tagListing = tagListingRepository.selectByItemId(inventoryItem.getItemId());
|
|
|
2219 |
Item item = itemRepository.selectById(inventoryItem.getItemId());
|
|
|
2220 |
ActivateItemModel aim = new ActivateItemModel();
|
|
|
2221 |
aim.setFofoId(inventoryItem.getFofoId());
|
|
|
2222 |
aim.setQuantity(inventoryItem.getGoodQuantity());
|
|
|
2223 |
aim.setAmount(tagListing.getSellingPrice());
|
|
|
2224 |
aim.setItemDescription(item.getItemDescription());
|
|
|
2225 |
aim.setItemId(inventoryItem.getItemId());
|
|
|
2226 |
activateStocks.add(aim);
|
|
|
2227 |
}
|
|
|
2228 |
|
|
|
2229 |
model.addAttribute("activateStocks", activateStocks);
|
|
|
2230 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2231 |
return "partner-activate-stock";
|
|
|
2232 |
}
|
|
|
2233 |
|
|
|
2234 |
@RequestMapping(value = "/getPatnerBrandWiseMTDSale", method = RequestMethod.GET)
|
|
|
2235 |
public String getPatnerBrandWiseMTDSale(HttpServletRequest request,
|
|
|
2236 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
2237 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
2238 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2239 |
Map<String, Double> brandMtdAmount = fofoOrderItemRepository
|
|
|
2240 |
.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
|
| 27638 |
tejbeer |
2241 |
Map<String, Long> brandMtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(curDate.withDayOfMonth(1),
|
|
|
2242 |
curDate.with(LocalTime.MAX), fofoId);
|
| 27636 |
tejbeer |
2243 |
Double accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId,
|
|
|
2244 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false)).get(fofoId);
|
| 27638 |
tejbeer |
2245 |
Long accesoriesmtdqty = fofoOrderRepository.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId,
|
|
|
2246 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false)).get(fofoId);
|
|
|
2247 |
|
| 27636 |
tejbeer |
2248 |
LOGGER.info("accesoriesmtdsale" + accesoriesmtdsale);
|
|
|
2249 |
model.addAttribute("brandMtdAmount", brandMtdAmount);
|
| 27638 |
tejbeer |
2250 |
model.addAttribute("brandMtdQty", brandMtdQty);
|
| 27636 |
tejbeer |
2251 |
model.addAttribute("accesoriesmtdsale", accesoriesmtdsale);
|
| 27638 |
tejbeer |
2252 |
model.addAttribute("accesoriesmtdqty", accesoriesmtdqty);
|
|
|
2253 |
|
| 27636 |
tejbeer |
2254 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2255 |
return "partner-brand-mtd-sale";
|
|
|
2256 |
}
|
|
|
2257 |
|
| 27637 |
tejbeer |
2258 |
@RequestMapping(value = "/getPatnerBrandWiseLMTDSale", method = RequestMethod.GET)
|
|
|
2259 |
public String getPatnerBrandWiseLMTDSale(HttpServletRequest request,
|
|
|
2260 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
2261 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
2262 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2263 |
Map<String, Double> brandLMtdAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
|
|
2264 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
|
| 27638 |
tejbeer |
2265 |
Map<String, Long> brandLmtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
|
|
|
2266 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
|
| 27637 |
tejbeer |
2267 |
|
|
|
2268 |
Double accesorieslmtdsale = fofoOrderRepository
|
|
|
2269 |
.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1).minusMonths(1),
|
|
|
2270 |
curDate.with(LocalTime.MAX).minusMonths(1), Optional.of(false))
|
|
|
2271 |
.get(fofoId);
|
| 27638 |
tejbeer |
2272 |
Long accesorieslmtdqty = fofoOrderRepository.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId,
|
|
|
2273 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1),
|
|
|
2274 |
Optional.of(false)).get(fofoId);
|
|
|
2275 |
|
| 27637 |
tejbeer |
2276 |
model.addAttribute("brandLMtdAmount", brandLMtdAmount);
|
| 27638 |
tejbeer |
2277 |
model.addAttribute("brandLmtdQty", brandLmtdQty);
|
|
|
2278 |
model.addAttribute("accesorieslmtdqty", accesorieslmtdqty);
|
| 27637 |
tejbeer |
2279 |
model.addAttribute("accesorieslmtdsale", accesorieslmtdsale);
|
|
|
2280 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2281 |
return "partner-brand-lmtd-sale";
|
|
|
2282 |
}
|
|
|
2283 |
|
| 27660 |
tejbeer |
2284 |
@RequestMapping(value = "/getPatnerBrandWiseLMSSale", method = RequestMethod.GET)
|
|
|
2285 |
public String getPatnerBrandWiseLMSSale(HttpServletRequest request,
|
|
|
2286 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
2287 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
2288 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2289 |
int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
|
|
|
2290 |
|
|
|
2291 |
Map<String, Double> brandLMSAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
| 27893 |
tejbeer |
2292 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), fofoId);
|
| 27660 |
tejbeer |
2293 |
Map<String, Long> brandLmsQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
|
| 27893 |
tejbeer |
2294 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), fofoId);
|
| 27660 |
tejbeer |
2295 |
|
| 27893 |
tejbeer |
2296 |
Double accesorieslmssale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId,
|
|
|
2297 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), Optional.of(false)).get(fofoId);
|
| 27660 |
tejbeer |
2298 |
Long accesorieslmsqty = fofoOrderRepository
|
|
|
2299 |
.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId,
|
| 27893 |
tejbeer |
2300 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), Optional.of(false))
|
| 27660 |
tejbeer |
2301 |
.get(fofoId);
|
|
|
2302 |
|
|
|
2303 |
model.addAttribute("brandLMSAmount", brandLMSAmount);
|
|
|
2304 |
model.addAttribute("brandLmsQty", brandLmsQty);
|
|
|
2305 |
model.addAttribute("accesorieslmssale", accesorieslmssale);
|
|
|
2306 |
model.addAttribute("accesorieslmsqty", accesorieslmsqty);
|
|
|
2307 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2308 |
return "partner-brand-lms-sale";
|
|
|
2309 |
}
|
|
|
2310 |
|
| 27640 |
tejbeer |
2311 |
@RequestMapping(value = "/getPatnerInStock", method = RequestMethod.GET)
|
|
|
2312 |
public String getPatnerInStock(HttpServletRequest request,
|
|
|
2313 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
2314 |
|
|
|
2315 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2316 |
|
| 27660 |
tejbeer |
2317 |
List<InStockBrandModel> mobileStocks = currentInventorySnapshotRepository
|
| 27640 |
tejbeer |
2318 |
.selectSumInStockMobileGroupByBrand(fofoId);
|
| 27660 |
tejbeer |
2319 |
List<InStockBrandModel> accesStock = currentInventorySnapshotRepository
|
| 27640 |
tejbeer |
2320 |
.selectSumInStockAccessoriesGroupByBrand(fofoId);
|
|
|
2321 |
|
| 27660 |
tejbeer |
2322 |
List<InStockBrandItemModel> stockItemlist = currentInventorySnapshotRepository
|
|
|
2323 |
.selectInStockItemsByBrand(fofoId);
|
|
|
2324 |
|
|
|
2325 |
Map<String, List<InStockBrandItemModel>> stockItemMap = stockItemlist.stream()
|
|
|
2326 |
.collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
|
|
2327 |
|
|
|
2328 |
model.addAttribute("stockItemMap", stockItemMap);
|
|
|
2329 |
model.addAttribute("mobileStock", mobileStocks);
|
|
|
2330 |
model.addAttribute("accesStock", accesStock);
|
| 27640 |
tejbeer |
2331 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2332 |
return "partner-instock-item";
|
|
|
2333 |
}
|
|
|
2334 |
|
| 27660 |
tejbeer |
2335 |
@RequestMapping(value = "/getOpenTicketByFofoId", method = RequestMethod.GET)
|
|
|
2336 |
public String getOpenTicketByFofoId(HttpServletRequest request,
|
|
|
2337 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
2338 |
Map<Integer, AuthUser> ticketIdAuthUser = new HashMap<>();
|
|
|
2339 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2340 |
List<Integer> ticketIds = ticketRepository.selectAllOpenTicketByRetailer(fofoId).stream().map(x -> x.getId())
|
|
|
2341 |
.collect(Collectors.toList());
|
|
|
2342 |
List<TicketAssigned> ticketAssigns = ticketAssignedRepository.selectByTicketIds(ticketIds);
|
|
|
2343 |
|
|
|
2344 |
for (TicketAssigned ticketAssign : ticketAssigns) {
|
|
|
2345 |
AuthUser authUser = authRepository.selectById(ticketAssign.getAssineeId());
|
|
|
2346 |
ticketIdAuthUser.put(ticketAssign.getTicketId(), authUser);
|
|
|
2347 |
}
|
|
|
2348 |
model.addAttribute("ticketIdAuthUser", ticketIdAuthUser);
|
|
|
2349 |
model.addAttribute("ticketAssigns", ticketAssigns);
|
|
|
2350 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2351 |
return "open-ticket";
|
|
|
2352 |
}
|
|
|
2353 |
|
| 27893 |
tejbeer |
2354 |
@RequestMapping(value = "/getPartnerSecondarySale", method = RequestMethod.GET)
|
|
|
2355 |
public String getPartnerSecondarySale(HttpServletRequest request,
|
|
|
2356 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, @RequestParam String timeValue, Model model)
|
|
|
2357 |
throws Exception {
|
|
|
2358 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
2359 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
2360 |
int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
|
|
|
2361 |
LocalDateTime startDate = null;
|
|
|
2362 |
LocalDateTime endDate = null;
|
|
|
2363 |
List<InStockBrandModel> secondarySale = null;
|
|
|
2364 |
Map<String, List<InStockBrandItemModel>> secondaryItemSale = null;
|
|
|
2365 |
|
|
|
2366 |
if (timeValue.equals("mtd")) {
|
|
|
2367 |
startDate = curDate.withDayOfMonth(1);
|
|
|
2368 |
endDate = curDate.with(LocalTime.MAX);
|
|
|
2369 |
secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
|
|
|
2370 |
secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId)
|
|
|
2371 |
.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
|
|
2372 |
LOGGER.info("secondarySalemtd" + secondarySale);
|
|
|
2373 |
} else if (timeValue.equals("lmtd")) {
|
|
|
2374 |
startDate = curDate.withDayOfMonth(1).minusMonths(1);
|
|
|
2375 |
endDate = curDate.with(LocalTime.MAX).minusMonths(1);
|
|
|
2376 |
secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId)
|
|
|
2377 |
.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
|
|
2378 |
|
|
|
2379 |
secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
|
|
|
2380 |
LOGGER.info("secondarySalelmtd" + secondarySale);
|
|
|
2381 |
|
|
|
2382 |
} else {
|
|
|
2383 |
startDate = curDate.withDayOfMonth(1).minusMonths(1);
|
|
|
2384 |
endDate = curDate.withDayOfMonth(1);
|
|
|
2385 |
secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId)
|
|
|
2386 |
.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
|
|
|
2387 |
|
|
|
2388 |
secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
|
|
|
2389 |
LOGGER.info("secondarySalelms" + secondarySale);
|
|
|
2390 |
|
|
|
2391 |
}
|
|
|
2392 |
|
|
|
2393 |
LOGGER.info("secondarySale" + secondarySale);
|
|
|
2394 |
model.addAttribute("secondarySale", secondarySale);
|
|
|
2395 |
model.addAttribute("secondaryItemSale", secondaryItemSale);
|
|
|
2396 |
model.addAttribute("customRetailer", customRetailer);
|
|
|
2397 |
|
|
|
2398 |
return "partner-secondary-order";
|
|
|
2399 |
}
|
|
|
2400 |
|
| 21615 |
kshitij.so |
2401 |
}
|