1.增加盘点测试的开放,使用灵闪拍照给669发送trigger:1

2.如果未连接删除连接状态
bozhou-古井贡酒
LAPTOP-S9HJSOEB\昊天 2 years ago
parent 6e864b75c6
commit 88ade194ed

@ -42,6 +42,7 @@ public class ConfigProperties {
private AsyncExecutorThread asyncExecutorThread;
private VisualSense visualSense;
private Integer orderTest = 0;
@Data
public static class VisualSense{

@ -153,9 +153,11 @@ public class CameraService {
if(ok){
camera.setStatus("连接正常");
}else {
CameraConnMap.disConn(camera.getId());
camera.setStatus("未连接");
}
}catch (Exception e){
CameraConnMap.disConn(camera.getId());
camera.setStatus("未连接");
}finally {
latch.countDown();

@ -35,9 +35,10 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;
@ -890,34 +891,66 @@ public class PlcService {
}
} else if (Cmd.D.name().equals(ksecInfo.getType())) {
//柳州去掉告警
// String code = dataInfo.getCmdName();
// if(code.equals(Cmd.D1.name())){
// log.info("plcId:{},warn start",plcCmdInfo.getPlcId());
// //根据告警code转动camera
// String warnCode = dataInfo.getWarnCode();
// if(!StringUtils.isEmpty(warnCode)){
// String warnCode0 = Cmd.D1.name()+"-"+warnCode.split(",")[0];
// plcService.warnAction(plcCmdInfo,warnCode0);
// }
// plcService.warnStart(plcCmdInfo.getPlcId(),dataInfo.getWarnCode());
// }else if(code.equals(Cmd.D2.name())){
// log.info("plcId:{},warn stop",plcCmdInfo.getPlcId());
// plcService.warnStop(plcCmdInfo.getPlcId());
// }else {
// log.info("other D code :{}",code);
// }
} else if (Cmd.E.name().equals(ksecInfo.getType()) ) {
String code = dataInfo.getCmdName();
log.info("盘点指令:{}", ksecInfo);
AlgorithmPojo algorithmPojo = check(plcCmdInfo,ksecInfo.getType(),dataInfo);
ksecInfo.getData().setAckStatus(1);
dataInfo.setResult(algorithmPojo.getResult());
dataInfo.setGoodsTypeResult(algorithmPojo.getGoodsTypeResult());
dataInfo.setGoodsNumberResult(algorithmPojo.getGoodsNumberResult());
log.info("盘点完成");
if(configProperties.getOrderTest() == 0) {
AlgorithmPojo algorithmPojo = check(plcCmdInfo, ksecInfo.getType(), dataInfo);
ksecInfo.getData().setAckStatus(1);
dataInfo.setResult(algorithmPojo.getResult());
dataInfo.setGoodsTypeResult(algorithmPojo.getGoodsTypeResult());
dataInfo.setGoodsNumberResult(algorithmPojo.getGoodsNumberResult());
log.info("盘点完成");
}else {
checkTest(plcCmdInfo, ksecInfo.getType(), dataInfo);
}
}
return dataInfo;
}
private void checkTest(PlcCmdInfo plcCmdInfo, String type, KsecDataInfo dataInfo) {
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
Socket socket = new Socket();
int status = 0;
OutputStream os = null;
InputStream is = null;
try {
socket.connect(new InetSocketAddress(street.getPlcIp(),669),3000);
//socket.setSoTimeout(10000);
os = socket.getOutputStream();
Thread.sleep(100);
String startCmd = "trigger:1";
byte [] bytes = startCmd.getBytes(StandardCharsets.UTF_8);
os.write(bytes);
socket.close();
} catch (IOException e) {
log.error("hik contro time out,ip:{},info:{}",street.getPlcIp(),e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
if(os != null){
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(is != null){
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

@ -103,3 +103,7 @@ asyncExecutorThread:
maxPoolSize: 70
queueCapacity: 99999
namePrefix: "Thread_Pool_Task_Executor"
#订单测试
orderTest: 1
Loading…
Cancel
Save