From 25468c298cea807546b54926b17d75e6b1f5a01d Mon Sep 17 00:00:00 2001 From: Joshi <3040996759@qq.com> Date: Mon, 14 Jul 2025 09:39:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=BC=80TODO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IndustryStepServiceImpl.java | 89 ++++++++++--------- 1 file changed, 49 insertions(+), 40 deletions(-) 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 2ce27396..c37575a8 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 @@ -179,16 +179,16 @@ public class IndustryStepServiceImpl implements IIndustryStepService { // TODO PLC // 将切换道次改为true -// s7PLC.writeBoolean("DB15.1.2",true); + s7PLC.writeBoolean("DB15.1.2",true); // 判断当前切换是否转化过来成true 没有则再发 -// while (!s7PLC.readBoolean("DB15.1.2")){ -// Threads.sleep(500); + while (!s7PLC.readBoolean("DB15.1.2")){ + Threads.sleep(500); -// } + } // 当当前的到此为true时候将其置 5s延迟 使其切换道次 -// if (s7PLC.readBoolean("DB15.1.2")){ + if (s7PLC.readBoolean("DB15.1.2")){ Threads.sleep(5000); // 更新该批次中的全部道次的 "操作中" 字段为0 @@ -216,27 +216,27 @@ public class IndustryStepServiceImpl implements IIndustryStepService { // 更新一下下一步的状态 industryStepMapper.updateIndustryStepByBatchId(industryStep1); // TODO 向plc发送当前道次 -// s7PLC.writeInt32("DB16.0", Math.toIntExact(newStep)); + s7PLC.writeInt32("DB16.0", Math.toIntExact(newStep)); //以及剩余道次 Long num = industryStepMapper.selectMaxStepNum(industryStep.getBatchId()); -// s7PLC.writeInt32("M854", Math.toIntExact(num - newStep)); + s7PLC.writeInt32("M854", Math.toIntExact(num - newStep)); Long materialFlag = redisCache.getCacheObject("materialFlag"); redisCache.setCacheObject("nextStepFlag", 0L, 100, TimeUnit.HOURS); redisCache.setCacheObject("materialFlag", materialFlag == 1L ? 0L : 1L, 100, TimeUnit.HOURS); -// s7PLC.writeBoolean("DB15.1.2",false); -// s7PLC.writeFloat32("DB15.118",industryStepVos.get(0).getSetValue().floatValue()); + s7PLC.writeBoolean("DB15.1.2",false); + s7PLC.writeFloat32("DB15.118",industryStepVos.get(0).getSetValue().floatValue()); // 设定值确认 -// s7PLC.writeBoolean("DB15.0.3",true); + s7PLC.writeBoolean("DB15.0.3",true); -// while (s7PLC.readBoolean("DB15.0.3")){ -// s7PLC.writeBoolean("DB15.0.3",false); -// } -// } + while (s7PLC.readBoolean("DB15.0.3")){ + s7PLC.writeBoolean("DB15.0.3",false); + } + } -// while (s7PLC.readBoolean("DB15.1.2")){ -// Threads.sleep(500); -// } + while (s7PLC.readBoolean("DB15.1.2")){ + Threads.sleep(500); + } return 1; } @@ -253,6 +253,17 @@ public class IndustryStepServiceImpl implements IIndustryStepService { // nextStepFlag为切换道次的标志位,当其为1时需要进行切换道次,否则不用切换道次 return 0; } + + // 将切换道次改为true + s7PLC.writeBoolean("DB15.1.2",true); + + // 判断当前切换是否转化过来成true 没有则再发 + while (!s7PLC.readBoolean("DB15.1.2")){ + Threads.sleep(500); + } + + // 当当前的到此为true时候将其置 5s延迟 使其切换道次 + if (s7PLC.readBoolean("DB15.1.2")){ Threads.sleep(5000); // 更新该批次中的全部道次的 "操作中" 字段为0 IndustryStep step = new IndustryStep(); @@ -284,30 +295,28 @@ public class IndustryStepServiceImpl implements IIndustryStepService { // TODO 向plc发送当前道次 -// s7PLC.writeInt32("DB16.0", Math.toIntExact(newStep)); + s7PLC.writeInt32("DB16.0", Math.toIntExact(newStep)); //以及剩余道次 Long num = industryStepMapper.selectMaxStepNum(industryStep.getBatchId()); -// s7PLC.writeInt32("M854", Math.toIntExact(num - newStep)); + s7PLC.writeInt32("M854", Math.toIntExact(num - newStep)); Long materialFlagError = redisCache.getCacheObject("materialFlagError"); redisCache.setCacheObject("nextStepFlagError", 0L, 100, TimeUnit.HOURS); redisCache.setCacheObject("materialFlagError", materialFlagError==1L?0L:1L, 100, TimeUnit.HOURS); -// s7PLC.writeBoolean("DB15.1.2", false); -// -// s7PLC.writeFloat32("DB15.118", industryStepVos.get(0).getSetValue().floatValue()); -// s7PLC.writeBoolean("DB15.0.3", true); + s7PLC.writeBoolean("DB15.1.2", false); -// while (s7PLC.readBoolean("DB15.0.3")) { -// s7PLC.writeBoolean("DB15.0.3", false); -// } -// } + s7PLC.writeFloat32("DB15.118", industryStepVos.get(0).getSetValue().floatValue()); + s7PLC.writeBoolean("DB15.0.3", true); + while (s7PLC.readBoolean("DB15.0.3")) { + s7PLC.writeBoolean("DB15.0.3", false); + } + } -// while (s7PLC.readBoolean("DB15.1.2")) { -// Threads.sleep(500); -// } - + while (s7PLC.readBoolean("DB15.1.2")) { + Threads.sleep(500); + } return 1; } @@ -381,7 +390,7 @@ public class IndustryStepServiceImpl implements IIndustryStepService { } // TODO PLC - //s7PLC.writeBoolean("DB15.1.2", false); + s7PLC.writeBoolean("DB15.1.2", false); return 1; } @@ -495,7 +504,7 @@ public class IndustryStepServiceImpl implements IIndustryStepService { } // TODO PLC -// s7PLC.writeBoolean("DB15.1.2", false); + s7PLC.writeBoolean("DB15.1.2", false); return 1; } @@ -565,13 +574,13 @@ public class IndustryStepServiceImpl implements IIndustryStepService { List industryStepVos = industryStepMapper.selectIndustryStepList(industryStep); // TODO PLC -// if (!industryStepVos.isEmpty()){ -// s7PLC.writeFloat32("DB15.118",industryStepVos.get(0).getSetValue().floatValue()); -// s7PLC.writeBoolean("DB15.0.3",true); -// while (s7PLC.readBoolean("DB15.0.3")){ -// s7PLC.writeBoolean("DB15.0.3",false); -// } -// } + if (!industryStepVos.isEmpty()){ + s7PLC.writeFloat32("DB15.118",industryStepVos.get(0).getSetValue().floatValue()); + s7PLC.writeBoolean("DB15.0.3",true); + while (s7PLC.readBoolean("DB15.0.3")){ + s7PLC.writeBoolean("DB15.0.3",false); + } + } industryStep.setOperation(1L); industryStepMapper.start(industryStep); }