简体   繁体   English

是否可以通过简单的方式使用PHP POS与JavaPOS设备进行交互?

[英]Is it possible to interact with JavaPOS device using PHP POS in a simplistic manner?

We have a POS written in PHP which needs to interact with a POS printer. 我们有一个用PHP编写的POS,需要与POS打印机进行交互。 The printer support JavaPOS. 打印机支持JavaPOS。 The state of PHP POS is that it generates a bill and waits for a user to select a printer. PHP POS的状态是它生成帐单并等待用户选择打印机。

The issue now is, the JavaPOS printer doesn't show up. 现在的问题是,JavaPOS打印机没有出现。 I am able to interact with using test Java code which has the necessary drivers & jpos.xml. 我可以使用具有必要驱动程序&jpos.xml的测试Java代码进行交互。 I wish to 'install' this. 我希望“安装”此文件。

From my understanding for past four days going through JavaPOS manuals from different manufactures [EPSON, Starmicronics, Diebold Nixdorfag ], it is not possible. 根据我过去四天对不同制造商[EPSON,Starmicronics,Diebold Nixdorfag]的JavaPOS手册的了解,这是不可能的。 JavaPOS is meant for POS system written in Java [JavaFX to Spring]. JavaPOS用于用Java [Spring的JavaFX]编写的POS系统。

But I find it very odd to believe this. 但是我相信这一点很奇怪。 I believe this shouldn't be the case because if this true, it would make very hard for POS not written in Java or .Net to interact with plethora of POS devices and terminal out there. 我相信事实并非如此,因为如果这是真的,那么非Java或.Net编写的POS将很难与大量POS设备交互并在那里终端。

Hence, is it possible to interact with non Java & non .Net POS to send print command to JavaPOS device? 因此,是否可以与非Java和非.Net POS交互以将打印命令发送到JavaPOS设备?

Please note, simply installing the device and sending a print command doesn't fix the issue. 请注意,仅安装设备并发送打印命令并不能解决问题。 Say, if I want to add a logo to the receipt along with dynamic data in the footer of the receipt, Java code will be required for .Net to make it 'rich'. 假设,如果我想在收据中添加徽标以及动态数据,请在收据的页脚中添加.Net以使其变得“丰富”。 Now, where does this Java code specifically sit? 现在,此Java代码专门放在哪里? Is it some virtual device which runs in the background and pretends to be a printer and shows up in the print dialog in a, say PHP POS? 它是某个虚拟设备,它在后台运行并假装成打印机,并在PHP POS这样的打印对话框中显示吗?

Sample Java code written to interact with JavaPOS with jpos.xml file as reference. 编写了与jpos.xml文件作为与JavaPOS交互的示例Java代码。

public static void main(String[] args) {
    File f = new File(PrintFTest.class.getClassLoader().getResource("jpos.xml").getPath());

    System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, f.getAbsolutePath());
    //System.getProperties().list(System.out);
    FiscalPrinter fiscalPrinter = new FiscalPrinter();

    // Get Access to it
    try {
        fiscalPrinter.open("printf");
        fiscalPrinter.claim(1000);
        fiscalPrinter.setDeviceEnabled(true);
    } catch (JposException e) {
        System.out.println("Exception at Access");
        e.printStackTrace();
    }

    // Print 
    try {
        fiscalPrinter.resetPrinter();
        fiscalPrinter.beginFiscalReceipt(true);
        fiscalPrinter.printRecItem("Salame", 40000, 0, 0, 0, "");
        fiscalPrinter.printRecTotal(40000, 40000, "CONTANTI");
        fiscalPrinter.endFiscalReceipt(false);
    } catch (JposException e) {
        System.out.println("Exception at Print");
    }

    try {
        System.out.println("1FP - Fiscal Printer disabling");
        fiscalPrinter.setDeviceEnabled(false);
        System.out.println("2FP - Fiscal Printer releasing");
        fiscalPrinter.release();
        System.out.println("2FP - Fiscal Printer closing");
        fiscalPrinter.close();
    } catch (JposException e) {
        System.out.println("Exception at Close");
    }

}

} }

It should contain the installation/setup/configuration method in the JavaPOS provided by each printer vendor and its user's manual. 它应包含每个打印机供应商提供的JavaPOS中的安装/设置/配置方法及其用户手册。

Please install and configure equipment and software accordingly. 请相应地安装和配置设备和软件。

However, in general, JavaPOS printers are rarely recognized as standard printer devices for their respective operating systems. 但是,通常,JavaPOS打印机很少被视为各自操作系统的标准打印机设备。

For example, there is such an article. 例如,有这样的文章。
Getting started with Java POS development Java POS开发入门
JavaPOS Working Group JavaPOS工作组

Next, it is recommended that you use these programs to operate and verify the printer only in the Java environment. 接下来,建议您仅在Java环境中使用这些程序来操作和验证打印机。
emigonza/POStest emigonza / POStest
ntsggr/JavaPOS-POStest-2 ntsggr / JavaPOS的-POStest -2-

There are several ways to use Java from PHP as follows. 有以下几种从PHP使用Java的方法。
PHP/Java Integration PHP / Java集成
Using PHP-Java Bridges with WebLogic Server 将PHP-Java桥与WebLogic Server一起使用
What is the PHP/Java Bridge? 什么是PHP / Java桥?
How it works 这个怎么运作
Java Bridge Java桥
How to call custom java methods from PHP? 如何从PHP调用自定义Java方法?

There is no problem if it can be solved by the above method, but I recommend the following method. 如果可以通过上述方法解决,则没有问题,但是我建议使用以下方法。

  • Combine the Java program and JavaPOS to create a program that runs standalone. 组合Java程序和JavaPOS以创建独立运行的程序。
  • The program provides functions similar to POS processing units such as "receipt printing". 该程序提供类似于POS处理单元的功能,例如“收据打印”。
  • This program communicates with PHP's POS in a simple and light way such as a bare TCP/IP socket, so that request issuance, completion notification or completion confirmation can be performed asynchronously. 该程序以简单明了的方式与PHP的POS通信,例如裸露的TCP / IP套接字,因此可以异步执行请求发布,完成通知或完成确认。

In Addition: 此外:

The following is an example of a POS application that is entirely made in Java. 以下是完全用Java制作的POS应用程序的示例。
Since these are open source, it seems to be a reference for programming. 由于这些都是开源的,因此似乎是编程的参考。
However, it is unknown whether JavaPOS control is used or not. 但是,未知是否使用JavaPOS控件。

Openbravo Java POS Openbravo Java POS
Floreant POS Floreant POS

The following is an example of an open source POS application written in PHP. 以下是用PHP编写的开源POS应用程序的示例。
Probably JavaPOS will not be used. 可能不会使用JavaPOS。

OpenSourcePOS OpenSourcePOS
WallacePOS WallacePOS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM