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