| Line 9... |
Line 9... |
| 9 |
import java.util.List;
|
9 |
import java.util.List;
|
| 10 |
import java.util.Map;
|
10 |
import java.util.Map;
|
| 11 |
|
11 |
|
| 12 |
import javax.servlet.http.HttpServletRequest;
|
12 |
import javax.servlet.http.HttpServletRequest;
|
| 13 |
|
13 |
|
| 14 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 15 |
import org.apache.logging.log4j.LogManager;
|
14 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
15 |
import org.apache.logging.log4j.Logger;
|
| 16 |
import org.springframework.beans.factory.annotation.Autowired;
|
16 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
17 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 17 |
import org.springframework.core.io.InputStreamResource;
|
18 |
import org.springframework.core.io.InputStreamResource;
|
| 18 |
import org.springframework.http.HttpHeaders;
|
19 |
import org.springframework.http.HttpHeaders;
|
| 19 |
import org.springframework.http.HttpStatus;
|
20 |
import org.springframework.http.HttpStatus;
|
| 20 |
import org.springframework.http.ResponseEntity;
|
21 |
import org.springframework.http.ResponseEntity;
|
| 21 |
import org.springframework.stereotype.Controller;
|
22 |
import org.springframework.stereotype.Controller;
|
| Line 32... |
Line 33... |
| 32 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
33 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 33 |
import com.spice.profitmandi.common.model.SchemeItems;
|
34 |
import com.spice.profitmandi.common.model.SchemeItems;
|
| 34 |
import com.spice.profitmandi.common.model.SchemeModel;
|
35 |
import com.spice.profitmandi.common.model.SchemeModel;
|
| 35 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
36 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 36 |
import com.spice.profitmandi.common.util.StringUtils;
|
37 |
import com.spice.profitmandi.common.util.StringUtils;
|
| - |
|
38 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 37 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
39 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| - |
|
40 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 38 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
41 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
| 39 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
42 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 40 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
43 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 41 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
44 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| - |
|
45 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 42 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
46 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 43 |
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
|
47 |
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
|
| 44 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
48 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 45 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
49 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 46 |
import com.spice.profitmandi.web.model.LoginDetails;
|
50 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 47 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
51 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 48 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
52 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 49 |
|
53 |
|
| 50 |
@Controller
|
54 |
@Controller
|
| 51 |
@Transactional(rollbackFor = Throwable.class)
|
55 |
@Transactional(rollbackFor=Throwable.class)
|
| 52 |
public class SchemeController {
|
56 |
public class SchemeController {
|
| 53 |
|
57 |
|
| 54 |
private static final Logger LOGGER = LogManager.getLogger(SchemeController.class);
|
58 |
private static final Logger LOGGER = LogManager.getLogger(SchemeController.class);
|
| 55 |
|
59 |
|
| 56 |
@Autowired
|
60 |
@Autowired
|
| 57 |
private SchemeService schemeService;
|
61 |
private SchemeService schemeService;
|
| 58 |
|
62 |
|
| 59 |
@Autowired
|
63 |
@Autowired
|
| 60 |
private SchemeRepository schemeRepository;
|
64 |
private SchemeRepository schemeRepository;
|
| 61 |
|
65 |
|
| 62 |
@Autowired
|
66 |
@Autowired
|
| 63 |
private SchemeItemRepository schemeItemRepository;
|
67 |
private SchemeItemRepository schemeItemRepository;
|
| 64 |
|
68 |
|
| 65 |
@Autowired
|
69 |
@Autowired
|
| 66 |
private MVCResponseSender mvcResponseSender;
|
70 |
private MVCResponseSender mvcResponseSender;
|
| 67 |
|
71 |
|
| 68 |
@Autowired
|
72 |
@Autowired
|
| 69 |
private CookiesProcessor cookiesProcessor;
|
73 |
private CookiesProcessor cookiesProcessor;
|
| 70 |
|
74 |
|
| 71 |
@Autowired
|
75 |
@Autowired
|
| - |
|
76 |
@Qualifier("fofoInventoryService")
|
| 72 |
private InventoryService inventoryService;
|
77 |
private InventoryService inventoryService;
|
| 73 |
|
78 |
|
| 74 |
@Autowired
|
79 |
@Autowired
|
| 75 |
private TagListingRepository tagListingRepository;
|
80 |
private TagListingRepository tagListingRepository;
|
| 76 |
|
81 |
|
| 77 |
@Autowired
|
82 |
@Autowired
|
| 78 |
PurchaseRepository purchaseRepository;
|
83 |
PurchaseRepository purchaseRepository;
|
| - |
|
84 |
|
| - |
|
85 |
@Autowired
|
| - |
|
86 |
private RoleRepository roleRepository;
|
| - |
|
87 |
|
| - |
|
88 |
@Autowired
|
| - |
|
89 |
private ResponseSender<?> responseSender;
|
| 79 |
|
90 |
|
| 80 |
@RequestMapping(value = "/createScheme", method = RequestMethod.GET)
|
91 |
@RequestMapping(value = "/createScheme", method = RequestMethod.GET)
|
| 81 |
public String createScheme(HttpServletRequest request, Model model) {
|
92 |
public String createScheme(HttpServletRequest request, Model model){
|
| 82 |
// Map<Integer, String> itemIdItemDescriptionMap =
|
- |
|
| 83 |
// inventoryService.getAllItemIdItemDescriptionMap();
|
93 |
//Map<Integer, String> itemIdItemDescriptionMap = inventoryService.getAllItemIdItemDescriptionMap();
|
| 84 |
// model.addAttribute("itemIdItemDescriptionMap",
|
94 |
//model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
| 85 |
// itemIdItemDescriptionMap);
|
- |
|
| 86 |
model.addAttribute("brands", inventoryService.getAllTagListingBrands());
|
95 |
model.addAttribute("brands", inventoryService.getAllTagListingBrands());
|
| 87 |
return "create-scheme";
|
96 |
return "create-scheme";
|
| 88 |
}
|
97 |
}
|
| 89 |
|
98 |
|
| 90 |
@RequestMapping(value = "/getTagListingItemsByBrand", method = RequestMethod.GET)
|
99 |
@RequestMapping(value = "/getTagListingItemsByBrand", method = RequestMethod.GET)
|
| 91 |
public String getTagListingItemsByBrand(HttpServletRequest request,
|
- |
|
| 92 |
@RequestParam(name = ProfitMandiConstants.BRAND) String brand, Model model) {
|
100 |
public String getTagListingItemsByBrand(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.BRAND) String brand, Model model){
|
| 93 |
Map<Integer, String> itemIdItemDescriptionMap = inventoryService
|
101 |
Map<Integer, String> itemIdItemDescriptionMap = inventoryService.getAllTagListingItemIdItemDescriptionMap(brand);
|
| 94 |
.getAllTagListingItemIdItemDescriptionMap(brand);
|
- |
|
| 95 |
model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
102 |
model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
| 96 |
// model.addAttribute("brands", inventoryService.getAllBrands());
|
103 |
//model.addAttribute("brands", inventoryService.getAllBrands());
|
| 97 |
return "tag-listing-items-description";
|
104 |
return "tag-listing-items-description";
|
| 98 |
}
|
105 |
}
|
| 99 |
|
106 |
|
| 100 |
@RequestMapping(value = "/schemes/update-schemes-page", method = RequestMethod.GET)
|
107 |
@RequestMapping(value = "/schemes/update-schemes-page", method = RequestMethod.GET)
|
| 101 |
public String updateShcemes(HttpServletRequest request) throws ProfitMandiBusinessException {
|
108 |
public String updateShcemes(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| 102 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
109 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
110 |
Role role = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
|
| 103 |
if (!loginDetails.getRoleTypes().contains(RoleType.FOFO_ADMIN)) {
|
111 |
if(loginDetails.getRoleIds().contains(role.getId())) {
|
| 104 |
throw new ProfitMandiBusinessException("User", loginDetails.getEmailId(), "Unauthorised access");
|
112 |
throw new ProfitMandiBusinessException("User", loginDetails.getEmailId(), "Unauthorised access");
|
| 105 |
}
|
113 |
}
|
| 106 |
return "update-schemes-page";
|
114 |
return "update-schemes-page";
|
| 107 |
}
|
115 |
}
|
| 108 |
|
116 |
|
| 109 |
@RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
|
117 |
@RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
|
| 110 |
public String updateShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
|
118 |
public String updateShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model) throws Exception {
|
| 111 |
throws Exception {
|
- |
|
| 112 |
for (int schemeId : schemeItems.getSchemeIds()) {
|
119 |
for(int schemeId : schemeItems.getSchemeIds()) {
|
| 113 |
if (schemeRepository.selectById(schemeId) != null)
|
120 |
if(schemeRepository.selectById(schemeId) != null)
|
| 114 |
for (int itemId : schemeItems.getItemIds()) {
|
121 |
for(int itemId : schemeItems.getItemIds()) {
|
| 115 |
if (tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)),
|
122 |
if(tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)), new HashSet<>(Arrays.asList(4,7))).size() > 0) {
|
| 116 |
new HashSet<>(Arrays.asList(4, 7))).size() > 0) {
|
- |
|
| 117 |
SchemeItem si = new SchemeItem();
|
123 |
SchemeItem si = new SchemeItem();
|
| 118 |
si.setItemId(itemId);
|
124 |
si.setItemId(itemId);
|
| 119 |
si.setSchemeId(schemeId);
|
125 |
si.setSchemeId(schemeId);
|
| 120 |
try {
|
126 |
try {
|
| 121 |
schemeItemRepository.persist(si);
|
127 |
schemeItemRepository.persist(si);
|
| 122 |
} catch (Exception e) {
|
128 |
} catch (Exception e) {
|
| 123 |
LOGGER.info("Scheme aleady exist");
|
129 |
LOGGER.info("Scheme aleady exist");
|
| 124 |
}
|
- |
|
| 125 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
- |
|
| 126 |
} else {
|
- |
|
| 127 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
- |
|
| 128 |
throw new ProfitMandiBusinessException("ItemId", itemId, "Invalid Item Id");
|
- |
|
| 129 |
}
|
130 |
}
|
| 130 |
}
|
- |
|
| 131 |
}
|
- |
|
| 132 |
return "response";
|
- |
|
| 133 |
}
|
- |
|
| 134 |
|
- |
|
| 135 |
@RequestMapping(value = "/schemes/delete", method = RequestMethod.POST)
|
- |
|
| 136 |
public String deleteShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
|
- |
|
| 137 |
throws Exception {
|
- |
|
| 138 |
if (schemeItemRepository.selectBySchemeIdsAndItemIds(new HashSet<>(schemeItems.getSchemeIds()),
|
- |
|
| 139 |
new HashSet<>(schemeItems.getItemIds())).size() > 0) {
|
- |
|
| 140 |
for (int schemeId : schemeItems.getSchemeIds()) {
|
- |
|
| 141 |
for (int itemId : schemeItems.getItemIds()) {
|
- |
|
| 142 |
schemeItemRepository.deletebyItemIdsandSchemeIds(itemId, schemeId);
|
- |
|
| 143 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
131 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
132 |
} else {
|
| - |
|
133 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
| - |
|
134 |
throw new ProfitMandiBusinessException("ItemId", itemId,"Invalid Item Id");
|
| 144 |
}
|
135 |
}
|
| 145 |
}
|
136 |
}
|
| 146 |
} else {
|
- |
|
| 147 |
throw new ProfitMandiBusinessException("ItemId", schemeItems.getItemIds(), "invalid Item Id");
|
- |
|
| 148 |
}
|
137 |
}
|
| 149 |
return "response";
|
138 |
return "response";
|
| 150 |
}
|
139 |
}
|
| - |
|
140 |
|
| 151 |
|
141 |
|
| 152 |
@RequestMapping(value = "/createScheme", method = RequestMethod.POST)
|
142 |
@RequestMapping(value = "/createScheme", method = RequestMethod.POST)
|
| 153 |
public String createScheme(HttpServletRequest request, @RequestBody CreateSchemeRequest createSchemeRequest,
|
143 |
public String createScheme(HttpServletRequest request, @RequestBody CreateSchemeRequest createSchemeRequest,
|
| 154 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
144 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 155 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
145 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| 156 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem,
|
146 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem,
|
| Line 167... |
Line 157... |
| 167 |
model.addAttribute("size", size);
|
157 |
model.addAttribute("size", size);
|
| 168 |
model.addAttribute("searchItem", searchItem);
|
158 |
model.addAttribute("searchItem", searchItem);
|
| 169 |
model.addAttribute("searchTerm", searchTerm);
|
159 |
model.addAttribute("searchTerm", searchTerm);
|
| 170 |
if (schemes.size() < limit) {
|
160 |
if (schemes.size() < limit) {
|
| 171 |
model.addAttribute("end", offset + schemes.size());
|
161 |
model.addAttribute("end", offset + schemes.size());
|
| 172 |
} else {
|
162 |
}else{
|
| 173 |
model.addAttribute("end", offset + limit);
|
163 |
model.addAttribute("end", offset + limit);
|
| 174 |
}
|
164 |
}
|
| 175 |
return "schemes";
|
165 |
return "schemes";
|
| 176 |
|
166 |
|
| 177 |
}
|
167 |
}
|
| 178 |
|
168 |
|
| 179 |
@RequestMapping(value = "/getSchemes", method = RequestMethod.GET)
|
169 |
@RequestMapping(value = "/getSchemes", method = RequestMethod.GET)
|
| 180 |
public String getSchemes(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
170 |
public String getSchemes(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 181 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
171 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| 182 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem,
|
172 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem,
|
| 183 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
173 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| 184 |
throws ProfitMandiBusinessException {
|
174 |
throws ProfitMandiBusinessException {
|
| 185 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
175 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 186 |
List<Scheme> schemes = null;
|
176 |
List<Scheme> schemes = null;
|
| 187 |
long size = 0;
|
177 |
long size = 0;
|
| - |
|
178 |
Role role = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
|
| 188 |
if (loginDetails.getRoleTypes().contains(RoleType.FOFO_ADMIN)) {
|
179 |
if(loginDetails.getRoleIds().contains(role.getId())){
|
| 189 |
schemes = schemeRepository.selectAll(offset, limit);
|
180 |
schemes = schemeRepository.selectAll(offset, limit);
|
| 190 |
size = schemeRepository.selectAllCount();
|
181 |
size = schemeRepository.selectAllCount();
|
| 191 |
} else {
|
182 |
}else{
|
| 192 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
183 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
| 193 |
size = schemeRepository.selectAllActiveCount();
|
184 |
size = schemeRepository.selectAllActiveCount();
|
| 194 |
}
|
185 |
}
|
| 195 |
model.addAttribute("schemes", schemes);
|
186 |
model.addAttribute("schemes", schemes);
|
| 196 |
model.addAttribute("start", offset + 1);
|
187 |
model.addAttribute("start", offset + 1);
|
| 197 |
model.addAttribute("size", size);
|
188 |
model.addAttribute("size", size);
|
| 198 |
model.addAttribute("searchItem", searchItem);
|
189 |
model.addAttribute("searchItem", searchItem);
|
| 199 |
model.addAttribute("searchTerm", searchTerm);
|
190 |
model.addAttribute("searchTerm", searchTerm);
|
| 200 |
if (schemes.size() < limit) {
|
191 |
if (schemes.size() < limit) {
|
| 201 |
model.addAttribute("end", offset + schemes.size());
|
192 |
model.addAttribute("end", offset + schemes.size());
|
| 202 |
} else {
|
193 |
}else{
|
| 203 |
model.addAttribute("end", offset + limit);
|
194 |
model.addAttribute("end", offset + limit);
|
| 204 |
}
|
195 |
}
|
| 205 |
// model.addAttribute("roleTypes", loginDetails.getRoleTypes());
|
196 |
//model.addAttribute("roleTypes", loginDetails.getRoleTypes());
|
| 206 |
return "schemes";
|
197 |
return "schemes";
|
| 207 |
}
|
198 |
}
|
| 208 |
|
199 |
|
| 209 |
@RequestMapping(value = "/getPaginatedSchemes", method = RequestMethod.GET)
|
200 |
@RequestMapping(value = "/getPaginatedSchemes", method = RequestMethod.GET)
|
| 210 |
public String getPaginatedSchemes(HttpServletRequest request,
|
- |
|
| 211 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 212 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
201 |
public String getPaginatedSchemes(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
| 213 |
throws ProfitMandiBusinessException {
|
- |
|
| 214 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
202 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 215 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
203 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
| 216 |
List<Scheme> schemes = null;
|
204 |
List<Scheme> schemes = null;
|
| - |
|
205 |
Role role = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
|
| 217 |
if (loginDetails.getRoleTypes().contains(RoleType.FOFO_ADMIN)) {
|
206 |
if(loginDetails.getRoleIds().contains(role.getId())){
|
| 218 |
schemes = schemeRepository.selectAll(offset, limit);
|
207 |
schemes = schemeRepository.selectAll(offset, limit);
|
| 219 |
} else {
|
208 |
}else{
|
| 220 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
209 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
| 221 |
}
|
210 |
}
|
| 222 |
model.addAttribute("schemes", schemes);
|
211 |
model.addAttribute("schemes", schemes);
|
| 223 |
model.addAttribute("roleTypes", loginDetails.getRoleTypes());
|
212 |
model.addAttribute("roleIds", loginDetails.getRoleIds());
|
| 224 |
return "schemes-paginated";
|
213 |
return "schemes-paginated";
|
| 225 |
}
|
214 |
}
|
| 226 |
|
215 |
|
| 227 |
@RequestMapping(value = "/schemes/downloadPage", method = RequestMethod.GET)
|
216 |
@RequestMapping(value = "/schemes/downloadPage", method = RequestMethod.GET)
|
| 228 |
public String downloadPage(HttpServletRequest request, Model model) {
|
217 |
public String downloadPage(HttpServletRequest request, Model model){
|
| 229 |
return "schemes-download";
|
218 |
return "schemes-download";
|
| 230 |
}
|
219 |
}
|
| 231 |
|
220 |
|
| 232 |
@RequestMapping(value = "/schemes/download", method = RequestMethod.GET)
|
221 |
@RequestMapping(value = "/schemes/download", method = RequestMethod.GET)
|
| 233 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
- |
|
| 234 |
@RequestParam(name = ProfitMandiConstants.START_DATE_TIME) String startDateTimeString,
|
- |
|
| 235 |
@RequestParam(name = ProfitMandiConstants.END_DATE_TIME) String endDateTimeString, Model model)
|
222 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.START_DATE_TIME) String startDateTimeString, @RequestParam(name = ProfitMandiConstants.END_DATE_TIME) String endDateTimeString, Model model) throws ProfitMandiBusinessException{
|
| 236 |
throws ProfitMandiBusinessException {
|
- |
|
| 237 |
LocalDateTime startDateTime = StringUtils.toDateTime(startDateTimeString,
|
223 |
LocalDateTime startDateTime = StringUtils.toDateTime(startDateTimeString, DateTimePattern.DD_MM_YYYY_T_HH_MM_SS);
|
| 238 |
DateTimePattern.DD_MM_YYYY_T_HH_MM_SS);
|
- |
|
| 239 |
LocalDateTime endDateTime = StringUtils.toDateTime(endDateTimeString, DateTimePattern.DD_MM_YYYY_T_HH_MM_SS);
|
224 |
LocalDateTime endDateTime = StringUtils.toDateTime(endDateTimeString, DateTimePattern.DD_MM_YYYY_T_HH_MM_SS);
|
| 240 |
|
225 |
|
| 241 |
List<SchemeModel> schemeModels = schemeService.getAllSchemeModels(startDateTime, endDateTime);
|
226 |
List<SchemeModel> schemeModels = schemeService.getAllSchemeModels(startDateTime, endDateTime);
|
| 242 |
|
227 |
|
| 243 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
228 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| 244 |
ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
229 |
ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
| 245 |
|
230 |
|
| 246 |
final HttpHeaders headers = new HttpHeaders();
|
231 |
final HttpHeaders headers=new HttpHeaders();
|
| 247 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
232 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| 248 |
headers.set("Content-disposition", "inline; filename=SchemesReport.xlsx");
|
233 |
headers.set("Content-disposition", "inline; filename=SchemesReport.xlsx");
|
| 249 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
234 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
| 250 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
235 |
final InputStream inputStream=new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
| 251 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
236 |
final InputStreamResource inputStreamResource=new InputStreamResource(inputStream);
|
| 252 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
237 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| 253 |
|
238 |
|
| 254 |
// return
|
- |
|
| 255 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
239 |
//return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 256 |
}
|
240 |
}
|
| 257 |
|
241 |
|
| 258 |
@RequestMapping(value = "/getSchemeById", method = RequestMethod.GET)
|
242 |
@RequestMapping(value = "/getSchemeById", method = RequestMethod.GET)
|
| 259 |
public String getSchemeById(HttpServletRequest request,
|
- |
|
| 260 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, Model model)
|
243 |
public String getSchemeById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, Model model) throws ProfitMandiBusinessException{
|
| 261 |
throws ProfitMandiBusinessException {
|
- |
|
| 262 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
244 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 263 |
Scheme scheme = schemeService.getSchemeById(schemeId);
|
245 |
Scheme scheme = schemeService.getSchemeById(schemeId);
|
| 264 |
model.addAttribute("scheme", scheme);
|
246 |
model.addAttribute("scheme", scheme);
|
| 265 |
model.addAttribute("roleTypes", loginDetails.getRoleTypes());
|
247 |
model.addAttribute("roleIds", loginDetails.getRoleIds());
|
| 266 |
return "scheme-details";
|
248 |
return "scheme-details";
|
| 267 |
}
|
249 |
}
|
| 268 |
|
250 |
|
| 269 |
@RequestMapping(value = "/activeSchemeById", method = RequestMethod.PUT)
|
251 |
@RequestMapping(value = "/activeSchemeById", method = RequestMethod.PUT)
|
| 270 |
public String activeSchemeById(HttpServletRequest request,
|
- |
|
| 271 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId,
|
- |
|
| 272 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 273 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
252 |
public String activeSchemeById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
| 274 |
throws ProfitMandiBusinessException {
|
- |
|
| 275 |
schemeService.activeSchemeById(schemeId);
|
253 |
schemeService.activeSchemeById(schemeId);
|
| 276 |
List<Scheme> schemes = schemeRepository.selectAll(offset, limit);
|
254 |
List<Scheme> schemes = schemeRepository.selectAll(offset, limit);
|
| 277 |
model.addAttribute("schemes", schemes);
|
255 |
model.addAttribute("schemes", schemes);
|
| 278 |
return "schemes-paginated";
|
256 |
return "schemes-paginated";
|
| 279 |
}
|
257 |
}
|
| - |
|
258 |
|
| 280 |
|
259 |
|
| 281 |
@RequestMapping(value = "/expireSchemeById", method = RequestMethod.PUT)
|
260 |
@RequestMapping(value = "/expireSchemeById", method = RequestMethod.PUT)
|
| 282 |
public String expireSchemeById(HttpServletRequest request,
|
- |
|
| 283 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId,
|
- |
|
| 284 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 285 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
261 |
public String expireSchemeById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
| 286 |
throws ProfitMandiBusinessException {
|
- |
|
| 287 |
schemeService.expireSchemeById(schemeId);
|
262 |
schemeService.expireSchemeById(schemeId);
|
| 288 |
List<Scheme> schemes = schemeRepository.selectAll(offset, limit);
|
263 |
List<Scheme> schemes = schemeRepository.selectAll(offset, limit);
|
| 289 |
model.addAttribute("schemes", schemes);
|
264 |
model.addAttribute("schemes", schemes);
|
| 290 |
return "schemes-paginated";
|
265 |
return "schemes-paginated";
|
| 291 |
}
|
266 |
}
|
| - |
|
267 |
|
| - |
|
268 |
@RequestMapping(value = "/getSchemesJson", method = RequestMethod.GET)
|
| - |
|
269 |
public ResponseEntity<?> getSchemesJson(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
| - |
|
270 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
271 |
return responseSender.ok(schemeService.getSchemes(loginDetails.getRoleIds(), offset, limit));
|
| - |
|
272 |
}
|
| 292 |
|
273 |
|
| 293 |
@RequestMapping(value = "/searchScheme")
|
274 |
@RequestMapping(value = "/searchScheme")
|
| 294 |
public String getSchemeBySchemeId(HttpServletRequest request,
|
275 |
public String getSchemeBySchemeId(HttpServletRequest request,
|
| 295 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
276 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 296 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
277 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| Line 341... |
Line 322... |
| 341 |
|
322 |
|
| 342 |
} else {
|
323 |
} else {
|
| 343 |
throw new ProfitMandiBusinessException("SchemeIds", searchItem, "SchemeId Not Found");
|
324 |
throw new ProfitMandiBusinessException("SchemeIds", searchItem, "SchemeId Not Found");
|
| 344 |
}
|
325 |
}
|
| 345 |
} else {
|
326 |
} else {
|
| - |
|
327 |
Role role = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
|
| 346 |
if (loginDetails.getRoleTypes().contains(RoleType.FOFO_ADMIN)) {
|
328 |
if (loginDetails.getRoleIds().contains(role.getId())) {
|
| 347 |
schemes = schemeRepository.selectAll(offset, limit);
|
329 |
schemes = schemeRepository.selectAll(offset, limit);
|
| 348 |
size = schemeRepository.selectAllCount();
|
330 |
size = schemeRepository.selectAllCount();
|
| 349 |
} else {
|
331 |
} else {
|
| 350 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
332 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
| 351 |
size = schemeRepository.selectAllActiveCount();
|
333 |
size = schemeRepository.selectAllActiveCount();
|