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