From 640ccb9229224642515527daf87f308a7aa9bdf4 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Wed, 10 Jun 2026 11:47:26 +0800
Subject: [PATCH] 1

---
 trading-order-huobi/src/main/java/com.yami.trading.huobi/data/internal/AdjustmentValueServiceImpl.java |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/trading-order-huobi/src/main/java/com.yami.trading.huobi/data/internal/AdjustmentValueServiceImpl.java b/trading-order-huobi/src/main/java/com.yami.trading.huobi/data/internal/AdjustmentValueServiceImpl.java
index 4d8b6e5..73847dc 100644
--- a/trading-order-huobi/src/main/java/com.yami.trading.huobi/data/internal/AdjustmentValueServiceImpl.java
+++ b/trading-order-huobi/src/main/java/com.yami.trading.huobi/data/internal/AdjustmentValueServiceImpl.java
@@ -34,9 +34,9 @@
         Realtime realtime = dataService.realtime(symbol).get(0);
         BigDecimal new_price = realtime.getClose();
         BigDecimal plus = value.abs();
-        if (plus.divide(new_price, 2, RoundingMode.HALF_UP).compareTo(new BigDecimal("0.1")) > 0) {
-            throw new YamiShopBindException("调整偏差过大,超过10%");
-        }
+//        if (plus.divide(new_price, 2, RoundingMode.HALF_UP).compareTo(new BigDecimal("0.1")) > 0) {
+//            throw new YamiShopBindException("Adjustment deviation too large, exceeds 10%");
+//        }
 
         if (second <= 0) {
             /**
@@ -50,15 +50,17 @@
             } else {
                 AdjustmentValueCache.getCurrentValue().put(symbol, currentValue.add(value));
             }
-            // 马上扣除价格,避免因为数据没有拉取导致加不正确
-            realtime.setClose(realtime.getClose().add(value));
             /*
-             * 持久化缓存
+             * 持久化到品种表(重启后 InitHandle 会加载到 AdjustmentValueCache)
              */
             Item item = this.itemService.findBySymbol(symbol);
-            if (item.getAdjustmentValue().compareTo(AdjustmentValueCache.getCurrentValue().get(symbol)) != 0) {
-                item.setAdjustmentValue(AdjustmentValueCache.getCurrentValue().get(symbol));
-                itemService.saveOrUpdate(item);
+            BigDecimal cachedAdjust = AdjustmentValueCache.getCurrentValue().get(symbol);
+            if (item != null && cachedAdjust != null) {
+                BigDecimal itemAdjust = item.getAdjustmentValue();
+                if (itemAdjust == null || itemAdjust.compareTo(cachedAdjust) != 0) {
+                    item.setAdjustmentValue(cachedAdjust);
+                    itemService.saveOrUpdate(item);
+                }
             }
 
         } else {

--
Gitblit v1.9.3