diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java index 22abbf5d0..705cf7498 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java @@ -124,6 +124,7 @@ import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -3138,20 +3139,40 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl wrapper = Wrappers.lambdaQuery() .eq(BasicdataPriceEntity::getClientId, clientId) - .eq(BasicdataPriceEntity::getBrandId, brandId); + .eq(BasicdataPriceEntity::getBrandId, brandId) + .in(BasicdataPriceEntity::getEffectiveStatus, 0, 1) + ; + List priceEntities = this.list(wrapper); if (StrUtil.isNotEmpty(param.getTime())) { - wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd")) - .le(BasicdataPriceEntity::getEffectiveTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd")) + String time = param.getTime(); + DateTime dateTime = DateUtil.beginOfDay(DateUtil.parseDate(time)); + if(CollUtil.isNotEmpty(priceEntities)){ + List sortedPriceEntities = priceEntities.stream() + .filter(item -> item.getEffectiveTime().compareTo(dateTime) <= 0) + .sorted(Comparator.comparing(BasicdataPriceEntity::getEffectiveTime).reversed()) + .collect(Collectors.toList()); + if(CollUtil.isNotEmpty(sortedPriceEntities)){ + return sortedPriceEntities.get(0); + } + } + // wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd")) + // .le(BasicdataPriceEntity::getEffectiveTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd")) ; } else { - wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.beginOfDay(new Date())) - .le(BasicdataPriceEntity::getEffectiveTime, DateUtil.beginOfDay(new Date())) + if(CollUtil.isNotEmpty(priceEntities)){ + List collect = priceEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getEffectiveStatus())) + .filter(item -> item.getEffectiveStatus() == 0).collect(Collectors.toList()); + if(CollUtil.isNotEmpty(collect)){ + return collect.get(0); + } + } + // wrapper.eq(BasicdataPriceEntity::getEffectiveStatus, 0) ; } - List priceEntities = this.list(wrapper); - if (CollUtil.isNotEmpty(priceEntities)) { - priceEntity = priceEntities.get(0); - } + // if (CollUtil.isNotEmpty(priceEntities)) { + // priceEntity = priceEntities.get(0); + // } return priceEntity; }