| @@ -571,12 +571,13 @@ open class DeliveryOrderService( | |||
| val trucks = truckRepository.findByShopIdAndDeletedFalse(shopId) | |||
| println("🔍 DEBUG: Found ${trucks.size} trucks for shop $shopId") | |||
| val preferredStoreId = when (preferredFloor) { | |||
| "2F" -> 2 | |||
| "4F" -> 4 | |||
| else -> 2 | |||
| "2F" -> "2F" | |||
| "4F" -> "4F" | |||
| "3F" -> "3F" | |||
| else -> "2F" | |||
| } | |||
| // 优先选择匹配的 truck | |||
| val selectedTruck = if (trucks.size > 1) { | |||
| trucks.find { it.storeId == preferredStoreId } | |||
| @@ -592,9 +593,10 @@ open class DeliveryOrderService( | |||
| // 检查 truck 和 preferredFloor 是否匹配 | |||
| val truckStoreId = truck?.storeId | |||
| val expectedStoreId = when (preferredFloor) { | |||
| "2F" -> 2 | |||
| "4F" -> 4 | |||
| else -> 2 | |||
| "2F" -> "2F" | |||
| "4F" -> "4F" | |||
| "3F" -> "3F" | |||
| else -> "2F" | |||
| } | |||
| if (truck == null || truckStoreId != expectedStoreId) { | |||
| @@ -1219,9 +1221,10 @@ open fun releaseDeliveryOrderWithoutTicket(request: ReleaseDoRequest): ReleaseDo | |||
| val truck = deliveryOrder.shop?.id?.let { shopId -> | |||
| val trucks = truckRepository.findByShopIdAndDeletedFalse(shopId) | |||
| val preferredStoreId = when (preferredFloor) { | |||
| "2F" -> 2 | |||
| "4F" -> 4 | |||
| else -> 2 | |||
| "2F" -> "2F" | |||
| "4F" -> "4F" | |||
| "3F" -> "3F" | |||
| else -> "2F" | |||
| } | |||
| // 只选择 store_id 匹配的 truck | |||
| @@ -544,15 +544,16 @@ open class DoPickOrderService( | |||
| open fun selectTruck(shopId: Long?, storeId: String): Truck? { | |||
| if (shopId == null) return null | |||
| val storeIdInt = when (storeId) { | |||
| "2/F" -> 2 | |||
| "4/F" -> 4 | |||
| "3/F" -> 3 | |||
| else -> 2 | |||
| val storeId= when (storeId) { | |||
| "2F" -> "2F" | |||
| "4F" -> "4F" | |||
| "3F" -> "3F" | |||
| "3/F" -> "3F" | |||
| else -> "2F" | |||
| } | |||
| val trucks = truckRepository.findByShopIdAndDeletedFalse(shopId) | |||
| return trucks.find { it.storeId == storeIdInt } ?: trucks.firstOrNull() | |||
| return trucks.find { it.storeId == storeId } ?: trucks.firstOrNull() | |||
| } | |||
| open fun finishDoPickOrder(doPickOrderId: Long): MessageResponse { | |||
| @@ -33,9 +33,12 @@ open class Truck : BaseEntity<Long>() { | |||
| open var loadingSequence: Int? = null | |||
| @Column(name = "Store_id") | |||
| open var storeId: Int? = null | |||
| open var storeId: String? = null | |||
| @Column(name = "districtReference") | |||
| open var districtReference: Int? = null | |||
| @Column(name = "remark") | |||
| open var remark: String? = null | |||
| } | |||
| @@ -26,12 +26,12 @@ interface TruckRepository : AbstractRepository<Truck, Long> { | |||
| fun findByShopCodeAndDeletedFalse(@Param("shopCode") shopCode: String): List<Truck> | |||
| // 按 Store_id 查询 | |||
| fun findByStoreIdAndDeletedFalse(storeId: Int): List<Truck> | |||
| fun findByStoreIdAndDeletedFalse(storeId: String): List<Truck> | |||
| // 按 TruckLanceCode 查询 | |||
| fun findByTruckLanceCode(truckLanceCode: String): Truck? | |||
| fun findByShopNameAndStoreIdAndTruckLanceCode(shopName: String, storeId: Int, truckLanceCode: String): Truck? | |||
| fun findByShopCodeAndStoreId(shopCode: String, storeId: Int): Truck? | |||
| fun findByShopNameAndStoreIdAndTruckLanceCode(shopName: String, storeId: String, truckLanceCode: String): Truck? | |||
| fun findByShopCodeAndStoreId(shopCode: String, storeId: String): Truck? | |||
| fun findAllByShopId(shopId :Long):List<Truck> | |||
| @@ -39,6 +39,7 @@ open class TruckService( | |||
| this.shopName = request.shopName | |||
| this.shopCode = request.shopCode | |||
| this.loadingSequence = request.loadingSequence | |||
| this.remark = request.remark | |||
| } | |||
| return truckRepository.save(truck); | |||
| @@ -127,7 +128,7 @@ open class TruckService( | |||
| val shopCode = ExcelUtils.getStringValue(row.getCell(COLUMN_SHOP_CODE_INDEX)).trim() | |||
| val loadingSequence = ExcelUtils.getIntValue(row.getCell(COLUMN_LOADING_SEQUENCE_INDEX)) | |||
| val store_id = ExcelUtils.getStringValue(row.getCell(COLUMN_STORE_ID_INDEX)).trim() | |||
| //val remark = ExcelUtils.getStringValue(row.getCell(COLUMN_REMARK_INDEX)).trim() | |||
| val remark = ExcelUtils.getStringValue(row.getCell(COLUMN_REMARK_INDEX)).trim() | |||
| val storeIdInt = when (store_id.uppercase()) { | |||
| "2F" -> 2 | |||
| @@ -146,31 +147,33 @@ open class TruckService( | |||
| val normalizedShopCode = normalizeShopCode(shopCode) | |||
| val shop = shopRepository.findAllByDeletedIsFalse().firstOrNull { it.code == normalizedShopCode } | |||
| //println("shop: ${shop}") | |||
| val existingTruck = truckRepository.findByShopCodeAndStoreId(shopCode, storeIdInt) | |||
| val existingTruck = truckRepository.findByShopCodeAndStoreId(shopCode, store_id) | |||
| if (existingTruck != null) { | |||
| val truckRequest = SaveTruckRequest( | |||
| id = existingTruck.id, | |||
| store_id = storeIdInt, | |||
| store_id = store_id, | |||
| truckLanceCode = truckLanceCode ?: existingTruck.truckLanceCode ?: "", | |||
| departureTime = departureTime, | |||
| shopId = shop?.id!!, | |||
| shopName = shopName ?: "", | |||
| shopCode = normalizedShopCode, | |||
| loadingSequence = loadingSequence | |||
| loadingSequence = loadingSequence, | |||
| remark = remark | |||
| ) | |||
| saveTruck(truckRequest) | |||
| } else { | |||
| // 创建新记录 | |||
| val truckRequest = SaveTruckRequest( | |||
| id = null, | |||
| store_id = storeIdInt, | |||
| store_id = store_id, | |||
| truckLanceCode = truckLanceCode ?: "", | |||
| departureTime = departureTime, | |||
| shopId = shop?.id!!, | |||
| shopName = shopName ?: "", | |||
| shopCode = normalizedShopCode, | |||
| loadingSequence = loadingSequence | |||
| loadingSequence = loadingSequence, | |||
| remark = remark | |||
| ) | |||
| saveTruck(truckRequest) | |||
| } | |||
| @@ -197,7 +200,7 @@ open class TruckService( | |||
| updateTruckLance.loadingSequence = request.loadingSequence.toInt() | |||
| updateTruckLance.districtReference = request.districtReference.toInt() | |||
| updateTruckLance.departureTime = request.departureTime | |||
| updateTruckLance.storeId = request.storeId.toInt() | |||
| updateTruckLance.storeId = request.storeId | |||
| val savedTruck = truckRepository.save(updateTruckLance) | |||
| //print(updateTruckLance,"after") | |||
| @@ -2,13 +2,14 @@ package com.ffii.fpsms.modules.pickOrder.web.models | |||
| import java.time.LocalTime | |||
| data class SaveTruckRequest( | |||
| val id: Long? = null, | |||
| val store_id: Int, | |||
| val store_id: String, | |||
| val truckLanceCode: String, | |||
| val departureTime: LocalTime, | |||
| val shopId: Long, | |||
| val shopName: String, | |||
| val shopCode: String, | |||
| val loadingSequence: Int, | |||
| val remark: String? = null, | |||
| val districtReference: Int? = null, | |||
| ) | |||
| data class SaveTruckLane( | |||
| @@ -17,7 +18,7 @@ data class SaveTruckLane( | |||
| val departureTime: LocalTime, | |||
| val loadingSequence: Long, | |||
| val districtReference: Long, | |||
| val storeId: Int | |||
| val storeId: String | |||
| ) | |||
| data class deleteTruckLane( | |||
| val id: Long | |||