|
|
|
|
@ -25,6 +25,7 @@ import com.zhehekeji.web.service.ksec.KsecNettyClient;
|
|
|
|
|
import com.zhehekeji.web.service.sick.SickSocket;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
|
|
|
import org.springframework.http.*;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
@ -1072,34 +1073,51 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
// 创建 HttpEntity 对象
|
|
|
|
|
HttpEntity<TransmissionPojo> entity = new HttpEntity<>(scTransmission, headers);
|
|
|
|
|
|
|
|
|
|
// 发送 POST 请求
|
|
|
|
|
ResponseEntity<Boolean> response = restTemplate.exchange(
|
|
|
|
|
"http://" + street.getPlcIp() + ":8099" + "/api/industrialCamera/matchFeatures",
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Boolean.class
|
|
|
|
|
);
|
|
|
|
|
if (response.getStatusCode() == HttpStatus.OK) {
|
|
|
|
|
// 请求成功
|
|
|
|
|
Boolean responseBody = response.getBody();
|
|
|
|
|
System.out.println("获得的返回:" + responseBody);
|
|
|
|
|
if (Boolean.TRUE.equals(responseBody)) {
|
|
|
|
|
scTransmission.setResult(1);
|
|
|
|
|
try {
|
|
|
|
|
// 发送 POST 请求
|
|
|
|
|
ResponseEntity<Boolean> response = restTemplate.exchange(
|
|
|
|
|
"http://" + street.getPlcIp() + ":8099" + "/api/industrialCamera/matchFeatures",
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Boolean.class
|
|
|
|
|
);
|
|
|
|
|
if (response.getStatusCode() == HttpStatus.OK) {
|
|
|
|
|
// 请求成功
|
|
|
|
|
Boolean responseBody = response.getBody();
|
|
|
|
|
System.out.println("获得的返回:" + responseBody);
|
|
|
|
|
if (Boolean.TRUE.equals(responseBody)) {
|
|
|
|
|
scTransmission.setResult(1);
|
|
|
|
|
} else {
|
|
|
|
|
scTransmission.setResult(0);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
scTransmission.setResult(0);
|
|
|
|
|
// 请求失败
|
|
|
|
|
System.out.println("请求失败,状态码:" + response.getStatusCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// 请求失败
|
|
|
|
|
System.out.println("请求失败,状态码:" + response.getStatusCode());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
scTransmission.setResult(0);
|
|
|
|
|
log.info("请求异常");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return scTransmission;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
RestTemplate restTemplate = new RestTemplateBuilder()
|
|
|
|
|
.setConnectTimeout(Duration.ofSeconds(2)) // 设置连接超时时间,单位毫秒
|
|
|
|
|
.setReadTimeout(Duration.ofSeconds(2)) // 设置读取超时时间,单位毫秒
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
// 使用restTemplate发起请求
|
|
|
|
|
String response = restTemplate.getForObject("http://127.0.0.1:6000/example.com/api/data", String.class);
|
|
|
|
|
System.out.println(response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void visualInventory(SCTransmission scTransmission) {
|
|
|
|
|
String[] location = scTransmission.getGoodsLocation().split("_");
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(
|
|
|
|
|
|