|
|
|
|
@ -36,7 +36,9 @@ import javax.annotation.PostConstruct;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
@ -342,11 +344,14 @@ public class PlcService {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("cameraId error:{}", cameraId);
|
|
|
|
|
}
|
|
|
|
|
if (needCapture) {
|
|
|
|
|
Boolean delay = true;
|
|
|
|
|
Integer row = 0;
|
|
|
|
|
Integer column = 0;
|
|
|
|
|
Integer sep = 0;
|
|
|
|
|
|
|
|
|
|
long delayTime = 0;
|
|
|
|
|
if (needCapture) {
|
|
|
|
|
|
|
|
|
|
if (times <= 2) {
|
|
|
|
|
row = plcCmdInfo.getRow1();
|
|
|
|
|
column = plcCmdInfo.getColumn1();
|
|
|
|
|
@ -356,7 +361,6 @@ public class PlcService {
|
|
|
|
|
column = plcCmdInfo.getColumn2();
|
|
|
|
|
sep = plcCmdInfo.getSeparation2();
|
|
|
|
|
}
|
|
|
|
|
long delayTime = 0;
|
|
|
|
|
|
|
|
|
|
if (code.startsWith("C1")) {
|
|
|
|
|
|
|
|
|
|
@ -367,26 +371,7 @@ public class PlcService {
|
|
|
|
|
} else {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC2OutDelayCaptureTime();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
headers.set("Content-Type", "application/json");
|
|
|
|
|
headers.set("User-Agent", "Mozilla/5.0");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TransmissionPojo scTransmission = new TransmissionPojo(street, plcCmdInfo.getRow2(), plcCmdInfo.getColumn2(), plcCmdInfo.getLeftRight2(), plcCmdInfo.getTaskId());
|
|
|
|
|
// 创建 HttpEntity 对象
|
|
|
|
|
HttpEntity<TransmissionPojo> entity = new HttpEntity<>(scTransmission, headers);
|
|
|
|
|
|
|
|
|
|
// 发送 POST 请求
|
|
|
|
|
ResponseEntity<Boolean> response = restTemplate.exchange(
|
|
|
|
|
"http://" + street.getPlcIp() + ":8099" + "/api/industrialCamera/actionType",
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Boolean.class
|
|
|
|
|
);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("3D get pcd error", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (code.startsWith("C3")) {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC3DelayCaptureTime();
|
|
|
|
|
@ -415,6 +400,32 @@ public class PlcService {
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera1Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (code.startsWith("C2")) {
|
|
|
|
|
//延迟后拍照
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(delayTime);
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
headers.set("Content-Type", "application/json");
|
|
|
|
|
headers.set("User-Agent", "Mozilla/5.0");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TransmissionPojo scTransmission = new TransmissionPojo(street, plcCmdInfo.getRow2(), plcCmdInfo.getColumn2(), plcCmdInfo.getLeftRight2(), plcCmdInfo.getTaskId());
|
|
|
|
|
// 创建 HttpEntity 对象
|
|
|
|
|
HttpEntity<TransmissionPojo> entity = new HttpEntity<>(scTransmission, headers);
|
|
|
|
|
|
|
|
|
|
// 发送 POST 请求
|
|
|
|
|
ResponseEntity<Boolean> response = restTemplate.exchange(
|
|
|
|
|
"http://" + street.getPlcIp() + ":8099" + "/api/industrialCamera/actionType",
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Boolean.class
|
|
|
|
|
);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("3D get pcd error", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void gyrateCamera(PlcCmdInfo plcCmdInfo, String code) {
|
|
|
|
|
@ -773,19 +784,19 @@ public class PlcService {
|
|
|
|
|
} catch (ExecutionException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
String path2D = "http://" + street.getPlcIp() + ":8099/api/"
|
|
|
|
|
|
|
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
String path2D = "http://" + street.getPlcIp() + ":9007/api/pic/"
|
|
|
|
|
+ "industrialCamera/"
|
|
|
|
|
+ street.getPlcId() + "/"
|
|
|
|
|
+ checkLog.getLotnum() + "/"
|
|
|
|
|
+ checkLog.getId() + "/"
|
|
|
|
|
+ checkLog.getRow() + "/"
|
|
|
|
|
+ checkLog.getColumn() + "/"
|
|
|
|
|
+ currentDate.format(formatter) + "/"
|
|
|
|
|
+ checkLog.getRow() + "-"
|
|
|
|
|
+ checkLog.getColumn() + "-"
|
|
|
|
|
+ checkLog.getDirection().toString() + "/";
|
|
|
|
|
//结果
|
|
|
|
|
String filePath = path2D + street.getIndustrialCamera() + ".jpeg";
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode);
|
|
|
|
|
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getLeftRight1(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
|
|
|
|
|
String scanCode = null;
|
|
|
|
|
|
|
|
|
|
//货物使用球机扫码
|
|
|
|
|
@ -799,6 +810,8 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
checkLog.setStatus(status);
|
|
|
|
|
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getLeftRight1(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
|
|
|
|
|
|
|
|
|
|
checkLogMapper.updateById(checkLog);
|
|
|
|
|
if (stock == null) {
|
|
|
|
|
stock = Stock.builder()
|
|
|
|
|
@ -816,9 +829,7 @@ public class PlcService {
|
|
|
|
|
.status(status)
|
|
|
|
|
.checkPic(path)
|
|
|
|
|
.preoperationPic(filePath)
|
|
|
|
|
.statusVision(checkLog.getStatusVision())
|
|
|
|
|
.count(checkLog.getCount())
|
|
|
|
|
.category(checkLog.getCategory())
|
|
|
|
|
|
|
|
|
|
.exportTime(LocalDateTime.now()).build();
|
|
|
|
|
stockMapper.insert(stock);
|
|
|
|
|
} else {
|
|
|
|
|
@ -827,9 +838,6 @@ public class PlcService {
|
|
|
|
|
stock.setExportTime(LocalDateTime.now());
|
|
|
|
|
stock.setCheckPic(path);
|
|
|
|
|
|
|
|
|
|
stock.setStatusVision(checkLog.getStatusVision());
|
|
|
|
|
stock.setCount(checkLog.getCount());
|
|
|
|
|
stock.setCategory(checkLog.getCategory());
|
|
|
|
|
stock.setCheckNum(plcCmdInfo.getOrderNum());
|
|
|
|
|
stock.setTrayCode(checkLog.getTrayCode());
|
|
|
|
|
stock.setWmsTrayCode(wmsTrayCode);
|
|
|
|
|
@ -927,28 +935,9 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
} else if (type == 4) {
|
|
|
|
|
TransmissionPojo transmissionPojo = new TransmissionPojo(checkLog, street);
|
|
|
|
|
if (ClientChanel.get(plcCmdInfo.getPlcId()) != null) {
|
|
|
|
|
ClientChanel.get(plcCmdInfo.getPlcId()).writeAndFlush(transmissionPojo.toString(TransmissionType.ST));
|
|
|
|
|
} else {
|
|
|
|
|
log.error("未找到对应plc" + transmissionPojo.toString());
|
|
|
|
|
}
|
|
|
|
|
//取货完成进行拍照
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(50L);
|
|
|
|
|
//不为其他状态进入队列
|
|
|
|
|
if (lock.tryLock()) {
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
getPhotoDelayExecutor.communicationFactory(street.getPlcId(), transmissionPojo.toString(TransmissionType.GPS), configProperties.getQueueSpanTime(), transmissionPojo, checkLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
log.error("取图命令 error", e);
|
|
|
|
|
} finally {
|
|
|
|
|
lock.unlock();
|
|
|
|
|
log.info("盘点完成");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (checkLog.getTrayCode() != null && !"".equals(checkLog.getTrayCode())) {
|
|
|
|
|
|
|
|
|
|
checkLog.setTrayCode(checkLog.getTrayCode() + trayCode);
|
|
|
|
|
|