|
|
|
@ -35,9 +35,10 @@ import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.*;
|
|
|
|
import java.io.FileWriter;
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.Socket;
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
@ -890,34 +891,66 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (Cmd.D.name().equals(ksecInfo.getType())) {
|
|
|
|
} 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()) ) {
|
|
|
|
} else if (Cmd.E.name().equals(ksecInfo.getType()) ) {
|
|
|
|
|
|
|
|
|
|
|
|
String code = dataInfo.getCmdName();
|
|
|
|
String code = dataInfo.getCmdName();
|
|
|
|
log.info("盘点指令:{}", ksecInfo);
|
|
|
|
log.info("盘点指令:{}", ksecInfo);
|
|
|
|
AlgorithmPojo algorithmPojo = check(plcCmdInfo,ksecInfo.getType(),dataInfo);
|
|
|
|
if(configProperties.getOrderTest() == 0) {
|
|
|
|
ksecInfo.getData().setAckStatus(1);
|
|
|
|
AlgorithmPojo algorithmPojo = check(plcCmdInfo, ksecInfo.getType(), dataInfo);
|
|
|
|
dataInfo.setResult(algorithmPojo.getResult());
|
|
|
|
ksecInfo.getData().setAckStatus(1);
|
|
|
|
dataInfo.setGoodsTypeResult(algorithmPojo.getGoodsTypeResult());
|
|
|
|
dataInfo.setResult(algorithmPojo.getResult());
|
|
|
|
dataInfo.setGoodsNumberResult(algorithmPojo.getGoodsNumberResult());
|
|
|
|
dataInfo.setGoodsTypeResult(algorithmPojo.getGoodsTypeResult());
|
|
|
|
log.info("盘点完成");
|
|
|
|
dataInfo.setGoodsNumberResult(algorithmPojo.getGoodsNumberResult());
|
|
|
|
|
|
|
|
log.info("盘点完成");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
checkTest(plcCmdInfo, ksecInfo.getType(), dataInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|