| Line 5... |
Line 5... |
| 5 |
import java.time.LocalDateTime;
|
5 |
import java.time.LocalDateTime;
|
| 6 |
import java.time.LocalTime;
|
6 |
import java.time.LocalTime;
|
| 7 |
import java.util.ArrayList;
|
7 |
import java.util.ArrayList;
|
| 8 |
import java.util.Arrays;
|
8 |
import java.util.Arrays;
|
| 9 |
import java.util.HashMap;
|
9 |
import java.util.HashMap;
|
| - |
|
10 |
import java.util.HashSet;
|
| 10 |
import java.util.List;
|
11 |
import java.util.List;
|
| 11 |
import java.util.Map;
|
12 |
import java.util.Map;
|
| - |
|
13 |
import java.util.Set;
|
| 12 |
import java.util.stream.Collectors;
|
14 |
import java.util.stream.Collectors;
|
| 13 |
|
15 |
|
| 14 |
import javax.servlet.http.HttpServletRequest;
|
16 |
import javax.servlet.http.HttpServletRequest;
|
| 15 |
import javax.transaction.Transactional;
|
17 |
import javax.transaction.Transactional;
|
| 16 |
|
18 |
|
| Line 128... |
Line 130... |
| 128 |
@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
|
130 |
@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
|
| 129 |
public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
131 |
public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
| 130 |
|
132 |
|
| 131 |
List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
133 |
List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
| 132 |
Map<Integer, TagListing> tagListingMap = new HashMap<>();
|
134 |
Map<Integer, TagListing> tagListingMap = new HashMap<>();
|
| 133 |
List<ItemDescriptionModel> customItems = new ArrayList<>();
|
135 |
Set<ItemDescriptionModel> customItems = new HashSet<>();
|
| 134 |
List<ItemDescriptionModel> newCustomItems = new ArrayList<>();
|
136 |
List<ItemDescriptionModel> newCustomItems = new ArrayList<>();
|
| 135 |
List<Item> items = itemRepository.selectRecentItems(100);
|
137 |
List<Item> items = itemRepository.selectRecentItems(100);
|
| 136 |
for(Item item: items) {
|
138 |
for(Item item: items) {
|
| 137 |
ItemDescriptionModel itemDescriptionModel = new ItemDescriptionModel();
|
139 |
ItemDescriptionModel itemDescriptionModel = new ItemDescriptionModel();
|
| 138 |
itemDescriptionModel.setItemId(item.getId());
|
140 |
itemDescriptionModel.setItemId(item.getId());
|
| Line 151... |
Line 153... |
| 151 |
.setItemDescription(tagListing.getItemDescription() + "(" + tagListing.getItemId() + ")");
|
153 |
.setItemDescription(tagListing.getItemDescription() + "(" + tagListing.getItemId() + ")");
|
| 152 |
customItems.add(itemDescriptionModel);
|
154 |
customItems.add(itemDescriptionModel);
|
| 153 |
catalogDescription.put(item.getCatalogItemId(), item.getItemDescriptionNoColor());
|
155 |
catalogDescription.put(item.getCatalogItemId(), item.getItemDescriptionNoColor());
|
| 154 |
}
|
156 |
}
|
| 155 |
|
157 |
|
| 156 |
newCustomItems.removeAll(customItems);
|
158 |
newCustomItems.addAll(customItems);
|
| 157 |
|
159 |
|
| 158 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
160 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
| 159 |
model.addAttribute("tagListingMap", tagListingMap);
|
161 |
model.addAttribute("tagListingMap", tagListingMap);
|
| 160 |
model.addAttribute("customItems", new JSONArray(customItems).toString());
|
162 |
model.addAttribute("customItems", new JSONArray(customItems).toString());
|
| 161 |
model.addAttribute("newCustomItems", new JSONArray(newCustomItems).toString());
|
163 |
model.addAttribute("newCustomItems", new JSONArray(newCustomItems).toString());
|
| Line 166... |
Line 168... |
| 166 |
}
|
168 |
}
|
| 167 |
|
169 |
|
| 168 |
@RequestMapping(value = "/item-pricing/{itemId}", method = RequestMethod.GET)
|
170 |
@RequestMapping(value = "/item-pricing/{itemId}", method = RequestMethod.GET)
|
| 169 |
public String getItemPricing(HttpServletRequest request, Model model, @PathVariable int itemId) throws Throwable {
|
171 |
public String getItemPricing(HttpServletRequest request, Model model, @PathVariable int itemId) throws Throwable {
|
| 170 |
|
172 |
|
| 171 |
TagListing tagListing = tagListingRepository.selectByItemId(itemId);
|
173 |
TagListing tagListing;
|
| 172 |
PriceDropModel pm = new PriceDropModel();
|
174 |
PriceDropModel pm = new PriceDropModel();
|
| - |
|
175 |
try {
|
| - |
|
176 |
tagListing = tagListingRepository.selectByItemId(itemId);
|
| - |
|
177 |
if(tagListing!=null) {
|
| 173 |
pm.setMop(tagListing.getMop());
|
178 |
pm.setMop(tagListing.getMop());
|
| 174 |
pm.setDp(tagListing.getSellingPrice());
|
179 |
pm.setDp(tagListing.getSellingPrice());
|
| - |
|
180 |
pm.setMrp(tagListing.getMrp());
|
| 175 |
List<VendorItemPricing> vips = vendorItemPricingRepository.selectAll(itemId);
|
181 |
List<VendorItemPricing> vips = vendorItemPricingRepository.selectAll(itemId);
|
| 176 |
if(vips.size() > 0) {
|
182 |
if(vips.size() > 0) {
|
| 177 |
VendorItemPricing vip = vips.get(0);
|
183 |
VendorItemPricing vip = vips.get(0);
|
| 178 |
pm.setNlc(vip.getNlc());
|
184 |
pm.setNlc(vip.getNlc());
|
| 179 |
pm.setTp(vip.getTp());
|
185 |
pm.setTp(vip.getTp());
|
| 180 |
} else {
|
186 |
} else {
|
| 181 |
throw new ProfitMandiBusinessException("Item Id", itemId, "Vendor item pricing does not exist");
|
187 |
throw new ProfitMandiBusinessException("Item Id", itemId, "Vendor item pricing does not exist");
|
| - |
|
188 |
}
|
| - |
|
189 |
}
|
| - |
|
190 |
} catch(Exception e) {
|
| - |
|
191 |
LOGGER.info("Chose item that doesn't exist");
|
| 182 |
}
|
192 |
}
|
| 183 |
model.addAttribute("response", mvcResponseSender.createResponseString(pm));
|
193 |
model.addAttribute("response", mvcResponseSender.createResponseString(pm));
|
| 184 |
return "response";
|
194 |
return "response";
|
| 185 |
}
|
195 |
}
|
| 186 |
|
196 |
|