|
|
|
|
@ -720,29 +720,30 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//进行品规识别,完成进行拍照
|
|
|
|
|
if( stock.getCategory() != null && "20".equals(stock.getCategory())) {
|
|
|
|
|
checkLog.setStatus(StockStatus.OTHER.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.OTHER.getStatus());
|
|
|
|
|
}
|
|
|
|
|
AlgorithmPojo algorithmPojo = sendHttp(street,stock.getDirection(),dataInfo.getTypeNum());
|
|
|
|
|
// if( stock.getCategory() != null && "20".equals(stock.getCategory())) {
|
|
|
|
|
// checkLog.setStatus(StockStatus.OTHER.getStatus());
|
|
|
|
|
// stock.setStatus(StockStatus.OTHER.getStatus());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Boolean algorithmPojo = sendHttp(street,plcCmdInfo);
|
|
|
|
|
if (algorithmPojo!=null){
|
|
|
|
|
if (algorithmPojo.getResult()){
|
|
|
|
|
if (algorithmPojo){
|
|
|
|
|
checkLog.setStatus(StockStatus.SUCCESS.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.SUCCESS.getStatus());
|
|
|
|
|
stock.setCategory(dataInfo.getTypeNum());
|
|
|
|
|
|
|
|
|
|
checkLog.setCategory(dataInfo.getTypeNum());
|
|
|
|
|
// stock.setCategory(dataInfo.getTypeNum());
|
|
|
|
|
//
|
|
|
|
|
// checkLog.setCategory(dataInfo.getTypeNum());
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
checkLog.setStatus(StockStatus.CATEGORY_ERROR.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.CATEGORY_ERROR.getStatus());
|
|
|
|
|
checkLog.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkLog.setPic("http://"+street.getPlcIp()+":9007/pic/"+algorithmPojo.getDeterminePath());
|
|
|
|
|
stock.setCheckPic("http://"+street.getPlcIp()+":9007/pic/"+algorithmPojo.getDeterminePath());
|
|
|
|
|
//
|
|
|
|
|
// checkLog.setPic("http://"+street.getPlcIp()+":9007/pic/"+algorithmPojo.getDeterminePath());
|
|
|
|
|
// stock.setCheckPic("http://"+street.getPlcIp()+":9007/pic/"+algorithmPojo.getDeterminePath());
|
|
|
|
|
}else {
|
|
|
|
|
checkLog.setStatus(StockStatus.CATEGORY_ERROR.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.CATEGORY_ERROR.getStatus());
|
|
|
|
|
checkLog.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
|
@ -752,7 +753,7 @@ public class PlcService {
|
|
|
|
|
stockMapper.insert(stock);
|
|
|
|
|
} else stockMapper.updateById(stock);
|
|
|
|
|
if (algorithmPojo != null) {
|
|
|
|
|
return algorithmPojo.getResult();
|
|
|
|
|
return algorithmPojo;
|
|
|
|
|
}else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@ -930,6 +931,31 @@ public class PlcService {
|
|
|
|
|
return checkLog.getStatus()>2?1:0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean sendHttp(Street street ,PlcCmdInfo plcCmdInfo){
|
|
|
|
|
// 创建RestTemplate实例
|
|
|
|
|
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
|
|
|
|
factory.setConnectTimeout(10000); // 5 seconds
|
|
|
|
|
factory.setReadTimeout(10000); // 5 seconds
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(factory);
|
|
|
|
|
// 定义 URL
|
|
|
|
|
String url = "http://"+street.getPlcIp()+":8097/judge/judge?direction={direction}&separation={separation}";
|
|
|
|
|
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
// 发起 GET 请求
|
|
|
|
|
ResponseEntity<Boolean> response = restTemplate.getForEntity(url, Boolean.class,plcCmdInfo.getLeftRight1(),plcCmdInfo.getSeparation1());
|
|
|
|
|
flag = response.getBody();
|
|
|
|
|
// 输出响应状态码和响应体
|
|
|
|
|
System.out.println("Status Code: " + response.getStatusCode());
|
|
|
|
|
return flag;
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("请求异常",e);
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String join(String[] array, String separator) {
|
|
|
|
|
|