qiangxuan 1 өдөр өмнө
parent
commit
774637ac8a

+ 16 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/impl/StorageBillServiceImpl.java

@@ -77,6 +77,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
@@ -2627,6 +2628,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 result.put("success", "装运单临时表明细不存在,编辑目的地成功!");
                 return result;
             }
+            // 如果临时表存在数据,用独立事务先更新装运单目的地(typeConfigId、destination)
+            updateStorageBillDestination(storageBill);
 
             List<BilletAutoTmp> billetAutoTmpHotChargeList = new ArrayList<>();
             List<BilletAutoTmp> billetAutoTmpStackList = new ArrayList<>();
@@ -2911,7 +2914,17 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
         }
     }
 
-
+    /**
+     * 独立事务更新装运单目的地(关键逻辑)
+     * - Propagation.REQUIRES_NEW 开启新事务,立即提交
+     * - 不使用锁,仅通过事务独立性确保优先更新
+     */
+    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
+    public void updateStorageBillDestination(StorageBill storageBill) {
+        // 更新目的地信息(如typeConfigId、destination)
+        baseMapper.updateById(storageBill);
+        log.info("独立事务已更新装运单目的地,ID: {}", storageBill.getId());
+    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -2927,6 +2940,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 result.put("success", "看板确认目的地成功!");
                 return result;
             }
+            // 如果临时表存在数据,用独立事务先更新装运单目的地(typeConfigId、destination)
+            updateStorageBillDestination(storageBill);
 
             List<BilletAutoTmp> billetAutoTmpHotChargeList = new ArrayList<>();
             List<BilletAutoTmp> billetAutoTmpStackList = new ArrayList<>();