| 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;
|
| 24336 |
amit.gupta |
9 |
import java.util.Arrays;
|
| 23884 |
amit.gupta |
10 |
import java.util.List;
|
| 23568 |
govind |
11 |
|
| 22086 |
amit.gupta |
12 |
import javax.servlet.http.HttpServletRequest;
|
|
|
13 |
|
| 23786 |
amit.gupta |
14 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
15 |
import org.apache.logging.log4j.Logger;
|
| 24321 |
amit.gupta |
16 |
import org.json.JSONArray;
|
|
|
17 |
import org.json.JSONObject;
|
| 22481 |
ashik.ali |
18 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23379 |
ashik.ali |
19 |
import org.springframework.beans.factory.annotation.Value;
|
| 21615 |
kshitij.so |
20 |
import org.springframework.stereotype.Controller;
|
| 22481 |
ashik.ali |
21 |
import org.springframework.transaction.annotation.Transactional;
|
| 22073 |
ashik.ali |
22 |
import org.springframework.ui.Model;
|
| 21615 |
kshitij.so |
23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
24 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 24098 |
tejbeer |
25 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21615 |
kshitij.so |
26 |
|
| 22481 |
ashik.ali |
27 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24203 |
amit.gupta |
28 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 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;
|
| 23884 |
amit.gupta |
37 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 24336 |
amit.gupta |
38 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 23844 |
amit.gupta |
39 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 23884 |
amit.gupta |
40 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
|
|
41 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
|
|
42 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 22481 |
ashik.ali |
43 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
44 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24263 |
tejbeer |
45 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22481 |
ashik.ali |
46 |
|
| 21615 |
kshitij.so |
47 |
@Controller
|
| 22481 |
ashik.ali |
48 |
@Transactional(rollbackFor = Throwable.class)
|
| 21615 |
kshitij.so |
49 |
public class DashboardController {
|
| 23923 |
amit.gupta |
50 |
|
| 24321 |
amit.gupta |
51 |
private static final String IN_TRANSIT_STACK = "inTransitStack";
|
|
|
52 |
|
|
|
53 |
private static final String BILLING_PENDING_STACK = "billingPendingStack";
|
|
|
54 |
|
|
|
55 |
private static final String GRN_PENDING_STACK = "grnPendingStack";
|
|
|
56 |
|
|
|
57 |
private static final String SALES_STACK = "salesStack";
|
|
|
58 |
|
|
|
59 |
private static final String IN_STOCK_STACK = "inStockStack";
|
|
|
60 |
|
|
|
61 |
private static final String WALLET_STACK = "walletStack";
|
|
|
62 |
|
| 23379 |
ashik.ali |
63 |
@Value("${web.api.host}")
|
|
|
64 |
private String webApiHost;
|
| 23923 |
amit.gupta |
65 |
|
| 24072 |
amit.gupta |
66 |
@Value("${web.api.scheme}")
|
|
|
67 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
68 |
|
| 24078 |
amit.gupta |
69 |
@Value("${web.api.root}")
|
|
|
70 |
private String webApiRoot;
|
|
|
71 |
|
| 23379 |
ashik.ali |
72 |
@Value("${web.api.port}")
|
|
|
73 |
private int webApiPort;
|
| 21615 |
kshitij.so |
74 |
|
| 22481 |
ashik.ali |
75 |
@Autowired
|
| 22927 |
ashik.ali |
76 |
private CookiesProcessor cookiesProcessor;
|
| 23923 |
amit.gupta |
77 |
|
| 23568 |
govind |
78 |
@Autowired
|
| 23786 |
amit.gupta |
79 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
80 |
|
| 23838 |
ashik.ali |
81 |
@Autowired
|
|
|
82 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
83 |
|
|
|
84 |
@Autowired
|
|
|
85 |
private WalletService walletService;
|
| 23923 |
amit.gupta |
86 |
|
| 23884 |
amit.gupta |
87 |
@Autowired
|
|
|
88 |
private InventoryService inventoryService;
|
| 24288 |
amit.gupta |
89 |
|
| 23923 |
amit.gupta |
90 |
|
| 23884 |
amit.gupta |
91 |
@Autowired
|
|
|
92 |
private OrderRepository orderRepository;
|
| 24288 |
amit.gupta |
93 |
|
|
|
94 |
|
|
|
95 |
@Autowired
|
|
|
96 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 24336 |
amit.gupta |
97 |
|
|
|
98 |
@Autowired
|
|
|
99 |
private PartnerInvestmentService partnerInvestmentService;
|
| 24288 |
amit.gupta |
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));
|
| 24336 |
amit.gupta |
244 |
LocalDate startDate = weekStartDate.minusWeeks(2);
|
|
|
245 |
List<PartnerDailyInvestment> partnerInvestments =
|
|
|
246 |
Arrays.asList(partnerInvestmentService.getInvestment(loginDetails.getFofoId(), 0));
|
|
|
247 |
partnerInvestments.addAll(partnerDailyInvestmentRepository.selectAll(loginDetails.getFofoId(), startDate, endDate));
|
| 24312 |
amit.gupta |
248 |
|
|
|
249 |
model.addAttribute("investmentChart", this.getInvestmentChartData(partnerInvestments));
|
| 24271 |
amit.gupta |
250 |
model.addAttribute("sale", sale);
|
| 23923 |
amit.gupta |
251 |
model.addAttribute("walletAmount", walletAmount);
|
|
|
252 |
model.addAttribute("inStockAmount", inStockAmount);
|
|
|
253 |
model.addAttribute("unbilledStockAmount", unbilledStockAmount);
|
|
|
254 |
model.addAttribute("grnPendingStockAmount", grnPendingStockAmount);
|
|
|
255 |
model.addAttribute("shortPercentage", shortPercentage);
|
|
|
256 |
model.addAttribute("totalInvestedAmount", totalInvestedAmount);
|
| 23936 |
tejbeer |
257 |
model.addAttribute("minimumInvestmentAmount", minimumInvestment);
|
| 23951 |
amit.gupta |
258 |
model.addAttribute("returnedStockInTransit", returnedStockInTransit);
|
| 23923 |
amit.gupta |
259 |
|
| 23848 |
ashik.ali |
260 |
model.addAttribute("fofoStore", fofoStore);
|
| 23918 |
amit.gupta |
261 |
model.addAttribute("walletAmount");
|
| 22086 |
amit.gupta |
262 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 23796 |
amit.gupta |
263 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23379 |
ashik.ali |
264 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
265 |
model.addAttribute("webApiPort", webApiPort);
|
| 24072 |
amit.gupta |
266 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 24077 |
amit.gupta |
267 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 24203 |
amit.gupta |
268 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
|
|
269 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 24248 |
govind |
270 |
model.addAttribute("sale", sale);
|
| 24098 |
tejbeer |
271 |
|
| 23923 |
amit.gupta |
272 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
|
|
273 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
| 21615 |
kshitij.so |
274 |
return "dashboard";
|
|
|
275 |
}
|
| 23923 |
amit.gupta |
276 |
|
| 24312 |
amit.gupta |
277 |
private String getInvestmentChartData(List<PartnerDailyInvestment> partnerInvestments) {
|
| 24321 |
amit.gupta |
278 |
|
|
|
279 |
|
|
|
280 |
JSONObject scale = new JSONObject().put("scaleLabel", new JSONObject().put("scaleLabel", "Amount in Rs"));
|
|
|
281 |
JSONObject titleObject = new JSONObject()
|
|
|
282 |
.put("display", true)
|
|
|
283 |
.put("text", "Investment Overview").put("display", true);
|
|
|
284 |
|
|
|
285 |
JSONObject barData = new JSONObject();
|
|
|
286 |
|
| 24325 |
amit.gupta |
287 |
JSONObject walletStack = new JSONObject().put("backgroundColor","rgba(255, 99, 132, 0.2)")
|
| 24323 |
amit.gupta |
288 |
.put("label", "Wallet").put("stack", "Stack1").put("data", new JSONArray());
|
| 24321 |
amit.gupta |
289 |
JSONObject inStockStack = new JSONObject().put("label", "In Stock").put("backgroundColor","rgba(54, 162, 235, 0.2)")
|
| 24325 |
amit.gupta |
290 |
.put("stack", "Stack1").put("data", new JSONArray());
|
|
|
291 |
JSONObject salesStack = new JSONObject().put("backgroundColor","rgba(255, 206, 86, 0.2)")
|
| 24323 |
amit.gupta |
292 |
.put("label", "Sales").put("stack", "Stack1").put("data", new JSONArray());
|
| 24325 |
amit.gupta |
293 |
JSONObject grnPendingStack = new JSONObject().put("backgroundColor","rgba(75, 192, 192, 0.2)")
|
| 24323 |
amit.gupta |
294 |
.put("label", "Grn Pending").put("stack", "Stack1").put("data", new JSONArray());
|
| 24325 |
amit.gupta |
295 |
JSONObject billingPendingStack = new JSONObject().put("backgroundColor","rgba(153, 102, 255, 0.2)")
|
| 24323 |
amit.gupta |
296 |
.put("label", "Billing Pending").put("stack", "Stack1").put("data", new JSONArray());
|
| 24325 |
amit.gupta |
297 |
JSONObject inTransitStack = new JSONObject().put("backgroundColor","rgba(255, 159, 64, 0.2)")
|
| 24324 |
amit.gupta |
298 |
.put("label", "Returned").put("stack", "Stack1").put("data", new JSONArray());
|
| 24321 |
amit.gupta |
299 |
|
| 24327 |
amit.gupta |
300 |
JSONObject minInvestmentDataSet = new JSONObject().put("label", "Min. Ivestment").put("data", new JSONArray()).put("type", "line");
|
| 24321 |
amit.gupta |
301 |
JSONArray dateLabels = new JSONArray();
|
|
|
302 |
|
| 24312 |
amit.gupta |
303 |
for (PartnerDailyInvestment pdi : partnerInvestments) {
|
| 24321 |
amit.gupta |
304 |
dateLabels = dateLabels.put(pdi.getDate().toString());
|
|
|
305 |
walletStack.getJSONArray("data").put((int)pdi.getWalletAmount());
|
|
|
306 |
inStockStack.getJSONArray("data").put((int)pdi.getInStockAmount());
|
|
|
307 |
salesStack.getJSONArray("data").put((int)pdi.getSalesAmount());
|
|
|
308 |
grnPendingStack.getJSONArray("data").put((int)pdi.getUnbilledAmount());
|
|
|
309 |
billingPendingStack.getJSONArray("data").put((int)pdi.getGrnPendingAmount());
|
|
|
310 |
inTransitStack.getJSONArray("data").put((int)pdi.getReturnInTransitAmount());
|
| 24327 |
amit.gupta |
311 |
minInvestmentDataSet.getJSONArray("data").put((int)pdi.getMinInvestment());
|
| 24312 |
amit.gupta |
312 |
}
|
|
|
313 |
|
| 24321 |
amit.gupta |
314 |
JSONArray barDataSetsArray = new JSONArray().put(walletStack).put(inStockStack)
|
|
|
315 |
.put(salesStack).put(grnPendingStack).put(billingPendingStack).put(inTransitStack);
|
|
|
316 |
barData.put("labels", dateLabels).put("datasets", barDataSetsArray);
|
|
|
317 |
scale.put("yAxes", new JSONArray().put(new JSONObject().put("stacked", true)))
|
|
|
318 |
.put("xAxes", new JSONArray().put(new JSONObject().put("stacked", true)));
|
|
|
319 |
|
|
|
320 |
JSONObject barOptions = new JSONObject()
|
| 24324 |
amit.gupta |
321 |
.put("title", titleObject).put("responsive", true).put("scales", scale)
|
| 24321 |
amit.gupta |
322 |
.put("tooltips", new JSONObject().put("mode", "index").put("intersect", false));
|
|
|
323 |
|
|
|
324 |
JSONObject chartJSOn = new JSONObject().put("type", "bar").put("data", barData).put("options", barOptions);
|
|
|
325 |
return chartJSOn.toString();
|
| 24312 |
amit.gupta |
326 |
}
|
|
|
327 |
|
| 24288 |
amit.gupta |
328 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
329 |
private boolean hasGift(int fofoId) {
|
|
|
330 |
try {
|
| 24288 |
amit.gupta |
331 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
332 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
333 |
} catch (ProfitMandiBusinessException e) {
|
|
|
334 |
return false;
|
|
|
335 |
}
|
|
|
336 |
}
|
| 24288 |
amit.gupta |
337 |
|
| 24098 |
tejbeer |
338 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
|
|
339 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
|
|
340 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
341 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 24263 |
tejbeer |
342 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24098 |
tejbeer |
343 |
|
| 24263 |
tejbeer |
344 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
345 |
List<NotificationData> notificationData = null;
|
| 24098 |
tejbeer |
346 |
|
| 24263 |
tejbeer |
347 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
| 24098 |
tejbeer |
348 |
|
| 24263 |
tejbeer |
349 |
LOGGER.info("notification_data {}", notificationData);
|
| 24098 |
tejbeer |
350 |
|
| 24263 |
tejbeer |
351 |
if (!notificationData.isEmpty()) {
|
| 24098 |
tejbeer |
352 |
|
| 24263 |
tejbeer |
353 |
model.addAttribute("notificationData", notificationData);
|
|
|
354 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
355 |
|
|
|
356 |
} else {
|
|
|
357 |
model.addAttribute("notificationData", notificationData);
|
|
|
358 |
|
|
|
359 |
}
|
|
|
360 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
|
|
361 |
|
|
|
362 |
List<NotificationData> notificationData = null;
|
|
|
363 |
|
|
|
364 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
|
|
365 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
366 |
|
|
|
367 |
if (!notificationData.isEmpty()) {
|
|
|
368 |
|
|
|
369 |
model.addAttribute("notificationData", notificationData);
|
|
|
370 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
371 |
|
|
|
372 |
} else {
|
|
|
373 |
model.addAttribute("notificationData", notificationData);
|
|
|
374 |
|
|
|
375 |
}
|
| 24098 |
tejbeer |
376 |
}
|
|
|
377 |
|
|
|
378 |
return "dashboard-paginated";
|
|
|
379 |
}
|
| 24288 |
amit.gupta |
380 |
|
| 22354 |
ashik.ali |
381 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 23923 |
amit.gupta |
382 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 22354 |
ashik.ali |
383 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
384 |
return "contact-us";
|
|
|
385 |
}
|
| 23923 |
amit.gupta |
386 |
|
|
|
387 |
/*
|
|
|
388 |
* private List<PaymentOption> getPaymentOptions(int fofoId){ List<Integer>
|
|
|
389 |
* paymentOptionIds =
|
| 24288 |
amit.gupta |
390 |
* fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId) ;
|
|
|
391 |
* if(paymentOptionIds.isEmpty()){ return new ArrayList<>(); } return
|
| 23923 |
amit.gupta |
392 |
* paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds)); }
|
|
|
393 |
*/
|
|
|
394 |
|
| 24263 |
tejbeer |
395 |
@RequestMapping(value = "/inactiveNotificationData", method = RequestMethod.POST)
|
|
|
396 |
public String inactiveNotificationData(HttpServletRequest request,
|
|
|
397 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
398 |
|
|
|
399 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
400 |
if (notificationData != null) {
|
|
|
401 |
|
|
|
402 |
notificationData.setActive(false);
|
|
|
403 |
LOGGER.info("notification" + notificationData);
|
|
|
404 |
notificationPanelRepository.persist(notificationData);
|
|
|
405 |
|
|
|
406 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
407 |
} else {
|
|
|
408 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
409 |
|
|
|
410 |
}
|
|
|
411 |
return "response";
|
|
|
412 |
}
|
|
|
413 |
|
|
|
414 |
@RequestMapping(value = "/activeNotificationData", method = RequestMethod.POST)
|
|
|
415 |
public String activeNotificationData(HttpServletRequest request,
|
|
|
416 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
417 |
|
|
|
418 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
419 |
if (notificationData != null) {
|
|
|
420 |
|
|
|
421 |
notificationData.setActive(true);
|
|
|
422 |
notificationData.setCreated_timestamp(LocalDateTime.now());
|
|
|
423 |
LOGGER.info("notification" + notificationData);
|
|
|
424 |
notificationPanelRepository.persist(notificationData);
|
|
|
425 |
|
|
|
426 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
427 |
} else {
|
|
|
428 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
429 |
|
|
|
430 |
}
|
|
|
431 |
return "response";
|
|
|
432 |
}
|
|
|
433 |
|
| 21615 |
kshitij.so |
434 |
}
|