|
|
|
|
@ -10,13 +10,18 @@ import com.zhehekeji.web.lib.*;
|
|
|
|
|
import com.zhehekeji.web.mapper.*;
|
|
|
|
|
import com.zhehekeji.web.pojo.CameraPtzPojo;
|
|
|
|
|
import com.zhehekeji.web.pojo.OrderVO;
|
|
|
|
|
import com.zhehekeji.web.pojo.stock.StockCheck;
|
|
|
|
|
import com.zhehekeji.web.service.RFID.RFIDMap;
|
|
|
|
|
import com.zhehekeji.web.service.RFID.RFIDSocket;
|
|
|
|
|
import com.zhehekeji.web.service.client.ClientChanel;
|
|
|
|
|
import com.zhehekeji.web.service.client.TransmissionPojo;
|
|
|
|
|
import com.zhehekeji.web.service.client.image.GetPhotoDelayExecutor;
|
|
|
|
|
import com.zhehekeji.web.service.client.image.ImageSaver;
|
|
|
|
|
import com.zhehekeji.web.service.damLightSource.JYDAMEquip;
|
|
|
|
|
import com.zhehekeji.web.service.damLightSource.JYDamHelper;
|
|
|
|
|
import com.zhehekeji.web.service.hikLightSource.HikControlSocket;
|
|
|
|
|
import com.zhehekeji.web.service.ksec.KsecDataInfo;
|
|
|
|
|
import com.zhehekeji.web.service.ksec.KsecInfo;
|
|
|
|
|
import com.zhehekeji.web.service.ksec.KsecNettyClient;
|
|
|
|
|
import com.zhehekeji.web.service.sick.SickSocket;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
@ -101,7 +106,17 @@ public class PlcService {
|
|
|
|
|
List<Integer> connIds = StreetConn.connList();
|
|
|
|
|
return (count - connIds.size());
|
|
|
|
|
}
|
|
|
|
|
public Street getStreetByPlcId(String streetPlc) {
|
|
|
|
|
|
|
|
|
|
return streetMapper.getStreetByPlcId(streetPlc);
|
|
|
|
|
}
|
|
|
|
|
public Stock checkCorrect(StockCheck stockCheck){
|
|
|
|
|
return stockService.checkCorrect(stockCheck);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Stock stockInfo(StockCheck stockCheck){
|
|
|
|
|
return stockService.stockInfo(stockCheck);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 开始工单 robotic plcId是plcId,昆船的plcId是来自包体,即srmNumber
|
|
|
|
|
*
|
|
|
|
|
@ -603,37 +618,11 @@ public class PlcService {
|
|
|
|
|
//判断单双伸 type=0 单伸 1为双伸
|
|
|
|
|
Integer type;
|
|
|
|
|
if(leftRight == 1){
|
|
|
|
|
type = street.getLeftType();
|
|
|
|
|
return street.getCamera1Id();
|
|
|
|
|
}else {
|
|
|
|
|
type = street.getRightType();
|
|
|
|
|
return street.getCamera2Id();
|
|
|
|
|
}
|
|
|
|
|
if(type == 0){
|
|
|
|
|
//单伸
|
|
|
|
|
if (street.getCamera1Id() != null && street.getCamera2Id() != null && street.getCamera1Id() != 0 && street.getCamera2Id() != 0) {
|
|
|
|
|
if (leftRight == 1) {
|
|
|
|
|
return street.getCamera2Id();
|
|
|
|
|
} else {
|
|
|
|
|
return street.getCamera1Id();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Integer cameraId = street.getCamera1Id() != null && street.getCamera1Id() != 0 ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
|
return cameraId;
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
if (street.getCamera1Id() != null && street.getCamera2Id() != null && street.getCamera1Id() != 0 && street.getCamera2Id() != 0) {
|
|
|
|
|
//双伸 todo 这个因项目而异,看现场的情况
|
|
|
|
|
//默认是 左侧返回camera2 右侧返回camera1
|
|
|
|
|
if(plcCmdInfo.getLeftRight1() == 1){
|
|
|
|
|
return street.getCamera2Id();
|
|
|
|
|
}else {
|
|
|
|
|
return street.getCamera1Id();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Integer cameraId = street.getCamera1Id() != null && street.getCamera1Id() != 0 ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
|
return cameraId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -652,53 +641,31 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
//南通通威拍摄货物顶部时按列号的单双来判断单数左侧
|
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getColumn1()%2==1?1:2);
|
|
|
|
|
|
|
|
|
|
Integer leftRightTop = plcCmdInfo.getLeftRight1() == 1 ? 2 : 1;
|
|
|
|
|
Integer cameraIdTop = getCameraByPlcCmd(plcCmdInfo, leftRightTop);
|
|
|
|
|
if(plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2){
|
|
|
|
|
//内测
|
|
|
|
|
String c = cmdCode + "-" + plcCmdInfo.getLeftRightStr(1) + "-IN";
|
|
|
|
|
log.info("camera ptz"+c);
|
|
|
|
|
gyrateCameraByCode(cameraIdTop, c);
|
|
|
|
|
}else {
|
|
|
|
|
log.info("camera ptz"+cmdCode);
|
|
|
|
|
gyrateCameraByCode(cameraIdTop, cmdCode);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime());
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//对侧拍摄二维码
|
|
|
|
|
Integer cameraIdQt = getCameraByPlcCmd(plcCmdInfo, plcCmdInfo.getLeftRight1() == 1 ? 2 : 1);
|
|
|
|
|
gyrateCameraByCode(cameraId, "E1-Len");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
|
|
|
|
|
//拍照暂停1s再拍
|
|
|
|
|
//拍照暂停1s再拍,拍摄正面的二维码
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getEDelayCaptureTime());
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
cameraCapture(cameraIdTop,false,null,path);
|
|
|
|
|
cameraCapture(cameraId,false,null,path);
|
|
|
|
|
//成都蜜雪冰城 只拍照人工核对
|
|
|
|
|
String e2 = "E2-" + plcCmdInfo.getLeftRightStr(1) + "-IN";
|
|
|
|
|
log.info("camera ptz"+e2);
|
|
|
|
|
gyrateCameraByCode(cameraId, e2);
|
|
|
|
|
gyrateCameraByCode(cameraIdQt, "E1-QRCode");
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getEDelayCaptureTime());
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
cameraCapture(cameraId,false,null,path+".jpg");
|
|
|
|
|
cameraCapture(cameraIdQt,false,null,path+".jpg");
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode);
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(),orderInfo.getLeftRight(),orderInfo.getSeparation(),orderInfo.getRow(),orderInfo.getColumn());
|
|
|
|
|
//核对异常
|
|
|
|
|
if(stock == null){
|
|
|
|
|
/* stock = new Stock(null,null,plcCmdInfo.getOrderNum(),plcCmdInfo.getLotnum()
|
|
|
|
|
,"", null,null,wmsCode,wmsCatagary,null,
|
|
|
|
|
wmsTrayCode,"",orderInfo.getStreetId(),
|
|
|
|
|
orderInfo.getLeftRight(),orderInfo.getSeparation(),
|
|
|
|
|
orderInfo.getRow(),orderInfo.getColumn(),0,null,null,
|
|
|
|
|
path, LocalDateTime.now(),null);*/
|
|
|
|
|
stock = Stock.builder()
|
|
|
|
|
.checkNum(plcCmdInfo.getOrderNum())
|
|
|
|
|
.lotnum(plcCmdInfo.getLotnum())
|
|
|
|
|
@ -740,16 +707,49 @@ public class PlcService {
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
|
long s = end - startTime;
|
|
|
|
|
//发送图片,触发拍照和id
|
|
|
|
|
imageSaver.uploadFileToFtp(street.getPlcIp(), configProperties.getSavePath().getMediaPath() + path);
|
|
|
|
|
ClientChanel.get(street.getPlcId()).writeAndFlush("id:"+stock.getCheckNum());
|
|
|
|
|
ClientChanel.get(street.getPlcId()).writeAndFlush("tar:1");
|
|
|
|
|
|
|
|
|
|
//增加到队列中
|
|
|
|
|
TransmissionPojo transmissionPojo = TransmissionPojo.builder()
|
|
|
|
|
.ip(street.getPlcIp())
|
|
|
|
|
.streetNumber(street.getPlcId())
|
|
|
|
|
.direction(stock.getDirection())
|
|
|
|
|
.id(stock.getCheckNum())
|
|
|
|
|
.localFilePath(configProperties.getSavePath().getMediaPath() + path)
|
|
|
|
|
.build();
|
|
|
|
|
GetPhotoDelayExecutor.addDelayTask(transmissionPojo,15000l);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("time:{}millisecond",s);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取旧数据并发送给上位机
|
|
|
|
|
public KsecInfo getKsecDataInfo(TransmissionPojo transmissionPojo, String type){
|
|
|
|
|
KsecDataInfo ksecDataInfo = new KsecDataInfo();
|
|
|
|
|
CheckLog checkLog = checkLogMapper.selectOne(new QueryWrapper<CheckLog>()
|
|
|
|
|
.eq("check_Num",transmissionPojo.getId())
|
|
|
|
|
.orderByDesc("export_Time")
|
|
|
|
|
.last("limit 1"));
|
|
|
|
|
if(checkLog!=null) {
|
|
|
|
|
ksecDataInfo.setLotnum(checkLog.getLotnum());
|
|
|
|
|
ksecDataInfo.setSRMNumber(transmissionPojo.getStreetNumber());
|
|
|
|
|
ksecDataInfo.setCmdName(type);
|
|
|
|
|
ksecDataInfo.setTaskId(checkLog.getTaskId().toString());
|
|
|
|
|
ksecDataInfo.setFromDirection(checkLog.getDirection());
|
|
|
|
|
ksecDataInfo.setFromColumn(checkLog.getColumn());
|
|
|
|
|
ksecDataInfo.setFromRow(checkLog.getRow());
|
|
|
|
|
ksecDataInfo.setFromSide(checkLog.getSide());
|
|
|
|
|
ksecDataInfo.setCode(checkLog.getCode());
|
|
|
|
|
ksecDataInfo.setTrayCode(checkLog.getTrayCode());
|
|
|
|
|
ksecDataInfo.setLotnum(checkLog.getLotnum());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KsecInfo ksecInfo = new KsecInfo("KC", "E", ksecDataInfo);
|
|
|
|
|
KsecNettyClient.write(ksecInfo);
|
|
|
|
|
return ksecInfo;
|
|
|
|
|
}
|
|
|
|
|
@Resource
|
|
|
|
|
ImageSaver imageSaver;
|
|
|
|
|
public CheckLog checkLog(Stock stock){
|
|
|
|
|
@ -768,6 +768,7 @@ public class PlcService {
|
|
|
|
|
checkLog.setTrayCode(stock.getTrayCode());
|
|
|
|
|
checkLog.setWmsTrayCode(stock.getWmsTrayCode());
|
|
|
|
|
checkLog.setLotnum(stock.getLotnum());
|
|
|
|
|
checkLog.setTaskId(stock.getCheckNum().substring(stock.getCheckNum().lastIndexOf("_")+1));
|
|
|
|
|
log.info("checklogmapper start insert new checklog info.");
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
|
log.info("checklogmapper insert new checklog info finished.");
|
|
|
|
|
|