|
|
|
@ -134,6 +134,9 @@ 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());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer cameraId = (plcCmdInfo.getFromAround() == 1) ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
|
|
|
|
gyrateCameraByCode(cameraId, "C5", plcCmdInfo.getTaskId());
|
|
|
|
|
|
|
|
|
|
|
|
if (street != null) {
|
|
|
|
if (street != null) {
|
|
|
|
if (plcCmdInfo.getLeftRight1() == 1) {
|
|
|
|
if (plcCmdInfo.getLeftRight1() == 1) {
|
|
|
|
if (plcCmdInfo.getRow1() > street.getLeftRow() && plcCmdInfo.getColumn1() > street.getLeftColumn()) {
|
|
|
|
if (plcCmdInfo.getRow1() > street.getLeftRow() && plcCmdInfo.getColumn1() > street.getLeftColumn()) {
|
|
|
|
@ -155,6 +158,10 @@ public class PlcService {
|
|
|
|
order.setLeftRight1(plcCmdInfo.getLeftRight1());
|
|
|
|
order.setLeftRight1(plcCmdInfo.getLeftRight1());
|
|
|
|
order.setColumn1(plcCmdInfo.getColumn1());
|
|
|
|
order.setColumn1(plcCmdInfo.getColumn1());
|
|
|
|
order.setRow1(plcCmdInfo.getRow1());
|
|
|
|
order.setRow1(plcCmdInfo.getRow1());
|
|
|
|
|
|
|
|
order.setInOut2(plcCmdInfo.getSide2());
|
|
|
|
|
|
|
|
order.setLeftRight2(plcCmdInfo.getLeftRight2());
|
|
|
|
|
|
|
|
order.setColumn2(plcCmdInfo.getColumn2());
|
|
|
|
|
|
|
|
order.setRow2(plcCmdInfo.getRow2());
|
|
|
|
//todo 昆船的项目 ,取货 放货是独立的
|
|
|
|
//todo 昆船的项目 ,取货 放货是独立的
|
|
|
|
//取货是是不知道放货的位置的,所以订单开始的时候只写1位置
|
|
|
|
//取货是是不知道放货的位置的,所以订单开始的时候只写1位置
|
|
|
|
//订单结束写2位置
|
|
|
|
//订单结束写2位置
|
|
|
|
@ -170,23 +177,36 @@ public class PlcService {
|
|
|
|
* @param plcCmdInfo
|
|
|
|
* @param plcCmdInfo
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void orderStop(PlcCmdInfo plcCmdInfo) {
|
|
|
|
public void orderStop(PlcCmdInfo plcCmdInfo) {
|
|
|
|
|
|
|
|
|
|
|
|
LocalDateTime endTime = LocalDateTime.now();
|
|
|
|
LocalDateTime endTime = LocalDateTime.now();
|
|
|
|
Street street = streetMapper.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
|
|
|
if (street == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Order order = orderMapper.getOneByOrderNum(plcCmdInfo.getOrderNum());
|
|
|
|
Order order = orderMapper.getOneByOrderNum(plcCmdInfo.getOrderNum());
|
|
|
|
|
|
|
|
|
|
|
|
if (order == null) {
|
|
|
|
if (order == null) {
|
|
|
|
log.error("订单结束信号,订单不存在,orderNum:{}", plcCmdInfo.getOrderNum());
|
|
|
|
log.error("订单结束信号,订单不存在,orderNum:{}", plcCmdInfo.getOrderNum());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Order update = new Order();
|
|
|
|
|
|
|
|
update.setId(order.getId());
|
|
|
|
//这里判断是不是双伸
|
|
|
|
update.setEndTime(endTime);
|
|
|
|
if (order.getInOut2() == 2) {
|
|
|
|
update.setInOut2(plcCmdInfo.getSide2());
|
|
|
|
//深测货架延迟
|
|
|
|
update.setLeftRight2(plcCmdInfo.getLeftRight2());
|
|
|
|
try {
|
|
|
|
update.setColumn2(plcCmdInfo.getColumn2());
|
|
|
|
Thread.sleep(getConfigProperties().getCameraConfig().getB2OutDelayTime());
|
|
|
|
update.setRow2(plcCmdInfo.getRow2());
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//浅侧延迟
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(getConfigProperties().getCameraConfig().getB2DelayTime());
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Street street = streetMapper.selectById(order.getStreetId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalDateTime endDownLoadTime = endTime.plusSeconds(5);
|
|
|
|
LocalDateTime endDownLoadTime = endTime.plusSeconds(5);
|
|
|
|
Duration duration = Duration.between(order.getStartTime(), endDownLoadTime);
|
|
|
|
Duration duration = Duration.between(order.getStartTime(), endDownLoadTime);
|
|
|
|
|
|
|
|
|
|
|
|
@ -195,13 +215,13 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
String path = cameraVideo(street.getCamera1Id(), order.getStartTime(), endDownLoadTime);
|
|
|
|
String path = cameraVideo(street.getCamera1Id(), order.getStartTime(), endDownLoadTime);
|
|
|
|
update.setVideoPath1(path);
|
|
|
|
order.setVideoPath1(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
String path = cameraVideo(street.getCamera2Id(), order.getStartTime(), endDownLoadTime);
|
|
|
|
String path = cameraVideo(street.getCamera2Id(), order.getStartTime(), endDownLoadTime);
|
|
|
|
update.setVideoPath2(path);
|
|
|
|
order.setVideoPath2(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
orderMapper.updateById(update);
|
|
|
|
orderMapper.updateById(order);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -255,7 +275,7 @@ public class PlcService {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 古井贡酒球机分前后,前使用左侧相机
|
|
|
|
* 古井贡酒球机分前后,前使用左侧相机
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Integer cameraId = (plcCmdInfo.getFromAround() == 1)? street.getCamera1Id(): street.getCamera2Id();
|
|
|
|
Integer cameraId = (plcCmdInfo.getFromAround() == 1) ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
gyrateCameraByCode(cameraId, orderInfo.getCmdCode(), orderInfo.getOrderNum());
|
|
|
|
gyrateCameraByCode(cameraId, orderInfo.getCmdCode(), orderInfo.getOrderNum());
|
|
|
|
if (needCapture) {
|
|
|
|
if (needCapture) {
|
|
|
|
Boolean delay = true;
|
|
|
|
Boolean delay = true;
|
|
|
|
@ -282,7 +302,7 @@ public class PlcService {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
delayTime = configProperties.getCameraConfig().getC2OutDelayCaptureTime();
|
|
|
|
delayTime = configProperties.getCameraConfig().getC2OutDelayCaptureTime();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(configProperties.getOrderTest() == 1 && plcCmdInfo.getFromAround() == 2) {
|
|
|
|
if (configProperties.getOrderTest() == 1 && plcCmdInfo.getFromAround() == 2) {
|
|
|
|
checkTest(plcCmdInfo);
|
|
|
|
checkTest(plcCmdInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (code.startsWith("C3")) {
|
|
|
|
} else if (code.startsWith("C3")) {
|
|
|
|
@ -303,14 +323,9 @@ public class PlcService {
|
|
|
|
captureUpdateOrderAndStock(orderInfo, path);
|
|
|
|
captureUpdateOrderAndStock(orderInfo, path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//转向原点位
|
|
|
|
//转向原点位
|
|
|
|
if (times == 2) {
|
|
|
|
if (times == 2 || times == 4) {
|
|
|
|
|
|
|
|
gyrateCameraByCodeTimeLater(cameraId, "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
|
|
|
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera2Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera1Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// threadPoolExecutor.execute(()->{
|
|
|
|
// threadPoolExecutor.execute(()->{
|
|
|
|
// rfidLiveService.rfidOrderStock(plcCmdInfo, times, code);
|
|
|
|
// rfidLiveService.rfidOrderStock(plcCmdInfo, times, code);
|
|
|
|
@ -372,7 +387,7 @@ public class PlcService {
|
|
|
|
public String cameraCapture(Integer cameraId, Boolean delay, Long delayTime, String path) {
|
|
|
|
public String cameraCapture(Integer cameraId, Boolean delay, Long delayTime, String path) {
|
|
|
|
//String path = PathUtil.createFileName("jpg",cameraId);
|
|
|
|
//String path = PathUtil.createFileName("jpg",cameraId);
|
|
|
|
String realPath = configProperties.getSavePath().getMediaPath() + path;
|
|
|
|
String realPath = configProperties.getSavePath().getMediaPath() + path;
|
|
|
|
log.info("capture picture, cameraId:{},path:{}delayTime:{}", cameraId, realPath,delayTime);
|
|
|
|
log.info("capture picture, cameraId:{},path:{}delayTime:{}", cameraId, realPath, delayTime);
|
|
|
|
if (delay) {
|
|
|
|
if (delay) {
|
|
|
|
TaskDelayExecutor.addPicDelayTask(cameraId, realPath, delayTime);
|
|
|
|
TaskDelayExecutor.addPicDelayTask(cameraId, realPath, delayTime);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -564,52 +579,11 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Integer getCameraByPlcCmd(PlcCmdInfo plcCmdInfo, Integer leftRight) {
|
|
|
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
|
|
|
//判断单双伸 type=0 单伸 1为双伸
|
|
|
|
|
|
|
|
Integer type;
|
|
|
|
|
|
|
|
if (leftRight == 1) {
|
|
|
|
|
|
|
|
type = street.getLeftType();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
type = street.getRightType();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == 0) {
|
|
|
|
|
|
|
|
//单伸
|
|
|
|
|
|
|
|
if (street.getCamera1Id() != null && street.getCamera2Id() != null && street.getCamera1Id() != 0 && street.getCamera2Id() != 0) {
|
|
|
|
|
|
|
|
if (leftRight == 1) {
|
|
|
|
|
|
|
|
return street.getCamera2Id();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return street.getCamera1Id();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Integer cameraId = street.getCamera1Id() != null && street.getCamera1Id() != 0 ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
|
|
|
|
return cameraId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (street.getCamera1Id() != null && street.getCamera2Id() != null && street.getCamera1Id() != 0 && street.getCamera2Id() != 0) {
|
|
|
|
|
|
|
|
//双伸 todo 这个因项目而异,看现场的情况
|
|
|
|
|
|
|
|
//默认是 左侧返回camera1 右侧返回camera2
|
|
|
|
|
|
|
|
if (plcCmdInfo.getLeftRight1() == 1) {
|
|
|
|
|
|
|
|
return street.getCamera1Id();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return street.getCamera2Id();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Integer cameraId = street.getCamera1Id() != null && street.getCamera1Id() != 0 ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
|
|
|
|
return cameraId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Integer getCameraByPlcCmdE(PlcCmdInfo plcCmdInfo, Integer leftRight) {
|
|
|
|
public Integer getCameraByPlcCmdE(PlcCmdInfo plcCmdInfo, Integer leftRight) {
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
Integer type;
|
|
|
|
//古井前后修改
|
|
|
|
//只进行相机方向判断左边
|
|
|
|
return (plcCmdInfo.getFromAround() == 1) ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
if (plcCmdInfo.getFromDirection() == 1) {
|
|
|
|
|
|
|
|
return street.getCamera1Id();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return street.getCamera2Id();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
@ -624,6 +598,7 @@ public class PlcService {
|
|
|
|
WebSocketServer.sendInfo(JSONObject.toJSONString(webSocketVo), null);
|
|
|
|
WebSocketServer.sendInfo(JSONObject.toJSONString(webSocketVo), null);
|
|
|
|
return JSONObject.toJSONString(webSocketVo);
|
|
|
|
return JSONObject.toJSONString(webSocketVo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
AlgorithmService algorithmService;
|
|
|
|
AlgorithmService algorithmService;
|
|
|
|
|
|
|
|
|
|
|
|
@ -639,21 +614,9 @@ public class PlcService {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
log.info("盘点摄像头变化参数:" + plcCmdInfo.toString());
|
|
|
|
log.info("盘点摄像头变化参数:" + plcCmdInfo.toString());
|
|
|
|
Integer cameraId = getCameraByPlcCmdE(plcCmdInfo, plcCmdInfo.getLeftRight1());
|
|
|
|
Integer cameraId = getCameraByPlcCmdE(plcCmdInfo, plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
String code = "E1" + "-" + plcCmdInfo.getEndStr(1, plcCmdInfo.getFromAround());
|
|
|
|
|
|
|
|
|
|
|
|
if (plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2) {
|
|
|
|
gyrateCameraByCode(cameraId, code);
|
|
|
|
//内测
|
|
|
|
|
|
|
|
String c = cmdCode + "-" + plcCmdInfo.getLeftRightStr(1) + "-IN";
|
|
|
|
|
|
|
|
log.info("camera ptz" + c);
|
|
|
|
|
|
|
|
gyrateCameraByCode(cameraId, c);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
String c = cmdCode + "1-" +plcCmdInfo.getEndStr(1);
|
|
|
|
|
|
|
|
gyrateCameraByCode(cameraId, c);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime());
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg", cameraId, plcCmdInfo.getRow1(), plcCmdInfo.getColumn1());
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg", cameraId, plcCmdInfo.getRow1(), plcCmdInfo.getColumn1());
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -667,7 +630,7 @@ 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);
|
|
|
|
|
|
|
|
|
|
|
|
//货物使用球机扫码
|
|
|
|
//货物使用球机扫码
|
|
|
|
|
|
|
|
|
|
|
|
@ -675,7 +638,7 @@ public class PlcService {
|
|
|
|
//核对异常
|
|
|
|
//核对异常
|
|
|
|
Integer status = 1;
|
|
|
|
Integer status = 1;
|
|
|
|
//托盘和货物都正确
|
|
|
|
//托盘和货物都正确
|
|
|
|
if (algorithmPojo.getResult()==1
|
|
|
|
if (algorithmPojo.getResult() == 1
|
|
|
|
&& algorithmPojo.getGoodsNumber().equals(algorithmPojo.getGoodsNumberResult())
|
|
|
|
&& algorithmPojo.getGoodsNumber().equals(algorithmPojo.getGoodsNumberResult())
|
|
|
|
&& algorithmPojo.getGoodsType().equals(algorithmPojo.getGoodsTypeResult())) {
|
|
|
|
&& algorithmPojo.getGoodsType().equals(algorithmPojo.getGoodsTypeResult())) {
|
|
|
|
status = 2;
|
|
|
|
status = 2;
|
|
|
|
@ -788,6 +751,7 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public KsecDataInfo orderDecoder(KsecInfo ksecInfo) {
|
|
|
|
public KsecDataInfo orderDecoder(KsecInfo ksecInfo) {
|
|
|
|
|
|
|
|
log.info("收到命令:{}", ksecInfo.toString());
|
|
|
|
KsecDataInfo dataInfo = ksecInfo.getData();
|
|
|
|
KsecDataInfo dataInfo = ksecInfo.getData();
|
|
|
|
if (Cmd.A.name().equals(ksecInfo.getType())) {
|
|
|
|
if (Cmd.A.name().equals(ksecInfo.getType())) {
|
|
|
|
return dataInfo;
|
|
|
|
return dataInfo;
|
|
|
|
@ -796,38 +760,44 @@ public class PlcService {
|
|
|
|
PlcCmdInfo plcCmdInfo = null;
|
|
|
|
PlcCmdInfo plcCmdInfo = null;
|
|
|
|
String srmNumber = null;
|
|
|
|
String srmNumber = null;
|
|
|
|
String cmdName = null;
|
|
|
|
String cmdName = null;
|
|
|
|
if(dataInfo != null){
|
|
|
|
if (dataInfo != null) {
|
|
|
|
|
|
|
|
//古井贡酒没有side使用双伸单伸Separation代替全部side
|
|
|
|
plcCmdInfo = new PlcCmdInfo(dataInfo.getSRMNumber(), dataInfo.getTaskId(),
|
|
|
|
plcCmdInfo = new PlcCmdInfo(dataInfo.getSRMNumber(), dataInfo.getTaskId(),
|
|
|
|
dataInfo.getFromSide(), dataInfo.getFromDirection(), dataInfo.getFromColumn(),
|
|
|
|
dataInfo.getFromSeparation(), dataInfo.getFromDirection(), dataInfo.getFromColumn(),
|
|
|
|
dataInfo.getFromRow(), dataInfo.getFromSeparation(),dataInfo.getToSide(),
|
|
|
|
dataInfo.getFromRow(), dataInfo.getFromSeparation(), dataInfo.getToSeparation(),
|
|
|
|
dataInfo.getToDirection(), dataInfo.getToColumn(), dataInfo.getToRow(),
|
|
|
|
dataInfo.getToDirection(), dataInfo.getToColumn(), dataInfo.getToRow(),
|
|
|
|
dataInfo.getToSeparation(),lotnum);
|
|
|
|
dataInfo.getToSeparation(), lotnum);
|
|
|
|
plcCmdInfo.setFromDirection(dataInfo.getFromDirection());
|
|
|
|
plcCmdInfo.setFromDirection(dataInfo.getFromDirection());
|
|
|
|
plcCmdInfo.setToDirection(dataInfo.getToDirection());
|
|
|
|
plcCmdInfo.setToDirection(dataInfo.getToDirection());
|
|
|
|
plcCmdInfo.setToColumn(dataInfo.getToColumn());
|
|
|
|
plcCmdInfo.setToColumn(dataInfo.getToColumn());
|
|
|
|
plcCmdInfo.setToRow(dataInfo.getToRow());
|
|
|
|
plcCmdInfo.setToRow(dataInfo.getToRow());
|
|
|
|
plcCmdInfo.setFromRow(dataInfo.getFromRow());
|
|
|
|
plcCmdInfo.setFromRow(dataInfo.getFromRow());
|
|
|
|
plcCmdInfo.setFromColumn(dataInfo.getFromColumn());
|
|
|
|
plcCmdInfo.setFromColumn(dataInfo.getFromColumn());
|
|
|
|
plcCmdInfo.setFromSide(dataInfo.getFromSide());
|
|
|
|
plcCmdInfo.setFromSide(dataInfo.getFromSeparation());
|
|
|
|
plcCmdInfo.setFromSeparation(dataInfo.getFromSeparation());
|
|
|
|
plcCmdInfo.setFromSeparation(dataInfo.getFromSeparation());
|
|
|
|
plcCmdInfo.setToSeparation(dataInfo.getToSeparation());
|
|
|
|
plcCmdInfo.setToSeparation(dataInfo.getToSeparation());
|
|
|
|
plcCmdInfo.setFromAround(dataInfo.getFromAround());
|
|
|
|
plcCmdInfo.setFromAround(dataInfo.getFromAround());
|
|
|
|
plcCmdInfo.setToSide(dataInfo.getToSide());
|
|
|
|
plcCmdInfo.setToSide(dataInfo.getToSeparation());
|
|
|
|
//左右不交换
|
|
|
|
//左右不交换
|
|
|
|
if(dataInfo.getFromDirection() == 1){
|
|
|
|
if (dataInfo.getFromDirection() != null) {
|
|
|
|
|
|
|
|
if (dataInfo.getFromDirection() == 1) {
|
|
|
|
//dataInfo.setFromDirection(2);
|
|
|
|
//dataInfo.setFromDirection(2);
|
|
|
|
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
|
|
|
|
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
//dataInfo.setFromDirection(1);
|
|
|
|
//dataInfo.setFromDirection(1);
|
|
|
|
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
|
|
|
|
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(dataInfo.getToDirection() != null && dataInfo.getToDirection() == 1){
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dataInfo.getToDirection() != null) {
|
|
|
|
|
|
|
|
if (dataInfo.getToDirection() == 1) {
|
|
|
|
//dataInfo.setToDirection(2);
|
|
|
|
//dataInfo.setToDirection(2);
|
|
|
|
plcCmdInfo.setLeftRight2(dataInfo.getToDirection());
|
|
|
|
plcCmdInfo.setLeftRight2(dataInfo.getToDirection());
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
//dataInfo.setToDirection(1);
|
|
|
|
//dataInfo.setToDirection(1);
|
|
|
|
plcCmdInfo.setLeftRight2(dataInfo.getToDirection());
|
|
|
|
plcCmdInfo.setLeftRight2(dataInfo.getToDirection());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
srmNumber = dataInfo.getSRMNumber();
|
|
|
|
srmNumber = dataInfo.getSRMNumber();
|
|
|
|
cmdName = dataInfo.getCmdName();
|
|
|
|
cmdName = dataInfo.getCmdName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -838,35 +808,18 @@ public class PlcService {
|
|
|
|
//任务
|
|
|
|
//任务
|
|
|
|
if (Cmd.B1.name().equals(cmdName)) {
|
|
|
|
if (Cmd.B1.name().equals(cmdName)) {
|
|
|
|
//昆船盘点模式下也会发B1 ,但是不会发送B2
|
|
|
|
//昆船盘点模式下也会发B1 ,但是不会发送B2
|
|
|
|
//这里判断下,是否存在盘点批次号 若存在,既是盘点的B1,无需处理;若不存在lotnum,则是随行的B1
|
|
|
|
|
|
|
|
if(StringUtils.isEmpty(dataInfo.getLotnum())){
|
|
|
|
|
|
|
|
//任务开始 旋转到原点位
|
|
|
|
//任务开始 旋转到原点位
|
|
|
|
gyrateCamera(plcCmdInfo,Cmd.C5.name());
|
|
|
|
gyrateCamera(plcCmdInfo, Cmd.C5.name());
|
|
|
|
orderStart(plcCmdInfo);
|
|
|
|
orderStart(plcCmdInfo);
|
|
|
|
}else {
|
|
|
|
|
|
|
|
log.info("check move");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (Cmd.B2.name().equals(cmdName)) {
|
|
|
|
} else if (Cmd.B2.name().equals(cmdName)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//B2 C4 一起发的,需要停止等B2
|
|
|
|
//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);
|
|
|
|
orderStop(plcCmdInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (Cmd.C.name().equals(ksecInfo.getType())) {
|
|
|
|
} else if (Cmd.C.name().equals(ksecInfo.getType())) {
|
|
|
|
@ -878,30 +831,30 @@ public class PlcService {
|
|
|
|
//执行动作,需要保存执行到第几步了
|
|
|
|
//执行动作,需要保存执行到第几步了
|
|
|
|
Integer times = GoodsActionTimes.get(dataInfo.getCmdName());
|
|
|
|
Integer times = GoodsActionTimes.get(dataInfo.getCmdName());
|
|
|
|
plcCmdInfo.setTimes(times);
|
|
|
|
plcCmdInfo.setTimes(times);
|
|
|
|
code = code + "-" + plcCmdInfo.getEndStr(times);
|
|
|
|
code = code + "-" + plcCmdInfo.getEndStr(times, plcCmdInfo.getFromAround());
|
|
|
|
//执行动作
|
|
|
|
//执行动作
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
action(plcCmdInfo, times, code);
|
|
|
|
action(plcCmdInfo, times, code);
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
log.info("other C code :{}",code);
|
|
|
|
log.info("other C code :{}", code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (Cmd.D.name().equals(ksecInfo.getType())) {
|
|
|
|
} else if (Cmd.D.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
|
|
|
|
} else if (Cmd.E.name().equals(ksecInfo.getType()) ) {
|
|
|
|
} else if (Cmd.E.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
|
|
|
|
String code = dataInfo.getCmdName();
|
|
|
|
String code = dataInfo.getCmdName();
|
|
|
|
log.info("盘点指令:{}", ksecInfo);
|
|
|
|
log.info("盘点指令:{}", ksecInfo);
|
|
|
|
if(configProperties.getOrderTest() == 0) {
|
|
|
|
{
|
|
|
|
AlgorithmPojo algorithmPojo = check(plcCmdInfo, ksecInfo.getType(), dataInfo);
|
|
|
|
AlgorithmPojo algorithmPojo = check(plcCmdInfo, ksecInfo.getType(), dataInfo);
|
|
|
|
ksecInfo.getData().setAckStatus(1);
|
|
|
|
ksecInfo.getData().setAckStatus(1);
|
|
|
|
dataInfo.setResult(algorithmPojo.getResult());
|
|
|
|
dataInfo.setResult(algorithmPojo.getResult());
|
|
|
|
dataInfo.setGoodsTypeResult(algorithmPojo.getGoodsTypeResult());
|
|
|
|
dataInfo.setGoodsTypeResult(algorithmPojo.getGoodsTypeResult());
|
|
|
|
dataInfo.setGoodsNumberResult(algorithmPojo.getGoodsNumberResult());
|
|
|
|
dataInfo.setGoodsNumberResult(algorithmPojo.getGoodsNumberResult());
|
|
|
|
log.info("盘点完成");
|
|
|
|
log.info("盘点完成");
|
|
|
|
}else {
|
|
|
|
} if (configProperties.getOrderTest() == 1) {
|
|
|
|
checkTest(plcCmdInfo);
|
|
|
|
checkTest(plcCmdInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -918,27 +871,27 @@ 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(), street.getPlcPort()), 3000);
|
|
|
|
//socket.setSoTimeout(10000);
|
|
|
|
//socket.setSoTimeout(10000);
|
|
|
|
os = socket.getOutputStream();
|
|
|
|
os = socket.getOutputStream();
|
|
|
|
Thread.sleep(100);
|
|
|
|
Thread.sleep(100);
|
|
|
|
String startCmd = "trigger:1";
|
|
|
|
String startCmd = "trigger:1";
|
|
|
|
byte [] bytes = startCmd.getBytes(StandardCharsets.UTF_8);
|
|
|
|
byte[] bytes = startCmd.getBytes(StandardCharsets.UTF_8);
|
|
|
|
os.write(bytes);
|
|
|
|
os.write(bytes);
|
|
|
|
socket.close();
|
|
|
|
socket.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.error("hik contro time out,ip:{},info:{}",street.getPlcIp(),e);
|
|
|
|
log.error("hik contro time out,ip:{},info:{}", street.getPlcIp(), e);
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
if(os != null){
|
|
|
|
if (os != null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
os.close();
|
|
|
|
os.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(is != null){
|
|
|
|
if (is != null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
is.close();
|
|
|
|
is.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
|