|
|
|
|
@ -201,35 +201,19 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
|
|
|
|
|
|
|
|
|
|
// 提交一个可调用任务
|
|
|
|
|
PlcCmdInfo finalPlcCmdInfo = plcCmdInfo;
|
|
|
|
|
Future<Boolean> future = threadPoolExecutor.submit(new Callable<Boolean>() {
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean call() throws Exception {
|
|
|
|
|
Boolean ok = plcService.check(finalPlcCmdInfo,ksecInfo.getData().getCmdName(), dataInfo.getCode(), dataInfo.getTrayCode(), dataInfo.getLotnum());
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Boolean result=false;
|
|
|
|
|
try {
|
|
|
|
|
// 尝试在3秒内获取结果
|
|
|
|
|
result = future.get(5, TimeUnit.SECONDS);
|
|
|
|
|
System.out.println("任务完成: " + result);
|
|
|
|
|
} catch (TimeoutException e) {
|
|
|
|
|
System.out.println("任务超时,触发新方法");
|
|
|
|
|
// 触发新的方法
|
|
|
|
|
Boolean ok = plcService.check(finalPlcCmdInfo,ksecInfo.getData().getCmdName(), dataInfo.getCode(), dataInfo.getTrayCode(), dataInfo.getLotnum());
|
|
|
|
|
|
|
|
|
|
Boolean result=ok;
|
|
|
|
|
|
|
|
|
|
if (!result){
|
|
|
|
|
ksecInfo.getData().setAckStatus(0);
|
|
|
|
|
}else {
|
|
|
|
|
ksecInfo.getData().setAckStatus(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 取消原任务,但允许其继续运行
|
|
|
|
|
future.cancel(false);
|
|
|
|
|
} catch (InterruptedException | ExecutionException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally {
|
|
|
|
|
|
|
|
|
|
ctx.channel().writeAndFlush(ksecInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//log.info("盘点结束:"+ksecInfo.getData().toString());
|
|
|
|
|
}
|
|
|
|
|
|