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