| 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;
|
| 24288 |
amit.gupta |
8 |
import java.time.temporal.TemporalAdjusters;
|
|
|
9 |
import java.time.temporal.WeekFields;
|
| 24312 |
amit.gupta |
10 |
import java.util.ArrayList;
|
| 23884 |
amit.gupta |
11 |
import java.util.List;
|
| 23568 |
govind |
12 |
|
| 22086 |
amit.gupta |
13 |
import javax.servlet.http.HttpServletRequest;
|
|
|
14 |
|
| 23786 |
amit.gupta |
15 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
16 |
import org.apache.logging.log4j.Logger;
|
| 22481 |
ashik.ali |
17 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23379 |
ashik.ali |
18 |
import org.springframework.beans.factory.annotation.Value;
|
| 21615 |
kshitij.so |
19 |
import org.springframework.stereotype.Controller;
|
| 22481 |
ashik.ali |
20 |
import org.springframework.transaction.annotation.Transactional;
|
| 22073 |
ashik.ali |
21 |
import org.springframework.ui.Model;
|
| 21615 |
kshitij.so |
22 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
23 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 24098 |
tejbeer |
24 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21615 |
kshitij.so |
25 |
|
| 22481 |
ashik.ali |
26 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24203 |
amit.gupta |
27 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 24312 |
amit.gupta |
28 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 24098 |
tejbeer |
29 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
| 22654 |
ashik.ali |
30 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 24288 |
amit.gupta |
31 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 23884 |
amit.gupta |
32 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 22481 |
ashik.ali |
33 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24098 |
tejbeer |
34 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
| 24203 |
amit.gupta |
35 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24288 |
amit.gupta |
36 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 24271 |
amit.gupta |
37 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseReturnItemRepository;
|
| 23884 |
amit.gupta |
38 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 23844 |
amit.gupta |
39 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 23884 |
amit.gupta |
40 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 24271 |
amit.gupta |
41 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
| 23884 |
amit.gupta |
42 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
|
|
43 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 22481 |
ashik.ali |
44 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
45 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24263 |
tejbeer |
46 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22481 |
ashik.ali |
47 |
|
| 24312 |
amit.gupta |
48 |
import be.ceau.chart.BarChart;
|
|
|
49 |
import be.ceau.chart.data.BarData;
|
|
|
50 |
import be.ceau.chart.dataset.BarDataset;
|
|
|
51 |
import be.ceau.chart.options.BarOptions;
|
|
|
52 |
import be.ceau.chart.options.Title;
|
|
|
53 |
import be.ceau.chart.options.scales.BarScale;
|
|
|
54 |
import be.ceau.chart.options.scales.XAxis;
|
|
|
55 |
import be.ceau.chart.options.scales.YAxis;
|
|
|
56 |
import be.ceau.chart.options.ticks.LinearTicks;
|
|
|
57 |
|
| 21615 |
kshitij.so |
58 |
@Controller
|
| 22481 |
ashik.ali |
59 |
@Transactional(rollbackFor = Throwable.class)
|
| 21615 |
kshitij.so |
60 |
public class DashboardController {
|
| 23923 |
amit.gupta |
61 |
|
| 23379 |
ashik.ali |
62 |
@Value("${web.api.host}")
|
|
|
63 |
private String webApiHost;
|
| 23923 |
amit.gupta |
64 |
|
| 24072 |
amit.gupta |
65 |
@Value("${web.api.scheme}")
|
|
|
66 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
67 |
|
| 24078 |
amit.gupta |
68 |
@Value("${web.api.root}")
|
|
|
69 |
private String webApiRoot;
|
|
|
70 |
|
| 23379 |
ashik.ali |
71 |
@Value("${web.api.port}")
|
|
|
72 |
private int webApiPort;
|
| 21615 |
kshitij.so |
73 |
|
| 22481 |
ashik.ali |
74 |
@Autowired
|
| 22927 |
ashik.ali |
75 |
private CookiesProcessor cookiesProcessor;
|
| 23923 |
amit.gupta |
76 |
|
| 23568 |
govind |
77 |
@Autowired
|
| 23786 |
amit.gupta |
78 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
79 |
|
| 23838 |
ashik.ali |
80 |
@Autowired
|
|
|
81 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
82 |
|
|
|
83 |
@Autowired
|
|
|
84 |
private WalletService walletService;
|
| 23923 |
amit.gupta |
85 |
|
| 23884 |
amit.gupta |
86 |
@Autowired
|
|
|
87 |
private InventoryService inventoryService;
|
| 24288 |
amit.gupta |
88 |
|
| 24271 |
amit.gupta |
89 |
@Autowired
|
|
|
90 |
private TargetSlabService targetSlabService;
|
| 23923 |
amit.gupta |
91 |
|
| 23884 |
amit.gupta |
92 |
@Autowired
|
|
|
93 |
private OrderRepository orderRepository;
|
| 24288 |
amit.gupta |
94 |
|
| 23951 |
amit.gupta |
95 |
@Autowired
|
| 24271 |
amit.gupta |
96 |
private PurchaseReturnItemRepository purchaseReturnItemRepository;
|
| 24288 |
amit.gupta |
97 |
|
|
|
98 |
@Autowired
|
|
|
99 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
|
|
100 |
|
| 23923 |
amit.gupta |
101 |
/*
|
|
|
102 |
* @Autowired private ScanRepository scanRepository;
|
|
|
103 |
*/
|
|
|
104 |
|
| 23884 |
amit.gupta |
105 |
@Autowired
|
|
|
106 |
private TransactionService transactionService;
|
| 24263 |
tejbeer |
107 |
|
| 24098 |
tejbeer |
108 |
@Autowired
|
| 24263 |
tejbeer |
109 |
private MVCResponseSender mvcResponseSender;
|
|
|
110 |
|
|
|
111 |
@Autowired
|
| 24098 |
tejbeer |
112 |
private NotificationPanelRepository notificationPanelRepository;
|
| 23923 |
amit.gupta |
113 |
|
| 24203 |
amit.gupta |
114 |
@Autowired
|
|
|
115 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
116 |
|
| 23568 |
govind |
117 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 23923 |
amit.gupta |
118 |
|
| 21615 |
kshitij.so |
119 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 24312 |
amit.gupta |
120 |
public String dashboard(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24098 |
tejbeer |
121 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 23923 |
amit.gupta |
122 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
|
|
123 |
// LOGGER.info("scanRepository.selectScansByInventoryItemId(1)",
|
|
|
124 |
// scanRepository.selectScansByInventoryItemId(1));
|
| 23884 |
amit.gupta |
125 |
LOGGER.info("In Dashboard");
|
| 22927 |
ashik.ali |
126 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23923 |
amit.gupta |
127 |
|
| 22481 |
ashik.ali |
128 |
FofoStore fofoStore = null;
|
|
|
129 |
try {
|
| 22927 |
ashik.ali |
130 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
131 |
} catch (ProfitMandiBusinessException e) {
|
| 22927 |
ashik.ali |
132 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
133 |
}
|
| 23884 |
amit.gupta |
134 |
|
| 23923 |
amit.gupta |
135 |
float walletAmount = 0;
|
|
|
136 |
float inStockAmount = 0;
|
|
|
137 |
float unbilledStockAmount = 0;
|
|
|
138 |
float grnPendingStockAmount = 0;
|
|
|
139 |
float shortPercentage = 100;
|
|
|
140 |
float totalInvestedAmount = 0;
|
| 23936 |
tejbeer |
141 |
float minimumInvestment = 0;
|
| 24312 |
amit.gupta |
142 |
float returnedStockInTransit = 0;
|
|
|
143 |
float sale = 0;
|
| 23923 |
amit.gupta |
144 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
145 |
model.addAttribute("showAlert", false);
|
| 24263 |
tejbeer |
146 |
model.addAttribute("sale", sale);
|
|
|
147 |
List<NotificationData> notificationData = null;
|
|
|
148 |
long size = 0;
|
|
|
149 |
|
|
|
150 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
|
|
151 |
size = notificationPanelRepository.selectAllCount();
|
|
|
152 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
153 |
|
|
|
154 |
LOGGER.info("notification_data {}", size);
|
|
|
155 |
|
|
|
156 |
if (!notificationData.isEmpty()) {
|
|
|
157 |
|
|
|
158 |
model.addAttribute("notificationData", notificationData);
|
|
|
159 |
LOGGER.info("notificationdata", notificationData);
|
|
|
160 |
model.addAttribute("start", offset + 1);
|
|
|
161 |
model.addAttribute("size", size);
|
|
|
162 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
163 |
|
|
|
164 |
LOGGER.info("start {}", offset + 1);
|
|
|
165 |
LOGGER.info("SIZE {}", size);
|
|
|
166 |
|
|
|
167 |
if (notificationData.size() < limit) {
|
|
|
168 |
model.addAttribute("end", offset + notificationData.size());
|
|
|
169 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
|
|
170 |
} else {
|
|
|
171 |
model.addAttribute("end", offset + limit);
|
|
|
172 |
|
|
|
173 |
LOGGER.info("end {}", size);
|
|
|
174 |
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
} else {
|
|
|
178 |
|
|
|
179 |
model.addAttribute("notificationData", notificationData);
|
|
|
180 |
model.addAttribute("size", size);
|
|
|
181 |
LOGGER.info("sizeOriginal {}", size);
|
|
|
182 |
|
|
|
183 |
}
|
| 23923 |
amit.gupta |
184 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
|
|
185 |
walletAmount = walletService.getUserWallet(loginDetails.getFofoId()).getAmount();
|
|
|
186 |
inStockAmount = inventoryService.getTotalAmountInStock(loginDetails.getFofoId());
|
| 24312 |
amit.gupta |
187 |
|
| 23884 |
amit.gupta |
188 |
List<Order> unbilledOrders = transactionService.getInTransitOrders(loginDetails.getFofoId());
|
| 23923 |
amit.gupta |
189 |
for (Order unBilledOrder : unbilledOrders) {
|
| 23884 |
amit.gupta |
190 |
unbilledStockAmount += unBilledOrder.getTotalAmount();
|
|
|
191 |
}
|
|
|
192 |
|
| 23904 |
amit.gupta |
193 |
List<Order> grnPendingOrders = orderRepository.selectPendingGrnOrders(loginDetails.getFofoId());
|
| 23923 |
amit.gupta |
194 |
for (Order grnPendingOrder : grnPendingOrders) {
|
| 23884 |
amit.gupta |
195 |
grnPendingStockAmount += grnPendingOrder.getTotalAmount();
|
|
|
196 |
}
|
| 24271 |
amit.gupta |
197 |
totalInvestedAmount = walletAmount + inStockAmount + unbilledStockAmount + grnPendingStockAmount + sale;
|
| 23923 |
amit.gupta |
198 |
shortPercentage = ((fofoStore.getMinimumInvestment() - totalInvestedAmount)
|
|
|
199 |
/ fofoStore.getMinimumInvestment()) * 100;
|
| 23944 |
amit.gupta |
200 |
model.addAttribute("showAlert", shortPercentage > 10);
|
| 23936 |
tejbeer |
201 |
minimumInvestment = fofoStore.getMinimumInvestment();
|
| 24263 |
tejbeer |
202 |
|
|
|
203 |
// debitNoteRepository.se
|
|
|
204 |
List<NotificationData> notificationData = null;
|
|
|
205 |
long size = 0;
|
|
|
206 |
|
|
|
207 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
|
|
208 |
size = notificationPanelRepository.selectCountByActiveFlag(true);
|
|
|
209 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
210 |
|
|
|
211 |
LOGGER.info("notification_data {}", size);
|
|
|
212 |
|
|
|
213 |
if (!notificationData.isEmpty()) {
|
|
|
214 |
|
|
|
215 |
model.addAttribute("notificationData", notificationData);
|
|
|
216 |
LOGGER.info("notificationdata", notificationData);
|
|
|
217 |
model.addAttribute("start", offset + 1);
|
|
|
218 |
model.addAttribute("size", size);
|
|
|
219 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
220 |
|
|
|
221 |
LOGGER.info("start {}", offset + 1);
|
|
|
222 |
LOGGER.info("SIZE {}", size);
|
|
|
223 |
|
|
|
224 |
if (notificationData.size() < limit) {
|
|
|
225 |
model.addAttribute("end", offset + notificationData.size());
|
|
|
226 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
|
|
227 |
} else {
|
|
|
228 |
model.addAttribute("end", offset + limit);
|
|
|
229 |
|
|
|
230 |
LOGGER.info("end {}", size);
|
|
|
231 |
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
} else {
|
|
|
235 |
|
|
|
236 |
model.addAttribute("notificationData", notificationData);
|
|
|
237 |
model.addAttribute("size", size);
|
|
|
238 |
LOGGER.info("sizeOriginal {}", size);
|
|
|
239 |
|
|
|
240 |
}
|
| 23884 |
amit.gupta |
241 |
}
|
| 24288 |
amit.gupta |
242 |
LocalDate endDate = LocalDate.now().minusDays(1);
|
|
|
243 |
LocalDate weekStartDate = endDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
| 24312 |
amit.gupta |
244 |
LocalDate startDate = weekStartDate.minusWeeks(5);
|
|
|
245 |
List<PartnerDailyInvestment> partnerInvestments = partnerDailyInvestmentRepository
|
|
|
246 |
.selectAll(loginDetails.getFofoId(), startDate, endDate);
|
|
|
247 |
|
|
|
248 |
model.addAttribute("investmentChart", this.getInvestmentChartData(partnerInvestments));
|
| 24271 |
amit.gupta |
249 |
model.addAttribute("sale", sale);
|
| 23923 |
amit.gupta |
250 |
model.addAttribute("walletAmount", walletAmount);
|
|
|
251 |
model.addAttribute("inStockAmount", inStockAmount);
|
|
|
252 |
model.addAttribute("unbilledStockAmount", unbilledStockAmount);
|
|
|
253 |
model.addAttribute("grnPendingStockAmount", grnPendingStockAmount);
|
|
|
254 |
model.addAttribute("shortPercentage", shortPercentage);
|
|
|
255 |
model.addAttribute("totalInvestedAmount", totalInvestedAmount);
|
| 23936 |
tejbeer |
256 |
model.addAttribute("minimumInvestmentAmount", minimumInvestment);
|
| 23951 |
amit.gupta |
257 |
model.addAttribute("returnedStockInTransit", returnedStockInTransit);
|
| 23923 |
amit.gupta |
258 |
|
| 23848 |
ashik.ali |
259 |
model.addAttribute("fofoStore", fofoStore);
|
| 23918 |
amit.gupta |
260 |
model.addAttribute("walletAmount");
|
| 22086 |
amit.gupta |
261 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 23796 |
amit.gupta |
262 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23379 |
ashik.ali |
263 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
264 |
model.addAttribute("webApiPort", webApiPort);
|
| 24072 |
amit.gupta |
265 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 24077 |
amit.gupta |
266 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 24203 |
amit.gupta |
267 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
|
|
268 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 24248 |
govind |
269 |
model.addAttribute("sale", sale);
|
| 24098 |
tejbeer |
270 |
|
| 23923 |
amit.gupta |
271 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
|
|
272 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
| 21615 |
kshitij.so |
273 |
return "dashboard";
|
|
|
274 |
}
|
| 23923 |
amit.gupta |
275 |
|
| 24312 |
amit.gupta |
276 |
private String getInvestmentChartData(List<PartnerDailyInvestment> partnerInvestments) {
|
|
|
277 |
|
|
|
278 |
List<List<Integer>> walletStackList = new ArrayList<>();
|
|
|
279 |
List<List<Integer>> inStockStackList = new ArrayList<>();
|
|
|
280 |
List<List<Integer>> salesStackList = new ArrayList<>();
|
|
|
281 |
List<List<Integer>> grnPendingStackList = new ArrayList<>();
|
|
|
282 |
List<List<Integer>> billingPendingStackList = new ArrayList<>();
|
|
|
283 |
List<List<Integer>> inTransitStackList = new ArrayList<>();
|
|
|
284 |
List<List<LocalDate>> datesList = new ArrayList<>();
|
|
|
285 |
|
|
|
286 |
int currentWeekOfYear = 0;
|
|
|
287 |
for (PartnerDailyInvestment pdi : partnerInvestments) {
|
|
|
288 |
List<Integer> walletStack = null;
|
|
|
289 |
List<Integer> inStockStack = null;
|
|
|
290 |
List<Integer> salesStack = null;
|
|
|
291 |
List<Integer> grnPendingStack = null;
|
|
|
292 |
List<Integer> billingPendingStack = null;
|
|
|
293 |
List<Integer> inTransitStack = null;
|
|
|
294 |
List<LocalDate> dates = null;
|
|
|
295 |
int weekOfYear = pdi.getDate().get(WeekFields.ISO.weekOfYear());
|
|
|
296 |
if (weekOfYear != currentWeekOfYear) {
|
|
|
297 |
walletStack = new ArrayList<>();
|
|
|
298 |
inStockStack = new ArrayList<>();
|
|
|
299 |
salesStack = new ArrayList<>();
|
|
|
300 |
grnPendingStack = new ArrayList<>();
|
|
|
301 |
billingPendingStack = new ArrayList<>();
|
|
|
302 |
inTransitStack = new ArrayList<>();
|
|
|
303 |
dates = new ArrayList<>();
|
|
|
304 |
currentWeekOfYear = weekOfYear;
|
|
|
305 |
walletStackList.add(walletStack);
|
|
|
306 |
inStockStackList.add(inStockStack);
|
|
|
307 |
salesStackList.add(salesStack);
|
|
|
308 |
grnPendingStackList.add(grnPendingStack);
|
|
|
309 |
billingPendingStackList.add(billingPendingStack);
|
|
|
310 |
inTransitStackList.add(inTransitStack);
|
|
|
311 |
}
|
|
|
312 |
walletStack.add((int)pdi.getWalletAmount());
|
|
|
313 |
inStockStack.add((int)pdi.getInStockAmount());
|
|
|
314 |
salesStack.add((int)pdi.getSalesAmount());
|
|
|
315 |
grnPendingStack.add((int)pdi.getGrnPendingAmount());
|
|
|
316 |
billingPendingStack.add((int)pdi.getUnbilledAmount());
|
|
|
317 |
inTransitStack.add((int)pdi.getReturnInTransitAmount());
|
|
|
318 |
datesList.add(dates);
|
|
|
319 |
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
int counter = 0;
|
|
|
323 |
BarData barData = new BarData();
|
|
|
324 |
while(counter < walletStackList.size()) {
|
|
|
325 |
barData
|
|
|
326 |
.addDataset(new BarDataset().setData(walletStackList.get(counter).stream().mapToInt(i -> i).toArray()).setLabel("Wallet"))
|
|
|
327 |
.addDataset(new BarDataset().setData(inStockStackList.get(counter).stream().mapToInt(i -> i).toArray()).setLabel("In Stock"))
|
|
|
328 |
.addDataset(new BarDataset().setData(salesStackList.get(counter).stream().mapToInt(i -> i).toArray()).setLabel("Sales"))
|
|
|
329 |
.addDataset(new BarDataset().setData(grnPendingStackList.get(counter).stream().mapToInt(i -> i).toArray()).setLabel("Grn Pending"))
|
|
|
330 |
.addDataset(new BarDataset().setData(billingPendingStackList.get(counter).stream().mapToInt(i -> i).toArray()).setLabel("Billing Pending"))
|
|
|
331 |
.addDataset(new BarDataset().setData(inTransitStackList.get(counter).stream().mapToInt(i -> i).toArray()).setLabel("In Transit"));
|
|
|
332 |
counter++;
|
|
|
333 |
}
|
|
|
334 |
BarOptions barOptions = new BarOptions()
|
|
|
335 |
.setTitle(new Title().setText("Daily Investment Summary"))
|
|
|
336 |
.setScales(new BarScale().addxAxes(new XAxis<LinearTicks>().setStacked(true))
|
|
|
337 |
.addyAxes(new YAxis<LinearTicks>().setStacked(true))
|
|
|
338 |
);
|
|
|
339 |
|
|
|
340 |
BarChart barChart = new BarChart(barData, barOptions);
|
|
|
341 |
return barChart.toJson();
|
|
|
342 |
}
|
|
|
343 |
|
| 24288 |
amit.gupta |
344 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
345 |
private boolean hasGift(int fofoId) {
|
|
|
346 |
try {
|
| 24288 |
amit.gupta |
347 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
348 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
349 |
} catch (ProfitMandiBusinessException e) {
|
|
|
350 |
return false;
|
|
|
351 |
}
|
|
|
352 |
}
|
| 24288 |
amit.gupta |
353 |
|
| 24098 |
tejbeer |
354 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
|
|
355 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
|
|
356 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
357 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 24263 |
tejbeer |
358 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24098 |
tejbeer |
359 |
|
| 24263 |
tejbeer |
360 |
FofoStore fofoStore = null;
|
|
|
361 |
try {
|
|
|
362 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
|
|
363 |
} catch (ProfitMandiBusinessException e) {
|
|
|
364 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
|
|
365 |
}
|
|
|
366 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
367 |
List<NotificationData> notificationData = null;
|
| 24098 |
tejbeer |
368 |
|
| 24263 |
tejbeer |
369 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
| 24098 |
tejbeer |
370 |
|
| 24263 |
tejbeer |
371 |
LOGGER.info("notification_data {}", notificationData);
|
| 24098 |
tejbeer |
372 |
|
| 24263 |
tejbeer |
373 |
if (!notificationData.isEmpty()) {
|
| 24098 |
tejbeer |
374 |
|
| 24263 |
tejbeer |
375 |
model.addAttribute("notificationData", notificationData);
|
|
|
376 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
377 |
|
|
|
378 |
} else {
|
|
|
379 |
model.addAttribute("notificationData", notificationData);
|
|
|
380 |
|
|
|
381 |
}
|
|
|
382 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
|
|
383 |
|
|
|
384 |
List<NotificationData> notificationData = null;
|
|
|
385 |
|
|
|
386 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
|
|
387 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
388 |
|
|
|
389 |
if (!notificationData.isEmpty()) {
|
|
|
390 |
|
|
|
391 |
model.addAttribute("notificationData", notificationData);
|
|
|
392 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
393 |
|
|
|
394 |
} else {
|
|
|
395 |
model.addAttribute("notificationData", notificationData);
|
|
|
396 |
|
|
|
397 |
}
|
| 24098 |
tejbeer |
398 |
}
|
|
|
399 |
|
|
|
400 |
return "dashboard-paginated";
|
|
|
401 |
}
|
| 24288 |
amit.gupta |
402 |
|
| 22354 |
ashik.ali |
403 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 23923 |
amit.gupta |
404 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 22354 |
ashik.ali |
405 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
406 |
return "contact-us";
|
|
|
407 |
}
|
| 23923 |
amit.gupta |
408 |
|
|
|
409 |
/*
|
|
|
410 |
* private List<PaymentOption> getPaymentOptions(int fofoId){ List<Integer>
|
|
|
411 |
* paymentOptionIds =
|
| 24288 |
amit.gupta |
412 |
* fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId) ;
|
|
|
413 |
* if(paymentOptionIds.isEmpty()){ return new ArrayList<>(); } return
|
| 23923 |
amit.gupta |
414 |
* paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds)); }
|
|
|
415 |
*/
|
|
|
416 |
|
| 24263 |
tejbeer |
417 |
@RequestMapping(value = "/inactiveNotificationData", method = RequestMethod.POST)
|
|
|
418 |
public String inactiveNotificationData(HttpServletRequest request,
|
|
|
419 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
420 |
|
|
|
421 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
422 |
if (notificationData != null) {
|
|
|
423 |
|
|
|
424 |
notificationData.setActive(false);
|
|
|
425 |
LOGGER.info("notification" + notificationData);
|
|
|
426 |
notificationPanelRepository.persist(notificationData);
|
|
|
427 |
|
|
|
428 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
429 |
} else {
|
|
|
430 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
431 |
|
|
|
432 |
}
|
|
|
433 |
return "response";
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
@RequestMapping(value = "/activeNotificationData", method = RequestMethod.POST)
|
|
|
437 |
public String activeNotificationData(HttpServletRequest request,
|
|
|
438 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
439 |
|
|
|
440 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
441 |
if (notificationData != null) {
|
|
|
442 |
|
|
|
443 |
notificationData.setActive(true);
|
|
|
444 |
notificationData.setCreated_timestamp(LocalDateTime.now());
|
|
|
445 |
LOGGER.info("notification" + notificationData);
|
|
|
446 |
notificationPanelRepository.persist(notificationData);
|
|
|
447 |
|
|
|
448 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
449 |
} else {
|
|
|
450 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
451 |
|
|
|
452 |
}
|
|
|
453 |
return "response";
|
|
|
454 |
}
|
|
|
455 |
|
| 21615 |
kshitij.so |
456 |
}
|