|
|
|
@ -16,6 +16,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import java.net.InetAddress;
|
|
|
|
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
@ -525,17 +527,16 @@ public class PlcService {
|
|
|
|
log.info("test endTime:{},time:{}millisecond",endTime,(endTime - startTime));
|
|
|
|
log.info("test endTime:{},time:{}millisecond",endTime,(endTime - startTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Boolean check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode){
|
|
|
|
public Stock check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode){
|
|
|
|
|
|
|
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getLeftRight1());
|
|
|
|
if(street == null){
|
|
|
|
gyrateCameraByCode(cameraId, cmdCode);
|
|
|
|
return new Stock();
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime());
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
//台湾项目只有托盘码,使用sick扫码枪,
|
|
|
|
|
|
|
|
//使用球机直接拍照,并把图片返回给wcs
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
|
|
|
|
cameraCapture(cameraId,false,null,path);
|
|
|
|
cameraCapture(cameraId,false,null,path);
|
|
|
|
//托盘码
|
|
|
|
//托盘码
|
|
|
|
@ -546,7 +547,7 @@ public class PlcService {
|
|
|
|
//托盘使用sick扫码枪
|
|
|
|
//托盘使用sick扫码枪
|
|
|
|
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
if(sensorGun == null){
|
|
|
|
if(sensorGun == null){
|
|
|
|
trayCode = "识别异常";
|
|
|
|
trayCode = "識別異常";
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
log.error("no sensor gun config in database ,street id:{},direction:{}",street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
log.error("no sensor gun config in database ,street id:{},direction:{}",street.getId(),plcCmdInfo.getLeftRight1());
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
@ -559,13 +560,13 @@ public class PlcService {
|
|
|
|
trayCode = "";
|
|
|
|
trayCode = "";
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
trayCode = "识别异常";
|
|
|
|
trayCode = "識別異常";
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
log.warn("sick ocr error:{}",trayCode);
|
|
|
|
log.warn("sick ocr error:{}",trayCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
if(StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")){
|
|
|
|
if(StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")){
|
|
|
|
trayCode = "识别异常";
|
|
|
|
trayCode = "識別異常";
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
log.warn("sick ocr error:{}",trayCode);
|
|
|
|
log.warn("sick ocr error:{}",trayCode);
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
@ -580,19 +581,77 @@ public class PlcService {
|
|
|
|
RFID rfid = rfidService.getRFIDByPlc(street.getId());
|
|
|
|
RFID rfid = rfidService.getRFIDByPlc(street.getId());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StockCheckRunnable stockCheckRunnable = new StockCheckRunnable(street,plcCmdInfo,cmdCode,stockMapper,path,checkLogMapper,configProperties.getScanCodeMode().getGoods(),wmsCode,wmsTrayCode,trayCode,trayCheck,configProperties);
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode);
|
|
|
|
threadPoolExecutor.execute(stockCheckRunnable);
|
|
|
|
Stock stock = stockMapper.getByShelveIdAndRowColumn(orderInfo.getShelveId(),orderInfo.getRow(),orderInfo.getColumn());
|
|
|
|
|
|
|
|
Integer status = 1;
|
|
|
|
|
|
|
|
//托盘
|
|
|
|
|
|
|
|
if(trayCheck ){
|
|
|
|
|
|
|
|
status = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(stock == null){
|
|
|
|
|
|
|
|
stock = new Stock();
|
|
|
|
|
|
|
|
stock.setStatus(status);
|
|
|
|
|
|
|
|
stock.setShelveId(orderInfo.getShelveId());
|
|
|
|
|
|
|
|
stock.setRow(orderInfo.getRow());
|
|
|
|
|
|
|
|
stock.setColumn(orderInfo.getColumn());
|
|
|
|
|
|
|
|
stock.setLotnum(plcCmdInfo.getLotnum());
|
|
|
|
|
|
|
|
stock.setExportTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
stock.setCheckPic(path);
|
|
|
|
|
|
|
|
stock.setCheckNum(plcCmdInfo.getOrderNum());
|
|
|
|
|
|
|
|
stock.setTrayCode(trayCode);
|
|
|
|
|
|
|
|
stock.setWmsTrayCode(wmsTrayCode);
|
|
|
|
|
|
|
|
stockMapper.insert(stock);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
stock.setStatus(status);
|
|
|
|
|
|
|
|
stock.setShelveId(orderInfo.getShelveId());
|
|
|
|
|
|
|
|
stock.setRow(orderInfo.getRow());
|
|
|
|
|
|
|
|
stock.setColumn(orderInfo.getColumn());
|
|
|
|
|
|
|
|
stock.setLotnum(plcCmdInfo.getLotnum());
|
|
|
|
|
|
|
|
stock.setExportTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
stock.setCheckPic(path);
|
|
|
|
|
|
|
|
stock.setCheckNum(plcCmdInfo.getOrderNum());
|
|
|
|
|
|
|
|
stock.setTrayCode(trayCode);
|
|
|
|
|
|
|
|
stock.setWmsTrayCode(wmsTrayCode);
|
|
|
|
|
|
|
|
stockMapper.updateById(stock);
|
|
|
|
|
|
|
|
}
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
long s = end - startTime;
|
|
|
|
long s = end - startTime;
|
|
|
|
log.info("time:{}millisecond",s);
|
|
|
|
log.debug("time:{}millisecond",s);
|
|
|
|
return true;
|
|
|
|
String ip = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ip = InetAddress.getLocalHost().getHostAddress()+"\\"+configProperties.getSavePath().getMediaPath()+path;
|
|
|
|
|
|
|
|
} catch (UnknownHostException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String p = path.substring(path.lastIndexOf("\\")+1,path.lastIndexOf("."));
|
|
|
|
|
|
|
|
stock.setCheckPicTaiWan(ip);
|
|
|
|
|
|
|
|
stock.setCheckPathTaiWan(p);
|
|
|
|
|
|
|
|
//判断照片是否存在,确认已保存再返回
|
|
|
|
|
|
|
|
//return checkPathExist(stock);
|
|
|
|
|
|
|
|
checkLog(stock);
|
|
|
|
|
|
|
|
return stock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void truncateStock(){
|
|
|
|
public void truncateStock(){
|
|
|
|
stockMapper.truncate();
|
|
|
|
stockMapper.truncate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void checkLog(Stock stock){
|
|
|
|
|
|
|
|
CheckLog checkLog = new CheckLog();
|
|
|
|
|
|
|
|
checkLog.setLotnum(stock.getLotnum());
|
|
|
|
|
|
|
|
checkLog.setCheckNum(stock.getCheckNum());
|
|
|
|
|
|
|
|
checkLog.setPic(stock.getCheckPic());
|
|
|
|
|
|
|
|
checkLog.setShelveId(stock.getShelveId());
|
|
|
|
|
|
|
|
checkLog.setCode(stock.getCode());
|
|
|
|
|
|
|
|
checkLog.setWmsCode(stock.getWmsCode());
|
|
|
|
|
|
|
|
checkLog.setStatus(stock.getStatus());
|
|
|
|
|
|
|
|
checkLog.setRow(stock.getRow());
|
|
|
|
|
|
|
|
checkLog.setColumn(stock.getColumn());
|
|
|
|
|
|
|
|
checkLog.setCreateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
checkLog.setTrayCode(stock.getTrayCode());
|
|
|
|
|
|
|
|
checkLog.setWmsTrayCode(stock.getWmsTrayCode());
|
|
|
|
|
|
|
|
checkLog.setLotnum(stock.getLotnum());
|
|
|
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|