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