| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import java.io.IOException;
|
| 4 |
import java.net.URISyntaxException;
|
4 |
import java.net.URISyntaxException;
|
| 5 |
import java.time.LocalDateTime;
|
- |
|
| 6 |
import java.util.List;
|
5 |
import java.util.List;
|
| 7 |
|
6 |
|
| 8 |
import javax.servlet.http.HttpServletRequest;
|
7 |
import javax.servlet.http.HttpServletRequest;
|
| 9 |
|
8 |
|
| 10 |
import org.apache.logging.log4j.LogManager;
|
9 |
import org.apache.logging.log4j.LogManager;
|
| Line 17... |
Line 16... |
| 17 |
import org.springframework.web.bind.annotation.RequestMapping;
|
16 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 18 |
import org.springframework.web.bind.annotation.RequestMethod;
|
17 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 19 |
import org.springframework.web.bind.annotation.RequestParam;
|
18 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 20 |
|
19 |
|
| 21 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
20 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
21 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 22 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
22 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
| - |
|
23 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 23 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
24 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 24 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
25 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 25 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
26 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
27 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
| - |
|
28 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseReturnItemRepository;
|
29 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseReturnItemRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
30 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 29 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
31 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 30 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
32 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 31 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
33 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
| Line 83... |
Line 85... |
| 83 |
private TransactionService transactionService;
|
85 |
private TransactionService transactionService;
|
| 84 |
|
86 |
|
| 85 |
@Autowired
|
87 |
@Autowired
|
| 86 |
private NotificationPanelRepository notificationPanelRepository;
|
88 |
private NotificationPanelRepository notificationPanelRepository;
|
| 87 |
|
89 |
|
| - |
|
90 |
@Autowired
|
| - |
|
91 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| - |
|
92 |
|
| 88 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
93 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 89 |
|
94 |
|
| 90 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
95 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 91 |
public String dashboard(HttpServletRequest request,@RequestParam(name = "offset", defaultValue = "0") int offset,
|
96 |
public String dashboard(HttpServletRequest request,@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 92 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
97 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| Line 151... |
Line 156... |
| 151 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
156 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 152 |
model.addAttribute("webApiHost", webApiHost);
|
157 |
model.addAttribute("webApiHost", webApiHost);
|
| 153 |
model.addAttribute("webApiPort", webApiPort);
|
158 |
model.addAttribute("webApiPort", webApiPort);
|
| 154 |
model.addAttribute("webApiScheme", webApiScheme);
|
159 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 155 |
model.addAttribute("webApiRoot", webApiRoot);
|
160 |
model.addAttribute("webApiRoot", webApiRoot);
|
| - |
|
161 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| - |
|
162 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 156 |
|
163 |
|
| 157 |
List<NotificationData> notificationData = null;
|
164 |
List<NotificationData> notificationData = null;
|
| 158 |
long size = 0;
|
165 |
long size = 0;
|
| 159 |
|
166 |
|
| 160 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
167 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
| Line 199... |
Line 206... |
| 199 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
206 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
| 200 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
207 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
| 201 |
return "dashboard";
|
208 |
return "dashboard";
|
| 202 |
}
|
209 |
}
|
| 203 |
|
210 |
|
| - |
|
211 |
//This method is currently hardcoded to faciliate watches sold as gift.
|
| - |
|
212 |
private boolean hasGift(int fofoId) {
|
| - |
|
213 |
try {
|
| - |
|
214 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId).getAvailability() > 0;
|
| - |
|
215 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
216 |
return false;
|
| - |
|
217 |
}
|
| 204 |
|
218 |
}
|
| 205 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
219 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
| 206 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
220 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
| 207 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
221 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 208 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
222 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 209 |
List<NotificationData> notificationData = null;
|
223 |
List<NotificationData> notificationData = null;
|