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