|
|
|
@ -11,6 +11,7 @@ import com.zhehekeji.web.lib.*;
|
|
|
|
import com.zhehekeji.web.mapper.*;
|
|
|
|
import com.zhehekeji.web.mapper.*;
|
|
|
|
import com.zhehekeji.web.pojo.CameraPtzPojo;
|
|
|
|
import com.zhehekeji.web.pojo.CameraPtzPojo;
|
|
|
|
import com.zhehekeji.web.pojo.OrderVO;
|
|
|
|
import com.zhehekeji.web.pojo.OrderVO;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.pojo.stock.StockStatus;
|
|
|
|
import com.zhehekeji.web.service.RFID.RFIDMap;
|
|
|
|
import com.zhehekeji.web.service.RFID.RFIDMap;
|
|
|
|
import com.zhehekeji.web.service.RFID.RFIDSocket;
|
|
|
|
import com.zhehekeji.web.service.RFID.RFIDSocket;
|
|
|
|
import com.zhehekeji.web.service.RFID.RFIDSocketFactory;
|
|
|
|
import com.zhehekeji.web.service.RFID.RFIDSocketFactory;
|
|
|
|
@ -41,6 +42,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.aspectj.weaver.tools.cache.SimpleCacheFactory.path;
|
|
|
|
import static org.aspectj.weaver.tools.cache.SimpleCacheFactory.path;
|
|
|
|
|
|
|
|
|
|
|
|
@ -652,7 +654,26 @@ public class PlcService {
|
|
|
|
public Boolean check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode,String wmsCatagary){
|
|
|
|
public Boolean check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode,String wmsCatagary){
|
|
|
|
|
|
|
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//开始盘点具体货位
|
|
|
|
|
|
|
|
CheckLog checkLog = new CheckLog();
|
|
|
|
|
|
|
|
checkLog.setStreetId(street.getId());
|
|
|
|
|
|
|
|
checkLog.setLotnum(plcCmdInfo.getLotnum());
|
|
|
|
|
|
|
|
checkLog.setDirection(plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
checkLog.setSide(plcCmdInfo.getSide1());
|
|
|
|
|
|
|
|
checkLog.setRow(plcCmdInfo.getRow1());
|
|
|
|
|
|
|
|
checkLog.setColumn(plcCmdInfo.getColumn1());
|
|
|
|
|
|
|
|
checkLog.setWmsCode(plcCmdInfo.getCode());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkLog.setTaskId((plcCmdInfo.getTaskId()));
|
|
|
|
|
|
|
|
//默认未盘点
|
|
|
|
|
|
|
|
checkLog.setStatus(StockStatus.PENDING.getStatus());
|
|
|
|
|
|
|
|
checkLog.setCreateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
checkLog.setWmsCategory(plcCmdInfo.getTypeNum());
|
|
|
|
|
|
|
|
checkLog.setWmsCount(plcCmdInfo.getQuantity());
|
|
|
|
|
|
|
|
|
|
|
|
CronTab.putTime(street.getId());
|
|
|
|
CronTab.putTime(street.getId());
|
|
|
|
List<LightSource> lightSources = lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",street.getId()));
|
|
|
|
List<LightSource> lightSources = lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",street.getId()));
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
@ -680,76 +701,26 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg", cameraId, plcCmdInfo.getRow1(), plcCmdInfo.getColumn1());
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg", cameraId, plcCmdInfo.getRow1(), plcCmdInfo.getColumn1());
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
cameraCapture(cameraId, false, null, path);
|
|
|
|
cameraCapture(cameraId, false, null, path);
|
|
|
|
} catch (NullPointerException e) {
|
|
|
|
} catch (NullPointerException e) {
|
|
|
|
log.error("相机{}未连接无法拍照", cameraId);
|
|
|
|
log.error("相机{}未连接无法拍照", cameraId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkLog.setPic(path);
|
|
|
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
//托盘码
|
|
|
|
//托盘码
|
|
|
|
String trayCode = null;
|
|
|
|
String trayCode = null;
|
|
|
|
Boolean trayCheck = Boolean.TRUE;
|
|
|
|
Boolean trayCheck = Boolean.TRUE;
|
|
|
|
//扫托盘码
|
|
|
|
//扫托盘码
|
|
|
|
if(configProperties.getScanCodeMode().getTray() == 2) {
|
|
|
|
trayCheck = scan(configProperties.getScanCodeMode().getTray(),street,plcCmdInfo,checkLog,trayCode);
|
|
|
|
log.info("扫码类型:" + configProperties.getScanCodeMode().getTray());
|
|
|
|
|
|
|
|
//托盘使用sick扫码枪
|
|
|
|
|
|
|
|
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(), plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
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 = Boolean.TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else if(configProperties.getScanCodeMode().getTray() == 3){
|
|
|
|
|
|
|
|
//扫到的码
|
|
|
|
|
|
|
|
Set<String> tags = new HashSet<>();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
RFIDCheck(plcCmdInfo, true);
|
|
|
|
|
|
|
|
Thread.sleep(1000 * configProperties.getRfid().getScanTime());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
tags = RFIDStop(plcCmdInfo);
|
|
|
|
|
|
|
|
log.info("盘点rfid扫描结果:" + tags);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tags !=null && tags.contains(wmsTrayCode)) {
|
|
|
|
|
|
|
|
//托盘码为空,无货物
|
|
|
|
|
|
|
|
//只要扫码枪未识别出条码,即认为盘点正确
|
|
|
|
|
|
|
|
trayCode = wmsTrayCode;
|
|
|
|
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
trayCode = trayCode+ "扫码枪识别异常";
|
|
|
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
|
|
|
log.warn("rfid error:{}", trayCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
String trayGoodCode = null;
|
|
|
|
Boolean trayGoodCheck = Boolean.TRUE;
|
|
|
|
Boolean trayGoodCheck = scan(configProperties.getScanCodeMode().getGoods(),street,plcCmdInfo,checkLog,trayGoodCode);
|
|
|
|
|
|
|
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode);
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode);
|
|
|
|
//扫货物
|
|
|
|
//扫货物
|
|
|
|
@ -786,7 +757,8 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if(configProperties.getScanCodeMode().getGoods() == 3){
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(configProperties.getScanCodeMode().getGoods() == 3){
|
|
|
|
Set<String> tags = new HashSet<>();
|
|
|
|
Set<String> tags = new HashSet<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
RFIDCheck(plcCmdInfo, true);
|
|
|
|
RFIDCheck(plcCmdInfo, true);
|
|
|
|
@ -809,31 +781,49 @@ public class PlcService {
|
|
|
|
log.warn("rfid error:{}", trayCode);
|
|
|
|
log.warn("rfid error:{}", trayCode);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if (configProperties.getScanCodeMode().getGoods() == 4){
|
|
|
|
}else
|
|
|
|
//开始盘点
|
|
|
|
if (configProperties.getScanCodeMode().getGoods() == 4){
|
|
|
|
String goodLocation = orderInfo.getStreetId().toString()+"_"+ plcCmdInfo.getLeftRight1().toString()+"_"+ orderInfo.getSeparation().toString()+"_"+ orderInfo.getRow().toString()+"_"+ orderInfo.getColumn();
|
|
|
|
TransmissionPojo transmissionPojo = new TransmissionPojo(checkLog, street);
|
|
|
|
SCTransmission scTransmission = new SCTransmission(street.getPlcId(),plcCmdInfo.getTaskId(),goodLocation,plcCmdInfo.getTypeNum(), plcCmdInfo.getQuantity(), "N");
|
|
|
|
if (ClientChanel.get(plcCmdInfo.getPlcId()) != null) {
|
|
|
|
|
|
|
|
ClientChanel.get(plcCmdInfo.getPlcId()).writeAndFlush(transmissionPojo.toString(TransmissionType.ST));
|
|
|
|
String scTransmissionStr = scTransmission.toString();
|
|
|
|
} else {
|
|
|
|
ClientChanel.write(scTransmissionStr,street.getPlcId());
|
|
|
|
log.error("未找到对应plc" + transmissionPojo.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//取货完成进行拍照
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Thread.sleep(500);
|
|
|
|
Thread.sleep(50L);
|
|
|
|
|
|
|
|
//不为其他状态进入队列
|
|
|
|
|
|
|
|
if (lock.tryLock()) {
|
|
|
|
|
|
|
|
//队列中没有任务,发送取图指令
|
|
|
|
|
|
|
|
//只采用队列,队列中有数据则自动发送
|
|
|
|
|
|
|
|
//模拟随行
|
|
|
|
|
|
|
|
if (configProperties.isInventorySimulationFollow() ) {
|
|
|
|
|
|
|
|
TransmissionPojo transmissionPojoFollow = new TransmissionPojo(street, transmissionPojo.getRow(),transmissionPojo.getColumn(),transmissionPojo.getDirection(), "");
|
|
|
|
|
|
|
|
String s = (transmissionPojoFollow).toString(TransmissionType.GPS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//放置到队列中,等待取图返回后删除
|
|
|
|
|
|
|
|
GetPhotoDelayExecutor.addCameraDelayTask(street.getPlcId(), s, configProperties.getQueueSpanTime(),transmissionPojoFollow);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//放置到队列中,等待取图返回后删除
|
|
|
|
|
|
|
|
GetPhotoDelayExecutor.addCameraDelayTask(street.getPlcId(), transmissionPojo.toString(TransmissionType.GPS), configProperties.getQueueSpanTime(),transmissionPojo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
log.error("取图命令 error", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
lock.unlock();
|
|
|
|
|
|
|
|
log.info("盘点完成");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//滁州开始盘点即取货到位
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCTransmission scTransmission2 = new SCTransmission(street.getPlcId(),plcCmdInfo.getTaskId());
|
|
|
|
|
|
|
|
String scTransmissionStr2 = scTransmission2.toSC02String();
|
|
|
|
|
|
|
|
ClientChanel.write(scTransmissionStr2,street.getPlcId());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getLeftRight1(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getLeftRight1(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
|
|
|
|
String scanCode = null;
|
|
|
|
String scanCode = null;
|
|
|
|
|
|
|
|
|
|
|
|
//货物使用球机扫码
|
|
|
|
//货物使用球机扫码
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkLog.setTrayCode(trayCode);
|
|
|
|
log.info("code:{}", scanCode);
|
|
|
|
log.info("code:{}", scanCode);
|
|
|
|
//核对异常
|
|
|
|
//核对异常
|
|
|
|
Integer status = 1;
|
|
|
|
Integer status = 1;
|
|
|
|
@ -841,6 +831,8 @@ public class PlcService {
|
|
|
|
if (trayCheck && trayGoodCheck ) {
|
|
|
|
if (trayCheck && trayGoodCheck ) {
|
|
|
|
status = 2;
|
|
|
|
status = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
checkLog.setStatus(status);
|
|
|
|
|
|
|
|
checkLogMapper.updateById(checkLog);
|
|
|
|
if (stock == null) {
|
|
|
|
if (stock == null) {
|
|
|
|
stock = Stock.builder()
|
|
|
|
stock = Stock.builder()
|
|
|
|
.checkNum(plcCmdInfo.getOrderNum())
|
|
|
|
.checkNum(plcCmdInfo.getOrderNum())
|
|
|
|
@ -872,47 +864,115 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// StockCheckRunnable stockCheckRunnable = new StockCheckRunnable(street,plcCmdInfo,cmdCode,stockMapper,path,checkLogMapper,configProperties.getScanCodeMode().getGoods(),wmsCode,wmsTrayCode,trayCode,trayCheck,configProperties,sensorGun);
|
|
|
|
// StockCheckRunnable stockCheckRunnable = new StockCheckRunnable(street,plcCmdInfo,cmdCode,stockMapper,path,checkLogMapper,configProperties.getScanCodeMode().getGoods(),wmsCode,wmsTrayCode,trayCode,trayCheck,configProperties,sensorGun);
|
|
|
|
// threadPoolExecutor.execute(stockCheckRunnable);
|
|
|
|
// threadPoolExecutor.execute(stockCheckRunnable);
|
|
|
|
|
|
|
|
|
|
|
|
//还原相机
|
|
|
|
//还原相机
|
|
|
|
gyrateCameraByCode(cameraId, "C5");
|
|
|
|
gyrateCameraByCode(cameraId, "C5");
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
long s = end - startTime;
|
|
|
|
long timeLong = end - startTime;
|
|
|
|
log.info("time:{}millisecond", s);
|
|
|
|
log.info("time:{}millisecond", timeLong);
|
|
|
|
TransmissionPojo transmissionPojo = new TransmissionPojo(checkLog, street);
|
|
|
|
|
|
|
|
if (ClientChanel.get(dataInfo.getSRMNumber()) != null) {
|
|
|
|
|
|
|
|
ClientChanel.get(dataInfo.getSRMNumber()).writeAndFlush(transmissionPojo.toString(TransmissionType.ST));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.error("未找到对应plc" + transmissionPojo.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//取货完成进行拍照
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(50L);
|
|
|
|
|
|
|
|
//不为其他状态进入队列
|
|
|
|
|
|
|
|
if (lock.tryLock()) {
|
|
|
|
|
|
|
|
//队列中没有任务,发送取图指令
|
|
|
|
|
|
|
|
//只采用队列,队列中有数据则自动发送
|
|
|
|
|
|
|
|
//模拟随行
|
|
|
|
|
|
|
|
if (configProperties.isInventorySimulationFollow() ) {
|
|
|
|
|
|
|
|
TransmissionPojo transmissionPojoFollow = new TransmissionPojo(street, transmissionPojo.getRow(),transmissionPojo.getColumn(),transmissionPojo.getDirection(), "");
|
|
|
|
|
|
|
|
String s = (transmissionPojoFollow).toString(TransmissionType.GPS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//放置到队列中,等待取图返回后删除
|
|
|
|
return true;
|
|
|
|
GetPhotoDelayExecutor.addCameraDelayTask(street.getPlcId(), s, configProperties.getQueueSpanTime(),transmissionPojoFollow);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Boolean scan(int type ,Street street, PlcCmdInfo plcCmdInfo,CheckLog checkLog ,String trayCode){
|
|
|
|
|
|
|
|
Boolean checkBoolean = true;
|
|
|
|
|
|
|
|
if(type == 2) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkBoolean = Boolean.FALSE;
|
|
|
|
|
|
|
|
log.info("扫码类型:" + configProperties.getScanCodeMode().getTray());
|
|
|
|
|
|
|
|
//托盘使用sick扫码枪
|
|
|
|
|
|
|
|
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(), plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
if (sensorGun == null) {
|
|
|
|
|
|
|
|
trayCode = "扫码枪识别异常";
|
|
|
|
|
|
|
|
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(plcCmdInfo.getCode())) {
|
|
|
|
|
|
|
|
//托盘码为空,无货物
|
|
|
|
|
|
|
|
//只要扫码枪未识别出条码,即认为盘点正确
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")) {
|
|
|
|
|
|
|
|
trayCode = "";
|
|
|
|
|
|
|
|
checkBoolean = Boolean.TRUE;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
trayCode = "扫码枪识别异常";
|
|
|
|
|
|
|
|
checkBoolean = Boolean.FALSE;
|
|
|
|
|
|
|
|
log.warn("sick ocr error:{}", trayCode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")) {
|
|
|
|
|
|
|
|
trayCode = "扫码枪识别异常";
|
|
|
|
|
|
|
|
checkBoolean = Boolean.FALSE;
|
|
|
|
|
|
|
|
log.warn("sick ocr error:{}", trayCode);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//扫到就认为正常
|
|
|
|
|
|
|
|
checkBoolean = Boolean.TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//放置到队列中,等待取图返回后删除
|
|
|
|
|
|
|
|
GetPhotoDelayExecutor.addCameraDelayTask(street.getPlcId(), transmissionPojo.toString(TransmissionType.GPS), configProperties.getQueueSpanTime(),transmissionPojo);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(type == 3){
|
|
|
|
|
|
|
|
Set<String> tags = new HashSet<>();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
RFIDCheck(plcCmdInfo, true);
|
|
|
|
|
|
|
|
Thread.sleep(1000 * configProperties.getRfid().getScanTime());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
tags = RFIDStop(plcCmdInfo);
|
|
|
|
|
|
|
|
log.info("盘点rfid扫描结果:" + tags);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tags !=null && tags.contains(plcCmdInfo.getCode())) {
|
|
|
|
|
|
|
|
//托盘码为空,无货物
|
|
|
|
|
|
|
|
//只要扫码枪未识别出条码,即认为盘点正确
|
|
|
|
|
|
|
|
trayCode = plcCmdInfo.getCode();
|
|
|
|
|
|
|
|
checkBoolean = Boolean.TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
trayCode = trayCode+ "扫码枪识别异常";
|
|
|
|
|
|
|
|
checkBoolean = Boolean.FALSE;
|
|
|
|
|
|
|
|
log.warn("rfid error:{}", trayCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if (type == 4){
|
|
|
|
|
|
|
|
TransmissionPojo transmissionPojo = new TransmissionPojo(checkLog, street);
|
|
|
|
|
|
|
|
if (ClientChanel.get(plcCmdInfo.getPlcId()) != null) {
|
|
|
|
|
|
|
|
ClientChanel.get(plcCmdInfo.getPlcId()).writeAndFlush(transmissionPojo.toString(TransmissionType.ST));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.error("未找到对应plc" + transmissionPojo.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//取货完成进行拍照
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(50L);
|
|
|
|
|
|
|
|
//不为其他状态进入队列
|
|
|
|
|
|
|
|
if (lock.tryLock()) {
|
|
|
|
|
|
|
|
//队列中没有任务,发送取图指令
|
|
|
|
|
|
|
|
//只采用队列,队列中有数据则自动发送
|
|
|
|
|
|
|
|
//模拟随行
|
|
|
|
|
|
|
|
if (configProperties.isInventorySimulationFollow() ) {
|
|
|
|
|
|
|
|
TransmissionPojo transmissionPojoFollow = new TransmissionPojo(street, transmissionPojo.getRow(),transmissionPojo.getColumn(),transmissionPojo.getDirection(), "");
|
|
|
|
|
|
|
|
String s = (transmissionPojoFollow).toString(TransmissionType.GPS);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
//放置到队列中,等待取图返回后删除
|
|
|
|
log.error("取图命令 error", e);
|
|
|
|
GetPhotoDelayExecutor.addCameraDelayTask(street.getPlcId(), s, configProperties.getQueueSpanTime(),transmissionPojoFollow);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
lock.unlock();
|
|
|
|
|
|
|
|
log.info("盘点完成");
|
|
|
|
}
|
|
|
|
|
|
|
|
//放置到队列中,等待取图返回后删除
|
|
|
|
|
|
|
|
GetPhotoDelayExecutor.addCameraDelayTask(street.getPlcId(), transmissionPojo.toString(TransmissionType.GPS), configProperties.getQueueSpanTime(),transmissionPojo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
log.error("取图命令 error", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
lock.unlock();
|
|
|
|
|
|
|
|
log.info("盘点完成");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return checkBoolean;
|
|
|
|
|
|
|
|
}
|
|
|
|
public KsecInfo getKsecDataInfo(TransmissionPojo transmissionPojo, String type) {
|
|
|
|
public KsecInfo getKsecDataInfo(TransmissionPojo transmissionPojo, String type) {
|
|
|
|
KsecDataInfo ksecDataInfo = new KsecDataInfo();
|
|
|
|
KsecDataInfo ksecDataInfo = new KsecDataInfo();
|
|
|
|
CheckLog checkLog = checkLogMapper.selectById(transmissionPojo.getCheckId());
|
|
|
|
CheckLog checkLog = checkLogMapper.selectById(transmissionPojo.getCheckId());
|
|
|
|
@ -1042,4 +1102,37 @@ public class PlcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
checkLog(stock);
|
|
|
|
checkLog(stock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void visualCalculationResults(TransmissionPojo transmissionPojo) {
|
|
|
|
|
|
|
|
CheckLog checkLog = checkLogMapper.selectById(transmissionPojo.getCheckId());
|
|
|
|
|
|
|
|
Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("check_Num", checkLog.getId()));
|
|
|
|
|
|
|
|
Street street = streetService.getStreetByPlcId(transmissionPojo.getStreetNumber());
|
|
|
|
|
|
|
|
if (transmissionPojo.getResult() != null && transmissionPojo.getResult() == 1) {
|
|
|
|
|
|
|
|
checkLog.setStatusVision(StockStatus.SUCCESS.getStatus());
|
|
|
|
|
|
|
|
stock.setStatusVision(StockStatus.SUCCESS.getStatus());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
checkLog.setStatusVision(StockStatus.ERROR.getStatus());
|
|
|
|
|
|
|
|
stock.setStatusVision(StockStatus.ERROR.getStatus());
|
|
|
|
|
|
|
|
stock.setCount(transmissionPojo.getCount());
|
|
|
|
|
|
|
|
stock.setCategory(transmissionPojo.getCategory());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (transmissionPojo.getPcd() != null && !"".equals(transmissionPojo.getPcd())) {
|
|
|
|
|
|
|
|
stock.setPcd("http://" + street.getPlcIp() + ":8007" + transmissionPojo.getPcd());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transmissionPojo.getPicsPath() != null && transmissionPojo.getPicsPath().size() > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String pics = transmissionPojo.getPicsPath().stream().map(v -> {
|
|
|
|
|
|
|
|
return "http://" + street.getPlcIp() + ":8007" + v;
|
|
|
|
|
|
|
|
}).collect(Collectors.joining(";"));
|
|
|
|
|
|
|
|
checkLog.setPic(pics);
|
|
|
|
|
|
|
|
stock.setCheckPic(pics);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
checkLogMapper.updateById(checkLog);
|
|
|
|
|
|
|
|
stockMapper.updateById(stock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void saveFollowPhoto(TransmissionPojo transmissionPojo) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|