| Line 149... |
Line 149... |
| 149 |
Catalog catalog = catalogRepository.selectCatalog(itemLoaderModel.getBrand(), itemLoaderModel.getModelNumber(), itemLoaderModel.getModelName());
|
149 |
Catalog catalog = catalogRepository.selectCatalog(itemLoaderModel.getBrand(), itemLoaderModel.getModelNumber(), itemLoaderModel.getModelName());
|
| 150 |
if (catalog != null) {
|
150 |
if (catalog != null) {
|
| 151 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalog.getId());
|
151 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalog.getId());
|
| 152 |
long similarColorCount = items.stream().filter(x -> itemLoaderModel.getColor().equals(x.getColorNatural())).count();
|
152 |
long similarColorCount = items.stream().filter(x -> itemLoaderModel.getColor().equals(x.getColorNatural())).count();
|
| 153 |
if (similarColorCount > 0) {
|
153 |
if (similarColorCount > 0) {
|
| 154 |
throw new ProfitMandiBusinessException("Color alerady exist", "Pls check", itemLoaderModel.getColor());
|
154 |
throw new ProfitMandiBusinessException("Color already exist", "Pls check", itemLoaderModel.getColor());
|
| 155 |
}
|
155 |
}
|
| 156 |
|
156 |
|
| 157 |
List<Integer> categoryIds = items.stream().map(x -> x.getCategoryId()).distinct().collect(Collectors.toList());
|
157 |
List<Integer> categoryIds = items.stream().map(x -> x.getCategoryId()).distinct().collect(Collectors.toList());
|
| 158 |
if (categoryIds.size() > 1) {
|
158 |
if (categoryIds.size() > 1) {
|
| 159 |
throw new ProfitMandiBusinessException("Model Wrongly Mapped to different categories", "Pls check", categoryIds.toString());
|
159 |
throw new ProfitMandiBusinessException("Model Wrongly Mapped to different categories", "Pls check", categoryIds.toString());
|