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