|
|
|
|
@ -593,7 +593,7 @@ public class PlcService {
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1);
|
|
|
|
|
});
|
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
|
|
log.info("1");
|
|
|
|
|
gyrateCameraByCode(cameraId, cmdCode);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime());
|
|
|
|
|
@ -601,92 +601,56 @@ public class PlcService {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
|
|
|
|
|
log.info("2");
|
|
|
|
|
cameraCapture(cameraId,false,null,path);
|
|
|
|
|
//托盘码
|
|
|
|
|
String trayCode = null;
|
|
|
|
|
Boolean trayCheck = Boolean.TRUE;
|
|
|
|
|
//如果是用扫码枪 扫 托盘码,就直接扫
|
|
|
|
|
//if(configProperties.getScanCodeMode().getTray() == 2){
|
|
|
|
|
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
|
if(plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2){
|
|
|
|
|
//托盘使用sick扫码枪
|
|
|
|
|
|
|
|
|
|
if(sensorGun == null){
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
log.error("no sensor gun config in database ,street id:{},direction:{}",street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
|
}else {
|
|
|
|
|
trayCode = SickSocket.readOCR(sensorGun.getIp(),sensorGun.getPort());
|
|
|
|
|
log.info("sensor tray code:{}",trayCode);
|
|
|
|
|
if("".equals(wmsTrayCode)){
|
|
|
|
|
//托盘码为空,无货物
|
|
|
|
|
//只要扫码枪未识别出条码,即认为盘点正确
|
|
|
|
|
if(StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")){
|
|
|
|
|
trayCode = "";
|
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
|
}else {
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
log.warn("sick ocr error:{}",trayCode);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
if(StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")){
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
log.warn("sick ocr error:{}",trayCode);
|
|
|
|
|
}else {
|
|
|
|
|
trayCheck = wmsTrayCode.equals(trayCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
log.info("3");
|
|
|
|
|
//重庆项目 单身,只用扫码枪
|
|
|
|
|
|
|
|
|
|
}else if(configProperties.getScanCodeMode().getTray() == 3){
|
|
|
|
|
//RFID
|
|
|
|
|
RFID rfid = rfidService.getRFIDByPlc(street.getId());
|
|
|
|
|
}
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode);
|
|
|
|
|
Stock stock = stockMapper.getByShelveIdAndRowColumn(orderInfo.getShelveId(),orderInfo.getRow(),orderInfo.getColumn());
|
|
|
|
|
String scanCode = null;
|
|
|
|
|
Boolean codeCheck = Boolean.TRUE;
|
|
|
|
|
Boolean trayCodeCheck = Boolean.TRUE;
|
|
|
|
|
//货物使用球机扫码
|
|
|
|
|
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
|
|
if(configProperties.getScanCodeMode().getTray() == 2 && plcCmdInfo.getSeparation1() == 2){
|
|
|
|
|
//托盘使用球机扫码
|
|
|
|
|
if(sensorGun == null){
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
log.error("no sensor gun config in database ,street id:{},direction:{}",street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
|
}else {
|
|
|
|
|
log.info("sensor ip:{},port:{}",sensorGun.getIp(),sensorGun.getPort());
|
|
|
|
|
trayCode = SickSocket.readOCR(sensorGun.getIp(),sensorGun.getPort());
|
|
|
|
|
log.info("sensor tray code:{}",trayCode);
|
|
|
|
|
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;
|
|
|
|
|
//托盘码为空,无货物
|
|
|
|
|
//只要扫码枪未识别出条码,即认为盘点正确
|
|
|
|
|
if(StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")){
|
|
|
|
|
trayCode = "";
|
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
|
}else {
|
|
|
|
|
trayCheck = wmsTrayCode.equals(trayCode);
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
log.warn("sick ocr error:{}",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);
|
|
|
|
|
if(StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")){
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
log.warn("sick ocr error:{}",trayCode);
|
|
|
|
|
}else {
|
|
|
|
|
trayCheck = wmsTrayCode.equals(trayCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
log.info("code:{}",scanCode);
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode);
|
|
|
|
|
Stock stock = stockMapper.getByShelveIdAndRowColumn(orderInfo.getShelveId(),orderInfo.getRow(),orderInfo.getColumn());
|
|
|
|
|
//核对异常
|
|
|
|
|
Integer status = 1;
|
|
|
|
|
//托盘和货物都正确
|
|
|
|
|
if(trayCheck && codeCheck){
|
|
|
|
|
if(trayCheck){
|
|
|
|
|
status = 2;
|
|
|
|
|
}
|
|
|
|
|
if(stock == null){
|
|
|
|
|
stock = new Stock(null,null,plcCmdInfo.getOrderNum(),plcCmdInfo.getLotnum(),scanCode, null,null,wmsCode,null,null,wmsTrayCode,trayCode,orderInfo.getShelveId(),orderInfo.getRow(),orderInfo.getColumn(),status,null,null,path, LocalDateTime.now());
|
|
|
|
|
stock = new Stock(null,null,plcCmdInfo.getOrderNum(),plcCmdInfo.getLotnum(),null, null,null,wmsCode,null,null,wmsTrayCode,trayCode,orderInfo.getShelveId(),orderInfo.getRow(),orderInfo.getColumn(),status,null,null,path, LocalDateTime.now());
|
|
|
|
|
stockMapper.insert(stock);
|
|
|
|
|
}else {
|
|
|
|
|
stock.setStatus(status);
|
|
|
|
|
@ -696,14 +660,9 @@ public class PlcService {
|
|
|
|
|
stock.setCheckNum(plcCmdInfo.getOrderNum());
|
|
|
|
|
stock.setTrayCode(trayCode);
|
|
|
|
|
stock.setWmsTrayCode(wmsTrayCode);
|
|
|
|
|
stock.setCode(scanCode);
|
|
|
|
|
stock.setWmsCode(wmsCode);
|
|
|
|
|
stockMapper.updateById(stock);
|
|
|
|
|
}
|
|
|
|
|
checkLog(stock);
|
|
|
|
|
// StockCheckRunnable stockCheckRunnable = new StockCheckRunnable(street,plcCmdInfo,cmdCode,stockMapper,path,checkLogMapper,configProperties.getScanCodeMode().getGoods(),wmsCode,wmsTrayCode,trayCode,trayCheck,configProperties,sensorGun);
|
|
|
|
|
// threadPoolExecutor.execute(stockCheckRunnable);
|
|
|
|
|
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
|
long s = end - startTime;
|
|
|
|
|
log.info("time:{}millisecond",s);
|
|
|
|
|
|