@@ -0,0 +1,57 @@ | |||||
package com.ffii.fpsms.modules.pickOrder.entity | |||||
import com.fasterxml.jackson.annotation.JsonManagedReference | |||||
import com.ffii.core.entity.BaseEntity | |||||
import com.ffii.fpsms.modules.deliveryOrder.entity.DeliveryOrder | |||||
import com.ffii.fpsms.modules.jobOrder.entity.JobOrder | |||||
import com.ffii.fpsms.modules.master.entity.BomMaterial | |||||
import com.ffii.fpsms.modules.user.entity.User | |||||
import jakarta.persistence.* | |||||
import jakarta.validation.constraints.NotNull | |||||
import jakarta.validation.constraints.Size | |||||
import org.hibernate.annotations.Formula | |||||
import java.time.LocalDateTime | |||||
@Entity | |||||
@Table(name = "pick_order") | |||||
open class PickOrder: BaseEntity<Long>() { | |||||
@Size(max = 255) | |||||
@NotNull | |||||
@Column(name = "code", nullable = false) | |||||
open var code: String? = null | |||||
@Size(max = 255) | |||||
@Column(name = "consoCode") | |||||
open var consoCode: String? = null | |||||
@ManyToOne | |||||
@JoinColumn(name = "joId") | |||||
open var jobOrder: JobOrder? = null | |||||
@ManyToOne | |||||
@JoinColumn(name = "doId") | |||||
open var deliveryOrder: DeliveryOrder? = null | |||||
@Column(name = "targetDate") | |||||
open var targetDate: LocalDateTime? = null | |||||
@Column(name = "completeDate") | |||||
open var completeDate: LocalDateTime? = null | |||||
@Size(max = 30) | |||||
@Column(name = "type", length = 30) | |||||
open var type: String? = null | |||||
@Size(max = 30) | |||||
@NotNull | |||||
@Column(name = "status", nullable = false, length = 30) | |||||
open var status: String? = null | |||||
@ManyToOne | |||||
@JoinColumn(name = "releasedBy", referencedColumnName = "id") | |||||
open var releasedBy: User? = null | |||||
@JsonManagedReference | |||||
@OneToMany(mappedBy = "pickOrder", cascade = [CascadeType.ALL], orphanRemoval = true) | |||||
open var pickOrderLines: MutableList<PickOrderLine> = mutableListOf() | |||||
} |
@@ -0,0 +1,38 @@ | |||||
package com.ffii.fpsms.modules.pickOrder.entity | |||||
import com.ffii.core.entity.BaseEntity | |||||
import com.ffii.fpsms.modules.master.entity.Items | |||||
import com.ffii.fpsms.modules.master.entity.UomConversion | |||||
import jakarta.persistence.* | |||||
import jakarta.validation.constraints.NotNull | |||||
import jakarta.validation.constraints.Size | |||||
import java.math.BigDecimal | |||||
@Entity | |||||
@Table(name = "pick_order_line") | |||||
open class PickOrderLine : BaseEntity<Long>() { | |||||
@NotNull | |||||
@ManyToOne | |||||
@JoinColumn(name = "poId", nullable = false) | |||||
open var pickOrder: PickOrder? = null | |||||
@NotNull | |||||
@ManyToOne | |||||
@JoinColumn(name = "itemId", nullable = false) | |||||
open var item: Items? = null | |||||
@NotNull | |||||
@Column(name = "qty", nullable = false, precision = 14, scale = 2) | |||||
open var qty: BigDecimal? = null | |||||
@NotNull | |||||
@ManyToOne | |||||
@JoinColumn(name = "uomId", nullable = false) | |||||
open var uom: UomConversion? = null | |||||
@Size(max = 30) | |||||
@NotNull | |||||
@Column(name = "status", nullable = false, length = 30) | |||||
open var status: String? = null | |||||
} |
@@ -0,0 +1,9 @@ | |||||
package com.ffii.fpsms.modules.pickOrder.entity | |||||
import com.ffii.core.support.AbstractRepository | |||||
import org.springframework.stereotype.Repository | |||||
@Repository | |||||
interface PickOrderLineRepository : AbstractRepository<PickOrderLine, Long> { | |||||
} |
@@ -0,0 +1,11 @@ | |||||
package com.ffii.fpsms.modules.pickOrder.entity | |||||
import com.ffii.core.support.AbstractRepository | |||||
import com.ffii.fpsms.modules.pickOrder.entity.projection.PickOrderInfo | |||||
import org.springframework.data.jpa.repository.Query | |||||
import org.springframework.stereotype.Repository | |||||
@Repository | |||||
interface PickOrderRepository: AbstractRepository<PickOrder, Long> { | |||||
fun findPickOrderInfoByDeletedIsFalse(): List<PickOrderInfo> | |||||
} |
@@ -0,0 +1,24 @@ | |||||
package com.ffii.fpsms.modules.pickOrder.entity.projection | |||||
import org.springframework.beans.factory.annotation.Value | |||||
import java.time.LocalDateTime | |||||
data class PickOrderItemInfo( | |||||
val name: String?, | |||||
val type: String?, | |||||
) | |||||
interface PickOrderInfo { | |||||
val id: Long? | |||||
val code: String? | |||||
val consoCode: String? | |||||
val targetDate: LocalDateTime? | |||||
val completeDate: LocalDateTime? | |||||
val type: String? | |||||
val status: String? | |||||
@get:Value("#{target.releasedBy.name}") | |||||
val releasedBy: String? | |||||
@get:Value("#{target.pickOrderLines?.size() > 0 ? target.pickOrderLines.![new com.ffii.fpsms.modules.pickOrder.entity.projection.PickOrderItemInfo(item.name, item.type)] : null}") | |||||
val items: List<PickOrderItemInfo?>? | |||||
} |
@@ -0,0 +1,19 @@ | |||||
package com.ffii.fpsms.modules.pickOrder.service | |||||
import com.ffii.fpsms.modules.pickOrder.entity.PickOrderRepository | |||||
import com.ffii.fpsms.modules.pickOrder.entity.projection.PickOrderInfo | |||||
import org.springframework.stereotype.Service | |||||
@Service | |||||
open class PickOrderService( | |||||
val pickOrderRepository: PickOrderRepository, | |||||
) { | |||||
open fun allPickOrders(): List<PickOrderInfo> { | |||||
return pickOrderRepository.findPickOrderInfoByDeletedIsFalse() | |||||
} | |||||
// Consolidating Pick Orders | |||||
open fun consoPickOrders() { | |||||
} | |||||
} |
@@ -0,0 +1,18 @@ | |||||
package com.ffii.fpsms.modules.pickOrder.web | |||||
import com.ffii.fpsms.modules.pickOrder.entity.projection.PickOrderInfo | |||||
import com.ffii.fpsms.modules.pickOrder.service.PickOrderService | |||||
import org.springframework.web.bind.annotation.GetMapping | |||||
import org.springframework.web.bind.annotation.RequestMapping | |||||
import org.springframework.web.bind.annotation.RestController | |||||
@RestController | |||||
@RequestMapping("/pickOrder") | |||||
class PickOrderController( | |||||
private val pickOrderService: PickOrderService, | |||||
) { | |||||
@GetMapping("/list") | |||||
fun allPickOrders(): List<PickOrderInfo> { | |||||
return pickOrderService.allPickOrders(); | |||||
} | |||||
} |
@@ -22,8 +22,9 @@ open class Inventory: BaseEntity<Long>(){ | |||||
@Column(name = "price") | @Column(name = "price") | ||||
open var price: BigDecimal? = null | open var price: BigDecimal? = null | ||||
@Column(name = "stockInLineId") | |||||
open var stockInLine: Long? = null // change this later | |||||
@ManyToOne | |||||
@JoinColumn(name = "itemId") | |||||
open var item: Items? = null | |||||
@ManyToOne | @ManyToOne | ||||
@JoinColumn(name = "currencyId") | @JoinColumn(name = "currencyId") | ||||
@@ -48,7 +49,7 @@ open class Inventory: BaseEntity<Long>(){ | |||||
@NotNull | @NotNull | ||||
@ManyToOne | @ManyToOne | ||||
@JoinColumn(name = "uomId") | @JoinColumn(name = "uomId") | ||||
open var uomId: UomConversion? = null | |||||
open var uom: UomConversion? = null | |||||
// @NotNull | // @NotNull | ||||
@Column(name = "status") | @Column(name = "status") | ||||
@@ -1,8 +1,10 @@ | |||||
package com.ffii.fpsms.modules.stock.entity | package com.ffii.fpsms.modules.stock.entity | ||||
import com.ffii.core.support.AbstractRepository | import com.ffii.core.support.AbstractRepository | ||||
import com.ffii.fpsms.modules.stock.entity.projection.InventoryInfo | |||||
import org.springframework.stereotype.Repository | import org.springframework.stereotype.Repository | ||||
@Repository | @Repository | ||||
interface InventoryRepository: AbstractRepository<Inventory, Long> { | interface InventoryRepository: AbstractRepository<Inventory, Long> { | ||||
fun findInventoryInfoByDeletedIsFalse(): List<InventoryInfo> | |||||
} | } |
@@ -0,0 +1,35 @@ | |||||
package com.ffii.fpsms.modules.stock.entity.projection | |||||
import org.springframework.beans.factory.annotation.Value | |||||
import java.math.BigDecimal | |||||
interface InventoryInfo{ | |||||
val id: Long? | |||||
@get:Value("#{target.item.code}") | |||||
val code: String? | |||||
@get:Value("#{target.item.name}") | |||||
val name: String? | |||||
@get:Value("#{target.item.type}") | |||||
val type: String? | |||||
val qty: BigDecimal? | |||||
@get:Value("#{target.uom.code}") | |||||
val uomCode: String? | |||||
@get:Value("#{target.uom.udfudesc}") | |||||
val uomUdfudesc: String? | |||||
@get:Value("#{target.qty * target.uom.gramPerSmallestUnit}") | |||||
val germPerSmallestUnit: BigDecimal? | |||||
@get:Value("#{target.qty * (target.uom.unit4 != '' ? target.uom.unit4Qty " + | |||||
": target.uom.unit3 != '' ? target.uom.unit3Qty " + | |||||
": target.uom.unit2 != '' ? target.uom.unit2Qty " + | |||||
": target.uom.unit1Qty)}") | |||||
val qtyPerSmallestUnit: BigDecimal? | |||||
@get:Value("#{target.uom.unit4 != '' ? target.uom.unit4 " + | |||||
": target.uom.unit3 != '' ? target.uom.unit3 " + | |||||
": target.uom.unit2 != '' ? target.uom.unit2 " + | |||||
": target.uom.unit1}") | |||||
val smallestUnit: String? | |||||
val price: BigDecimal? | |||||
@get:Value("#{target.currency?.name}") | |||||
val currencyName: String? | |||||
val status: String? | |||||
} |
@@ -8,6 +8,7 @@ import com.ffii.fpsms.modules.master.entity.ItemsRepository | |||||
import com.ffii.fpsms.modules.master.web.models.MessageResponse | import com.ffii.fpsms.modules.master.web.models.MessageResponse | ||||
import com.ffii.fpsms.modules.stock.entity.Inventory | import com.ffii.fpsms.modules.stock.entity.Inventory | ||||
import com.ffii.fpsms.modules.stock.entity.InventoryRepository | import com.ffii.fpsms.modules.stock.entity.InventoryRepository | ||||
import com.ffii.fpsms.modules.stock.entity.projection.InventoryInfo | |||||
import com.ffii.fpsms.modules.stock.web.model.SaveInventoryRequest | import com.ffii.fpsms.modules.stock.web.model.SaveInventoryRequest | ||||
import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
import java.io.IOException | import java.io.IOException | ||||
@@ -25,6 +26,11 @@ open class InventoryService( | |||||
val inventory = inventoryRepository.findAll() | val inventory = inventoryRepository.findAll() | ||||
return inventory | return inventory | ||||
} | } | ||||
open fun allInventories(): List<InventoryInfo>{ | |||||
return inventoryRepository.findInventoryInfoByDeletedIsFalse(); | |||||
} | |||||
// @Throws(IOException::class) | // @Throws(IOException::class) | ||||
// open fun updateInventory(request: SaveInventoryRequest): MessageResponse { | // open fun updateInventory(request: SaveInventoryRequest): MessageResponse { | ||||
// // out need id | // // out need id | ||||
@@ -0,0 +1,18 @@ | |||||
package com.ffii.fpsms.modules.stock.web | |||||
import com.ffii.fpsms.modules.stock.entity.projection.InventoryInfo | |||||
import com.ffii.fpsms.modules.stock.service.InventoryService | |||||
import org.springframework.web.bind.annotation.GetMapping | |||||
import org.springframework.web.bind.annotation.RequestMapping | |||||
import org.springframework.web.bind.annotation.RestController | |||||
@RestController | |||||
@RequestMapping("/inventory") | |||||
class InventoryController( | |||||
private val inventoryService: InventoryService, | |||||
) { | |||||
@GetMapping("/list") | |||||
fun allInventories(): List<InventoryInfo> { | |||||
return inventoryService.allInventories() | |||||
} | |||||
} |
@@ -0,0 +1,46 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset cyril:create pick order | |||||
CREATE TABLE `pick_order` | |||||
( | |||||
`id` INT NOT NULL AUTO_INCREMENT, | |||||
`created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`createdBy` VARCHAR(30) NULL DEFAULT NULL, | |||||
`version` INT NOT NULL DEFAULT '0', | |||||
`modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`modifiedBy` VARCHAR(30) NULL DEFAULT NULL, | |||||
`deleted` TINYINT(1) NOT NULL DEFAULT '0', | |||||
`code` VARCHAR(255) NOT NULL, | |||||
`consoCode` VARCHAR(255) NULL, | |||||
`joId` INT NULL, | |||||
`doId` INT NULL, | |||||
`targetDate` DATETIME NULL, | |||||
`completeDate` DATETIME NULL, | |||||
`type` VARCHAR(30) NULL, | |||||
`status` VARCHAR(30) NOT NULL DEFAULT 'pending', | |||||
`releasedBy` INT NULL, | |||||
CONSTRAINT pk_pick_order PRIMARY KEY (id), | |||||
CONSTRAINT `FK_PICK_ORDER_ON_JOID` FOREIGN KEY (`joId`) REFERENCES `job_order` (`id`), | |||||
CONSTRAINT `FK_PICK_ORDER_ON_DOID` FOREIGN KEY (`doId`) REFERENCES `delivery_order` (`id`), | |||||
CONSTRAINT `FK_PICK_ORDER_ON_RELEASEDBY` FOREIGN KEY (`releasedBy`) REFERENCES `user` (`id`) | |||||
); | |||||
CREATE TABLE `pick_order_line` | |||||
( | |||||
`id` INT NOT NULL AUTO_INCREMENT, | |||||
`created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`createdBy` VARCHAR(30) NULL DEFAULT NULL, | |||||
`version` INT NOT NULL DEFAULT '0', | |||||
`modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`modifiedBy` VARCHAR(30) NULL DEFAULT NULL, | |||||
`deleted` TINYINT(1) NOT NULL DEFAULT '0', | |||||
`poId` INT NOT NULL, | |||||
`itemId` INT NOT NULL, | |||||
`qty` DECIMAL(14, 2) NOT NULL DEFAULT 0, | |||||
`uomId` INT NOT NULL, | |||||
`status` VARCHAR(30) NOT NULL DEFAULT 'pending', | |||||
CONSTRAINT pk_pick_order_line PRIMARY KEY (id), | |||||
CONSTRAINT `FK_PICK_ORDER_LINE_ON_POID` FOREIGN KEY (`poId`) REFERENCES `pick_order` (`id`), | |||||
CONSTRAINT `FK_PICK_ORDER_LINE_ON_ITEMID` FOREIGN KEY (`itemId`) REFERENCES `items` (`id`), | |||||
CONSTRAINT `FK_PICK_ORDER_LINE_ON_UOMID` FOREIGN KEY (`uomId`) REFERENCES `uom_conversion` (`id`) | |||||
); |