fix:opcutl修改、开盖位查询数据库优化
This commit is contained in:
@@ -202,9 +202,9 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
vehicle_code2 = inst.getVehicle_code2();
|
vehicle_code2 = inst.getVehicle_code2();
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction instruction = instructionService.findByCode(String.valueOf(task));
|
|
||||||
//空箱出库开盖位,申请开盖
|
//空箱出库开盖位,申请开盖
|
||||||
if (mode == 15 && move == 1 && task > 0 ) {
|
if (mode == 15 && move == 1 && task > 0 ) {
|
||||||
|
Instruction instruction = instructionService.findByCode(String.valueOf(task));
|
||||||
//不允许开盖,完成出库任务,自动去扫码位
|
//不允许开盖,完成出库任务,自动去扫码位
|
||||||
if (StrUtil.isEmpty(instruction.getVehicle_code())){
|
if (StrUtil.isEmpty(instruction.getVehicle_code())){
|
||||||
message = "任务托盘码为空";
|
message = "任务托盘码为空";
|
||||||
|
|||||||
@@ -323,14 +323,14 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instruction findByCode(String code) {
|
public Instruction findByCode(String code) {
|
||||||
|
Iterator var3 = instructions.iterator();
|
||||||
InstructionMybatis ins = new LambdaQueryChainWrapper<>(instructionMapper)
|
while (var3.hasNext()) {
|
||||||
.eq(InstructionMybatis::getInstruction_code, code)
|
Instruction instruction = (Instruction) var3.next();
|
||||||
.one();
|
if (StrUtil.equals(instruction.getInstruction_code(), code)) {
|
||||||
if (ObjectUtil.isEmpty(ins)) {
|
return instruction;
|
||||||
return null;
|
}
|
||||||
}
|
}
|
||||||
return ConvertUtil.convert(ins, Instruction.class);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
server.disconnect();
|
server.disconnect();
|
||||||
log.trace("清理server...");
|
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);
|
this.server.addStateListener(this);
|
||||||
group = this.server.addGroup();
|
group = this.server.addGroup();
|
||||||
List<String> itemsString = new ArrayList();
|
List<String> itemsString = new ArrayList();
|
||||||
@@ -322,7 +323,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.server == null) {
|
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);
|
this.server.addStateListener(this);
|
||||||
accessor = new Async20Access(this.server, OpcConfig.synchronized_millisecond, true);
|
accessor = new Async20Access(this.server, OpcConfig.synchronized_millisecond, true);
|
||||||
Iterator var9 = this.protocols.iterator();
|
Iterator var9 = this.protocols.iterator();
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (server == null) {
|
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 {
|
try {
|
||||||
@@ -133,7 +134,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
|||||||
this.clearServer(code);
|
this.clearServer(code);
|
||||||
ThreadUtl.sleep(5000L);
|
ThreadUtl.sleep(5000L);
|
||||||
log.warn("获取opc出错重新获取", code, var12);
|
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 {
|
try {
|
||||||
group = server.addGroup(groupName);
|
group = server.addGroup(groupName);
|
||||||
} catch (Exception var11) {
|
} catch (Exception var11) {
|
||||||
@@ -164,7 +166,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if (server == null) {
|
// 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;
|
String groupName = code;
|
||||||
Group group = null;
|
Group group = null;
|
||||||
@@ -175,7 +178,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
|||||||
this.clearServer(code);
|
this.clearServer(code);
|
||||||
ThreadUtl.sleep(2000L);
|
ThreadUtl.sleep(2000L);
|
||||||
log.warn("获取opc出错重新获取", code, var12);
|
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 {
|
try {
|
||||||
group = server.addGroup(groupName);
|
group = server.addGroup(groupName);
|
||||||
} catch (Exception var11) {
|
} catch (Exception var11) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.openscada.opc.lib.da.Server;
|
|||||||
/**
|
/**
|
||||||
* @author 20220102CG\noblelift
|
* @author 20220102CG\noblelift
|
||||||
*/
|
*/
|
||||||
public class OpcServerUtl {
|
/*public class OpcServerUtl {
|
||||||
|
|
||||||
public static synchronized Server getServerWithOutException(String host, String clsid, String user, String password,
|
public static synchronized Server getServerWithOutException(String host, String clsid, String user, String password,
|
||||||
String domain) {
|
String domain) {
|
||||||
@@ -21,4 +21,4 @@ public class OpcServerUtl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|||||||
Reference in New Issue
Block a user