|
|
|
@ -32,14 +32,21 @@ import org.apache.commons.collections4.SetUtils;
|
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
import org.apache.poi.util.ArrayUtil;
|
|
|
|
import org.apache.poi.util.ArrayUtil;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
|
|
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
|
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.io.*;
|
|
|
|
import java.io.*;
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
import java.net.Socket;
|
|
|
|
import java.net.Socket;
|
|
|
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
@ -108,6 +115,15 @@ public class PlcService {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private RfidLiveService rfidLiveService;
|
|
|
|
private RfidLiveService rfidLiveService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private RestTemplate restTemplate ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private Environment environment;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Map<String, Set<String>> wmsTrayCodeMapByTask = new HashMap<>();
|
|
|
|
public static Map<String, Set<String>> wmsTrayCodeMapByTask = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 8, 200, TimeUnit.MINUTES, new ArrayBlockingQueue<>(100000));
|
|
|
|
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 8, 200, TimeUnit.MINUTES, new ArrayBlockingQueue<>(100000));
|
|
|
|
@ -251,14 +267,48 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
|
|
public String cameraVideo(Integer cameraId, LocalDateTime startTime, LocalDateTime endTime) {
|
|
|
|
public String cameraVideo(Integer cameraId, LocalDateTime startTime, LocalDateTime endTime) {
|
|
|
|
String path = PathUtil.createFileName("mp4", cameraId);
|
|
|
|
String path = PathUtil.createFileName("mp4", cameraId);
|
|
|
|
Thread thread = new Thread(new Runnable() {
|
|
|
|
if(configProperties.getCameraConfig().getDownloadType() == 1){
|
|
|
|
@Override
|
|
|
|
String finalPath = path;
|
|
|
|
public void run() {
|
|
|
|
Thread thread = new Thread(new Runnable() {
|
|
|
|
String realPath = configProperties.getSavePath().getMp4Path() + path;
|
|
|
|
@Override
|
|
|
|
TaskDelayExecutor.addMp4DelayTask(cameraId, realPath, startTime, endTime, configProperties.getCameraConfig().getDelayDownloadMp4());
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
String realPath = configProperties.getSavePath().getMp4Path() + finalPath;
|
|
|
|
|
|
|
|
TaskDelayExecutor.addMp4DelayTask(cameraId, realPath, startTime, endTime, configProperties.getCameraConfig().getDelayDownloadMp4());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
thread.start();
|
|
|
|
|
|
|
|
}else if(configProperties.getCameraConfig().getDownloadType() == 0){
|
|
|
|
|
|
|
|
Street street = streetService.getOne(new QueryWrapper<Street>().eq("camera1_Id",cameraId).or().eq("camera2_Id",cameraId));
|
|
|
|
|
|
|
|
if(street != null){
|
|
|
|
|
|
|
|
// 设置请求URL
|
|
|
|
|
|
|
|
String url = "http://"+street.getPlcIp()+":"+environment.getProperty("server.port")+"/api/camera/control/mp4/delay";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置请求头
|
|
|
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置请求体
|
|
|
|
|
|
|
|
CameraDownload cameraDownload = new CameraDownload();
|
|
|
|
|
|
|
|
cameraDownload.setId(cameraId);
|
|
|
|
|
|
|
|
cameraDownload.setStartTime(startTime);
|
|
|
|
|
|
|
|
cameraDownload.setIp(street.getPlcIp());
|
|
|
|
|
|
|
|
cameraDownload.setPort(environment.getProperty("server.port"));
|
|
|
|
|
|
|
|
cameraDownload.setEndTime(endTime);
|
|
|
|
|
|
|
|
// 创建HttpEntity对象
|
|
|
|
|
|
|
|
HttpEntity<CameraDownload> requestEntity = new HttpEntity<>(cameraDownload, headers);
|
|
|
|
|
|
|
|
restTemplate.getMessageConverters().add(new StringHttpMessageConverter(Charset.forName("utf-8")));
|
|
|
|
|
|
|
|
// 发起POST请求,获取响应数据
|
|
|
|
|
|
|
|
path = restTemplate.postForObject(url, requestEntity, String.class);
|
|
|
|
|
|
|
|
path = "http://"+street.getPlcIp()+":9007/api/mp4/"+path;
|
|
|
|
|
|
|
|
// 输出响应数据
|
|
|
|
|
|
|
|
System.out.println(path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
log.error("camera:{}未绑定巷道,无法远程下载",cameraId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
thread.start();
|
|
|
|
|
|
|
|
//cameraControlModule.downloadMp4(cameraId,realPath,startTime,endTime);
|
|
|
|
//cameraControlModule.downloadMp4(cameraId,realPath,startTime,endTime);
|
|
|
|
return path;
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -651,9 +701,9 @@ public class PlcService {
|
|
|
|
//核对异常
|
|
|
|
//核对异常
|
|
|
|
Integer status = 1;
|
|
|
|
Integer status = 1;
|
|
|
|
//托盘和货物都正确
|
|
|
|
//托盘和货物都正确
|
|
|
|
if (algorithmPojo.getResult() == 1
|
|
|
|
if (algorithmPojo != null && algorithmPojo.getResult() != null && algorithmPojo.getResult() == 1
|
|
|
|
&& algorithmPojo.getGoodsNumber().equals(algorithmPojo.getGoodsNumberResult())
|
|
|
|
&& algorithmPojo.getGoodsNumber() != null && algorithmPojo.getGoodsNumber().equals(algorithmPojo.getGoodsNumberResult())
|
|
|
|
&& algorithmPojo.getGoodsType().equals(algorithmPojo.getGoodsTypeResult())) {
|
|
|
|
&& algorithmPojo.getGoodsType() != null && algorithmPojo.getGoodsType().equals(algorithmPojo.getGoodsTypeResult())) {
|
|
|
|
status = 2;
|
|
|
|
status = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (stock == null) {
|
|
|
|
if (stock == null) {
|
|
|
|
@ -889,7 +939,7 @@ public class PlcService {
|
|
|
|
OutputStream os = null;
|
|
|
|
OutputStream os = null;
|
|
|
|
InputStream is = null;
|
|
|
|
InputStream is = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
socket.connect(new InetSocketAddress(street.getPlcIp(), street.getPlcPort()), 3000);
|
|
|
|
socket.connect(new InetSocketAddress(street.getPlcIp(), 9040), 3000);
|
|
|
|
//socket.setSoTimeout(10000);
|
|
|
|
//socket.setSoTimeout(10000);
|
|
|
|
os = socket.getOutputStream();
|
|
|
|
os = socket.getOutputStream();
|
|
|
|
Thread.sleep(100);
|
|
|
|
Thread.sleep(100);
|
|
|
|
|