| Line 5... |
Line 5... |
| 5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 6 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
6 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 7 |
import com.spice.profitmandi.common.util.Utils;
|
7 |
import com.spice.profitmandi.common.util.Utils;
|
| 8 |
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
|
8 |
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
|
| 9 |
import com.spice.profitmandi.dao.entity.catalog.Catalog;
|
9 |
import com.spice.profitmandi.dao.entity.catalog.Catalog;
|
| - |
|
10 |
import com.spice.profitmandi.dao.entity.catalog.CategorisedCatalog;
|
| 10 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
11 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 11 |
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricing;
|
12 |
import com.spice.profitmandi.dao.entity.inventory.VendorCatalogPricing;
|
| 12 |
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
|
13 |
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
|
| 13 |
import com.spice.profitmandi.dao.entity.warehouse.Supplier;
|
14 |
import com.spice.profitmandi.dao.entity.warehouse.Supplier;
|
| - |
|
15 |
import com.spice.profitmandi.dao.enumuration.inventory.CatalogMovingEnum;
|
| 14 |
import com.spice.profitmandi.dao.model.StateGstRateModel;
|
16 |
import com.spice.profitmandi.dao.model.StateGstRateModel;
|
| 15 |
import com.spice.profitmandi.dao.repository.catalog.BrandsRepository;
|
- |
|
| 16 |
import com.spice.profitmandi.dao.repository.catalog.CatalogRepository;
|
- |
|
| 17 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
17 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 18 |
import com.spice.profitmandi.dao.repository.catalog.StateGstRateRepository;
|
- |
|
| 19 |
import com.spice.profitmandi.dao.repository.inventory.VendorCatalogPricingRepository;
|
18 |
import com.spice.profitmandi.dao.repository.inventory.VendorCatalogPricingRepository;
|
| 20 |
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
|
19 |
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
|
| 21 |
import com.spice.profitmandi.dao.repository.warehouse.SupplierRepository;
|
20 |
import com.spice.profitmandi.dao.repository.warehouse.SupplierRepository;
|
| 22 |
import in.shop2020.model.v1.catalog.status;
|
21 |
import in.shop2020.model.v1.catalog.status;
|
| 23 |
import org.apache.logging.log4j.LogManager;
|
22 |
import org.apache.logging.log4j.LogManager;
|
| Line 29... |
Line 28... |
| 29 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
28 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| 30 |
import org.springframework.beans.factory.annotation.Autowired;
|
29 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 31 |
import org.springframework.stereotype.Component;
|
30 |
import org.springframework.stereotype.Component;
|
| 32 |
import org.springframework.web.multipart.MultipartFile;
|
31 |
import org.springframework.web.multipart.MultipartFile;
|
| 33 |
|
32 |
|
| - |
|
33 |
import java.time.LocalDate;
|
| 34 |
import java.time.LocalDateTime;
|
34 |
import java.time.LocalDateTime;
|
| 35 |
import java.util.Arrays;
|
35 |
import java.util.Arrays;
|
| 36 |
import java.util.List;
|
36 |
import java.util.List;
|
| 37 |
import java.util.Map;
|
37 |
import java.util.Map;
|
| 38 |
import java.util.stream.Collectors;
|
38 |
import java.util.stream.Collectors;
|
| Line 142... |
Line 142... |
| 142 |
|
142 |
|
| 143 |
|
143 |
|
| 144 |
@Autowired
|
144 |
@Autowired
|
| 145 |
CatalogRepository catalogRepository;
|
145 |
CatalogRepository catalogRepository;
|
| 146 |
|
146 |
|
| - |
|
147 |
@Autowired
|
| - |
|
148 |
CategorisedCatalogRepository categorisedCatalogRepository;
|
| - |
|
149 |
|
| 147 |
private void addItem(ItemLoaderModel itemLoaderModel) throws ProfitMandiBusinessException {
|
150 |
private void addItem(ItemLoaderModel itemLoaderModel) throws ProfitMandiBusinessException {
|
| 148 |
this.validateItemLoaderModel(itemLoaderModel);
|
151 |
this.validateItemLoaderModel(itemLoaderModel);
|
| 149 |
Catalog catalog = catalogRepository.selectCatalog(itemLoaderModel.getBrand(), itemLoaderModel.getModelNumber(), itemLoaderModel.getModelName());
|
152 |
Catalog catalog = catalogRepository.selectCatalog(itemLoaderModel.getBrand(), itemLoaderModel.getModelNumber(), itemLoaderModel.getModelName());
|
| 150 |
if (catalog != null) {
|
153 |
if (catalog != null) {
|
| 151 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalog.getId());
|
154 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalog.getId());
|
| Line 168... |
Line 171... |
| 168 |
for (Map.Entry<String, Long> colorCountEntrySet : colorsCount.entrySet()) {
|
171 |
for (Map.Entry<String, Long> colorCountEntrySet : colorsCount.entrySet()) {
|
| 169 |
if (colorCountEntrySet.getValue() > 1) {
|
172 |
if (colorCountEntrySet.getValue() > 1) {
|
| 170 |
throw new ProfitMandiBusinessException("Model repeats the same color", "Pls check", colorCountEntrySet.getKey());
|
173 |
throw new ProfitMandiBusinessException("Model repeats the same color", "Pls check", colorCountEntrySet.getKey());
|
| 171 |
}
|
174 |
}
|
| 172 |
}
|
175 |
}
|
| - |
|
176 |
|
| - |
|
177 |
CategorisedCatalog categorisedCatalog = categorisedCatalogRepository.getCurrentCatalogMovement(catalog.getId());
|
| - |
|
178 |
if (categorisedCatalog == null) {
|
| - |
|
179 |
CategorisedCatalog categorisedCatalogNew = new CategorisedCatalog();
|
| - |
|
180 |
categorisedCatalogNew.setCatalogId(catalog.getId());
|
| - |
|
181 |
categorisedCatalogNew.setStatus(CatalogMovingEnum.RUNNING);
|
| - |
|
182 |
categorisedCatalogNew.setStartDate(LocalDate.now());
|
| - |
|
183 |
categorisedCatalogRepository.persist(categorisedCatalogNew);
|
| - |
|
184 |
} else if (categorisedCatalog.getStatus().equals(CatalogMovingEnum.OTHER)) {
|
| - |
|
185 |
categorisedCatalog.setStatus(CatalogMovingEnum.SLOWMOVING);
|
| - |
|
186 |
}
|
| - |
|
187 |
|
| 173 |
} else {
|
188 |
} else {
|
| 174 |
catalog = new Catalog();
|
189 |
catalog = new Catalog();
|
| 175 |
BrandCatalog brand = brandsRepository.selectByBrand(itemLoaderModel.getBrand());
|
190 |
BrandCatalog brand = brandsRepository.selectByBrand(itemLoaderModel.getBrand());
|
| 176 |
if(brand == null) {
|
191 |
if(brand == null) {
|
| 177 |
throw new ProfitMandiBusinessException("Brand Does not exist", "Pls check", itemLoaderModel.getBrand());
|
192 |
throw new ProfitMandiBusinessException("Brand Does not exist", "Pls check", itemLoaderModel.getBrand());
|
| Line 182... |
Line 197... |
| 182 |
catalog.setModelNumber(itemLoaderModel.getModelNumber());
|
197 |
catalog.setModelNumber(itemLoaderModel.getModelNumber());
|
| 183 |
catalog.setCategoryId(itemLoaderModel.getCategoryId());
|
198 |
catalog.setCategoryId(itemLoaderModel.getCategoryId());
|
| 184 |
catalog.setCreated(LocalDateTime.now());
|
199 |
catalog.setCreated(LocalDateTime.now());
|
| 185 |
catalog.setCreatedBy("System");
|
200 |
catalog.setCreatedBy("System");
|
| 186 |
catalogRepository.persist(catalog);
|
201 |
catalogRepository.persist(catalog);
|
| - |
|
202 |
|
| - |
|
203 |
|
| - |
|
204 |
CategorisedCatalog categorisedCatalog = new CategorisedCatalog();
|
| - |
|
205 |
categorisedCatalog.setCatalogId(catalog.getId());
|
| - |
|
206 |
categorisedCatalog.setStatus(CatalogMovingEnum.RUNNING);
|
| - |
|
207 |
categorisedCatalog.setStartDate(LocalDate.now());
|
| - |
|
208 |
categorisedCatalogRepository.persist(categorisedCatalog);
|
| 187 |
}
|
209 |
}
|
| 188 |
//Finally either got valid existing model or new model altogether
|
210 |
//Finally either got valid existing model or new model altogether
|
| 189 |
Item item = new Item();
|
211 |
Item item = new Item();
|
| 190 |
item.setBrand(itemLoaderModel.getBrand());
|
212 |
item.setBrand(itemLoaderModel.getBrand());
|
| 191 |
item.setModelName(itemLoaderModel.getModelName());
|
213 |
item.setModelName(itemLoaderModel.getModelName());
|