From 79b06a2ed35d43da6af2edf40e25a905b25a6fd7 Mon Sep 17 00:00:00 2001 From: hdka <823267011@qq.com> Date: Wed, 13 Aug 2025 10:18:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../work/service/IIndustryMaterialService.java | 3 +++ .../service/impl/IndustryMaterialServiceImpl.java | 6 ++---- .../work/service/impl/IndustryStepServiceImpl.java | 11 +++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/industry-system/src/main/java/com/industry/work/service/IIndustryMaterialService.java b/industry-system/src/main/java/com/industry/work/service/IIndustryMaterialService.java index 514cc62f..85cd0b9c 100644 --- a/industry-system/src/main/java/com/industry/work/service/IIndustryMaterialService.java +++ b/industry-system/src/main/java/com/industry/work/service/IIndustryMaterialService.java @@ -136,4 +136,7 @@ public interface IIndustryMaterialService int toCheckErrorMaterial(List successList); int delIndustryMaterialById(String id); + + void clearSystem(); + } diff --git a/industry-system/src/main/java/com/industry/work/service/impl/IndustryMaterialServiceImpl.java b/industry-system/src/main/java/com/industry/work/service/impl/IndustryMaterialServiceImpl.java index 89e701af..ed0acfb0 100644 --- a/industry-system/src/main/java/com/industry/work/service/impl/IndustryMaterialServiceImpl.java +++ b/industry-system/src/main/java/com/industry/work/service/impl/IndustryMaterialServiceImpl.java @@ -121,8 +121,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService { @DataSource(value = DataSourceType.SLAVE) public String insertIndustryMaterialToSlaveDataSource(List industryMaterialVos) { - // 直接删掉扫入并且未轧制的,写入二辊数据到四辊机器里面 - clearSystem(); + // TODO 这里需要查一下数据库查看是否有正在轧或者说是未轧的情况 state=1,3,4 List industryMaterialVos1 = industryMaterialMapper.selectIndustryMaterialListAndNotFinish(); @@ -309,7 +308,6 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService { for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) { if (Objects.nonNull(industryMaterialVo.getId())) { industryMaterialMapper.submitMaterial(industryMaterialVo); - // 将异常的道次恢复成初始料 IndustryStep industryStep = new IndustryStep(); industryStep.setBatchId(industryMaterialVo.getBatchId()); @@ -988,7 +986,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService { @DataSource(value = DataSourceType.SLAVE) - private void clearSystem() { + public void clearSystem() { redis2Cache.deleteObject("sort"); redis2Cache.deleteObject("batchId"); redis2Cache.deleteObject("leftId"); diff --git a/industry-system/src/main/java/com/industry/work/service/impl/IndustryStepServiceImpl.java b/industry-system/src/main/java/com/industry/work/service/impl/IndustryStepServiceImpl.java index d03bcd7e..36a4cc0a 100644 --- a/industry-system/src/main/java/com/industry/work/service/impl/IndustryStepServiceImpl.java +++ b/industry-system/src/main/java/com/industry/work/service/impl/IndustryStepServiceImpl.java @@ -407,14 +407,16 @@ public class IndustryStepServiceImpl implements IIndustryStepService { if (Objects.isNull(materialLock) || materialLock != 0L) { // 如果是空就写一个1进去占住锁 redis2Cache.setCacheObject("materialLock", 1L); + Long originBatchId = redis2Cache.getCacheObject("originBatchId"); + if (Objects.isNull(originBatchId) || !originBatchId.equals(industryStep.getBatchId())) { + industryMaterialService.clearSystem(); + } // 然后把非异常的东西都赛里面 industryMaterialVo = new IndustryMaterialVo(); industryMaterialVo.setBatchId(industryStep.getBatchId()); industryMaterialVo.setState(6L); List industryMaterialVos1 = industryMaterialMapper.selectIndustryMaterialList1(industryMaterialVo); String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos1); - - System.out.println(result); } } @@ -580,14 +582,19 @@ public class IndustryStepServiceImpl implements IIndustryStepService { } if (Objects.isNull(materialLock) || materialLock != 0L) { + // 如果是空就写一个1进去占住锁 redis2Cache.setCacheObject("materialLock", 1L, 3000, TimeUnit.HOURS); + redis2Cache.setCacheObject("originBatchId", industryStep.getBatchId(), 3000, TimeUnit.HOURS); // 然后把非异常的东西都赛里面 + // 直接删掉扫入并且未轧制的,写入二辊数据到四辊机器里面 + industryMaterialService.clearSystem(); IndustryMaterialVo industryMaterialVo = new IndustryMaterialVo(); industryMaterialVo.setBatchId(industryStep.getBatchId()); industryMaterialVo.setState(2L); List industryMaterialVos = industryMaterialMapper.selectIndustryMaterialList1(industryMaterialVo); String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos); + } }