|
|
|
|
@ -389,10 +389,10 @@ public class PlcService {
|
|
|
|
|
Integer ptzId = cameraService.getPtzIdByCodeAndCameraId(code, cameraId);
|
|
|
|
|
if (ptzId != null && ptzId >= 0) {
|
|
|
|
|
log.info("gyrate camera by code, code:{},cameraId:{},ptId:{}", code, cameraId, ptzId);
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
cameraControlModule.toPtz(ptzId, cameraId);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.info("摄像头没有读取到 , code:{},cameraId:{},ptId:{}", code, cameraId, ptzId);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
@ -400,10 +400,11 @@ public class PlcService {
|
|
|
|
|
log.error("ptz not found ,code:{},cameraId:{}", code, cameraId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void gyrateCameraByCode(Integer cameraId, String code,String taskId) {
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
log.info("gyrate camera by code, code:{},cameraId:{},ptId:{},taskId:{}", code, cameraId, ptzId, taskId);
|
|
|
|
|
cameraControlModule.toPtz(ptzId, cameraId);
|
|
|
|
|
} else {
|
|
|
|
|
log.error("ptz not found ,code:{},cameraId:{}", code, cameraId);
|
|
|
|
|
@ -601,6 +602,7 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Integer getCameraByPlcCmdE(PlcCmdInfo plcCmdInfo, Integer leftRight) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
Integer type;
|
|
|
|
|
@ -611,6 +613,7 @@ public class PlcService {
|
|
|
|
|
return street.getCamera2Id();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private LightSourceMapper lightSourceMapper;
|
|
|
|
|
|
|
|
|
|
@ -634,7 +637,7 @@ public class PlcService {
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(), lightSource.getPort(), configProperties.getLightSource().getIndex(), 1);
|
|
|
|
|
});
|
|
|
|
|
log.info("盘点摄像头变化参数:"+plcCmdInfo.toString());
|
|
|
|
|
log.info("盘点摄像头变化参数:" + plcCmdInfo.toString());
|
|
|
|
|
Integer cameraId = getCameraByPlcCmdE(plcCmdInfo, plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
|
|
if (plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2) {
|
|
|
|
|
@ -656,20 +659,19 @@ public class PlcService {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
cameraCapture(cameraId, false, null, path);
|
|
|
|
|
}catch (NullPointerException e){
|
|
|
|
|
log.error("相机{}未连接无法拍照",cameraId);
|
|
|
|
|
} catch (NullPointerException e) {
|
|
|
|
|
log.error("相机{}未连接无法拍照", cameraId);
|
|
|
|
|
}
|
|
|
|
|
//托盘码
|
|
|
|
|
String trayCode = null;
|
|
|
|
|
Boolean trayCheck = Boolean.TRUE;
|
|
|
|
|
//如果是用扫码枪 扫 托盘码,就直接扫
|
|
|
|
|
//if(configProperties.getScanCodeMode().getTray() == 2){
|
|
|
|
|
log.info("扫码类型:"+configProperties.getScanCodeMode().getTray());
|
|
|
|
|
if (plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2) {
|
|
|
|
|
log.info("扫码类型:" + configProperties.getScanCodeMode().getTray());
|
|
|
|
|
//托盘使用sick扫码枪
|
|
|
|
|
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(), plcCmdInfo.getLeftRight1());
|
|
|
|
|
if (sensorGun == null) {
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCode = "扫码枪识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
log.error("no sensor gun config in database ,street id:{},direction:{}", street.getId(), plcCmdInfo.getLeftRight1());
|
|
|
|
|
} else {
|
|
|
|
|
@ -682,97 +684,68 @@ public class PlcService {
|
|
|
|
|
trayCode = "";
|
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
|
} else {
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCode = "扫码枪识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
log.warn("sick ocr error:{}", trayCode);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")) {
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCode = "扫码枪识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
log.warn("sick ocr error:{}", trayCode);
|
|
|
|
|
} else {
|
|
|
|
|
trayCheck = wmsTrayCode.equals(trayCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (configProperties.getScanCodeMode().getTray() == 3 ) {
|
|
|
|
|
// //RFID
|
|
|
|
|
// RFID
|
|
|
|
|
// RFID rfid = rfidService.getRFIDByPlc(street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
|
|
|
|
|
Boolean trayRFIDCheck = Boolean.FALSE;
|
|
|
|
|
|
|
|
|
|
Set<String> tags = new HashSet<>();
|
|
|
|
|
try {
|
|
|
|
|
RFIDCheck(plcCmdInfo,true);
|
|
|
|
|
RFIDCheck(plcCmdInfo, true);
|
|
|
|
|
Thread.sleep(1000 * configProperties.getRfid().getScanTime());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
tags = RFIDStop(plcCmdInfo);
|
|
|
|
|
log.info("盘点rfid扫描结果:"+tags);
|
|
|
|
|
log.info("盘点rfid扫描结果:" + tags);
|
|
|
|
|
}
|
|
|
|
|
if (tags != null && tags.size() > 0 ) {
|
|
|
|
|
if (tags != null && tags.size() > 0) {
|
|
|
|
|
|
|
|
|
|
if(tags.containsAll(wmsTrayCodeMapByTask.get(plcCmdInfo.getOrderNum()))) {
|
|
|
|
|
if (tags.containsAll(wmsTrayCodeMapByTask.get(plcCmdInfo.getOrderNum()))) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trayCode = "盘点正常";
|
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
trayCode = "盘点失败";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
trayRFIDCheck = Boolean.TRUE;
|
|
|
|
|
} else {
|
|
|
|
|
if(trayCheck){
|
|
|
|
|
trayCode = "RFID扫描失败";
|
|
|
|
|
}else
|
|
|
|
|
trayCode += ";RFID扫描失败";
|
|
|
|
|
trayRFIDCheck = Boolean.FALSE;
|
|
|
|
|
}
|
|
|
|
|
wmsTrayCodeMapByTask.remove(plcCmdInfo.getOrderNum());
|
|
|
|
|
RFID rfid = rfidMapper.selectOne(new QueryWrapper<RFID>().eq("street_id", street.getId()));
|
|
|
|
|
if(! rfidLiveService.getRfidLive(plcCmdInfo,street,wmsTrayCode)){
|
|
|
|
|
rfidLiveService.rfidRemoveLive(plcCmdInfo,street,rfid);
|
|
|
|
|
if (!rfidLiveService.getRfidLive(plcCmdInfo, street, wmsTrayCode)) {
|
|
|
|
|
rfidLiveService.rfidRemoveLive(plcCmdInfo, street, rfid);
|
|
|
|
|
}
|
|
|
|
|
rfidLiveService.rfidSave(plcCmdInfo, String.join(",", tags),street,rfid);
|
|
|
|
|
rfidLiveService.rfidSave(plcCmdInfo, String.join(",", tags), street, rfid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode);
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getFromDirection(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
|
|
|
|
|
String scanCode = null;
|
|
|
|
|
Boolean codeCheck = Boolean.TRUE;
|
|
|
|
|
Boolean trayCodeCheck = Boolean.TRUE;
|
|
|
|
|
//货物使用球机扫码
|
|
|
|
|
|
|
|
|
|
if (configProperties.getScanCodeMode().getTray() == 2 && plcCmdInfo.getSeparation1() == 2) {
|
|
|
|
|
//托盘使用球机扫码
|
|
|
|
|
if ("".equals(wmsTrayCode)) {
|
|
|
|
|
//空货物的处理
|
|
|
|
|
//如果系统货物为空,则只要扫码识别未出结果,就认为无货物
|
|
|
|
|
trayCode = BarcodeDetector.detectBestCodeUntilOK(configProperties.getSavePath().getMediaPath() + path, configProperties.getScanCodeMode().getTrayCodeTypes());
|
|
|
|
|
log.info("tray code:{},sys trayCode:{}", trayCode, wmsTrayCode);
|
|
|
|
|
if (StringUtils.isEmpty(trayCode) || trayCode.equals("Unrecognized")) {
|
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
|
trayCode = "";
|
|
|
|
|
} else {
|
|
|
|
|
trayCheck = wmsTrayCode.equals(trayCode);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
trayCode = BarcodeDetector.detectBestCodeUntilOK(configProperties.getSavePath().getMediaPath() + path, configProperties.getScanCodeMode().getTrayCodeTypes());
|
|
|
|
|
if (StringUtils.isEmpty(trayCode)) {
|
|
|
|
|
log.error("row:{},cloumn:{}", plcCmdInfo.getRow1(), plcCmdInfo.getColumn1());
|
|
|
|
|
log.error("detectBestBarCode:{}", trayCode);
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
} else {
|
|
|
|
|
trayCheck = wmsTrayCode.equals(trayCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//货物使用球机扫码
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
log.info("code:{}", scanCode);
|
|
|
|
|
//核对异常
|
|
|
|
|
Integer status = 1;
|
|
|
|
|
//托盘和货物都正确
|
|
|
|
|
if (trayCheck && codeCheck) {
|
|
|
|
|
if (trayCheck && trayRFIDCheck ) {
|
|
|
|
|
status = 2;
|
|
|
|
|
}
|
|
|
|
|
if (stock == null) {
|
|
|
|
|
@ -818,7 +791,7 @@ public class PlcService {
|
|
|
|
|
.type("InventoryPush")
|
|
|
|
|
.build();
|
|
|
|
|
try {
|
|
|
|
|
WebSocketServer.sendInfo(JSONObject.toJSONString(webSocketVo),"");
|
|
|
|
|
WebSocketServer.sendInfo(JSONObject.toJSONString(webSocketVo), "");
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
@ -826,7 +799,6 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void checkLog(Stock stock) {
|
|
|
|
|
CheckLog checkLog = new CheckLog();
|
|
|
|
|
checkLog.setCheckNum(stock.getCheckNum());
|
|
|
|
|
@ -852,6 +824,7 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据信息开启rfid链接
|
|
|
|
|
*
|
|
|
|
|
* @param plcCmdInfo 相关信息
|
|
|
|
|
* @param fromOrTo 确定方向
|
|
|
|
|
*/
|
|
|
|
|
@ -864,7 +837,7 @@ public class PlcService {
|
|
|
|
|
if (rfid != null) {
|
|
|
|
|
if (fromOrTo) {
|
|
|
|
|
RFIDStart(rfid.getIp(), rfid.getPort(), street.getId(), plcCmdInfo.getFromDirection());
|
|
|
|
|
}else
|
|
|
|
|
} else
|
|
|
|
|
RFIDStart(rfid.getIp(), rfid.getPort(), street.getId(), plcCmdInfo.getToDirection());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -872,8 +845,8 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
public void RFIDStart(String ip, Integer port, Integer streetId, Integer direction) {
|
|
|
|
|
RFIDSocket rfidSocket = new RFIDSocket(ip, port);
|
|
|
|
|
log.info("rfid调用,ip:"+ip+";port:"+port);
|
|
|
|
|
rfidSocket.startCheck(direction,true);
|
|
|
|
|
log.info("rfid调用,ip:" + ip + ";port:" + port);
|
|
|
|
|
rfidSocket.startCheck(direction, true);
|
|
|
|
|
RFIDMap.put(streetId, rfidSocket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|