| @@ -10,6 +10,11 @@ import jakarta.validation.constraints.Size | |||||
| @Table(name = "equipment_detail") | @Table(name = "equipment_detail") | ||||
| @Entity | @Entity | ||||
| open class EquipmentDetail : BaseEntity<Long>() { | open class EquipmentDetail : BaseEntity<Long>() { | ||||
| @Size(max = 255) | |||||
| @Column(name = "equipmentCode", nullable = true, length = 255) | |||||
| open var equipmentCode: String? = null | |||||
| @Size(max = 30) | @Size(max = 30) | ||||
| @NotNull | @NotNull | ||||
| @Column(name = "code", nullable = false, length = 30) | @Column(name = "code", nullable = false, length = 30) | ||||
| @@ -25,7 +30,6 @@ open class EquipmentDetail : BaseEntity<Long>() { | |||||
| @Column(name = "description", nullable = false, length = 500) | @Column(name = "description", nullable = false, length = 500) | ||||
| open var description: String? = null | open var description: String? = null | ||||
| @Column(name = "equipmentTypeID") | @Column(name = "equipmentTypeID") | ||||
| open var equipmentTypeId: Long? = null | open var equipmentTypeId: Long? = null | ||||
| @@ -34,15 +34,9 @@ open class Items : BaseEntity<Long>() { | |||||
| @Column(name = "countryOfOrigin") | @Column(name = "countryOfOrigin") | ||||
| open var countryOfOrigin: String? = null | open var countryOfOrigin: String? = null | ||||
| @Column(name = "inventorySheet") | |||||
| open var inventorySheet: String? = null | |||||
| @Column(name = "store_id", nullable = true, length = 255) | @Column(name = "store_id", nullable = true, length = 255) | ||||
| open var store_id: String? = null | open var store_id: String? = null | ||||
| @Column(name = "storeLocation", nullable = true, length = 255) | |||||
| open var storeLocation: String? = null | |||||
| @Column(name = "warehouse", nullable = true, length = 255) | @Column(name = "warehouse", nullable = true, length = 255) | ||||
| open var warehouse: String? = null | open var warehouse: String? = null | ||||
| @@ -52,14 +46,17 @@ open class Items : BaseEntity<Long>() { | |||||
| @Column(name = "slot", nullable = true, length = 255) | @Column(name = "slot", nullable = true, length = 255) | ||||
| open var slot: String? = null | open var slot: String? = null | ||||
| @Column(name = "MTMSPickRoutingID", nullable = true) | |||||
| open var MTMSPickRoutingID: Int? = null | |||||
| @Column(name = "LocationCode", nullable = true, length = 255) | @Column(name = "LocationCode", nullable = true, length = 255) | ||||
| open var LocationCode: String? = null | open var LocationCode: String? = null | ||||
| @Column(name = "company", nullable = true, length = 30) | |||||
| open var company: String? = null | |||||
| @Column(name = "isEgg", nullable = true) | |||||
| open var isEgg: Boolean? = false | |||||
| @Column(name = "isFee", nullable = true) | |||||
| open var isFee: Boolean? = false | |||||
| @Column(name = "isBag", nullable = true) | |||||
| open var isBag: Boolean? = false | |||||
| @Column(name = "maxQty") | @Column(name = "maxQty") | ||||
| open var maxQty: Double? = null | open var maxQty: Double? = null | ||||
| @@ -90,4 +87,5 @@ open class Items : BaseEntity<Long>() { | |||||
| @JsonManagedReference | @JsonManagedReference | ||||
| @JoinColumn(name = "qcCategoryId") | @JoinColumn(name = "qcCategoryId") | ||||
| open var qcCategory: QcCategory? = null | open var qcCategory: QcCategory? = null | ||||
| } | } | ||||
| @@ -18,6 +18,10 @@ open class Printer : BaseEntity<Long>() { | |||||
| @Column(name = "name", length = 500) | @Column(name = "name", length = 500) | ||||
| open var name: String? = null | open var name: String? = null | ||||
| @Size(max = 255) | |||||
| @Column(name = "type", nullable = true, length = 255) | |||||
| open var type: String? = null | |||||
| @Size(max = 500) | @Size(max = 500) | ||||
| @Column(name = "description", length = 500) | @Column(name = "description", length = 500) | ||||
| open var description: String? = null | open var description: String? = null | ||||
| @@ -32,16 +32,16 @@ open class Warehouse : BaseEntity<Long>() { | |||||
| @Column(name = "store_id", nullable = false, length = 30) | @Column(name = "store_id", nullable = false, length = 30) | ||||
| open var store_id: String? = null | open var store_id: String? = null | ||||
| @Column(name = "storeLocation", nullable = true, length = 30) | |||||
| open var storeLocation: String? = null | |||||
| @Column(name = "stockTakeTable", nullable = true, length = 30) | |||||
| open var stockTakeTable: String? = null | |||||
| @Column(name = "company", nullable = true, length = 30) | |||||
| open var company: String? = null | |||||
| @Column(name = "warehouse", nullable = true, length = 30) | @Column(name = "warehouse", nullable = true, length = 30) | ||||
| open var warehouse: String? = null | open var warehouse: String? = null | ||||
| @Column(name = "area", nullable = true, length = 30) | @Column(name = "area", nullable = true, length = 30) | ||||
| open var area: String? = null | open var area: String? = null | ||||
| @Column(name = "slot", nullable = true, length = 30) | @Column(name = "slot", nullable = true, length = 30) | ||||
| open var slot: String? = null | open var slot: String? = null | ||||
| @Column(name = "stockTakeSection", nullable = true, length = 255) | |||||
| open var stockTakeSection: String? = null | |||||
| } | } | ||||
| @@ -13,19 +13,5 @@ interface WarehouseRepository : AbstractRepository<Warehouse, Long> { | |||||
| fun findByIdAndDeletedIsFalse(id: Serializable): Warehouse?; | fun findByIdAndDeletedIsFalse(id: Serializable): Warehouse?; | ||||
| fun findByCodeAndDeletedIsFalse(code: String): Warehouse?; | fun findByCodeAndDeletedIsFalse(code: String): Warehouse?; | ||||
| @Query(""" | |||||
| SELECT w FROM Warehouse w | |||||
| WHERE w.code = :code | |||||
| AND w.stockTakeTable = :stockTakeTable | |||||
| AND w.company = :company | |||||
| AND w.storeLocation = :storeLocation | |||||
| AND w.deleted = false | |||||
| """) | |||||
| fun findByCodeAndStockTakeTableAndCompanyAndStoreLocationAndDeletedIsFalse( | |||||
| code: String, | |||||
| stockTakeTable: String, | |||||
| company: String, | |||||
| storeLocation: String | |||||
| ): Warehouse? | |||||
| } | } | ||||
| @@ -244,9 +244,6 @@ open class WarehouseService( | |||||
| this.store_id = store_id | this.store_id = store_id | ||||
| this.slot = slot | this.slot = slot | ||||
| this.order = order | this.order = order | ||||
| this.storeLocation = storeLocation | |||||
| this.stockTakeTable = stockTakeTable | |||||
| this.company = company | |||||
| } | } | ||||
| warehouseRepository.save(existingWarehouse) | warehouseRepository.save(existingWarehouse) | ||||
| updateCount++ | updateCount++ | ||||
| @@ -262,9 +259,6 @@ open class WarehouseService( | |||||
| this.store_id = store_id | this.store_id = store_id | ||||
| this.slot = slot | this.slot = slot | ||||
| this.order = order | this.order = order | ||||
| this.storeLocation = storeLocation | |||||
| this.stockTakeTable = stockTakeTable | |||||
| this.company = company | |||||
| } | } | ||||
| warehouseRepository.save(newWarehouse) | warehouseRepository.save(newWarehouse) | ||||
| createCount++ | createCount++ | ||||
| @@ -342,15 +336,4 @@ open class WarehouseService( | |||||
| // calculate total sort value: floor * 10000 + letter * 100 + slot | // calculate total sort value: floor * 10000 + letter * 100 + slot | ||||
| return floorOrder * 10000L + letterOrder * 100L + slot | return floorOrder * 10000L + letterOrder * 100L + slot | ||||
| } | } | ||||
| open fun findByCodeAndStockTakeTableAndCompanyAndStoreLocation( | |||||
| code: String, | |||||
| stockTakeTable: String, | |||||
| company: String, | |||||
| storeLocation: String | |||||
| ): Warehouse? { | |||||
| return warehouseRepository.findByCodeAndStockTakeTableAndCompanyAndStoreLocationAndDeletedIsFalse( | |||||
| code, stockTakeTable, company, storeLocation | |||||
| ) | |||||
| } | |||||
| } | } | ||||
| @@ -128,19 +128,4 @@ fun getItemsWithDetailsByPage(request: HttpServletRequest): RecordsRes<Map<Strin | |||||
| return RecordsRes(paginatedList, fullList.size) | return RecordsRes(paginatedList, fullList.size) | ||||
| } | } | ||||
| @PostMapping("/patch/file") | |||||
| fun patchItemsFromExcelFile(@RequestParam("fileName") fileName: String): ResponseEntity<*> { | |||||
| return try { | |||||
| if (fileName.isBlank()) { | |||||
| return ResponseEntity.badRequest().body("File name cannot be empty") | |||||
| } | |||||
| logger.info("Request to patch items from file: $fileName") | |||||
| val result = itemsService.patchItemsFromExcelFileName(fileName) | |||||
| ResponseEntity.ok(result) | |||||
| } catch (e: Exception) { | |||||
| logger.error("Error patching from file: ${e.message}", e) | |||||
| ResponseEntity.badRequest().body("Error: ${e.message}") | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -1,5 +1,7 @@ | |||||
| -- liquibase formatted sql | -- liquibase formatted sql | ||||
| -- changeset Enson:add_column | -- changeset Enson:add_column | ||||
| -- preconditions onFail:MARK_RAN | |||||
| -- precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'fpsmsdb' AND table_name = 'bag' | |||||
| create table `fpsmsdb`.`bag` ( | create table `fpsmsdb`.`bag` ( | ||||
| `id` int not null auto_increment, | `id` int not null auto_increment, | ||||
| @@ -56,4 +58,4 @@ create table `fpsmsdb`.`jo_bag_consumption` ( | |||||
| `deleted` tinyint(1) NOT NULL DEFAULT '0', | `deleted` tinyint(1) NOT NULL DEFAULT '0', | ||||
| primary key (`id`) | primary key (`id`) | ||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | |||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | |||||
| @@ -0,0 +1,5 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset KelvinY:add_equipmentCode_to_equipment_detail | |||||
| ALTER TABLE `fpsmsdb`.`equipment_detail` | |||||
| ADD COLUMN `equipmentCode` VARCHAR(255) NULL; | |||||
| @@ -0,0 +1,5 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset KelvinY:add_type_to_printer | |||||
| ALTER TABLE `fpsmsdb`.`printer` | |||||
| ADD COLUMN `type` VARCHAR(255) NULL; | |||||
| @@ -0,0 +1,15 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset KelvinY:modify_items_table | |||||
| -- Add new columns | |||||
| ALTER TABLE `fpsmsdb`.`items` | |||||
| ADD COLUMN `isEgg` TINYINT(1) NULL DEFAULT 0 AFTER `LocationCode`, | |||||
| ADD COLUMN `isFee` TINYINT(1) NULL DEFAULT 0 AFTER `isEgg`, | |||||
| ADD COLUMN `isBag` TINYINT(1) NULL DEFAULT 0 AFTER `isFee`; | |||||
| -- Remove old columns | |||||
| ALTER TABLE `fpsmsdb`.`items` | |||||
| DROP COLUMN `storeLocation`, | |||||
| DROP COLUMN `MTMSPickRoutingID`, | |||||
| DROP COLUMN `inventorySheet`, | |||||
| DROP COLUMN `company`; | |||||
| @@ -0,0 +1,12 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset KelvinY:modify_warehouse_table | |||||
| -- Add new column | |||||
| ALTER TABLE `fpsmsdb`.`warehouse` | |||||
| ADD COLUMN `stockTakeSection` VARCHAR(255) NULL; | |||||
| -- Remove old columns | |||||
| ALTER TABLE `fpsmsdb`.`warehouse` | |||||
| DROP COLUMN `storeLocation`, | |||||
| DROP COLUMN `stockTakeTable`, | |||||
| DROP COLUMN `company`; | |||||