| 21615 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 23568 |
govind |
3 |
import java.io.IOException;
|
|
|
4 |
import java.net.URISyntaxException;
|
| 24288 |
amit.gupta |
5 |
import java.time.DayOfWeek;
|
|
|
6 |
import java.time.LocalDate;
|
| 24276 |
amit.gupta |
7 |
import java.time.LocalDateTime;
|
| 24880 |
govind |
8 |
import java.time.LocalTime;
|
| 24288 |
amit.gupta |
9 |
import java.time.temporal.TemporalAdjusters;
|
| 24339 |
amit.gupta |
10 |
import java.util.ArrayList;
|
| 24880 |
govind |
11 |
import java.util.HashMap;
|
| 25136 |
amit.gupta |
12 |
import java.util.LinkedHashMap;
|
| 23884 |
amit.gupta |
13 |
import java.util.List;
|
| 24880 |
govind |
14 |
import java.util.Map;
|
|
|
15 |
import java.util.Set;
|
|
|
16 |
import java.util.function.IntFunction;
|
|
|
17 |
import java.util.function.IntPredicate;
|
|
|
18 |
import java.util.stream.Collectors;
|
| 23568 |
govind |
19 |
|
| 22086 |
amit.gupta |
20 |
import javax.servlet.http.HttpServletRequest;
|
|
|
21 |
|
| 23786 |
amit.gupta |
22 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
23 |
import org.apache.logging.log4j.Logger;
|
| 24321 |
amit.gupta |
24 |
import org.json.JSONArray;
|
|
|
25 |
import org.json.JSONObject;
|
| 22481 |
ashik.ali |
26 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23379 |
ashik.ali |
27 |
import org.springframework.beans.factory.annotation.Value;
|
| 21615 |
kshitij.so |
28 |
import org.springframework.stereotype.Controller;
|
| 22481 |
ashik.ali |
29 |
import org.springframework.transaction.annotation.Transactional;
|
| 22073 |
ashik.ali |
30 |
import org.springframework.ui.Model;
|
| 21615 |
kshitij.so |
31 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
32 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 24098 |
tejbeer |
33 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21615 |
kshitij.so |
34 |
|
| 24996 |
amit.gupta |
35 |
import com.mongodb.DBObject;
|
| 24880 |
govind |
36 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| 22481 |
ashik.ali |
37 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24996 |
amit.gupta |
38 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
| 24203 |
amit.gupta |
39 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 24880 |
govind |
40 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
|
|
41 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| 24098 |
tejbeer |
42 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
| 24880 |
govind |
43 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
|
|
44 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 22654 |
ashik.ali |
45 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 24288 |
amit.gupta |
46 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 24880 |
govind |
47 |
import com.spice.profitmandi.dao.enumuration.dtr.RechargeType;
|
|
|
48 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 22481 |
ashik.ali |
49 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24880 |
govind |
50 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
|
|
51 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| 24996 |
amit.gupta |
52 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 24098 |
tejbeer |
53 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
| 24880 |
govind |
54 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| 24203 |
amit.gupta |
55 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24880 |
govind |
56 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 24288 |
amit.gupta |
57 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 24336 |
amit.gupta |
58 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 23844 |
amit.gupta |
59 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 23884 |
amit.gupta |
60 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
|
|
61 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 22481 |
ashik.ali |
62 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
63 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24263 |
tejbeer |
64 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22481 |
ashik.ali |
65 |
|
| 21615 |
kshitij.so |
66 |
@Controller
|
| 22481 |
ashik.ali |
67 |
@Transactional(rollbackFor = Throwable.class)
|
| 21615 |
kshitij.so |
68 |
public class DashboardController {
|
| 23923 |
amit.gupta |
69 |
|
| 23379 |
ashik.ali |
70 |
@Value("${web.api.host}")
|
|
|
71 |
private String webApiHost;
|
| 23923 |
amit.gupta |
72 |
|
| 24072 |
amit.gupta |
73 |
@Value("${web.api.scheme}")
|
|
|
74 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
75 |
|
| 24078 |
amit.gupta |
76 |
@Value("${web.api.root}")
|
|
|
77 |
private String webApiRoot;
|
|
|
78 |
|
| 23379 |
ashik.ali |
79 |
@Value("${web.api.port}")
|
|
|
80 |
private int webApiPort;
|
| 21615 |
kshitij.so |
81 |
|
| 22481 |
ashik.ali |
82 |
@Autowired
|
| 22927 |
ashik.ali |
83 |
private CookiesProcessor cookiesProcessor;
|
| 23923 |
amit.gupta |
84 |
|
| 23568 |
govind |
85 |
@Autowired
|
| 24880 |
govind |
86 |
private ItemRepository itemRepository;
|
|
|
87 |
|
|
|
88 |
@Autowired
|
| 23786 |
amit.gupta |
89 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
90 |
|
| 23838 |
ashik.ali |
91 |
@Autowired
|
|
|
92 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
93 |
|
|
|
94 |
@Autowired
|
| 24880 |
govind |
95 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 23923 |
amit.gupta |
96 |
|
| 23884 |
amit.gupta |
97 |
@Autowired
|
| 24880 |
govind |
98 |
private PartnerInvestmentService partnerInvestmentService;
|
| 24288 |
amit.gupta |
99 |
|
| 23884 |
amit.gupta |
100 |
@Autowired
|
| 24880 |
govind |
101 |
private InsurancePolicyRepository insurancePolicyRepository;
|
| 23923 |
amit.gupta |
102 |
/*
|
|
|
103 |
* @Autowired private ScanRepository scanRepository;
|
|
|
104 |
*/
|
| 24880 |
govind |
105 |
@Autowired
|
|
|
106 |
private RechargeTransactionRepository rechargeTransactionRepository;
|
| 23923 |
amit.gupta |
107 |
|
| 23884 |
amit.gupta |
108 |
@Autowired
|
|
|
109 |
private TransactionService transactionService;
|
| 25136 |
amit.gupta |
110 |
|
| 24996 |
amit.gupta |
111 |
@Autowired
|
|
|
112 |
private InventoryService inventoryService;
|
| 24263 |
tejbeer |
113 |
|
| 24098 |
tejbeer |
114 |
@Autowired
|
| 24263 |
tejbeer |
115 |
private MVCResponseSender mvcResponseSender;
|
|
|
116 |
|
|
|
117 |
@Autowired
|
| 24098 |
tejbeer |
118 |
private NotificationPanelRepository notificationPanelRepository;
|
| 23923 |
amit.gupta |
119 |
|
| 24203 |
amit.gupta |
120 |
@Autowired
|
|
|
121 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
122 |
|
| 24880 |
govind |
123 |
@Autowired
|
|
|
124 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
|
|
125 |
|
|
|
126 |
@Autowired
|
|
|
127 |
private InsuranceProviderRepository insuranceProviderRepository;
|
| 25136 |
amit.gupta |
128 |
|
| 24996 |
amit.gupta |
129 |
@Autowired
|
|
|
130 |
private Mongo mongoClient;
|
| 24880 |
govind |
131 |
|
| 23568 |
govind |
132 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 23923 |
amit.gupta |
133 |
|
| 25136 |
amit.gupta |
134 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
|
|
135 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
|
|
136 |
LOGGER.info("In Dashboard1");
|
|
|
137 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
138 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices());
|
|
|
139 |
model.addAttribute("salesMap", this.getSales());
|
|
|
140 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
|
|
141 |
return "dashboard1";
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
|
|
145 |
Map<String, Object> investments = new LinkedHashMap<>();
|
|
|
146 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 1);
|
|
|
147 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
|
|
|
148 |
LocalDate lastMonthStart = LocalDate.now().minusMonths(1).withDayOfMonth(1);
|
|
|
149 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
|
|
150 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
|
|
151 |
if (yesterdayInvestment == null) {
|
|
|
152 |
yesterdayInvestment = new PartnerDailyInvestment();
|
|
|
153 |
}
|
|
|
154 |
List<PartnerDailyInvestment> lastMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
|
|
155 |
lastMonthStart, lastMonthStart.withDayOfMonth(lastMonthStart.lengthOfMonth()));
|
|
|
156 |
|
|
|
157 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
|
|
158 |
currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
|
|
159 |
|
|
|
160 |
long lastMonthShortDays = lastMonthInvestments.stream().filter(x -> x.getShortPercentage() > 10)
|
|
|
161 |
.collect(Collectors.counting());
|
|
|
162 |
long mtdShortDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() > 10)
|
|
|
163 |
.collect(Collectors.counting());
|
|
|
164 |
investments.put("Today", investment.getTotalInvestment());
|
|
|
165 |
investments.put("Yesterday", yesterdayInvestment.getTotalInvestment());
|
|
|
166 |
investments.put("Short MTD", mtdShortDays);
|
|
|
167 |
investments.put("Short Last Month", lastMonthShortDays);
|
|
|
168 |
return investments;
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
private Map<String, Float> getSales() {
|
|
|
172 |
Map<String, Float> salesMap = new LinkedHashMap<>();
|
|
|
173 |
salesMap.put("Today", 10000f);
|
|
|
174 |
salesMap.put("Yesterday", 100000f);
|
|
|
175 |
salesMap.put("MTD", 100000f);
|
|
|
176 |
return salesMap;
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
private List<BrandStockPrice> getBrandStockPrices() {
|
|
|
180 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
|
|
181 |
BrandStockPrice brandStockPrice = new BrandStockPrice();
|
|
|
182 |
brandStockPrice.setBrand("Nokia");
|
|
|
183 |
brandStockPrice.setBrandUrl("");
|
|
|
184 |
brandStockPrice.setRank(1);
|
|
|
185 |
brandStockPrice.setTotalQty(10);
|
|
|
186 |
brandStockPrice.setTotalValue(10000);
|
|
|
187 |
BrandStockPrice brandStockPrice1 = new BrandStockPrice();
|
|
|
188 |
brandStockPrice1.setBrand("Samsung");
|
|
|
189 |
brandStockPrice1.setBrandUrl("");
|
|
|
190 |
brandStockPrice1.setRank(1);
|
|
|
191 |
brandStockPrice1.setTotalQty(10);
|
|
|
192 |
brandStockPrice1.setTotalValue(10000);
|
|
|
193 |
BrandStockPrice brandStockPrice2 = new BrandStockPrice();
|
|
|
194 |
brandStockPrice2.setBrand("Oppo");
|
|
|
195 |
brandStockPrice2.setBrandUrl("");
|
|
|
196 |
brandStockPrice2.setRank(1);
|
|
|
197 |
brandStockPrice2.setTotalQty(10);
|
|
|
198 |
brandStockPrice2.setTotalValue(10000);
|
|
|
199 |
BrandStockPrice brandStockPrice3 = new BrandStockPrice();
|
|
|
200 |
brandStockPrice3.setBrand("Vivo");
|
|
|
201 |
brandStockPrice3.setBrandUrl("");
|
|
|
202 |
brandStockPrice3.setRank(1);
|
|
|
203 |
brandStockPrice3.setTotalQty(10);
|
|
|
204 |
brandStockPrice3.setTotalValue(10000);
|
|
|
205 |
brandStockPrices.add(brandStockPrice);
|
|
|
206 |
brandStockPrices.add(brandStockPrice1);
|
|
|
207 |
brandStockPrices.add(brandStockPrice2);
|
|
|
208 |
brandStockPrices.add(brandStockPrice3);
|
|
|
209 |
return brandStockPrices;
|
|
|
210 |
}
|
|
|
211 |
|
| 21615 |
kshitij.so |
212 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 24312 |
amit.gupta |
213 |
public String dashboard(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24098 |
tejbeer |
214 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 23923 |
amit.gupta |
215 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
|
|
216 |
// LOGGER.info("scanRepository.selectScansByInventoryItemId(1)",
|
|
|
217 |
// scanRepository.selectScansByInventoryItemId(1));
|
| 23884 |
amit.gupta |
218 |
LOGGER.info("In Dashboard");
|
| 22927 |
ashik.ali |
219 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23923 |
amit.gupta |
220 |
|
| 22481 |
ashik.ali |
221 |
FofoStore fofoStore = null;
|
|
|
222 |
try {
|
| 22927 |
ashik.ali |
223 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
224 |
} catch (ProfitMandiBusinessException e) {
|
| 22927 |
ashik.ali |
225 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
226 |
}
|
| 23884 |
amit.gupta |
227 |
|
| 24312 |
amit.gupta |
228 |
float sale = 0;
|
| 23923 |
amit.gupta |
229 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
| 24263 |
tejbeer |
230 |
model.addAttribute("sale", sale);
|
|
|
231 |
List<NotificationData> notificationData = null;
|
|
|
232 |
long size = 0;
|
|
|
233 |
|
|
|
234 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
|
|
235 |
size = notificationPanelRepository.selectAllCount();
|
|
|
236 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
237 |
|
|
|
238 |
LOGGER.info("notification_data {}", size);
|
| 24880 |
govind |
239 |
// Map<String, Object> saleSummary=this.getAllSaleDetails(loginDetails);
|
|
|
240 |
// model.addAllAttributes(saleSummary);
|
| 24263 |
tejbeer |
241 |
if (!notificationData.isEmpty()) {
|
|
|
242 |
|
|
|
243 |
model.addAttribute("notificationData", notificationData);
|
|
|
244 |
LOGGER.info("notificationdata", notificationData);
|
|
|
245 |
model.addAttribute("start", offset + 1);
|
|
|
246 |
model.addAttribute("size", size);
|
|
|
247 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
248 |
|
|
|
249 |
LOGGER.info("start {}", offset + 1);
|
|
|
250 |
LOGGER.info("SIZE {}", size);
|
|
|
251 |
|
|
|
252 |
if (notificationData.size() < limit) {
|
|
|
253 |
model.addAttribute("end", offset + notificationData.size());
|
|
|
254 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
|
|
255 |
} else {
|
|
|
256 |
model.addAttribute("end", offset + limit);
|
|
|
257 |
|
|
|
258 |
LOGGER.info("end {}", size);
|
|
|
259 |
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
} else {
|
|
|
263 |
|
|
|
264 |
model.addAttribute("notificationData", notificationData);
|
|
|
265 |
model.addAttribute("size", size);
|
|
|
266 |
LOGGER.info("sizeOriginal {}", size);
|
|
|
267 |
|
|
|
268 |
}
|
| 23923 |
amit.gupta |
269 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
| 24312 |
amit.gupta |
270 |
|
| 24263 |
tejbeer |
271 |
List<NotificationData> notificationData = null;
|
|
|
272 |
long size = 0;
|
|
|
273 |
|
|
|
274 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
|
|
275 |
size = notificationPanelRepository.selectCountByActiveFlag(true);
|
|
|
276 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
277 |
|
|
|
278 |
LOGGER.info("notification_data {}", size);
|
|
|
279 |
|
| 24880 |
govind |
280 |
///// DashBoard ......................///////
|
|
|
281 |
model.addAllAttributes(this.getAllInsuranceDetails(loginDetails.getFofoId()));
|
|
|
282 |
model.addAllAttributes(this.getAllRechargeDetails(loginDetails.getFofoId()));
|
|
|
283 |
model.addAllAttributes(this.getAllSaleDetails(loginDetails.getFofoId()));
|
|
|
284 |
model.addAttribute("fofoId", loginDetails.getFofoId());
|
|
|
285 |
///////////////////////////////
|
| 24263 |
tejbeer |
286 |
if (!notificationData.isEmpty()) {
|
|
|
287 |
|
|
|
288 |
model.addAttribute("notificationData", notificationData);
|
|
|
289 |
LOGGER.info("notificationdata", notificationData);
|
|
|
290 |
model.addAttribute("start", offset + 1);
|
|
|
291 |
model.addAttribute("size", size);
|
|
|
292 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
293 |
|
|
|
294 |
LOGGER.info("start {}", offset + 1);
|
|
|
295 |
LOGGER.info("SIZE {}", size);
|
|
|
296 |
|
|
|
297 |
if (notificationData.size() < limit) {
|
|
|
298 |
model.addAttribute("end", offset + notificationData.size());
|
|
|
299 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
|
|
300 |
} else {
|
|
|
301 |
model.addAttribute("end", offset + limit);
|
|
|
302 |
|
|
|
303 |
LOGGER.info("end {}", size);
|
|
|
304 |
|
|
|
305 |
}
|
|
|
306 |
|
|
|
307 |
} else {
|
|
|
308 |
|
|
|
309 |
model.addAttribute("notificationData", notificationData);
|
|
|
310 |
model.addAttribute("size", size);
|
|
|
311 |
LOGGER.info("sizeOriginal {}", size);
|
|
|
312 |
|
|
|
313 |
}
|
| 23884 |
amit.gupta |
314 |
}
|
| 24880 |
govind |
315 |
|
| 24366 |
amit.gupta |
316 |
boolean isInvestmentOk = partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(), 10, 30);
|
| 24288 |
amit.gupta |
317 |
LocalDate endDate = LocalDate.now().minusDays(1);
|
|
|
318 |
LocalDate weekStartDate = endDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
| 24336 |
amit.gupta |
319 |
LocalDate startDate = weekStartDate.minusWeeks(2);
|
| 24339 |
amit.gupta |
320 |
List<PartnerDailyInvestment> partnerInvestments = new ArrayList<>();
|
| 24880 |
govind |
321 |
try {
|
|
|
322 |
partnerInvestments.add(partnerInvestmentService.getInvestment(loginDetails.getFofoId(), 1));
|
|
|
323 |
partnerInvestments
|
|
|
324 |
.addAll(partnerDailyInvestmentRepository.selectAll(loginDetails.getFofoId(), startDate, endDate));
|
|
|
325 |
|
|
|
326 |
} catch (Exception e) {
|
| 24383 |
amit.gupta |
327 |
LOGGER.error("partner Investment can't exists");
|
|
|
328 |
}
|
| 25136 |
amit.gupta |
329 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService
|
|
|
330 |
.getBrandWiseStockValue(loginDetails.getFofoId());
|
|
|
331 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(loginDetails.getFofoId(), loginDetails.getEmailId(),
|
|
|
332 |
3);
|
| 24996 |
amit.gupta |
333 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
| 25136 |
amit.gupta |
334 |
mobileBrands.stream().forEach(x -> {
|
|
|
335 |
String brand = (String) x.get("name");
|
|
|
336 |
if (brandStockPricesMap.containsKey(brand)) {
|
| 24996 |
amit.gupta |
337 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
| 25136 |
amit.gupta |
338 |
brandStockPrice.setBrandUrl((String) x.get("url"));
|
|
|
339 |
brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
| 24996 |
amit.gupta |
340 |
brandStockPrices.add(brandStockPrice);
|
|
|
341 |
} else {
|
|
|
342 |
}
|
|
|
343 |
});
|
| 25136 |
amit.gupta |
344 |
model.addAttribute("brandStockPrices",
|
|
|
345 |
brandStockPrices.stream().sorted((x, y) -> y.getRank() - x.getRank()).collect(Collectors.toList()));
|
| 24366 |
amit.gupta |
346 |
model.addAttribute("isInvestmentOk", isInvestmentOk || roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 24387 |
amit.gupta |
347 |
model.addAttribute("partnerInvestment", partnerInvestments.get(0));
|
| 25136 |
amit.gupta |
348 |
// model.addAttribute("investmentChart",
|
|
|
349 |
// this.getInvestmentChartData(partnerInvestments));
|
| 23848 |
ashik.ali |
350 |
model.addAttribute("fofoStore", fofoStore);
|
| 23918 |
amit.gupta |
351 |
model.addAttribute("walletAmount");
|
| 22086 |
amit.gupta |
352 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 25136 |
amit.gupta |
353 |
// model.addAttribute("isAdmin",
|
|
|
354 |
// roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 25135 |
amit.gupta |
355 |
model.addAttribute("isAdmin", false);
|
| 23379 |
ashik.ali |
356 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
357 |
model.addAttribute("webApiPort", webApiPort);
|
| 24072 |
amit.gupta |
358 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 24077 |
amit.gupta |
359 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 24203 |
amit.gupta |
360 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
|
|
361 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 24248 |
govind |
362 |
model.addAttribute("sale", sale);
|
| 24098 |
tejbeer |
363 |
|
| 23923 |
amit.gupta |
364 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
|
|
365 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
| 21615 |
kshitij.so |
366 |
return "dashboard";
|
|
|
367 |
}
|
| 23923 |
amit.gupta |
368 |
|
| 24312 |
amit.gupta |
369 |
private String getInvestmentChartData(List<PartnerDailyInvestment> partnerInvestments) {
|
| 24880 |
govind |
370 |
|
| 24321 |
amit.gupta |
371 |
JSONObject scale = new JSONObject().put("scaleLabel", new JSONObject().put("scaleLabel", "Amount in Rs"));
|
| 24880 |
govind |
372 |
JSONObject titleObject = new JSONObject().put("display", true).put("text", "Investment Overview").put("display",
|
|
|
373 |
true);
|
|
|
374 |
|
| 24321 |
amit.gupta |
375 |
JSONObject barData = new JSONObject();
|
| 24880 |
govind |
376 |
|
|
|
377 |
JSONObject walletStack = new JSONObject().put("backgroundColor", "rgba(255, 99, 132, 0.2)")
|
| 24323 |
amit.gupta |
378 |
.put("label", "Wallet").put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
379 |
JSONObject inStockStack = new JSONObject().put("label", "In Stock")
|
|
|
380 |
.put("backgroundColor", "rgba(54, 162, 235, 0.2)").put("stack", "Stack1").put("data", new JSONArray());
|
|
|
381 |
JSONObject salesStack = new JSONObject().put("backgroundColor", "rgba(255, 206, 86, 0.2)").put("label", "Sales")
|
| 24325 |
amit.gupta |
382 |
.put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
383 |
JSONObject grnPendingStack = new JSONObject().put("backgroundColor", "rgba(75, 192, 192, 0.2)")
|
| 24323 |
amit.gupta |
384 |
.put("label", "Grn Pending").put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
385 |
JSONObject billingPendingStack = new JSONObject().put("backgroundColor", "rgba(153, 102, 255, 0.2)")
|
| 24323 |
amit.gupta |
386 |
.put("label", "Billing Pending").put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
387 |
JSONObject inTransitStack = new JSONObject().put("backgroundColor", "rgba(255, 159, 64, 0.2)")
|
| 24324 |
amit.gupta |
388 |
.put("label", "Returned").put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
389 |
|
|
|
390 |
JSONObject minInvestmentDataSet = new JSONObject().put("label", "Min. Ivestment").put("data", new JSONArray())
|
|
|
391 |
.put("type", "line");
|
| 24321 |
amit.gupta |
392 |
JSONArray dateLabels = new JSONArray();
|
| 24880 |
govind |
393 |
|
| 24312 |
amit.gupta |
394 |
for (PartnerDailyInvestment pdi : partnerInvestments) {
|
| 24321 |
amit.gupta |
395 |
dateLabels = dateLabels.put(pdi.getDate().toString());
|
| 24880 |
govind |
396 |
walletStack.getJSONArray("data").put((int) pdi.getWalletAmount());
|
|
|
397 |
inStockStack.getJSONArray("data").put((int) pdi.getInStockAmount());
|
|
|
398 |
salesStack.getJSONArray("data").put((int) pdi.getSalesAmount());
|
|
|
399 |
grnPendingStack.getJSONArray("data").put((int) pdi.getUnbilledAmount());
|
|
|
400 |
billingPendingStack.getJSONArray("data").put((int) pdi.getGrnPendingAmount());
|
|
|
401 |
inTransitStack.getJSONArray("data").put((int) pdi.getReturnInTransitAmount());
|
|
|
402 |
minInvestmentDataSet.getJSONArray("data").put((int) pdi.getMinInvestment());
|
| 24312 |
amit.gupta |
403 |
}
|
| 24880 |
govind |
404 |
|
|
|
405 |
JSONArray barDataSetsArray = new JSONArray().put(walletStack).put(inStockStack).put(salesStack)
|
|
|
406 |
.put(grnPendingStack).put(billingPendingStack).put(inTransitStack);
|
| 24321 |
amit.gupta |
407 |
barData.put("labels", dateLabels).put("datasets", barDataSetsArray);
|
| 24880 |
govind |
408 |
scale.put("yAxes", new JSONArray().put(new JSONObject().put("stacked", true))).put("xAxes",
|
|
|
409 |
new JSONArray().put(new JSONObject().put("stacked", true)));
|
| 24321 |
amit.gupta |
410 |
|
| 24880 |
govind |
411 |
JSONObject barOptions = new JSONObject().put("title", titleObject).put("responsive", true).put("scales", scale)
|
| 24321 |
amit.gupta |
412 |
.put("tooltips", new JSONObject().put("mode", "index").put("intersect", false));
|
| 24880 |
govind |
413 |
|
| 24321 |
amit.gupta |
414 |
JSONObject chartJSOn = new JSONObject().put("type", "bar").put("data", barData).put("options", barOptions);
|
|
|
415 |
return chartJSOn.toString();
|
| 24312 |
amit.gupta |
416 |
}
|
|
|
417 |
|
| 24288 |
amit.gupta |
418 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
419 |
private boolean hasGift(int fofoId) {
|
|
|
420 |
try {
|
| 24288 |
amit.gupta |
421 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
422 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
423 |
} catch (ProfitMandiBusinessException e) {
|
|
|
424 |
return false;
|
|
|
425 |
}
|
|
|
426 |
}
|
| 24288 |
amit.gupta |
427 |
|
| 24098 |
tejbeer |
428 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
|
|
429 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
|
|
430 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
431 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 24263 |
tejbeer |
432 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24098 |
tejbeer |
433 |
|
| 24263 |
tejbeer |
434 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
435 |
List<NotificationData> notificationData = null;
|
| 24098 |
tejbeer |
436 |
|
| 24263 |
tejbeer |
437 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
| 24098 |
tejbeer |
438 |
|
| 24263 |
tejbeer |
439 |
LOGGER.info("notification_data {}", notificationData);
|
| 24098 |
tejbeer |
440 |
|
| 24263 |
tejbeer |
441 |
if (!notificationData.isEmpty()) {
|
| 24098 |
tejbeer |
442 |
|
| 24263 |
tejbeer |
443 |
model.addAttribute("notificationData", notificationData);
|
|
|
444 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
445 |
|
|
|
446 |
} else {
|
|
|
447 |
model.addAttribute("notificationData", notificationData);
|
|
|
448 |
|
|
|
449 |
}
|
|
|
450 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
|
|
451 |
|
|
|
452 |
List<NotificationData> notificationData = null;
|
|
|
453 |
|
|
|
454 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
|
|
455 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
456 |
|
|
|
457 |
if (!notificationData.isEmpty()) {
|
|
|
458 |
|
|
|
459 |
model.addAttribute("notificationData", notificationData);
|
|
|
460 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
461 |
|
|
|
462 |
} else {
|
|
|
463 |
model.addAttribute("notificationData", notificationData);
|
|
|
464 |
|
|
|
465 |
}
|
| 24098 |
tejbeer |
466 |
}
|
|
|
467 |
|
|
|
468 |
return "dashboard-paginated";
|
|
|
469 |
}
|
| 24288 |
amit.gupta |
470 |
|
| 22354 |
ashik.ali |
471 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 23923 |
amit.gupta |
472 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 22354 |
ashik.ali |
473 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
474 |
return "contact-us";
|
|
|
475 |
}
|
| 23923 |
amit.gupta |
476 |
|
|
|
477 |
/*
|
|
|
478 |
* private List<PaymentOption> getPaymentOptions(int fofoId){ List<Integer>
|
|
|
479 |
* paymentOptionIds =
|
| 24288 |
amit.gupta |
480 |
* fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId) ;
|
|
|
481 |
* if(paymentOptionIds.isEmpty()){ return new ArrayList<>(); } return
|
| 23923 |
amit.gupta |
482 |
* paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds)); }
|
|
|
483 |
*/
|
|
|
484 |
|
| 24263 |
tejbeer |
485 |
@RequestMapping(value = "/inactiveNotificationData", method = RequestMethod.POST)
|
|
|
486 |
public String inactiveNotificationData(HttpServletRequest request,
|
|
|
487 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
488 |
|
|
|
489 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
490 |
if (notificationData != null) {
|
|
|
491 |
|
|
|
492 |
notificationData.setActive(false);
|
|
|
493 |
LOGGER.info("notification" + notificationData);
|
|
|
494 |
notificationPanelRepository.persist(notificationData);
|
|
|
495 |
|
|
|
496 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
497 |
} else {
|
|
|
498 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
499 |
|
|
|
500 |
}
|
|
|
501 |
return "response";
|
|
|
502 |
}
|
|
|
503 |
|
|
|
504 |
@RequestMapping(value = "/activeNotificationData", method = RequestMethod.POST)
|
|
|
505 |
public String activeNotificationData(HttpServletRequest request,
|
|
|
506 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
507 |
|
|
|
508 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
509 |
if (notificationData != null) {
|
|
|
510 |
|
|
|
511 |
notificationData.setActive(true);
|
|
|
512 |
notificationData.setCreated_timestamp(LocalDateTime.now());
|
|
|
513 |
LOGGER.info("notification" + notificationData);
|
|
|
514 |
notificationPanelRepository.persist(notificationData);
|
|
|
515 |
|
|
|
516 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
517 |
} else {
|
|
|
518 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
519 |
|
|
|
520 |
}
|
|
|
521 |
return "response";
|
|
|
522 |
}
|
|
|
523 |
|
| 24880 |
govind |
524 |
private Map<String, Object> getAllInsuranceDetails(int fofoId) {
|
|
|
525 |
|
|
|
526 |
LocalDateTime currentDayStart = LocalDateTime.of(LocalDate.now(), LocalTime.of(00, 00));
|
|
|
527 |
LocalDateTime previousDayStart = currentDayStart.minusDays(1);
|
|
|
528 |
LocalDateTime currentDayEnd = LocalDateTime.now();
|
|
|
529 |
LocalDateTime currentMonthDayStart = LocalDateTime
|
|
|
530 |
.of(LocalDate.of(currentDayStart.getYear(), currentDayStart.getMonth(), 01), LocalTime.of(00, 00));
|
|
|
531 |
LocalDateTime previousDayEnd = currentDayStart.minusMinutes(1);
|
|
|
532 |
LocalDateTime previousMonthFirstDay = currentMonthDayStart.minusMonths(1);
|
|
|
533 |
LocalDateTime previousMonthLastDay = currentMonthDayStart.minusMinutes(1);
|
|
|
534 |
|
|
|
535 |
List<String> insuranceProviders = insuranceProviderRepository.selectAll().stream().map(x -> x.getName())
|
|
|
536 |
.collect(Collectors.toList());
|
|
|
537 |
|
|
|
538 |
Map<String, Object> map = new HashMap<>();
|
|
|
539 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository
|
|
|
540 |
.selectByRetailerIdAndBetweenCreatedTimeStamp(fofoId, previousMonthFirstDay, LocalDateTime.now());
|
|
|
541 |
|
|
|
542 |
Map<Integer, Double> currentMonthTotalInsurance = insurancePolicies.stream()
|
|
|
543 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
544 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
545 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
|
|
546 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
547 |
|
|
|
548 |
Map<Integer, Double> previousMonthTotalInsurance = insurancePolicies.stream()
|
|
|
549 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
550 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
551 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
|
|
552 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
553 |
|
|
|
554 |
Map<Integer, Double> currentDayTotalInsurance = insurancePolicies.stream().filter(
|
|
|
555 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
556 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
|
|
557 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
558 |
|
|
|
559 |
Map<Integer, Double> previousDayTotalInsurance = insurancePolicies.stream()
|
|
|
560 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
561 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
562 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
|
|
563 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
564 |
|
|
|
565 |
IntFunction<String> intFunction = (providerId) -> {
|
|
|
566 |
try {
|
|
|
567 |
return insuranceProviderRepository.selectById(providerId).getName();
|
|
|
568 |
} catch (ProfitMandiBusinessException e1) {
|
|
|
569 |
// TODO Auto-generated catch block
|
|
|
570 |
return "";
|
|
|
571 |
}
|
|
|
572 |
};
|
|
|
573 |
Map<String, Double> currentMonthTotalInsuranceByPolicyName = insurancePolicies.stream()
|
|
|
574 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
575 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
576 |
.collect(Collectors.groupingBy(x -> {
|
|
|
577 |
return intFunction.apply(x.getProviderId());
|
|
|
578 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
579 |
|
|
|
580 |
Map<String, Double> previousMonthTotalInsuranceByPolicyName = insurancePolicies.stream()
|
|
|
581 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
582 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
583 |
.collect(Collectors.groupingBy(x -> {
|
|
|
584 |
return intFunction.apply(x.getProviderId());
|
|
|
585 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
586 |
|
|
|
587 |
Map<String, Double> previousDayTotalInsuranceByPolicyName = insurancePolicies.stream()
|
|
|
588 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
589 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
590 |
.collect(Collectors.groupingBy(x -> {
|
|
|
591 |
return intFunction.apply(x.getProviderId());
|
|
|
592 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
593 |
|
|
|
594 |
Map<String, Double> currentDayTotalInsuranceByPolicyName = insurancePolicies.stream().filter(
|
|
|
595 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
596 |
.collect(Collectors.groupingBy(x -> {
|
|
|
597 |
return intFunction.apply(x.getProviderId());
|
|
|
598 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
599 |
|
|
|
600 |
map.put("currentMonthTotalInsurance", currentMonthTotalInsurance);
|
|
|
601 |
map.put("previousMonthTotalInsurance", previousMonthTotalInsurance);
|
|
|
602 |
map.put("currentDayTotalInsurance", currentDayTotalInsurance);
|
|
|
603 |
map.put("previousDayTotalInsurance", previousDayTotalInsurance);
|
|
|
604 |
map.put("currentMonthTotalInsuranceByPolicyName", currentMonthTotalInsuranceByPolicyName);
|
|
|
605 |
map.put("previousMonthTotalInsuranceByPolicyName", previousMonthTotalInsuranceByPolicyName);
|
|
|
606 |
map.put("previousDayTotalInsuranceByPolicyName", previousDayTotalInsuranceByPolicyName);
|
|
|
607 |
map.put("currentDayTotalInsuranceByPolicyName", currentDayTotalInsuranceByPolicyName);
|
|
|
608 |
map.put("insuranceProviders", insuranceProviders);
|
|
|
609 |
return map;
|
|
|
610 |
}
|
|
|
611 |
|
|
|
612 |
private Map<String, Object> getAllRechargeDetails(int fofoId) {
|
|
|
613 |
|
|
|
614 |
LocalDateTime currentDayStart = LocalDateTime.of(LocalDate.now(), LocalTime.of(00, 00));
|
|
|
615 |
LocalDateTime previousDayStart = currentDayStart.minusDays(1);
|
|
|
616 |
LocalDateTime currentDayEnd = LocalDateTime.now();
|
|
|
617 |
LocalDateTime currentMonthDayStart = LocalDateTime
|
|
|
618 |
.of(LocalDate.of(currentDayStart.getYear(), currentDayStart.getMonth(), 01), LocalTime.of(00, 00));
|
|
|
619 |
LocalDateTime previousDayEnd = currentDayStart.minusMinutes(1);
|
|
|
620 |
LocalDateTime previousMonthFirstDay = currentMonthDayStart.minusMonths(1);
|
|
|
621 |
LocalDateTime previousMonthLastDay = currentMonthDayStart.minusMinutes(1);
|
|
|
622 |
|
|
|
623 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
624 |
.getAllRechargeTransactionByCreatedTimeStamp(fofoId, previousMonthFirstDay, currentDayEnd).stream()
|
|
|
625 |
.filter(x -> x.getStatus().equals(RechargeStatus.SUCCESS)).collect(Collectors.toList());
|
|
|
626 |
|
|
|
627 |
LOGGER.info(rechargeTransactions);
|
|
|
628 |
Map<Integer, Double> currentMonthTotalRecharge = rechargeTransactions.stream()
|
|
|
629 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
630 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
631 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
|
|
632 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
633 |
LOGGER.info(currentMonthTotalRecharge);
|
|
|
634 |
Map<Integer, Double> previousMonthTotalRecharge = rechargeTransactions.stream()
|
|
|
635 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
636 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
637 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
|
|
638 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
639 |
|
|
|
640 |
LOGGER.info(previousMonthTotalRecharge);
|
|
|
641 |
Map<Integer, Double> currentDayTotalRecharge = rechargeTransactions.stream().filter(
|
|
|
642 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
643 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
|
|
644 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
645 |
|
|
|
646 |
Map<Integer, Double> previousDayTotalRecharge = rechargeTransactions.stream()
|
|
|
647 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
648 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
649 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
|
|
650 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
651 |
|
|
|
652 |
Map<Object, Double> currentMonthTotalRechargeByRechargeType = rechargeTransactions.stream()
|
|
|
653 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
654 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
655 |
.collect(Collectors.groupingBy(x -> {
|
|
|
656 |
return x.getType();
|
|
|
657 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
658 |
|
|
|
659 |
Map<Object, Double> previosMonthTotalRechargeByRechargeType = rechargeTransactions.stream()
|
|
|
660 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
661 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
662 |
.collect(Collectors.groupingBy(x -> {
|
|
|
663 |
return x.getType();
|
|
|
664 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
665 |
|
|
|
666 |
Map<Object, Double> currentDayTotalRechargeByRechargeType = rechargeTransactions.stream().filter(
|
|
|
667 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
668 |
.collect(Collectors.groupingBy(x -> {
|
|
|
669 |
return x.getType();
|
|
|
670 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
671 |
|
|
|
672 |
Map<Object, Double> previousDayTotalRechargeByRechargeType = rechargeTransactions.stream()
|
|
|
673 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
674 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
675 |
.collect(Collectors.groupingBy(x -> {
|
|
|
676 |
return x.getType();
|
|
|
677 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
678 |
|
|
|
679 |
LOGGER.info("previosMonthTotalRechargeByRechargeType" + previosMonthTotalRechargeByRechargeType);
|
|
|
680 |
Map<String, Object> map = new HashMap<>();
|
|
|
681 |
map.put("currentMonthTotalRecharge", currentMonthTotalRecharge);
|
|
|
682 |
map.put("previousMonthTotalRecharge", previousMonthTotalRecharge);
|
|
|
683 |
map.put("currentDayTotalRecharge", currentDayTotalRecharge);
|
|
|
684 |
map.put("previousDayTotalRecharge", previousDayTotalRecharge);
|
|
|
685 |
map.put("currentMonthTotalRechargeByRechargeType", currentMonthTotalRechargeByRechargeType);
|
|
|
686 |
map.put("previosMonthTotalRechargeByRechargeType", previosMonthTotalRechargeByRechargeType);
|
|
|
687 |
map.put("currentDayTotalRechargeByRechargeType", currentDayTotalRechargeByRechargeType);
|
|
|
688 |
map.put("previousDayTotalRechargeByRechargeType", previousDayTotalRechargeByRechargeType);
|
|
|
689 |
map.put("rechargeTypes", RechargeType.values());
|
|
|
690 |
|
|
|
691 |
return map;
|
|
|
692 |
|
|
|
693 |
}
|
|
|
694 |
|
|
|
695 |
private Map<String, Object> getAllSaleDetails(int fofoId) {
|
|
|
696 |
|
|
|
697 |
LocalDateTime currentDayStart = LocalDateTime.of(LocalDate.now(), LocalTime.of(00, 00));
|
|
|
698 |
LocalDateTime previousDayStart = currentDayStart.minusDays(1);
|
|
|
699 |
LocalDateTime currentDayEnd = LocalDateTime.now();
|
|
|
700 |
LocalDateTime currentMonthDayStart = LocalDateTime
|
|
|
701 |
.of(LocalDate.of(currentDayStart.getYear(), currentDayStart.getMonth(), 01), LocalTime.of(00, 00));
|
|
|
702 |
LocalDateTime previousDayEnd = currentDayStart.minusMinutes(1);
|
|
|
703 |
LocalDateTime previousMonthFirstDay = currentMonthDayStart.minusMonths(1);
|
|
|
704 |
LocalDateTime previousMonthLastDay = currentMonthDayStart.minusMinutes(1);
|
|
|
705 |
|
|
|
706 |
Map<String, Object> map = new HashMap<>();
|
|
|
707 |
|
|
|
708 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
|
|
709 |
previousMonthFirstDay, currentDayEnd);
|
| 25136 |
amit.gupta |
710 |
|
| 24880 |
govind |
711 |
Double currentMonthTotalSale = fofoOrderItems.stream()
|
|
|
712 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
713 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
714 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
715 |
|
|
|
716 |
LOGGER.info("currentMonthTotalSale" + currentMonthTotalSale);
|
|
|
717 |
Double previousMonthTotalSale = fofoOrderItems.stream()
|
|
|
718 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
719 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
720 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
721 |
|
|
|
722 |
Double currentDayTotalSale = fofoOrderItems.stream().filter(
|
|
|
723 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
724 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
725 |
|
|
|
726 |
LOGGER.info(currentDayTotalSale);
|
|
|
727 |
|
|
|
728 |
Double previousDayTotalSale = fofoOrderItems.stream()
|
|
|
729 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
730 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
731 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
732 |
LOGGER.info(previousDayTotalSale);
|
|
|
733 |
IntPredicate checkHandset = (itemId) -> {
|
|
|
734 |
try {
|
|
|
735 |
Item item = itemRepository.selectById(itemId);
|
|
|
736 |
return item.getCategoryId() == 10006;
|
|
|
737 |
} catch (ProfitMandiBusinessException e) {
|
|
|
738 |
// TODO Auto-generated catch block
|
|
|
739 |
e.printStackTrace();
|
|
|
740 |
return false;
|
|
|
741 |
}
|
|
|
742 |
};
|
|
|
743 |
|
|
|
744 |
Set<String> brands = fofoOrderItemRepository
|
|
|
745 |
.selectBetweenDates(previousMonthFirstDay.minusMonths(1), currentDayEnd).stream()
|
|
|
746 |
.filter(x -> checkHandset.test(x.getItemId())).map(x -> x.getBrand()).collect(Collectors.toSet());
|
|
|
747 |
Set<String> accessories = fofoOrderItemRepository
|
|
|
748 |
.selectBetweenDates(previousMonthFirstDay.minusMonths(1), currentDayEnd).stream()
|
|
|
749 |
.filter(x -> !checkHandset.test(x.getItemId())).map(x -> x.getBrand()).collect(Collectors.toSet());
|
|
|
750 |
|
|
|
751 |
Double currentMonthTotalMobileSale = fofoOrderItems.stream()
|
|
|
752 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
753 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
754 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
755 |
|
|
|
756 |
Double previousMonthTotalMobileSale = fofoOrderItems.stream()
|
|
|
757 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
758 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && checkHandset.test(x.getItemId()))
|
|
|
759 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
760 |
|
|
|
761 |
Double previousDayTotalMobileSale = fofoOrderItems.stream()
|
|
|
762 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
763 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
764 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
765 |
|
|
|
766 |
Double currentDayTotalMobileSale = fofoOrderItems.stream()
|
|
|
767 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
|
|
768 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
769 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
770 |
|
|
|
771 |
Double currentMonthTotalAccessoriesSale = fofoOrderItems.stream()
|
|
|
772 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
773 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
774 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
775 |
|
|
|
776 |
Double previousMonthTotalAccessoriesSale = fofoOrderItems.stream()
|
|
|
777 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
778 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && !checkHandset.test(x.getItemId()))
|
|
|
779 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
780 |
|
|
|
781 |
Double previousDayTotalAccessoriesSale = fofoOrderItems.stream()
|
|
|
782 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
783 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
784 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
785 |
|
|
|
786 |
Double currentDayTotalAccessoriesSale = fofoOrderItems.stream()
|
|
|
787 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
|
|
788 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
789 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
790 |
|
|
|
791 |
Map<String, Double> currentMonthMobileSalegroupByBrand = fofoOrderItems.stream()
|
|
|
792 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
793 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
794 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
795 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
796 |
|
|
|
797 |
Map<String, Double> currentMonthAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
|
|
798 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
799 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
800 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
801 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
802 |
|
|
|
803 |
Map<String, Double> previousMonthAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
|
|
804 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
805 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && !checkHandset.test(x.getItemId()))
|
|
|
806 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
807 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
808 |
|
|
|
809 |
Map<String, Double> currentDayAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
|
|
810 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
|
|
811 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
812 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
813 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
814 |
|
|
|
815 |
Map<String, Double> previousDayAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
|
|
816 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
817 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
818 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
819 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
820 |
|
|
|
821 |
Map<String, Double> currentDayMobileSalegroupByBrand = fofoOrderItems.stream()
|
|
|
822 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
|
|
823 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
824 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
825 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
826 |
|
|
|
827 |
Map<String, Double> previousDayMobileSalegroupByBrand = fofoOrderItems.stream()
|
|
|
828 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
829 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
830 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
831 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
832 |
Map<String, Double> previousMonthMobileSalegroupByBrand = fofoOrderItems.stream()
|
|
|
833 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
834 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && checkHandset.test(x.getItemId()))
|
|
|
835 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
836 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
| 25136 |
amit.gupta |
837 |
|
| 24880 |
govind |
838 |
map.put("brands", brands);
|
|
|
839 |
map.put("accessories", accessories);
|
|
|
840 |
map.put("currentMonthTotalSale", currentMonthTotalSale);
|
|
|
841 |
map.put("previousMonthTotalSale", previousMonthTotalSale);
|
|
|
842 |
map.put("currentDayTotalSale", currentDayTotalSale);
|
|
|
843 |
map.put("previousDayTotalSale", previousDayTotalSale);
|
|
|
844 |
map.put("currentMonthMobileSalegroupByBrand", currentMonthMobileSalegroupByBrand);
|
|
|
845 |
map.put("currentMonthAccesoriesSalegroupByBrand", currentMonthAccesoriesSalegroupByBrand);
|
|
|
846 |
map.put("previousMonthAccesoriesSalegroupByBrand", previousMonthAccesoriesSalegroupByBrand);
|
|
|
847 |
map.put("previousDayAccesoriesSalegroupByBrand", previousDayAccesoriesSalegroupByBrand);
|
|
|
848 |
map.put("currentDayMobileSalegroupByBrand", currentDayMobileSalegroupByBrand);
|
|
|
849 |
map.put("previousDayMobileSalegroupByBrand", previousDayMobileSalegroupByBrand);
|
|
|
850 |
map.put("currentDayAccesoriesSalegroupByBrand", currentDayAccesoriesSalegroupByBrand);
|
|
|
851 |
map.put("previousMonthMobileSalegroupByBrand", previousMonthMobileSalegroupByBrand);
|
|
|
852 |
|
|
|
853 |
map.put("currentMonthTotalMobileSale", currentMonthTotalMobileSale);
|
|
|
854 |
map.put("previousMonthTotalMobileSale", previousMonthTotalMobileSale);
|
|
|
855 |
map.put("previousDayTotalMobileSale", previousDayTotalMobileSale);
|
|
|
856 |
map.put("currentDayTotalMobileSale", currentDayTotalMobileSale);
|
|
|
857 |
map.put("currentMonthTotalAccessoriesSale", currentMonthTotalAccessoriesSale);
|
|
|
858 |
map.put("previousMonthTotalAccessoriesSale", previousMonthTotalAccessoriesSale);
|
|
|
859 |
map.put("previousDayTotalAccessoriesSale", previousDayTotalAccessoriesSale);
|
|
|
860 |
map.put("currentDayTotalAccessoriesSale", currentDayTotalAccessoriesSale);
|
|
|
861 |
|
|
|
862 |
return map;
|
|
|
863 |
}
|
| 21615 |
kshitij.so |
864 |
}
|