fix:opcutl修改、开盖位查询数据库优化

This commit is contained in:
2024-08-23 12:06:19 +08:00
parent e7acfbf034
commit ca8c658cd7
5 changed files with 22 additions and 16 deletions

View File

@@ -202,9 +202,9 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
vehicle_code2 = inst.getVehicle_code2();
}
Instruction instruction = instructionService.findByCode(String.valueOf(task));
//空箱出库开盖位,申请开盖
if (mode == 15 && move == 1 && task > 0 ) {
Instruction instruction = instructionService.findByCode(String.valueOf(task));
//不允许开盖,完成出库任务,自动去扫码位
if (StrUtil.isEmpty(instruction.getVehicle_code())){
message = "任务托盘码为空";

View File

@@ -323,14 +323,14 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public Instruction findByCode(String code) {
InstructionMybatis ins = new LambdaQueryChainWrapper<>(instructionMapper)
.eq(InstructionMybatis::getInstruction_code, code)
.one();
if (ObjectUtil.isEmpty(ins)) {
return null;
Iterator var3 = instructions.iterator();
while (var3.hasNext()) {
Instruction instruction = (Instruction) var3.next();
if (StrUtil.equals(instruction.getInstruction_code(), code)) {
return instruction;
}
}
return ConvertUtil.convert(ins, Instruction.class);
return null;
}
@Override

View File

@@ -105,7 +105,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
server.disconnect();
log.trace("清理server...");
}
this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
// this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
this.server = OpcUtl.getServer(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
this.server.addStateListener(this);
group = this.server.addGroup();
List<String> itemsString = new ArrayList();
@@ -322,7 +323,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
try {
if (this.server == null) {
this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
// this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
this.server = OpcUtl.getServer(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
this.server.addStateListener(this);
accessor = new Async20Access(this.server, OpcConfig.synchronized_millisecond, true);
Iterator var9 = this.protocols.iterator();

View File

@@ -124,7 +124,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
// }
if (server == null) {
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
// server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
server = OpcUtl.getServer(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
}
try {
@@ -133,7 +134,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
this.clearServer(code);
ThreadUtl.sleep(5000L);
log.warn("获取opc出错重新获取", code, var12);
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
// server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
server = OpcUtl.getServer(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
try {
group = server.addGroup(groupName);
} catch (Exception var11) {
@@ -164,7 +166,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
}
// if (server == null) {
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
// server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
server = OpcUtl.getServer(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
// }
String groupName = code;
Group group = null;
@@ -175,7 +178,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
this.clearServer(code);
ThreadUtl.sleep(2000L);
log.warn("获取opc出错重新获取", code, var12);
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
// server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
server = OpcUtl.getServer(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
try {
group = server.addGroup(groupName);
} catch (Exception var11) {

View File

@@ -6,7 +6,7 @@ import org.openscada.opc.lib.da.Server;
/**
* @author 20220102CG\noblelift
*/
public class OpcServerUtl {
/*public class OpcServerUtl {
public static synchronized Server getServerWithOutException(String host, String clsid, String user, String password,
String domain) {
@@ -21,4 +21,4 @@ public class OpcServerUtl {
}
}
}
}*/