|
|
|
|
@ -39,6 +39,7 @@ import java.nio.charset.Charset;
|
|
|
|
|
import java.nio.charset.CharsetEncoder;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.ArrayBlockingQueue;
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
@ -688,7 +689,7 @@ public class PlcService {
|
|
|
|
|
//默认未盘点
|
|
|
|
|
checkLog.setStatus(StockStatus.PENDING.getStatus());
|
|
|
|
|
checkLog.setCreateTime(LocalDateTime.now());
|
|
|
|
|
checkLog.setWmsTrayCode(dataInfo.getTypeNum());
|
|
|
|
|
checkLog.setWmsTrayCode(dataInfo.getTrayCode());
|
|
|
|
|
checkLog.setWmsCount(dataInfo.getQuantity());
|
|
|
|
|
checkLog.setWmsCategory(dataInfo.getTypeNum());
|
|
|
|
|
|
|
|
|
|
@ -714,20 +715,27 @@ public class PlcService {
|
|
|
|
|
stock.setCount(dataInfo.getQuantity());
|
|
|
|
|
stock.setWmsCategoryName(dataInfo.getCategoryName());
|
|
|
|
|
stock.setTaskId((dataInfo.getTaskId()));
|
|
|
|
|
stock.setWmsTrayCode(dataInfo.getTrayCode());
|
|
|
|
|
//默认未盘点
|
|
|
|
|
if(stock.getCategory().length() == 6) {
|
|
|
|
|
stock.setStatus(StockStatus.PENDING.getStatus());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//进行品规识别,完成进行拍照
|
|
|
|
|
// if( stock.getCategory() != null && "20".equals(stock.getCategory())) {
|
|
|
|
|
// checkLog.setStatus(StockStatus.OTHER.getStatus());
|
|
|
|
|
// stock.setStatus(StockStatus.OTHER.getStatus());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//algorithmPojo true为无货位,false为有货位
|
|
|
|
|
Boolean algorithmPojo = sendHttp(street,plcCmdInfo);
|
|
|
|
|
if (algorithmPojo!=null){
|
|
|
|
|
if (algorithmPojo){
|
|
|
|
|
// 获取当前日期时间
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
|
|
|
|
// 定义格式化模式
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
// 格式化为字符串
|
|
|
|
|
String formattedDate = now.format(formatter);
|
|
|
|
|
if (algorithmPojo!=null ){
|
|
|
|
|
if (algorithmPojo.equals(Objects.equals(dataInfo.getTrayCode(), "0"))){
|
|
|
|
|
checkLog.setStatus(StockStatus.SUCCESS.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.SUCCESS.getStatus());
|
|
|
|
|
// stock.setCategory(dataInfo.getTypeNum());
|
|
|
|
|
@ -739,8 +747,8 @@ public class PlcService {
|
|
|
|
|
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/"+formattedDate+"/"+plcCmdInfo.getTaskId()+".png");
|
|
|
|
|
stock.setCheckPic("http://"+street.getPlcIp()+":9007/pic/"+formattedDate+"/"+plcCmdInfo.getTaskId()+".png");
|
|
|
|
|
}else {
|
|
|
|
|
checkLog.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
@ -930,21 +938,18 @@ public class PlcService {
|
|
|
|
|
stockMapper.updateById(stock);
|
|
|
|
|
return checkLog.getStatus()>2?1:0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
RestTemplate restTemplate;
|
|
|
|
|
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}";
|
|
|
|
|
String url = "http://"+street.getPlcIp()+":8097/judge/judge?direction={direction}&separation={separation}&taskId={taskId}";
|
|
|
|
|
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
// 发起 GET 请求
|
|
|
|
|
ResponseEntity<Boolean> response = restTemplate.getForEntity(url, Boolean.class,plcCmdInfo.getLeftRight1(),plcCmdInfo.getSeparation1());
|
|
|
|
|
ResponseEntity<Boolean> response = restTemplate.getForEntity(url, Boolean.class,plcCmdInfo.getLeftRight1(),plcCmdInfo.getSeparation1(),plcCmdInfo.getTaskId());
|
|
|
|
|
flag = response.getBody();
|
|
|
|
|
// 输出响应状态码和响应体
|
|
|
|
|
System.out.println("Status Code: " + response.getStatusCode());
|
|
|
|
|
|