南通返回格式修改

不再使用线程处理
湖北-大华摄像头
LAPTOP-S9HJSOEB\昊天 1 year ago
parent aa12f448f4
commit 5414bc81f8

@ -658,7 +658,7 @@ public class PlcService {
gyrateCameraByCode(cameraIdQt, "E1");
//球机拍照
try {
Thread.sleep(3000);
Thread.sleep(4000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}

@ -1,10 +1,11 @@
package com.zhehekeji.web.service.ksec;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class KsecDataInfo {
@JSONField(name = "SRMNumber")
private String SRMNumber;
private String cmdName;

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

@ -1,5 +1,6 @@
package com.zhehekeji.web.service.ksec;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -13,6 +14,12 @@ public class KsecInfo {
private KsecDataInfo data;
public static void main(String[] args) {
KsecDataInfo ksecDataInfo = new KsecDataInfo();
ksecDataInfo.setSRMNumber("001");
System.out.println(JSONObject.toJSONString(ksecDataInfo));
}
/**
*
* @return

Loading…
Cancel
Save