修改为有货无货

淮阴-烟草
LAPTOP-S9HJSOEB\昊天 9 months ago
parent ff86044184
commit 1950dec57c

@ -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) {

@ -183,6 +183,7 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
if (Cmd.E1.name().equals(cmdName)){
boolean f = plcService.check(plcCmdInfo, dataInfo);
// 1为有货0为无货
ksecInfo.getData().setCheckRlt(f?1:0);
ksecInfo.getData().setCmdName("E2");
KsecNettyClient.write(ksecInfo);
@ -199,7 +200,7 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
}else if (Cmd.SC.name().equals(ksecInfo.getType())) {
//站台盘点
plcService.check(plcCmdInfo, dataInfo);
// plcService.check(plcCmdInfo, dataInfo);
}
//找到该货位的最后一张照片与现在的照片比照

Loading…
Cancel
Save