Authored by wangnan

fix

... ... @@ -34,30 +34,36 @@ public class StorageUpdateTimeLogicService {
@Autowired
private ProductService productService;
public List<StorageUpdateTime> getData(List<Integer> productIds,List<Integer> productSkns) {
if (CollectionUtils.isEmpty(productIds)||CollectionUtils.isEmpty(productSkns)) {
public List<StorageUpdateTime> getData(List<Integer> productIds, List<Integer> productSkns) {
if (CollectionUtils.isEmpty(productIds) || CollectionUtils.isEmpty(productSkns)) {
return new ArrayList<StorageUpdateTime>();
}
//查询Product对应的StorageUpdateTime
List<StorageUpdateTime> storageUpdateTimes = storageService.getStorageUpdateTime(productIds);
if (CollectionUtils.isEmpty(storageUpdateTimes)) {
logger.warn("[class=StorageUpdateTimeLogicService][fun=getData][message={}]","storageUpdateTimes is empty");
logger.warn("[class=StorageUpdateTimeLogicService][fun=getData][message={}]", "storageUpdateTimes is empty");
return new ArrayList<StorageUpdateTime>();
}
List<ProductTiming> productTimings = productTimingService.selectBySkns(productSkns);
Map<Integer,Integer> outSaleTimeMap = new HashMap<>();
if(!CollectionUtils.isEmpty(storageUpdateTimes)){
Map<Integer, Integer> outSaleTimeMap = new HashMap<>();
if (!CollectionUtils.isEmpty(productTimings)) {
outSaleTimeMap = productTimings.stream().parallel().collect(Collectors.toMap(ProductTiming::getProductSkn, ProductTiming::getOutSaleTime));
}
List<Product> products =productService.selectListByIds(productIds);
Map<Integer,Integer> sknMap = products.stream().parallel().collect(Collectors.toMap(Product::getId, Product::getErpProductId));
Map<Integer, Integer> sknMap = new HashMap<>();
List<Product> products = productService.selectListByIds(productIds);
if (!CollectionUtils.isEmpty(products)) {
sknMap = products.stream().parallel().collect(Collectors.toMap(Product::getId, Product::getErpProductId));
}
for (StorageUpdateTime storageUpdateTime : storageUpdateTimes) {
Integer outSaleTime = outSaleTimeMap.get(sknMap.get(storageUpdateTime.getProductId()));
//当前的updateTime+过期天数,再取到那天的23:59
Integer updateTime = storageUpdateTime.getStorageUpdateTime();
if(updateTime==null){
if (updateTime == null) {
updateTime = new Integer(0);
}
if (outSaleTime == null) {
outSaleTime = new Integer(0);
}
updateTime = DateUtil.getLastTimeSecond(DateUtil.addTimeSecondByDayAmount(updateTime, outSaleTime));
storageUpdateTime.setStorageUpdateTime(updateTime);
}
... ...