From 83650f6bb34e5633fb1f18655ce3bd4c2384457c Mon Sep 17 00:00:00 2001 From: 86156 <823267011@qq.com> Date: Mon, 14 Jul 2025 12:11:51 +0800 Subject: [PATCH] =?UTF-8?q?bug=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../work/IndustryMaterialController.java | 19 ++- .../impl/IndustryMaterialServiceImpl.java | 7 +- .../service/impl/IndustryStepServiceImpl.java | 111 ++++++++++-------- .../mapper/work/IndustryStepMapper.xml | 4 +- 4 files changed, 80 insertions(+), 61 deletions(-) diff --git a/industry-admin/src/main/java/com/industry/web/controller/work/IndustryMaterialController.java b/industry-admin/src/main/java/com/industry/web/controller/work/IndustryMaterialController.java index 10f2b303..df543e9b 100644 --- a/industry-admin/src/main/java/com/industry/web/controller/work/IndustryMaterialController.java +++ b/industry-admin/src/main/java/com/industry/web/controller/work/IndustryMaterialController.java @@ -236,9 +236,6 @@ public class IndustryMaterialController extends BaseController } - - - /** * 开始异常轧制接口 * 首先拿到道次最小的那个材料id @@ -293,4 +290,20 @@ public class IndustryMaterialController extends BaseController industryMaterialService.deleteIndustryMaterialByState(0L); } + + + @GetMapping("/clear-system") + public void clearSystem(){ + redisCache.deleteObject("sort"); + redisCache.deleteObject("batchId"); + redisCache.deleteObject("leftId"); + redisCache.deleteObject("rightId"); + if ("1".equals(mode)){ + redisCache.deleteObject("materialLock"); + } + s7PLC.writeString("DB4.30","\u0000\u0000\u0000\u0000"); + s7PLC.writeString("DB44.30","\u0000\u0000\u0000\u0000"); + industryMaterialService.deleteIndustryMaterialByState(1L); + + } } 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 b521c677..614aa807 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 @@ -411,7 +411,7 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService { Long flag = checkFirstOrLast(firstMaterial); - // 记录materialFlag为升序 + // 记录materialFlagError为升序 redisCache.setCacheObject("materialFlagError", flag, 100, TimeUnit.HOURS); redisCache.setCacheObject("nextStepFlagError", 0L, 100, TimeUnit.HOURS); @@ -496,9 +496,9 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService { public int checkFlagError(IndustryMaterialDto material) { IndustryMaterial industryMaterial = new IndustryMaterial(); industryMaterial.setBatchId(material.getBatchId()); - Long state = material.getState(); + //Long state = material.getState(); // 3代表的是该批次中存在道次异常,下面的查询时直接跳过这个批次 - state = state == 3 ? 5 : state; + Long state = 5L; // 查询下一个应该将operation改为 1 的批次 并且为同一状态 industryMaterial.setState(state); List industryMaterialVos = industryMaterialMapper.selectIndustryMaterialList(industryMaterial); @@ -532,7 +532,6 @@ public class IndustryMaterialServiceImpl implements IIndustryMaterialService { if (materialFlag == 0L) { // 降序 // 表示走到了最后一个了 - if (start == pos) { redisCache.setCacheObject("nextStepFlagError", 1L, 100, TimeUnit.HOURS); // 向上升并且已经升到头了 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 c37575a8..bdf389c9 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,62 +179,62 @@ 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")){ + 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 - IndustryStep step = new IndustryStep(); + Threads.sleep(5000); + // 更新该批次中的全部道次的 "操作中" 字段为0 + IndustryStep step = new IndustryStep(); - step.setBatchId(industryStep.getBatchId()); + step.setBatchId(industryStep.getBatchId()); - step.setOperation(0L); - industryStepMapper.updateIndustryStepByBatchId(step); + step.setOperation(0L); + industryStepMapper.updateIndustryStepByBatchId(step); - IndustryStep industryStep1 = new IndustryStep(); - industryStep1.setBatchId(industryStep.getBatchId()); - Long newStep = industryStep.getStep() + 1L; - industryStep1.setStep(newStep); - // 查询下一步还有没有 - List industryStepVos = selectIndustryStepList(industryStep1); - if (industryStepVos.isEmpty()) { - // 等于0说明没有下一步了 通知前端处理下一批 - return 2; - } + IndustryStep industryStep1 = new IndustryStep(); + industryStep1.setBatchId(industryStep.getBatchId()); + Long newStep = industryStep.getStep() + 1L; + industryStep1.setStep(newStep); + // 查询下一步还有没有 + List industryStepVos = selectIndustryStepList(industryStep1); + if (industryStepVos.isEmpty()) { + // 等于0说明没有下一步了 通知前端处理下一批 + return 2; + } - // 如果不为0 说明该批次依然有道次未处理 - // 获取第一个 将其operation改为1 - industryStep1.setOperation(1L); - // 更新一下下一步的状态 - industryStepMapper.updateIndustryStepByBatchId(industryStep1); - // TODO 向plc发送当前道次 - s7PLC.writeInt32("DB16.0", Math.toIntExact(newStep)); - //以及剩余道次 - Long num = industryStepMapper.selectMaxStepNum(industryStep.getBatchId()); + // 如果不为0 说明该批次依然有道次未处理 + // 获取第一个 将其operation改为1 + industryStep1.setOperation(1L); + // 更新一下下一步的状态 + industryStepMapper.updateIndustryStepByBatchId(industryStep1); + // TODO 向plc发送当前道次 + s7PLC.writeInt32("DB16.0", Math.toIntExact(newStep)); + //以及剩余道次 + Long num = industryStepMapper.selectMaxStepNum(industryStep.getBatchId()); 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()); + 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.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")){ + while (s7PLC.readBoolean("DB15.1.2")) { Threads.sleep(500); } @@ -254,16 +254,16 @@ public class IndustryStepServiceImpl implements IIndustryStepService { return 0; } - // 将切换道次改为true - s7PLC.writeBoolean("DB15.1.2",true); - + s7PLC.writeBoolean("DB15.1.2", true); // 判断当前切换是否转化过来成true 没有则再发 - while (!s7PLC.readBoolean("DB15.1.2")){ + 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 IndustryStep step = new IndustryStep(); @@ -302,7 +302,7 @@ public class IndustryStepServiceImpl implements IIndustryStepService { Long materialFlagError = redisCache.getCacheObject("materialFlagError"); redisCache.setCacheObject("nextStepFlagError", 0L, 100, TimeUnit.HOURS); - redisCache.setCacheObject("materialFlagError", materialFlagError==1L?0L:1L, 100, TimeUnit.HOURS); + redisCache.setCacheObject("materialFlagError", materialFlagError == 1L ? 0L : 1L, 100, TimeUnit.HOURS); s7PLC.writeBoolean("DB15.1.2", false); @@ -314,10 +314,12 @@ public class IndustryStepServiceImpl implements IIndustryStepService { } } + while (s7PLC.readBoolean("DB15.1.2")) { Threads.sleep(500); } + return 1; } @@ -337,10 +339,18 @@ public class IndustryStepServiceImpl implements IIndustryStepService { } } + // 将此值写入plc 为辊缝设定和设定输入 + s7PLC.writeFloat32("DB15.118", smallStep.getSetValue().floatValue()); + s7PLC.writeBoolean("DB15.0.3", true); + while (s7PLC.readBoolean("DB15.0.3")) { + s7PLC.writeBoolean("DB15.0.3", false); + } + industryStep.setStep(smallStep.getStep()); industryStep.setOperation(1L); industryStep.setState(null); industryStepMapper.updateAllIndustryStepByStep(industryStep); + return smallStep.getMaterialId(); } @@ -355,7 +365,6 @@ public class IndustryStepServiceImpl implements IIndustryStepService { industryMaterialVo.setBatchId(batchId); industryMaterialVo.setDelFlag(1L); List industryMaterialVos = industryMaterialService.selectAbnormalList(industryMaterialVo); - System.out.println(industryMaterialVos); for (IndustryMaterialVo materialVo : industryMaterialVos) { materialVo.setState(6L); materialVo.setOperation(0L); @@ -572,13 +581,11 @@ public class IndustryStepServiceImpl implements IIndustryStepService { @Override public void start(IndustryStep industryStep) { 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); diff --git a/industry-system/src/main/resources/mapper/work/IndustryStepMapper.xml b/industry-system/src/main/resources/mapper/work/IndustryStepMapper.xml index 202ac02b..17a21c8b 100644 --- a/industry-system/src/main/resources/mapper/work/IndustryStepMapper.xml +++ b/industry-system/src/main/resources/mapper/work/IndustryStepMapper.xml @@ -109,7 +109,7 @@ select count(*) from industry_step step - left join industry.industry_material im on step.material_id = im.id + left join industry_material im on step.material_id = im.id where step.state = 0 and step.del_flag=1 and step.batch_id = #{batchId}