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