新增record_type字段区分扫码枪录入还是采购录入明细表,以及注释扫码枪代码,修改出入库移库逻辑
This commit is contained in:
@@ -1,70 +1,70 @@
|
||||
package com.klp.reader.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.klp.reader.entity.ScanResultEntity;
|
||||
import com.klp.reader.mapper.ScanResultMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import MvCodeReaderCtrlWrapper.*;
|
||||
import MvCodeReaderCtrlWrapper.MvCodeReaderCtrl.*;
|
||||
import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine.*;
|
||||
|
||||
@Service
|
||||
public class ScannerService {
|
||||
private Handle hHandle;
|
||||
|
||||
@Autowired
|
||||
private ScanResultMapper scanResultMapper; // 你需要实现这个Mapper
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
ArrayList<MV_CODEREADER_DEVICE_INFO> stCamList = MvCodeReaderCtrl.MV_CODEREADER_EnumDevices();
|
||||
if (stCamList == null || stCamList.isEmpty()) {
|
||||
System.out.println("Find No Device!");
|
||||
return;
|
||||
}
|
||||
MV_CODEREADER_DEVICE_INFO deviceInfo = stCamList.get(0);
|
||||
try {
|
||||
hHandle = MvCodeReaderCtrl.MV_CODEREADER_CreateHandle(deviceInfo);
|
||||
} catch (ParameterException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (hHandle == null) {
|
||||
System.out.println("Create handle failed!");
|
||||
return;
|
||||
}
|
||||
int nRet = MvCodeReaderCtrl.MV_CODEREADER_OpenDevice(hHandle);
|
||||
if (nRet != 0) {
|
||||
System.out.println("Open Device fail! nRet[" + String.format("0x%x", nRet) + "]");
|
||||
return;
|
||||
}
|
||||
MvCodeReaderCtrl.MV_CODEREADER_RegisterImageCallBackEx2(hHandle, (pdata, stOutInfo) -> {
|
||||
handleScanResult(stOutInfo);
|
||||
return 0;
|
||||
});
|
||||
MvCodeReaderCtrl.MV_CODEREADER_StartGrabbing(hHandle);
|
||||
}
|
||||
|
||||
private void handleScanResult(MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo) {
|
||||
for (int a = 0; a < stOutInfo.pstCodeListEx.nCodeNum; a++) {
|
||||
String code = stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).chCode;
|
||||
// 保存到数据库
|
||||
ScanResultEntity entity = new ScanResultEntity();
|
||||
entity.setCode(code);
|
||||
scanResultMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
if (hHandle != null) {
|
||||
MvCodeReaderCtrl.MV_CODEREADER_StopGrabbing(hHandle);
|
||||
MvCodeReaderCtrl.MV_CODEREADER_DestroyHandle(hHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.klp.reader.service;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import com.klp.reader.entity.ScanResultEntity;
|
||||
//import com.klp.reader.mapper.ScanResultMapper;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import javax.annotation.PostConstruct;
|
||||
//import javax.annotation.PreDestroy;
|
||||
//import java.util.ArrayList;
|
||||
//
|
||||
//import MvCodeReaderCtrlWrapper.*;
|
||||
//import MvCodeReaderCtrlWrapper.MvCodeReaderCtrl.*;
|
||||
//import MvCodeReaderCtrlWrapper.MvCodeReaderCtrlDefine.*;
|
||||
//
|
||||
//@Service
|
||||
//public class ScannerService {
|
||||
// private Handle hHandle;
|
||||
//
|
||||
// @Autowired
|
||||
// private ScanResultMapper scanResultMapper; // 你需要实现这个Mapper
|
||||
//
|
||||
// @PostConstruct
|
||||
// public void init() {
|
||||
// ArrayList<MV_CODEREADER_DEVICE_INFO> stCamList = MvCodeReaderCtrl.MV_CODEREADER_EnumDevices();
|
||||
// if (stCamList == null || stCamList.isEmpty()) {
|
||||
// System.out.println("Find No Device!");
|
||||
// return;
|
||||
// }
|
||||
// MV_CODEREADER_DEVICE_INFO deviceInfo = stCamList.get(0);
|
||||
// try {
|
||||
// hHandle = MvCodeReaderCtrl.MV_CODEREADER_CreateHandle(deviceInfo);
|
||||
// } catch (ParameterException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// if (hHandle == null) {
|
||||
// System.out.println("Create handle failed!");
|
||||
// return;
|
||||
// }
|
||||
// int nRet = MvCodeReaderCtrl.MV_CODEREADER_OpenDevice(hHandle);
|
||||
// if (nRet != 0) {
|
||||
// System.out.println("Open Device fail! nRet[" + String.format("0x%x", nRet) + "]");
|
||||
// return;
|
||||
// }
|
||||
// MvCodeReaderCtrl.MV_CODEREADER_RegisterImageCallBackEx2(hHandle, (pdata, stOutInfo) -> {
|
||||
// handleScanResult(stOutInfo);
|
||||
// return 0;
|
||||
// });
|
||||
// MvCodeReaderCtrl.MV_CODEREADER_StartGrabbing(hHandle);
|
||||
// }
|
||||
//
|
||||
// private void handleScanResult(MV_CODEREADER_IMAGE_OUT_INFO_EX2 stOutInfo) {
|
||||
// for (int a = 0; a < stOutInfo.pstCodeListEx.nCodeNum; a++) {
|
||||
// String code = stOutInfo.pstCodeListEx.stBcrInfoEx.get(a).chCode;
|
||||
// // 保存到数据库
|
||||
// ScanResultEntity entity = new ScanResultEntity();
|
||||
// entity.setCode(code);
|
||||
// scanResultMapper.insert(entity);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @PreDestroy
|
||||
// public void destroy() {
|
||||
// if (hHandle != null) {
|
||||
// MvCodeReaderCtrl.MV_CODEREADER_StopGrabbing(hHandle);
|
||||
// MvCodeReaderCtrl.MV_CODEREADER_DestroyHandle(hHandle);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user