fix: 断连等待时间过长处理、指令编号同步锁

This commit is contained in:
2024-07-30 17:08:46 +08:00
parent 73c0fee1b2
commit 24c61f2fe5
3 changed files with 12 additions and 14 deletions

View File

@@ -232,7 +232,7 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
} catch (Exception var4) {
this.clearServer(code);
log.warn("写入出错opc server {} 重新加载", code, var4);
ThreadUtl.sleep(5000L);
ThreadUtl.sleep(3000L);
throw var4;
}
}

View File

@@ -42,13 +42,9 @@ public class OpcUtl {
Map<Item, Integer> e = null;
try {
e = group.write(requests);
group.write(requests);
// group.write(requests);
} catch (Exception e1) {
try {
e = group.write(requests);
} catch (Exception e2) {
e = group.write(requests);
}
e1.printStackTrace();
}
boolean is_success = true;
@@ -77,7 +73,7 @@ public class OpcUtl {
log.info("下发信号失败:" + message.toString());
throw new BadRequestException(message.toString());
}
} catch (JIException arg7) {
} catch (Exception arg7) {
log.info("下发信号失败:" + arg7.getMessage());
System.out.println("下发信号失败原因:" + arg7.getMessage());
throw new BadRequestException(arg7.toString());

View File

@@ -8,12 +8,14 @@ import java.util.*;
public class CodeUtil {
public static String getNewCode(String ruleCode){
String flag = CommonFinalParam.ONE;
HashMap<String,String> map = new HashMap<>();
map.put("flag",flag);
map.put("code",ruleCode);
return SpringContextHolder.getBean(ISysCodeRuleService.class).codeDemo(map);
public static String getNewCode(String ruleCode) {
synchronized (ruleCode) {
String flag = CommonFinalParam.ONE;
HashMap<String, String> map = new HashMap<>();
map.put("flag", flag);
map.put("code", ruleCode);
return SpringContextHolder.getBean(ISysCodeRuleService.class).codeDemo(map);
}
}