|
|
|
@ -56,6 +56,10 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private CameraMapper cameraMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private StockMapper stockMapper;
|
|
|
|
private StockMapper stockMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
@ -234,7 +238,7 @@ public class PlcService {
|
|
|
|
public void action(PlcCmdInfo plcCmdInfo, Integer times, String code) throws InterruptedException {
|
|
|
|
public void action(PlcCmdInfo plcCmdInfo, Integer times, String code) throws InterruptedException {
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
if (street == null) {
|
|
|
|
if (street == null) {
|
|
|
|
log.error("street not found ,plcId :{}", plcCmdInfo.getPlcId());
|
|
|
|
log.error("street not found ,plcId :{},taskId:{}", plcCmdInfo.getPlcId(), plcCmdInfo.getOrderNum());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, times, code);
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, times, code);
|
|
|
|
@ -248,8 +252,8 @@ public class PlcService {
|
|
|
|
* 右侧转camera2
|
|
|
|
* 右侧转camera2
|
|
|
|
* 没有就不管了
|
|
|
|
* 没有就不管了
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo, orderInfo.getLeftRight());
|
|
|
|
Integer cameraId = getCameraByPlcCmdAction(plcCmdInfo, orderInfo.getCmdCode());
|
|
|
|
gyrateCameraByCode(cameraId, orderInfo.getCmdCode());
|
|
|
|
gyrateCameraByCode(cameraId, orderInfo.getCmdCode(), orderInfo.getOrderNum());
|
|
|
|
if (needCapture) {
|
|
|
|
if (needCapture) {
|
|
|
|
Boolean delay = true;
|
|
|
|
Boolean delay = true;
|
|
|
|
Integer row = 0;
|
|
|
|
Integer row = 0;
|
|
|
|
@ -303,7 +307,19 @@ public class PlcService {
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera1Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera1Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rfidLiveService.rfidOrderStock(plcCmdInfo, times, code);
|
|
|
|
threadPoolExecutor.execute(()->{
|
|
|
|
|
|
|
|
rfidLiveService.rfidOrderStock(plcCmdInfo, times, code);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer getCameraByPlcCmdAction(PlcCmdInfo plcCmdInfo, String code) {
|
|
|
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
|
|
|
//只进行相机方向判断左边
|
|
|
|
|
|
|
|
if (code.contains("L")) {
|
|
|
|
|
|
|
|
return street.getCamera1Id();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return street.getCamera2Id();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void gyrateCamera(PlcCmdInfo plcCmdInfo, String code) {
|
|
|
|
public void gyrateCamera(PlcCmdInfo plcCmdInfo, String code) {
|
|
|
|
@ -370,6 +386,16 @@ public class PlcService {
|
|
|
|
if (ptzId != null && ptzId >= 0) {
|
|
|
|
if (ptzId != null && ptzId >= 0) {
|
|
|
|
log.info("gyrate camera by code, code:{},cameraId:{},ptId:{}", code, cameraId, ptzId);
|
|
|
|
log.info("gyrate camera by code, code:{},cameraId:{},ptId:{}", code, cameraId, ptzId);
|
|
|
|
cameraControlModule.toPtz(ptzId, cameraId);
|
|
|
|
cameraControlModule.toPtz(ptzId, cameraId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("ptz not found , code:{},cameraId:{},ptId:{}", code, cameraId, ptzId);
|
|
|
|
|
|
|
|
log.error("ptz not found ,code:{},cameraId:{}", code, cameraId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void gyrateCameraByCode(Integer cameraId, String code,String taskId) {
|
|
|
|
|
|
|
|
Integer ptzId = cameraService.getPtzIdByCodeAndCameraId(code, cameraId);
|
|
|
|
|
|
|
|
if (ptzId != null && ptzId >= 0) {
|
|
|
|
|
|
|
|
log.info("gyrate camera by code, code:{},cameraId:{},ptId:{},taskId:{}", code, cameraId, ptzId,taskId);
|
|
|
|
|
|
|
|
cameraControlModule.toPtz(ptzId, cameraId);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
log.error("ptz not found ,code:{},cameraId:{}", code, cameraId);
|
|
|
|
log.error("ptz not found ,code:{},cameraId:{}", code, cameraId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -563,15 +589,13 @@ public class PlcService {
|
|
|
|
Integer cameraId = street.getCamera1Id() != null && street.getCamera1Id() != 0 ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
Integer cameraId = street.getCamera1Id() != null && street.getCamera1Id() != 0 ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
return cameraId;
|
|
|
|
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());
|
|
|
|
//判断单双伸 type=0 单伸 1为双伸
|
|
|
|
|
|
|
|
Integer type;
|
|
|
|
Integer type;
|
|
|
|
if (plcCmdInfo.getFromSeparation() == 1) {
|
|
|
|
//只进行相机方向判断左边
|
|
|
|
|
|
|
|
if (plcCmdInfo.getFromDirection() == 1) {
|
|
|
|
return street.getCamera1Id();
|
|
|
|
return street.getCamera1Id();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return street.getCamera2Id();
|
|
|
|
return street.getCamera2Id();
|
|
|
|
@ -625,6 +649,7 @@ public class PlcService {
|
|
|
|
Boolean trayCheck = Boolean.TRUE;
|
|
|
|
Boolean trayCheck = Boolean.TRUE;
|
|
|
|
//如果是用扫码枪 扫 托盘码,就直接扫
|
|
|
|
//如果是用扫码枪 扫 托盘码,就直接扫
|
|
|
|
//if(configProperties.getScanCodeMode().getTray() == 2){
|
|
|
|
//if(configProperties.getScanCodeMode().getTray() == 2){
|
|
|
|
|
|
|
|
log.info("扫码类型:"+configProperties.getScanCodeMode().getTray());
|
|
|
|
if (plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2) {
|
|
|
|
if (plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2) {
|
|
|
|
//托盘使用sick扫码枪
|
|
|
|
//托盘使用sick扫码枪
|
|
|
|
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(), plcCmdInfo.getLeftRight1());
|
|
|
|
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(), plcCmdInfo.getLeftRight1());
|
|
|
|
@ -658,7 +683,7 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (configProperties.getScanCodeMode().getTray() == 3) {
|
|
|
|
} else if (configProperties.getScanCodeMode().getTray() == 3 ) {
|
|
|
|
// //RFID
|
|
|
|
// //RFID
|
|
|
|
// RFID rfid = rfidService.getRFIDByPlc(street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
// RFID rfid = rfidService.getRFIDByPlc(street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
Set<String> tags = new HashSet<>();
|
|
|
|
Set<String> tags = new HashSet<>();
|
|
|
|
@ -669,6 +694,7 @@ public class PlcService {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
tags = RFIDStop(plcCmdInfo);
|
|
|
|
tags = RFIDStop(plcCmdInfo);
|
|
|
|
|
|
|
|
log.info("盘点rfid扫描结果:"+tags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tags != null && tags.size() > 0 && tags.contains(wmsTrayCode)) {
|
|
|
|
if (tags != null && tags.size() > 0 && tags.contains(wmsTrayCode)) {
|
|
|
|
|
|
|
|
|
|
|
|
@ -686,10 +712,10 @@ public class PlcService {
|
|
|
|
RfidLive rfidLive = rfidLiveService.getOne(new QueryWrapper<RfidLive>()
|
|
|
|
RfidLive rfidLive = rfidLiveService.getOne(new QueryWrapper<RfidLive>()
|
|
|
|
.eq("street_Id", street.getId())
|
|
|
|
.eq("street_Id", street.getId())
|
|
|
|
.eq("direction", plcCmdInfo.getFromDirection())
|
|
|
|
.eq("direction", plcCmdInfo.getFromDirection())
|
|
|
|
.eq("side", plcCmdInfo.getSide1())
|
|
|
|
.eq("side", plcCmdInfo.getFromSeparation())
|
|
|
|
.eq("rfid_row", plcCmdInfo.getRow1())
|
|
|
|
.eq("rfid_row", plcCmdInfo.getRow1())
|
|
|
|
.eq("rfid_column", plcCmdInfo.getRow1()));
|
|
|
|
.eq("rfid_column", plcCmdInfo.getColumn1()));
|
|
|
|
if (ToolUtil.isNotEmpty(rfidLive) && ToolUtil.isNotEmpty(rfidLive.getRfidTrayCode()) && rfidLive.getRfidTrayCode().equals(wmsTrayCode)) {
|
|
|
|
if (ToolUtil.isNotEmpty(rfidLive) && ToolUtil.isNotEmpty(rfidLive.getRfidTrayCode()) && rfidLive.getRfidTrayCode().contains(wmsTrayCode)) {
|
|
|
|
trayCode = wmsTrayCode;
|
|
|
|
trayCode = wmsTrayCode;
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
log.info("数据库查询rfid", trayCode);
|
|
|
|
log.info("数据库查询rfid", trayCode);
|
|
|
|
@ -820,6 +846,7 @@ public class PlcService {
|
|
|
|
* @param fromOrTo 确定方向
|
|
|
|
* @param fromOrTo 确定方向
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void RFIDCheck(PlcCmdInfo plcCmdInfo, boolean fromOrTo) {
|
|
|
|
public void RFIDCheck(PlcCmdInfo plcCmdInfo, boolean fromOrTo) {
|
|
|
|
|
|
|
|
log.info("开启rfid");
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
if (street != null) {
|
|
|
|
if (street != null) {
|
|
|
|
//rfid不分左右,rfid使用同一ip和端口,依靠传递字符调整方向
|
|
|
|
//rfid不分左右,rfid使用同一ip和端口,依靠传递字符调整方向
|
|
|
|
@ -837,7 +864,6 @@ public class PlcService {
|
|
|
|
RFIDSocket rfidSocket = new RFIDSocket(ip, port);
|
|
|
|
RFIDSocket rfidSocket = new RFIDSocket(ip, port);
|
|
|
|
log.info("rfid调用,ip:"+ip+";port:"+port);
|
|
|
|
log.info("rfid调用,ip:"+ip+";port:"+port);
|
|
|
|
rfidSocket.startCheck(direction);
|
|
|
|
rfidSocket.startCheck(direction);
|
|
|
|
rfidSocket.readData();
|
|
|
|
|
|
|
|
RFIDMap.put(streetId, rfidSocket);
|
|
|
|
RFIDMap.put(streetId, rfidSocket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -848,7 +874,7 @@ public class PlcService {
|
|
|
|
if (rfidSocket != null) {
|
|
|
|
if (rfidSocket != null) {
|
|
|
|
tags = rfidSocket.getTags();
|
|
|
|
tags = rfidSocket.getTags();
|
|
|
|
log.info("tags:{}", tags);
|
|
|
|
log.info("tags:{}", tags);
|
|
|
|
rfidSocket.close();
|
|
|
|
rfidSocket.stopCheck();
|
|
|
|
RFIDMap.remove(street.getId());
|
|
|
|
RFIDMap.remove(street.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tags;
|
|
|
|
return tags;
|
|
|
|
@ -861,9 +887,9 @@ public class PlcService {
|
|
|
|
RFIDSocket rfidSocket = RFIDMap.get(street.getId());
|
|
|
|
RFIDSocket rfidSocket = RFIDMap.get(street.getId());
|
|
|
|
String tags = "";
|
|
|
|
String tags = "";
|
|
|
|
if (rfidSocket != null) {
|
|
|
|
if (rfidSocket != null) {
|
|
|
|
tags = rfidSocket.getTag();
|
|
|
|
|
|
|
|
log.info("tag:{}", tags);
|
|
|
|
log.info("tag:{}", tags);
|
|
|
|
rfidSocket.close();
|
|
|
|
rfidSocket.stopCheck();
|
|
|
|
|
|
|
|
tags = rfidSocket.getTag();
|
|
|
|
RFIDMap.remove(street.getId());
|
|
|
|
RFIDMap.remove(street.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tags;
|
|
|
|
return tags;
|
|
|
|
|