| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.util.ArrayList;
|
| - |
|
4 |
import java.util.Arrays;
|
| - |
|
5 |
import java.util.Comparator;
|
| - |
|
6 |
import java.util.HashMap;
|
| - |
|
7 |
import java.util.HashSet;
|
| - |
|
8 |
import java.util.Iterator;
|
| - |
|
9 |
import java.util.List;
|
| - |
|
10 |
import java.util.Map;
|
| - |
|
11 |
import java.util.Optional;
|
| - |
|
12 |
import java.util.Set;
|
| - |
|
13 |
import java.util.concurrent.atomic.AtomicInteger;
|
| - |
|
14 |
import java.util.stream.Collectors;
|
| - |
|
15 |
|
| - |
|
16 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
17 |
|
| - |
|
18 |
import org.apache.commons.lang3.StringUtils;
|
| - |
|
19 |
import org.apache.http.conn.HttpHostConnectException;
|
| - |
|
20 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
21 |
import org.apache.logging.log4j.Logger;
|
| - |
|
22 |
import org.json.JSONArray;
|
| - |
|
23 |
import org.json.JSONObject;
|
| - |
|
24 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
25 |
import org.springframework.beans.factory.annotation.Value;
|
| - |
|
26 |
import org.springframework.http.HttpStatus;
|
| - |
|
27 |
import org.springframework.http.MediaType;
|
| - |
|
28 |
import org.springframework.http.ResponseEntity;
|
| - |
|
29 |
import org.springframework.stereotype.Controller;
|
| - |
|
30 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
31 |
import org.springframework.web.bind.annotation.PathVariable;
|
| - |
|
32 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
33 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
34 |
import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
35 |
|
| 3 |
import com.eclipsesource.json.Json;
|
36 |
import com.eclipsesource.json.Json;
|
| 4 |
import com.eclipsesource.json.JsonArray;
|
37 |
import com.eclipsesource.json.JsonArray;
|
| 5 |
import com.eclipsesource.json.JsonObject;
|
38 |
import com.eclipsesource.json.JsonObject;
|
| 6 |
import com.eclipsesource.json.JsonValue;
|
39 |
import com.eclipsesource.json.JsonValue;
|
| 7 |
import com.google.gson.Gson;
|
40 |
import com.google.gson.Gson;
|
| 8 |
import com.google.gson.reflect.TypeToken;
|
41 |
import com.google.gson.reflect.TypeToken;
|
| - |
|
42 |
import com.itextpdf.text.pdf.security.CertificateInfo.X500Name;
|
| 9 |
import com.mongodb.BasicDBObject;
|
43 |
import com.mongodb.BasicDBObject;
|
| 10 |
import com.mongodb.DBObject;
|
44 |
import com.mongodb.DBObject;
|
| 11 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
45 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 12 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
46 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 13 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
47 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 14 |
import com.spice.profitmandi.common.model.UserInfo;
|
48 |
import com.spice.profitmandi.common.model.UserInfo;
|
| 15 |
import com.spice.profitmandi.common.solr.SolrService;
|
49 |
import com.spice.profitmandi.common.solr.SolrService;
|
| 16 |
import com.spice.profitmandi.common.web.client.RestClient;
|
50 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 17 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
51 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 18 |
import com.spice.profitmandi.dao.entity.catalog.Category;
|
52 |
import com.spice.profitmandi.dao.entity.catalog.Category;
|
| - |
|
53 |
import com.spice.profitmandi.dao.entity.catalog.ComboMappedModel;
|
| - |
|
54 |
import com.spice.profitmandi.dao.entity.catalog.ComboModel;
|
| 19 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
55 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 20 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
56 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 21 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
57 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
58 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
59 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
| Line 25... |
Line 61... |
| 25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
61 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
| 26 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
62 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| 27 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
63 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| 28 |
import com.spice.profitmandi.dao.model.UserCart;
|
64 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 29 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
65 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
| - |
|
66 |
import com.spice.profitmandi.dao.repository.catalog.ComboMappedModelRepository;
|
| - |
|
67 |
import com.spice.profitmandi.dao.repository.catalog.ComboModelRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
68 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
69 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 32 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
70 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
71 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 34 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
72 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
|
73 |
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
74 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
| 37 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
75 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
| 38 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
76 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
| 39 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
77 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| - |
|
78 |
import com.spice.profitmandi.service.inventory.AvailabilityInfo;
|
| 40 |
import com.spice.profitmandi.service.inventory.*;
|
79 |
import com.spice.profitmandi.service.inventory.Bucket;
|
| - |
|
80 |
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
|
| - |
|
81 |
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
|
| - |
|
82 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| - |
|
83 |
import com.spice.profitmandi.service.inventory.ItemBucketService;
|
| - |
|
84 |
import com.spice.profitmandi.service.inventory.ItemQuantityPojo;
|
| - |
|
85 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
| 41 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModel;
|
86 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModel;
|
| 42 |
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
|
87 |
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
|
| 43 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
88 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
| 44 |
import com.spice.profitmandi.service.pricing.PricingService;
|
89 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 45 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
90 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 46 |
import com.spice.profitmandi.web.res.DealBrands;
|
91 |
import com.spice.profitmandi.web.res.DealBrands;
|
| 47 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
92 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
| 48 |
import com.spice.profitmandi.web.res.DealsResponse;
|
93 |
import com.spice.profitmandi.web.res.DealsResponse;
|
| - |
|
94 |
|
| 49 |
import io.swagger.annotations.ApiImplicitParam;
|
95 |
import io.swagger.annotations.ApiImplicitParam;
|
| 50 |
import io.swagger.annotations.ApiImplicitParams;
|
96 |
import io.swagger.annotations.ApiImplicitParams;
|
| 51 |
import io.swagger.annotations.ApiOperation;
|
97 |
import io.swagger.annotations.ApiOperation;
|
| 52 |
import org.apache.commons.lang3.StringUtils;
|
- |
|
| 53 |
import org.apache.http.conn.HttpHostConnectException;
|
- |
|
| 54 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 55 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 56 |
import org.json.JSONArray;
|
- |
|
| 57 |
import org.json.JSONObject;
|
- |
|
| 58 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 59 |
import org.springframework.beans.factory.annotation.Value;
|
- |
|
| 60 |
import org.springframework.http.HttpStatus;
|
- |
|
| 61 |
import org.springframework.http.MediaType;
|
- |
|
| 62 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 63 |
import org.springframework.stereotype.Controller;
|
- |
|
| 64 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 65 |
import org.springframework.web.bind.annotation.PathVariable;
|
- |
|
| 66 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 67 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 68 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 69 |
|
- |
|
| 70 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 71 |
import java.util.*;
|
- |
|
| 72 |
import java.util.concurrent.atomic.AtomicInteger;
|
- |
|
| 73 |
import java.util.stream.Collectors;
|
- |
|
| 74 |
|
98 |
|
| 75 |
@Controller
|
99 |
@Controller
|
| 76 |
@Transactional(rollbackFor = Throwable.class)
|
100 |
@Transactional(rollbackFor = Throwable.class)
|
| 77 |
public class DealsController {
|
101 |
public class DealsController {
|
| 78 |
|
102 |
|
| Line 145... |
Line 169... |
| 145 |
private SuggestedPoRepository suggestedPoRepository;
|
169 |
private SuggestedPoRepository suggestedPoRepository;
|
| 146 |
|
170 |
|
| 147 |
@Autowired
|
171 |
@Autowired
|
| 148 |
private WebOfferRepository webOfferRepository;
|
172 |
private WebOfferRepository webOfferRepository;
|
| 149 |
|
173 |
|
| - |
|
174 |
@Autowired
|
| - |
|
175 |
private ComboModelRepository comboModelRepository;
|
| - |
|
176 |
|
| - |
|
177 |
@Autowired
|
| - |
|
178 |
private ComboMappedModelRepository comboMappedModelRepository;
|
| - |
|
179 |
|
| 150 |
List<String> filterableParams = Arrays.asList("brand");
|
180 |
List<String> filterableParams = Arrays.asList("brand");
|
| 151 |
|
181 |
|
| 152 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
182 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 153 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
183 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| 154 |
logger.info("Request " + request.getParameterMap());
|
184 |
logger.info("Request " + request.getParameterMap());
|
| Line 572... |
Line 602... |
| 572 |
fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
|
602 |
fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
|
| 573 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
603 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
| 574 |
|
604 |
|
| 575 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers()
|
605 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers()
|
| 576 |
.get(fofoCatalogResponse.getCatalogId());
|
606 |
.get(fofoCatalogResponse.getCatalogId());
|
| - |
|
607 |
|
| 577 |
logger.info("webOffers {}", webOffers);
|
608 |
logger.info("webOffers {}", webOffers);
|
| 578 |
if (webOffers != null && webOffers.size() > 0) {
|
609 |
if (webOffers != null && webOffers.size() > 0) {
|
| 579 |
fofoCatalogResponse.setWebOffers(webOffers);
|
610 |
fofoCatalogResponse.setWebOffers(webOffers);
|
| 580 |
}
|
611 |
}
|
| - |
|
612 |
|
| - |
|
613 |
List<ComboModel> comboModels = comboModelRepository.selectByWarehouseId(warehouseId).stream()
|
| - |
|
614 |
.filter(x -> x.getCatalogId() == fofoCatalogResponse.getCatalogId()).collect(Collectors.toList());
|
| - |
|
615 |
|
| - |
|
616 |
for (ComboModel comboModel : comboModels) {
|
| - |
|
617 |
|
| - |
|
618 |
List<ComboMappedModel> mappedModels = comboMappedModelRepository.selectByComboId(comboModel.getId());
|
| - |
|
619 |
|
| - |
|
620 |
comboModel.setComboMappedModels(mappedModels);
|
| - |
|
621 |
|
| - |
|
622 |
}
|
| - |
|
623 |
|
| - |
|
624 |
if (comboModels != null && comboModels.size() > 0) {
|
| - |
|
625 |
fofoCatalogResponse.setComboModels(comboModels);
|
| - |
|
626 |
}
|
| - |
|
627 |
|
| 581 |
try {
|
628 |
try {
|
| 582 |
fofoCatalogResponse.setFeature(doc.getString("feature_s"));
|
629 |
fofoCatalogResponse.setFeature(doc.getString("feature_s"));
|
| 583 |
} catch (Exception e) {
|
630 |
} catch (Exception e) {
|
| 584 |
fofoCatalogResponse.setFeature(null);
|
631 |
fofoCatalogResponse.setFeature(null);
|
| 585 |
logger.info("Could not find Feature_s for {}", fofoCatalogResponse.getCatalogId());
|
632 |
logger.info("Could not find Feature_s for {}", fofoCatalogResponse.getCatalogId());
|
| Line 843... |
Line 890... |
| 843 |
}
|
890 |
}
|
| 844 |
}
|
891 |
}
|
| 845 |
return dealResponse;
|
892 |
return dealResponse;
|
| 846 |
|
893 |
|
| 847 |
}
|
894 |
}
|
| - |
|
895 |
|
| - |
|
896 |
@RequestMapping(value = "/combo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
897 |
public ResponseEntity<?> getBanners(@RequestParam int catalogId, @RequestParam int warehouseId) {
|
| - |
|
898 |
List<ComboModel> comboModels = comboModelRepository.selectByCatalogIdAndWarehouseId(catalogId, warehouseId);
|
| - |
|
899 |
return responseSender.ok(comboModels);
|
| - |
|
900 |
}
|
| 848 |
}
|
901 |
}
|
| 849 |
|
902 |
|