Authored by wangnan

storagesku整理

package com.yoho.search.index.fullbuild;
import com.yoho.search.base.utils.ISearchConstans;
import com.yoho.search.service.logic.SpecialDealLogicService;
import com.yoho.search.dal.StorageMapper;
import com.yoho.search.dal.model.StorageSku;
import com.yoho.search.service.base.Product15DaySalesNumService;
import com.yoho.search.service.base.StorageSkuService;
import com.yoho.search.service.logic.SpecialDealLogicService;
import com.yoho.search.service.logic.StorageSkuLogicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -27,21 +26,13 @@ public class StorageSkuIndexBuilder extends IIndexBuilder {
@Override
public int getTotalCount() throws Exception {
if (ISearchConstans.BUILD_STORAGESKUINDEX_USE_CODE) {
return storageMapper.count();
} else {
return storageSkuService.count();
}
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
List<StorageSku> pageLists = new ArrayList<StorageSku>();
if (ISearchConstans.BUILD_STORAGESKUINDEX_USE_CODE) {
pageLists = storageSkuLogicService.getStorageSkuIndex(offset, limit);
} else {
pageLists = storageSkuService.selectList(offset, limit);
}
for (StorageSku storageSku : pageLists) {
SpecialDealLogicService.specialDealStorageSku(storageSku);
}
... ...
... ... @@ -96,33 +96,21 @@ public class StorageSkuIndexToolsService implements ApplicationEventPublisherAwa
// 1、根据sku去取数据库对象
List<Integer> productSkus = this.getElementsFromArrayBlockingQueue(productSkuQueue, 200);
if (!productSkus.isEmpty()) {
if (ISearchConstans.BUILD_STORAGESKUINDEX_USE_CODE) {
storageSkuList.addAll(storageSkuLogicService.getStorageSkuIndexBySkus(productSkus));
} else {
storageSkuList.addAll(storageSkuService.selectListProductSkus(productSkus));
}
storageSkuList.addAll(storageSkuLogicService.getStorageSkuIndexBySkus(productSkus));
logger.info("doBulkUpdateStorageSkuIndex[getListBySku], storageSkuList size is [{}], cost [{}]ms", storageSkuList.size(), costStatistics.getCost());
}
// 2、根据skc去取数据库对象
List<Integer> goodsIds = this.getElementsFromArrayBlockingQueue(goodsIdQueue, 200);
if (!goodsIds.isEmpty()) {
if (ISearchConstans.BUILD_STORAGESKUINDEX_USE_CODE) {
storageSkuList.addAll(storageSkuLogicService.getStorageSkuIndexBySkcs(goodsIds));
} else {
storageSkuList.addAll(storageSkuService.selectListByGoodsIds(goodsIds));
}
storageSkuList.addAll(storageSkuLogicService.getStorageSkuIndexBySkcs(goodsIds));
logger.info("doBulkUpdateStorageSkuIndex[getListBySkc], storageSkuList size is [{}], cost [{}]ms", storageSkuList.size(), costStatistics.getCost());
}
// 3、根据skn去取数据库对象
List<Integer> productIds = this.getElementsFromArrayBlockingQueue(productIdQueue, 200);
if (!productIds.isEmpty()) {
if (ISearchConstans.BUILD_STORAGESKUINDEX_USE_CODE) {
storageSkuList.addAll(storageSkuLogicService.getStorageSkuIndexBySkns(productIds));
} else {
storageSkuList.addAll(storageSkuService.selectListByProductIds(productIds));
}
logger.info("doBulkUpdateStorageSkuIndex[getListBySkn], storageSkuList size is [{}], cost [{}]ms", storageSkuList.size(), costStatistics.getCost());
}
... ...
package com.yoho.search.service.base;
import java.util.ArrayList;
import java.util.List;
import com.yoho.search.dal.StorageSkuMapper;
import com.yoho.search.dal.model.StorageSku;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class StorageSkuService {
@Autowired
private StorageSkuMapper storageSkuMapper;
public int count() {
return storageSkuMapper.selectCount();
}
public List<StorageSku> selectList(int offset, int limit) {
return storageSkuMapper.selectList(offset, limit);
}
public StorageSku getById(Integer erpSkuId) {
return storageSkuMapper.selectByPrimaryKey(erpSkuId);
}
public List<StorageSku> selectListProductSkus(List<Integer> productSkus) {
if (productSkus == null || productSkus.isEmpty()) {
return new ArrayList<StorageSku>();
}
return storageSkuMapper.selectListProductSkus(productSkus);
}
public List<StorageSku> selectListByProductId(Integer productId) {
return storageSkuMapper.selectListByProductId(productId);
}
public List<StorageSku> selectListByProductIds(List<Integer> productIds) {
if (productIds == null || productIds.isEmpty()) {
return new ArrayList<StorageSku>();
}
return storageSkuMapper.selectListByProductIds(productIds);
}
public List<StorageSku> selectListByGoodsId(Integer goodsId) {
return storageSkuMapper.selectListByGoodsId(goodsId);
}
public List<StorageSku> selectListByGoodsIds(List<Integer> goodsId) {
if (goodsId == null || goodsId.isEmpty()) {
return new ArrayList<StorageSku>();
}
return storageSkuMapper.selectListByGoodsIds(goodsId);
}
}
... ...