diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/service/WarehouseGoodsSummaryService.java b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/service/WarehouseGoodsSummaryService.java index 3d2e0ab6..1a94176a 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/service/WarehouseGoodsSummaryService.java +++ b/src/main/java/cn/lihongjie/coal/warehouseGoodsSummary/service/WarehouseGoodsSummaryService.java @@ -40,6 +40,7 @@ import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; @Service @Slf4j @@ -93,6 +94,9 @@ public class WarehouseGoodsSummaryService public Page list(CommonQuery query) { + + log.info("query: {}", query.toString()); + CommonQuery copy = new CommonQuery(); BeanUtil.copyProperties(query, copy); @@ -135,7 +139,9 @@ public class WarehouseGoodsSummaryService copy.getItems().add(new CommonQuery.QueryItem().withKey("startTime").withValue(LocalDateTimeUtil.format(startTime, "yyyy-MM-dd HH:mm:ss"))); copy.getItems().add(new CommonQuery.QueryItem().withKey("endTime").withValue(LocalDateTimeUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"))); + copy.getItems().add(new CommonQuery.QueryItem().withKey("id").withOpt("in").withValue(dtos.getContent().stream().map(WarehouseGoodsSummaryDto::getId).collect(Collectors.joining(",")))); + em.clear(); Page prevSummary = list(copy); List> join = cn.lihongjie.coal.common.CollectionUtils.leftHashJoin( @@ -147,10 +153,10 @@ public class WarehouseGoodsSummaryService for (Tuple2 tuple2 : join) { WarehouseGoodsSummaryDto dto = tuple2._1; - WarehouseGoodsSummaryDto entity = tuple2._2; + WarehouseGoodsSummaryDto prev = tuple2._2; - dto.setPrevAmount(ObjectUtils.defaultIfNull(entity.getType0Amount(), 0.0) - ObjectUtils.defaultIfNull(entity.getType1Amount(), 0.0)); - dto.setPrevNumber(ObjectUtils.defaultIfNull(entity.getType0Number(), 0.0) - ObjectUtils.defaultIfNull(entity.getType1Number(), 0.0)); + dto.setPrevAmount(ObjectUtils.defaultIfNull(prev.getType0Amount(), 0.0) - ObjectUtils.defaultIfNull(prev.getType1Amount(), 0.0)); + dto.setPrevNumber(ObjectUtils.defaultIfNull(prev.getType0Number(), 0.0) - ObjectUtils.defaultIfNull(prev.getType1Number(), 0.0)); }