|
|
|
|
@ -26,6 +26,7 @@ import io.swagger.models.auth.In;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
@ -279,33 +280,38 @@ public class PlcService {
|
|
|
|
|
} else {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC2OutDelayCaptureTime();
|
|
|
|
|
}
|
|
|
|
|
sendHttp( street,plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
|
|
//拍照拉平
|
|
|
|
|
} else if (code.startsWith("C3")) {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC3DelayCaptureTime();
|
|
|
|
|
|
|
|
|
|
} else if (code.startsWith("C4")) {
|
|
|
|
|
//拍照拉平
|
|
|
|
|
|
|
|
|
|
if (sep == 1) {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC4DelayCaptureTime();
|
|
|
|
|
} else {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC4OutDelayCaptureTime();
|
|
|
|
|
}
|
|
|
|
|
sendHttp( street,plcCmdInfo.getLeftRight2());
|
|
|
|
|
}
|
|
|
|
|
path = PathUtil.createFileNameByRowColumn("jpg", cameraId, row, column);
|
|
|
|
|
path = cameraCapture(cameraId, delay, delayTime, path);
|
|
|
|
|
// path = PathUtil.createFileNameByRowColumn("jpg", cameraId, row, column);
|
|
|
|
|
// path = cameraCapture(cameraId, delay, delayTime, path);
|
|
|
|
|
}
|
|
|
|
|
//update order info after capture
|
|
|
|
|
if (path != null && needCapture) {
|
|
|
|
|
captureUpdateOrderAndStock(orderInfo, path);
|
|
|
|
|
}
|
|
|
|
|
//转向原点位
|
|
|
|
|
if (times == 2) {
|
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera2Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
}
|
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera1Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// if (path != null && needCapture) {
|
|
|
|
|
// captureUpdateOrderAndStock(orderInfo, path);
|
|
|
|
|
// }
|
|
|
|
|
// //转向原点位
|
|
|
|
|
// if (times == 2) {
|
|
|
|
|
// if (street.getCamera2Id() != null) {
|
|
|
|
|
// gyrateCameraByCodeTimeLater(street.getCamera2Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
// }
|
|
|
|
|
// if (street.getCamera1Id() != null) {
|
|
|
|
|
// gyrateCameraByCodeTimeLater(street.getCamera1Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void gyrateCamera(PlcCmdInfo plcCmdInfo, String code) {
|
|
|
|
|
@ -695,7 +701,7 @@ public class PlcService {
|
|
|
|
|
stock = new Stock();
|
|
|
|
|
}
|
|
|
|
|
stock.setStreetId(street.getId());
|
|
|
|
|
stock.setCheckNum(checkLog.getId().toString());
|
|
|
|
|
|
|
|
|
|
stock.setLotnum(dataInfo.getLotnum());
|
|
|
|
|
stock.setDirection(dataInfo.getFromDirection());
|
|
|
|
|
stock.setSide(dataInfo.getFromSide());
|
|
|
|
|
@ -733,9 +739,13 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
checkLog.setPic("http://"+street.getPlcIp()+":9007/pic/"+algorithmPojo.getDeterminePath());
|
|
|
|
|
stock.setCheckPic("http://"+street.getPlcIp()+":9007/pic/"+algorithmPojo.getDeterminePath());
|
|
|
|
|
}else {
|
|
|
|
|
checkLog.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
|
stock.setCheckNum(checkLog.getId().toString());
|
|
|
|
|
stock.setExportTime(LocalDateTime.now());
|
|
|
|
|
if (stock.getId() == null) {
|
|
|
|
|
stockMapper.insert(stock);
|
|
|
|
|
@ -804,10 +814,14 @@ public class PlcService {
|
|
|
|
|
checkLogMapper.updateById(checkLog);
|
|
|
|
|
stockMapper.updateById(stock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static AlgorithmPojo sendHttp(Street street,Integer direction , String category ){
|
|
|
|
|
// 创建RestTemplate实例
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
|
|
|
|
|
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
|
|
|
|
factory.setConnectTimeout(5000); // 5 seconds
|
|
|
|
|
factory.setReadTimeout(5000); // 5 seconds
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(factory);
|
|
|
|
|
// 定义请求URL
|
|
|
|
|
String url = "http://"+street.getPlcIp()+":8097/hik/distinguish?streetNumber={streetNumber}&direction={direction}&category={category}";
|
|
|
|
|
|
|
|
|
|
@ -815,7 +829,48 @@ public class PlcService {
|
|
|
|
|
// 替换为实际的category
|
|
|
|
|
|
|
|
|
|
// 发送GET请求并获取响应
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
ResponseEntity<AlgorithmPojo> response = restTemplate.getForEntity(url, AlgorithmPojo.class, street.getPlcId(),direction, category);
|
|
|
|
|
// 输出响应结果
|
|
|
|
|
if (response.getStatusCode().is2xxSuccessful()) {
|
|
|
|
|
System.out.println("Distinguish result: " + response);
|
|
|
|
|
return response.getBody();
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("Failed to get response. Status code: " + response.getStatusCode());
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("sendHttp error",e);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
Street street = new Street();
|
|
|
|
|
street.setPlcIp("127.0.0.1");
|
|
|
|
|
sendHttp(street,1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static AlgorithmPojo sendHttp(Street street,Integer direction ){
|
|
|
|
|
// 创建RestTemplate实例
|
|
|
|
|
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
|
|
|
|
factory.setConnectTimeout(5000); // 5 seconds
|
|
|
|
|
factory.setReadTimeout(5000); // 5 seconds
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(factory);
|
|
|
|
|
|
|
|
|
|
// 定义请求URL
|
|
|
|
|
String url = "http://"+street.getPlcIp()+":8097/hik/calibration?direction={direction}";
|
|
|
|
|
|
|
|
|
|
// 定义请求参数
|
|
|
|
|
// 替换为实际的category
|
|
|
|
|
|
|
|
|
|
// 发送GET请求并获取响应
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
// 发送GET请求并获取响应
|
|
|
|
|
ResponseEntity<AlgorithmPojo> response = restTemplate.getForEntity(url, AlgorithmPojo.class, direction);
|
|
|
|
|
|
|
|
|
|
// 输出响应结果
|
|
|
|
|
if (response.getStatusCode().is2xxSuccessful()) {
|
|
|
|
|
@ -827,13 +882,21 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("sendHttp error",e);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int sendHttp(String streetNumber,PlcCmdInfo plcCmdInfo, KsecDataInfo dataInfo){
|
|
|
|
|
Street street = streetService.getStreetByPlcId(streetNumber);
|
|
|
|
|
// 创建 RestTemplate 实例
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
|
|
|
|
|
// 创建RestTemplate实例
|
|
|
|
|
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
|
|
|
|
factory.setConnectTimeout(5000); // 5 seconds
|
|
|
|
|
factory.setReadTimeout(5000); // 5 seconds
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(factory);
|
|
|
|
|
// 定义 URL
|
|
|
|
|
String url = "http://"+street.getPlcIp()+":8097/category/getBoxCountByCategory?streetId={streetNumber}&category={category}";
|
|
|
|
|
|
|
|
|
|
|