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