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