|
|
|
@ -7,6 +7,7 @@ import com.leaper.web.lib.OrderInfo;
|
|
|
|
import com.leaper.web.lib.OrderRealtime;
|
|
|
|
import com.leaper.web.lib.OrderRealtime;
|
|
|
|
import com.leaper.web.lib.TaskDelayExecutor;
|
|
|
|
import com.leaper.web.lib.TaskDelayExecutor;
|
|
|
|
import com.leaper.web.mapper.*;
|
|
|
|
import com.leaper.web.mapper.*;
|
|
|
|
|
|
|
|
import com.leaper.web.pojo.Cmd;
|
|
|
|
import com.leaper.web.service.RFID.RFIDSocket;
|
|
|
|
import com.leaper.web.service.RFID.RFIDSocket;
|
|
|
|
import com.leaper.common.util.PathUtil;
|
|
|
|
import com.leaper.common.util.PathUtil;
|
|
|
|
import com.leaper.web.config.ConfigProperties;
|
|
|
|
import com.leaper.web.config.ConfigProperties;
|
|
|
|
@ -16,6 +17,8 @@ import com.leaper.web.mapper.*;
|
|
|
|
import com.leaper.web.pojo.OrderVO;
|
|
|
|
import com.leaper.web.pojo.OrderVO;
|
|
|
|
import com.leaper.web.service.RFID.RFIDMap;
|
|
|
|
import com.leaper.web.service.RFID.RFIDMap;
|
|
|
|
import com.leaper.web.service.hikLightSource.HikControlSocket;
|
|
|
|
import com.leaper.web.service.hikLightSource.HikControlSocket;
|
|
|
|
|
|
|
|
import com.leaper.web.service.ksec.KsecDataInfo;
|
|
|
|
|
|
|
|
import com.leaper.web.service.ksec.KsecInfo;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.aspectj.weaver.ast.Or;
|
|
|
|
import org.aspectj.weaver.ast.Or;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
@ -25,10 +28,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import java.util.concurrent.ArrayBlockingQueue;
|
|
|
|
import java.util.concurrent.ArrayBlockingQueue;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
@ -80,6 +80,9 @@ public class PlcService {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CheckLogMapper checkLogMapper;
|
|
|
|
private CheckLogMapper checkLogMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
WarnUrlMapper warnUrlMapper;
|
|
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
|
|
public void setCameraControlModule(CameraControlModule cameraControlModule){
|
|
|
|
public void setCameraControlModule(CameraControlModule cameraControlModule){
|
|
|
|
@ -468,15 +471,18 @@ public class PlcService {
|
|
|
|
log.error("ptz not found ,code:{},cameraId:{}", code, cameraId);
|
|
|
|
log.error("ptz not found ,code:{},cameraId:{}", code, cameraId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
旧报警,华为不使用
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 收到告警异常信号
|
|
|
|
* 收到告警异常信号
|
|
|
|
* 1.判断是否有正在进行订单,有的话,不做处理
|
|
|
|
* 1.判断是否有正在进行订单,有的话,不做处理
|
|
|
|
* 2.没有订单,新增告警记录
|
|
|
|
* 2.没有订单,新增告警记录
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param plcId
|
|
|
|
* @param plcId
|
|
|
|
*/
|
|
|
|
*//*
|
|
|
|
|
|
|
|
|
|
|
|
public void warnStart(String plcId, String signal) {
|
|
|
|
public void warnStart(String plcId, String signal) {
|
|
|
|
Street street = streetService.getStreetByPlcId(plcId);
|
|
|
|
Street street = streetService.getStreetByPlcId(plcId);
|
|
|
|
if (street == null) {
|
|
|
|
if (street == null) {
|
|
|
|
@ -516,6 +522,7 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 收到告警异常信号
|
|
|
|
* 收到告警异常信号
|
|
|
|
@ -524,52 +531,33 @@ public class PlcService {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param deviceReq
|
|
|
|
* @param deviceReq
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void warn(DeviceReq deviceReq) {
|
|
|
|
public List<String> warn(DeviceReq deviceReq) {
|
|
|
|
Warn warn = new Warn();
|
|
|
|
Warn warn = deviceReq.getWarn();
|
|
|
|
warn.setStartTime(LocalDateTime.now());
|
|
|
|
if (warn!= null) {
|
|
|
|
warn.setStreetId(street.getId());
|
|
|
|
warnMapper.insert(warn);
|
|
|
|
String orderNum = OrderRealtime.getOrderByStreetId(street.getId());
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(orderNum)) {
|
|
|
|
|
|
|
|
log.debug("{}:warn start...., but no order running", plcId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//不为空的话,填写工单的位置
|
|
|
|
|
|
|
|
Order order = orderMapper.getOneByOrderNum(orderNum);
|
|
|
|
|
|
|
|
if (order != null) {
|
|
|
|
|
|
|
|
//stop the order
|
|
|
|
|
|
|
|
log.debug("plcId:{},warn start and stop the order",plcId);
|
|
|
|
|
|
|
|
orderStopByWarn(orderNum);
|
|
|
|
|
|
|
|
OrderVO orderVO = new OrderVO();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(order, orderVO);
|
|
|
|
|
|
|
|
String location = orderService.location(orderVO, street);
|
|
|
|
|
|
|
|
warn.setLocation(location);
|
|
|
|
|
|
|
|
warn.setOrderId(order.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//没有正在执行的工单 不需要填写location
|
|
|
|
|
|
|
|
warn.setSignal(signal);
|
|
|
|
|
|
|
|
warnMapper.insert(warn);
|
|
|
|
|
|
|
|
OrderRealtime.startWarn(street.getId(), warn.getId());
|
|
|
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcId);
|
|
|
|
|
|
|
|
if (street == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
synchronized (plcId.intern()) {
|
|
|
|
List<String> result = new ArrayList<>();
|
|
|
|
//新增 告警
|
|
|
|
for (WarnUrl warnUrl : deviceReq.getWarnUrlList(warn)) {
|
|
|
|
if (OrderRealtime.getWarnId(street.getId()) != null) {
|
|
|
|
gyrateCameraByCode(Math.toIntExact(warnUrl.getCameraId()),warnUrl.getCameraCode());
|
|
|
|
log.debug("{}:exist warn", plcId);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//不存在正在执行的告警记录,就新增
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg",Math.toIntExact(warnUrl.getCameraId()),0,0);
|
|
|
|
|
|
|
|
cameraCapture(Math.toIntExact(warnUrl.getCameraId()),false,null,path);
|
|
|
|
|
|
|
|
log.info("warn拍照 cameraId:{},path:{}",warnUrl.getUrl(),path);
|
|
|
|
|
|
|
|
warnUrl.setUrl(path);
|
|
|
|
|
|
|
|
warnUrlMapper.insert(warnUrl);
|
|
|
|
|
|
|
|
//获取告警视频地址
|
|
|
|
|
|
|
|
result.add(configProperties.getCameraConfig().getCameraUrl()+"/#/camera"+warnUrl.getCameraId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/*旧报警,华为不使用
|
|
|
|
|
|
|
|
*//**
|
|
|
|
* 告警结束信号
|
|
|
|
* 告警结束信号
|
|
|
|
* 是否存在订单,存在-》保存该订单的视频
|
|
|
|
* 是否存在订单,存在-》保存该订单的视频
|
|
|
|
* 如果没有订单-》是否存在告警记录-》有告警记录的话,保存视频
|
|
|
|
* 如果没有订单-》是否存在告警记录-》有告警记录的话,保存视频
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param plcId
|
|
|
|
* @param plcId
|
|
|
|
*/
|
|
|
|
*//*
|
|
|
|
public void warnStop(String plcId) {
|
|
|
|
public void warnStop(String plcId) {
|
|
|
|
Street street = streetMapper.getStreetByPlcId(plcId);
|
|
|
|
Street street = streetMapper.getStreetByPlcId(plcId);
|
|
|
|
if (street == null) {
|
|
|
|
if (street == null) {
|
|
|
|
@ -598,7 +586,7 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* capture ,and update the picture path in order and stock
|
|
|
|
* capture ,and update the picture path in order and stock
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -819,4 +807,102 @@ public class PlcService {
|
|
|
|
return configProperties;
|
|
|
|
return configProperties;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void orderDecoder(KsecInfo ksecInfo) {
|
|
|
|
|
|
|
|
if (Cmd.A.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
KsecDataInfo dataInfo = ksecInfo.getData();
|
|
|
|
|
|
|
|
String lotnum = dataInfo.getLotnum();
|
|
|
|
|
|
|
|
PlcCmdInfo plcCmdInfo = null;
|
|
|
|
|
|
|
|
String srmNumber = null;
|
|
|
|
|
|
|
|
String cmdName = null;
|
|
|
|
|
|
|
|
if(dataInfo != null){
|
|
|
|
|
|
|
|
//左右换过来
|
|
|
|
|
|
|
|
if(dataInfo.getFromDirection() == 1){
|
|
|
|
|
|
|
|
dataInfo.setFromDirection(2);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
dataInfo.setFromDirection(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dataInfo.getToDirection() != null && dataInfo.getToDirection() == 1){
|
|
|
|
|
|
|
|
dataInfo.setToDirection(2);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
dataInfo.setToDirection(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
plcCmdInfo = new PlcCmdInfo(dataInfo.getSRMNumber(), dataInfo.getTaskId(), dataInfo.getFromSide(), dataInfo.getFromDirection(), dataInfo.getFromColumn(), dataInfo.getFromRow(), dataInfo.getFromSeparation(),dataInfo.getToSide(), dataInfo.getToDirection(), dataInfo.getToColumn(), dataInfo.getToRow(),dataInfo.getToSeparation(),lotnum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
srmNumber = dataInfo.getSRMNumber();
|
|
|
|
|
|
|
|
cmdName = dataInfo.getCmdName();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd.A.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
//心跳
|
|
|
|
|
|
|
|
log.debug("receieve heart ");
|
|
|
|
|
|
|
|
} else if (Cmd.B.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//任务
|
|
|
|
|
|
|
|
if (Cmd.B1.name().equals(cmdName)) {
|
|
|
|
|
|
|
|
//昆船盘点模式下也会发B1 ,但是不会发送B2
|
|
|
|
|
|
|
|
//这里判断下,是否存在盘点批次号 若存在,既是盘点的B1,无需处理;若不存在lotnum,则是随行的B1
|
|
|
|
|
|
|
|
if(StringUtils.isEmpty(dataInfo.getLotnum())){
|
|
|
|
|
|
|
|
//任务开始 旋转到原点位
|
|
|
|
|
|
|
|
gyrateCamera(plcCmdInfo,Cmd.C5.name());
|
|
|
|
|
|
|
|
orderStart(plcCmdInfo);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
log.info("check move");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (Cmd.B2.name().equals(cmdName)) {
|
|
|
|
|
|
|
|
//B2 C4 一起发的,需要停止等B2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//这里判断是不是双伸
|
|
|
|
|
|
|
|
if(plcCmdInfo.getSeparation2() == 2){
|
|
|
|
|
|
|
|
//深测货架延迟
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(getConfigProperties().getCameraConfig().getB2OutDelayTime());
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//浅侧延迟
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(getConfigProperties().getCameraConfig().getB2DelayTime());
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gyrateCamera(plcCmdInfo,Cmd.C5.name());
|
|
|
|
|
|
|
|
orderStop(plcCmdInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (Cmd.C.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//动作
|
|
|
|
|
|
|
|
String code = dataInfo.getCmdName();
|
|
|
|
|
|
|
|
log.info("action code,{},orderInfo:{}", code, plcCmdInfo.toString());
|
|
|
|
|
|
|
|
if (Cmd.isBaseAction(code)) {
|
|
|
|
|
|
|
|
//执行动作,需要保存执行到第几步了
|
|
|
|
|
|
|
|
Integer times = GoodsActionTimes.put(plcCmdInfo.getOrderNum());
|
|
|
|
|
|
|
|
plcCmdInfo.setTimes(times);
|
|
|
|
|
|
|
|
code = code + "-" + plcCmdInfo.getLeftRightStr(times) + plcCmdInfo.getInOutStr(times);
|
|
|
|
|
|
|
|
//执行动作
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
action(plcCmdInfo, times, code);
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
log.info("other C code :{}",code);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (Cmd.D.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (Cmd.E.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//rfid的逻辑
|
|
|
|
|
|
|
|
String code = dataInfo.getCmdName();
|
|
|
|
|
|
|
|
if("E1".equals(code)){
|
|
|
|
|
|
|
|
RFIDCheck(plcCmdInfo);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
RFIDStop(plcCmdInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|