新增record_type字段区分扫码枪录入还是采购录入明细表,以及注释扫码枪代码,修改出入库移库逻辑
This commit is contained in:
@@ -52,7 +52,7 @@ spring:
|
|||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||||
url: jdbc:mysql://140.143.206:3306/klp-oa?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
url: jdbc:mysql://140.143.206.120:3306/klp-oa?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||||
username: klp
|
username: klp
|
||||||
password: KeLunPu123@
|
password: KeLunPu123@
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
@@ -105,13 +105,13 @@ spring:
|
|||||||
spring:
|
spring:
|
||||||
redis:
|
redis:
|
||||||
# 地址
|
# 地址
|
||||||
host: localhost
|
host: 140.143.206.120
|
||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 0
|
database: 0
|
||||||
# 密码(如没有密码请注释掉)
|
# 密码(如没有密码请注释掉)
|
||||||
# password:
|
password: KeLunPu123!
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
# 是否开启ssl
|
# 是否开启ssl
|
||||||
|
|||||||
@@ -137,6 +137,9 @@ security:
|
|||||||
# actuator 监控配置
|
# actuator 监控配置
|
||||||
- /actuator
|
- /actuator
|
||||||
- /actuator/**
|
- /actuator/**
|
||||||
|
# 扫码枪获取出入库单详情
|
||||||
|
- /wms/stockIoDetail
|
||||||
|
|
||||||
|
|
||||||
# MyBatisPlus配置
|
# MyBatisPlus配置
|
||||||
# https://baomidou.com/config/
|
# https://baomidou.com/config/
|
||||||
|
|||||||
@@ -1,247 +1,247 @@
|
|||||||
package com.klp.reader;
|
//package com.klp.reader;
|
||||||
|
//
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
//import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
//import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
|
//
|
||||||
import MvCodeReaderCtrlWrapper.*;
|
//import MvCodeReaderCtrlWrapper.*;
|
||||||
import MvCodeReaderCtrlWrapper.MvCodeReaderCtrl.*;
|
//import MvCodeReaderCtrlWrapper.MvCodeReaderCtrl.*;
|
||||||
import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine.*;
|
//import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine.*;
|
||||||
import MvCodeReaderCtrlWrapper.ParameterException.*;
|
//import MvCodeReaderCtrlWrapper.ParameterException.*;
|
||||||
|
//
|
||||||
public class CallBackDemo {
|
//public class CallBackDemo {
|
||||||
|
//
|
||||||
static Handle hHandle = null;
|
// static Handle hHandle = null;
|
||||||
|
//
|
||||||
public static void saveDataToFile(byte[] dataToSave, int dataSize, String fileName)
|
// public static void saveDataToFile(byte[] dataToSave, int dataSize, String fileName)
|
||||||
{
|
// {
|
||||||
OutputStream os = null;
|
// OutputStream os = null;
|
||||||
|
//
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
// Create saveImg directory
|
// // Create saveImg directory
|
||||||
File tempFile = new File("saveImg");
|
// File tempFile = new File("saveImg");
|
||||||
if (!tempFile.exists())
|
// if (!tempFile.exists())
|
||||||
{
|
// {
|
||||||
tempFile.mkdirs();
|
// tempFile.mkdirs();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
os = new FileOutputStream(tempFile.getPath() + File.separator + fileName);
|
// os = new FileOutputStream(tempFile.getPath() + File.separator + fileName);
|
||||||
os.write(dataToSave, 0, dataSize);
|
// os.write(dataToSave, 0, dataSize);
|
||||||
System.out.println("SaveImage succeed.");
|
// System.out.println("SaveImage succeed.");
|
||||||
}
|
// }
|
||||||
catch (IOException e)
|
// catch (IOException e)
|
||||||
{
|
// {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
finally
|
// finally
|
||||||
{
|
// {
|
||||||
// Close file stream
|
// // Close file stream
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
os.close();
|
// os.close();
|
||||||
}
|
// }
|
||||||
catch (IOException e)
|
// catch (IOException e)
|
||||||
{
|
// {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// CallBack function
|
// // CallBack function
|
||||||
private static void printImgCBInfo(byte[] pdata, MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo)
|
// private static void printImgCBInfo(byte[] pdata, MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo)
|
||||||
{
|
// {
|
||||||
if (null == stOutInfo)
|
// if (null == stOutInfo)
|
||||||
{
|
// {
|
||||||
System.out.println("stOutInfo is null");
|
// System.out.println("stOutInfo is null");
|
||||||
return ;
|
// return ;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
System.out.print("/**CBpstOutInfo***************************************/\n");
|
// System.out.print("/**CBpstOutInfo***************************************/\n");
|
||||||
|
//
|
||||||
// save buffer to file follow Image Type to Save
|
// // save buffer to file follow Image Type to Save
|
||||||
// saveDataToFile(pdata, stOutInfo.nFrameLen, "Image.jpg");
|
// // saveDataToFile(pdata, stOutInfo.nFrameLen, "Image.jpg");
|
||||||
// saveDataToFile(pdata, stOutInfo.nFrameLen, "Image.raw");
|
// // saveDataToFile(pdata, stOutInfo.nFrameLen, "Image.raw");
|
||||||
|
//
|
||||||
System.out.print(String.format("Get One Frame: nEventID[%d], nChannelID[%d], nWidth[%d], nHeight[%d], nFrameNum[%d], nTriggerIndex[%d], nFrameLen[%d], "
|
// System.out.print(String.format("Get One Frame: nEventID[%d], nChannelID[%d], nWidth[%d], nHeight[%d], nFrameNum[%d], nTriggerIndex[%d], nFrameLen[%d], "
|
||||||
+ " nCodeNumber[%d] \r\n",
|
// + " nCodeNumber[%d] \r\n",
|
||||||
stOutInfo.nEventID, stOutInfo.nChannelID, stOutInfo.nWidth, stOutInfo.nHeight, stOutInfo.nFrameNum,
|
// stOutInfo.nEventID, stOutInfo.nChannelID, stOutInfo.nWidth, stOutInfo.nHeight, stOutInfo.nFrameNum,
|
||||||
stOutInfo.nTriggerIndex, stOutInfo.nFrameLen, stOutInfo.pstCodeListEx.nCodeNum));
|
// stOutInfo.nTriggerIndex, stOutInfo.nFrameLen, stOutInfo.pstCodeListEx.nCodeNum));
|
||||||
|
//
|
||||||
System.out.print("Get One Code: bIsGetCode[" + stOutInfo.bIsGetCode + "]success\r\n");
|
// System.out.print("Get One Code: bIsGetCode[" + stOutInfo.bIsGetCode + "]success\r\n");
|
||||||
|
//
|
||||||
System.out.print("Get GvspPixelType: MvCodeReaderGvspPixelType[" + stOutInfo.enPixelType + "]success\r\n");
|
// System.out.print("Get GvspPixelType: MvCodeReaderGvspPixelType[" + stOutInfo.enPixelType + "]success\r\n");
|
||||||
|
//
|
||||||
// print code info
|
// // print code info
|
||||||
for(int a = 0; a < stOutInfo.pstCodeListEx.nCodeNum; a++)
|
// for(int a = 0; a < stOutInfo.pstCodeListEx.nCodeNum; a++)
|
||||||
{
|
// {
|
||||||
System.out.print(String.format("CodeInfo: TheCodeID[%d], CodeString[%s], nCodeLen[%d], nAngle[%d], nBarType[%d],"
|
// System.out.print(String.format("CodeInfo: TheCodeID[%d], CodeString[%s], nCodeLen[%d], nAngle[%d], nBarType[%d],"
|
||||||
+ "sAlgoCost[%d], nIDRScore[%d], n1DIsGetQuality[%d]\r\n",
|
// + "sAlgoCost[%d], nIDRScore[%d], n1DIsGetQuality[%d]\r\n",
|
||||||
a, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).chCode, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nLen,
|
// a, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).chCode, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nLen,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nAngle, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nBarType,
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nAngle, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nBarType,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).sAlgoCost, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nIDRScore,
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).sAlgoCost, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nIDRScore,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).n1DIsGetQuality));
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).n1DIsGetQuality));
|
||||||
|
//
|
||||||
System.out.print(String.format("CodePointInfo: stCornerLeftTop.X[%d], stCornerLeftTop.Y[%d], stCornerRightTop.X[%d], stCornerRightTop.Y[%d],"
|
// System.out.print(String.format("CodePointInfo: stCornerLeftTop.X[%d], stCornerLeftTop.Y[%d], stCornerRightTop.X[%d], stCornerRightTop.Y[%d],"
|
||||||
+ "stCornerRightBottom.X[%d], stCornerRightBottom.Y[%d], stCornerLeftBottom.X[%d], stCornerLeftBottom.Y[%d]\r\n",
|
// + "stCornerRightBottom.X[%d], stCornerRightBottom.Y[%d], stCornerLeftBottom.X[%d], stCornerLeftBottom.Y[%d]\r\n",
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftTop.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftTop.nY,
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftTop.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftTop.nY,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightTop.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightTop.nY,
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightTop.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightTop.nY,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightBottom.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightBottom.nY,
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightBottom.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightBottom.nY,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftBottom.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftBottom.nY));
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftBottom.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftBottom.nY));
|
||||||
|
//
|
||||||
System.out.print("Get CodeQuality: bIsGetQuality[" + stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).bIsGetQuality + "]success\r\n");
|
// System.out.print("Get CodeQuality: bIsGetQuality[" + stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).bIsGetQuality + "]success\r\n");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private static void PrintDeviceInfo(MV_CODEREADER_DEVICE_INFO stCamInfo)
|
// private static void PrintDeviceInfo(MV_CODEREADER_DEVICE_INFO stCamInfo)
|
||||||
{
|
// {
|
||||||
if(stCamInfo.nTLayerType == MvCodeReaderCtrlDefine.MV_CODEREADER_GIGE_DEVICE)
|
// if(stCamInfo.nTLayerType == MvCodeReaderCtrlDefine.MV_CODEREADER_GIGE_DEVICE)
|
||||||
{
|
// {
|
||||||
int nIp1 = ((stCamInfo.stGigEInfo.nCurrentIp & 0xff000000) >> 24) & 0xff;
|
// int nIp1 = ((stCamInfo.stGigEInfo.nCurrentIp & 0xff000000) >> 24) & 0xff;
|
||||||
int nIp2 = ((stCamInfo.stGigEInfo.nCurrentIp & 0x00ff0000) >> 16);
|
// int nIp2 = ((stCamInfo.stGigEInfo.nCurrentIp & 0x00ff0000) >> 16);
|
||||||
int nIp3 = ((stCamInfo.stGigEInfo.nCurrentIp & 0x0000ff00) >> 8);
|
// int nIp3 = ((stCamInfo.stGigEInfo.nCurrentIp & 0x0000ff00) >> 8);
|
||||||
int nIp4 = (stCamInfo.stGigEInfo.nCurrentIp & 0x000000ff);
|
// int nIp4 = (stCamInfo.stGigEInfo.nCurrentIp & 0x000000ff);
|
||||||
|
//
|
||||||
System.out.print("CurrentIp: " + nIp1 + "." + nIp2 + "." + nIp3 + "." + nIp4 + "\r\n");
|
// System.out.print("CurrentIp: " + nIp1 + "." + nIp2 + "." + nIp3 + "." + nIp4 + "\r\n");
|
||||||
|
//
|
||||||
System.out.print(String.format("GiGEInfo: UserDefinedName:[%s], chSerialNumber:[%s] \r\n\r\n",
|
// System.out.print(String.format("GiGEInfo: UserDefinedName:[%s], chSerialNumber:[%s] \r\n\r\n",
|
||||||
stCamInfo.stGigEInfo.chUserDefinedName, stCamInfo.stGigEInfo.chSerialNumber));
|
// stCamInfo.stGigEInfo.chUserDefinedName, stCamInfo.stGigEInfo.chSerialNumber));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
public static void main(String[] args) throws InterruptedException {
|
// public static void main(String[] args) throws InterruptedException {
|
||||||
|
//
|
||||||
int nRet = 0;
|
// int nRet = 0;
|
||||||
int i = 0;
|
// int i = 0;
|
||||||
|
//
|
||||||
System.out.print(" ***************Begin****************** \r\n");
|
// System.out.print(" ***************Begin****************** \r\n");
|
||||||
|
//
|
||||||
String strVersion = MvCodeReaderCtrl.MV_CODEREADER_GetSDKVersion();
|
// String strVersion = MvCodeReaderCtrl.MV_CODEREADER_GetSDKVersion();
|
||||||
System.out.print("Get version " + strVersion + "\r\n");
|
// System.out.print("Get version " + strVersion + "\r\n");
|
||||||
|
//
|
||||||
do
|
// do
|
||||||
{
|
// {
|
||||||
// Enum device
|
// // Enum device
|
||||||
ArrayList<MV_CODEREADER_DEVICE_INFO> stCamList = MvCodeReaderCtrl.MV_CODEREADER_EnumDevices();
|
// ArrayList<MV_CODEREADER_DEVICE_INFO> stCamList = MvCodeReaderCtrl.MV_CODEREADER_EnumDevices();
|
||||||
|
//
|
||||||
if (stCamList == null)
|
// if (stCamList == null)
|
||||||
{
|
// {
|
||||||
System.out.print("Find No Device!\r\n");
|
// System.out.print("Find No Device!\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for(MV_CODEREADER_DEVICE_INFO stCamInfo:stCamList)
|
// for(MV_CODEREADER_DEVICE_INFO stCamInfo:stCamList)
|
||||||
{
|
// {
|
||||||
|
//
|
||||||
System.out.print("[device " + i + "]:\r\n");
|
// System.out.print("[device " + i + "]:\r\n");
|
||||||
PrintDeviceInfo(stCamInfo);
|
// PrintDeviceInfo(stCamInfo);
|
||||||
i++;
|
// i++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
int nIndex = 0;
|
// int nIndex = 0;
|
||||||
System.out.print("Please input camera index: ");
|
// System.out.print("Please input camera index: ");
|
||||||
|
//
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
nIndex = System.in.read() - 48;
|
// nIndex = System.in.read() - 48;
|
||||||
|
//
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
// TODO Auto-generated catch block
|
// // TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
System.out.print("Input Error!\r\n");
|
// System.out.print("Input Error!\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
MV_CODEREADER_DEVICE_INFO deviceInfo = new MV_CODEREADER_DEVICE_INFO();
|
// MV_CODEREADER_DEVICE_INFO deviceInfo = new MV_CODEREADER_DEVICE_INFO();
|
||||||
|
//
|
||||||
hHandle = MvCodeReaderCtrl.MV_CODEREADER_CreateHandle(stCamList.get(nIndex));
|
// hHandle = MvCodeReaderCtrl.MV_CODEREADER_CreateHandle(stCamList.get(nIndex));
|
||||||
if(null == hHandle)
|
// if(null == hHandle)
|
||||||
{
|
// {
|
||||||
System.out.print("Create handle failed! \r\n");
|
// System.out.print("Create handle failed! \r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch(Exception e)
|
// catch(Exception e)
|
||||||
{
|
// {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
System.out.print("Create Handle Failed \r\n");
|
// System.out.print("Create Handle Failed \r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
nRet = MvCodeReaderCtrl.MV_CODEREADER_OpenDevice(hHandle);
|
// nRet = MvCodeReaderCtrl.MV_CODEREADER_OpenDevice(hHandle);
|
||||||
if(0 != nRet){
|
// if(0 != nRet){
|
||||||
System.out.print("Open Device fail! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("Open Device fail! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
System.out.print("Open device success!\r\n");
|
// System.out.print("Open device success!\r\n");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Register MvCodeReaderCtrl.MV_CODEREADER_RegisterImageCallBackEx2
|
// // Register MvCodeReaderCtrl.MV_CODEREADER_RegisterImageCallBackEx2
|
||||||
nRet = MvCodeReaderCtrl.MV_CODEREADER_RegisterImageCallBackEx2(hHandle, new ImageCallBack()
|
// nRet = MvCodeReaderCtrl.MV_CODEREADER_RegisterImageCallBackEx2(hHandle, new ImageCallBack()
|
||||||
{
|
// {
|
||||||
@Override
|
// @Override
|
||||||
public int OnImageCallBack(byte[] pdata, MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo) {
|
// public int OnImageCallBack(byte[] pdata, MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo) {
|
||||||
// TODO Auto-generated method stub
|
// // TODO Auto-generated method stub
|
||||||
printImgCBInfo( pdata, stOutInfo);
|
// printImgCBInfo( pdata, stOutInfo);
|
||||||
|
//
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
if(0 != nRet)
|
// if(0 != nRet)
|
||||||
{
|
// {
|
||||||
System.out.print("MV_CODEREADER_RegisterImageCallBackEx2 Failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("MV_CODEREADER_RegisterImageCallBackEx2 Failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
System.out.print("MV_CODEREADER_RegisterImageCallBackEx2 ! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("MV_CODEREADER_RegisterImageCallBackEx2 ! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
|
//
|
||||||
nRet = MvCodeReaderCtrl.MV_CODEREADER_StartGrabbing(hHandle);
|
// nRet = MvCodeReaderCtrl.MV_CODEREADER_StartGrabbing(hHandle);
|
||||||
if(0 != nRet){
|
// if(0 != nRet){
|
||||||
System.out.print("StartGrabbing Failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("StartGrabbing Failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
System.out.print("Device startGrabbing success!\r\n");
|
// System.out.print("Device startGrabbing success!\r\n");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Wait CallBack Data
|
// // Wait CallBack Data
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
Thread.sleep(1000 * 1000);
|
// Thread.sleep(1000 * 1000);
|
||||||
}
|
// }
|
||||||
catch (InterruptedException e)
|
// catch (InterruptedException e)
|
||||||
{
|
// {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
MvCodeReaderCtrl.MV_CODEREADER_StopGrabbing(hHandle);
|
// MvCodeReaderCtrl.MV_CODEREADER_StopGrabbing(hHandle);
|
||||||
if(0 != nRet){
|
// if(0 != nRet){
|
||||||
System.out.print("StopGrabbing failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("StopGrabbing failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
System.out.print("Device stopGrabbing success!\r\n");
|
// System.out.print("Device stopGrabbing success!\r\n");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}while(false);
|
// }while(false);
|
||||||
|
//
|
||||||
if (null != hHandle)
|
// if (null != hHandle)
|
||||||
{
|
// {
|
||||||
MvCodeReaderCtrl.MV_CODEREADER_DestroyHandle(hHandle);
|
// MvCodeReaderCtrl.MV_CODEREADER_DestroyHandle(hHandle);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
System.out.print("exit.\r\n");
|
// System.out.print("exit.\r\n");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
|||||||
@@ -1,275 +1,275 @@
|
|||||||
package com.klp.reader;
|
//package com.klp.reader;
|
||||||
|
//
|
||||||
import MvCodeReaderCtrlWrapper.MvCodeReaderCtrl;
|
//import MvCodeReaderCtrlWrapper.MvCodeReaderCtrl;
|
||||||
import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine;
|
//import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine;
|
||||||
import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine.*;
|
//import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine.*;
|
||||||
|
//
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
//import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
//import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
|
//
|
||||||
public class MvIDDemo {
|
//public class MvIDDemo {
|
||||||
|
//
|
||||||
static Handle hHandle = null;
|
// static Handle hHandle = null;
|
||||||
|
//
|
||||||
// Save Image API
|
// // Save Image API
|
||||||
public static void saveDataToFile(byte[] dataToSave, int dataSize, String fileName)
|
// public static void saveDataToFile(byte[] dataToSave, int dataSize, String fileName)
|
||||||
{
|
// {
|
||||||
OutputStream os = null;
|
// OutputStream os = null;
|
||||||
|
//
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
// Create directory
|
// // Create directory
|
||||||
File tempFile = new File("ImageSave");
|
// File tempFile = new File("ImageSave");
|
||||||
if (!tempFile.exists())
|
// if (!tempFile.exists())
|
||||||
{
|
// {
|
||||||
tempFile.mkdirs();
|
// tempFile.mkdirs();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
os = new FileOutputStream(tempFile.getPath() + File.separator + fileName);
|
// os = new FileOutputStream(tempFile.getPath() + File.separator + fileName);
|
||||||
os.write(dataToSave, 0, dataSize);
|
// os.write(dataToSave, 0, dataSize);
|
||||||
os.flush();
|
// os.flush();
|
||||||
os.close();
|
// os.close();
|
||||||
System.out.println("SaveImage succeed.");
|
// System.out.println("SaveImage succeed.");
|
||||||
}
|
// }
|
||||||
catch (IOException e)
|
// catch (IOException e)
|
||||||
{
|
// {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
finally
|
// finally
|
||||||
{
|
// {
|
||||||
// Close file stream
|
// // Close file stream
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
os.close();
|
// os.close();
|
||||||
}
|
// }
|
||||||
catch (IOException e)
|
// catch (IOException e)
|
||||||
{
|
// {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Print Device Info
|
// // Print Device Info
|
||||||
private static void PrintDeviceInfo(MV_CODEREADER_DEVICE_INFO stCamInfo)
|
// private static void PrintDeviceInfo(MV_CODEREADER_DEVICE_INFO stCamInfo)
|
||||||
{
|
// {
|
||||||
if(stCamInfo.nTLayerType == MvCodeReaderCtrlDefine.MV_CODEREADER_GIGE_DEVICE)
|
// if(stCamInfo.nTLayerType == MvCodeReaderCtrlDefine.MV_CODEREADER_GIGE_DEVICE)
|
||||||
{
|
// {
|
||||||
int nIp1 = ((stCamInfo.stGigEInfo.nCurrentIp & 0xff000000) >> 24) & 0xff;
|
// int nIp1 = ((stCamInfo.stGigEInfo.nCurrentIp & 0xff000000) >> 24) & 0xff;
|
||||||
int nIp2 = ((stCamInfo.stGigEInfo.nCurrentIp & 0x00ff0000) >> 16);
|
// int nIp2 = ((stCamInfo.stGigEInfo.nCurrentIp & 0x00ff0000) >> 16);
|
||||||
int nIp3 = ((stCamInfo.stGigEInfo.nCurrentIp & 0x0000ff00) >> 8);
|
// int nIp3 = ((stCamInfo.stGigEInfo.nCurrentIp & 0x0000ff00) >> 8);
|
||||||
int nIp4 = (stCamInfo.stGigEInfo.nCurrentIp & 0x000000ff);
|
// int nIp4 = (stCamInfo.stGigEInfo.nCurrentIp & 0x000000ff);
|
||||||
|
//
|
||||||
System.out.print("CurrentIp: " + nIp1 + "." + nIp2 + "." + nIp3 + "." + nIp4 + "\r\n");
|
// System.out.print("CurrentIp: " + nIp1 + "." + nIp2 + "." + nIp3 + "." + nIp4 + "\r\n");
|
||||||
|
//
|
||||||
System.out.print(String.format("GiGEInfo: UserDefinedName:[%s], chSerialNumber:[%s] \r\n\r\n",
|
// System.out.print(String.format("GiGEInfo: UserDefinedName:[%s], chSerialNumber:[%s] \r\n\r\n",
|
||||||
stCamInfo.stGigEInfo.chUserDefinedName, stCamInfo.stGigEInfo.chSerialNumber));
|
// stCamInfo.stGigEInfo.chUserDefinedName, stCamInfo.stGigEInfo.chSerialNumber));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Grabbing thread API
|
// // Grabbing thread API
|
||||||
public static class GrabbingThread extends Thread
|
// public static class GrabbingThread extends Thread
|
||||||
{
|
// {
|
||||||
public GrabbingThread()
|
// public GrabbingThread()
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void run()
|
// public void run()
|
||||||
{
|
// {
|
||||||
MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo = new MV_CODEREADER_IMAGE_OUT_INFO_EX2();
|
// MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo = new MV_CODEREADER_IMAGE_OUT_INFO_EX2();
|
||||||
MV_CODEREADER_CAM_INTVALUE stValue = new MV_CODEREADER_CAM_INTVALUE();
|
// MV_CODEREADER_CAM_INTVALUE stValue = new MV_CODEREADER_CAM_INTVALUE();
|
||||||
int nRet = 0;
|
// int nRet = 0;
|
||||||
long payloadSize = 0;
|
// long payloadSize = 0;
|
||||||
nRet = MvCodeReaderCtrl.MV_CODEREADER_GetIntValue(hHandle, "PayloadSize", stValue);
|
// nRet = MvCodeReaderCtrl.MV_CODEREADER_GetIntValue(hHandle, "PayloadSize", stValue);
|
||||||
if (0 == nRet)
|
// if (0 == nRet)
|
||||||
{
|
// {
|
||||||
payloadSize = stValue.nCurValue;
|
// payloadSize = stValue.nCurValue;
|
||||||
System.out.print("GetOneFrame GetOptimalPacketSize[" + String.format("%d", payloadSize) + "]\r\n");
|
// System.out.print("GetOneFrame GetOptimalPacketSize[" + String.format("%d", payloadSize) + "]\r\n");
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
System.out.print("GetIntValue Failed, nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("GetIntValue Failed, nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
MV_CODEREADER_SAVE_IMAGE_PARAM_EX stParam = new MV_CODEREADER_SAVE_IMAGE_PARAM_EX();
|
// MV_CODEREADER_SAVE_IMAGE_PARAM_EX stParam = new MV_CODEREADER_SAVE_IMAGE_PARAM_EX();
|
||||||
byte[] pdata = new byte[(int)payloadSize];
|
// byte[] pdata = new byte[(int)payloadSize];
|
||||||
|
//
|
||||||
for(int i = 0; i < 5; i++)
|
// for(int i = 0; i < 5; i++)
|
||||||
{
|
// {
|
||||||
if(null != hHandle)
|
// if(null != hHandle)
|
||||||
{
|
// {
|
||||||
nRet = MvCodeReaderCtrl.MV_CODEREADER_GetOneFrameTimeoutEx2(hHandle, pdata, stOutInfo, 1000);
|
// nRet = MvCodeReaderCtrl.MV_CODEREADER_GetOneFrameTimeoutEx2(hHandle, pdata, stOutInfo, 1000);
|
||||||
if(0 != nRet)
|
// if(0 != nRet)
|
||||||
{
|
// {
|
||||||
System.out.print("GetOneFrame Failed, nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("GetOneFrame Failed, nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
// save buffer to file follow Image Type to Save
|
// // save buffer to file follow Image Type to Save
|
||||||
// saveDataToFile(pdata, stOutInfo.nFrameLen, "Image.jpg");
|
// // saveDataToFile(pdata, stOutInfo.nFrameLen, "Image.jpg");
|
||||||
|
//
|
||||||
System.out.print(String.format("Get One Frame: nEventID[%d], nChannelID[%d], nWidth[%d], nHeight[%d], nFrameNum[%d], nTriggerIndex[%d], nFrameLen[%d]"
|
// System.out.print(String.format("Get One Frame: nEventID[%d], nChannelID[%d], nWidth[%d], nHeight[%d], nFrameNum[%d], nTriggerIndex[%d], nFrameLen[%d]"
|
||||||
+ " nCodeNumber[%d]\r\n",
|
// + " nCodeNumber[%d]\r\n",
|
||||||
stOutInfo.nEventID, stOutInfo.nChannelID, stOutInfo.nWidth, stOutInfo.nHeight, stOutInfo.nFrameNum,
|
// stOutInfo.nEventID, stOutInfo.nChannelID, stOutInfo.nWidth, stOutInfo.nHeight, stOutInfo.nFrameNum,
|
||||||
stOutInfo.nTriggerIndex, stOutInfo.nFrameLen, stOutInfo.pstCodeListEx.nCodeNum));
|
// stOutInfo.nTriggerIndex, stOutInfo.nFrameLen, stOutInfo.pstCodeListEx.nCodeNum));
|
||||||
|
//
|
||||||
System.out.print("Get One Code: bIsGetCode[" + stOutInfo.bIsGetCode + "]success\r\n");
|
// System.out.print("Get One Code: bIsGetCode[" + stOutInfo.bIsGetCode + "]success\r\n");
|
||||||
|
//
|
||||||
System.out.print("Get GvspPixelType: MvCodeReaderGvspPixelType[" + stOutInfo.enPixelType + "]success\r\n");
|
// System.out.print("Get GvspPixelType: MvCodeReaderGvspPixelType[" + stOutInfo.enPixelType + "]success\r\n");
|
||||||
|
//
|
||||||
// print code info
|
// // print code info
|
||||||
for(int a = 0; a < stOutInfo.pstCodeListEx.nCodeNum; a++)
|
// for(int a = 0; a < stOutInfo.pstCodeListEx.nCodeNum; a++)
|
||||||
{
|
// {
|
||||||
System.out.print(String.format("CodeInfo: TheCodeID[%d], CodeString[%s], nCodeLen[%d], nAngle[%d], nBarType[%d]\r\n",
|
// System.out.print(String.format("CodeInfo: TheCodeID[%d], CodeString[%s], nCodeLen[%d], nAngle[%d], nBarType[%d]\r\n",
|
||||||
a, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).chCode, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nLen,
|
// a, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).chCode, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nLen,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nAngle, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nBarType));
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nAngle, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).nBarType));
|
||||||
|
//
|
||||||
System.out.print(String.format("CodePointInfo: stCornerLeftTop.X[%d], stCornerLeftTop.Y[%d], stCornerRightTop.X[%d], stCornerRightTop.Y[%d],"
|
// System.out.print(String.format("CodePointInfo: stCornerLeftTop.X[%d], stCornerLeftTop.Y[%d], stCornerRightTop.X[%d], stCornerRightTop.Y[%d],"
|
||||||
+ "stCornerRightBottom.X[%d], stCornerRightBottom.Y[%d], stCornerLeftBottom.X[%d], stCornerLeftBottom.Y[%d]\r\n",
|
// + "stCornerRightBottom.X[%d], stCornerRightBottom.Y[%d], stCornerLeftBottom.X[%d], stCornerLeftBottom.Y[%d]\r\n",
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftTop.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftTop.nY,
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftTop.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftTop.nY,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightTop.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightTop.nY,
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightTop.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightTop.nY,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightBottom.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightBottom.nY,
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightBottom.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerRightBottom.nY,
|
||||||
stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftBottom.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftBottom.nY));
|
// stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftBottom.nX, stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).stCornerLeftBottom.nY));
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
public static void main(String[] args) throws InterruptedException {
|
// public static void main(String[] args) throws InterruptedException {
|
||||||
|
//
|
||||||
int nRet = 0;
|
// int nRet = 0;
|
||||||
int i = 0;
|
// int i = 0;
|
||||||
|
//
|
||||||
System.out.print(" *****************Begin******************* \r\n");
|
// System.out.print(" *****************Begin******************* \r\n");
|
||||||
|
//
|
||||||
String strVersion = MvCodeReaderCtrl.MV_CODEREADER_GetSDKVersion();
|
// String strVersion = MvCodeReaderCtrl.MV_CODEREADER_GetSDKVersion();
|
||||||
System.out.print("Get version " + strVersion + "\r\n");
|
// System.out.print("Get version " + strVersion + "\r\n");
|
||||||
|
//
|
||||||
do
|
// do
|
||||||
{
|
// {
|
||||||
// Enum device
|
// // Enum device
|
||||||
ArrayList<MV_CODEREADER_DEVICE_INFO> stCamList = MvCodeReaderCtrl.MV_CODEREADER_EnumDevices();
|
// ArrayList<MV_CODEREADER_DEVICE_INFO> stCamList = MvCodeReaderCtrl.MV_CODEREADER_EnumDevices();
|
||||||
|
//
|
||||||
if (stCamList == null)
|
// if (stCamList == null)
|
||||||
{
|
// {
|
||||||
System.out.print("Find No Device!\r\n");
|
// System.out.print("Find No Device!\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for(MV_CODEREADER_DEVICE_INFO stCamInfo:stCamList)
|
// for(MV_CODEREADER_DEVICE_INFO stCamInfo:stCamList)
|
||||||
{
|
// {
|
||||||
|
//
|
||||||
System.out.print("[device " + i + "]:\r\n");
|
// System.out.print("[device " + i + "]:\r\n");
|
||||||
PrintDeviceInfo(stCamInfo);
|
// PrintDeviceInfo(stCamInfo);
|
||||||
i++;
|
// i++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
int nIndex = 0;
|
// int nIndex = 0;
|
||||||
System.out.print("Please input camera index: ");
|
// System.out.print("Please input camera index: ");
|
||||||
|
//
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
nIndex = System.in.read() - 48;
|
// nIndex = System.in.read() - 48;
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
// TODO Auto-generated catch block
|
// // TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
System.out.print("Input Error!\r\n");
|
// System.out.print("Input Error!\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
System.out.print("input camera index is [" + nIndex + "]\r\n" );
|
// System.out.print("input camera index is [" + nIndex + "]\r\n" );
|
||||||
|
//
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
hHandle = MvCodeReaderCtrl.MV_CODEREADER_CreateHandle(stCamList.get(nIndex));
|
// hHandle = MvCodeReaderCtrl.MV_CODEREADER_CreateHandle(stCamList.get(nIndex));
|
||||||
if(null == hHandle)
|
// if(null == hHandle)
|
||||||
{
|
// {
|
||||||
System.out.print("Create handle failed! \r\n");
|
// System.out.print("Create handle failed! \r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
catch(Exception e)
|
// catch(Exception e)
|
||||||
{
|
// {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
System.out.print("Create handle failed\r\n");
|
// System.out.print("Create handle failed\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
nRet = MvCodeReaderCtrl.MV_CODEREADER_OpenDevice(hHandle);
|
// nRet = MvCodeReaderCtrl.MV_CODEREADER_OpenDevice(hHandle);
|
||||||
if(0 != nRet){
|
// if(0 != nRet){
|
||||||
System.out.print("Open Device fail! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("Open Device fail! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
System.out.print("Open device success!\r\n");
|
// System.out.print("Open device success!\r\n");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// register exception cb
|
// // register exception cb
|
||||||
nRet = MvCodeReaderCtrl.MV_CODEREADER_RegisterExceptionCallBack(hHandle, new ExceptionCallBack()
|
// nRet = MvCodeReaderCtrl.MV_CODEREADER_RegisterExceptionCallBack(hHandle, new ExceptionCallBack()
|
||||||
{
|
// {
|
||||||
@Override
|
// @Override
|
||||||
public int OnExceptionCallBack(int nMsg)
|
// public int OnExceptionCallBack(int nMsg)
|
||||||
{
|
// {
|
||||||
System.out.print("Open Device MV_CODEREADER_RegisterExceptionCallBack! nMsg[" + String.format("0x%x", nMsg) + "]\r\n");
|
// System.out.print("Open Device MV_CODEREADER_RegisterExceptionCallBack! nMsg[" + String.format("0x%x", nMsg) + "]\r\n");
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
if(0 != nRet)
|
// if(0 != nRet)
|
||||||
{
|
// {
|
||||||
System.out.print("MVID_CR_CAM_RegisterImageCallBack Failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("MVID_CR_CAM_RegisterImageCallBack Failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
nRet = MvCodeReaderCtrl.MV_CODEREADER_StartGrabbing(hHandle);
|
// nRet = MvCodeReaderCtrl.MV_CODEREADER_StartGrabbing(hHandle);
|
||||||
if(0 != nRet){
|
// if(0 != nRet){
|
||||||
System.out.print("StartGrabbing Failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("StartGrabbing Failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
System.out.print("Device startGrabbing success!\r\n");
|
// System.out.print("Device startGrabbing success!\r\n");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Create recv thread
|
// // Create recv thread
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
GrabbingThread grabThread = new MvIDDemo.GrabbingThread();
|
// GrabbingThread grabThread = new MvIDDemo.GrabbingThread();
|
||||||
grabThread.start();
|
// grabThread.start();
|
||||||
Thread.sleep(12000);
|
// Thread.sleep(12000);
|
||||||
grabThread.interrupt();
|
// grabThread.interrupt();
|
||||||
} catch (InterruptedException e) {
|
// } catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
nRet = MvCodeReaderCtrl.MV_CODEREADER_StopGrabbing(hHandle);
|
// nRet = MvCodeReaderCtrl.MV_CODEREADER_StopGrabbing(hHandle);
|
||||||
if(0 != nRet){
|
// if(0 != nRet){
|
||||||
System.out.print("StopGrabbing failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
// System.out.print("StopGrabbing failed! nRet[" + String.format("0x%x", nRet) + "]\r\n");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
System.out.print("\r\nDevice stopGrabbing success!\r\n");
|
// System.out.print("\r\nDevice stopGrabbing success!\r\n");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}while(false);
|
// }while(false);
|
||||||
|
//
|
||||||
if (null != hHandle)
|
// if (null != hHandle)
|
||||||
{
|
// {
|
||||||
MvCodeReaderCtrl.MV_CODEREADER_DestroyHandle(hHandle);
|
// MvCodeReaderCtrl.MV_CODEREADER_DestroyHandle(hHandle);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
System.out.print("Exit.\r\n");
|
// System.out.print("Exit.\r\n");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -1,70 +1,70 @@
|
|||||||
package com.klp.reader.service;
|
//package com.klp.reader.service;
|
||||||
|
//
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.klp.reader.entity.ScanResultEntity;
|
//import com.klp.reader.entity.ScanResultEntity;
|
||||||
import com.klp.reader.mapper.ScanResultMapper;
|
//import com.klp.reader.mapper.ScanResultMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
|
//
|
||||||
import javax.annotation.PostConstruct;
|
//import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.PreDestroy;
|
//import javax.annotation.PreDestroy;
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
|
//
|
||||||
import MvCodeReaderCtrlWrapper.*;
|
//import MvCodeReaderCtrlWrapper.*;
|
||||||
import MvCodeReaderCtrlWrapper.MvCodeReaderCtrl.*;
|
//import MvCodeReaderCtrlWrapper.MvCodeReaderCtrl.*;
|
||||||
import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine.*;
|
//import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine.*;
|
||||||
|
//
|
||||||
@Service
|
//@Service
|
||||||
public class ScannerService {
|
//public class ScannerService {
|
||||||
private Handle hHandle;
|
// private Handle hHandle;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ScanResultMapper scanResultMapper; // 你需要实现这个Mapper
|
// private ScanResultMapper scanResultMapper; // 你需要实现这个Mapper
|
||||||
|
//
|
||||||
@PostConstruct
|
// @PostConstruct
|
||||||
public void init() {
|
// public void init() {
|
||||||
ArrayList<MV_CODEREADER_DEVICE_INFO> stCamList = MvCodeReaderCtrl.MV_CODEREADER_EnumDevices();
|
// ArrayList<MV_CODEREADER_DEVICE_INFO> stCamList = MvCodeReaderCtrl.MV_CODEREADER_EnumDevices();
|
||||||
if (stCamList == null || stCamList.isEmpty()) {
|
// if (stCamList == null || stCamList.isEmpty()) {
|
||||||
System.out.println("Find No Device!");
|
// System.out.println("Find No Device!");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
MV_CODEREADER_DEVICE_INFO deviceInfo = stCamList.get(0);
|
// MV_CODEREADER_DEVICE_INFO deviceInfo = stCamList.get(0);
|
||||||
try {
|
// try {
|
||||||
hHandle = MvCodeReaderCtrl.MV_CODEREADER_CreateHandle(deviceInfo);
|
// hHandle = MvCodeReaderCtrl.MV_CODEREADER_CreateHandle(deviceInfo);
|
||||||
} catch (ParameterException e) {
|
// } catch (ParameterException e) {
|
||||||
throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
if (hHandle == null) {
|
// if (hHandle == null) {
|
||||||
System.out.println("Create handle failed!");
|
// System.out.println("Create handle failed!");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
int nRet = MvCodeReaderCtrl.MV_CODEREADER_OpenDevice(hHandle);
|
// int nRet = MvCodeReaderCtrl.MV_CODEREADER_OpenDevice(hHandle);
|
||||||
if (nRet != 0) {
|
// if (nRet != 0) {
|
||||||
System.out.println("Open Device fail! nRet[" + String.format("0x%x", nRet) + "]");
|
// System.out.println("Open Device fail! nRet[" + String.format("0x%x", nRet) + "]");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
MvCodeReaderCtrl.MV_CODEREADER_RegisterImageCallBackEx2(hHandle, (pdata, stOutInfo) -> {
|
// MvCodeReaderCtrl.MV_CODEREADER_RegisterImageCallBackEx2(hHandle, (pdata, stOutInfo) -> {
|
||||||
handleScanResult(stOutInfo);
|
// handleScanResult(stOutInfo);
|
||||||
return 0;
|
// return 0;
|
||||||
});
|
// });
|
||||||
MvCodeReaderCtrl.MV_CODEREADER_StartGrabbing(hHandle);
|
// MvCodeReaderCtrl.MV_CODEREADER_StartGrabbing(hHandle);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void handleScanResult(MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo) {
|
// private void handleScanResult(MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo) {
|
||||||
for (int a = 0; a < stOutInfo.pstCodeListEx.nCodeNum; a++) {
|
// for (int a = 0; a < stOutInfo.pstCodeListEx.nCodeNum; a++) {
|
||||||
String code = stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).chCode;
|
// String code = stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).chCode;
|
||||||
// 保存到数据库
|
// // 保存到数据库
|
||||||
ScanResultEntity entity = new ScanResultEntity();
|
// ScanResultEntity entity = new ScanResultEntity();
|
||||||
entity.setCode(code);
|
// entity.setCode(code);
|
||||||
scanResultMapper.insert(entity);
|
// scanResultMapper.insert(entity);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@PreDestroy
|
// @PreDestroy
|
||||||
public void destroy() {
|
// public void destroy() {
|
||||||
if (hHandle != null) {
|
// if (hHandle != null) {
|
||||||
MvCodeReaderCtrl.MV_CODEREADER_StopGrabbing(hHandle);
|
// MvCodeReaderCtrl.MV_CODEREADER_StopGrabbing(hHandle);
|
||||||
MvCodeReaderCtrl.MV_CODEREADER_DestroyHandle(hHandle);
|
// MvCodeReaderCtrl.MV_CODEREADER_DestroyHandle(hHandle);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -66,5 +66,9 @@ public class WmsStockIoDetail extends BaseEntity {
|
|||||||
* 源库位ID(移库时使用)
|
* 源库位ID(移库时使用)
|
||||||
*/
|
*/
|
||||||
private Long fromWarehouseId;
|
private Long fromWarehouseId;
|
||||||
|
/**
|
||||||
|
* 记录类型,0:详情,1:扫码枪记录
|
||||||
|
*/
|
||||||
|
private Integer recordType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,5 +77,10 @@ public class WmsStockIoDetailBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Long fromWarehouseId;
|
private Long fromWarehouseId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录类型,0:详情,1:扫码枪记录
|
||||||
|
*/
|
||||||
|
private Integer recordType;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ public class WmsStockIoDetailVo {
|
|||||||
@ExcelProperty(value = "备注")
|
@ExcelProperty(value = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录类型,0:详情,1:扫码枪记录
|
||||||
|
*/
|
||||||
|
private Integer recordType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 库区/库位名称
|
* 库区/库位名称
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -162,6 +162,10 @@ public class WmsStockIoServiceImpl implements IWmsStockIoService {
|
|||||||
throw new RuntimeException("单据明细不能为空");
|
throw new RuntimeException("单据明细不能为空");
|
||||||
}
|
}
|
||||||
for (WmsStockIoDetail detail : details) {
|
for (WmsStockIoDetail detail : details) {
|
||||||
|
// 新增:扫码枪录入(recordType==1)时不做任何库存操作
|
||||||
|
if (detail.getRecordType() != null && detail.getRecordType() == 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String ioType = stockIo.getIoType();
|
String ioType = stockIo.getIoType();
|
||||||
if ("in".equals(ioType)) {
|
if ("in".equals(ioType)) {
|
||||||
// 入库:目标库位库存增加
|
// 入库:目标库位库存增加
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
<result property="updateBy" column="update_by"/>
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="fromWarehouseId" column="from_warehouse_id"/>
|
<result property="fromWarehouseId" column="from_warehouse_id"/>
|
||||||
|
<result property="recordType" column="record_type"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!-- 联查库区/库位名称的明细列表SQL,直接返回Map -->
|
<!-- 联查库区/库位名称的明细列表SQL,直接返回Map -->
|
||||||
@@ -40,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
d.update_time,
|
d.update_time,
|
||||||
d.update_by,
|
d.update_by,
|
||||||
d.from_warehouse_id,
|
d.from_warehouse_id,
|
||||||
|
d.record_type,
|
||||||
w1.warehouse_name AS warehouseName,
|
w1.warehouse_name AS warehouseName,
|
||||||
w2.warehouse_name AS fromWarehouseName
|
w2.warehouse_name AS fromWarehouseName
|
||||||
FROM wms_stock_io_detail d
|
FROM wms_stock_io_detail d
|
||||||
@@ -69,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
d.update_time,
|
d.update_time,
|
||||||
d.update_by,
|
d.update_by,
|
||||||
d.from_warehouse_id,
|
d.from_warehouse_id,
|
||||||
|
d.record_type,
|
||||||
w1.warehouse_name AS warehouseName,
|
w1.warehouse_name AS warehouseName,
|
||||||
w2.warehouse_name AS fromWarehouseName
|
w2.warehouse_name AS fromWarehouseName
|
||||||
FROM wms_stock_io_detail d
|
FROM wms_stock_io_detail d
|
||||||
|
|||||||
Reference in New Issue
Block a user