| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDate;
|
3 |
import java.time.LocalDate;
|
| 4 |
import java.time.LocalDateTime;
|
4 |
import java.time.LocalDateTime;
|
| 5 |
import java.time.LocalTime;
|
5 |
import java.time.LocalTime;
|
| 6 |
import java.util.ArrayList;
|
- |
|
| 7 |
import java.util.Arrays;
|
6 |
import java.util.Arrays;
|
| 8 |
import java.util.HashSet;
|
7 |
import java.util.HashSet;
|
| 9 |
import java.util.List;
|
8 |
import java.util.List;
|
| 10 |
import java.util.Map;
|
9 |
import java.util.Map;
|
| 11 |
import java.util.stream.Collectors;
|
10 |
import java.util.stream.Collectors;
|
| Line 14... |
Line 13... |
| 14 |
|
13 |
|
| 15 |
import org.apache.logging.log4j.LogManager;
|
14 |
import org.apache.logging.log4j.LogManager;
|
| 16 |
import org.apache.logging.log4j.Logger;
|
15 |
import org.apache.logging.log4j.Logger;
|
| 17 |
import org.json.JSONObject;
|
16 |
import org.json.JSONObject;
|
| 18 |
import org.springframework.beans.factory.annotation.Autowired;
|
17 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
18 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 19 |
import org.springframework.stereotype.Controller;
|
19 |
import org.springframework.stereotype.Controller;
|
| 20 |
import org.springframework.transaction.annotation.Transactional;
|
20 |
import org.springframework.transaction.annotation.Transactional;
|
| 21 |
import org.springframework.ui.Model;
|
21 |
import org.springframework.ui.Model;
|
| 22 |
import org.springframework.web.bind.annotation.RequestBody;
|
22 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| Line 26... |
Line 26... |
| 26 |
|
26 |
|
| 27 |
import com.spice.profitmandi.common.enumuration.IndentStatus;
|
27 |
import com.spice.profitmandi.common.enumuration.IndentStatus;
|
| 28 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
28 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 29 |
import com.spice.profitmandi.common.model.StockAllocationModel;
|
29 |
import com.spice.profitmandi.common.model.StockAllocationModel;
|
| 30 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
30 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| - |
|
31 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 31 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
32 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 32 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
33 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 33 |
import com.spice.profitmandi.dao.entity.fofo.IndentItem;
|
34 |
import com.spice.profitmandi.dao.entity.fofo.IndentItem;
|
| - |
|
35 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 34 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
36 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
37 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
38 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 37 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
39 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 38 |
import com.spice.profitmandi.dao.repository.dtr.IndentItemRepository;
|
40 |
import com.spice.profitmandi.dao.repository.dtr.IndentItemRepository;
|
| 39 |
import com.spice.profitmandi.dao.repository.dtr.IndentRepository;
|
41 |
import com.spice.profitmandi.dao.repository.dtr.IndentRepository;
|
| - |
|
42 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 40 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
43 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 41 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
44 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 42 |
import com.spice.profitmandi.service.indent.IndentService;
|
45 |
import com.spice.profitmandi.service.indent.IndentService;
|
| 43 |
import com.spice.profitmandi.service.inventory.StockAllocationService;
|
46 |
import com.spice.profitmandi.service.inventory.StockAllocationService;
|
| 44 |
import com.spice.profitmandi.service.user.RetailerService;
|
47 |
import com.spice.profitmandi.service.user.RetailerService;
|
| Line 60... |
Line 63... |
| 60 |
|
63 |
|
| 61 |
@Autowired
|
64 |
@Autowired
|
| 62 |
private CategoryRepository categoryRepository;
|
65 |
private CategoryRepository categoryRepository;
|
| 63 |
|
66 |
|
| 64 |
@Autowired
|
67 |
@Autowired
|
| - |
|
68 |
@Qualifier("catalogItemRepository")
|
| 65 |
private ItemRepository itemRepository;
|
69 |
private ItemRepository itemRepository;
|
| 66 |
|
70 |
|
| 67 |
@Autowired
|
71 |
@Autowired
|
| 68 |
private IndentRepository indentRepository;
|
72 |
private IndentRepository indentRepository;
|
| 69 |
|
73 |
|
| Line 84... |
Line 88... |
| 84 |
|
88 |
|
| 85 |
@Autowired
|
89 |
@Autowired
|
| 86 |
private FofoOrderRepository fofoOrderRepository;
|
90 |
private FofoOrderRepository fofoOrderRepository;
|
| 87 |
|
91 |
|
| 88 |
@Autowired
|
92 |
@Autowired
|
| - |
|
93 |
@Qualifier("fofoCurrentInventorySnapshotRepository")
|
| 89 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
94 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| - |
|
95 |
|
| - |
|
96 |
@Autowired
|
| - |
|
97 |
private RoleRepository roleRepository;
|
| 90 |
|
98 |
|
| 91 |
@Autowired
|
99 |
@Autowired
|
| 92 |
private MVCResponseSender mvcResponseSender;
|
100 |
private MVCResponseSender mvcResponseSender;
|
| 93 |
|
101 |
|
| 94 |
/*@RequestMapping(value = "/indent-item/save", method = RequestMethod.PUT)
|
102 |
/*@RequestMapping(value = "/indent-item/save", method = RequestMethod.PUT)
|
| 95 |
public String saveIndentItem(HttpServletRequest request, @RequestBody ItemIdQuantity itemIdQuantity, Model model)
|
103 |
public String saveIndentItem(HttpServletRequest request, @RequestBody ItemIdQuantity itemIdQuantity, Model model)
|
| 96 |
throws Exception {
|
104 |
throws Exception {
|
| 97 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
105 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 98 |
LOGGER.info("Item id is {}, And quantity is {}", itemIdQuantity.getItemId(), itemIdQuantity.getItemId());
|
106 |
LOGGER.info("Item id is {}, And quantity is {}", itemIdQuantity.getItemId(), itemIdQuantity.getItemId());
|
| 99 |
boolean response = false;
|
- |
|
| 100 |
if(loginDetails.isAdmin()) {
|
107 |
int fofoId = loginDetails.getFofoId();
|
| 101 |
StockAllocationModel stockAllocationModel = new StockAllocationModel();
|
- |
|
| 102 |
stockAllocationModel.setQuantity(itemIdQuantity.getQuantity());
|
- |
|
| 103 |
stockAllocationModel.setItemId(itemIdQuantity.getItemId());
|
108 |
boolean response = indentService.updateOpenIndentItem(fofoId, itemIdQuantity.getItemId(),
|
| 104 |
response = stockAllocationService.addToAllocation(stockAllocationModel);
|
- |
|
| 105 |
}
|
- |
|
| 106 |
//int fofoId = loginDetails.getFofoId();
|
109 |
itemIdQuantity.getQuantity());
|
| 107 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
110 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
| 108 |
return "response";
|
111 |
return "response";
|
| 109 |
}*/
|
112 |
}*/
|
| 110 |
|
113 |
|
| 111 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
114 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
| 112 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestBody List<StockAllocationModel> stockAllocationModelList) throws Exception {
|
115 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestBody List<StockAllocationModel> stockAllocationModelList) throws Exception {
|
| 113 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
116 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 114 |
boolean response = false;
|
117 |
boolean response = false;
|
| 115 |
if(loginDetails.isAdmin()) {
|
118 |
Role roleFofoAdmin = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
|
| 116 |
response = stockAllocationService.addToAllocation(stockAllocationModelList);
|
119 |
response = stockAllocationService.addToAllocation(stockAllocationModelList);
|
| 117 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
120 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
| 118 |
}
|
- |
|
| 119 |
return "response";
|
121 |
return "response";
|
| 120 |
}
|
122 |
}
|
| 121 |
|
123 |
|
| 122 |
@RequestMapping(value = "/migrate", method = RequestMethod.PUT)
|
124 |
@RequestMapping(value = "/migrate", method = RequestMethod.PUT)
|
| 123 |
public String migrate(HttpServletRequest request, Model model) throws Exception {
|
125 |
public String migrate(HttpServletRequest request, Model model) throws Exception {
|