|
|
|
@ -53,10 +53,7 @@ import java.nio.charset.StandardCharsets;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.concurrent.ArrayBlockingQueue;
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
import java.util.concurrent.BlockingDeque;
|
|
|
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -118,8 +115,7 @@ public class PlcService {
|
|
|
|
private RfidLiveService rfidLiveService;
|
|
|
|
private RfidLiveService rfidLiveService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private RestTemplate restTemplate ;
|
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
@ -157,7 +153,7 @@ public class PlcService {
|
|
|
|
public void orderStart(PlcCmdInfo plcCmdInfo) {
|
|
|
|
public void orderStart(PlcCmdInfo plcCmdInfo) {
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
//打开光源
|
|
|
|
//打开光源
|
|
|
|
streetController.openStreetLightSource( street.getId());
|
|
|
|
streetController.openStreetLightSource(street.getId());
|
|
|
|
|
|
|
|
|
|
|
|
Integer cameraId = (plcCmdInfo.getFromAround() == 1) ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
Integer cameraId = (plcCmdInfo.getFromAround() == 1) ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
gyrateCameraByCode(cameraId, "C5", plcCmdInfo.getTaskId());
|
|
|
|
gyrateCameraByCode(cameraId, "C5", plcCmdInfo.getTaskId());
|
|
|
|
@ -233,7 +229,7 @@ public class PlcService {
|
|
|
|
Street street = streetMapper.selectById(order.getStreetId());
|
|
|
|
Street street = streetMapper.selectById(order.getStreetId());
|
|
|
|
|
|
|
|
|
|
|
|
//关闭光源
|
|
|
|
//关闭光源
|
|
|
|
Thread thread = new Thread(()->{
|
|
|
|
Thread thread = new Thread(() -> {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Thread.sleep(10000);
|
|
|
|
Thread.sleep(10000);
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
@ -264,7 +260,6 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void orderStopByWarn(String orderNum) {
|
|
|
|
public void orderStopByWarn(String orderNum) {
|
|
|
|
Order order = orderMapper.getOneByOrderNum(orderNum);
|
|
|
|
Order order = orderMapper.getOneByOrderNum(orderNum);
|
|
|
|
if (order == null) {
|
|
|
|
if (order == null) {
|
|
|
|
@ -278,12 +273,13 @@ public class PlcService {
|
|
|
|
upd.setStatus(1);
|
|
|
|
upd.setStatus(1);
|
|
|
|
orderMapper.updateById(upd);
|
|
|
|
orderMapper.updateById(upd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private TaskDelayExecutor taskDelayExecutor;
|
|
|
|
private TaskDelayExecutor taskDelayExecutor;
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
if(configProperties.getCameraConfig().getDownloadType() == 1){
|
|
|
|
if (configProperties.getCameraConfig().getDownloadType() == 1) {
|
|
|
|
String finalPath = path;
|
|
|
|
String finalPath = path;
|
|
|
|
Thread thread = new Thread(new Runnable() {
|
|
|
|
Thread thread = new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -293,11 +289,11 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
thread.start();
|
|
|
|
thread.start();
|
|
|
|
}else if(configProperties.getCameraConfig().getDownloadType() == 0){
|
|
|
|
} else if (configProperties.getCameraConfig().getDownloadType() == 0) {
|
|
|
|
Street street = streetService.getOne(new QueryWrapper<Street>().eq("camera1_Id",cameraId).or().eq("camera2_Id",cameraId));
|
|
|
|
Street street = streetService.getOne(new QueryWrapper<Street>().eq("camera1_Id", cameraId).or().eq("camera2_Id", cameraId));
|
|
|
|
if(street != null){
|
|
|
|
if (street != null) {
|
|
|
|
// 设置请求URL
|
|
|
|
// 设置请求URL
|
|
|
|
String url = "http://"+street.getPlcIp()+":"+environment.getProperty("server.port")+"/api/camera/control/mp4/delay";
|
|
|
|
String url = "http://" + street.getPlcIp() + ":" + environment.getProperty("server.port") + "/api/camera/control/mp4/delay";
|
|
|
|
|
|
|
|
|
|
|
|
// 设置请求头
|
|
|
|
// 设置请求头
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
@ -316,12 +312,12 @@ public class PlcService {
|
|
|
|
restTemplate.getMessageConverters().add(new StringHttpMessageConverter(Charset.forName("utf-8")));
|
|
|
|
restTemplate.getMessageConverters().add(new StringHttpMessageConverter(Charset.forName("utf-8")));
|
|
|
|
// 发起POST请求,获取响应数据
|
|
|
|
// 发起POST请求,获取响应数据
|
|
|
|
path = restTemplate.postForObject(url, requestEntity, String.class);
|
|
|
|
path = restTemplate.postForObject(url, requestEntity, String.class);
|
|
|
|
path = "http://"+street.getPlcIp()+":9007/api/mp4/"+path;
|
|
|
|
path = "http://" + street.getPlcIp() + ":9007/api/mp4/" + path;
|
|
|
|
// 输出响应数据
|
|
|
|
// 输出响应数据
|
|
|
|
System.out.println(path);
|
|
|
|
System.out.println(path);
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
log.error("camera:{}未绑定巷道,无法远程下载",cameraId);
|
|
|
|
log.error("camera:{}未绑定巷道,无法远程下载", cameraId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -682,13 +678,15 @@ public class PlcService {
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//打开光源
|
|
|
|
|
|
|
|
streetController.openStreetLightSourceAsyncClose(street.getId());
|
|
|
|
if (checkLogMapper.selectCount(new QueryWrapper<CheckLog>()
|
|
|
|
if (checkLogMapper.selectCount(new QueryWrapper<CheckLog>()
|
|
|
|
.eq("street_Id",street.getId())
|
|
|
|
.eq("street_Id", street.getId())
|
|
|
|
.eq("check_Num",plcCmdInfo.getOrderNum()))>0){
|
|
|
|
.eq("check_Num", plcCmdInfo.getOrderNum())) > 0) {
|
|
|
|
log.error("库存信息已经盘点");
|
|
|
|
log.error("库存信息已经盘点");
|
|
|
|
CheckLog checkLog = checkLogMapper.selectOne(new QueryWrapper<CheckLog>()
|
|
|
|
CheckLog checkLog = checkLogMapper.selectOne(new QueryWrapper<CheckLog>()
|
|
|
|
.eq("street_Id",street.getId())
|
|
|
|
.eq("street_Id", street.getId())
|
|
|
|
.eq("check_Num",plcCmdInfo.getOrderNum()));
|
|
|
|
.eq("check_Num", plcCmdInfo.getOrderNum()));
|
|
|
|
AlgorithmPojo pojo = AlgorithmPojo.buildAlgorithmPojo(street, dataInfo);
|
|
|
|
AlgorithmPojo pojo = AlgorithmPojo.buildAlgorithmPojo(street, dataInfo);
|
|
|
|
if (checkLog.getWmsCategory() != null)
|
|
|
|
if (checkLog.getWmsCategory() != null)
|
|
|
|
pojo.setGoodsType(checkLog.getWmsCategory());
|
|
|
|
pojo.setGoodsType(checkLog.getWmsCategory());
|
|
|
|
@ -700,14 +698,12 @@ public class PlcService {
|
|
|
|
pojo.setGoodsNumberResult(checkLog.getCount());
|
|
|
|
pojo.setGoodsNumberResult(checkLog.getCount());
|
|
|
|
return pojo;
|
|
|
|
return pojo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//打开光源
|
|
|
|
|
|
|
|
streetController.openStreetLightSource( street.getId());
|
|
|
|
|
|
|
|
CronTab.putTime(street.getId());
|
|
|
|
CronTab.putTime(street.getId());
|
|
|
|
plcCmdInfo.setStreetName(street.getName());
|
|
|
|
plcCmdInfo.setStreetName(street.getName());
|
|
|
|
// List<LightSource> lightSources = lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id", street.getId()));
|
|
|
|
// List<LightSource> lightSources = lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id", street.getId()));
|
|
|
|
|
|
|
|
|
|
|
|
//关闭光源
|
|
|
|
//关闭光源
|
|
|
|
streetController.openStreetLightSource(street.getId());
|
|
|
|
streetController.openStreetLightSourceAsyncClose(street.getId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("盘点摄像头变化参数:" + plcCmdInfo.toString());
|
|
|
|
log.info("盘点摄像头变化参数:" + plcCmdInfo.toString());
|
|
|
|
@ -729,22 +725,22 @@ public class PlcService {
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode);
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode);
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getFromDirection(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getFromDirection(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
|
|
|
|
AlgorithmPojo algorithmPojo = algorithmService.getGoodResult(street, dataInfo);
|
|
|
|
AlgorithmPojo algorithmPojo = algorithmService.getGoodResult(street, dataInfo);
|
|
|
|
String paths = String.join(";", algorithmPojo.getCalculate().getFisheye()) +";"+String.join(";",algorithmPojo.getCalculate().getCloseUp())+";"+algorithmPojo.getCalculate().getPath();
|
|
|
|
String paths = String.join(";", algorithmPojo.getCalculate().getFisheye()) + ";" + String.join(";", algorithmPojo.getCalculate().getCloseUp()) + ";" + algorithmPojo.getCalculate().getPath();
|
|
|
|
|
|
|
|
|
|
|
|
//货物使用球机扫码
|
|
|
|
//货物使用球机扫码
|
|
|
|
|
|
|
|
|
|
|
|
log.info("盘点信息:{}", algorithmPojo.toString());
|
|
|
|
log.info("盘点信息:{}", algorithmPojo.toString());
|
|
|
|
//关闭光源
|
|
|
|
// //关闭光源
|
|
|
|
Thread thread = new Thread(() -> {
|
|
|
|
// Thread thread = new Thread(() -> {
|
|
|
|
try {
|
|
|
|
// try {
|
|
|
|
Thread.sleep(30000);
|
|
|
|
// Thread.sleep(30000);
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
// } catch (InterruptedException e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
//关闭光源
|
|
|
|
// //关闭光源
|
|
|
|
streetController.closeStreetLightSource(street.getId());
|
|
|
|
// streetController.closeStreetLightSource(street.getId());
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
thread.start();
|
|
|
|
// thread.start();
|
|
|
|
//核对异常
|
|
|
|
//核对异常
|
|
|
|
Integer status = 4;
|
|
|
|
Integer status = 4;
|
|
|
|
//托盘和货物都正确
|
|
|
|
//托盘和货物都正确
|
|
|
|
@ -871,6 +867,10 @@ public class PlcService {
|
|
|
|
return configProperties;
|
|
|
|
return configProperties;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 在PlcService类中添加以下静态成员
|
|
|
|
|
|
|
|
private static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(10);
|
|
|
|
|
|
|
|
private static ConcurrentHashMap<String, ScheduledFuture<?>> scheduledTasks = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
public KsecDataInfo orderDecoder(KsecInfo ksecInfo) {
|
|
|
|
public KsecDataInfo orderDecoder(KsecInfo ksecInfo) {
|
|
|
|
log.info("收到命令:{}", ksecInfo.toString());
|
|
|
|
log.info("收到命令:{}", ksecInfo.toString());
|
|
|
|
KsecDataInfo dataInfo = ksecInfo.getData();
|
|
|
|
KsecDataInfo dataInfo = ksecInfo.getData();
|
|
|
|
@ -900,11 +900,11 @@ public class PlcService {
|
|
|
|
plcCmdInfo.setFromAround(dataInfo.getFromAround());
|
|
|
|
plcCmdInfo.setFromAround(dataInfo.getFromAround());
|
|
|
|
plcCmdInfo.setToSide(dataInfo.getToSeparation());
|
|
|
|
plcCmdInfo.setToSide(dataInfo.getToSeparation());
|
|
|
|
//古井贡增加层概念,等于行
|
|
|
|
//古井贡增加层概念,等于行
|
|
|
|
if( dataInfo.getToStorey()!=null ){
|
|
|
|
if (dataInfo.getToStorey() != null) {
|
|
|
|
plcCmdInfo.setToRow(dataInfo.getToStorey());
|
|
|
|
plcCmdInfo.setToRow(dataInfo.getToStorey());
|
|
|
|
plcCmdInfo.setRow2(dataInfo.getToStorey());
|
|
|
|
plcCmdInfo.setRow2(dataInfo.getToStorey());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( dataInfo.getFromStorey()!=null ){
|
|
|
|
if (dataInfo.getFromStorey() != null) {
|
|
|
|
plcCmdInfo.setFromRow(dataInfo.getFromStorey());
|
|
|
|
plcCmdInfo.setFromRow(dataInfo.getFromStorey());
|
|
|
|
plcCmdInfo.setRow1(dataInfo.getFromStorey());
|
|
|
|
plcCmdInfo.setRow1(dataInfo.getFromStorey());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -944,10 +944,25 @@ public class PlcService {
|
|
|
|
//任务开始 旋转到原点位
|
|
|
|
//任务开始 旋转到原点位
|
|
|
|
gyrateCamera(plcCmdInfo, Cmd.C5.name());
|
|
|
|
gyrateCamera(plcCmdInfo, Cmd.C5.name());
|
|
|
|
orderStart(plcCmdInfo);
|
|
|
|
orderStart(plcCmdInfo);
|
|
|
|
|
|
|
|
// 添加延时任务
|
|
|
|
|
|
|
|
PlcCmdInfo finalPlcCmdInfo = plcCmdInfo;
|
|
|
|
|
|
|
|
ScheduledFuture<?> future = scheduler.schedule(() -> {
|
|
|
|
|
|
|
|
// 执行orderStop
|
|
|
|
|
|
|
|
orderStop(finalPlcCmdInfo);
|
|
|
|
|
|
|
|
// 从map中移除已执行的任务
|
|
|
|
|
|
|
|
scheduledTasks.remove(finalPlcCmdInfo.getTaskId());
|
|
|
|
|
|
|
|
}, 5, TimeUnit.MINUTES);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将future放入map中,便于后续取消
|
|
|
|
|
|
|
|
scheduledTasks.put(plcCmdInfo.getTaskId(), future);
|
|
|
|
|
|
|
|
|
|
|
|
} else if (Cmd.B2.name().equals(cmdName)) {
|
|
|
|
} else if (Cmd.B2.name().equals(cmdName)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 取消对应的计划任务(如果存在)
|
|
|
|
|
|
|
|
ScheduledFuture<?> existingTask = scheduledTasks.remove(plcCmdInfo.getTaskId());
|
|
|
|
|
|
|
|
if (existingTask != null && !existingTask.isDone()) {
|
|
|
|
|
|
|
|
existingTask.cancel(false); // 取消尚未执行的任务
|
|
|
|
|
|
|
|
}
|
|
|
|
orderStop(plcCmdInfo);
|
|
|
|
orderStop(plcCmdInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (Cmd.C.name().equals(ksecInfo.getType())) {
|
|
|
|
} else if (Cmd.C.name().equals(ksecInfo.getType())) {
|
|
|
|
|