diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoods/service/WarehouseGoodsService.java b/src/main/java/cn/lihongjie/coal/warehouseGoods/service/WarehouseGoodsService.java index aee8fab6..c9622689 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseGoods/service/WarehouseGoodsService.java +++ b/src/main/java/cn/lihongjie/coal/warehouseGoods/service/WarehouseGoodsService.java @@ -79,10 +79,17 @@ public class WarehouseGoodsService public Integer goodsCount(GoodsCountRequest request) { - return commonMapper.toInt((em.createQuery( - "select sum(case when receiptType = '0' then number when receiptType = '1' then number * -1 end ) from WarehouseReceiptDetailEntity where warehouse.id = :warehouseId and goods.id = :goodsIds") - .setParameter("warehouseId", request.getWarehouseId()) - .setParameter("goodsIds", request.getGoodsId()) - .getSingleResult() + "")); + Double result = + em.createQuery( + "select sum(case when receiptType = '0' then number when receiptType = '1' then number * -1 end ) from WarehouseReceiptDetailEntity where warehouse.id = :warehouseId and goods.id = :goodsIds", + Double.class) + .setParameter("warehouseId", request.getWarehouseId()) + .setParameter("goodsIds", request.getGoodsId()) + .getSingleResult(); + if (request == null){ + return 0; + } + return result.intValue(); } + } diff --git a/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/CreateWarehouseReceiptDetailDto.java b/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/CreateWarehouseReceiptDetailDto.java index 3f5ee079..0d770470 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/CreateWarehouseReceiptDetailDto.java +++ b/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/CreateWarehouseReceiptDetailDto.java @@ -6,6 +6,8 @@ import lombok.Data; import org.hibernate.annotations.Comment; +import java.time.LocalDateTime; + @Data public class CreateWarehouseReceiptDetailDto extends OrgCommonDto { @@ -23,6 +25,8 @@ public class CreateWarehouseReceiptDetailDto extends OrgCommonDto { private String receipt; + private String supplier; + @Comment("数量") private Double number; @@ -34,4 +38,14 @@ public class CreateWarehouseReceiptDetailDto extends OrgCommonDto { @Comment("总价") private Double amount; + @Comment("保质期 天") + private Integer shelfLife; + + + @Comment("生产日期") + private LocalDateTime productionDate; + + @Comment("过期日期") + private LocalDateTime expirationDate; + } diff --git a/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/UpdateWarehouseReceiptDetailDto.java b/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/UpdateWarehouseReceiptDetailDto.java index 373279a9..d3d1b868 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/UpdateWarehouseReceiptDetailDto.java +++ b/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/UpdateWarehouseReceiptDetailDto.java @@ -6,6 +6,8 @@ import lombok.Data; import org.hibernate.annotations.Comment; +import java.time.LocalDateTime; + @Data public class UpdateWarehouseReceiptDetailDto extends OrgCommonDto { @@ -25,6 +27,8 @@ public class UpdateWarehouseReceiptDetailDto extends OrgCommonDto { private String receipt; + private String supplier; + @Comment("数量") private Double number; @@ -34,4 +38,14 @@ public class UpdateWarehouseReceiptDetailDto extends OrgCommonDto { @Comment("总价") private Double amount; + + @Comment("保质期 天") + private Integer shelfLife; + + + @Comment("生产日期") + private LocalDateTime productionDate; + + @Comment("过期日期") + private LocalDateTime expirationDate; } diff --git a/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/WarehouseReceiptDetailDto.java b/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/WarehouseReceiptDetailDto.java index 02e17b31..bc311aef 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/WarehouseReceiptDetailDto.java +++ b/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/dto/WarehouseReceiptDetailDto.java @@ -5,6 +5,7 @@ import cn.lihongjie.coal.base.dto.SimpleDto; import cn.lihongjie.coal.warehouse.dto.WarehouseDto; import cn.lihongjie.coal.warehouseGoods.dto.WarehouseGoodsDto; import cn.lihongjie.coal.warehouseShelve.dto.WarehouseShelveDto; +import cn.lihongjie.coal.warehouseSupplier.dto.WarehouseSupplierDto; import jakarta.persistence.ManyToOne; @@ -12,6 +13,8 @@ import lombok.Data; import org.hibernate.annotations.Comment; +import java.time.LocalDateTime; + @Data public class WarehouseReceiptDetailDto extends OrgCommonDto { @@ -30,7 +33,7 @@ public class WarehouseReceiptDetailDto extends OrgCommonDto { @ManyToOne private WarehouseShelveDto shelve1; - + private WarehouseSupplierDto supplier; @ManyToOne private SimpleDto receipt; @@ -44,4 +47,14 @@ public class WarehouseReceiptDetailDto extends OrgCommonDto { private Double amount; + + @Comment("保质期 天") + private Integer shelfLife; + + + @Comment("生产日期") + private LocalDateTime productionDate; + + @Comment("过期日期") + private LocalDateTime expirationDate; } diff --git a/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/entity/WarehouseReceiptDetailEntity.java b/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/entity/WarehouseReceiptDetailEntity.java index 53d18fe7..7176e6b9 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/entity/WarehouseReceiptDetailEntity.java +++ b/src/main/java/cn/lihongjie/coal/warehouseReceiptDetail/entity/WarehouseReceiptDetailEntity.java @@ -5,22 +5,31 @@ import cn.lihongjie.coal.warehouse.entity.WarehouseEntity; import cn.lihongjie.coal.warehouseGoods.entity.WarehouseGoodsEntity; import cn.lihongjie.coal.warehouseReceipt.entity.WarehouseReceiptEntity; import cn.lihongjie.coal.warehouseShelve.entity.WarehouseShelveEntity; +import cn.lihongjie.coal.warehouseSupplier.entity.WarehouseSupplierEntity; import jakarta.persistence.Entity; +import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; import lombok.Data; import org.hibernate.annotations.Comment; +import java.time.LocalDateTime; + @Data @Entity +@jakarta.persistence.Table( + indexes = { + @jakarta.persistence.Index( + name = "idx_warehouse_receipt_detail_org_id", + columnList = "organization_id"), -@jakarta.persistence.Table(indexes = @jakarta.persistence.Index(name ="idx_warehouse_receipt_detail_org_id", columnList = "organization_id")) + @Index(name = "idx_warehouse_receipt_detail_goods_id", columnList = "goods_id, receipt_id, warehouse_id"), + }) public class WarehouseReceiptDetailEntity extends OrgCommonEntity { - @ManyToOne private WarehouseGoodsEntity goods; @@ -43,6 +52,8 @@ public class WarehouseReceiptDetailEntity extends OrgCommonEntity { @ManyToOne private WarehouseReceiptEntity receipt; + @ManyToOne private WarehouseSupplierEntity supplier; + @Comment("现有库存") private Double stock; @@ -62,4 +73,17 @@ public class WarehouseReceiptDetailEntity extends OrgCommonEntity { + + + @Comment("保质期 天") + private Integer shelfLife; + + + @Comment("生产日期") + private LocalDateTime productionDate; + + @Comment("过期日期") + private LocalDateTime expirationDate; + + } \ No newline at end of file