Browse Source

Merge branch 'dev' into pre-production

pre-production
zhaoqiaobo 1 month ago
parent
commit
381e46efc9
  1. 39
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java

39
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.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -3138,20 +3139,40 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
BasicdataPriceEntity priceEntity = null; BasicdataPriceEntity priceEntity = null;
LambdaQueryWrapper<BasicdataPriceEntity> wrapper = Wrappers.<BasicdataPriceEntity>lambdaQuery() LambdaQueryWrapper<BasicdataPriceEntity> wrapper = Wrappers.<BasicdataPriceEntity>lambdaQuery()
.eq(BasicdataPriceEntity::getClientId, clientId) .eq(BasicdataPriceEntity::getClientId, clientId)
.eq(BasicdataPriceEntity::getBrandId, brandId); .eq(BasicdataPriceEntity::getBrandId, brandId)
.in(BasicdataPriceEntity::getEffectiveStatus, 0, 1)
;
List<BasicdataPriceEntity> priceEntities = this.list(wrapper);
if (StrUtil.isNotEmpty(param.getTime())) { if (StrUtil.isNotEmpty(param.getTime())) {
wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd")) String time = param.getTime();
.le(BasicdataPriceEntity::getEffectiveTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd")) DateTime dateTime = DateUtil.beginOfDay(DateUtil.parseDate(time));
if(CollUtil.isNotEmpty(priceEntities)){
List<BasicdataPriceEntity> 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 { } else {
wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.beginOfDay(new Date())) if(CollUtil.isNotEmpty(priceEntities)){
.le(BasicdataPriceEntity::getEffectiveTime, DateUtil.beginOfDay(new Date())) List<BasicdataPriceEntity> 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<BasicdataPriceEntity> priceEntities = this.list(wrapper); // if (CollUtil.isNotEmpty(priceEntities)) {
if (CollUtil.isNotEmpty(priceEntities)) { // priceEntity = priceEntities.get(0);
priceEntity = priceEntities.get(0); // }
}
return priceEntity; return priceEntity;
} }

Loading…
Cancel
Save