| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 4 |
import com.spice.profitmandi.common.model.ItemDescriptionModel;
|
4 |
import com.spice.profitmandi.common.model.ItemDescriptionModel;
|
| - |
|
5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 5 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
6 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 6 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
7 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 7 |
import com.spice.profitmandi.dao.entity.inventory.Vendor;
|
8 |
import com.spice.profitmandi.dao.entity.inventory.Vendor;
|
| 8 |
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricing;
|
9 |
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricing;
|
| 9 |
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricingLog;
|
10 |
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricingLog;
|
| Line 221... |
Line 222... |
| 221 |
|
222 |
|
| 222 |
}
|
223 |
}
|
| 223 |
|
224 |
|
| 224 |
@RequestMapping(value = "/getPricing", method = RequestMethod.GET)
|
225 |
@RequestMapping(value = "/getPricing", method = RequestMethod.GET)
|
| 225 |
public String getPricing(HttpServletRequest request, @RequestParam int vendorId, @RequestParam int itemId, @RequestParam LocalDate onDate, Model model) throws Exception {
|
226 |
public String getPricing(HttpServletRequest request, @RequestParam int vendorId, @RequestParam int itemId, @RequestParam LocalDate onDate, Model model) throws Exception {
|
| 226 |
|
- |
|
| 227 |
vendorId = this.getVendorId(itemId, vendorId);
|
- |
|
| 228 |
Item item = itemRepository.selectById(itemId);
|
227 |
Item item = itemRepository.selectById(itemId);
|
| 229 |
VendorPriceCircularModel vendorPriceCircularModel = vendorCatalogPricingLogRepository.getVendorPriceOnDate(vendorId, item.getCatalogItemId(), onDate);
|
228 |
VendorPriceCircularModel vendorPriceCircularModel = vendorCatalogPricingLogRepository.getVendorPriceOnDate(vendorId, item.getCatalogItemId(), onDate);
|
| 230 |
|
229 |
|
| 231 |
LOGGER.info("vendorCatalogPricing {}", vendorPriceCircularModel);
|
230 |
LOGGER.info("vendorCatalogPricing {}", vendorPriceCircularModel);
|
| 232 |
|
231 |
|
| Line 234... |
Line 233... |
| 234 |
|
233 |
|
| 235 |
return "response";
|
234 |
return "response";
|
| 236 |
|
235 |
|
| 237 |
}
|
236 |
}
|
| 238 |
|
237 |
|
| 239 |
private int getVendorId(int itemId, int vendorId) throws ProfitMandiBusinessException {
|
238 |
private void addVendorPricingIfMissing(int itemId, int vendorId) throws ProfitMandiBusinessException {
|
| 240 |
Item item = itemRepository.selectById(itemId);
|
239 |
Item item = itemRepository.selectById(itemId);
|
| - |
|
240 |
int vendorWithPricing = 0;
|
| 241 |
if (vendorId == 406 || vendorId == 419) {
|
241 |
if (vendorId == 406 || vendorId == 419) {
|
| - |
|
242 |
VendorPriceCircularModel vendorPriceCircularModel = vendorCatalogPricingLogRepository.getVendorPriceOnDate(vendorId, itemId, LocalDate.now());
|
| - |
|
243 |
LOGGER.info("VendorPriceCircularModel - {}", vendorPriceCircularModel);
|
| - |
|
244 |
if (vendorPriceCircularModel == null) {
|
| - |
|
245 |
|
| 242 |
if (item.getBrand().equals("Oppo")) {
|
246 |
if (item.getBrand().equals("Oppo")) {
|
| 243 |
//RS Distributions
|
247 |
//RS Distributions
|
| 244 |
vendorId = 438;
|
248 |
vendorWithPricing = 438;
|
| 245 |
} else if (item.getBrand().equals("Vivo")) {
|
249 |
} else if (item.getBrand().equals("Vivo")) {
|
| 246 |
//Nexg
|
250 |
//Nexg
|
| 247 |
vendorId = 393;
|
251 |
vendorWithPricing = 393;
|
| 248 |
} else {
|
252 |
} else {
|
| 249 |
//NSSPL Delhi
|
253 |
//NSSPL Delhi
|
| 250 |
vendorId = 325;
|
254 |
vendorWithPricing = 325;
|
| - |
|
255 |
}
|
| - |
|
256 |
VendorPriceCircularModel existingPriceCircular = vendorCatalogPricingLogRepository.getVendorPriceOnDate(vendorWithPricing, item.getCatalogItemId(), LocalDate.now());
|
| - |
|
257 |
LOGGER.info("Existing price circular - {}", existingPriceCircular);
|
| - |
|
258 |
if (existingPriceCircular == null) {
|
| - |
|
259 |
throw new ProfitMandiBusinessException("Pricing missing for vendor - " + vendorId, "Pricing missing for vendor - " + vendorId, "Pricing missing for vendor - " + vendorId);
|
| - |
|
260 |
}
|
| - |
|
261 |
VendorCatalogPricingModel vendorCatalogPricingModel = new VendorCatalogPricingModel();
|
| - |
|
262 |
vendorCatalogPricingModel.setAuthId(52);
|
| - |
|
263 |
vendorCatalogPricingModel.setVendorId(vendorId);
|
| - |
|
264 |
vendorCatalogPricingModel.setCatalogId(existingPriceCircular.getCatalogId());
|
| - |
|
265 |
vendorCatalogPricingModel.setDp(existingPriceCircular.getDealerPrice());
|
| - |
|
266 |
vendorCatalogPricingModel.setEffectedOn(existingPriceCircular.getEffectedOn());
|
| - |
|
267 |
vendorCatalogPricingModel.setMop(existingPriceCircular.getMop());
|
| - |
|
268 |
vendorCatalogPricingModel.setTp(existingPriceCircular.getTransferPrice());
|
| - |
|
269 |
vendorCatalogPricingModel.setCatalogId(item.getCatalogItemId());
|
| - |
|
270 |
|
| - |
|
271 |
VendorCatalogPricingLog vendorCatalogPricingLog = vendorCatalogPricingService.createVendorCatalogPricingLog(vendorCatalogPricingModel);
|
| - |
|
272 |
vendorCatalogPricingLog.setStatus(VendorCatalogPricingStatus.APPROVED);
|
| - |
|
273 |
vendorCatalogPricingLog.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
274 |
//Deenanath Auth Id
|
| - |
|
275 |
vendorCatalogPricingLog.setApprovedBy(138);
|
| - |
|
276 |
vendorCatalogPricingLog.setApprovedTimestamp(LocalDateTime.now());
|
| - |
|
277 |
vendorCatalogPricingService.createVendorCatalogPricing(vendorCatalogPricingLog);
|
| - |
|
278 |
|
| 251 |
}
|
279 |
}
|
| 252 |
}
|
280 |
}
|
| 253 |
return vendorId;
|
- |
|
| 254 |
}
|
281 |
}
|
| 255 |
|
282 |
|
| 256 |
@RequestMapping(value = "/vendorItem", method = RequestMethod.GET)
|
283 |
@RequestMapping(value = "/vendorItem", method = RequestMethod.GET)
|
| 257 |
public String getItemPricing(HttpServletRequest request, Model model, @RequestParam int vendorId,
|
284 |
public String getItemPricing(HttpServletRequest request, Model model, @RequestParam int vendorId,
|
| 258 |
@RequestParam String query) throws Throwable {
|
285 |
@RequestParam String query) throws Throwable {
|
| 259 |
String query1 = query.toLowerCase();
|
286 |
String query1 = query.toLowerCase();
|
| 260 |
int itemId = 0;
|
287 |
int itemId = 0;
|
| 261 |
try {
|
288 |
try {
|
| 262 |
itemId = Integer.parseInt(query1);
|
289 |
itemId = Integer.parseInt(query1);
|
| 263 |
vendorId = this.getVendorId(itemId, vendorId);
|
290 |
addVendorPricingIfMissing(itemId, vendorId);
|
| 264 |
} catch (Exception e) {
|
291 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
292 |
LOGGER.info("Caught in the block - {}", e.getStackTrace());
|
| 265 |
//
|
293 |
// e.printStackTrace();
|
| 266 |
}
|
294 |
}
|
| 267 |
//UK or rudrapu
|
295 |
LOGGER.info("Vendor Id - {}", vendorId);
|
| 268 |
List<ItemDescriptionModel> partnersItemDescription = warehouseService.getAllPartnerItemStringDescription(vendorId).parallelStream().filter(x -> x.getItemDescription().toLowerCase().matches(".*?" + query1 + ".*?")).collect(Collectors.toList());
|
296 |
List<ItemDescriptionModel> partnersItemDescription = warehouseService.getAllPartnerItemStringDescription(vendorId).parallelStream().filter(x -> x.getItemDescription().toLowerCase().matches(".*?" + query1 + ".*?")).collect(Collectors.toList());
|
| 269 |
LOGGER.info("partnersItemDescription" + partnersItemDescription);
|
297 |
LOGGER.info("partnersItemDescription" + partnersItemDescription);
|
| 270 |
|
298 |
|
| 271 |
model.addAttribute("response1", mvcResponseSender.createResponseString(partnersItemDescription));
|
299 |
model.addAttribute("response1", mvcResponseSender.createResponseString(partnersItemDescription));
|
| 272 |
return "response";
|
300 |
return "response";
|