| 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;
|
| 27599 |
tejbeer |
86 |
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
|
| 25649 |
tejbeer |
87 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
|
|
88 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 27556 |
tejbeer |
89 |
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel;
|
| 27591 |
tejbeer |
90 |
import com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel;
|
|
|
91 |
import com.spice.profitmandi.dao.model.WarehouseWiseBrandStockModel;
|
| 27556 |
tejbeer |
92 |
import com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel;
|
| 27509 |
tejbeer |
93 |
import com.spice.profitmandi.dao.model.WarehouseWiseStockModel;
|
|
|
94 |
import com.spice.profitmandi.dao.model.WarehouseWiseitemStockModel;
|
| 25976 |
amit.gupta |
95 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 26011 |
amit.gupta |
96 |
import com.spice.profitmandi.dao.repository.auth.MenuCategoryRepository;
|
|
|
97 |
import com.spice.profitmandi.dao.repository.auth.MenuRepository;
|
| 27355 |
tejbeer |
98 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 26588 |
tejbeer |
99 |
import com.spice.profitmandi.dao.repository.catalog.OfferMarginRepository;
|
|
|
100 |
import com.spice.profitmandi.dao.repository.catalog.OfferPartnerRepository;
|
|
|
101 |
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
|
| 26090 |
amit.gupta |
102 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 26418 |
tejbeer |
103 |
import com.spice.profitmandi.dao.repository.cs.PartnersPositionRepository;
|
| 26011 |
amit.gupta |
104 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
|
|
105 |
import com.spice.profitmandi.dao.repository.cs.TicketCategoryRepository;
|
| 26418 |
tejbeer |
106 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 25651 |
tejbeer |
107 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 22481 |
ashik.ali |
108 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 26418 |
tejbeer |
109 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 24996 |
amit.gupta |
110 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 25649 |
tejbeer |
111 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
|
|
112 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
|
|
113 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
| 24203 |
amit.gupta |
114 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24880 |
govind |
115 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 26071 |
tejbeer |
116 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 25649 |
tejbeer |
117 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| 26234 |
amit.gupta |
118 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 24288 |
amit.gupta |
119 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 25214 |
amit.gupta |
120 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| 27474 |
tejbeer |
121 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
| 25566 |
tejbeer |
122 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 27529 |
tejbeer |
123 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
|
|
124 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| 27509 |
tejbeer |
125 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventorySnapshotRepository;
|
| 24336 |
amit.gupta |
126 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 26460 |
amit.gupta |
127 |
import com.spice.profitmandi.service.PartnerStatsService;
|
| 23844 |
amit.gupta |
128 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 25677 |
amit.gupta |
129 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 27586 |
tejbeer |
130 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 26005 |
amit.gupta |
131 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 22481 |
ashik.ali |
132 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
133 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 27529 |
tejbeer |
134 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22481 |
ashik.ali |
135 |
|
| 21615 |
kshitij.so |
136 |
@Controller
|
| 25222 |
amit.gupta |
137 |
@Transactional(rollbackOn = Throwable.class)
|
| 21615 |
kshitij.so |
138 |
public class DashboardController {
|
| 23923 |
amit.gupta |
139 |
|
| 26460 |
amit.gupta |
140 |
private static final double ONE_LAC = 1 * 1000 * 100;
|
|
|
141 |
private static final double TWO_LAC = 2 * 1000 * 100;
|
|
|
142 |
private static final double FOUR_LAC = 4 * 1000 * 100;
|
|
|
143 |
|
| 23379 |
ashik.ali |
144 |
@Value("${web.api.host}")
|
|
|
145 |
private String webApiHost;
|
| 23923 |
amit.gupta |
146 |
|
| 24072 |
amit.gupta |
147 |
@Value("${web.api.scheme}")
|
|
|
148 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
149 |
|
| 24078 |
amit.gupta |
150 |
@Value("${web.api.root}")
|
|
|
151 |
private String webApiRoot;
|
|
|
152 |
|
| 23379 |
ashik.ali |
153 |
@Value("${web.api.port}")
|
|
|
154 |
private int webApiPort;
|
| 21615 |
kshitij.so |
155 |
|
| 22481 |
ashik.ali |
156 |
@Autowired
|
| 22927 |
ashik.ali |
157 |
private CookiesProcessor cookiesProcessor;
|
| 26468 |
amit.gupta |
158 |
|
| 26460 |
amit.gupta |
159 |
@Autowired
|
|
|
160 |
private PartnerStatsService partnerStatsService;
|
| 23923 |
amit.gupta |
161 |
|
| 23568 |
govind |
162 |
@Autowired
|
| 26011 |
amit.gupta |
163 |
private MenuRepository menuRepository;
|
| 26012 |
amit.gupta |
164 |
|
| 26011 |
amit.gupta |
165 |
@Autowired
|
|
|
166 |
private MenuCategoryRepository menuCategoryRepository;
|
|
|
167 |
|
|
|
168 |
@Autowired
|
| 26090 |
amit.gupta |
169 |
private CsService csService;
|
|
|
170 |
|
|
|
171 |
@Autowired
|
| 25214 |
amit.gupta |
172 |
private PartnerTargetRepository partnerTargetRepository;
|
|
|
173 |
|
|
|
174 |
@Autowired
|
| 25653 |
amit.gupta |
175 |
private ResponseSender<?> responseSender;
|
| 26012 |
amit.gupta |
176 |
|
| 26005 |
amit.gupta |
177 |
@Autowired
|
|
|
178 |
RetailerService retailerService;
|
| 25214 |
amit.gupta |
179 |
|
|
|
180 |
@Autowired
|
| 23786 |
amit.gupta |
181 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
182 |
|
| 23838 |
ashik.ali |
183 |
@Autowired
|
|
|
184 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
185 |
|
|
|
186 |
@Autowired
|
| 24880 |
govind |
187 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 23923 |
amit.gupta |
188 |
|
| 23884 |
amit.gupta |
189 |
@Autowired
|
| 24880 |
govind |
190 |
private PartnerInvestmentService partnerInvestmentService;
|
| 24288 |
amit.gupta |
191 |
|
| 23884 |
amit.gupta |
192 |
@Autowired
|
| 25653 |
amit.gupta |
193 |
DocumentRepository documentRepository;
|
| 26236 |
amit.gupta |
194 |
|
| 26234 |
amit.gupta |
195 |
@Autowired
|
|
|
196 |
InventoryItemRepository inventoryItemRepository;
|
| 25683 |
tejbeer |
197 |
|
| 25677 |
amit.gupta |
198 |
@Autowired
|
|
|
199 |
InventoryService inventoryService;
|
| 23923 |
amit.gupta |
200 |
|
| 23884 |
amit.gupta |
201 |
@Autowired
|
| 24203 |
amit.gupta |
202 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
203 |
|
| 24880 |
govind |
204 |
@Autowired
|
|
|
205 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 26012 |
amit.gupta |
206 |
|
| 26011 |
amit.gupta |
207 |
@Autowired
|
|
|
208 |
private TicketCategoryRepository ticketCategoryRepository;
|
| 24880 |
govind |
209 |
|
|
|
210 |
@Autowired
|
| 25566 |
tejbeer |
211 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 25136 |
amit.gupta |
212 |
|
| 24996 |
amit.gupta |
213 |
@Autowired
|
| 25649 |
tejbeer |
214 |
private HygieneDataRepository hygieneDataRepository;
|
|
|
215 |
|
|
|
216 |
@Autowired
|
|
|
217 |
private UserCampaignRepository userCampaignRepository;
|
| 26012 |
amit.gupta |
218 |
|
| 26011 |
amit.gupta |
219 |
@Autowired
|
|
|
220 |
private PositionRepository positionRepository;
|
| 27474 |
tejbeer |
221 |
@Autowired
|
|
|
222 |
private PartnerTypeChangeRepository partnerTypeChangeRepository;
|
| 25649 |
tejbeer |
223 |
|
|
|
224 |
@Autowired
|
| 26418 |
tejbeer |
225 |
private PartnersPositionRepository partnerPositionRepository;
|
|
|
226 |
|
|
|
227 |
@Autowired
|
| 25649 |
tejbeer |
228 |
private UserAccountRepository userAccountRepository;
|
|
|
229 |
|
|
|
230 |
@Autowired
|
|
|
231 |
private NotificationCampaignRepository notificationCampaignRepository;
|
|
|
232 |
|
|
|
233 |
@Autowired
|
| 24996 |
amit.gupta |
234 |
private Mongo mongoClient;
|
| 26012 |
amit.gupta |
235 |
|
| 25976 |
amit.gupta |
236 |
@Autowired
|
|
|
237 |
private AuthRepository authRepository;
|
| 24880 |
govind |
238 |
|
| 25649 |
tejbeer |
239 |
@Autowired
|
| 26071 |
tejbeer |
240 |
private FofoOrderRepository fofoOrderRepository;
|
|
|
241 |
|
|
|
242 |
@Autowired
|
| 25649 |
tejbeer |
243 |
private Gson gson;
|
|
|
244 |
|
| 26418 |
tejbeer |
245 |
@Autowired
|
|
|
246 |
TicketRepository ticketRepository;
|
|
|
247 |
|
|
|
248 |
@Autowired
|
|
|
249 |
private LeadRepository leadRepository;
|
|
|
250 |
|
| 26588 |
tejbeer |
251 |
@Autowired
|
|
|
252 |
private OfferRepository offerRepository;
|
|
|
253 |
|
|
|
254 |
@Autowired
|
|
|
255 |
private OfferPartnerRepository offerPartnerRepository;
|
|
|
256 |
|
|
|
257 |
@Autowired
|
|
|
258 |
private OfferMarginRepository offerMarginRepository;
|
| 27529 |
tejbeer |
259 |
|
| 27355 |
tejbeer |
260 |
@Autowired
|
|
|
261 |
private ItemRepository itemRepository;
|
| 26588 |
tejbeer |
262 |
|
| 27509 |
tejbeer |
263 |
@Autowired
|
|
|
264 |
private SaholicInventorySnapshotRepository saholicInventorySnapshotRepository;
|
| 27529 |
tejbeer |
265 |
|
|
|
266 |
@Autowired
|
|
|
267 |
private SaholicInventoryCISRepository saholicInventoryCISRepository;
|
|
|
268 |
|
|
|
269 |
@Autowired
|
|
|
270 |
private MVCResponseSender mvcResponseSender;
|
|
|
271 |
|
|
|
272 |
@Autowired
|
|
|
273 |
private ReporticoCacheTableRepository reporticoCacheTableRepository;
|
|
|
274 |
|
| 27586 |
tejbeer |
275 |
@Autowired
|
|
|
276 |
private TransactionService transactionService;
|
|
|
277 |
|
| 23568 |
govind |
278 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 23923 |
amit.gupta |
279 |
|
| 25136 |
amit.gupta |
280 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
| 25726 |
amit.gupta |
281 |
public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
|
| 25740 |
amit.gupta |
282 |
boolean isAdmin = false;
|
|
|
283 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
284 |
|
|
|
285 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
286 |
model.addAttribute("webApiPort", webApiPort);
|
|
|
287 |
model.addAttribute("webApiScheme", webApiScheme);
|
|
|
288 |
model.addAttribute("webApiRoot", webApiRoot);
|
|
|
289 |
if (isAdmin) {
|
|
|
290 |
return "dashboard1";
|
| 26236 |
amit.gupta |
291 |
}
|
|
|
292 |
|
|
|
293 |
FofoStore fofoStore = null;
|
| 26234 |
amit.gupta |
294 |
try {
|
|
|
295 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
296 |
fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
|
|
297 |
if (!fofoStore.isActive()) {
|
|
|
298 |
return "redirect:/login";
|
|
|
299 |
}
|
| 25740 |
amit.gupta |
300 |
|
| 26234 |
amit.gupta |
301 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
|
|
302 |
model.addAttribute("partnerType", partnerType);
|
|
|
303 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
|
|
304 |
model.addAttribute("fofoStore", customRetailer);
|
|
|
305 |
model.addAttribute("partnerType", partnerType);
|
|
|
306 |
model.addAttribute("hasGift", hasGift(fofoId));
|
|
|
307 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 25740 |
amit.gupta |
308 |
|
| 26234 |
amit.gupta |
309 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
|
|
310 |
model.addAttribute("salesMap", this.getSales(fofoId));
|
|
|
311 |
model.addAttribute("activatedImeis", inventoryItemRepository.selectCountByActivatedNotSold(fofoId));
|
|
|
312 |
// this.setInvestments
|
|
|
313 |
//
|
|
|
314 |
model.addAttribute("investments", this.getInvestments(fofoId));
|
|
|
315 |
model.addAttribute("isInvestmentOk",
|
|
|
316 |
partnerInvestmentService.isInvestmentOk(fofoId, 10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
|
|
317 |
} catch (ProfitMandiBusinessException e) {
|
|
|
318 |
LOGGER.error("FofoStore Code not found of fofoId {}", fofoId);
|
| 25740 |
amit.gupta |
319 |
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
|
|
323 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
| 26012 |
amit.gupta |
324 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart, currentMonthEnd)
|
|
|
325 |
/ 2;
|
|
|
326 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart, currentMonthEnd) / 2;
|
|
|
327 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart, currentMonthEnd) / 2;
|
| 25740 |
amit.gupta |
328 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
|
|
329 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
|
|
330 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
|
|
331 |
|
| 26012 |
amit.gupta |
332 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(fofoId, true, currentMonthStart, currentMonthEnd);
|
|
|
333 |
|
|
|
334 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(fofoId, false, currentMonthStart,
|
| 25740 |
amit.gupta |
335 |
currentMonthEnd);
|
|
|
336 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
|
|
337 |
invalidHygieneCount = 1;
|
|
|
338 |
}
|
|
|
339 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| 26460 |
amit.gupta |
340 |
|
| 25740 |
amit.gupta |
341 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
|
|
342 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
|
|
343 |
return "12dashboard34";
|
| 25136 |
amit.gupta |
344 |
}
|
|
|
345 |
|
|
|
346 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
|
|
347 |
Map<String, Object> investments = new LinkedHashMap<>();
|
| 26233 |
amit.gupta |
348 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
|
| 25649 |
tejbeer |
349 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
|
| 25136 |
amit.gupta |
350 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
|
|
351 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
|
|
352 |
if (yesterdayInvestment == null) {
|
|
|
353 |
yesterdayInvestment = new PartnerDailyInvestment();
|
|
|
354 |
}
|
|
|
355 |
|
|
|
356 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
|
|
357 |
currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
|
|
358 |
|
| 25140 |
amit.gupta |
359 |
long okInvestmentDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() <= 10)
|
| 25136 |
amit.gupta |
360 |
.collect(Collectors.counting());
|
| 25140 |
amit.gupta |
361 |
investments.put("today", investment.getTotalInvestment());
|
|
|
362 |
investments.put("investment", investment);
|
|
|
363 |
investments.put("inStock", investment.getInStockAmount());
|
| 25182 |
amit.gupta |
364 |
investments.put("minimum", investment.getMinInvestmentString());
|
| 25140 |
amit.gupta |
365 |
investments.put("short", investment.getShortPercentage());
|
| 26267 |
amit.gupta |
366 |
investments.put("activated_stock", investment.getActivatedStockAmount());
|
| 25649 |
tejbeer |
367 |
investments.put("okDays", okInvestmentDays);
|
| 25136 |
amit.gupta |
368 |
return investments;
|
|
|
369 |
}
|
|
|
370 |
|
| 25221 |
amit.gupta |
371 |
private Map<String, Object> getSales(int fofoId) {
|
| 25653 |
amit.gupta |
372 |
|
| 25221 |
amit.gupta |
373 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| 25140 |
amit.gupta |
374 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 25214 |
amit.gupta |
375 |
int monthLength = LocalDate.now().lengthOfMonth();
|
| 26012 |
amit.gupta |
376 |
Double todaySale = fofoOrderItemRepository
|
| 27084 |
amit.gupta |
377 |
.selectSumMopGroupByRetailer(curDate, curDate.with(LocalTime.MAX), fofoId, false).get(fofoId);
|
| 26012 |
amit.gupta |
378 |
Double mtdSale = fofoOrderItemRepository
|
| 27084 |
amit.gupta |
379 |
.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId, false)
|
| 26012 |
amit.gupta |
380 |
.get(fofoId);
|
| 27352 |
tejbeer |
381 |
Double lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1).minusMonths(1),
|
|
|
382 |
curDate.with(LocalTime.MAX).minusMonths(1), fofoId, false).get(fofoId);
|
| 25214 |
amit.gupta |
383 |
|
|
|
384 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
|
|
385 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
| 25544 |
amit.gupta |
386 |
if (partnerTargetDetails.isEmpty()) {
|
| 25372 |
tejbeer |
387 |
partnerTargetDetails = partnerTargetRepository
|
| 25653 |
amit.gupta |
388 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusMonths(3));
|
| 25372 |
tejbeer |
389 |
}
|
| 25214 |
amit.gupta |
390 |
|
| 25653 |
amit.gupta |
391 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| 25214 |
amit.gupta |
392 |
|
| 25664 |
amit.gupta |
393 |
int currentRate = (int) (mtdSale / curDate.getDayOfMonth());
|
| 25653 |
amit.gupta |
394 |
|
|
|
395 |
salesMap.put("requiredType", partnerType.next());
|
|
|
396 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
|
|
397 |
int requiredRate = (int) ((reqdAmount - mtdSale) / (monthLength - curDate.getDayOfMonth()));
|
|
|
398 |
salesMap.put("requiredRate", requiredRate);
|
|
|
399 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
|
|
400 |
|
| 25858 |
amit.gupta |
401 |
salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
|
|
|
402 |
salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
|
| 26012 |
amit.gupta |
403 |
salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
|
| 26065 |
amit.gupta |
404 |
|
| 27352 |
tejbeer |
405 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
| 25653 |
amit.gupta |
406 |
salesMap.put("currentRate", currentRate);
|
|
|
407 |
salesMap.put("currentType", currentType);
|
|
|
408 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|
| 25136 |
amit.gupta |
409 |
return salesMap;
|
|
|
410 |
}
|
|
|
411 |
|
| 27474 |
tejbeer |
412 |
@RequestMapping(value = "/getMonthSale", method = RequestMethod.GET)
|
|
|
413 |
public String getMonthsale(HttpServletRequest request, Model model) throws Exception {
|
|
|
414 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
415 |
int fofoId = loginDetails.getFofoId();
|
|
|
416 |
Map<Integer, MonthSaleModel> monthSaleMap = new HashMap<>();
|
|
|
417 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
418 |
int dayOfMonth = curDate.getDayOfMonth();
|
|
|
419 |
for (int i = 1; i <= 6; i++) {
|
|
|
420 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 27555 |
tejbeer |
421 |
int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
|
| 27474 |
tejbeer |
422 |
double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth,
|
|
|
423 |
startOfMonth.plusMonths(1), loginDetails.getFofoId(), false).get(fofoId);
|
|
|
424 |
|
| 27574 |
tejbeer |
425 |
double mtdSales = fofoOrderItemRepository
|
|
|
426 |
.selectSumMopGroupByRetailer(startOfMonth,
|
|
|
427 |
startOfMonth.plusDays(Math.min(dayOfMonth, lengthOfMonth)), loginDetails.getFofoId(), false)
|
|
|
428 |
.get(fofoId);
|
| 27474 |
tejbeer |
429 |
|
|
|
430 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfMonth.toLocalDate());
|
|
|
431 |
|
|
|
432 |
MonthSaleModel ms = new MonthSaleModel();
|
|
|
433 |
ms.setMtdSales(this.format((long) mtdSales));
|
|
|
434 |
ms.setMonthlySales(this.format(((long) monthSales)));
|
|
|
435 |
ms.setPartnerType(partnerType);
|
| 27476 |
tejbeer |
436 |
ms.setMonth(startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
| 27474 |
tejbeer |
437 |
monthSaleMap.put(i, ms);
|
|
|
438 |
|
|
|
439 |
}
|
|
|
440 |
model.addAttribute("monthSales", monthSaleMap);
|
|
|
441 |
return "monthSales";
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
private String format(long value) {
|
|
|
445 |
String finalval = null;
|
|
|
446 |
|
|
|
447 |
if (value >= 100000 && value < 10000000) {
|
|
|
448 |
long reminder = value / 100000;
|
|
|
449 |
long quitonent = value % 100000;
|
|
|
450 |
finalval = reminder + "." + quitonent;
|
|
|
451 |
String secondval = String.valueOf(quitonent);
|
|
|
452 |
if (secondval.length() >= 2) {
|
|
|
453 |
secondval = secondval.substring(0, 2);
|
|
|
454 |
finalval = reminder + "." + secondval;
|
|
|
455 |
}
|
|
|
456 |
return String.valueOf(finalval) + " Lacs";
|
|
|
457 |
} else if (value >= 1000 && value < 100000) {
|
|
|
458 |
long reminder = value / 1000;
|
|
|
459 |
long quitonent = value % 1000;
|
|
|
460 |
finalval = reminder + "." + quitonent;
|
|
|
461 |
String secondval = String.valueOf(quitonent);
|
|
|
462 |
if (secondval.length() >= 2) {
|
|
|
463 |
secondval = secondval.substring(0, 2);
|
|
|
464 |
finalval = reminder + "." + secondval;
|
|
|
465 |
}
|
|
|
466 |
return String.valueOf(finalval) + " K";
|
|
|
467 |
} else if (value >= 10000000 && value < 1000000000) {
|
|
|
468 |
long reminder = value / 10000000;
|
|
|
469 |
long quitonent = value % 10000000;
|
|
|
470 |
finalval = reminder + "." + quitonent;
|
|
|
471 |
String secondval = String.valueOf(quitonent);
|
|
|
472 |
if (secondval.length() >= 2) {
|
|
|
473 |
secondval = secondval.substring(0, 2);
|
|
|
474 |
finalval = reminder + "." + secondval;
|
|
|
475 |
}
|
|
|
476 |
return String.valueOf(finalval) + " Cr";
|
|
|
477 |
}
|
|
|
478 |
return String.valueOf(finalval);
|
|
|
479 |
|
|
|
480 |
}
|
|
|
481 |
|
| 25677 |
amit.gupta |
482 |
private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
|
|
|
483 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
|
| 25175 |
amit.gupta |
484 |
|
| 26309 |
amit.gupta |
485 |
List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
|
| 25677 |
amit.gupta |
486 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
|
|
487 |
|
|
|
488 |
mobileBrands.stream().forEach(x -> {
|
|
|
489 |
String brand = (String) x.get("name");
|
|
|
490 |
if (brandStockPricesMap.containsKey(brand)) {
|
|
|
491 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
|
|
492 |
brandStockPrice.setBrandUrl((String) x.get("url"));
|
|
|
493 |
brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
|
|
494 |
brandStockPrices.add(brandStockPrice);
|
|
|
495 |
}
|
|
|
496 |
});
|
|
|
497 |
|
|
|
498 |
return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x, y) -> x.getRank() - y.getRank())
|
|
|
499 |
.collect(Collectors.toList());
|
|
|
500 |
}
|
|
|
501 |
|
| 21615 |
kshitij.so |
502 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 25653 |
amit.gupta |
503 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
| 22927 |
ashik.ali |
504 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26011 |
amit.gupta |
505 |
String email = loginDetails.getEmailId();
|
| 25180 |
amit.gupta |
506 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
507 |
model.addAttribute("isAdmin", isAdmin);
|
| 23923 |
amit.gupta |
508 |
|
| 25274 |
amit.gupta |
509 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
510 |
model.addAttribute("webApiPort", webApiPort);
|
|
|
511 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 25544 |
amit.gupta |
512 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 25183 |
amit.gupta |
513 |
if (isAdmin) {
|
| 26011 |
amit.gupta |
514 |
return adminPanel(loginDetails.getFofoId(), email, model);
|
| 25180 |
amit.gupta |
515 |
} else {
|
| 25740 |
amit.gupta |
516 |
FofoStore fofoStore = null;
|
| 25180 |
amit.gupta |
517 |
try {
|
|
|
518 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 25544 |
amit.gupta |
519 |
if (!fofoStore.isActive()) {
|
|
|
520 |
return "redirect:/login";
|
|
|
521 |
}
|
| 25649 |
tejbeer |
522 |
|
| 25740 |
amit.gupta |
523 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
| 25566 |
tejbeer |
524 |
model.addAttribute("partnerType", partnerType);
|
| 25653 |
amit.gupta |
525 |
model.addAttribute("partnerTypeImage", PartnerType.imageMap.get(partnerType));
|
| 25180 |
amit.gupta |
526 |
model.addAttribute("fofoStore", fofoStore);
|
| 25566 |
tejbeer |
527 |
model.addAttribute("partnerType", partnerType);
|
| 25180 |
amit.gupta |
528 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
|
|
529 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 26222 |
tejbeer |
530 |
model.addAttribute("retailers", new JSONObject().append("code", fofoStore.getCode())
|
| 26162 |
amit.gupta |
531 |
.append("partnerId", fofoStore.getId()).toString());
|
| 26460 |
amit.gupta |
532 |
model.addAttribute("activatedImeis",
|
|
|
533 |
inventoryItemRepository.selectCountByActivatedNotSold(loginDetails.getFofoId()));
|
| 26071 |
tejbeer |
534 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
535 |
Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository
|
|
|
536 |
.selectSumSaleGroupByFofoIdsForMobileOrAccessories(loginDetails.getFofoId(),
|
|
|
537 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
|
|
|
538 |
LOGGER.info("accesoriesmtdsale" + accesoriesmtdsale);
|
|
|
539 |
Double accesoriesStock = currentInventorySnapshotRepository
|
|
|
540 |
.selectSumStockGroupByFofoIdsForMobileOrAccessories(loginDetails.getFofoId(),
|
|
|
541 |
Optional.of(false))
|
|
|
542 |
.get(loginDetails.getFofoId());
|
| 25180 |
amit.gupta |
543 |
|
| 26071 |
tejbeer |
544 |
model.addAttribute("accesoriesStock", String.format("%.0f", accesoriesStock));
|
| 26065 |
amit.gupta |
545 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 25180 |
amit.gupta |
546 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
| 26055 |
tejbeer |
547 |
ChartModel cm = this.getBrandChart(loginDetails.getFofoId());
|
|
|
548 |
|
|
|
549 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
|
|
550 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 25544 |
amit.gupta |
551 |
// this.setInvestments
|
|
|
552 |
//
|
| 25180 |
amit.gupta |
553 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
| 25544 |
amit.gupta |
554 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
|
|
|
555 |
10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
| 26460 |
amit.gupta |
556 |
|
|
|
557 |
// Hardcoded for valentine
|
|
|
558 |
// Hardcoded for valentine
|
| 26588 |
tejbeer |
559 |
|
| 26694 |
tejbeer |
560 |
List<Offer> offers = offerRepository.selectOfferByStatus(true);
|
| 26588 |
tejbeer |
561 |
if (!offers.isEmpty()) {
|
|
|
562 |
List<CreateOfferRequest> cors = new ArrayList<>();
|
|
|
563 |
for (Offer offer : offers) {
|
|
|
564 |
|
|
|
565 |
List<OfferPartner> offerPartners = offerPartnerRepository.selectByOfferId(offer.getId());
|
|
|
566 |
|
|
|
567 |
for (OfferPartner offerPartner : offerPartners) {
|
|
|
568 |
|
|
|
569 |
if (offerPartner.getFofoId() == loginDetails.getFofoId()) {
|
| 27352 |
tejbeer |
570 |
/*
|
|
|
571 |
* if (LocalDateTime.now().isAfter(offer.getStartDateTime()) &&
|
|
|
572 |
* LocalDateTime.now().isBefore(offer.getEndDateTime())) {
|
|
|
573 |
*/
|
| 27398 |
tejbeer |
574 |
int todayMonth = LocalDateTime.now().getMonthValue();
|
|
|
575 |
if (todayMonth == offer.getStartDateTime().getMonthValue()
|
|
|
576 |
|| todayMonth == offer.getEndDateTime().getMonthValue()) {
|
| 26674 |
tejbeer |
577 |
LocalDateTime cur = LocalDate.now().minusMonths(2).atStartOfDay();
|
| 26619 |
tejbeer |
578 |
LOGGER.info("value" + cur);
|
| 26588 |
tejbeer |
579 |
Map<Integer, Double> value = offerRepository.selectSumOfferByRetailer(
|
| 26675 |
tejbeer |
580 |
offer.getStartDateTime(), offer.getEndDateTime(), loginDetails.getFofoId(),
|
|
|
581 |
offer, true);
|
| 26588 |
tejbeer |
582 |
CreateOfferRequest createOfferRequest = new CreateOfferRequest();
|
|
|
583 |
List<Offermargin> offerMargins = offerMarginRepository
|
|
|
584 |
.selectByOfferId(offer.getId());
|
|
|
585 |
LOGGER.info("value" + offer.getId());
|
|
|
586 |
LOGGER.info("value" + value);
|
|
|
587 |
for (Offermargin om : offerMargins) {
|
| 26619 |
tejbeer |
588 |
if (value.get(loginDetails.getFofoId()) <= om.getValue()) {
|
| 26588 |
tejbeer |
589 |
createOfferRequest.setMargin(om.getMargin());
|
| 26694 |
tejbeer |
590 |
createOfferRequest.setValue(om.getValue());
|
| 26588 |
tejbeer |
591 |
createOfferRequest.setShortAmount(
|
|
|
592 |
om.getValue() - value.get(loginDetails.getFofoId()));
|
| 26674 |
tejbeer |
593 |
|
| 26588 |
tejbeer |
594 |
break;
|
|
|
595 |
} else {
|
|
|
596 |
createOfferRequest.setMargin(om.getMargin());
|
| 26675 |
tejbeer |
597 |
|
| 26588 |
tejbeer |
598 |
}
|
|
|
599 |
|
|
|
600 |
}
|
| 27360 |
tejbeer |
601 |
createOfferRequest.setId(offer.getId());
|
| 26588 |
tejbeer |
602 |
|
|
|
603 |
createOfferRequest.setName(offer.getName());
|
|
|
604 |
createOfferRequest.setDescription(offer.getDescription());
|
|
|
605 |
createOfferRequest.setTargetType(offer.getTargetType());
|
|
|
606 |
createOfferRequest.setAmountType(offer.getAmountType());
|
| 26694 |
tejbeer |
607 |
createOfferRequest.setStartDateTime(offer.getStartDateTime().toLocalDate());
|
|
|
608 |
createOfferRequest.setEndDateTime(offer.getEndDateTime().toLocalDate());
|
| 26588 |
tejbeer |
609 |
createOfferRequest.setTotalSale(value.get(loginDetails.getFofoId()));
|
| 27352 |
tejbeer |
610 |
createOfferRequest.setOfferMargin(offerMargins);
|
| 26588 |
tejbeer |
611 |
cors.add(createOfferRequest);
|
|
|
612 |
|
|
|
613 |
model.addAttribute("sales", value.get(loginDetails.getFofoId()));
|
|
|
614 |
}
|
|
|
615 |
}
|
|
|
616 |
|
|
|
617 |
}
|
| 26327 |
amit.gupta |
618 |
}
|
| 26588 |
tejbeer |
619 |
model.addAttribute("offers", cors);
|
|
|
620 |
|
| 26674 |
tejbeer |
621 |
}
|
| 26588 |
tejbeer |
622 |
|
| 25180 |
amit.gupta |
623 |
} catch (ProfitMandiBusinessException e) {
|
|
|
624 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
|
|
625 |
|
|
|
626 |
}
|
| 22481 |
ashik.ali |
627 |
}
|
| 25649 |
tejbeer |
628 |
|
|
|
629 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
| 25747 |
amit.gupta |
630 |
LocalDateTime lastMonthStart = currentMonthStart.minusMonths(1);
|
| 25653 |
amit.gupta |
631 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
|
|
632 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
|
| 25677 |
amit.gupta |
633 |
currentMonthEnd) / 2;
|
| 25747 |
amit.gupta |
634 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), lastMonthStart,
|
|
|
635 |
currentMonthStart) / 2;
|
|
|
636 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), LocalDateTime.MIN,
|
| 25677 |
amit.gupta |
637 |
currentMonthEnd) / 2;
|
|
|
638 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
|
|
639 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
|
|
640 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
| 25649 |
tejbeer |
641 |
|
| 25653 |
amit.gupta |
642 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true, currentMonthStart,
|
|
|
643 |
currentMonthEnd);
|
| 25651 |
tejbeer |
644 |
|
| 25653 |
amit.gupta |
645 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false,
|
|
|
646 |
currentMonthStart, currentMonthEnd);
|
|
|
647 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
|
|
648 |
invalidHygieneCount = 1;
|
|
|
649 |
}
|
|
|
650 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| 25651 |
tejbeer |
651 |
|
| 25197 |
amit.gupta |
652 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
|
|
653 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
| 27352 |
tejbeer |
654 |
if (loginDetails.isReadOnly()) {
|
| 27229 |
amit.gupta |
655 |
return "dashboard-readonly";
|
|
|
656 |
} else {
|
|
|
657 |
return "dashboard1";
|
|
|
658 |
}
|
| 21615 |
kshitij.so |
659 |
}
|
| 23923 |
amit.gupta |
660 |
|
| 27355 |
tejbeer |
661 |
@RequestMapping(value = "/getOfferMargins", method = RequestMethod.GET)
|
|
|
662 |
public String getOfferMargins(HttpServletRequest request,
|
|
|
663 |
@RequestParam(name = "offerId", defaultValue = "0") int offerId, Model model) throws Exception {
|
|
|
664 |
Offer offer = offerRepository.selectById(offerId);
|
|
|
665 |
|
|
|
666 |
LOGGER.info("offerId" + offer.getId());
|
|
|
667 |
|
|
|
668 |
Map<Integer, Double> value = offerRepository.selectSumOfferByRetailer(offer.getStartDateTime(),
|
|
|
669 |
offer.getEndDateTime(), 0, offer, true);
|
|
|
670 |
|
|
|
671 |
LOGGER.info("value" + value);
|
|
|
672 |
List<Offermargin> offerMargin = offerMarginRepository.selectByOfferId(offerId);
|
|
|
673 |
|
|
|
674 |
ItemTypeParams scp = gson.fromJson(offer.getItemParam(), ItemTypeParams.class);
|
|
|
675 |
if (offer.getItemCriteria().equals(ItemCriteriaType.Multiple_Brand)) {
|
|
|
676 |
List<String> brands = scp.getBrands();
|
|
|
677 |
model.addAttribute("brands", brands);
|
|
|
678 |
}
|
|
|
679 |
if (offer.getItemCriteria().equals(ItemCriteriaType.Item_Model)) {
|
|
|
680 |
List<Integer> catalogIds = scp.getCatalogId();
|
|
|
681 |
List<Item> newList = new ArrayList<>();
|
|
|
682 |
Set<Integer> catalogId = new HashSet<>();
|
|
|
683 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds.stream().collect(Collectors.toSet()));
|
|
|
684 |
for (Item item : items) {
|
|
|
685 |
if (catalogId.add(item.getCatalogItemId())) {
|
|
|
686 |
newList.add(item);
|
|
|
687 |
}
|
|
|
688 |
}
|
|
|
689 |
model.addAttribute("items", newList);
|
|
|
690 |
}
|
|
|
691 |
|
|
|
692 |
model.addAttribute("offerMargin", offerMargin);
|
|
|
693 |
model.addAttribute("offer", offer);
|
|
|
694 |
|
|
|
695 |
return "offer_margin_detail_partner";
|
|
|
696 |
|
|
|
697 |
}
|
|
|
698 |
|
| 26055 |
tejbeer |
699 |
private ChartModel getBrandChart(int fofoId) {
|
|
|
700 |
|
|
|
701 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
702 |
|
|
|
703 |
LOGGER.info("cur Date" + curDate.withDayOfMonth(1));
|
|
|
704 |
|
|
|
705 |
LOGGER.info("curDateYear" + curDate.with(LocalTime.MAX));
|
|
|
706 |
|
|
|
707 |
Map<String, Double> brandwisesale = fofoOrderItemRepository
|
|
|
708 |
.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
|
| 26244 |
tejbeer |
709 |
|
|
|
710 |
Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
|
|
|
711 |
fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
|
|
|
712 |
|
|
|
713 |
LOGGER.info("accesoriesmtdsale" + accesoriesmtdsale);
|
|
|
714 |
|
| 26055 |
tejbeer |
715 |
LOGGER.info("brandwisesale" + brandwisesale);
|
|
|
716 |
|
|
|
717 |
Map<String, Double> lmtdBrandWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
|
|
718 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
|
|
|
719 |
|
| 26244 |
tejbeer |
720 |
Map<Integer, Double> accesorieslmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
|
|
|
721 |
fofoId, curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1),
|
|
|
722 |
Optional.of(false));
|
|
|
723 |
LOGGER.info("accesorieslmtdsale" + accesorieslmtdsale);
|
| 26055 |
tejbeer |
724 |
ChartModel cm = new ChartModel();
|
|
|
725 |
|
|
|
726 |
List<String> labels = new ArrayList<>();
|
|
|
727 |
labels.addAll(brandwisesale.keySet());
|
| 26244 |
tejbeer |
728 |
labels.add("accessories");
|
| 26055 |
tejbeer |
729 |
List<Double> values = new ArrayList<>();
|
|
|
730 |
values.addAll(brandwisesale.values());
|
| 26244 |
tejbeer |
731 |
values.addAll(accesoriesmtdsale.values());
|
| 26055 |
tejbeer |
732 |
|
|
|
733 |
List<Double> lmtdValues = new ArrayList<>();
|
|
|
734 |
lmtdValues.addAll(lmtdBrandWiseSale.values());
|
| 26244 |
tejbeer |
735 |
lmtdValues.addAll(accesorieslmtdsale.values());
|
| 26055 |
tejbeer |
736 |
|
|
|
737 |
DatasetModel dsm = new DatasetModel();
|
|
|
738 |
dsm.setLabel("mtd sales");
|
|
|
739 |
|
|
|
740 |
List<String> backgroundColor = new ArrayList<>();
|
|
|
741 |
for (Entry<String, Double> bs : brandwisesale.entrySet()) {
|
|
|
742 |
backgroundColor.add("#3e95cd");
|
|
|
743 |
}
|
| 26244 |
tejbeer |
744 |
backgroundColor.add("#3e95cd");
|
| 26055 |
tejbeer |
745 |
dsm.setBackgroundColor(backgroundColor);
|
|
|
746 |
dsm.setData(values);
|
|
|
747 |
|
|
|
748 |
DatasetModel lmtddsm = new DatasetModel();
|
|
|
749 |
lmtddsm.setLabel("lmtd sales");
|
|
|
750 |
|
|
|
751 |
List<String> background = new ArrayList<>();
|
|
|
752 |
for (Entry<String, Double> bs : lmtdBrandWiseSale.entrySet()) {
|
|
|
753 |
background.add("#8e5ea2");
|
|
|
754 |
}
|
| 26244 |
tejbeer |
755 |
background.add("#8e5ea2");
|
| 26055 |
tejbeer |
756 |
lmtddsm.setBackgroundColor(background);
|
|
|
757 |
lmtddsm.setData(lmtdValues);
|
|
|
758 |
|
|
|
759 |
List<DatasetModel> datasets = new ArrayList<>();
|
|
|
760 |
datasets.add(dsm);
|
|
|
761 |
datasets.add(lmtddsm);
|
|
|
762 |
|
|
|
763 |
DataModel dm = new DataModel();
|
|
|
764 |
dm.setDatasets(datasets);
|
|
|
765 |
dm.setLabels(labels);
|
|
|
766 |
|
|
|
767 |
LegendModel lm = new LegendModel();
|
|
|
768 |
lm.setDisplay(true);
|
|
|
769 |
|
|
|
770 |
TitleModel tm = new TitleModel();
|
|
|
771 |
tm.setText("Brand Wise Sale Graph");
|
|
|
772 |
tm.setDisplay(true);
|
|
|
773 |
|
|
|
774 |
OptionsModel om = new OptionsModel();
|
|
|
775 |
om.setLegend(lm);
|
|
|
776 |
om.setTitle(tm);
|
|
|
777 |
|
|
|
778 |
cm.setType("bar");
|
|
|
779 |
cm.setData(dm);
|
|
|
780 |
cm.setOptions(om);
|
|
|
781 |
|
|
|
782 |
return cm;
|
|
|
783 |
|
|
|
784 |
}
|
|
|
785 |
|
| 26418 |
tejbeer |
786 |
private String adminPanel(int fofoId, String email, Model model) throws Exception {
|
| 26022 |
amit.gupta |
787 |
List<Menu> menus = null;
|
| 26011 |
amit.gupta |
788 |
try {
|
|
|
789 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
|
|
790 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
| 27545 |
tejbeer |
791 |
Map<Integer, PartnerDetailModel> warehousePartnerDetailMap = null;
|
| 27529 |
tejbeer |
792 |
ReporticoCacheTable rct = null;
|
| 27509 |
tejbeer |
793 |
Map<Integer, WarehouseWiseStockModel> warehouseStockMap = new HashMap<>();
|
|
|
794 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27539 |
tejbeer |
795 |
LinkedHashMap<Integer, String> wm = new LinkedHashMap<Integer, String>();
|
|
|
796 |
|
| 27591 |
tejbeer |
797 |
List<BrandWisePartnerSaleModel> partnersBrandSale = null;
|
| 27594 |
tejbeer |
798 |
|
|
|
799 |
List<BrandWisePartnerSaleModel> accessoriesBrandSales = null;
|
| 27539 |
tejbeer |
800 |
for (Map.Entry<Integer, String> entry : warehouseMap.entrySet()) {
|
|
|
801 |
wm.put(entry.getKey(), entry.getValue());
|
|
|
802 |
}
|
|
|
803 |
|
|
|
804 |
wm.put(0, "Total Values");
|
|
|
805 |
long stockValue = 0;
|
|
|
806 |
long stockQty = 0;
|
|
|
807 |
long pendingIndent = 0;
|
| 27542 |
tejbeer |
808 |
long tertiary = 0;
|
| 26418 |
tejbeer |
809 |
if (positions.size() > 0) {
|
| 27352 |
tejbeer |
810 |
if (positions.stream()
|
|
|
811 |
.filter(x -> x.getEscalationType().equals(EscalationType.L3)
|
|
|
812 |
|| x.getEscalationType().equals(EscalationType.L4)
|
|
|
813 |
|| x.getEscalationType().equals(EscalationType.L5))
|
|
|
814 |
.count() > 0) {
|
| 26418 |
tejbeer |
815 |
|
| 27556 |
tejbeer |
816 |
List<WarehouseWiseStockModel> warehouseStocks = saholicInventoryCISRepository
|
|
|
817 |
.selectGroupByWarehouse();
|
|
|
818 |
|
|
|
819 |
warehouseStockMap = warehouseStocks.stream()
|
| 27509 |
tejbeer |
820 |
.collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
|
| 27352 |
tejbeer |
821 |
|
| 27539 |
tejbeer |
822 |
if (!warehouseStocks.isEmpty()) {
|
|
|
823 |
for (WarehouseWiseStockModel warehouseStock : warehouseStocks) {
|
|
|
824 |
stockValue += warehouseStock.getStockValue();
|
|
|
825 |
stockQty += warehouseStock.getStockQty();
|
|
|
826 |
pendingIndent += warehouseStock.getPendingIndent();
|
| 27542 |
tejbeer |
827 |
tertiary += warehouseStock.getTertiary();
|
| 27539 |
tejbeer |
828 |
}
|
|
|
829 |
WarehouseWiseStockModel ws = new WarehouseWiseStockModel();
|
|
|
830 |
ws.setStockQty(stockQty);
|
|
|
831 |
ws.setStockValue(stockValue);
|
|
|
832 |
ws.setPendingIndent(pendingIndent);
|
| 27542 |
tejbeer |
833 |
ws.setTertiary(tertiary);
|
| 27539 |
tejbeer |
834 |
ws.setWarehouseId(0);
|
|
|
835 |
warehouseStockMap.put(0, ws);
|
|
|
836 |
|
|
|
837 |
}
|
| 27591 |
tejbeer |
838 |
|
|
|
839 |
warehousePartnerDetailMap = this.getWarehousePartnerDetail();
|
| 27529 |
tejbeer |
840 |
rct = reporticoCacheTableRepository.selectByTableName("SaholicInventoryCIS");
|
| 27591 |
tejbeer |
841 |
partnersBrandSale = fofoStoreRepository.selectGroupByBrandWarehousePartnerSale();
|
| 27594 |
tejbeer |
842 |
accessoriesBrandSales = fofoStoreRepository.selectGroupByBrandAccesoriesWarehousePartnerSale();
|
| 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 |
}
|
| 27529 |
tejbeer |
887 |
model.addAttribute("reporticoDate", rct);
|
| 27545 |
tejbeer |
888 |
model.addAttribute("warehousePartnerDetailMap", warehousePartnerDetailMap);
|
| 27539 |
tejbeer |
889 |
model.addAttribute("warehouseMap", wm);
|
| 27509 |
tejbeer |
890 |
model.addAttribute("warehouseStockMap", warehouseStockMap);
|
| 27591 |
tejbeer |
891 |
model.addAttribute("brandSales", partnersBrandSale);
|
| 27556 |
tejbeer |
892 |
|
| 27594 |
tejbeer |
893 |
model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
|
|
|
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)
|
| 27591 |
tejbeer |
1103 |
public String getWarehouseWiseBrandPartnerSale(HttpServletRequest request, Model model, @RequestParam String brand)
|
|
|
1104 |
throws Exception {
|
|
|
1105 |
List<WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
|
|
|
1106 |
.selectGroupByWarehouseBrandWisePartnerSale(brand);
|
| 27556 |
tejbeer |
1107 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 27591 |
tejbeer |
1108 |
|
|
|
1109 |
Set<String> brands = inventoryService.getAllTagListingBrands();
|
|
|
1110 |
model.addAttribute("warehouseWiseBrandPartnerSales", warehouseWiseBrandPartnerSales);
|
| 27556 |
tejbeer |
1111 |
model.addAttribute("warehouseMap", warehouseMap);
|
| 27591 |
tejbeer |
1112 |
model.addAttribute("brands", brands);
|
|
|
1113 |
model.addAttribute("selectedbrand", brand);
|
|
|
1114 |
|
|
|
1115 |
LOGGER.info("warehouseWiseBrandPartnerSales" + warehouseWiseBrandPartnerSales);
|
|
|
1116 |
return "warehousewise_brand_partners_sale";
|
| 27556 |
tejbeer |
1117 |
}
|
|
|
1118 |
|
| 27594 |
tejbeer |
1119 |
@RequestMapping(value = "/getWarehouseWiseAccesoriesBrandPartnerSale", method = RequestMethod.GET)
|
|
|
1120 |
public String getWarehouseWiseAccesoriesBrandPartnerSale(HttpServletRequest request, Model model,
|
|
|
1121 |
@RequestParam String brand) throws Exception {
|
|
|
1122 |
List<WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
|
|
|
1123 |
.selectGroupByWarehouseAccesoriesBrandWisePartnerSale(brand);
|
|
|
1124 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1125 |
|
|
|
1126 |
Set<String> brands = inventoryService.getAllTagListingBrands();
|
|
|
1127 |
model.addAttribute("warehouseWiseBrandPartnerSales", warehouseWiseBrandPartnerSales);
|
|
|
1128 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1129 |
model.addAttribute("brands", brands);
|
|
|
1130 |
model.addAttribute("selectedbrand", brand);
|
|
|
1131 |
|
|
|
1132 |
LOGGER.info("warehouseWiseBrandPartnerSales" + warehouseWiseBrandPartnerSales);
|
|
|
1133 |
return "warehousewise_accessoriesbrand_sale";
|
|
|
1134 |
}
|
|
|
1135 |
|
| 27556 |
tejbeer |
1136 |
@RequestMapping(value = "/getWarehouseBrandWiseItemSale", method = RequestMethod.GET)
|
|
|
1137 |
public String getWarehouseBrandWiseItemSale(HttpServletRequest request, Model model,
|
|
|
1138 |
@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
|
|
1139 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1140 |
List<WarehouseBrandWiseItemSaleModel> branditemSales = fofoStoreRepository
|
|
|
1141 |
.selectWarehouseBrandItemSale(warehouseId, brand);
|
|
|
1142 |
model.addAttribute("branditemSales", branditemSales);
|
|
|
1143 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1144 |
return "warehouse_partner_itemwise_sale";
|
|
|
1145 |
}
|
|
|
1146 |
|
| 27594 |
tejbeer |
1147 |
@RequestMapping(value = "/getWarehouseAccesoriesBrandWiseItemSale", method = RequestMethod.GET)
|
|
|
1148 |
public String getWarehouseAccesoriesBrandWiseItemSale(HttpServletRequest request, Model model,
|
|
|
1149 |
@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
|
|
|
1150 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1151 |
List<WarehouseBrandWiseItemSaleModel> branditemSales = fofoStoreRepository
|
|
|
1152 |
.selectWarehouseAccesoriesBrandItemSale(warehouseId, brand);
|
|
|
1153 |
model.addAttribute("branditemSales", branditemSales);
|
|
|
1154 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1155 |
return "warehouse_accessories_itemwsie_sale";
|
|
|
1156 |
}
|
|
|
1157 |
|
| 26012 |
amit.gupta |
1158 |
private List<Menu> prepareMenu(List<Menu> menus) {
|
|
|
1159 |
List<Menu> returnMenu = new ArrayList<>();
|
|
|
1160 |
Map<Menu, List<Menu>> subMenuMap = new HashMap<Menu, List<Menu>>();
|
|
|
1161 |
for (Menu menu : menus) {
|
|
|
1162 |
if (menu.get_parent() == null) {
|
| 26014 |
amit.gupta |
1163 |
if (!subMenuMap.containsKey(menu)) {
|
| 26012 |
amit.gupta |
1164 |
subMenuMap.put(menu, new ArrayList<>());
|
| 26011 |
amit.gupta |
1165 |
}
|
|
|
1166 |
} else {
|
| 26012 |
amit.gupta |
1167 |
Menu parentMenu = menu.get_parent();
|
|
|
1168 |
if (!subMenuMap.containsKey(parentMenu)) {
|
|
|
1169 |
subMenuMap.put(parentMenu, new ArrayList<>());
|
| 26011 |
amit.gupta |
1170 |
}
|
| 26012 |
amit.gupta |
1171 |
subMenuMap.get(parentMenu).add(menu);
|
| 26011 |
amit.gupta |
1172 |
}
|
|
|
1173 |
}
|
| 26012 |
amit.gupta |
1174 |
subMenuMap.entrySet().stream().forEach(entry -> {
|
|
|
1175 |
entry.getKey().setSubMenus(entry.getValue());
|
|
|
1176 |
returnMenu.add(entry.getKey());
|
|
|
1177 |
});
|
|
|
1178 |
return returnMenu;
|
| 26005 |
amit.gupta |
1179 |
}
|
|
|
1180 |
|
| 24288 |
amit.gupta |
1181 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
1182 |
private boolean hasGift(int fofoId) {
|
|
|
1183 |
try {
|
| 24288 |
amit.gupta |
1184 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
1185 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
1186 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1187 |
return false;
|
|
|
1188 |
}
|
|
|
1189 |
}
|
| 24288 |
amit.gupta |
1190 |
|
| 22354 |
ashik.ali |
1191 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 23923 |
amit.gupta |
1192 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 22354 |
ashik.ali |
1193 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
1194 |
return "contact-us";
|
|
|
1195 |
}
|
| 23923 |
amit.gupta |
1196 |
|
| 25649 |
tejbeer |
1197 |
@RequestMapping(value = "/notifications", method = RequestMethod.GET)
|
| 25683 |
tejbeer |
1198 |
public String getNotificationsWithType(HttpServletRequest request,
|
|
|
1199 |
@RequestParam(required = false) MessageType messageType,
|
| 25649 |
tejbeer |
1200 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
1201 |
@RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
|
|
|
1202 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26060 |
tejbeer |
1203 |
int userId = 0;
|
|
|
1204 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
1205 |
if (isAdmin) {
|
|
|
1206 |
userId = loginDetails.getFofoId();
|
|
|
1207 |
} else {
|
|
|
1208 |
userId = userAccountRepository.selectUserIdByRetailerId(loginDetails.getFofoId());
|
|
|
1209 |
}
|
| 25683 |
tejbeer |
1210 |
List<Notification> notifications = null;
|
|
|
1211 |
|
| 26086 |
tejbeer |
1212 |
List<NotificationCampaign> notificationCampaigns = notificationCampaignRepository.getNotifications(messageType,
|
|
|
1213 |
userId, offset, limit);
|
|
|
1214 |
LOGGER.info("messageType" + messageType);
|
|
|
1215 |
notifications = getNotifications(notificationCampaigns, messageType);
|
|
|
1216 |
|
| 25683 |
tejbeer |
1217 |
model.addAttribute("notifications", notifications);
|
|
|
1218 |
|
|
|
1219 |
LOGGER.info("notifications" + notifications);
|
|
|
1220 |
return "notification-template";
|
|
|
1221 |
}
|
|
|
1222 |
|
|
|
1223 |
public List<Notification> getNotifications(List<NotificationCampaign> nc, MessageType messageType)
|
|
|
1224 |
throws ProfitMandiBusinessException {
|
|
|
1225 |
List<Notification> notifications = new ArrayList<>();
|
|
|
1226 |
Document document = null;
|
|
|
1227 |
if (messageType != null) {
|
|
|
1228 |
for (NotificationCampaign notificationCampaign : nc) {
|
|
|
1229 |
if (notificationCampaign.getMessageType() == messageType) {
|
| 25649 |
tejbeer |
1230 |
Notification ns = new Notification();
|
|
|
1231 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
|
|
1232 |
SimpleCampaignParams.class);
|
|
|
1233 |
Campaign campaign = new SimpleCampaign(scp);
|
|
|
1234 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
|
|
1235 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
|
|
1236 |
ns.setType(campaign.getType());
|
|
|
1237 |
ns.setMessage(campaign.getMessage());
|
|
|
1238 |
ns.setTitle(campaign.getTitle());
|
| 25651 |
tejbeer |
1239 |
if (notificationCampaign.getDocumentId() != null) {
|
|
|
1240 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
|
|
1241 |
ns.setDocumentName(document.getDisplayName());
|
|
|
1242 |
}
|
| 25683 |
tejbeer |
1243 |
ns.setUrl(campaign.getUrl());
|
| 25649 |
tejbeer |
1244 |
ns.setShowImage(campaign.getShowImage());
|
|
|
1245 |
ns.setImageUrl(campaign.getImageUrl());
|
| 25683 |
tejbeer |
1246 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
|
|
1247 |
ns.setMessageType(notificationCampaign.getMessageType());
|
| 25649 |
tejbeer |
1248 |
ns.setCreated(
|
|
|
1249 |
notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30))
|
|
|
1250 |
* 1000);
|
|
|
1251 |
if (LocalDateTime.now().isAfter(expire)) {
|
|
|
1252 |
ns.setExpired(true);
|
|
|
1253 |
} else {
|
|
|
1254 |
ns.setExpired(false);
|
|
|
1255 |
}
|
|
|
1256 |
notifications.add(ns);
|
|
|
1257 |
}
|
|
|
1258 |
}
|
| 25683 |
tejbeer |
1259 |
} else {
|
|
|
1260 |
for (NotificationCampaign notificationCampaign : nc) {
|
|
|
1261 |
|
|
|
1262 |
Notification ns = new Notification();
|
|
|
1263 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
|
|
1264 |
SimpleCampaignParams.class);
|
|
|
1265 |
Campaign campaign = new SimpleCampaign(scp);
|
|
|
1266 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
|
|
1267 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
|
|
1268 |
ns.setType(campaign.getType());
|
|
|
1269 |
ns.setMessage(campaign.getMessage());
|
|
|
1270 |
ns.setTitle(campaign.getTitle());
|
|
|
1271 |
if (notificationCampaign.getDocumentId() != null) {
|
|
|
1272 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
|
|
1273 |
ns.setDocumentName(document.getDisplayName());
|
|
|
1274 |
}
|
|
|
1275 |
ns.setUrl(campaign.getUrl());
|
|
|
1276 |
ns.setShowImage(campaign.getShowImage());
|
|
|
1277 |
ns.setImageUrl(campaign.getImageUrl());
|
|
|
1278 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
|
|
1279 |
ns.setMessageType(notificationCampaign.getMessageType());
|
|
|
1280 |
ns.setCreated(notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30))
|
|
|
1281 |
* 1000);
|
|
|
1282 |
if (LocalDateTime.now().isAfter(expire)) {
|
|
|
1283 |
ns.setExpired(true);
|
|
|
1284 |
} else {
|
|
|
1285 |
ns.setExpired(false);
|
|
|
1286 |
}
|
|
|
1287 |
notifications.add(ns);
|
|
|
1288 |
}
|
|
|
1289 |
|
| 25649 |
tejbeer |
1290 |
}
|
| 25683 |
tejbeer |
1291 |
return notifications;
|
| 25651 |
tejbeer |
1292 |
|
|
|
1293 |
}
|
| 25649 |
tejbeer |
1294 |
|
| 25651 |
tejbeer |
1295 |
@RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
|
|
|
1296 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
|
|
1297 |
@RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, @RequestParam int cid)
|
|
|
1298 |
throws ProfitMandiBusinessException {
|
|
|
1299 |
Document document = documentRepository.selectById(documentId);
|
|
|
1300 |
NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
|
|
|
1301 |
if (nc.getDocumentId() == null) {
|
|
|
1302 |
throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
|
|
|
1303 |
}
|
|
|
1304 |
if (nc.getDocumentId() != documentId) {
|
|
|
1305 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, documentId, "RTLR_1014");
|
|
|
1306 |
}
|
|
|
1307 |
return responseSender.ok(document);
|
| 25649 |
tejbeer |
1308 |
}
|
|
|
1309 |
|
| 25651 |
tejbeer |
1310 |
@RequestMapping(value = "/notifyDocument/download", method = RequestMethod.GET)
|
|
|
1311 |
public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request, @RequestParam int cid, Model model)
|
|
|
1312 |
throws ProfitMandiBusinessException {
|
|
|
1313 |
|
|
|
1314 |
NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
|
|
|
1315 |
|
|
|
1316 |
if (nc.getDocumentId() == null) {
|
|
|
1317 |
throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
|
|
|
1318 |
}
|
|
|
1319 |
|
|
|
1320 |
Document document = documentRepository.selectById(nc.getDocumentId());
|
|
|
1321 |
|
|
|
1322 |
FileInputStream file = null;
|
|
|
1323 |
try {
|
|
|
1324 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
|
|
1325 |
} catch (FileNotFoundException e) {
|
|
|
1326 |
LOGGER.error("Retailer Document file not found : ", e);
|
|
|
1327 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
|
|
1328 |
}
|
|
|
1329 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
|
|
1330 |
// ByteArrayOutputStream();
|
|
|
1331 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
|
|
1332 |
|
|
|
1333 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
1334 |
String contentType = "";
|
|
|
1335 |
if (document.getContentType() == ContentType.JPEG) {
|
|
|
1336 |
contentType = "image/jpeg";
|
|
|
1337 |
} else if (document.getContentType() == ContentType.PNG) {
|
|
|
1338 |
contentType = "image/png";
|
|
|
1339 |
} else if (document.getContentType() == ContentType.PDF) {
|
|
|
1340 |
contentType = "application/pdf";
|
|
|
1341 |
}
|
|
|
1342 |
headers.set("Content-Type", contentType);
|
|
|
1343 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
|
|
1344 |
headers.setContentLength(document.getSize());
|
|
|
1345 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
|
|
1346 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
1347 |
}
|
| 26460 |
amit.gupta |
1348 |
|
|
|
1349 |
public Map<Integer, PartnerDetailModel> getL2AuthUserPartnerDetail() throws Exception {
|
| 26445 |
amit.gupta |
1350 |
LOGGER.info("getL2AuthUserPartnerDetail Started");
|
| 26460 |
amit.gupta |
1351 |
Map<Integer, List<Integer>> L2L1Mapping = csService.getL2L1Mapping();
|
| 26422 |
tejbeer |
1352 |
Map<Integer, Integer> authIdAndleadsCountMap = new HashMap<>();
|
|
|
1353 |
for (Entry<Integer, List<Integer>> l2l1 : L2L1Mapping.entrySet()) {
|
|
|
1354 |
List<Integer> authIds = l2l1.getValue();
|
|
|
1355 |
authIds.add(l2l1.getKey());
|
|
|
1356 |
|
|
|
1357 |
List<Lead> leads = leadRepository.selectByAssignAuthIdsAndStatus(authIds, LeadStatus.followUp);
|
| 26433 |
tejbeer |
1358 |
LOGGER.info("authIdAndleadsCountMap" + authIdAndleadsCountMap);
|
| 26422 |
tejbeer |
1359 |
AuthUser auth = authRepository.selectById(l2l1.getKey());
|
| 26431 |
tejbeer |
1360 |
if (!leads.isEmpty()) {
|
|
|
1361 |
authIdAndleadsCountMap.put(auth.getId(), leads.size());
|
|
|
1362 |
} else {
|
|
|
1363 |
authIdAndleadsCountMap.put(auth.getId(), 0);
|
|
|
1364 |
}
|
| 26422 |
tejbeer |
1365 |
}
|
| 26468 |
amit.gupta |
1366 |
|
| 26460 |
amit.gupta |
1367 |
Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
|
| 27352 |
tejbeer |
1368 |
List<Integer> unmappedPartners = partnerStats.entrySet().stream().map(x -> x.getKey())
|
|
|
1369 |
.collect(Collectors.toList());
|
| 26433 |
tejbeer |
1370 |
LOGGER.info("authIdAndleadsCountMap" + authIdAndleadsCountMap);
|
| 26422 |
tejbeer |
1371 |
|
| 26460 |
amit.gupta |
1372 |
Map<Integer, PartnerDetailModel> authIdAndallValues = new LinkedHashMap<>();
|
| 26422 |
tejbeer |
1373 |
|
| 26460 |
amit.gupta |
1374 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
|
|
1375 |
for (int authUserId : pp.keySet()) {
|
|
|
1376 |
if (L2L1Mapping.keySet().contains(authUserId)) {
|
|
|
1377 |
List<Integer> fofoIds = pp.get(authUserId);
|
| 26997 |
amit.gupta |
1378 |
unmappedPartners.removeAll(fofoIds);
|
| 26468 |
amit.gupta |
1379 |
List<PartnerDetailModel> partnerDetails = fofoIds.stream().map(x -> partnerStats.get(x))
|
|
|
1380 |
.collect(Collectors.toList());
|
| 26927 |
amit.gupta |
1381 |
LOGGER.info("authUserId {}, partnerDetails {}" + authUserId, partnerDetails);
|
| 26460 |
amit.gupta |
1382 |
PartnerDetailModel partnerDetailModel = partnerStatsService.getAggregateStats(partnerDetails);
|
|
|
1383 |
authIdAndallValues.put(authUserId, partnerDetailModel);
|
| 26422 |
tejbeer |
1384 |
}
|
|
|
1385 |
}
|
| 26997 |
amit.gupta |
1386 |
List<PartnerDetailModel> unmappedPartnerDetails = unmappedPartners.stream().map(x -> partnerStats.get(x))
|
|
|
1387 |
.collect(Collectors.toList());
|
| 26468 |
amit.gupta |
1388 |
PartnerDetailModel partnerDetailModel = partnerStatsService
|
|
|
1389 |
.getAggregateStats(new ArrayList<>(partnerStats.values()));
|
| 27000 |
amit.gupta |
1390 |
authIdAndallValues.put(-1, partnerStatsService.getAggregateStats(unmappedPartnerDetails));
|
| 26460 |
amit.gupta |
1391 |
authIdAndallValues.put(0, partnerDetailModel);
|
| 26422 |
tejbeer |
1392 |
return authIdAndallValues;
|
|
|
1393 |
}
|
|
|
1394 |
|
| 27545 |
tejbeer |
1395 |
public Map<Integer, PartnerDetailModel> getWarehousePartnerDetail() throws Exception {
|
|
|
1396 |
|
|
|
1397 |
Map<Integer, PartnerDetailModel> warehouseIdAndallValues = new LinkedHashMap<>();
|
|
|
1398 |
Map<Integer, List<FofoStore>> warehousePartnerMap = fofoStoreRepository.getWarehousePartnerMap();
|
|
|
1399 |
Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
|
|
|
1400 |
|
|
|
1401 |
for (Entry<Integer, List<FofoStore>> warehouse : warehousePartnerMap.entrySet()) {
|
|
|
1402 |
List<Integer> fofoIds = warehouse.getValue().stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
1403 |
List<PartnerDetailModel> partnerDetails = fofoIds.stream().map(x -> partnerStats.get(x))
|
|
|
1404 |
.collect(Collectors.toList());
|
|
|
1405 |
LOGGER.info("partnerDetails" + partnerDetails);
|
|
|
1406 |
|
|
|
1407 |
PartnerDetailModel partnerDetailModel = partnerStatsService.getAggregateStats(partnerDetails);
|
|
|
1408 |
|
|
|
1409 |
warehouseIdAndallValues.put(warehouse.getKey(), partnerDetailModel);
|
|
|
1410 |
}
|
|
|
1411 |
LOGGER.info("warehouseIdAndallValues" + warehouseIdAndallValues);
|
| 27548 |
tejbeer |
1412 |
PartnerDetailModel partnerDetailModel = partnerStatsService
|
|
|
1413 |
.getAggregateStats(new ArrayList<>(partnerStats.values()));
|
|
|
1414 |
warehouseIdAndallValues.put(0, partnerDetailModel);
|
| 27545 |
tejbeer |
1415 |
|
|
|
1416 |
return warehouseIdAndallValues;
|
|
|
1417 |
}
|
|
|
1418 |
|
| 27579 |
tejbeer |
1419 |
@RequestMapping(value = "/getItemWiseTertiary", method = RequestMethod.GET)
|
|
|
1420 |
public String getItemWiseTertiary(HttpServletRequest request,
|
|
|
1421 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model)
|
|
|
1422 |
throws ProfitMandiBusinessException {
|
|
|
1423 |
List<ItemWiseTertiaryModel> itemWiseTertiary = fofoOrderRepository.SelectItemWiseTertiary(fofoId);
|
|
|
1424 |
|
|
|
1425 |
LOGGER.info("itemWiseTertiary" + itemWiseTertiary);
|
| 27586 |
tejbeer |
1426 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
|
|
1427 |
model.addAttribute("customRetailer", customRetailer);
|
| 27579 |
tejbeer |
1428 |
model.addAttribute("itemWiseTertiary", itemWiseTertiary);
|
|
|
1429 |
return "item-wise-tertiary";
|
|
|
1430 |
}
|
|
|
1431 |
|
| 27586 |
tejbeer |
1432 |
@RequestMapping(value = "/getItemWiseIndent", method = RequestMethod.GET)
|
|
|
1433 |
public String getItemWiseIndent(HttpServletRequest request,
|
|
|
1434 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model)
|
|
|
1435 |
throws ProfitMandiBusinessException {
|
|
|
1436 |
|
|
|
1437 |
List<Order> unbilledOrders = transactionService.getInTransitOrders(fofoId);
|
|
|
1438 |
model.addAttribute("unbilledOrders", unbilledOrders);
|
|
|
1439 |
|
|
|
1440 |
return "item-wise-indent";
|
|
|
1441 |
}
|
|
|
1442 |
|
| 27599 |
tejbeer |
1443 |
@RequestMapping(value = "/getPartnerPendingIndentItem", method = RequestMethod.GET)
|
|
|
1444 |
public String getPartnerPendingIndentItem(HttpServletRequest request, @RequestParam int warehouseId,
|
|
|
1445 |
@RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
|
|
|
1446 |
List<PartnerPendingIndentItemModel> partnerPendingIndent = fofoStoreRepository
|
|
|
1447 |
.selectPartnerPendingIndentItem(itemId, warehouseId);
|
|
|
1448 |
|
|
|
1449 |
model.addAttribute("partnerPendingIndent", partnerPendingIndent);
|
|
|
1450 |
return "partner-pending-indent-item";
|
|
|
1451 |
}
|
|
|
1452 |
|
| 21615 |
kshitij.so |
1453 |
}
|