Authored by hugufei

去除无用日志

... ... @@ -20,183 +20,181 @@ import java.util.Map;
@Component
public class ProductILogicService {
private final Logger logger = LoggerFactory.getLogger(ProductILogicService.class);
private final Logger logger = LoggerFactory.getLogger(ProductILogicService.class);
@Autowired
private SpecialDealLogicService specialDealLogicService;
@Autowired
private SpecialDealLogicService specialDealLogicService;
/**
* 拼装ProductIBO数据(包含了product,brand,sort,shop几部分信息),全量增量都有调用
*/
public List<ProductIBO> buildProductIBO(List<Product> products, Map<Integer, ProductSort> productSortMap, Map<Integer, Brand> brandMap,
Map<Integer, Shops> shopMap, Map<Integer, CsBrandKeyword> csBrandKeywordMap) {
/**
* 拼装ProductIBO数据(包含了product,brand,sort,shop几部分信息),全量增量都有调用
*/
public List<ProductIBO> buildProductIBO(List<Product> products, Map<Integer, ProductSort> productSortMap, Map<Integer, Brand> brandMap,
Map<Integer, Shops> shopMap, Map<Integer, CsBrandKeyword> csBrandKeywordMap) {
long begin = System.currentTimeMillis();
List<ProductIBO> productIBOList = new ArrayList<>();
List<ProductIBO> productIBOList = new ArrayList<>();
for (Product p : products) {
ProductIBO productIBO = new ProductIBO();
try {
productIBO.setId(p.getId().toString());
productIBO.setProductId(p.getId());
productIBO.setProductSkn(p.getErpProductId());
productIBO.setShopId(p.getShopId());
productIBO.setSupplierId(p.getSupplierId());
productIBO.setProductName(p.getProductName());
productIBO.setSalesPhrase(p.getSalesPhrase());
productIBO.setMarketPhrase(p.getMarketPhrase());
productIBO.setBrandId(p.getBrandId());
productIBO.setMaxSortId(p.getMaxSortId());
productIBO.setMiddleSortId(p.getMiddleSortId());
productIBO.setSmallSortId(p.getSmallSortId());
productIBO.setSeriesId(p.getSeriesId());
productIBO.setIsSeckill("N");
productIBO.setBundleType(p.getBundleType());
if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) {
productIBO.setIsSeckill("Y");
}
productIBO.setStyle(p.getStyle());
productIBO.setPattern(p.getPattern());
productIBO.setPhrase(p.getPhrase());
productIBO.setIsPhraseExist("Y");
if (StringUtils.isBlank(p.getPhrase())) {
productIBO.setIsPhraseExist("N");
}
productIBO.setGender(p.getGender());
productIBO.setGenderS("男,女");
if (p.getGender() != null) {
if (p.getGender().equals("1")) {
productIBO.setGenderS("男");
}
if (p.getGender().equals("2")) {
productIBO.setGenderS("女");
}
}
productIBO.setIslimited("N");
if ("Y".equals(p.getIsLimited())) {
productIBO.setIslimited("Y");
}
productIBO.setIsSpecial("N");
if ("Y".equals(p.getIsSpecial())) {
productIBO.setIsSpecial("Y");
}
productIBO.setIsSales("Y");
if ("N".equals(p.getIsSales())) {
productIBO.setIsSales("N");
}
productIBO.setIsAdvance("N");
if ("Y".equals(p.getIsAdvance())) {
productIBO.setIsAdvance("Y");
}
productIBO.setIsOutlets(2);
if ("Y".equals(p.getIsOutlets())) {
productIBO.setIsOutlets(1);
}
productIBO.setIsLimitbuy("N");
if ("Y".equals(p.getIsLimitbuy())) {
productIBO.setIsLimitbuy("Y");
}
productIBO.setIsInstalment("0");
if ("1".equals(p.getIsInstalment())) {
productIBO.setIsInstalment("1");
}
productIBO.setIsSeckill("N");
if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) {
productIBO.setIsSeckill("Y");
}
productIBO.setIsDepositAdvance("N");
if ("Y".equals(p.getIsDepositAdvance())) {
productIBO.setIsDepositAdvance("Y");
}
productIBO.setIspromotion(p.getIsPromotion());
productIBO.setAttribute(p.getAttribute());
productIBO.setSeasons(p.getSeasons());
productIBO.setFirstShelveTime(p.getFirstShelveTime());
productIBO.setShelveTime(p.getShelveTime());
String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(p.getShelveTime()), "yyyy-MM-dd");
productIBO.setShelveDay(shelveDay);
if (p.getShelveTime() == 0) {
productIBO.setShelveDay("0");
}
productIBO.setEditTime(p.getEditTime());
productIBO.setStatus(p.getStatus());
productIBO.setFolderId(p.getFolderId());
productIBO.setSellChannels(p.getSellChannels());
productIBO.setAgeLevel(p.getAgeLevel());
productIBO.setAppType(p.getAppType());
productIBO.setCouponLimitStatus(p.getCouponLimitStatus());
productIBO.setIsFobbiden(p.getIsFobbiden());
productIBO.setStoreShowStatus(p.getStoreShowStatus());
productIBO.setIsLimitTimeAdvance(p.getIsLimitTimeAdvance());
productIBO.setSellType(p.getSellType());
// 品牌
this.buildBrand(brandMap, csBrandKeywordMap, p, productIBO);
// 品类
this.buildSort(productSortMap, p, productIBO);
// 店铺
this.buildShop(shopMap, p, productIBO);
// 增加一些特殊处理的逻辑
specialDealLogicService.specialDealForProductIBO(productIBO);
productIBOList.add(productIBO);
} catch (Exception e) {
logger.error("[fun=buildProductIBO][" + p.getId() + "]" + e.getMessage(), e);
}
}
logger.info("[fun=buildProductIBO],[cost: {}]", System.currentTimeMillis() - begin);
return productIBOList;
}
for (Product p : products) {
ProductIBO productIBO = new ProductIBO();
try {
productIBO.setId(p.getId().toString());
productIBO.setProductId(p.getId());
productIBO.setProductSkn(p.getErpProductId());
productIBO.setShopId(p.getShopId());
productIBO.setSupplierId(p.getSupplierId());
productIBO.setProductName(p.getProductName());
productIBO.setSalesPhrase(p.getSalesPhrase());
productIBO.setMarketPhrase(p.getMarketPhrase());
productIBO.setBrandId(p.getBrandId());
productIBO.setMaxSortId(p.getMaxSortId());
productIBO.setMiddleSortId(p.getMiddleSortId());
productIBO.setSmallSortId(p.getSmallSortId());
productIBO.setSeriesId(p.getSeriesId());
productIBO.setIsSeckill("N");
productIBO.setBundleType(p.getBundleType());
if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) {
productIBO.setIsSeckill("Y");
}
productIBO.setStyle(p.getStyle());
productIBO.setPattern(p.getPattern());
productIBO.setPhrase(p.getPhrase());
productIBO.setIsPhraseExist("Y");
if (StringUtils.isBlank(p.getPhrase())) {
productIBO.setIsPhraseExist("N");
}
productIBO.setGender(p.getGender());
productIBO.setGenderS("男,女");
if (p.getGender() != null) {
if (p.getGender().equals("1")) {
productIBO.setGenderS("男");
}
if (p.getGender().equals("2")) {
productIBO.setGenderS("女");
}
}
productIBO.setIslimited("N");
if ("Y".equals(p.getIsLimited())) {
productIBO.setIslimited("Y");
}
productIBO.setIsSpecial("N");
if ("Y".equals(p.getIsSpecial())) {
productIBO.setIsSpecial("Y");
}
productIBO.setIsSales("Y");
if ("N".equals(p.getIsSales())) {
productIBO.setIsSales("N");
}
productIBO.setIsAdvance("N");
if ("Y".equals(p.getIsAdvance())) {
productIBO.setIsAdvance("Y");
}
productIBO.setIsOutlets(2);
if ("Y".equals(p.getIsOutlets())) {
productIBO.setIsOutlets(1);
}
productIBO.setIsLimitbuy("N");
if ("Y".equals(p.getIsLimitbuy())) {
productIBO.setIsLimitbuy("Y");
}
productIBO.setIsInstalment("0");
if ("1".equals(p.getIsInstalment())) {
productIBO.setIsInstalment("1");
}
productIBO.setIsSeckill("N");
if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) {
productIBO.setIsSeckill("Y");
}
productIBO.setIsDepositAdvance("N");
if ("Y".equals(p.getIsDepositAdvance())) {
productIBO.setIsDepositAdvance("Y");
}
productIBO.setIspromotion(p.getIsPromotion());
productIBO.setAttribute(p.getAttribute());
productIBO.setSeasons(p.getSeasons());
productIBO.setFirstShelveTime(p.getFirstShelveTime());
productIBO.setShelveTime(p.getShelveTime());
String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(p.getShelveTime()), "yyyy-MM-dd");
productIBO.setShelveDay(shelveDay);
if (p.getShelveTime() == 0) {
productIBO.setShelveDay("0");
}
productIBO.setEditTime(p.getEditTime());
productIBO.setStatus(p.getStatus());
productIBO.setFolderId(p.getFolderId());
productIBO.setSellChannels(p.getSellChannels());
productIBO.setAgeLevel(p.getAgeLevel());
productIBO.setAppType(p.getAppType());
productIBO.setCouponLimitStatus(p.getCouponLimitStatus());
productIBO.setIsFobbiden(p.getIsFobbiden());
productIBO.setStoreShowStatus(p.getStoreShowStatus());
productIBO.setIsLimitTimeAdvance(p.getIsLimitTimeAdvance());
productIBO.setSellType(p.getSellType());
// 品牌
this.buildBrand(brandMap, csBrandKeywordMap, p, productIBO);
// 品类
this.buildSort(productSortMap, p, productIBO);
// 店铺
this.buildShop(shopMap, p, productIBO);
// 增加一些特殊处理的逻辑
specialDealLogicService.specialDealForProductIBO(productIBO);
productIBOList.add(productIBO);
} catch (Exception e) {
logger.error("[fun=buildProductIBO][" + p.getId() + "]" + e.getMessage(), e);
}
}
return productIBOList;
}
private void buildBrand(Map<Integer, Brand> brandMap, Map<Integer, CsBrandKeyword> csBrandKeywordMap, Product p, ProductIBO productIBO) {
Brand brand = brandMap.get(p.getBrandId());
CsBrandKeyword csBrandKeyword = csBrandKeywordMap.get(p.getBrandId());
if (brand != null) {
productIBO.setBrandNameCn(brand.getBrandNameCn());
productIBO.setBrandNameEn(brand.getBrandNameEn());
productIBO.setBrandKeyword(brand.getBrandKeyword());
productIBO.setBrandName(brand.getBrandName());
productIBO.setBrandDomain(brand.getBrandDomain());
productIBO.setBrandAlif(BrandNameUtils.genBrandAlif(brand.getBrandName(),brand.getBrandNameCn()));
productIBO.setCountryId(brand.getCountryId());
}
if (csBrandKeyword != null) {
productIBO.setCsBrandKeyword(csBrandKeyword.getKeyword());
}
}
private void buildBrand(Map<Integer, Brand> brandMap, Map<Integer, CsBrandKeyword> csBrandKeywordMap, Product p, ProductIBO productIBO) {
Brand brand = brandMap.get(p.getBrandId());
CsBrandKeyword csBrandKeyword = csBrandKeywordMap.get(p.getBrandId());
if (brand != null) {
productIBO.setBrandNameCn(brand.getBrandNameCn());
productIBO.setBrandNameEn(brand.getBrandNameEn());
productIBO.setBrandKeyword(brand.getBrandKeyword());
productIBO.setBrandName(brand.getBrandName());
productIBO.setBrandDomain(brand.getBrandDomain());
productIBO.setBrandAlif(BrandNameUtils.genBrandAlif(brand.getBrandName(), brand.getBrandNameCn()));
productIBO.setCountryId(brand.getCountryId());
}
if (csBrandKeyword != null) {
productIBO.setCsBrandKeyword(csBrandKeyword.getKeyword());
}
}
private void buildSort(Map<Integer, ProductSort> ProductSortMap, Product p, ProductIBO productIBO) {
ProductSort productSortMax = ProductSortMap.get(p.getMaxSortId());
if (productSortMax != null) {
productIBO.setMaxSort(productSortMax.getSortName());
productIBO.setMaxSortName(p.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy());
} else {
productIBO.setMaxSort("");
productIBO.setMaxSortName("");
}
ProductSort productSortMiddle = ProductSortMap.get(p.getMiddleSortId());
if (productSortMiddle != null) {
productIBO.setMiddleSort(productSortMiddle.getSortName());
productIBO.setMiddleSortName(p.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy());
} else {
productIBO.setMiddleSort("");
productIBO.setMiddleSortName("");
}
ProductSort productSortSmall = ProductSortMap.get(p.getSmallSortId());
if (productSortSmall != null) {
productIBO.setSmallSort(productSortSmall.getSortName());
productIBO.setSmallSortName(p.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());
} else {
productIBO.setSmallSort("");
productIBO.setSmallSortName("");
}
}
private void buildSort(Map<Integer, ProductSort> ProductSortMap, Product p, ProductIBO productIBO) {
ProductSort productSortMax = ProductSortMap.get(p.getMaxSortId());
if (productSortMax != null) {
productIBO.setMaxSort(productSortMax.getSortName());
productIBO.setMaxSortName(p.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy());
} else {
productIBO.setMaxSort("");
productIBO.setMaxSortName("");
}
ProductSort productSortMiddle = ProductSortMap.get(p.getMiddleSortId());
if (productSortMiddle != null) {
productIBO.setMiddleSort(productSortMiddle.getSortName());
productIBO.setMiddleSortName(p.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy());
} else {
productIBO.setMiddleSort("");
productIBO.setMiddleSortName("");
}
ProductSort productSortSmall = ProductSortMap.get(p.getSmallSortId());
if (productSortSmall != null) {
productIBO.setSmallSort(productSortSmall.getSortName());
productIBO.setSmallSortName(p.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());
} else {
productIBO.setSmallSort("");
productIBO.setSmallSortName("");
}
}
private void buildShop(Map<Integer, Shops> shopMap, Product p, ProductIBO productIBO) {
Shops shops = shopMap.get(p.getShopId());
if (shops != null) {
productIBO.setShopName(shops.getShopName());
productIBO.setShopDomain(shops.getShopDomain());
productIBO.setShopCreateTime(shops.getCreateTime());
}
}
private void buildShop(Map<Integer, Shops> shopMap, Product p, ProductIBO productIBO) {
Shops shops = shopMap.get(p.getShopId());
if (shops != null) {
productIBO.setShopName(shops.getShopName());
productIBO.setShopDomain(shops.getShopDomain());
productIBO.setShopCreateTime(shops.getCreateTime());
}
}
}
... ...