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