bug尝试修复

This commit is contained in:
2025-07-14 12:11:51 +08:00
parent 25468c298c
commit 83650f6bb3
4 changed files with 80 additions and 61 deletions

View File

@@ -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);
}
}

View File

@@ -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<IndustryMaterialVo> 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);
// 向上升并且已经升到头了

View File

@@ -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<IndustryStepVo> 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<IndustryStepVo> 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<IndustryMaterialVo> 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<IndustryStepVo> 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);

View File

@@ -109,7 +109,7 @@
<select id="finishCheck" resultType="java.lang.Long">
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=0
and step.batch_id = #{batchId}
@@ -120,7 +120,7 @@
<select id="finishCheckAbnormal" resultType="java.lang.Long">
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}