Compare commits
8 Commits
master
...
d4b66aa77a
| Author | SHA1 | Date | |
|---|---|---|---|
| d4b66aa77a | |||
| 6754910edd | |||
| 68e2fbfc8c | |||
| 7d971f4d13 | |||
| 25af267b39 | |||
| 96d447fc0d | |||
| 1fa6933c18 | |||
| cfb6690df5 |
0
lib/autoreplyprint.jar
Normal file
0
lib/autoreplyprint.jar
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.dpkj.modules.autoReplyPrint.controller;
|
||||
|
||||
import com.dpkj.common.vo.Result;
|
||||
import com.dpkj.modules.autoReplyPrint.service.AutoReplyPrintService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 壁挂打印机
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("autoReplyPrint")
|
||||
public class AutoReplyPrintController {
|
||||
@Autowired
|
||||
private AutoReplyPrintService autoReplyPrintService;
|
||||
|
||||
/**
|
||||
* 获取打印机固件版本
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("CPPrinterGetPrinterFirmwareVersion")
|
||||
public Result<?> CPPrinterGetPrinterFirmwareVersion() {
|
||||
try {
|
||||
return autoReplyPrintService.CPPrinterGetPrinterFirmwareVersion();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info("获取打印机固件版本失败 {}", e.getMessage());
|
||||
return Result.error("获取打印机固件版本失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.dpkj.modules.autoReplyPrint.service;
|
||||
|
||||
|
||||
import com.dpkj.common.vo.Result;
|
||||
|
||||
public interface AutoReplyPrintService {
|
||||
|
||||
Result<?> CPPrinterGetPrinterFirmwareVersion();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.dpkj.modules.autoReplyPrint.service.impl;
|
||||
|
||||
import com.dpkj.common.vo.Result;
|
||||
import com.dpkj.modules.autoReplyPrint.service.AutoReplyPrintService;
|
||||
import com.dpkj.modules.autoReplyPrint.utils.AutoReplyPrint;
|
||||
import com.dpkj.modules.autoReplyPrint.utils.AutoReplyPrint2;
|
||||
import com.dpkj.modules.autoReplyPrint.utils.MyLibrary;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AutoReplyPrintServiceImpl implements AutoReplyPrintService {
|
||||
|
||||
private AutoReplyPrint2.AutoReplyPrint2Sdk autoReplyPrint2Sdk = AutoReplyPrint2.getAutoReplyPrint2SDK();
|
||||
|
||||
public AutoReplyPrintServiceImpl() throws AutoReplyPrint2.AutoReplyPrint2RegistrationException {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result<?> CPPrinterGetPrinterFirmwareVersion() {
|
||||
String s = MyLibrary.INSTANCE.CP_Printer_GetPrinterFirmwareVersion();
|
||||
//String s = autoReplyPrint2Sdk.CPPrinterGetPrinterFirmwareVersion();
|
||||
log.info("壁挂机打印机版本信息{}", s);
|
||||
return Result.ok(s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
package com.dpkj.modules.autoReplyPrint.service.impl;
|
||||
|
||||
import com.dpkj.modules.autoReplyPrint.utils.AutoReplyPrint;
|
||||
import com.dpkj.modules.autoReplyPrint.utils.TestFunction;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class samplelabel {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class GroupBoxPort extends JPanel implements ActionListener {
|
||||
|
||||
public JRadioButton rbCom = new JRadioButton();
|
||||
public JRadioButton rbTcp = new JRadioButton();
|
||||
public JRadioButton rbUsb = new JRadioButton();
|
||||
public ButtonGroup rbGroup = new ButtonGroup();
|
||||
|
||||
public JComboBox cbxComName = new JComboBox();
|
||||
public JComboBox cbxComBaudrate = new JComboBox();
|
||||
public JTextField editIPAddress = new JTextField();
|
||||
public JTextField editTcpPort = new JTextField();
|
||||
public JComboBox cbxUsbName = new JComboBox();
|
||||
|
||||
public GroupBoxPort() {
|
||||
this.setLayout(null);
|
||||
this.setSize(760, 120);
|
||||
this.setBorder(BorderFactory.createTitledBorder("Select Port"));
|
||||
|
||||
rbGroup.add(rbCom);
|
||||
rbGroup.add(rbTcp);
|
||||
rbGroup.add(rbUsb);
|
||||
|
||||
rbCom.setText("COM");
|
||||
rbCom.setBounds(10, 20, 60, 30);
|
||||
this.add(rbCom);
|
||||
|
||||
rbTcp.setText("TCP");
|
||||
rbTcp.setBounds(10, 50, 60, 30);
|
||||
this.add(rbTcp);
|
||||
|
||||
rbUsb.setText("USB");
|
||||
rbUsb.setBounds(10, 80, 60, 30);
|
||||
this.add(rbUsb);
|
||||
|
||||
cbxComName.setBounds(70, 20, 600, 30);
|
||||
this.add(cbxComName);
|
||||
cbxComBaudrate.setBounds(670, 20, 80, 30);
|
||||
this.add(cbxComBaudrate);
|
||||
editIPAddress.setBounds(70, 50, 600, 31);
|
||||
this.add(editIPAddress);
|
||||
editTcpPort.setBounds(670, 50, 81, 31);
|
||||
this.add(editTcpPort);
|
||||
cbxUsbName.setBounds(70, 80, 680, 30);
|
||||
this.add(cbxUsbName);
|
||||
|
||||
rbUsb.setSelected(true);
|
||||
editIPAddress.setText("192.168.1.87");
|
||||
editTcpPort.setText("9100");
|
||||
String[] ComBaudrateStringList = {"1200", "2400", "4800", "9600", "19200", "38400", "57600", "115200",
|
||||
"230400", "256000", "500000", "750000", "1125000", "1500000"};
|
||||
for (String baudrate : ComBaudrateStringList)
|
||||
cbxComBaudrate.addItem(baudrate);
|
||||
cbxComBaudrate.setSelectedIndex(7);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class TestForm extends JFrame implements ActionListener {
|
||||
|
||||
String[] testFunctionOrderedList = new String[]{
|
||||
|
||||
"Test_Label_SampleTicket_58MM_1",
|
||||
"Test_Label_SampleTicket_80MM_1",
|
||||
|
||||
"Test_Port_Write",
|
||||
"Test_Port_Read",
|
||||
"Test_Port_Available",
|
||||
"Test_Port_SkipAvailable",
|
||||
"Test_Port_IsConnectionValid",
|
||||
|
||||
"Test_Printer_GetPrinterInfo",
|
||||
"Test_Printer_ClearPrinterBuffer",
|
||||
"Test_Printer_ClearPrinterError",
|
||||
|
||||
"Test_Pos_QueryPrintResult",
|
||||
|
||||
"Test_Pos_KickOutDrawer",
|
||||
"Test_Pos_Beep",
|
||||
|
||||
"Test_Pos_PrintSelfTestPage",
|
||||
|
||||
"Test_Label_EnableLabelMode",
|
||||
"Test_Label_DisableLabelMode",
|
||||
"Test_Label_CalibrateLabel",
|
||||
"Test_Label_FeedLabel",
|
||||
"Test_Label_SetLabelPositionAdjustment",
|
||||
"Test_Label_PageBegin_PagePrint",
|
||||
"Test_Label_DrawText",
|
||||
"Test_Label_DrawBarcode_UPCA",
|
||||
"Test_Label_DrawBarcode_UPCE",
|
||||
"Test_Label_DrawBarcode_EAN13",
|
||||
"Test_Label_DrawBarcode_EAN8",
|
||||
"Test_Label_DrawBarcode_CODE39",
|
||||
"Test_Label_DrawBarcode_ITF",
|
||||
"Test_Label_DrawBarcode_CODEBAR",
|
||||
"Test_Label_DrawBarcode_CODE93",
|
||||
"Test_Label_DrawBarcode_CODE128",
|
||||
"Test_Label_DrawQRCode",
|
||||
"Test_Label_DrawPDF417Code",
|
||||
"Test_Label_DrawLine",
|
||||
"Test_Label_DrawRect",
|
||||
"Test_Label_DrawBox",
|
||||
"Test_Label_DrawImageFromBufferedImage",
|
||||
};
|
||||
|
||||
GroupBoxPort groupBoxPort = new GroupBoxPort();
|
||||
JButton btnEnumPort = new JButton();
|
||||
JButton btnOpenPort = new JButton();
|
||||
JButton btnClosePort = new JButton();
|
||||
JList listFunction = new JList(testFunctionOrderedList);
|
||||
JScrollPane scrollFunction = new JScrollPane(listFunction);
|
||||
JLabel labelFirmwareVersion = new JLabel();
|
||||
JLabel labelResolution = new JLabel();
|
||||
JLabel labelErrorStatus = new JLabel();
|
||||
JLabel labelInfoStatus = new JLabel();
|
||||
JLabel labelPrinterReceivedByteCount = new JLabel();
|
||||
JLabel labelPrinterPrintedPageID = new JLabel();
|
||||
Pointer h = Pointer.NULL;
|
||||
AutoReplyPrint.CP_OnPortClosedEvent_Callback closed_callback = new AutoReplyPrint.CP_OnPortClosedEvent_Callback() {
|
||||
@Override
|
||||
public void CP_OnPortClosedEvent(Pointer handle, Pointer private_data) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
btnClosePort.doClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
AutoReplyPrint.CP_OnPrinterStatusEvent_Callback status_callback = new AutoReplyPrint.CP_OnPrinterStatusEvent_Callback() {
|
||||
@Override
|
||||
public void CP_OnPrinterStatusEvent(Pointer h, final long printer_error_status,
|
||||
final long printer_info_status, Pointer private_data) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date calendarDate = calendar.getTime();
|
||||
String time = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss").format(calendarDate);
|
||||
AutoReplyPrint.CP_PrinterStatus status = new AutoReplyPrint.CP_PrinterStatus(
|
||||
printer_error_status, printer_info_status);
|
||||
String error_status_string = String.format(" Printer Error Status: 0x%04X",
|
||||
printer_error_status & 0xffff);
|
||||
if (status.ERROR_OCCURED()) {
|
||||
if (status.ERROR_CUTTER())
|
||||
error_status_string += "[ERROR_CUTTER]";
|
||||
if (status.ERROR_FLASH())
|
||||
error_status_string += "[ERROR_FLASH]";
|
||||
if (status.ERROR_NOPAPER())
|
||||
error_status_string += "[ERROR_NOPAPER]";
|
||||
if (status.ERROR_VOLTAGE())
|
||||
error_status_string += "[ERROR_VOLTAGE]";
|
||||
if (status.ERROR_MARKER())
|
||||
error_status_string += "[ERROR_MARKER]";
|
||||
if (status.ERROR_ENGINE())
|
||||
error_status_string += "[ERROR_ENGINE]";
|
||||
if (status.ERROR_OVERHEAT())
|
||||
error_status_string += "[ERROR_OVERHEAT]";
|
||||
if (status.ERROR_COVERUP())
|
||||
error_status_string += "[ERROR_COVERUP]";
|
||||
if (status.ERROR_MOTOR())
|
||||
error_status_string += "[ERROR_MOTOR]";
|
||||
}
|
||||
String info_status_string = String.format(" Printer Info Status: 0x%04X",
|
||||
printer_info_status & 0xffff);
|
||||
if (status.INFO_LABELMODE())
|
||||
info_status_string += "[Label Mode]";
|
||||
if (status.INFO_LABELPAPER())
|
||||
info_status_string += "[Label Paper]";
|
||||
if (status.INFO_PAPERNOFETCH())
|
||||
info_status_string += "[Paper Not Fetch]";
|
||||
labelErrorStatus.setText(time + error_status_string);
|
||||
labelInfoStatus.setText(time + info_status_string);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
AutoReplyPrint.CP_OnPrinterReceivedEvent_Callback received_callback = new AutoReplyPrint.CP_OnPrinterReceivedEvent_Callback() {
|
||||
@Override
|
||||
public void CP_OnPrinterReceivedEvent(Pointer h, final int printer_received_byte_count,
|
||||
Pointer private_data) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date calendarDate = calendar.getTime();
|
||||
String time = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss").format(calendarDate);
|
||||
labelPrinterReceivedByteCount
|
||||
.setText(time + " PrinterReceived: " + printer_received_byte_count);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
AutoReplyPrint.CP_OnPrinterPrintedEvent_Callback printed_callback = new AutoReplyPrint.CP_OnPrinterPrintedEvent_Callback() {
|
||||
@Override
|
||||
public void CP_OnPrinterPrintedEvent(Pointer h, final int printer_printed_page_id, Pointer private_data) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date calendarDate = calendar.getTime();
|
||||
String time = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss").format(calendarDate);
|
||||
labelPrinterPrintedPageID.setText(time + " PrinterPrinted: " + printer_printed_page_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private void AddCallback() {
|
||||
AutoReplyPrint.INSTANCE.CP_Port_AddOnPortClosedEvent(closed_callback, Pointer.NULL);
|
||||
AutoReplyPrint.INSTANCE.CP_Printer_AddOnPrinterStatusEvent(status_callback, Pointer.NULL);
|
||||
AutoReplyPrint.INSTANCE.CP_Printer_AddOnPrinterReceivedEvent(received_callback, Pointer.NULL);
|
||||
AutoReplyPrint.INSTANCE.CP_Printer_AddOnPrinterPrintedEvent(printed_callback, Pointer.NULL);
|
||||
}
|
||||
|
||||
private void RemoveCallback() {
|
||||
AutoReplyPrint.INSTANCE.CP_Port_RemoveOnPortClosedEvent(closed_callback);
|
||||
AutoReplyPrint.INSTANCE.CP_Printer_RemoveOnPrinterStatusEvent(status_callback);
|
||||
AutoReplyPrint.INSTANCE.CP_Printer_RemoveOnPrinterReceivedEvent(received_callback);
|
||||
AutoReplyPrint.INSTANCE.CP_Printer_RemoveOnPrinterPrintedEvent(printed_callback);
|
||||
}
|
||||
|
||||
public TestForm() {
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(null);
|
||||
this.setVisible(true);
|
||||
this.setSize(800, 700);
|
||||
this.setTitle(AutoReplyPrint.INSTANCE.CP_Library_Version());
|
||||
|
||||
groupBoxPort.setLocation(10, 10);
|
||||
this.add(groupBoxPort);
|
||||
|
||||
btnEnumPort.setBounds(20, 140, 240, 30);
|
||||
btnEnumPort.setText("EnumPort");
|
||||
btnEnumPort.addActionListener(this);
|
||||
this.add(btnEnumPort);
|
||||
btnOpenPort.setBounds(270, 140, 240, 30);
|
||||
btnOpenPort.setText("OpenPort");
|
||||
btnOpenPort.addActionListener(this);
|
||||
this.add(btnOpenPort);
|
||||
btnClosePort.setBounds(520, 140, 240, 30);
|
||||
btnClosePort.setText("ClosePort");
|
||||
btnClosePort.addActionListener(this);
|
||||
this.add(btnClosePort);
|
||||
|
||||
labelFirmwareVersion.setBounds(20, 460, 740, 30);
|
||||
labelFirmwareVersion.setText("Firmware Version:");
|
||||
this.add(labelFirmwareVersion);
|
||||
labelResolution.setBounds(20, 490, 740, 30);
|
||||
labelResolution.setText("Resolution:");
|
||||
this.add(labelResolution);
|
||||
labelErrorStatus.setBounds(20, 520, 740, 30);
|
||||
labelErrorStatus.setText("Error Status:");
|
||||
this.add(labelErrorStatus);
|
||||
labelInfoStatus.setBounds(20, 550, 740, 30);
|
||||
labelInfoStatus.setText("Info Status:");
|
||||
this.add(labelInfoStatus);
|
||||
labelPrinterReceivedByteCount.setBounds(20, 580, 740, 30);
|
||||
labelPrinterReceivedByteCount.setText("Printer Received Byte Count:");
|
||||
this.add(labelPrinterReceivedByteCount);
|
||||
labelPrinterPrintedPageID.setBounds(20, 610, 740, 30);
|
||||
labelPrinterPrintedPageID.setText("Printer Printed Page ID:");
|
||||
this.add(labelPrinterPrintedPageID);
|
||||
|
||||
scrollFunction.setBounds(20, 180, 740, 270);
|
||||
this.add(scrollFunction);
|
||||
listFunction.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
// listFunction.addListSelectionListener(this);
|
||||
listFunction.addMouseListener(new MouseListener() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
if (e.getSource() == listFunction) {
|
||||
String functionName = listFunction.getSelectedValue().toString();
|
||||
if ((functionName == null) || (functionName.isEmpty()))
|
||||
return;
|
||||
try {
|
||||
TestFunction fun = new TestFunction();
|
||||
Method m = TestFunction.class.getDeclaredMethod(functionName, Pointer.class);
|
||||
m.invoke(fun, h);
|
||||
} catch (Throwable tr) {
|
||||
tr.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
btnEnumPort.doClick();
|
||||
refreshUI();
|
||||
|
||||
AddCallback();
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
RemoveCallback();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == btnEnumPort) {
|
||||
String[] port_list = null;
|
||||
|
||||
groupBoxPort.cbxComName.removeAllItems();
|
||||
port_list = AutoReplyPrint.CP_Port_EnumCom_Helper.EnumCom();
|
||||
if (port_list != null) {
|
||||
for (String port : port_list)
|
||||
groupBoxPort.cbxComName.addItem(port);
|
||||
}
|
||||
|
||||
groupBoxPort.cbxUsbName.removeAllItems();
|
||||
port_list = AutoReplyPrint.CP_Port_EnumUsb_Helper.EnumUsb();
|
||||
if (port_list != null) {
|
||||
for (String port : port_list)
|
||||
groupBoxPort.cbxUsbName.addItem(port);
|
||||
}
|
||||
|
||||
} else if (e.getSource() == btnOpenPort) {
|
||||
if (groupBoxPort.rbCom.isSelected()) {
|
||||
if (groupBoxPort.cbxComName.getSelectedItem() == null)
|
||||
return;
|
||||
String name = groupBoxPort.cbxComName.getSelectedItem().toString();
|
||||
int baudrate = Integer.parseInt(groupBoxPort.cbxComBaudrate.getSelectedItem().toString());
|
||||
h = AutoReplyPrint.INSTANCE.CP_Port_OpenCom(name, baudrate, AutoReplyPrint.CP_ComDataBits_8,
|
||||
AutoReplyPrint.CP_ComParity_NoParity, AutoReplyPrint.CP_ComStopBits_One, AutoReplyPrint.CP_ComFlowControl_None,
|
||||
1);
|
||||
} else if (groupBoxPort.rbUsb.isSelected()) {
|
||||
if (groupBoxPort.cbxUsbName.getSelectedItem() == null)
|
||||
return;
|
||||
String name = groupBoxPort.cbxUsbName.getSelectedItem().toString();
|
||||
h = AutoReplyPrint.INSTANCE.CP_Port_OpenUsb(name, 1);
|
||||
} else if (groupBoxPort.rbTcp.isSelected()) {
|
||||
String ip = groupBoxPort.editIPAddress.getText();
|
||||
int port = Integer.parseInt(groupBoxPort.editTcpPort.getText());
|
||||
h = AutoReplyPrint.INSTANCE.CP_Port_OpenTcp(null, ip, (short) port, 5000, 1);
|
||||
}
|
||||
refreshUI();
|
||||
} else if (e.getSource() == btnClosePort) {
|
||||
if (h != Pointer.NULL) {
|
||||
AutoReplyPrint.INSTANCE.CP_Port_Close(h);
|
||||
h = Pointer.NULL;
|
||||
}
|
||||
refreshUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshUI() {
|
||||
groupBoxPort.setEnabled(h == Pointer.NULL);
|
||||
btnEnumPort.setEnabled(h == Pointer.NULL);
|
||||
btnOpenPort.setEnabled(h == Pointer.NULL);
|
||||
btnClosePort.setEnabled(h != Pointer.NULL);
|
||||
listFunction.setEnabled(h != Pointer.NULL);
|
||||
if (h != Pointer.NULL) {
|
||||
labelFirmwareVersion.setText("Firmware Version: "
|
||||
+ AutoReplyPrint.CP_Printer_GetPrinterFirmwareVersion_Helper.GetPrinterFirmwareVersion(h));
|
||||
IntByReference width_mm = new IntByReference();
|
||||
IntByReference height_mm = new IntByReference();
|
||||
IntByReference dots_per_mm = new IntByReference();
|
||||
if (AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterResolutionInfo(h, width_mm, height_mm, dots_per_mm)) {
|
||||
labelResolution.setText("Resolution: " + "width:" + width_mm.getValue() + "mm " + "height:"
|
||||
+ height_mm.getValue() + "mm " + "dots_per_mm:" + dots_per_mm.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static TestForm testform;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
testform = new samplelabel().new TestForm();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,849 @@
|
||||
package com.dpkj.modules.autoReplyPrint.utils;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.ptr.DoubleByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.LongByReference;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public interface AutoReplyPrint extends Library {
|
||||
AutoReplyPrint INSTANCE = (AutoReplyPrint) Native.loadLibrary(GetLibraryPath_Helper.GetLibraryPath(), AutoReplyPrint.class);
|
||||
int CP_ComDataBits_4 = 4;
|
||||
int CP_ComDataBits_5 = 5;
|
||||
int CP_ComDataBits_6 = 6;
|
||||
int CP_ComDataBits_7 = 7;
|
||||
int CP_ComDataBits_8 = 8;
|
||||
int CP_ComParity_NoParity = 0;
|
||||
int CP_ComParity_OddParity = 1;
|
||||
int CP_ComParity_EvenParity = 2;
|
||||
int CP_ComParity_MarkParity = 3;
|
||||
int CP_ComParity_SpaceParity = 4;
|
||||
int CP_ComStopBits_One = 0;
|
||||
int CP_ComStopBits_OnePointFive = 1;
|
||||
int CP_ComStopBits_Two = 2;
|
||||
int CP_ComFlowControl_None = 0;
|
||||
int CP_ComFlowControl_XonXoff = 1;
|
||||
int CP_ComFlowControl_RtsCts = 2;
|
||||
int CP_ComFlowControl_DtrDsr = 3;
|
||||
int CP_CharacterSet_USA = 0;
|
||||
int CP_CharacterSet_FRANCE = 1;
|
||||
int CP_CharacterSet_GERMANY = 2;
|
||||
int CP_CharacterSet_UK = 3;
|
||||
int CP_CharacterSet_DENMARK_I = 4;
|
||||
int CP_CharacterSet_SWEDEN = 5;
|
||||
int CP_CharacterSet_ITALY = 6;
|
||||
int CP_CharacterSet_SPAIN_I = 7;
|
||||
int CP_CharacterSet_JAPAN = 8;
|
||||
int CP_CharacterSet_NORWAY = 9;
|
||||
int CP_CharacterSet_DENMARK_II = 10;
|
||||
int CP_CharacterSet_SPAIN_II = 11;
|
||||
int CP_CharacterSet_LATIN = 12;
|
||||
int CP_CharacterSet_KOREA = 13;
|
||||
int CP_CharacterSet_SLOVENIA = 14;
|
||||
int CP_CharacterSet_CHINA = 15;
|
||||
int CP_CharacterCodepage_CP437 = 0;
|
||||
int CP_CharacterCodepage_KATAKANA = 1;
|
||||
int CP_CharacterCodepage_CP850 = 2;
|
||||
int CP_CharacterCodepage_CP860 = 3;
|
||||
int CP_CharacterCodepage_CP863 = 4;
|
||||
int CP_CharacterCodepage_CP865 = 5;
|
||||
int CP_CharacterCodepage_WCP1251 = 6;
|
||||
int CP_CharacterCodepage_CP866 = 7;
|
||||
int CP_CharacterCodepage_MIK = 8;
|
||||
int CP_CharacterCodepage_CP755 = 9;
|
||||
int CP_CharacterCodepage_IRAN = 10;
|
||||
int CP_CharacterCodepage_CP862 = 15;
|
||||
int CP_CharacterCodepage_WCP1252 = 16;
|
||||
int CP_CharacterCodepage_WCP1253 = 17;
|
||||
int CP_CharacterCodepage_CP852 = 18;
|
||||
int CP_CharacterCodepage_CP858 = 19;
|
||||
int CP_CharacterCodepage_IRAN_II = 20;
|
||||
int CP_CharacterCodepage_LATVIAN = 21;
|
||||
int CP_CharacterCodepage_CP864 = 22;
|
||||
int CP_CharacterCodepage_ISO_8859_1 = 23;
|
||||
int CP_CharacterCodepage_CP737 = 24;
|
||||
int CP_CharacterCodepage_WCP1257 = 25;
|
||||
int CP_CharacterCodepage_THAI = 26;
|
||||
int CP_CharacterCodepage_CP720 = 27;
|
||||
int CP_CharacterCodepage_CP855 = 28;
|
||||
int CP_CharacterCodepage_CP857 = 29;
|
||||
int CP_CharacterCodepage_WCP1250 = 30;
|
||||
int CP_CharacterCodepage_CP775 = 31;
|
||||
int CP_CharacterCodepage_WCP1254 = 32;
|
||||
int CP_CharacterCodepage_WCP1255 = 33;
|
||||
int CP_CharacterCodepage_WCP1256 = 34;
|
||||
int CP_CharacterCodepage_WCP1258 = 35;
|
||||
int CP_CharacterCodepage_ISO_8859_2 = 36;
|
||||
int CP_CharacterCodepage_ISO_8859_3 = 37;
|
||||
int CP_CharacterCodepage_ISO_8859_4 = 38;
|
||||
int CP_CharacterCodepage_ISO_8859_5 = 39;
|
||||
int CP_CharacterCodepage_ISO_8859_6 = 40;
|
||||
int CP_CharacterCodepage_ISO_8859_7 = 41;
|
||||
int CP_CharacterCodepage_ISO_8859_8 = 42;
|
||||
int CP_CharacterCodepage_ISO_8859_9 = 43;
|
||||
int CP_CharacterCodepage_ISO_8859_15 = 44;
|
||||
int CP_CharacterCodepage_THAI_2 = 45;
|
||||
int CP_CharacterCodepage_CP856 = 46;
|
||||
int CP_CharacterCodepage_CP874 = 47;
|
||||
int CP_CharacterCodepage_TCVN3 = 48;
|
||||
int CP_MultiByteEncoding_GBK = 0;
|
||||
int CP_MultiByteEncoding_UTF8 = 1;
|
||||
int CP_MultiByteEncoding_BIG5 = 3;
|
||||
int CP_MultiByteEncoding_ShiftJIS = 4;
|
||||
int CP_MultiByteEncoding_EUCKR = 5;
|
||||
int CP_ImageBinarizationMethod_Dithering = 0;
|
||||
int CP_ImageBinarizationMethod_Thresholding = 1;
|
||||
int CP_ImageBinarizationMethod_ErrorDiffusion = 2;
|
||||
int CP_ImageCompressionMethod_None = 0;
|
||||
int CP_ImageCompressionMethod_Level1 = 1;
|
||||
int CP_ImageCompressionMethod_Level2 = 2;
|
||||
int CP_ImagePixelsFormat_MONO = 1;
|
||||
int CP_ImagePixelsFormat_MONOLSB = 2;
|
||||
int CP_ImagePixelsFormat_GRAY8 = 3;
|
||||
int CP_ImagePixelsFormat_BYTEORDERED_RGB24 = 4;
|
||||
int CP_ImagePixelsFormat_BYTEORDERED_BGR24 = 5;
|
||||
int CP_ImagePixelsFormat_BYTEORDERED_ARGB32 = 6;
|
||||
int CP_ImagePixelsFormat_BYTEORDERED_RGBA32 = 7;
|
||||
int CP_ImagePixelsFormat_BYTEORDERED_ABGR32 = 8;
|
||||
int CP_ImagePixelsFormat_BYTEORDERED_BGRA32 = 9;
|
||||
int CP_QRCodeECC_L = 1;
|
||||
int CP_QRCodeECC_M = 2;
|
||||
int CP_QRCodeECC_Q = 3;
|
||||
int CP_QRCodeECC_H = 4;
|
||||
int CP_Pos_Alignment_Left = 0;
|
||||
int CP_Pos_Alignment_HCenter = 1;
|
||||
int CP_Pos_Alignment_Right = 2;
|
||||
int CP_Pos_BarcodeType_UPCA = 65;
|
||||
int CP_Pos_BarcodeType_UPCE = 66;
|
||||
int CP_Pos_BarcodeType_EAN13 = 67;
|
||||
int CP_Pos_BarcodeType_EAN8 = 68;
|
||||
int CP_Pos_BarcodeType_CODE39 = 69;
|
||||
int CP_Pos_BarcodeType_ITF = 70;
|
||||
int CP_Pos_BarcodeType_CODEBAR = 71;
|
||||
int CP_Pos_BarcodeType_CODE93 = 72;
|
||||
int CP_Pos_BarcodeType_CODE128 = 73;
|
||||
int CP_Pos_BarcodeTextPrintPosition_None = 0;
|
||||
int CP_Pos_BarcodeTextPrintPosition_AboveBarcode = 1;
|
||||
int CP_Pos_BarcodeTextPrintPosition_BelowBarcode = 2;
|
||||
int CP_Pos_BarcodeTextPrintPosition_AboveAndBelowBarcode = 3;
|
||||
int CP_Page_DrawDirection_LeftToRight = 0;
|
||||
int CP_Page_DrawDirection_BottomToTop = 1;
|
||||
int CP_Page_DrawDirection_RightToLeft = 2;
|
||||
int CP_Page_DrawDirection_TopToBottom = 3;
|
||||
int CP_Page_DrawAlignment_Left = -1;
|
||||
int CP_Page_DrawAlignment_HCenter = -2;
|
||||
int CP_Page_DrawAlignment_Right = -3;
|
||||
int CP_Page_DrawAlignment_Top = -1;
|
||||
int CP_Page_DrawAlignment_VCenter = -2;
|
||||
int CP_Page_DrawAlignment_Bottom = -3;
|
||||
int CP_Label_BarcodeType_UPCA = 0;
|
||||
int CP_Label_BarcodeType_UPCE = 1;
|
||||
int CP_Label_BarcodeType_EAN13 = 2;
|
||||
int CP_Label_BarcodeType_EAN8 = 3;
|
||||
int CP_Label_BarcodeType_CODE39 = 4;
|
||||
int CP_Label_BarcodeType_ITF = 5;
|
||||
int CP_Label_BarcodeType_CODEBAR = 6;
|
||||
int CP_Label_BarcodeType_CODE93 = 7;
|
||||
int CP_Label_BarcodeType_CODE128 = 8;
|
||||
int CP_Label_BarcodeType_CODE11 = 9;
|
||||
int CP_Label_BarcodeType_MSI = 10;
|
||||
int CP_Label_BarcodeType_128M = 11;
|
||||
int CP_Label_BarcodeType_EAN128 = 12;
|
||||
int CP_Label_BarcodeType_25C = 13;
|
||||
int CP_Label_BarcodeType_39C = 14;
|
||||
int CP_Label_BarcodeType_39 = 15;
|
||||
int CP_Label_BarcodeType_EAN13PLUS2 = 16;
|
||||
int CP_Label_BarcodeType_EAN13PLUS5 = 17;
|
||||
int CP_Label_BarcodeType_EAN8PLUS2 = 18;
|
||||
int CP_Label_BarcodeType_EAN8PLUS5 = 19;
|
||||
int CP_Label_BarcodeType_POST = 20;
|
||||
int CP_Label_BarcodeType_UPCAPLUS2 = 21;
|
||||
int CP_Label_BarcodeType_UPCAPLUS5 = 22;
|
||||
int CP_Label_BarcodeType_UPCEPLUS2 = 23;
|
||||
int CP_Label_BarcodeType_UPCEPLUS5 = 24;
|
||||
int CP_Label_BarcodeType_CPOST = 25;
|
||||
int CP_Label_BarcodeType_MSIC = 26;
|
||||
int CP_Label_BarcodeType_PLESSEY = 27;
|
||||
int CP_Label_BarcodeType_ITF14 = 28;
|
||||
int CP_Label_BarcodeType_EAN14 = 29;
|
||||
int CP_Label_BarcodeTextPrintPosition_None = 0;
|
||||
int CP_Label_BarcodeTextPrintPosition_AboveBarcode = 1;
|
||||
int CP_Label_BarcodeTextPrintPosition_BelowBarcode = 2;
|
||||
int CP_Label_BarcodeTextPrintPosition_AboveAndBelowBarcode = 3;
|
||||
int CP_Label_Rotation_0 = 0;
|
||||
int CP_Label_Rotation_90 = 1;
|
||||
int CP_Label_Rotation_180 = 2;
|
||||
int CP_Label_Rotation_270 = 3;
|
||||
int CP_Label_Color_White = 0;
|
||||
int CP_Label_Color_Black = 1;
|
||||
|
||||
String CP_Library_Version();
|
||||
|
||||
int CP_Port_EnumCom(byte[] var1, int var2, IntByReference var3);
|
||||
|
||||
int CP_Port_EnumLpt(byte[] var1, int var2, IntByReference var3);
|
||||
|
||||
int CP_Port_EnumUsb(byte[] var1, int var2, IntByReference var3);
|
||||
|
||||
void CP_Port_EnumNetPrinter(int var1, IntByReference var2, CP_OnNetPrinterDiscovered_Callback var3, Pointer var4);
|
||||
|
||||
void CP_Port_EnumBtDevice(int var1, IntByReference var2, CP_OnBluetoothDeviceDiscovered_Callback var3, Pointer var4);
|
||||
|
||||
void CP_Port_EnumBleDevice(int var1, IntByReference var2, CP_OnBluetoothDeviceDiscovered_Callback var3, Pointer var4);
|
||||
|
||||
Pointer CP_Port_OpenCom(String var1, int var2, int var3, int var4, int var5, int var6, int var7);
|
||||
|
||||
Pointer CP_Port_OpenLpt(String var1);
|
||||
|
||||
Pointer CP_Port_OpenUsb(String var1, int var2);
|
||||
|
||||
Pointer CP_Port_OpenTcp(String var1, String var2, short var3, int var4, int var5);
|
||||
|
||||
Pointer CP_Port_OpenBtSpp(String var1, int var2);
|
||||
|
||||
Pointer CP_Port_OpenBtBle(String var1, int var2);
|
||||
|
||||
int CP_Port_Write(Pointer var1, byte[] var2, int var3, int var4);
|
||||
|
||||
int CP_Port_Read(Pointer var1, byte[] var2, int var3, int var4);
|
||||
|
||||
int CP_Port_ReadUntilByte(Pointer var1, byte[] var2, int var3, int var4, byte var5);
|
||||
|
||||
int CP_Port_Available(Pointer var1);
|
||||
|
||||
boolean CP_Port_SkipAvailable(Pointer var1);
|
||||
|
||||
boolean CP_Port_IsConnectionValid(Pointer var1);
|
||||
|
||||
boolean CP_Port_IsOpened(Pointer var1);
|
||||
|
||||
boolean CP_Port_Close(Pointer var1);
|
||||
|
||||
boolean CP_Port_AddOnPortOpenedEvent(CP_OnPortOpenedEvent_Callback var1, Pointer var2);
|
||||
|
||||
boolean CP_Port_AddOnPortOpenFailedEvent(CP_OnPortOpenFailedEvent_Callback var1, Pointer var2);
|
||||
|
||||
boolean CP_Port_AddOnPortClosedEvent(CP_OnPortClosedEvent_Callback var1, Pointer var2);
|
||||
|
||||
boolean CP_Port_AddOnPortWrittenEvent(CP_OnPortWrittenEvent_Callback var1, Pointer var2);
|
||||
|
||||
boolean CP_Port_AddOnPortReceivedEvent(CP_OnPortReceivedEvent_Callback var1, Pointer var2);
|
||||
|
||||
boolean CP_Port_RemoveOnPortOpenedEvent(CP_OnPortOpenedEvent_Callback var1);
|
||||
|
||||
boolean CP_Port_RemoveOnPortOpenFailedEvent(CP_OnPortOpenFailedEvent_Callback var1);
|
||||
|
||||
boolean CP_Port_RemoveOnPortClosedEvent(CP_OnPortClosedEvent_Callback var1);
|
||||
|
||||
boolean CP_Port_RemoveOnPortWrittenEvent(CP_OnPortWrittenEvent_Callback var1);
|
||||
|
||||
boolean CP_Port_RemoveOnPortReceivedEvent(CP_OnPortReceivedEvent_Callback var1);
|
||||
|
||||
boolean CP_Printer_AddOnPrinterStatusEvent(CP_OnPrinterStatusEvent_Callback var1, Pointer var2);
|
||||
|
||||
boolean CP_Printer_AddOnPrinterReceivedEvent(CP_OnPrinterReceivedEvent_Callback var1, Pointer var2);
|
||||
|
||||
boolean CP_Printer_AddOnPrinterPrintedEvent(CP_OnPrinterPrintedEvent_Callback var1, Pointer var2);
|
||||
|
||||
boolean CP_Printer_RemoveOnPrinterStatusEvent(CP_OnPrinterStatusEvent_Callback var1);
|
||||
|
||||
boolean CP_Printer_RemoveOnPrinterReceivedEvent(CP_OnPrinterReceivedEvent_Callback var1);
|
||||
|
||||
boolean CP_Printer_RemoveOnPrinterPrintedEvent(CP_OnPrinterPrintedEvent_Callback var1);
|
||||
|
||||
boolean CP_Printer_GetPrinterResolutionInfo(Pointer var1, IntByReference var2, IntByReference var3, IntByReference var4);
|
||||
|
||||
boolean CP_Printer_GetPrinterFirmwareVersion(Pointer var1, byte[] var2, int var3, IntByReference var4);
|
||||
|
||||
boolean CP_Printer_GetPrinterStatusInfo(Pointer var1, LongByReference var2, LongByReference var3, LongByReference var4);
|
||||
|
||||
boolean CP_Printer_GetPrinterReceivedInfo(Pointer var1, IntByReference var2, LongByReference var3);
|
||||
|
||||
boolean CP_Printer_GetPrinterPrintedInfo(Pointer var1, IntByReference var2, LongByReference var3);
|
||||
|
||||
boolean CP_Printer_GetPrinterLabelPositionAdjustmentInfo(Pointer var1, DoubleByReference var2, DoubleByReference var3, LongByReference var4);
|
||||
|
||||
boolean CP_Printer_SetPrinterLabelPositionAdjustmentInfo(Pointer var1, double var2, double var4);
|
||||
|
||||
boolean CP_Printer_ClearPrinterBuffer(Pointer var1);
|
||||
|
||||
boolean CP_Printer_ClearPrinterError(Pointer var1);
|
||||
|
||||
int CP_Pos_QueryRTStatus(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_QueryPrintResult(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_KickOutDrawer(Pointer var1, int var2, int var3, int var4);
|
||||
|
||||
boolean CP_Pos_Beep(Pointer var1, int var2, int var3);
|
||||
|
||||
boolean CP_Pos_FeedAndHalfCutPaper(Pointer var1);
|
||||
|
||||
boolean CP_Pos_FullCutPaper(Pointer var1);
|
||||
|
||||
boolean CP_Pos_HalfCutPaper(Pointer var1);
|
||||
|
||||
boolean CP_Pos_FeedLine(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_FeedDot(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_PrintSelfTestPage(Pointer var1);
|
||||
|
||||
boolean CP_Pos_PrintText(Pointer var1, String var2);
|
||||
|
||||
boolean CP_Pos_PrintTextInUTF8(Pointer var1, WString var2);
|
||||
|
||||
boolean CP_Pos_PrintTextInGBK(Pointer var1, WString var2);
|
||||
|
||||
boolean CP_Pos_PrintTextInBIG5(Pointer var1, WString var2);
|
||||
|
||||
boolean CP_Pos_PrintTextInShiftJIS(Pointer var1, WString var2);
|
||||
|
||||
boolean CP_Pos_PrintTextInEUCKR(Pointer var1, WString var2);
|
||||
|
||||
boolean CP_Pos_PrintBarcode(Pointer var1, int var2, String var3);
|
||||
|
||||
boolean CP_Pos_PrintBarcode_Code128Auto(Pointer var1, String var2);
|
||||
|
||||
boolean CP_Pos_PrintQRCode(Pointer var1, int var2, int var3, String var4);
|
||||
|
||||
boolean CP_Pos_PrintQRCodeUseEpsonCmd(Pointer var1, int var2, int var3, String var4);
|
||||
|
||||
boolean CP_Pos_PrintDoubleQRCode(Pointer var1, int var2, int var3, int var4, int var5, String var6, int var7, int var8, int var9, String var10);
|
||||
|
||||
boolean CP_Pos_PrintPDF417BarcodeUseEpsonCmd(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7, String var8);
|
||||
|
||||
boolean CP_Pos_PrintRasterImageFromFile(Pointer var1, int var2, int var3, String var4, int var5, int var6);
|
||||
|
||||
boolean CP_Pos_PrintRasterImageFromData(Pointer var1, int var2, int var3, byte[] var4, int var5, int var6, int var7);
|
||||
|
||||
boolean CP_Pos_PrintRasterImageFromPixels(Pointer var1, byte[] var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9);
|
||||
|
||||
boolean CP_Pos_PrintHorizontalLine(Pointer var1, int var2, int var3);
|
||||
|
||||
boolean CP_Pos_PrintHorizontalLineSpecifyThickness(Pointer var1, int var2, int var3, int var4);
|
||||
|
||||
boolean CP_Pos_PrintMultipleHorizontalLinesAtOneRow(Pointer var1, int var2, int[] var3, int[] var4);
|
||||
|
||||
boolean CP_Pos_ResetPrinter(Pointer var1);
|
||||
|
||||
boolean CP_Pos_SetPrintSpeed(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetPrintDensity(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetSingleByteMode(Pointer var1);
|
||||
|
||||
boolean CP_Pos_SetCharacterSet(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetCharacterCodepage(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetMultiByteMode(Pointer var1);
|
||||
|
||||
boolean CP_Pos_SetMultiByteEncoding(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetMovementUnit(Pointer var1, int var2, int var3);
|
||||
|
||||
boolean CP_Pos_SetPrintAreaLeftMargin(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetPrintAreaWidth(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetHorizontalAbsolutePrintPosition(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetHorizontalRelativePrintPosition(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetVerticalAbsolutePrintPosition(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetVerticalRelativePrintPosition(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetAlignment(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetTextScale(Pointer var1, int var2, int var3);
|
||||
|
||||
boolean CP_Pos_SetAsciiTextFontType(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetTextBold(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetTextUnderline(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetTextUpsideDown(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetTextWhiteOnBlack(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetTextRotate(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetTextLineHeight(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetAsciiTextCharRightSpacing(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetKanjiTextCharSpacing(Pointer var1, int var2, int var3);
|
||||
|
||||
boolean CP_Pos_SetBarcodeUnitWidth(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetBarcodeHeight(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetBarcodeReadableTextFontType(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Pos_SetBarcodeReadableTextPosition(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Page_SelectPageMode(Pointer var1);
|
||||
|
||||
boolean CP_Page_SelectPageModeEx(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7);
|
||||
|
||||
boolean CP_Page_ExitPageMode(Pointer var1);
|
||||
|
||||
boolean CP_Page_PrintPage(Pointer var1);
|
||||
|
||||
boolean CP_Page_ClearPage(Pointer var1);
|
||||
|
||||
boolean CP_Page_SetPageArea(Pointer var1, int var2, int var3, int var4, int var5);
|
||||
|
||||
boolean CP_Page_SetPageDrawDirection(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Page_DrawRect(Pointer var1, int var2, int var3, int var4, int var5, int var6);
|
||||
|
||||
boolean CP_Page_DrawBox(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7);
|
||||
|
||||
boolean CP_Page_DrawText(Pointer var1, int var2, int var3, String var4);
|
||||
|
||||
boolean CP_Page_DrawTextInUTF8(Pointer var1, int var2, int var3, WString var4);
|
||||
|
||||
boolean CP_Page_DrawTextInGBK(Pointer var1, int var2, int var3, WString var4);
|
||||
|
||||
boolean CP_Page_DrawTextInBIG5(Pointer var1, int var2, int var3, WString var4);
|
||||
|
||||
boolean CP_Page_DrawTextInShiftJIS(Pointer var1, int var2, int var3, WString var4);
|
||||
|
||||
boolean CP_Page_DrawTextInEUCKR(Pointer var1, int var2, int var3, WString var4);
|
||||
|
||||
boolean CP_Page_DrawBarcode(Pointer var1, int var2, int var3, int var4, String var5);
|
||||
|
||||
boolean CP_Page_DrawQRCode(Pointer var1, int var2, int var3, int var4, int var5, String var6);
|
||||
|
||||
boolean CP_Page_DrawRasterImageFromFile(Pointer var1, int var2, int var3, int var4, int var5, String var6, int var7);
|
||||
|
||||
boolean CP_Page_DrawRasterImageFromData(Pointer var1, int var2, int var3, int var4, int var5, byte[] var6, int var7, int var8);
|
||||
|
||||
boolean CP_Page_DrawRasterImageFromPixels(Pointer var1, int var2, int var3, byte[] var4, int var5, int var6, int var7, int var8, int var9, int var10);
|
||||
|
||||
boolean CP_BlackMark_EnableBlackMarkMode(Pointer var1);
|
||||
|
||||
boolean CP_BlackMark_DisableBlackMarkMode(Pointer var1);
|
||||
|
||||
boolean CP_BlackMark_SetBlackMarkMaxFindLength(Pointer var1, int var2);
|
||||
|
||||
boolean CP_BlackMark_FindNextBlackMark(Pointer var1);
|
||||
|
||||
boolean CP_BlackMark_SetBlackMarkPaperPrintPosition(Pointer var1, int var2);
|
||||
|
||||
boolean CP_BlackMark_SetBlackMarkPaperCutPosition(Pointer var1, int var2);
|
||||
|
||||
boolean CP_BlackMark_FullCutBlackMarkPaper(Pointer var1);
|
||||
|
||||
boolean CP_BlackMark_HalfCutBlackMarkPaper(Pointer var1);
|
||||
|
||||
boolean CP_Label_EnableLabelMode(Pointer var1);
|
||||
|
||||
boolean CP_Label_DisableLabelMode(Pointer var1);
|
||||
|
||||
boolean CP_Label_CalibrateLabel(Pointer var1);
|
||||
|
||||
boolean CP_Label_FeedLabel(Pointer var1);
|
||||
|
||||
boolean CP_Label_PageBegin(Pointer var1, int var2, int var3, int var4, int var5, int var6);
|
||||
|
||||
boolean CP_Label_PagePrint(Pointer var1, int var2);
|
||||
|
||||
boolean CP_Label_DrawText(Pointer var1, int var2, int var3, int var4, int var5, String var6);
|
||||
|
||||
boolean CP_Label_DrawTextInUTF8(Pointer var1, int var2, int var3, int var4, int var5, WString var6);
|
||||
|
||||
boolean CP_Label_DrawTextInGBK(Pointer var1, int var2, int var3, int var4, int var5, WString var6);
|
||||
|
||||
boolean CP_Label_DrawBarcode(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, String var9);
|
||||
|
||||
boolean CP_Label_DrawQRCode(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7, String var8);
|
||||
|
||||
boolean CP_Label_DrawPDF417Code(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, String var9);
|
||||
|
||||
boolean CP_Label_DrawImageFromFile(Pointer var1, int var2, int var3, int var4, int var5, String var6, int var7, int var8);
|
||||
|
||||
boolean CP_Label_DrawImageFromData(Pointer var1, int var2, int var3, int var4, int var5, byte[] var6, int var7, int var8, int var9);
|
||||
|
||||
boolean CP_Label_DrawImageFromPixels(Pointer var1, int var2, int var3, byte[] var4, int var5, int var6, int var7, int var8, int var9, int var10, int var11);
|
||||
|
||||
boolean CP_Label_DrawLine(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7);
|
||||
|
||||
boolean CP_Label_DrawRect(Pointer var1, int var2, int var3, int var4, int var5, int var6);
|
||||
|
||||
boolean CP_Label_DrawBox(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7);
|
||||
|
||||
int CP_Proto_QueryBatteryLevel(Pointer var1, int var2);
|
||||
|
||||
public static class CP_Label_DrawImageFromData_Helper {
|
||||
public CP_Label_DrawImageFromData_Helper() {
|
||||
}
|
||||
|
||||
public static boolean DrawImageFromBufferedImage(Pointer handle, int x, int y, int dstw, int dsth, BufferedImage image, int binaryzation_method, int compression_method) {
|
||||
boolean result = false;
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
ImageIO.write(image, "png", os);
|
||||
byte[] data = os.toByteArray();
|
||||
result = AutoReplyPrint.INSTANCE.CP_Label_DrawImageFromData(handle, x, y, dstw, dsth, data, data.length, binaryzation_method, compression_method);
|
||||
} catch (Throwable var11) {
|
||||
var11.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CP_Label_TextStyle {
|
||||
private int style = 0;
|
||||
|
||||
public CP_Label_TextStyle(boolean bold, boolean underline, boolean highlight, boolean strikethrough, int rotation, int widthscale, int heightscale) {
|
||||
int style = 0;
|
||||
if (bold) {
|
||||
style |= 1;
|
||||
}
|
||||
|
||||
if (underline) {
|
||||
style |= 2;
|
||||
}
|
||||
|
||||
if (highlight) {
|
||||
style |= 4;
|
||||
}
|
||||
|
||||
if (strikethrough) {
|
||||
style |= 8;
|
||||
}
|
||||
|
||||
style |= rotation << 4;
|
||||
style |= widthscale << 8;
|
||||
style |= heightscale << 12;
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public int getStyle() {
|
||||
return this.style;
|
||||
}
|
||||
}
|
||||
|
||||
public interface CP_OnBluetoothDeviceDiscovered_Callback extends Callback {
|
||||
void CP_OnBluetoothDeviceDiscovered(String var1, String var2, Pointer var3);
|
||||
}
|
||||
|
||||
public interface CP_OnNetPrinterDiscovered_Callback extends Callback {
|
||||
void CP_OnNetPrinterDiscovered(String var1, String var2, String var3, String var4, Pointer var5);
|
||||
}
|
||||
|
||||
public interface CP_OnPortClosedEvent_Callback extends Callback {
|
||||
void CP_OnPortClosedEvent(Pointer var1, Pointer var2);
|
||||
}
|
||||
|
||||
public interface CP_OnPortOpenFailedEvent_Callback extends Callback {
|
||||
void CP_OnPortOpenFailedEvent(Pointer var1, String var2, Pointer var3);
|
||||
}
|
||||
|
||||
public interface CP_OnPortOpenedEvent_Callback extends Callback {
|
||||
void CP_OnPortOpenedEvent(Pointer var1, String var2, Pointer var3);
|
||||
}
|
||||
|
||||
public interface CP_OnPortReceivedEvent_Callback extends Callback {
|
||||
void CP_OnPortReceivedEvent(Pointer var1, Pointer var2, int var3, Pointer var4);
|
||||
}
|
||||
|
||||
public interface CP_OnPortWrittenEvent_Callback extends Callback {
|
||||
void CP_OnPortWrittenEvent(Pointer var1, Pointer var2, int var3, Pointer var4);
|
||||
}
|
||||
|
||||
public interface CP_OnPrinterPrintedEvent_Callback extends Callback {
|
||||
void CP_OnPrinterPrintedEvent(Pointer var1, int var2, Pointer var3);
|
||||
}
|
||||
|
||||
public interface CP_OnPrinterReceivedEvent_Callback extends Callback {
|
||||
void CP_OnPrinterReceivedEvent(Pointer var1, int var2, Pointer var3);
|
||||
}
|
||||
|
||||
public interface CP_OnPrinterStatusEvent_Callback extends Callback {
|
||||
void CP_OnPrinterStatusEvent(Pointer var1, long var2, long var4, Pointer var6);
|
||||
}
|
||||
|
||||
public static class CP_Page_DrawRasterImageFromData_Helper {
|
||||
public CP_Page_DrawRasterImageFromData_Helper() {
|
||||
}
|
||||
|
||||
public static boolean DrawRasterImageFromBufferedImage(Pointer handle, int x, int y, int dstw, int dsth, BufferedImage image, int binaryzation_method) {
|
||||
boolean result = false;
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
ImageIO.write(image, "png", os);
|
||||
byte[] data = os.toByteArray();
|
||||
result = AutoReplyPrint.INSTANCE.CP_Page_DrawRasterImageFromData(handle, x, y, dstw, dsth, data, data.length, binaryzation_method);
|
||||
} catch (Throwable var10) {
|
||||
var10.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CP_Port_EnumCom_Helper {
|
||||
public CP_Port_EnumCom_Helper() {
|
||||
}
|
||||
|
||||
public static String[] EnumCom() {
|
||||
IntByReference pcbNeeded = new IntByReference();
|
||||
AutoReplyPrint.INSTANCE.CP_Port_EnumCom((byte[]) null, 0, pcbNeeded);
|
||||
if (pcbNeeded.getValue() > 0) {
|
||||
byte[] pBuf = new byte[pcbNeeded.getValue()];
|
||||
if (pBuf != null) {
|
||||
AutoReplyPrint.INSTANCE.CP_Port_EnumCom(pBuf, pBuf.length, (IntByReference) null);
|
||||
String s = new String(pBuf);
|
||||
String[] ss = s.split("\u0000");
|
||||
return ss;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CP_Port_EnumLpt_Helper {
|
||||
public CP_Port_EnumLpt_Helper() {
|
||||
}
|
||||
|
||||
public static String[] EnumLpt() {
|
||||
IntByReference pcbNeeded = new IntByReference();
|
||||
AutoReplyPrint.INSTANCE.CP_Port_EnumLpt((byte[]) null, 0, pcbNeeded);
|
||||
if (pcbNeeded.getValue() > 0) {
|
||||
byte[] pBuf = new byte[pcbNeeded.getValue()];
|
||||
if (pBuf != null) {
|
||||
AutoReplyPrint.INSTANCE.CP_Port_EnumLpt(pBuf, pBuf.length, (IntByReference) null);
|
||||
String s = new String(pBuf);
|
||||
String[] ss = s.split("\u0000");
|
||||
return ss;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CP_Port_EnumUsb_Helper {
|
||||
public CP_Port_EnumUsb_Helper() {
|
||||
}
|
||||
|
||||
public static String[] EnumUsb() {
|
||||
IntByReference pcbNeeded = new IntByReference();
|
||||
AutoReplyPrint.INSTANCE.CP_Port_EnumUsb((byte[]) null, 0, pcbNeeded);
|
||||
if (pcbNeeded.getValue() > 0) {
|
||||
byte[] pBuf = new byte[pcbNeeded.getValue()];
|
||||
if (pBuf != null) {
|
||||
AutoReplyPrint.INSTANCE.CP_Port_EnumUsb(pBuf, pBuf.length, (IntByReference) null);
|
||||
String s = new String(pBuf);
|
||||
String[] ss = s.split("\u0000");
|
||||
return ss;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CP_Pos_PrintRasterImageFromData_Helper {
|
||||
public CP_Pos_PrintRasterImageFromData_Helper() {
|
||||
}
|
||||
|
||||
public static boolean PrintRasterImageFromBufferedImage(Pointer handle, int dstw, int dsth, BufferedImage image, int binaryzation_method, int compression_method) {
|
||||
boolean result = false;
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
ImageIO.write(image, "png", os);
|
||||
byte[] data = os.toByteArray();
|
||||
result = AutoReplyPrint.INSTANCE.CP_Pos_PrintRasterImageFromData(handle, dstw, dsth, data, data.length, binaryzation_method, compression_method);
|
||||
} catch (Throwable var9) {
|
||||
var9.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CP_PrinterStatus {
|
||||
private long error_status = 0L;
|
||||
private long info_status = 0L;
|
||||
|
||||
public CP_PrinterStatus(long error_status, long info_status) {
|
||||
this.error_status = error_status;
|
||||
this.info_status = info_status;
|
||||
}
|
||||
|
||||
public long errorStatus() {
|
||||
return this.error_status;
|
||||
}
|
||||
|
||||
public long infoStatus() {
|
||||
return this.info_status;
|
||||
}
|
||||
|
||||
public boolean ERROR_OCCURED() {
|
||||
return this.error_status != 0L;
|
||||
}
|
||||
|
||||
public boolean ERROR_CUTTER() {
|
||||
return (this.error_status & 1L) != 0L;
|
||||
}
|
||||
|
||||
public boolean ERROR_FLASH() {
|
||||
return (this.error_status & 2L) != 0L;
|
||||
}
|
||||
|
||||
public boolean ERROR_NOPAPER() {
|
||||
return (this.error_status & 4L) != 0L;
|
||||
}
|
||||
|
||||
public boolean ERROR_VOLTAGE() {
|
||||
return (this.error_status & 8L) != 0L;
|
||||
}
|
||||
|
||||
public boolean ERROR_MARKER() {
|
||||
return (this.error_status & 16L) != 0L;
|
||||
}
|
||||
|
||||
public boolean ERROR_ENGINE() {
|
||||
return (this.error_status & 32L) != 0L;
|
||||
}
|
||||
|
||||
public boolean ERROR_OVERHEAT() {
|
||||
return (this.error_status & 64L) != 0L;
|
||||
}
|
||||
|
||||
public boolean ERROR_COVERUP() {
|
||||
return (this.error_status & 128L) != 0L;
|
||||
}
|
||||
|
||||
public boolean ERROR_MOTOR() {
|
||||
return (this.error_status & 256L) != 0L;
|
||||
}
|
||||
|
||||
public boolean INFO_LABELPAPER() {
|
||||
return (this.info_status & 2L) != 0L;
|
||||
}
|
||||
|
||||
public boolean INFO_LABELMODE() {
|
||||
return (this.info_status & 4L) != 0L;
|
||||
}
|
||||
|
||||
public boolean INFO_HAVEDATA() {
|
||||
return (this.info_status & 8L) != 0L;
|
||||
}
|
||||
|
||||
public boolean INFO_NOPAPERCANCELED() {
|
||||
return (this.info_status & 16L) != 0L;
|
||||
}
|
||||
|
||||
public boolean INFO_PAPERNOFETCH() {
|
||||
return (this.info_status & 32L) != 0L;
|
||||
}
|
||||
|
||||
public boolean INFO_PRINTIDLE() {
|
||||
return (this.info_status & 64L) != 0L;
|
||||
}
|
||||
|
||||
public boolean INFO_RECVIDLE() {
|
||||
return (this.info_status & 128L) != 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CP_Printer_GetPrinterFirmwareVersion_Helper {
|
||||
public CP_Printer_GetPrinterFirmwareVersion_Helper() {
|
||||
}
|
||||
|
||||
public static String GetPrinterFirmwareVersion(Pointer handle) {
|
||||
IntByReference pcbNeeded = new IntByReference();
|
||||
AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterFirmwareVersion(handle, (byte[]) null, 0, pcbNeeded);
|
||||
if (pcbNeeded.getValue() > 0) {
|
||||
byte[] pBuf = new byte[pcbNeeded.getValue()];
|
||||
if (pBuf != null) {
|
||||
AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterFirmwareVersion(handle, pBuf, pBuf.length, (IntByReference) null);
|
||||
String s = new String(pBuf);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CP_RTSTATUS_Helper {
|
||||
public CP_RTSTATUS_Helper() {
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_DRAWER_OPENED(long status) {
|
||||
return (status >> 0 & 4L) == 0L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_OFFLINE(long status) {
|
||||
return (status >> 0 & 8L) == 8L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_COVERUP(long status) {
|
||||
return (status >> 8 & 4L) == 4L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_FEED_PRESSED(long status) {
|
||||
return (status >> 8 & 8L) == 8L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_NOPAPER(long status) {
|
||||
return (status >> 8 & 32L) == 32L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_ERROR_OCCURED(long status) {
|
||||
return (status >> 8 & 64L) == 64L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_CUTTER_ERROR(long status) {
|
||||
return (status >> 16 & 8L) == 8L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_UNRECOVERABLE_ERROR(long status) {
|
||||
return (status >> 16 & 32L) == 32L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_DEGREE_OR_VOLTAGE_OVERRANGE(long status) {
|
||||
return (status >> 16 & 64L) == 64L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_PAPER_NEAREND(long status) {
|
||||
return (status >> 24 & 12L) == 12L;
|
||||
}
|
||||
|
||||
public static boolean CP_RTSTATUS_PAPER_TAKEOUT(long status) {
|
||||
return (status >> 24 & 4L) == 4L;
|
||||
}
|
||||
}
|
||||
|
||||
public static class GetLibraryPath_Helper {
|
||||
public GetLibraryPath_Helper() {
|
||||
}
|
||||
|
||||
private static String GetLibraryPath() {
|
||||
if (Platform.isWindows()) {
|
||||
return Platform.is64Bit() ? "/autoreplyprint/win64/autoreplyprint.dll" : "/autoreplyprint/win32/autoreplyprint.dll";
|
||||
} else if (Platform.isLinux()) {
|
||||
return Platform.is64Bit() ? "/autoreplyprint/linux-x64/libautoreplyprint.so" : "/autoreplyprint/linux-x86/libautoreplyprint.so";
|
||||
} else {
|
||||
return Platform.isMac() ? "/autoreplyprint/mac/libautoreplyprint.so" : "autoreplyprint";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.dpkj.modules.autoReplyPrint.utils;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Platform;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class AutoReplyPrint2 {
|
||||
|
||||
|
||||
public static AutoReplyPrint2Sdk getAutoReplyPrint2SDK() throws AutoReplyPrint2RegistrationException {
|
||||
try {
|
||||
return Native.load(GetLibraryPath_Helper.GetLibraryPath(), AutoReplyPrint2Sdk.class);
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
log.info("[AutoReplyPrint2][AutoReplyPrint2.getAutoReplyPrint2SDK] SDK注册失败 {}", e.getMessage());
|
||||
throw new AutoReplyPrint2RegistrationException("Failed to load AutoReplyPrint2Sdk library: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 定义接口映射本地库中的函数。
|
||||
*/
|
||||
public interface AutoReplyPrint2Sdk extends Library {
|
||||
/**
|
||||
* 获取打印机固件版本
|
||||
* @return
|
||||
*/
|
||||
String CPPrinterGetPrinterFirmwareVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义自定义异常类,用于表示注册控件时发生的错误
|
||||
*/
|
||||
public static class AutoReplyPrint2RegistrationException extends Exception {
|
||||
public AutoReplyPrint2RegistrationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public AutoReplyPrint2RegistrationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
public static class GetLibraryPath_Helper {
|
||||
public GetLibraryPath_Helper() {
|
||||
}
|
||||
|
||||
private static String GetLibraryPath() {
|
||||
if (Platform.isWindows()) {
|
||||
return Platform.is64Bit() ? "/autoreplyprint/win64/autoreplyprint.dll" : "/autoreplyprint/win32/autoreplyprint.dll";
|
||||
} else if (Platform.isLinux()) {
|
||||
return Platform.is64Bit() ? "/autoreplyprint/linux-x64/libautoreplyprint.so" : "/autoreplyprint/linux-x86/libautoreplyprint.so";
|
||||
} else {
|
||||
return Platform.isMac() ? "/autoreplyprint/mac/libautoreplyprint.so" : "autoreplyprint";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.dpkj.modules.autoReplyPrint.utils;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
public interface MyLibrary extends StdCallLibrary {
|
||||
MyLibrary INSTANCE = (MyLibrary) Native.load("D:\\DPKJ\\yinyitong-zhongyuyuan-dll\\src\\main\\resources\\autoreplyprint\\win64\\autoreplyprint.dll", MyLibrary.class);
|
||||
|
||||
// 映射DLL中的函数
|
||||
String CP_Printer_GetPrinterFirmwareVersion();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.dpkj.modules.autoReplyPrint.utils;
|
||||
|
||||
public class MyNativeClass {
|
||||
public static native void ICC_Reader_Open(String devName);
|
||||
|
||||
static {
|
||||
System.load("D:\\DPKJ\\yinyitong-zhongyuyuan-dll\\src\\main\\resources\\win32-x86\\UnPack.dll");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ICC_Reader_Open("USB1");
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
package com.dpkj.modules.autoReplyPrint.utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class TestUtils {
|
||||
public static byte[] ReadFromFile(String fileName) {
|
||||
byte[] data = null;
|
||||
try {
|
||||
InputStream in = new FileInputStream(fileName);
|
||||
data = new byte[in.available()];
|
||||
in.read(data);
|
||||
in.close();
|
||||
} catch (Throwable tr) {
|
||||
tr.printStackTrace();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static void showMessageOnUiThread(final String msg) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JOptionPane.showMessageDialog(null, msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.dpkj.modules.cardReader.constant;
|
||||
|
||||
public interface StatusConstant {
|
||||
// 执行成功
|
||||
String IFD_OK = "0";
|
||||
|
||||
// 卡片类型不对
|
||||
String IFD_ICC_TypeError = "-1";
|
||||
|
||||
// 无卡
|
||||
String IFD_ICC_NoExist = "-2";
|
||||
|
||||
// 有卡未上电
|
||||
String IFD_ICC_NoPower = "-3";
|
||||
|
||||
// 卡片无应答
|
||||
String IFD_ICC_NoResponse = "-4";
|
||||
|
||||
// 卡片状态异常
|
||||
String IFD_ICC_StatusErr = "-5";
|
||||
|
||||
// 读写器执行指令失败
|
||||
String IFD_ICC_ExecuteErr = "-6";
|
||||
|
||||
// 读卡器连接错
|
||||
String IFD_ConnectError = "-11";
|
||||
|
||||
// 未建立连接(没有执行打开设备函数)
|
||||
String IFD_UnConnected = "-12";
|
||||
|
||||
// (动态库)不支持该命令
|
||||
String IFD_BadCommand = "-13";
|
||||
|
||||
// (发给动态库的)命令参数出错
|
||||
String IFD_ParameterError = "-14";
|
||||
|
||||
// 信息校验和出错
|
||||
String IFD_CheckSumError = "-15";
|
||||
|
||||
// 超时
|
||||
String IFD_TimeOut = "-16";
|
||||
|
||||
// 读取固件信息错误
|
||||
String IFD_ReadErr = "-17";
|
||||
|
||||
// 底层返回数据长度错误
|
||||
String IFD_DeviceDataLen = "-18";
|
||||
|
||||
// 卡片数据异常错误
|
||||
String IFD_CardDataErr = "-19";
|
||||
|
||||
// 标志位不支持
|
||||
String IFD_TAGNoExist = "-20";
|
||||
|
||||
// 读取文件异常
|
||||
String IFD_FileDataErr = "-21";
|
||||
|
||||
// 设备返回数据异常
|
||||
String IFD_DeviceDataErr = "-22";
|
||||
|
||||
// 加载动态库失败
|
||||
String IFD_LoadDllError = "-23";
|
||||
|
||||
// 用户取消操作
|
||||
String IFD_UserCancel = "-24";
|
||||
|
||||
// 密码长度错误
|
||||
String IFD_KeyLengthErr = "-25";
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.dpkj.modules.cardReader.controller;
|
||||
|
||||
import com.dpkj.common.vo.Result;
|
||||
import com.dpkj.modules.cardReader.service.CardReaderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 多合一读卡器
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("cardReader")
|
||||
public class CardReaderController {
|
||||
@Autowired
|
||||
private CardReaderService cardReaderService;
|
||||
|
||||
/**
|
||||
* 连接设备
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("connectedDevice")
|
||||
public Result<?> connectedDevice(@RequestParam(name = "devName") String devName) {
|
||||
try {
|
||||
return cardReaderService.connectedDevice(devName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info("设备连接失败 {}", e.getMessage());
|
||||
return Result.error("设备连接失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.dpkj.modules.cardReader.service;
|
||||
|
||||
|
||||
import com.dpkj.common.vo.Result;
|
||||
|
||||
public interface CardReaderService {
|
||||
|
||||
Result<?> connectedDevice(String devName);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.dpkj.modules.cardReader.service.impl;
|
||||
|
||||
import com.dpkj.common.vo.Result;
|
||||
import com.dpkj.modules.cardReader.service.CardReaderService;
|
||||
import com.dpkj.modules.cardReader.utils.CardReaderUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CardReaderServiceImpl implements CardReaderService {
|
||||
|
||||
private CardReaderUtil.CardReaderSdk cardReaderSdk = CardReaderUtil.getCardReaderSDK();
|
||||
|
||||
public CardReaderServiceImpl() throws CardReaderUtil.CardReaderRegistrationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> connectedDevice(String devName) {
|
||||
Long aLong = cardReaderSdk.ICC_Reader_Open(devName);
|
||||
log.info("连接状态{}", aLong);
|
||||
return Result.ok(aLong);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
package com.dpkj.modules.cardReader.utils;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class CardReaderUtil {
|
||||
|
||||
/**
|
||||
* 获取 多合一读卡器 实例,同时注册 CardReaderSdk 控件。
|
||||
*
|
||||
* @return CardReaderSdk 实例
|
||||
* @throws CardReaderRegistrationException 如果注册控件失败,抛出此异常
|
||||
*/
|
||||
public static CardReaderSdk getCardReaderSDK() throws CardReaderRegistrationException {
|
||||
try {
|
||||
return Native.load("UnPack", CardReaderSdk.class);
|
||||
//return Native.load("SSSE32", CardReaderSdk.class);
|
||||
//return Native.load("autoreplyprint", CardReaderSdk.class);
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
log.info("[CardReader][AutoReplyPrint2.getCardReaderSDK] SDK注册失败 {}", e.getMessage());
|
||||
throw new CardReaderRegistrationException("Failed to load CardReaderSdk library: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void convertAndPassStringAsJCharArray(String filePath) {
|
||||
// 将字符串转换为char[]
|
||||
char[] chars = filePath.toCharArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义接口映射本地库中的函数。
|
||||
*/
|
||||
public interface CardReaderSdk extends Library {
|
||||
/**
|
||||
* 连接指定设备与电脑端口,即打开端口
|
||||
* @param devName 接口名称,如”USB1”
|
||||
* @return >0成功,<=0失败
|
||||
*/
|
||||
Long ICC_Reader_Open(String devName);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 关闭已打开的电脑接口
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_Close(Long ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
* 读写器产生蜂鸣
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param time 蜂鸣时间,以毫秒为单位
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
Long ICC_PosBeep(Long ReaderHandle, Long time);
|
||||
|
||||
|
||||
/**
|
||||
* 获取动态库及设备版本信息
|
||||
* @return 设备及动态库版本信息 =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_Libinfo();
|
||||
|
||||
|
||||
/**
|
||||
* 从EEPROM读取数据
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param offset 偏移地址(起始地址)
|
||||
* @param length 要读取的数据的长度
|
||||
* @return 读取的数据 =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_ReadEEPROM(Long ReaderHandle, int offset, int length);
|
||||
|
||||
|
||||
/**
|
||||
* 往EEPROM写入数据
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param offset 偏移地址(起始地址)
|
||||
* @param length 要写入的数据的长度
|
||||
* @param buffer 待写入的数据
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_WriteEEPROM(Long ReaderHandle, int offset, int length, String buffer);
|
||||
|
||||
|
||||
/**
|
||||
* 播放语音(SSSE32.dll暴露函数中未发现该函数,但是文档中有)
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param voiceType 语音类型:
|
||||
* 1、请插卡
|
||||
* 2、请刷卡
|
||||
* 3、读卡错误
|
||||
* 4、请输入密码
|
||||
* 5、密码错误
|
||||
* 6、操作成功
|
||||
* 7、操作超时
|
||||
* 8、操作失败
|
||||
* 9、请取回卡
|
||||
* 10、请重新输入密码
|
||||
* 11、请再次输入密码
|
||||
* 12、请输入新密码
|
||||
* 13、请输入旧密码
|
||||
* 14、请确认新密码
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
@Deprecated
|
||||
Long ICC_Reader_DispSound(Long ReaderHandle, String voiceType);
|
||||
|
||||
|
||||
/**
|
||||
* 接触 CPU 卡上电复位,返回值数据格式为十六进制字符串
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param ICCSlotNo ICC插槽号 0x01 :大卡座 ;
|
||||
* 0x02 :副卡座 ;
|
||||
* 0x11:SAM1卡座;
|
||||
* 0x12:SAM2卡座;
|
||||
* 0x13:SAM3卡座;
|
||||
* 0x14:SAM4卡座
|
||||
* 0x3x:非接CPU卡
|
||||
* @return 上电返回ATR值,数据格式为十六进制字符串
|
||||
*/
|
||||
Long ICC_Reader_PowerOnHEX(Long ReaderHandle, String ICCSlotNo);
|
||||
|
||||
|
||||
/**
|
||||
* CPU 卡下电
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param ICCSlotNo ICC插槽号 0x01 :大卡座 ;
|
||||
* 0x02 :副卡座 ;
|
||||
* 0x11:SAM1卡座;
|
||||
* 0x12:SAM2卡座;
|
||||
* 0x13:SAM3卡座;
|
||||
* 0x14:SAM4卡座
|
||||
* 0x3x:非接CPU卡
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_PowerOff(Long ReaderHandle, String ICCSlotNo);
|
||||
|
||||
|
||||
/**
|
||||
* 获取卡座状态
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param ICCSlotNo ICC插槽号 0x01 :大卡座 ;
|
||||
* 0x02 :副卡座 ;
|
||||
* 0x11:SAM1卡座;
|
||||
* 0x12:SAM2卡座;
|
||||
* 0x13:SAM3卡座;
|
||||
* 0x14:SAM4卡座
|
||||
* 0x3x:非接CPU卡
|
||||
* @return = 0 表示卡座有卡,其他见状态码
|
||||
*/
|
||||
Long ICC_Reader_GetStatus(Long ReaderHandle, String ICCSlotNo);
|
||||
|
||||
|
||||
/**
|
||||
* 接触 CPU 卡执行APDU命令
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param ICCSlotNo ICC插槽号 0x01 :大卡座 ;
|
||||
* 0x02 :副卡座 ;
|
||||
* 0x11:SAM1卡座;
|
||||
* 0x12:SAM2卡座;
|
||||
* 0x13:SAM3卡座;
|
||||
* 0x14:SAM4卡座
|
||||
* 0x3x:非接CPU卡
|
||||
* @param CommandAPDU APDU命令数据,以十六进制字符串形式输入
|
||||
* @return 大于 0 表示执行成功,其值为 Response_APDU 的数据长度.否则表示执行失败
|
||||
*/
|
||||
Long ICC_Reader_ApplicationHEX(Long ReaderHandle, String ICCSlotNo, String CommandAPDU);
|
||||
|
||||
|
||||
/**
|
||||
* 4442卡片上电,数据以十六进制字符串输出
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return 返回卡片上电信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4428_PowerOnHEX(Long ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
* 4442卡片下电
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4442_PowerOff(Long ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
* 读取4442卡的指定字段内容,以十六进制字符串输出
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param offset 起始地址,需小于256
|
||||
* @param len 数据长度,offset+len需小于256
|
||||
* @return 返回卡片读取信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4428_ReadHEX(Long ReaderHandle, int offset, int len);
|
||||
|
||||
|
||||
/**
|
||||
* 写 4442 卡的指定字段内容,以十六进制字符串输入参数
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param offset 起始地址,需小于256
|
||||
* @param len 数据长度,offset+len需小于256
|
||||
* @param data 待写入卡片数据
|
||||
* @return 返回卡片读取信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4428_WriteHEX(Long ReaderHandle, int offset, int len, String data);
|
||||
|
||||
|
||||
/**
|
||||
* 4442卡认证密钥
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param keyHex 卡密钥
|
||||
* @return = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4442_Verify(Long ReaderHandle, String keyHex);
|
||||
|
||||
/** ----- 非接触操作函数 -------------- */
|
||||
/**
|
||||
* 查找天线磁场区域内有无卡,只有卡片上电后才能查找到
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return = 0 表示成功,非0失败
|
||||
*/
|
||||
Long PICC_Reader_Request(Long ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
* 天线操作
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param flag 00-关场强 01-开场强
|
||||
* @return = 0 表示成功,非0失败
|
||||
*/
|
||||
Long PICC_Reader_RFControl(Long ReaderHandle, String flag);
|
||||
|
||||
|
||||
/** --------------- 非接 CPU 卡操作函数 ------------ */
|
||||
/**
|
||||
* 非接TypeA CPU卡上电复位,输出十六进制字符串(SSSE32.dll暴露函数中未发现该函数,但是文档中有)
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return 输出上电成功返回的卡片复位信息(ATS) 返回ATS长度,大于0 表示成功,其他失败
|
||||
*/
|
||||
@Deprecated
|
||||
Long PICC_Reader_PowerOnTypeAHEX(Long ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
* 非接TypeB CPU卡上电复位,输出十六进制字符串(SSSE32.dll暴露函数中未发现该函数,但是文档中有)
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return 输出上电成功返回的卡片复位信息(ATS) 返回ATS长度,大于0 表示成功,其他失败
|
||||
*/
|
||||
@Deprecated
|
||||
Long PICC_Reader_PowerOnTypeBHEX(Long ReaderHandle);
|
||||
|
||||
/**
|
||||
* 非接触 CPU 卡执行APDU命令,命令以十六进制字符串传输(SSSE32.dll暴露函数中未发现该函数,但是文档中有)
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @param CommandAPDU APDU命令数据,以十六进制字符串形式输入
|
||||
* @return APDU命令执行后,响应的数据,返回数据为十六进制字符串
|
||||
* 大于 0 表示执行成功,其值为 Response_APDU 的数据长度.否则表示执行失败
|
||||
*/
|
||||
@Deprecated
|
||||
Long PICC_Reader_ApplicationHEX(Long ReaderHandle, String CommandAPDU);
|
||||
|
||||
|
||||
/** ---------------- 二代证/外国人居留证/港澳台居住证 --------------- */
|
||||
/**
|
||||
* 读取身份证物理ID号
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return 返回身份证物理ID信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long PICC_Reader_Read_CardID(Long ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
* 读取身份证物理ID号
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return 返回错误信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long PICC_Reader_ReadIDCard(Long ReaderHandle);
|
||||
|
||||
/** 以下函数须在 “PICCReaderReadIDCard” 函数执行成功之后调用,否则获取不到有效信息 */
|
||||
/**
|
||||
* 获取证件类型
|
||||
* @return
|
||||
* 0:居民身份证
|
||||
* 1:外国人永久居留证
|
||||
* 2:港澳台居民居住证
|
||||
* 4:新外国人永久居留证
|
||||
*/
|
||||
Integer GetCardType();
|
||||
|
||||
/**
|
||||
* 姓名(类型为 1 时表示:外国人中文姓名)
|
||||
*/
|
||||
Integer GetName();
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
Integer GetSex();
|
||||
/**
|
||||
* 民族
|
||||
*/
|
||||
Integer GetNation();
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
Integer GetBirth();
|
||||
/**
|
||||
* 住址
|
||||
*/
|
||||
Integer GetAddress();
|
||||
/**
|
||||
* 公民身份证号码(类型为 1时表示:外国人居留证号码)
|
||||
*/
|
||||
Integer GetCertNo();
|
||||
/**
|
||||
* 签发机关
|
||||
*/
|
||||
Integer GetDepartemt();
|
||||
/**
|
||||
* 有效起始日期
|
||||
*/
|
||||
Integer GetEffectDate();
|
||||
/**
|
||||
* 有效截止日期
|
||||
*/
|
||||
Integer GetExpireDate();
|
||||
/**
|
||||
* bmp 格式照片数据
|
||||
*/
|
||||
Integer GetBmpFileData();
|
||||
/**
|
||||
* 生成照片
|
||||
* TODO 入参参考文中3.4.1
|
||||
*/
|
||||
Integer GetBmpFile();
|
||||
/**
|
||||
* 是否含存在指纹信息:存在时返回 512 或者 1024
|
||||
* 不存在时返回 0
|
||||
*/
|
||||
Integer IsFingerExist();
|
||||
/**
|
||||
* 获取指纹数据:成功时返回获取到的字节长度
|
||||
*/
|
||||
Integer GetFingerprint();
|
||||
/**
|
||||
* 外国人英文姓名
|
||||
*/
|
||||
Integer GetEnName();
|
||||
/**
|
||||
* 外国人国籍代码,符合GB/T2659-2000规定
|
||||
*/
|
||||
Integer GetNationalityCode();
|
||||
/**
|
||||
* 港澳台通行证号码
|
||||
*/
|
||||
Integer GetTXZHM();
|
||||
/**
|
||||
* 港澳台通行证签发次数
|
||||
*/
|
||||
Integer GetTXZQFCS();
|
||||
/**
|
||||
* 外国人换证次数
|
||||
*/
|
||||
Integer GetHZCS();
|
||||
|
||||
/** ------------ 社保卡 ---------*/
|
||||
/**
|
||||
* 选择社保卡社会保障系统环境后,通过 PSAM 卡对社保卡进行内部认证,通过后将卡内的基本信息读出返回。
|
||||
* @param iType 操作卡的类型
|
||||
* 1-接触式操作卡;
|
||||
* 2-非接触式操作卡;
|
||||
* 3-自动寻卡,接触式操作卡优先;
|
||||
* 4-自动寻卡,非接触式操作卡优先
|
||||
* @return
|
||||
*/
|
||||
Long iReadCardBas(Integer iType);
|
||||
|
||||
/**
|
||||
* 基于加密机的读基本信息(步骤一)
|
||||
* 选择社会保障系统环境后,返回内部认证和外部认证所需信息。
|
||||
* @param iType 操作卡的类型
|
||||
* 1-接触式操作卡;
|
||||
* 2-非接触式操作卡;
|
||||
* 3-自动寻卡,接触式操作卡优先;
|
||||
* 4-自动寻卡,非接触式操作卡优先
|
||||
* @return
|
||||
*/
|
||||
Long iReadCardBas_HSM_Step1(Integer iType);
|
||||
|
||||
/**
|
||||
* 基于加密机的读基本信息(步骤二)
|
||||
* 根据加密机返回的内部认证和外部认证结果数据对社保卡进行内部认证和外部认证,通过后将卡内的基本信息读出返回。
|
||||
* @param pKey 加密机返回的内部认证和外部认证结果数据,依次为:内部认证结果数据
|
||||
* (即内部认证鉴别数据(16 位)和内部认证鉴别所需的原始信息(16 位)拼接组
|
||||
* 成)、外部认证结果数据(即外部认证鉴别数据(16 位)和外部认证鉴别所需的
|
||||
* 原始信息(16 位)拼接组成)。各数据项之间以“|”分割,且最后一个数据项以“|”结尾。
|
||||
* @return
|
||||
*/
|
||||
Long iReadCardBas_HSM_Step2(String pKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义自定义异常类,用于表示注册控件时发生的错误
|
||||
*/
|
||||
public static class CardReaderRegistrationException extends Exception {
|
||||
public CardReaderRegistrationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CardReaderRegistrationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,104 @@ public class PrinterUtil {
|
||||
}*/
|
||||
|
||||
try {
|
||||
return Native.load("Msprintsdk.x64", MsPrintSdk.class);
|
||||
// return Native.load("Msprintsdk.x64", MsPrintSdk.class);
|
||||
|
||||
return new MsPrintSdk() {
|
||||
@Override
|
||||
public Integer SetPrintPort(String strPort, int baudRate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer SetPrintConn(int iConnWay, String strName, String strValue) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer SetUsbportauto() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer GetStatus() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer GetStatusspecial() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer SetInit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PrintQrcode(String s, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetLeftmargin(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer PrintString(String s, int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer PrintRemainQR() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer SetReadZKmode(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer PrintCutpaper(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetHTseat(String s, int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PrintNextHT() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer PrintDiskbmpfile(String strPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer PrintDiskimgfile(String strPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer PrintMarkpositionPrint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer PrintMarkpositioncut() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer PrintMarkcutpaper(int iMode) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
log.info("[printer][PrinterUtil.getPrintSDK] SDK注册失败 {}", e.getMessage());
|
||||
throw new PrinterRegistrationException("Failed to load MsPrintSdk library: ", e);
|
||||
|
||||
BIN
src/main/resources/win32-x86/SSSE32.dll
Normal file
BIN
src/main/resources/win32-x86/SSSE32.dll
Normal file
Binary file not shown.
BIN
src/main/resources/win32-x86/UnPack.dll
Normal file
BIN
src/main/resources/win32-x86/UnPack.dll
Normal file
Binary file not shown.
@@ -1,13 +0,0 @@
|
||||
package com.dpkj.ems;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class EmsExpressBridgeApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.dpkj.ems.utils;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.dpkj.Application;
|
||||
import com.dpkj.common.config.FileConfig;
|
||||
import com.dpkj.modules.express.service.PrinterService;
|
||||
import com.dpkj.modules.express.utils.FileUtils;
|
||||
import com.dpkj.modules.express.utils.PrinterUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class)
|
||||
class PrinterUtilTest {
|
||||
|
||||
@Autowired
|
||||
private PrinterService printerService;
|
||||
@Autowired
|
||||
private FileConfig fileConfig;
|
||||
|
||||
@Test
|
||||
void getPrintSDK() throws PrinterUtil.PrinterRegistrationException {
|
||||
PrinterUtil.MsPrintSdk sdk = PrinterUtil.getPrintSDK();
|
||||
int i = sdk.SetUsbportauto();
|
||||
Console.log(i);
|
||||
|
||||
int i1 = sdk.SetInit();
|
||||
Console.log(i1);
|
||||
|
||||
int i2 = sdk.GetStatusspecial();
|
||||
Console.log(i2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void t2() throws IOException {
|
||||
String base64Path = "G:\\Temp\\text\\base64.txt";
|
||||
String base64 = FileUtil.readString(FileUtil.file(base64Path), StandardCharsets.UTF_8);
|
||||
|
||||
String bpmPath = "G:\\Temp\\img";
|
||||
List<BufferedImage> bufferedImages = FileUtils.convertBase64PdfToBufferedImage(base64);
|
||||
FileUtils.saveBufferedImageToBmp(bufferedImages);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void t3() throws Exception {
|
||||
String base64Path = "G:\\Temp\\text\\base64.txt";
|
||||
String base64 = FileUtil.readString(FileUtil.file(base64Path), StandardCharsets.UTF_8);
|
||||
|
||||
// String bpmPath = "G:\\Temp\\img";
|
||||
String bpmPath = fileConfig.getPath();
|
||||
List<BufferedImage> bufferedImages = FileUtils.convertBase64PdfToBufferedImage(base64);
|
||||
List<File> files = FileUtils.saveBufferedImageToBmp(bufferedImages);
|
||||
|
||||
/*for (File file : files) {
|
||||
String filePath = file.getAbsolutePath();
|
||||
printerService.printBmpByPath(filePath);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Test
|
||||
void t4() throws IOException {
|
||||
String base64Path = "G:\\Temp\\text\\base64.txt";
|
||||
String base64 = FileUtil.readString(FileUtil.file(base64Path), StandardCharsets.UTF_8);
|
||||
|
||||
List<BufferedImage> bufferedImages = FileUtils.convertBase64PdfToBufferedImage(base64);
|
||||
System.out.println(bufferedImages);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.dpkj.ems.utils;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.dpkj.modules.express.utils.FileUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
class PrinterUtilTest2 {
|
||||
|
||||
@Test
|
||||
void t4() throws IOException {
|
||||
String base64Path = "G:\\Temp\\text\\base64.txt";
|
||||
String base64 = FileUtil.readString(FileUtil.file(base64Path), StandardCharsets.UTF_8);
|
||||
|
||||
List<BufferedImage> bufferedImages = FileUtils.convertBase64PdfToBufferedImage(base64);
|
||||
System.out.println(bufferedImages);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user