| 22860 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 23020 |
ashik.ali |
3 |
import java.io.ByteArrayInputStream;
|
|
|
4 |
import java.io.ByteArrayOutputStream;
|
|
|
5 |
import java.io.InputStream;
|
| 26674 |
tejbeer |
6 |
import java.time.LocalDate;
|
| 23020 |
ashik.ali |
7 |
import java.time.LocalDateTime;
|
| 26674 |
tejbeer |
8 |
import java.util.ArrayList;
|
| 23556 |
amit.gupta |
9 |
import java.util.Arrays;
|
| 23914 |
govind |
10 |
import java.util.HashMap;
|
| 23556 |
amit.gupta |
11 |
import java.util.HashSet;
|
| 22860 |
ashik.ali |
12 |
import java.util.List;
|
| 23020 |
ashik.ali |
13 |
import java.util.Map;
|
| 25368 |
amit.gupta |
14 |
import java.util.Set;
|
| 26588 |
tejbeer |
15 |
import java.util.stream.Collectors;
|
| 22860 |
ashik.ali |
16 |
|
|
|
17 |
import javax.servlet.http.HttpServletRequest;
|
| 25368 |
amit.gupta |
18 |
import javax.transaction.Transactional;
|
| 22860 |
ashik.ali |
19 |
|
| 23784 |
ashik.ali |
20 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
21 |
import org.apache.logging.log4j.Logger;
|
| 22860 |
ashik.ali |
22 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23784 |
ashik.ali |
23 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 23020 |
ashik.ali |
24 |
import org.springframework.core.io.InputStreamResource;
|
|
|
25 |
import org.springframework.http.HttpHeaders;
|
|
|
26 |
import org.springframework.http.HttpStatus;
|
|
|
27 |
import org.springframework.http.ResponseEntity;
|
| 22860 |
ashik.ali |
28 |
import org.springframework.stereotype.Controller;
|
|
|
29 |
import org.springframework.ui.Model;
|
|
|
30 |
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
31 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
32 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
33 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
34 |
|
| 26588 |
tejbeer |
35 |
import com.google.gson.Gson;
|
| 23020 |
ashik.ali |
36 |
import com.spice.profitmandi.common.enumuration.DateTimePattern;
|
| 22860 |
ashik.ali |
37 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 26588 |
tejbeer |
38 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 23914 |
govind |
39 |
import com.spice.profitmandi.common.model.MapWrapper;
|
| 22860 |
ashik.ali |
40 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 23557 |
amit.gupta |
41 |
import com.spice.profitmandi.common.model.SchemeItems;
|
| 23020 |
ashik.ali |
42 |
import com.spice.profitmandi.common.model.SchemeModel;
|
|
|
43 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
|
|
44 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 23784 |
ashik.ali |
45 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 27387 |
tejbeer |
46 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 26588 |
tejbeer |
47 |
import com.spice.profitmandi.dao.entity.catalog.Offer;
|
|
|
48 |
import com.spice.profitmandi.dao.entity.catalog.OfferPartner;
|
|
|
49 |
import com.spice.profitmandi.dao.entity.catalog.Offermargin;
|
| 22860 |
ashik.ali |
50 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 27389 |
amit.gupta |
51 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 25505 |
amit.gupta |
52 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 23556 |
amit.gupta |
53 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
| 27389 |
amit.gupta |
54 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| 26588 |
tejbeer |
55 |
import com.spice.profitmandi.dao.enumuration.catalog.ItemCriteriaType;
|
|
|
56 |
import com.spice.profitmandi.dao.model.AmountMarginModel;
|
|
|
57 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| 25505 |
amit.gupta |
58 |
import com.spice.profitmandi.dao.model.CreateSchemeRequest;
|
| 26588 |
tejbeer |
59 |
import com.spice.profitmandi.dao.model.ItemTypeParams;
|
|
|
60 |
import com.spice.profitmandi.dao.model.SimpleItemType;
|
| 26674 |
tejbeer |
61 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 26588 |
tejbeer |
62 |
import com.spice.profitmandi.dao.repository.catalog.OfferMarginRepository;
|
|
|
63 |
import com.spice.profitmandi.dao.repository.catalog.OfferPartnerRepository;
|
|
|
64 |
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
|
| 22860 |
ashik.ali |
65 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 27389 |
amit.gupta |
66 |
import com.spice.profitmandi.dao.repository.catalog.StateGstRateRepository;
|
| 23556 |
amit.gupta |
67 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 26588 |
tejbeer |
68 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
|
|
69 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 23784 |
ashik.ali |
70 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 26674 |
tejbeer |
71 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 23506 |
amit.gupta |
72 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 23556 |
amit.gupta |
73 |
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
|
| 23798 |
amit.gupta |
74 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 23020 |
ashik.ali |
75 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 22860 |
ashik.ali |
76 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 26588 |
tejbeer |
77 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 22860 |
ashik.ali |
78 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
79 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 23570 |
amit.gupta |
80 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22860 |
ashik.ali |
81 |
|
|
|
82 |
@Controller
|
| 25369 |
amit.gupta |
83 |
@Transactional(rollbackOn = Throwable.class)
|
| 22860 |
ashik.ali |
84 |
public class SchemeController {
|
|
|
85 |
|
| 23568 |
govind |
86 |
private static final Logger LOGGER = LogManager.getLogger(SchemeController.class);
|
| 22860 |
ashik.ali |
87 |
|
|
|
88 |
@Autowired
|
| 22927 |
ashik.ali |
89 |
private SchemeService schemeService;
|
| 23786 |
amit.gupta |
90 |
|
| 22860 |
ashik.ali |
91 |
@Autowired
|
| 27389 |
amit.gupta |
92 |
private StateGstRateRepository stateGstRateRepository;
|
| 27391 |
tejbeer |
93 |
|
| 27389 |
amit.gupta |
94 |
@Autowired
|
| 22927 |
ashik.ali |
95 |
private SchemeRepository schemeRepository;
|
| 22860 |
ashik.ali |
96 |
|
|
|
97 |
@Autowired
|
| 23556 |
amit.gupta |
98 |
private SchemeItemRepository schemeItemRepository;
|
| 23786 |
amit.gupta |
99 |
|
| 23556 |
amit.gupta |
100 |
@Autowired
|
| 23570 |
amit.gupta |
101 |
private MVCResponseSender mvcResponseSender;
|
| 23786 |
amit.gupta |
102 |
|
| 23570 |
amit.gupta |
103 |
@Autowired
|
| 22927 |
ashik.ali |
104 |
private CookiesProcessor cookiesProcessor;
|
| 23786 |
amit.gupta |
105 |
|
| 23020 |
ashik.ali |
106 |
@Autowired
|
| 23784 |
ashik.ali |
107 |
@Qualifier("fofoInventoryService")
|
| 23020 |
ashik.ali |
108 |
private InventoryService inventoryService;
|
| 23556 |
amit.gupta |
109 |
|
|
|
110 |
@Autowired
|
|
|
111 |
private TagListingRepository tagListingRepository;
|
| 23914 |
govind |
112 |
|
| 23798 |
amit.gupta |
113 |
@Autowired
|
|
|
114 |
private RoleManager roleManager;
|
| 23786 |
amit.gupta |
115 |
|
| 23506 |
amit.gupta |
116 |
@Autowired
|
| 26588 |
tejbeer |
117 |
private PurchaseRepository purchaseRepository;
|
| 23786 |
amit.gupta |
118 |
|
| 23784 |
ashik.ali |
119 |
@Autowired
|
|
|
120 |
private RoleRepository roleRepository;
|
| 23786 |
amit.gupta |
121 |
|
| 23784 |
ashik.ali |
122 |
@Autowired
|
|
|
123 |
private ResponseSender<?> responseSender;
|
| 22860 |
ashik.ali |
124 |
|
| 26588 |
tejbeer |
125 |
|
|
|
126 |
|
|
|
127 |
@Autowired
|
| 26674 |
tejbeer |
128 |
private PartnerTypeChangeService partnerTypeChangeService;
|
|
|
129 |
|
| 22860 |
ashik.ali |
130 |
@RequestMapping(value = "/createScheme", method = RequestMethod.GET)
|
| 23786 |
amit.gupta |
131 |
public String createScheme(HttpServletRequest request, Model model) {
|
|
|
132 |
// Map<Integer, String> itemIdItemDescriptionMap =
|
|
|
133 |
// inventoryService.getAllItemIdItemDescriptionMap();
|
|
|
134 |
// model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
| 25368 |
amit.gupta |
135 |
Set<String> brands = inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID);
|
|
|
136 |
brands.addAll(inventoryService.getAllTagListingBrands(14206));
|
|
|
137 |
model.addAttribute("brands", brands);
|
| 25505 |
amit.gupta |
138 |
model.addAttribute("retailerTypes", PartnerType.values());
|
| 22860 |
ashik.ali |
139 |
return "create-scheme";
|
|
|
140 |
}
|
| 23786 |
amit.gupta |
141 |
|
| 23914 |
govind |
142 |
@RequestMapping(value = "/getTagListingItemsByBrand", method = RequestMethod.POST)
|
|
|
143 |
public String getTagListingItemsByBrand(HttpServletRequest request, @RequestBody List<String> brands, Model model) {
|
|
|
144 |
Map<Integer, String> itemIdItemDescriptionMap = new HashMap<>();
|
|
|
145 |
LOGGER.info("brands" + brands);
|
|
|
146 |
|
|
|
147 |
List<MapWrapper<Integer, String>> itemIdItemDescriptionMaplist = inventoryService
|
|
|
148 |
.getAllTagListingItemIdItemDescriptionMap(new HashSet<>(brands));
|
|
|
149 |
for (MapWrapper<Integer, String> mapWrapper : itemIdItemDescriptionMaplist) {
|
|
|
150 |
itemIdItemDescriptionMap.put(mapWrapper.getKey(), mapWrapper.getValue());
|
|
|
151 |
}
|
| 23020 |
ashik.ali |
152 |
model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
| 23786 |
amit.gupta |
153 |
// model.addAttribute("brands", inventoryService.getAllBrands());
|
| 23914 |
govind |
154 |
|
| 23419 |
ashik.ali |
155 |
return "tag-listing-items-description";
|
| 23020 |
ashik.ali |
156 |
}
|
| 23556 |
amit.gupta |
157 |
|
|
|
158 |
@RequestMapping(value = "/schemes/update-schemes-page", method = RequestMethod.GET)
|
|
|
159 |
public String updateShcemes(HttpServletRequest request) throws ProfitMandiBusinessException {
|
|
|
160 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23799 |
amit.gupta |
161 |
if (!roleManager.isAdmin(loginDetails.getRoleIds())) {
|
| 23556 |
amit.gupta |
162 |
throw new ProfitMandiBusinessException("User", loginDetails.getEmailId(), "Unauthorised access");
|
|
|
163 |
}
|
|
|
164 |
return "update-schemes-page";
|
|
|
165 |
}
|
| 25256 |
amit.gupta |
166 |
|
| 23556 |
amit.gupta |
167 |
@RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
168 |
public String updateShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
|
|
|
169 |
throws Exception {
|
|
|
170 |
for (int schemeId : schemeItems.getSchemeIds()) {
|
| 23928 |
govind |
171 |
if (schemeRepository.selectById(schemeId) != null)
|
|
|
172 |
for (int itemId : schemeItems.getItemIds()) {
|
|
|
173 |
if (tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)),
|
|
|
174 |
new HashSet<>(Arrays.asList(4, 7))).size() > 0) {
|
|
|
175 |
SchemeItem si = new SchemeItem();
|
|
|
176 |
si.setItemId(itemId);
|
|
|
177 |
si.setSchemeId(schemeId);
|
|
|
178 |
try {
|
|
|
179 |
schemeItemRepository.persist(si);
|
|
|
180 |
} catch (Exception e) {
|
|
|
181 |
LOGGER.info("Scheme aleady exist");
|
|
|
182 |
}
|
|
|
183 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
184 |
} else {
|
|
|
185 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
186 |
throw new ProfitMandiBusinessException("ItemId", itemId, "Invalid Item Id");
|
|
|
187 |
}
|
|
|
188 |
}
|
|
|
189 |
}
|
|
|
190 |
return "response";
|
|
|
191 |
}
|
| 25256 |
amit.gupta |
192 |
|
| 23928 |
govind |
193 |
@RequestMapping(value = "/addItemToScheme", method = RequestMethod.POST)
|
|
|
194 |
public String updateScheme(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
|
|
|
195 |
throws Exception {
|
|
|
196 |
for (int schemeId : schemeItems.getSchemeIds()) {
|
| 23914 |
govind |
197 |
List<Integer> itemIds = schemeItemRepository.selectItemIdsBySchemeId(schemeId);
|
| 23786 |
amit.gupta |
198 |
if (schemeRepository.selectById(schemeId) != null)
|
|
|
199 |
for (int itemId : schemeItems.getItemIds()) {
|
|
|
200 |
if (tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)),
|
| 23914 |
govind |
201 |
new HashSet<>(Arrays.asList(4, 7))).size() > 0 && (!(itemIds.contains(itemId)))) {
|
| 23786 |
amit.gupta |
202 |
SchemeItem si = new SchemeItem();
|
|
|
203 |
si.setItemId(itemId);
|
|
|
204 |
si.setSchemeId(schemeId);
|
|
|
205 |
try {
|
|
|
206 |
schemeItemRepository.persist(si);
|
|
|
207 |
} catch (Exception e) {
|
| 23914 |
govind |
208 |
LOGGER.info("Scheme already exist");
|
| 23786 |
amit.gupta |
209 |
}
|
|
|
210 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
211 |
} else {
|
|
|
212 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
| 23556 |
amit.gupta |
213 |
}
|
|
|
214 |
}
|
|
|
215 |
}
|
|
|
216 |
return "response";
|
|
|
217 |
}
|
| 23914 |
govind |
218 |
|
|
|
219 |
@RequestMapping(value = "/schemes/delete", method = RequestMethod.DELETE)
|
|
|
220 |
public String deleteShcemes(HttpServletRequest request,
|
|
|
221 |
@RequestParam(name = "schemeId", required = false, defaultValue = "0") int schemeId,
|
|
|
222 |
@RequestParam(name = "itemId", required = false, defaultValue = "0") int itemId, Model model)
|
| 23819 |
govind |
223 |
throws Exception {
|
| 23914 |
govind |
224 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
225 |
if (!(schemeId == 0 && itemId == 0) || (!(schemeId == 0 || itemId == 0))) {
|
|
|
226 |
schemeItemRepository.deletebyItemIdsandSchemeIds(itemId, schemeId);
|
|
|
227 |
|
|
|
228 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
229 |
|
|
|
230 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
|
|
231 |
|
|
|
232 |
}
|
|
|
233 |
return "response";
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
@RequestMapping(value = "/extendAllSchemes", method = RequestMethod.POST)
|
|
|
237 |
public String extendAllScheme(HttpServletRequest request, @RequestBody LocalDateTime extendDatetime, Model model)
|
|
|
238 |
throws Exception {
|
|
|
239 |
|
|
|
240 |
List<Scheme> schemes = schemeRepository.selectActiveAll();
|
|
|
241 |
if (schemes.size() > 0) {
|
|
|
242 |
for (Scheme scheme : schemes) {
|
| 25261 |
amit.gupta |
243 |
if (scheme.getExpireTimestamp() == null) {
|
| 23914 |
govind |
244 |
scheme.setEndDateTime(extendDatetime);
|
|
|
245 |
schemeRepository.persist(scheme);
|
| 23819 |
govind |
246 |
}
|
|
|
247 |
}
|
| 23914 |
govind |
248 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
249 |
return "response";
|
| 23819 |
govind |
250 |
}
|
| 23914 |
govind |
251 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
| 23819 |
govind |
252 |
return "response";
|
|
|
253 |
}
|
| 23786 |
amit.gupta |
254 |
|
| 23914 |
govind |
255 |
@RequestMapping(value = "/extendSchemeById", method = RequestMethod.POST)
|
|
|
256 |
public String extendSchemeById(HttpServletRequest request,
|
| 23819 |
govind |
257 |
|
| 23914 |
govind |
258 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId,
|
|
|
259 |
@RequestBody LocalDateTime extendDatetime, Model model) throws Exception {
|
|
|
260 |
|
|
|
261 |
LOGGER.info("ExtendDatetime" + extendDatetime);
|
|
|
262 |
LOGGER.info("schemeId" + schemeId);
|
|
|
263 |
Scheme scheme = schemeRepository.selectById(schemeId);
|
|
|
264 |
if ((!(scheme.getActiveTimestamp() == null)) && scheme.getExpireTimestamp() == null) {
|
|
|
265 |
scheme.setEndDateTime(extendDatetime);
|
|
|
266 |
schemeRepository.persist(scheme);
|
|
|
267 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
268 |
return "response";
|
|
|
269 |
}
|
|
|
270 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
271 |
return "response";
|
|
|
272 |
}
|
|
|
273 |
|
| 22860 |
ashik.ali |
274 |
@RequestMapping(value = "/createScheme", method = RequestMethod.POST)
|
| 23715 |
govind |
275 |
public String createScheme(HttpServletRequest request, @RequestBody CreateSchemeRequest createSchemeRequest,
|
|
|
276 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 23752 |
govind |
277 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
278 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem,
|
|
|
279 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| 23715 |
govind |
280 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
281 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 22860 |
ashik.ali |
282 |
LOGGER.info("CreateSchemeRequest {}", createSchemeRequest);
|
| 22927 |
ashik.ali |
283 |
schemeService.saveScheme(loginDetails.getFofoId(), createSchemeRequest);
|
|
|
284 |
LOGGER.info("Scheme saved successfully");
|
| 23271 |
ashik.ali |
285 |
long size = schemeRepository.selectAllCount();
|
| 22927 |
ashik.ali |
286 |
List<Scheme> schemes = schemeRepository.selectAll(offset, limit);
|
|
|
287 |
model.addAttribute("schemes", schemes);
|
|
|
288 |
model.addAttribute("start", offset + 1);
|
| 23271 |
ashik.ali |
289 |
model.addAttribute("size", size);
|
| 23752 |
govind |
290 |
model.addAttribute("searchItem", searchItem);
|
|
|
291 |
model.addAttribute("searchTerm", searchTerm);
|
| 23914 |
govind |
292 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23715 |
govind |
293 |
if (schemes.size() < limit) {
|
| 22927 |
ashik.ali |
294 |
model.addAttribute("end", offset + schemes.size());
|
| 23786 |
amit.gupta |
295 |
} else {
|
| 22927 |
ashik.ali |
296 |
model.addAttribute("end", offset + limit);
|
|
|
297 |
}
|
|
|
298 |
return "schemes";
|
| 23786 |
amit.gupta |
299 |
|
| 22860 |
ashik.ali |
300 |
}
|
| 23786 |
amit.gupta |
301 |
|
| 22860 |
ashik.ali |
302 |
@RequestMapping(value = "/getSchemes", method = RequestMethod.GET)
|
| 23715 |
govind |
303 |
public String getSchemes(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 23752 |
govind |
304 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
305 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem,
|
| 26802 |
tejbeer |
306 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm,
|
|
|
307 |
@RequestParam(name = "partnerType", required = false, defaultValue = "") PartnerType partnerType,
|
|
|
308 |
Model model) throws ProfitMandiBusinessException {
|
| 23343 |
ashik.ali |
309 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26802 |
tejbeer |
310 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
311 |
|
|
|
312 |
LOGGER.info("isAdmin" + isAdmin);
|
| 23343 |
ashik.ali |
313 |
List<Scheme> schemes = null;
|
|
|
314 |
long size = 0;
|
| 26802 |
tejbeer |
315 |
LOGGER.info("partnerType" + partnerType);
|
|
|
316 |
if (partnerType == null) {
|
|
|
317 |
partnerType = partnerTypeChangeService.getTypeOnDate(loginDetails.getFofoId(), LocalDate.now());
|
| 23343 |
ashik.ali |
318 |
}
|
| 26802 |
tejbeer |
319 |
if (!(searchTerm.equals("")) && searchItem.equals("")) {
|
|
|
320 |
schemes = schemeRepository.selectBySearchTerm(searchTerm, offset, limit);
|
|
|
321 |
if (!(schemes.size() == 0)) {
|
| 27391 |
tejbeer |
322 |
for (Scheme scheme : schemes) {
|
|
|
323 |
if (scheme.getAmountType().equals(AmountType.PERCENTAGE)) {
|
| 27389 |
amit.gupta |
324 |
scheme.setAmountModel(scheme.getAmount() + "%");
|
|
|
325 |
} else {
|
|
|
326 |
scheme.setAmountModel(scheme.getAmount() + "");
|
|
|
327 |
}
|
|
|
328 |
}
|
| 27391 |
tejbeer |
329 |
|
| 26802 |
tejbeer |
330 |
size = schemeRepository.selectAllCount();
|
|
|
331 |
LOGGER.info("schemes" + schemes);
|
|
|
332 |
model.addAttribute("schemes", schemes);
|
|
|
333 |
model.addAttribute("start", offset + 1);
|
|
|
334 |
model.addAttribute("size", size);
|
|
|
335 |
model.addAttribute("searchTerm", searchTerm);
|
|
|
336 |
model.addAttribute("searchItem", searchItem);
|
| 26912 |
tejbeer |
337 |
model.addAttribute("partnerType", partnerType);
|
| 26802 |
tejbeer |
338 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
|
|
339 |
if (schemes.size() < limit) {
|
|
|
340 |
model.addAttribute("end", offset + schemes.size());
|
|
|
341 |
} else {
|
|
|
342 |
model.addAttribute("end", offset + limit);
|
|
|
343 |
}
|
|
|
344 |
} else {
|
|
|
345 |
throw new ProfitMandiBusinessException("SchemeId", searchTerm, "SchemeId Not Found");
|
|
|
346 |
}
|
| 23786 |
amit.gupta |
347 |
} else {
|
| 26802 |
tejbeer |
348 |
int itemId = 0;
|
|
|
349 |
if (!(searchItem.equals("")) && searchTerm.equals("")) {
|
|
|
350 |
itemId = Integer.parseInt(searchItem);
|
|
|
351 |
}
|
|
|
352 |
schemes = schemeService.selectSchemeByPartnerType(partnerType, itemId, isAdmin, offset, limit);
|
| 27389 |
amit.gupta |
353 |
TagListing tagListing = tagListingRepository.selectByItemId(itemId);
|
| 27391 |
tejbeer |
354 |
for (Scheme scheme : schemes) {
|
|
|
355 |
if (scheme.getAmountType().equals(AmountType.PERCENTAGE)) {
|
| 27389 |
amit.gupta |
356 |
float taxRate = stateGstRateRepository.getIgstTaxRate(Arrays.asList(itemId)).get(itemId);
|
|
|
357 |
float taxableSellingPrice = tagListing.getSellingPrice() / (1 + taxRate / 100);
|
|
|
358 |
float amount = taxableSellingPrice * scheme.getAmount() / 100;
|
| 27391 |
tejbeer |
359 |
scheme.setAmountModel(amount + " (" + scheme.getAmount() + "%)");
|
| 27389 |
amit.gupta |
360 |
} else {
|
|
|
361 |
scheme.setAmountModel(scheme.getAmount() + "");
|
|
|
362 |
}
|
|
|
363 |
}
|
| 26802 |
tejbeer |
364 |
size = schemeService.selectSchemeCount(partnerType, itemId, isAdmin);
|
|
|
365 |
model.addAttribute("schemes", schemes);
|
|
|
366 |
model.addAttribute("start", offset + 1);
|
|
|
367 |
model.addAttribute("size", size);
|
|
|
368 |
model.addAttribute("searchItem", searchItem);
|
|
|
369 |
model.addAttribute("searchTerm", searchTerm);
|
| 26912 |
tejbeer |
370 |
model.addAttribute("partnerType", partnerType);
|
| 26802 |
tejbeer |
371 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
|
|
372 |
if (schemes.size() < limit) {
|
|
|
373 |
model.addAttribute("end", offset + schemes.size());
|
|
|
374 |
} else {
|
|
|
375 |
model.addAttribute("end", offset + limit);
|
|
|
376 |
}
|
| 22860 |
ashik.ali |
377 |
}
|
| 23786 |
amit.gupta |
378 |
// model.addAttribute("roleTypes", loginDetails.getRoleTypes());
|
| 22860 |
ashik.ali |
379 |
return "schemes";
|
|
|
380 |
}
|
| 23786 |
amit.gupta |
381 |
|
| 22860 |
ashik.ali |
382 |
@RequestMapping(value = "/getPaginatedSchemes", method = RequestMethod.GET)
|
| 23786 |
amit.gupta |
383 |
public String getPaginatedSchemes(HttpServletRequest request,
|
|
|
384 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 26802 |
tejbeer |
385 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
386 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem,
|
|
|
387 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm,
|
|
|
388 |
@RequestParam(name = "partnerType", required = false, defaultValue = "") PartnerType partnerType,
|
|
|
389 |
Model model) throws ProfitMandiBusinessException {
|
|
|
390 |
|
| 23343 |
ashik.ali |
391 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26802 |
tejbeer |
392 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
393 |
|
| 23271 |
ashik.ali |
394 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
| 23343 |
ashik.ali |
395 |
List<Scheme> schemes = null;
|
| 26802 |
tejbeer |
396 |
/*
|
|
|
397 |
* if (roleManager.isAdmin(loginDetails.getRoleIds())) { schemes =
|
|
|
398 |
* schemeRepository.selectAll(offset, limit); } else { schemes =
|
|
|
399 |
* schemeRepository.selectActiveAll(offset, limit); }
|
|
|
400 |
*/
|
|
|
401 |
if (partnerType == null) {
|
|
|
402 |
partnerType = partnerTypeChangeService.getTypeOnDate(loginDetails.getFofoId(), LocalDate.now());
|
| 23343 |
ashik.ali |
403 |
}
|
| 26802 |
tejbeer |
404 |
LOGGER.info("partnerType" + partnerType);
|
|
|
405 |
int itemId = 0;
|
|
|
406 |
if (!(searchItem.equals("")) && searchTerm.equals("")) {
|
|
|
407 |
itemId = Integer.parseInt(searchItem);
|
|
|
408 |
}
|
|
|
409 |
schemes = schemeService.selectSchemeByPartnerType(partnerType, itemId, isAdmin, offset, limit);
|
|
|
410 |
|
| 22860 |
ashik.ali |
411 |
model.addAttribute("schemes", schemes);
|
| 26912 |
tejbeer |
412 |
model.addAttribute("partnerType", partnerType);
|
| 23914 |
govind |
413 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 22860 |
ashik.ali |
414 |
return "schemes-paginated";
|
|
|
415 |
}
|
| 23786 |
amit.gupta |
416 |
|
| 23020 |
ashik.ali |
417 |
@RequestMapping(value = "/schemes/downloadPage", method = RequestMethod.GET)
|
| 23786 |
amit.gupta |
418 |
public String downloadPage(HttpServletRequest request, Model model) {
|
| 23020 |
ashik.ali |
419 |
return "schemes-download";
|
|
|
420 |
}
|
| 23786 |
amit.gupta |
421 |
|
| 23020 |
ashik.ali |
422 |
@RequestMapping(value = "/schemes/download", method = RequestMethod.GET)
|
| 23786 |
amit.gupta |
423 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
| 23914 |
govind |
424 |
@RequestParam(name = ProfitMandiConstants.START_DATE_TIME) String startDateTimeString,
|
|
|
425 |
@RequestParam(name = ProfitMandiConstants.END_DATE_TIME) String endDateTimeString, Model model)
|
| 23786 |
amit.gupta |
426 |
throws ProfitMandiBusinessException {
|
| 23914 |
govind |
427 |
LocalDateTime startDateTime = StringUtils.toDateTime(startDateTimeString,
|
| 24406 |
amit.gupta |
428 |
DateTimePattern.DD_MM_yyyy_T_HH_MM_SS);
|
|
|
429 |
LocalDateTime endDateTime = StringUtils.toDateTime(endDateTimeString, DateTimePattern.DD_MM_yyyy_T_HH_MM_SS);
|
| 23914 |
govind |
430 |
|
| 23020 |
ashik.ali |
431 |
List<SchemeModel> schemeModels = schemeService.getAllSchemeModels(startDateTime, endDateTime);
|
| 23786 |
amit.gupta |
432 |
|
| 23020 |
ashik.ali |
433 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
434 |
ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
| 23786 |
amit.gupta |
435 |
|
|
|
436 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
437 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| 23020 |
ashik.ali |
438 |
headers.set("Content-disposition", "inline; filename=SchemesReport.xlsx");
|
| 23786 |
amit.gupta |
439 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
440 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
441 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
442 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
443 |
|
|
|
444 |
// return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 23020 |
ashik.ali |
445 |
}
|
| 23786 |
amit.gupta |
446 |
|
| 22860 |
ashik.ali |
447 |
@RequestMapping(value = "/getSchemeById", method = RequestMethod.GET)
|
| 23786 |
amit.gupta |
448 |
public String getSchemeById(HttpServletRequest request,
|
|
|
449 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, Model model)
|
|
|
450 |
throws ProfitMandiBusinessException {
|
| 23343 |
ashik.ali |
451 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 22860 |
ashik.ali |
452 |
Scheme scheme = schemeService.getSchemeById(schemeId);
|
|
|
453 |
model.addAttribute("scheme", scheme);
|
| 24445 |
amit.gupta |
454 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 22860 |
ashik.ali |
455 |
return "scheme-details";
|
| 23914 |
govind |
456 |
|
| 22860 |
ashik.ali |
457 |
}
|
| 23786 |
amit.gupta |
458 |
|
| 22860 |
ashik.ali |
459 |
@RequestMapping(value = "/activeSchemeById", method = RequestMethod.PUT)
|
| 23786 |
amit.gupta |
460 |
public String activeSchemeById(HttpServletRequest request,
|
|
|
461 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId,
|
|
|
462 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
463 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
464 |
throws ProfitMandiBusinessException {
|
| 22860 |
ashik.ali |
465 |
schemeService.activeSchemeById(schemeId);
|
|
|
466 |
List<Scheme> schemes = schemeRepository.selectAll(offset, limit);
|
|
|
467 |
model.addAttribute("schemes", schemes);
|
|
|
468 |
return "schemes-paginated";
|
|
|
469 |
}
|
| 23786 |
amit.gupta |
470 |
|
| 22860 |
ashik.ali |
471 |
@RequestMapping(value = "/expireSchemeById", method = RequestMethod.PUT)
|
| 23786 |
amit.gupta |
472 |
public String expireSchemeById(HttpServletRequest request,
|
|
|
473 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId,
|
| 25069 |
amit.gupta |
474 |
@RequestParam(name = ProfitMandiConstants.EXPIRE_TIMESTAMP) LocalDateTime expiryTimestamp,
|
| 23786 |
amit.gupta |
475 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
476 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
477 |
throws ProfitMandiBusinessException {
|
| 25069 |
amit.gupta |
478 |
schemeService.expireSchemeById(schemeId, expiryTimestamp);
|
| 22860 |
ashik.ali |
479 |
List<Scheme> schemes = schemeRepository.selectAll(offset, limit);
|
|
|
480 |
model.addAttribute("schemes", schemes);
|
|
|
481 |
return "schemes-paginated";
|
|
|
482 |
}
|
| 23786 |
amit.gupta |
483 |
|
| 23784 |
ashik.ali |
484 |
@RequestMapping(value = "/getSchemesJson", method = RequestMethod.GET)
|
| 23786 |
amit.gupta |
485 |
public ResponseEntity<?> getSchemesJson(HttpServletRequest request,
|
|
|
486 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
487 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
488 |
throws ProfitMandiBusinessException {
|
| 23784 |
ashik.ali |
489 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
490 |
return responseSender.ok(schemeService.getSchemes(loginDetails.getRoleIds(), offset, limit));
|
|
|
491 |
}
|
| 26802 |
tejbeer |
492 |
|
| 26763 |
tejbeer |
493 |
@RequestMapping(value = "/searchSchemeByCategory")
|
|
|
494 |
public String getSchemeByCategory(HttpServletRequest request,
|
|
|
495 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
496 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
497 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem,
|
|
|
498 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm,
|
|
|
499 |
@RequestParam(name = "category", required = true, defaultValue = "") PartnerType category, Model model)
|
|
|
500 |
throws ProfitMandiBusinessException {
|
|
|
501 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
502 |
List<Scheme> schemes = null;
|
|
|
503 |
long size = 0;
|
| 26802 |
tejbeer |
504 |
|
|
|
505 |
schemes = schemeRepository.selectByPartnerType(category, offset, limit);
|
|
|
506 |
|
|
|
507 |
if (!(schemes.size() == 0)) {
|
|
|
508 |
size = schemeRepository.selectAllCount();
|
|
|
509 |
LOGGER.info("schemes" + schemes);
|
|
|
510 |
model.addAttribute("schemes", schemes);
|
|
|
511 |
model.addAttribute("start", offset + 1);
|
|
|
512 |
model.addAttribute("size", size);
|
|
|
513 |
model.addAttribute("searchTerm", searchTerm);
|
|
|
514 |
model.addAttribute("searchItem", searchItem);
|
|
|
515 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
|
|
516 |
if (schemes.size() < limit) {
|
|
|
517 |
model.addAttribute("end", offset + schemes.size());
|
|
|
518 |
} else {
|
|
|
519 |
model.addAttribute("end", offset + limit);
|
| 26763 |
tejbeer |
520 |
}
|
| 26802 |
tejbeer |
521 |
}
|
|
|
522 |
|
| 26763 |
tejbeer |
523 |
return "schemes";
|
|
|
524 |
}
|
| 26802 |
tejbeer |
525 |
|
| 26763 |
tejbeer |
526 |
@RequestMapping(value = "/getSchemeByCategoryPaginated")
|
|
|
527 |
public String getSchemeByCategoryPaginated(HttpServletRequest request,
|
|
|
528 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
529 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
530 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem,
|
|
|
531 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm,
|
|
|
532 |
@RequestParam(name = "category", required = true, defaultValue = "") PartnerType category, Model model)
|
|
|
533 |
throws ProfitMandiBusinessException {
|
|
|
534 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
535 |
LOGGER.info("In search Item....");
|
|
|
536 |
List<Scheme> schemes = null;
|
| 26802 |
tejbeer |
537 |
|
| 26763 |
tejbeer |
538 |
schemes = schemeRepository.selectByPartnerType(category, offset, limit);
|
| 23506 |
amit.gupta |
539 |
|
| 26763 |
tejbeer |
540 |
model.addAttribute("schemes", schemes);
|
|
|
541 |
model.addAttribute("searchItem", searchItem);
|
|
|
542 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
|
|
543 |
return "schemes-paginated";
|
|
|
544 |
}
|
|
|
545 |
|
| 23752 |
govind |
546 |
@RequestMapping(value = "/searchScheme")
|
|
|
547 |
public String getSchemeBySchemeId(HttpServletRequest request,
|
|
|
548 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
549 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
550 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm,
|
|
|
551 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem, Model model)
|
|
|
552 |
throws ProfitMandiBusinessException {
|
|
|
553 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
554 |
List<Scheme> schemes = null;
|
|
|
555 |
long size = 0;
|
|
|
556 |
if (!(searchTerm.equals("")) && searchItem.equals("")) {
|
|
|
557 |
schemes = schemeRepository.selectBySearchTerm(searchTerm, offset, limit);
|
| 23786 |
amit.gupta |
558 |
if (!(schemes.size() == 0)) {
|
|
|
559 |
size = schemeRepository.selectAllCount();
|
|
|
560 |
LOGGER.info("schemes" + schemes);
|
|
|
561 |
model.addAttribute("schemes", schemes);
|
|
|
562 |
model.addAttribute("start", offset + 1);
|
|
|
563 |
model.addAttribute("size", size);
|
|
|
564 |
model.addAttribute("searchTerm", searchTerm);
|
|
|
565 |
model.addAttribute("searchItem", searchItem);
|
| 23914 |
govind |
566 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23786 |
amit.gupta |
567 |
if (schemes.size() < limit) {
|
|
|
568 |
model.addAttribute("end", offset + schemes.size());
|
|
|
569 |
} else {
|
|
|
570 |
model.addAttribute("end", offset + limit);
|
|
|
571 |
}
|
| 23752 |
govind |
572 |
} else {
|
| 23786 |
amit.gupta |
573 |
throw new ProfitMandiBusinessException("SchemeId", searchTerm, "SchemeId Not Found");
|
| 23752 |
govind |
574 |
}
|
|
|
575 |
} else if (!(searchItem.equals("")) && searchTerm.equals("")) {
|
|
|
576 |
List<Integer> schemeIds = schemeItemRepository.selectSchemeIdByItemId(Integer.parseInt(searchItem));
|
| 23786 |
amit.gupta |
577 |
if (!(schemeIds.size() == 0)) {
|
| 23752 |
govind |
578 |
LOGGER.info("schemeIds in searchItemScheme" + schemeIds);
|
|
|
579 |
schemes = schemeRepository.selectBySchemeIds(schemeIds, offset, limit);
|
|
|
580 |
size = schemeIds.size();
|
|
|
581 |
LOGGER.info("Size" + size);
|
|
|
582 |
model.addAttribute("schemes", schemes);
|
|
|
583 |
model.addAttribute("start", offset + 1);
|
|
|
584 |
model.addAttribute("size", size);
|
|
|
585 |
model.addAttribute("searchItem", searchItem);
|
|
|
586 |
model.addAttribute("searchTerm", searchTerm);
|
| 23914 |
govind |
587 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23752 |
govind |
588 |
if (schemes.size() < limit) {
|
|
|
589 |
model.addAttribute("end", offset + schemes.size());
|
|
|
590 |
} else {
|
|
|
591 |
model.addAttribute("end", offset + limit);
|
|
|
592 |
}
|
|
|
593 |
|
|
|
594 |
} else {
|
|
|
595 |
throw new ProfitMandiBusinessException("SchemeIds", searchItem, "SchemeId Not Found");
|
|
|
596 |
}
|
|
|
597 |
} else {
|
| 23798 |
amit.gupta |
598 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
| 23752 |
govind |
599 |
schemes = schemeRepository.selectAll(offset, limit);
|
|
|
600 |
size = schemeRepository.selectAllCount();
|
|
|
601 |
} else {
|
|
|
602 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
|
|
603 |
size = schemeRepository.selectAllActiveCount();
|
|
|
604 |
}
|
|
|
605 |
model.addAttribute("schemes", schemes);
|
|
|
606 |
model.addAttribute("start", offset + 1);
|
|
|
607 |
model.addAttribute("size", size);
|
|
|
608 |
model.addAttribute("searchItem", searchItem);
|
|
|
609 |
model.addAttribute("searchTerm", searchTerm);
|
| 23914 |
govind |
610 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23752 |
govind |
611 |
if (schemes.size() < limit) {
|
|
|
612 |
model.addAttribute("end", offset + schemes.size());
|
|
|
613 |
} else {
|
|
|
614 |
model.addAttribute("end", offset + limit);
|
|
|
615 |
}
|
|
|
616 |
}
|
|
|
617 |
return "schemes";
|
|
|
618 |
}
|
|
|
619 |
|
|
|
620 |
@RequestMapping(value = "/searchItemSchemePanigated")
|
|
|
621 |
public String getSchemeByItemPanigated(HttpServletRequest request,
|
|
|
622 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
623 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
624 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem, Model model)
|
|
|
625 |
throws ProfitMandiBusinessException {
|
| 23914 |
govind |
626 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23752 |
govind |
627 |
LOGGER.info("In search Item....");
|
|
|
628 |
List<Scheme> schemes = null;
|
|
|
629 |
if (!searchItem.equals("")) {
|
|
|
630 |
List<Integer> schemeIds = schemeItemRepository.selectSchemeIdByItemId(Integer.parseInt(searchItem));
|
|
|
631 |
if (schemeIds != null) {
|
|
|
632 |
LOGGER.info(schemeIds);
|
|
|
633 |
schemes = schemeRepository.selectBySchemeIds(schemeIds, offset, limit);
|
|
|
634 |
|
|
|
635 |
}
|
|
|
636 |
}
|
|
|
637 |
model.addAttribute("schemes", schemes);
|
|
|
638 |
model.addAttribute("searchItem", searchItem);
|
| 23914 |
govind |
639 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23752 |
govind |
640 |
return "schemes-paginated";
|
|
|
641 |
|
|
|
642 |
}
|
|
|
643 |
|
| 22860 |
ashik.ali |
644 |
}
|