| @@ -33,6 +33,12 @@ open class ShopAndTruck : BaseEntity<Long>() { | |||||
| @Column(name = "type", length = 10) | @Column(name = "type", length = 10) | ||||
| open var type: ShopType? = null | open var type: ShopType? = null | ||||
| @Size(max = 50) | |||||
| @NotNull | |||||
| @Column(name = "contactNo", length = 50) | |||||
| open var contactNo: String? = null | |||||
| // --- Truck fields (secondary table) --- | // --- Truck fields (secondary table) --- | ||||
| @Column(table = "truck", name = "TruckLanceCode", length = 50) | @Column(table = "truck", name = "TruckLanceCode", length = 50) | ||||
| open var truckLanceCode: String? = null | open var truckLanceCode: String? = null | ||||
| @@ -47,5 +53,8 @@ open class ShopAndTruck : BaseEntity<Long>() { | |||||
| open var districtReference: Long? = null | open var districtReference: Long? = null | ||||
| @Column(table = "truck", name = "Store_id") | @Column(table = "truck", name = "Store_id") | ||||
| open var storeId: Long? = null | |||||
| open var storeId: String? = null | |||||
| @Column(table = "truck", name = "remark") | |||||
| open var remark: String? = null | |||||
| } | } | ||||
| @@ -33,7 +33,7 @@ interface ShopRepository : AbstractRepository<Shop, Long> { | |||||
| @Query( | @Query( | ||||
| nativeQuery = true, | nativeQuery = true, | ||||
| value = """ | value = """ | ||||
| SELECT s.id, s.code, s.name, s.contactNo, s.contactEmail, s.contactName, s.addr1, s.addr2, s.addr3, s.type, t.TruckLanceCode, t.LoadingSequence, t.districtReference,t.Store_id | |||||
| SELECT s.id, s.code, s.name, s.contactNo, s.contactEmail, s.contactName, s.addr1, s.addr2, s.addr3, s.type, t.TruckLanceCode, t.LoadingSequence, t.districtReference,t.Store_id, t.remark | |||||
| FROM shop s LEFT JOIN truck t ON s.id = t.shopId | FROM shop s LEFT JOIN truck t ON s.id = t.shopId | ||||
| WHERE s.type = 'shop' | WHERE s.type = 'shop' | ||||
| AND s.deleted = false; | AND s.deleted = false; | ||||
| @@ -17,5 +17,6 @@ interface ShopAndTruck { | |||||
| val departureTime: LocalTime? | val departureTime: LocalTime? | ||||
| val LoadingSequence: Long? | val LoadingSequence: Long? | ||||
| val districtReference: Long? | val districtReference: Long? | ||||
| val Store_id: Long? | |||||
| val Store_id: String? | |||||
| val remark: String? | |||||
| } | } | ||||
| @@ -34,6 +34,7 @@ interface TruckRepository : AbstractRepository<Truck, Long> { | |||||
| fun findByShopCodeAndStoreId(shopCode: String, storeId: String): Truck? | fun findByShopCodeAndStoreId(shopCode: String, storeId: String): Truck? | ||||
| fun findByShopIdAndStoreId(shopId: Long, storeId: String): Truck? | |||||
| fun findAllByShopId(shopId :Long):List<Truck> | fun findAllByShopId(shopId :Long):List<Truck> | ||||
| //fun findByTruckLanceCode(truckLanceCode: String):List<Truck> | //fun findByTruckLanceCode(truckLanceCode: String):List<Truck> | ||||
| //fun deleteByTruckLanceCodeAndDepartureTimeAndLoadingSequenceAndDistrictReferenceAndStoreId(truckLanceCode: String, departureTime: LocalTime, loadingSequence: Long, districtReference: Long, storeId: Long): String | //fun deleteByTruckLanceCodeAndDepartureTimeAndLoadingSequenceAndDistrictReferenceAndStoreId(truckLanceCode: String, departureTime: LocalTime, loadingSequence: Long, districtReference: Long, storeId: Long): String | ||||
| @@ -195,15 +195,17 @@ open class TruckService( | |||||
| val updateTruckLance = truckRepository.findById(request.id).orElseThrow() | val updateTruckLance = truckRepository.findById(request.id).orElseThrow() | ||||
| ?: throw IllegalArgumentException("Truck not found with truckLanceCode: $request.truckLanceCode") | ?: throw IllegalArgumentException("Truck not found with truckLanceCode: $request.truckLanceCode") | ||||
| //println(updateTruckLance,"before") | |||||
| // Use remark from request (user input) - no auto-fill | |||||
| updateTruckLance.truckLanceCode = request.truckLanceCode | updateTruckLance.truckLanceCode = request.truckLanceCode | ||||
| updateTruckLance.loadingSequence = request.loadingSequence.toInt() | updateTruckLance.loadingSequence = request.loadingSequence.toInt() | ||||
| updateTruckLance.districtReference = request.districtReference.toInt() | updateTruckLance.districtReference = request.districtReference.toInt() | ||||
| updateTruckLance.departureTime = request.departureTime | updateTruckLance.departureTime = request.departureTime | ||||
| updateTruckLance.storeId = request.storeId | updateTruckLance.storeId = request.storeId | ||||
| // Only set remark if storeId is "4F", otherwise set to null | |||||
| updateTruckLance.remark = if (request.storeId == "4F") request.remark else null | |||||
| val savedTruck = truckRepository.save(updateTruckLance) | val savedTruck = truckRepository.save(updateTruckLance) | ||||
| //print(updateTruckLance,"after") | |||||
| return listOf(savedTruck) | return listOf(savedTruck) | ||||
| } | } | ||||
| @@ -232,6 +234,8 @@ open class TruckService( | |||||
| this.shopCode = request.shopCode | this.shopCode = request.shopCode | ||||
| this.loadingSequence = request.loadingSequence | this.loadingSequence = request.loadingSequence | ||||
| this.districtReference = request.districtReference | this.districtReference = request.districtReference | ||||
| // Only set remark if store_id is "4F", otherwise set to null | |||||
| this.remark = if (request.store_id == "4F") request.remark else null | |||||
| } | } | ||||
| return truckRepository.save(truck) | return truckRepository.save(truck) | ||||
| @@ -18,7 +18,8 @@ data class SaveTruckLane( | |||||
| val departureTime: LocalTime, | val departureTime: LocalTime, | ||||
| val loadingSequence: Long, | val loadingSequence: Long, | ||||
| val districtReference: Long, | val districtReference: Long, | ||||
| val storeId: String | |||||
| val storeId: String, | |||||
| val remark: String? = null | |||||
| ) | ) | ||||
| data class deleteTruckLane( | data class deleteTruckLane( | ||||
| val id: Long | val id: Long | ||||