Pārlūkot izejas kodu

no message

production
[email protected] pirms 6 dienas
vecāks
revīzija
4d38dcff74
2 mainītis faili ar 18 papildinājumiem un 22 dzēšanām
  1. +1
    -1
      src/main/java/com/ffii/fpsms/m18/model/M18BomForShopSaveRequest.kt
  2. +17
    -21
      src/main/java/com/ffii/fpsms/m18/service/M18BomForShopService.kt

+ 1
- 1
src/main/java/com/ffii/fpsms/m18/model/M18BomForShopSaveRequest.kt Parādīt failu

@@ -79,7 +79,7 @@ data class M18UdfProductSaveValue(
val udfIngredients: String? = null,
/** Line UOM: [com.ffii.fpsms.modules.master.entity.UomConversion.code] (same unit as [udfqty]). */
val udfBaseUnit: String? = null,
/** M18 vendor id from latest synced PO for the material: local [com.ffii.fpsms.modules.master.entity.Shop.m18Id] or M18 `ven` search (PF BE when BOM is PF). */
/** M18 vendor id ([StSearchType.VENDOR]) for the BOM business entity: PP → [M18Config.BEID_PP], PF → [M18Config.BEID_PF]. */
val udfSupplier: Long? = null,
/**
* M18 UOM id for price/purchase unit on the **M18-linked** PO line (`m18DataLog` present):


+ 17
- 21
src/main/java/com/ffii/fpsms/m18/service/M18BomForShopService.kt Parādīt failu

@@ -389,7 +389,7 @@ open class M18BomForShopService(
/**
* Resolves M18 vendor id for BOM material line supplier:
* - PF BOMs: M18 search by supplier code + [M18Config.BEID_PF]
* - PP / other: local [Shop.m18Id] by code, then M18 search with [M18Config.BEID_PP] when needed
* - PP BOMs: M18 search by supplier code + [M18Config.BEID_PP] (never local [Shop.m18Id] first — duplicate codes may be PF ids)
*/
private fun resolveSupplierM18Id(
latestPoLine: PurchaseOrderLine?,
@@ -406,28 +406,24 @@ open class M18BomForShopService(
if (supplierCode == null) {
return directM18Id
}
if (directM18Id != null && (targetBeId == null || poBeId == targetBeId)) {
return directM18Id
}

val cacheKey = "$supplierCode|$flowTypeId"
cache[cacheKey]?.let { return it }

val resolved = when (flowTypeId) {
2 -> m18VendorLookupService.findVendorM18IdByCode(supplierCode, m18Config.BEID_PF)
?: directM18Id.also {
if (it == null) {
logger.warn("[M18 BOM] PF vendor M18 id not found for supplierCode=$supplierCode")
}
}
3 -> shopService.findVendorByCode(supplierCode)?.m18Id?.takeIf { it > 0L }
?: m18VendorLookupService.findVendorM18IdByCode(supplierCode, m18Config.BEID_PP)
?: directM18Id
else -> shopService.findVendorByCode(supplierCode)?.m18Id?.takeIf { it > 0L }
?: directM18Id
if (flowTypeId == 2 || flowTypeId == 3) {
val cacheKey = "$supplierCode|$flowTypeId"
cache[cacheKey]?.let { return it }
val beId = if (flowTypeId == 2) m18Config.BEID_PF else m18Config.BEID_PP
val beLabel = if (flowTypeId == 2) "PF" else "PP"
val resolved =
m18VendorLookupService.findVendorM18IdByCode(supplierCode, beId)
?: directM18Id.takeIf { poBeId != null && poBeId == targetBeId }
if (resolved == null) {
logger.warn("[M18 BOM] $beLabel vendor M18 id not found for supplierCode=$supplierCode")
}
cache[cacheKey] = resolved
return resolved
}
cache[cacheKey] = resolved
return resolved

return shopService.findVendorByCode(supplierCode)?.m18Id?.takeIf { it > 0L }
?: directM18Id
}

private fun resolveFlowTypeId(code: String): Int = when {


Notiek ielāde…
Atcelt
Saglabāt