Browse Source

update

master
CANCERYS\kw093 7 hours ago
parent
commit
e77862246f
2 changed files with 29 additions and 7 deletions
  1. +4
    -4
      src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLine.kt
  2. +25
    -3
      src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt

+ 4
- 4
src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLine.kt View File

@@ -16,18 +16,18 @@ import jakarta.validation.constraints.NotNull
import org.hibernate.annotations.JdbcTypeCode import org.hibernate.annotations.JdbcTypeCode
import org.hibernate.type.SqlTypes import org.hibernate.type.SqlTypes
import java.math.BigDecimal import java.math.BigDecimal
import jakarta.persistence.FetchType
@Entity @Entity
@Table(name = "inventory_lot_line") @Table(name = "inventory_lot_line")
open class InventoryLotLine : BaseEntity<Long>() { open class InventoryLotLine : BaseEntity<Long>() {
// @JsonBackReference // @JsonBackReference
@NotNull @NotNull
@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "inventoryLotId") @JoinColumn(name = "inventoryLotId")
open var inventoryLot: InventoryLot? = null open var inventoryLot: InventoryLot? = null


@NotNull @NotNull
@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "warehouseId") @JoinColumn(name = "warehouseId")
open var warehouse: Warehouse? = null open var warehouse: Warehouse? = null


@@ -38,7 +38,7 @@ open class InventoryLotLine : BaseEntity<Long>() {
open var outQty: BigDecimal? = null open var outQty: BigDecimal? = null


@NotNull @NotNull
@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "stockItemUomId") @JoinColumn(name = "stockItemUomId")
open var stockUom: ItemUom? = null open var stockUom: ItemUom? = null




+ 25
- 3
src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotLineRepository.kt View File

@@ -13,6 +13,7 @@ import java.io.Serializable
import com.ffii.fpsms.modules.stock.entity.enum.InventoryLotLineStatus import com.ffii.fpsms.modules.stock.entity.enum.InventoryLotLineStatus
import org.springframework.data.repository.query.Param import org.springframework.data.repository.query.Param
import java.time.LocalDate import java.time.LocalDate
import org.springframework.data.jpa.repository.EntityGraph
@Repository @Repository
interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long> { interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long> {


@@ -69,11 +70,31 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long
itemId: Long itemId: Long
): InventoryLotLine? ): InventoryLotLine?


// InventoryLotLineRepository.kt 中添加
@EntityGraph(
type = EntityGraph.EntityGraphType.FETCH,
attributePaths = [
"inventoryLot",
"inventoryLot.item", // important: two levels deep
"warehouse",
"stockUom",
"stockUom.uom" // if uom is a relation inside ItemUom
]
)
@Query("SELECT ill FROM InventoryLotLine ill WHERE ill.warehouse.id IN :warehouseIds AND ill.deleted = false") @Query("SELECT ill FROM InventoryLotLine ill WHERE ill.warehouse.id IN :warehouseIds AND ill.deleted = false")
fun findAllByWarehouseIdInAndDeletedIsFalse(@Param("warehouseIds") warehouseIds: List<Long>): List<InventoryLotLine> fun findAllByWarehouseIdInAndDeletedIsFalse(@Param("warehouseIds") warehouseIds: List<Long>): List<InventoryLotLine>

@Query("SELECT ill FROM InventoryLotLine ill WHERE ill.warehouse.id IN :warehouseIds AND ill.deleted = false AND ill.status = 'available'")
// You can also add another one for the status filter if needed
@EntityGraph(
type = EntityGraph.EntityGraphType.FETCH,
attributePaths = ["inventoryLot", "inventoryLot.item", "warehouse", "stockUom", "stockUom.uom"]
)
@Query("""
SELECT ill
FROM InventoryLotLine ill
WHERE ill.warehouse.id IN :warehouseIds
AND ill.deleted = false
AND ill.status = 'available'
""")
fun findAllByWarehouseIdInAndDeletedIsFalseAndStatusIsAvailable(@Param("warehouseIds") warehouseIds: List<Long>): List<InventoryLotLine> fun findAllByWarehouseIdInAndDeletedIsFalseAndStatusIsAvailable(@Param("warehouseIds") warehouseIds: List<Long>): List<InventoryLotLine>


@Query(""" @Query("""
@@ -95,6 +116,7 @@ interface InventoryLotLineRepository : AbstractRepository<InventoryLotLine, Long
""") """)
fun findAllByWarehouseCodeAndDeletedIsFalse(@Param("warehouseCode") warehouseCode: String): List<InventoryLotLine> fun findAllByWarehouseCodeAndDeletedIsFalse(@Param("warehouseCode") warehouseCode: String): List<InventoryLotLine>



@Query(""" @Query("""
SELECT COUNT(DISTINCT ill.inventoryLot.item.id) SELECT COUNT(DISTINCT ill.inventoryLot.item.id)
FROM InventoryLotLine ill FROM InventoryLotLine ill


Loading…
Cancel
Save