Merge branch 'main' into teya-integration
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.unicenta</groupId>
|
<groupId>com.unicenta</groupId>
|
||||||
<artifactId>unicentaopos</artifactId>
|
<artifactId>unicentaopos</artifactId>
|
||||||
<version>5.0.1</version>
|
<version>5.0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
@@ -67,12 +67,12 @@ public class PreparedSentence extends JDBCSentence {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param s
|
* @param session
|
||||||
* @param sentence
|
* @param sentence
|
||||||
* @param serwrite
|
* @param serwrite
|
||||||
*/
|
*/
|
||||||
public PreparedSentence(Session s, String sentence, SerializerWrite serwrite) {
|
public PreparedSentence(Session session, String sentence, SerializerWrite serwrite) {
|
||||||
this(s, sentence, serwrite, null);
|
this(session, sentence, serwrite, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ import com.unicenta.basic.BasicException;
|
|||||||
*/
|
*/
|
||||||
public abstract class SentenceExecTransaction implements SentenceExec {
|
public abstract class SentenceExecTransaction implements SentenceExec {
|
||||||
|
|
||||||
private Session m_s;
|
private Session session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param s
|
* @param session
|
||||||
*/
|
*/
|
||||||
public SentenceExecTransaction(Session s) {
|
public SentenceExecTransaction(Session session) {
|
||||||
m_s = s;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +66,7 @@ public abstract class SentenceExecTransaction implements SentenceExec {
|
|||||||
*/
|
*/
|
||||||
public final int exec(final Object params) throws BasicException {
|
public final int exec(final Object params) throws BasicException {
|
||||||
|
|
||||||
Transaction<Integer> t = new Transaction<Integer>(m_s) {
|
Transaction<Integer> t = new Transaction<Integer>(session) {
|
||||||
public Integer transact() throws BasicException{
|
public Integer transact() throws BasicException{
|
||||||
return execInTransaction(params);
|
return execInTransaction(params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,14 @@ public class JRootFrame extends javax.swing.JFrame implements AppMessage {
|
|||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JRootApp getRootapp() {
|
||||||
|
return m_rootapp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRootapp(JRootApp m_rootapp) {
|
||||||
|
this.m_rootapp = m_rootapp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param props
|
* @param props
|
||||||
*/
|
*/
|
||||||
@@ -98,6 +106,7 @@ public class JRootFrame extends javax.swing.JFrame implements AppMessage {
|
|||||||
new JFrmConfig(props).setVisible(true); // Show the configuration window.
|
new JFrmConfig(props).setVisible(true); // Show the configuration window.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setRootapp(m_rootapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ public class StartPOS {
|
|||||||
|
|
||||||
String hostname = config.getProperty("machine.hostname");
|
String hostname = config.getProperty("machine.hostname");
|
||||||
TicketInfo.setHostname(hostname);
|
TicketInfo.setHostname(hostname);
|
||||||
applicationStarted(hostname);
|
|
||||||
|
|
||||||
String screenmode = config.getProperty("machine.screenmode");
|
String screenmode = config.getProperty("machine.screenmode");
|
||||||
|
|
||||||
@@ -106,6 +105,8 @@ public class StartPOS {
|
|||||||
JRootKiosk rootkiosk = new JRootKiosk();
|
JRootKiosk rootkiosk = new JRootKiosk();
|
||||||
try {
|
try {
|
||||||
rootkiosk.initFrame(config);
|
rootkiosk.initFrame(config);
|
||||||
|
applicationStarted(hostname, rootkiosk.getRootapp());
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
log.error(ex.getMessage());
|
log.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
@@ -113,18 +114,25 @@ public class StartPOS {
|
|||||||
JRootFrame rootframe = new JRootFrame();
|
JRootFrame rootframe = new JRootFrame();
|
||||||
try {
|
try {
|
||||||
rootframe.initFrame(config);
|
rootframe.initFrame(config);
|
||||||
|
applicationStarted(hostname, rootframe.getRootapp());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error(ex.getMessage());
|
log.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private static void applicationStarted(String host) {
|
private static void applicationStarted(String host, JRootApp jRootApp) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
Metrics metrics = new Metrics();
|
try {
|
||||||
metrics.setDevice(host);
|
Metrics metrics = new Metrics();
|
||||||
metrics.setUniCentaVersion(AppLocal.APP_VERSION);
|
metrics.setDevice(host);
|
||||||
new Application().postMetrics(metrics);
|
metrics.setUniCentaVersion(AppLocal.APP_VERSION);
|
||||||
|
Application application = new Application();
|
||||||
|
application.postMetrics(metrics);
|
||||||
|
application.startEventListener(host, jRootApp);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Problem with starting the uniCenta plugin application:${}", e.getMessage());
|
||||||
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author JG uniCenta
|
* @author JG uniCenta
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -51,119 +50,157 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
*/
|
*/
|
||||||
protected int m_iBodyHeight;
|
protected int m_iBodyHeight;
|
||||||
|
|
||||||
/** Creates a new instance of AbstractTicket */
|
/**
|
||||||
public BasicTicket() {
|
* Creates a new instance of AbstractTicket
|
||||||
|
*/
|
||||||
|
public BasicTicket() {
|
||||||
// JG 16 May 12 use diamond inference
|
// JG 16 May 12 use diamond inference
|
||||||
m_aCommands = new ArrayList<>();
|
m_aCommands = new ArrayList<>();
|
||||||
pil = null;
|
pil = null;
|
||||||
m_iBodyHeight = 0;
|
m_iBodyHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract Font getBaseFont();
|
protected abstract Font getBaseFont();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract int getFontHeight();
|
protected abstract int getFontHeight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract double getImageScale();
|
protected abstract double getImageScale();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
return m_iBodyHeight;
|
return m_iBodyHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param g2d
|
* @param g2d
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
* @param width
|
* @param width
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, int x, int y, int width) {
|
public void draw(Graphics2D g2d, int x, int y, int width) {
|
||||||
|
|
||||||
int currenty = y;
|
int currenty = y;
|
||||||
for (PrintItem pi : m_aCommands) {
|
for (PrintItem pi : m_aCommands) {
|
||||||
pi.draw(g2d, x, currenty, width);
|
pi.draw(g2d, x, currenty, width);
|
||||||
currenty += pi.getHeight();
|
currenty += pi.getHeight();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
saveTicket(g2d, x, y, width);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveTicket(Graphics2D g2d, int x, int y, int width) {
|
||||||
|
|
||||||
|
int receiptHeight = 5;
|
||||||
|
|
||||||
|
PrintItem pi;
|
||||||
|
for(Iterator i$ = m_aCommands.iterator(); i$.hasNext(); receiptHeight += pi.getHeight()) {
|
||||||
|
pi = (PrintItem)i$.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedImage image = new BufferedImage(width + 10, receiptHeight, 1);
|
||||||
|
g2d = image.createGraphics();
|
||||||
|
int currenty = y;
|
||||||
|
|
||||||
|
for(Iterator i$ = this.m_aCommands.iterator(); i$.hasNext(); currenty += pi.getHeight()) {
|
||||||
|
pi = (PrintItem)i$.next();
|
||||||
|
if (pi instanceof PrintItemImage) {
|
||||||
|
((PrintItemImage) pi).setImage(negative(((PrintItemImage) pi).getImage()));
|
||||||
|
}
|
||||||
|
pi.draw(g2d, x, currenty, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ImageIO.write(this.negative(image), "png", new File(System.getProperty("user.home") + "/receipt.png"));
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
System.out.println("Error serialising receipt image !!! : " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage negative(BufferedImage img) {
|
||||||
|
for (int x = 0; x < img.getWidth(); ++x) {
|
||||||
|
for (int y = 0; y < img.getHeight(); ++y) {
|
||||||
|
int RGBA = img.getRGB(x, y);
|
||||||
|
Color col = new Color(RGBA, true);
|
||||||
|
col = new Color(Math.abs(col.getRed() - 255), Math.abs(col.getGreen() - 255), Math.abs(col.getBlue() - 255));
|
||||||
|
img.setRGB(x, y, col.getRGB());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public java.util.List<PrintItem> getCommands() {
|
public java.util.List<PrintItem> getCommands() {
|
||||||
return m_aCommands;
|
return m_aCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INTERFAZ PRINTER 2
|
// INTERFAZ PRINTER 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param image
|
* @param image
|
||||||
*/
|
*/
|
||||||
public void printImage(BufferedImage image) {
|
public void printImage(BufferedImage image) {
|
||||||
|
|
||||||
PrintItem pi = new PrintItemImage(image, getImageScale());
|
PrintItem pi = new PrintItemImage(image, getImageScale());
|
||||||
m_aCommands.add(pi);
|
m_aCommands.add(pi);
|
||||||
m_iBodyHeight += pi.getHeight();
|
m_iBodyHeight += pi.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param type
|
* @param type
|
||||||
* @param position
|
* @param position
|
||||||
* @param code
|
* @param code
|
||||||
*/
|
*/
|
||||||
public void printBarCode(String type, String position, String code) {
|
public void printBarCode(String type, String position, String code) {
|
||||||
|
|
||||||
PrintItem pi = new PrintItemBarcode(type, position, code, getImageScale());
|
PrintItem pi = new PrintItemBarcode(type, position, code, getImageScale());
|
||||||
m_aCommands.add(pi);
|
m_aCommands.add(pi);
|
||||||
m_iBodyHeight += pi.getHeight();
|
m_iBodyHeight += pi.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param iTextSize
|
* @param iTextSize
|
||||||
*/
|
*/
|
||||||
public void beginLine(int iTextSize) {
|
public void beginLine(int iTextSize) {
|
||||||
pil = new PrintItemLine(iTextSize, getBaseFont(), getFontHeight());
|
pil = new PrintItemLine(iTextSize, getBaseFont(), getFontHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param iStyle
|
* @param iStyle
|
||||||
* @param sText
|
* @param sText
|
||||||
*/
|
*/
|
||||||
public void printText(int iStyle, String sText) {
|
public void printText(int iStyle, String sText) {
|
||||||
if (pil != null) {
|
if (pil != null) {
|
||||||
pil.addText(iStyle, sText);
|
pil.addText(iStyle, sText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void endLine() {
|
public void endLine() {
|
||||||
if (pil != null) {
|
if (pil != null) {
|
||||||
m_aCommands.add(pil);
|
m_aCommands.add(pil);
|
||||||
m_iBodyHeight += pil.getHeight();
|
m_iBodyHeight += pil.getHeight();
|
||||||
pil = null;
|
pil = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,4 +70,12 @@ public class PrintItemImage implements PrintItem {
|
|||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
return (int) (image.getHeight() * scale);
|
return (int) (image.getHeight() * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BufferedImage getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(BufferedImage image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,14 +79,14 @@ public final class TicketInfo implements SerializableRead, Externalizable {
|
|||||||
private Double nsum;
|
private Double nsum;
|
||||||
private int ticketstatus;
|
private int ticketstatus;
|
||||||
|
|
||||||
private static String Hostname;
|
private static String hostname;
|
||||||
|
|
||||||
public static void setHostname(String name) {
|
public static void setHostname(String name) {
|
||||||
Hostname=name;
|
hostname =name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getHostname() {
|
public static String getHostname() {
|
||||||
return Hostname;
|
return hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates new TicketModel */
|
/** Creates new TicketModel */
|
||||||
|
|||||||
Reference in New Issue
Block a user