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 85cd0b9c..ca406d4d 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 @@ -116,7 +116,7 @@ public interface IIndustryMaterialService void deleteIndustryMaterialByState(Long state); - String insertIndustryMaterialToSlaveDataSource(List industryMaterialVos); + String insertIndustryMaterialToSlaveDataSource(List industryMaterialVos, Long aLong); /**3 * 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 ed0acfb0..1a6cc3c6 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 @@ -119,7 +119,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService { @Override @DataSource(value = DataSourceType.SLAVE) - public String insertIndustryMaterialToSlaveDataSource(List industryMaterialVos) { + public String insertIndustryMaterialToSlaveDataSource(List industryMaterialVos,Long insertBatchId) { // TODO 这里需要查一下数据库查看是否有正在轧或者说是未轧的情况 state=1,3,4 @@ -128,13 +128,22 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService { System.out.println("触发四辊数据写入"); // 这个大小等于0 表示四辊没有东西再轧制了可以进行放行 if (industryMaterialVos1.isEmpty()) { - IndustryBatch industryBatch = new IndustryBatch(); - industryBatch.setBatchSize((long) industryMaterialVos.size()); - industryBatchService.insertIndustryBatch(industryBatch); + + if (Objects.nonNull(insertBatchId)) { + IndustryBatchVo industryBatchVo = industryBatchService.selectIndustryBatchById(insertBatchId); + industryBatchVo.setBatchSize(industryBatchVo.getBatchSize() + 1); + industryBatchService.updateIndustryBatch(industryBatchVo); + }else{ + IndustryBatch industryBatch = new IndustryBatch(); + industryBatch.setBatchSize((long) industryMaterialVos.size()); + industryBatchService.insertIndustryBatch(industryBatch); + insertBatchId = industryBatch.getId(); + redis2Cache.setCacheObject("insertBatchId", insertBatchId,3000,TimeUnit.HOURS); + } for (IndustryMaterialVo industryMaterialVo : industryMaterialVos) { industryMaterialVo.setState(0L); industryMaterialVo.setStepSize(null); - industryMaterialVo.setBatchId(industryBatch.getId()); + industryMaterialVo.setBatchId(insertBatchId); industryMaterialVo.setDelFlag(0L); industryMaterialVo.setFinalDiameter(null); industryMaterialVo.setOperation(0L); 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 36a4cc0a..479345e5 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 @@ -398,6 +398,8 @@ public class IndustryStepServiceImpl implements IIndustryStepService { // 如果当前模式是4辊 if ("1".equals(mode)) { redisCache.deleteObject("materialLock"); + redis2Cache.deleteObject("insertBatchId"); + redis2Cache.deleteObject("originBatchId"); } // 如果当前模式是2辊 @@ -416,7 +418,9 @@ public class IndustryStepServiceImpl implements IIndustryStepService { industryMaterialVo.setBatchId(industryStep.getBatchId()); industryMaterialVo.setState(6L); List industryMaterialVos1 = industryMaterialMapper.selectIndustryMaterialList1(industryMaterialVo); - String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos1); + Long insertBatchId = redis2Cache.getCacheObject("insertBatchId"); + + String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos1,Objects.nonNull(insertBatchId)?insertBatchId:null); } } @@ -554,6 +558,8 @@ public class IndustryStepServiceImpl implements IIndustryStepService { // 如果当前模式是4辊 if ("1".equals(mode)) { redisCache.deleteObject("materialLock"); + redis2Cache.deleteObject("insertBatchId"); + redis2Cache.deleteObject("originBatchId"); } // 如果当前模式是2辊 @@ -593,7 +599,7 @@ public class IndustryStepServiceImpl implements IIndustryStepService { industryMaterialVo.setBatchId(industryStep.getBatchId()); industryMaterialVo.setState(2L); List industryMaterialVos = industryMaterialMapper.selectIndustryMaterialList1(industryMaterialVo); - String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos); + String result = industryMaterialService.insertIndustryMaterialToSlaveDataSource(industryMaterialVos, null); } }