소스 검색

fixing the error that if item deleted

master
Fai Luk 6 시간 전
부모
커밋
f15898662d
1개의 변경된 파일13개의 추가작업 그리고 3개의 파일을 삭제
  1. +13
    -3
      src/main/java/com/ffii/fpsms/modules/master/service/ItemsService.kt

+ 13
- 3
src/main/java/com/ffii/fpsms/modules/master/service/ItemsService.kt 파일 보기

@@ -450,10 +450,20 @@ open class ItemsService(
val avg = row["avgUp"] as? BigDecimal ?: return@mapNotNull null
id to avg.toPlainString()
}.toMap()
// Use JDBC UPDATE instead of load+save: avoids ObjectOptimisticLockingFailureException when the same
// Items row was already updated earlier in this transaction (e.g. M18 PO sync) or concurrently.
idList.forEach { itemId ->
val item = itemsRepository.findById(itemId).orElse(null) ?: return@forEach
item.averageUnitPrice = avgByItem[itemId]
itemsRepository.saveAndFlush(item)
val avg = avgByItem[itemId]
jdbcDao.executeUpdate(
"""
UPDATE items
SET AverageUnitPrice = :avg,
modified = NOW(),
version = version + 1
WHERE id = :id AND deleted = 0
""".trimIndent(),
mapOf("avg" to avg, "id" to itemId),
)
}
}



불러오는 중...
취소
저장