Commit 522480e0 by 宁斌

PrinterFlowProxy类调整

parent 32aeaa84
...@@ -9,7 +9,7 @@ import com.epson.epos2.printer.Printer; ...@@ -9,7 +9,7 @@ import com.epson.epos2.printer.Printer;
import com.epson.epos2.printer.PrinterStatusInfo; import com.epson.epos2.printer.PrinterStatusInfo;
import com.epson.epos2.printer.ReceiveListener; import com.epson.epos2.printer.ReceiveListener;
import com.gingersoft.gsa.cloud.common.logan.LoganManager; import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowProxy;
import com.gingersoft.gsa.cloud.print.PrintExecutor; import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder; import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.joe.print.mvp.model.bean.PrintInfoBean; import com.joe.print.mvp.model.bean.PrintInfoBean;
...@@ -279,7 +279,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -279,7 +279,7 @@ public class EpsonPrint implements ReceiveListener {
ids.add(foodId); ids.add(foodId);
if (isPrint) { if (isPrint) {
Log.d("eee", "針式打印機隊列中,前面還有" + bitmaps.size() + "個任務"); Log.d("eee", "針式打印機隊列中,前面還有" + bitmaps.size() + "個任務");
PrinterPlugins.getOnPrinterFlowHandler().connectionBefore("針式打印機隊列中,前面還有" + bitmaps.size() + "個任務", ip, 0, 0, 0); PrinterFlowProxy.newInstance().dispatchConnectionBefore("針式打印機隊列中,前面還有" + bitmaps.size() + "個任務", ip, 0, 0, 0);
return; return;
} }
isPrint = true; isPrint = true;
...@@ -287,7 +287,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -287,7 +287,7 @@ public class EpsonPrint implements ReceiveListener {
} }
private void printData(String ip, Bitmap bitmap) { private void printData(String ip, Bitmap bitmap) {
PrinterPlugins.getOnPrinterFlowHandler().onPrinterDataBefore(0, 0, "針式打印機", ip); PrinterFlowProxy.newInstance().dispatchPrinterDataBefore(0, 0, "針式打印機", ip);
mPrinter.clearCommandBuffer(); mPrinter.clearCommandBuffer();
Log.d("eee", "針式打印機創建數據中,任務數:" + bitmaps.size()); Log.d("eee", "針式打印機創建數據中,任務數:" + bitmaps.size());
if (!createPrintData(bitmap)) { if (!createPrintData(bitmap)) {
...@@ -306,7 +306,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -306,7 +306,7 @@ public class EpsonPrint implements ReceiveListener {
if (statusInfo.getConnection() != 1) { if (statusInfo.getConnection() != 1) {
//未連接到打印機 //未連接到打印機
updatePrintState(PrintSocketHolder.ERROR_7); updatePrintState(PrintSocketHolder.ERROR_7);
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new ConnectException("針式打印機連接失敗" + ip)); PrinterFlowProxy.newInstance().dispatchConnectionError(new ConnectException("針式打印機連接失敗" + ip));
isPrint = false; isPrint = false;
return; return;
} else if (statusInfo.getPaper() != 0) { } else if (statusInfo.getPaper() != 0) {
...@@ -314,23 +314,23 @@ public class EpsonPrint implements ReceiveListener { ...@@ -314,23 +314,23 @@ public class EpsonPrint implements ReceiveListener {
if (statusInfo.getPaper() == 2) { if (statusInfo.getPaper() == 2) {
//沒紙了 //沒紙了
updatePrintState(PrintSocketHolder.ERROR_11); updatePrintState(PrintSocketHolder.ERROR_11);
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("針式打印機缺紙,打印失敗" + ip),0); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception("針式打印機缺紙,打印失敗" + ip),0);
} else { } else {
//紙張狀態異常 //紙張狀態異常
updatePrintState(PrintSocketHolder.ERROR_11); updatePrintState(PrintSocketHolder.ERROR_11);
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("針式打印機紙張異常,請重啟打印機" + ip),0); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception("針式打印機紙張異常,請重啟打印機" + ip),0);
} }
isPrint = false; isPrint = false;
return; return;
} }
try { try {
mPrinter.sendData(Printer.PARAM_DEFAULT); mPrinter.sendData(Printer.PARAM_DEFAULT);
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterFlowProxy.newInstance().dispatchPrintSuccess();
Log.d("eee", "針式打印機打印成功" + ",任務數:" + bitmaps.size()); Log.d("eee", "針式打印機打印成功" + ",任務數:" + bitmaps.size());
} catch (Exception e) { } catch (Exception e) {
Log.d("eee", "針式打印機打印失敗" + ",任務數:" + bitmaps.size() + e.getMessage()); Log.d("eee", "針式打印機打印失敗" + ",任務數:" + bitmaps.size() + e.getMessage());
updatePrintState(PrintSocketHolder.ERROR_10); updatePrintState(PrintSocketHolder.ERROR_10);
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("打印機連接成功,發送數據出現問題"),0); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception("打印機連接成功,發送數據出現問題"),0);
mPrinter.clearCommandBuffer(); mPrinter.clearCommandBuffer();
disconnectPrinter(); disconnectPrinter();
isPrint = false; isPrint = false;
...@@ -392,10 +392,10 @@ public class EpsonPrint implements ReceiveListener { ...@@ -392,10 +392,10 @@ public class EpsonPrint implements ReceiveListener {
LoganManager.w_printer(TAG, "連接打印機報錯:" + e.getMessage()); LoganManager.w_printer(TAG, "連接打印機報錯:" + e.getMessage());
disconnectPrinter(); disconnectPrinter();
finalizeObject(); finalizeObject();
PrinterPlugins.getOnPrinterFlowHandler().connectionError(e); PrinterFlowProxy.newInstance().dispatchConnectionError(e);
return false; return false;
} }
PrinterPlugins.getOnPrinterFlowHandler().connectionSuccess(); PrinterFlowProxy.newInstance().dispatchConnectionSuccess();
return true; return true;
} }
......
...@@ -17,7 +17,7 @@ import com.gingersoft.gsa.cloud.common.constans.PrintConstans; ...@@ -17,7 +17,7 @@ import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager; import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.logan.LoganManager; import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.AidlUtil; import com.gingersoft.gsa.cloud.common.printer.AidlUtil;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowProxy;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils; import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils; import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils;
...@@ -46,7 +46,6 @@ import com.joe.print.mvp.print.usb.UsbPrinter; ...@@ -46,7 +46,6 @@ import com.joe.print.mvp.print.usb.UsbPrinter;
import com.joe.print.mvp.print.usb.UsbPrinterFinder; import com.joe.print.mvp.print.usb.UsbPrinterFinder;
import com.joe.print.mvp.print.utils.MyPrintUtils; import com.joe.print.mvp.print.utils.MyPrintUtils;
import com.sunmi.peripheral.printer.InnerResultCallbcak; import com.sunmi.peripheral.printer.InnerResultCallbcak;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
...@@ -61,7 +60,6 @@ import java.util.Iterator; ...@@ -61,7 +60,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observer; import io.reactivex.Observer;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
...@@ -309,7 +307,7 @@ public class PrjPtinterManager implements ReceiveListener { ...@@ -309,7 +307,7 @@ public class PrjPtinterManager implements ReceiveListener {
if (beans != null && beans.size() > 0) { if (beans != null && beans.size() > 0) {
orderType = beans.get(0).getOrderType(); orderType = beans.get(0).getOrderType();
} }
PrinterPlugins.getOnPrinterFlowHandler().onPrinterDataBefore(orderType, PrintConstans.PRINT_KITCHEN, GsonUtils.GsonString(beans), GsonUtils.GsonString(printerDeviceBean)); PrinterFlowProxy.newInstance().dispatchPrinterDataBefore(orderType, PrintConstans.PRINT_KITCHEN, GsonUtils.GsonString(beans), GsonUtils.GsonString(printerDeviceBean));
if (isPinPrinter(printerDeviceBean) && printerDeviceBean.getPrinterDeviceType() == PRINT_IP) { if (isPinPrinter(printerDeviceBean) && printerDeviceBean.getPrinterDeviceType() == PRINT_IP) {
//針式打印 //針式打印
...@@ -458,11 +456,11 @@ public class PrjPtinterManager implements ReceiveListener { ...@@ -458,11 +456,11 @@ public class PrjPtinterManager implements ReceiveListener {
boolean initResult = EpsonPrint.getInstance().initializeObject(mContext, this, errorCode -> updatePrjState(errorCode, getPrintIds(bitmapMaps))); boolean initResult = EpsonPrint.getInstance().initializeObject(mContext, this, errorCode -> updatePrjState(errorCode, getPrintIds(bitmapMaps)));
if (!initResult) { if (!initResult) {
//初始化打印機失敗 //初始化打印機失敗
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new ConnectException("初始化針式打印機失敗")); PrinterFlowProxy.newInstance().dispatchConnectionError(new ConnectException("初始化針式打印機失敗"));
updatePrjState(UpdateBean.FAIL_EPSON_INIT, getPrintIds(bitmapMaps)); updatePrjState(UpdateBean.FAIL_EPSON_INIT, getPrintIds(bitmapMaps));
return; return;
} }
PrinterPlugins.getOnPrinterFlowHandler().connectionBefore("針式打印機" + bitmapMaps.size(), printerDeviceBean.getIp(), printerDeviceBean.getPort(), 0, 0); PrinterFlowProxy.newInstance().dispatchConnectionBefore("針式打印機" + bitmapMaps.size(), printerDeviceBean.getIp(), printerDeviceBean.getPort(), 0, 0);
Log.d("eee", "針式打印機本次PRJ數量:" + bitmapMaps.size()); Log.d("eee", "針式打印機本次PRJ數量:" + bitmapMaps.size());
for (int i = 0; i < bitmapMaps.size(); i++) { for (int i = 0; i < bitmapMaps.size(); i++) {
for (Map.Entry<String, Bitmap> mapEntry : bitmapMaps.get(i).entrySet()) { for (Map.Entry<String, Bitmap> mapEntry : bitmapMaps.get(i).entrySet()) {
...@@ -507,10 +505,10 @@ public class PrjPtinterManager implements ReceiveListener { ...@@ -507,10 +505,10 @@ public class PrjPtinterManager implements ReceiveListener {
UsbPrint usbPrint = new UsbPrint(mContext, (code, printId) -> { UsbPrint usbPrint = new UsbPrint(mContext, (code, printId) -> {
//打印結果 //打印結果
if (code == SendResultCode.SEND_SUCCESS) { if (code == SendResultCode.SEND_SUCCESS) {
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterFlowProxy.newInstance().dispatchPrintSuccess();
updatePrjSuccess(key); updatePrjSuccess(key);
} else if (code == SendResultCode.SEND_FAILED) { } else if (code == SendResultCode.SEND_FAILED) {
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("發送打印數據失敗"), code); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception("發送打印數據失敗"), code);
updatePrjFailure(key); updatePrjFailure(key);
} }
}); });
...@@ -621,7 +619,7 @@ public class PrjPtinterManager implements ReceiveListener { ...@@ -621,7 +619,7 @@ public class PrjPtinterManager implements ReceiveListener {
@Override @Override
public void onRaiseException(int code, String msg) { public void onRaiseException(int code, String msg) {
//接⼝执⾏失败时,返回的异常状态 //接⼝执⾏失败时,返回的异常状态
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(msg), code); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception(msg), code);
LoganManager.w_printer(TAG, "商米onRaiseException: " + code + msg); LoganManager.w_printer(TAG, "商米onRaiseException: " + code + msg);
switch (code) { switch (code) {
case 3: case 3:
...@@ -684,7 +682,7 @@ public class PrjPtinterManager implements ReceiveListener { ...@@ -684,7 +682,7 @@ public class PrjPtinterManager implements ReceiveListener {
updatePrjSuccess(ids); updatePrjSuccess(ids);
} else { } else {
//打印失敗 //打印失敗
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(UpdateBean.getStateByCode(i)), i); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception(UpdateBean.getStateByCode(i)), i);
updatePrjState(i, ids); updatePrjState(i, ids);
} }
} }
...@@ -697,7 +695,7 @@ public class PrjPtinterManager implements ReceiveListener { ...@@ -697,7 +695,7 @@ public class PrjPtinterManager implements ReceiveListener {
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(e, i); PrinterFlowProxy.newInstance().dispatchPrintError(e, i);
LoganManager.w_printer(TAG, "N5 RemoteException :" + e.getLocalizedMessage()); LoganManager.w_printer(TAG, "N5 RemoteException :" + e.getLocalizedMessage());
updatePrjFailure(ids); updatePrjFailure(ids);
} }
...@@ -766,7 +764,7 @@ public class PrjPtinterManager implements ReceiveListener { ...@@ -766,7 +764,7 @@ public class PrjPtinterManager implements ReceiveListener {
bitmapList.add(bitmapIterator.next().getValue()); bitmapList.add(bitmapIterator.next().getValue());
} }
} }
PrinterPlugins.getOnPrinterFlowHandler().onPrinterBitmapBefore(orderType, PrintConstans.PRINT_KITCHEN, prjName, bitmapList); PrinterFlowProxy.newInstance().dispatchPrinterBitmapBefore(orderType, PrintConstans.PRINT_KITCHEN, prjName, bitmapList);
} }
} }
...@@ -841,11 +839,11 @@ public class PrjPtinterManager implements ReceiveListener { ...@@ -841,11 +839,11 @@ public class PrjPtinterManager implements ReceiveListener {
public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String s) { public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String s) {
//針式打印回調 //針式打印回調
if (i == 0) { if (i == 0) {
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterFlowProxy.newInstance().dispatchPrintSuccess();
//打印成功 //打印成功
updatePrjSuccess(s); updatePrjSuccess(s);
} else { } else {
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("打印失敗"), i); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception("打印失敗"), i);
//打印失敗 //打印失敗
updatePrjFailure(s); updatePrjFailure(s);
} }
......
...@@ -9,7 +9,6 @@ import android.os.Build; ...@@ -9,7 +9,6 @@ import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
...@@ -35,10 +34,8 @@ import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager; ...@@ -35,10 +34,8 @@ import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils; import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.logan.LoganManager; import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.AidlUtil; import com.gingersoft.gsa.cloud.common.printer.AidlUtil;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowProxy;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.threadPool.ThreadPoolManager;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.common.utils.view.ImageUtils; import com.gingersoft.gsa.cloud.common.utils.view.ImageUtils;
import com.gingersoft.gsa.cloud.common.utils.view.LayoutToBitmapUtils; import com.gingersoft.gsa.cloud.common.utils.view.LayoutToBitmapUtils;
...@@ -81,7 +78,6 @@ import com.xuexiang.rxutil2.rxjava.RxJavaUtils; ...@@ -81,7 +78,6 @@ import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask; import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.io.IOException; import java.io.IOException;
import java.net.ConnectException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
...@@ -235,7 +231,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -235,7 +231,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
new BBposPrint().print(BBPosPrintDatas, listener, false); new BBposPrint().print(BBPosPrintDatas, listener, false);
} else { } else {
// listener.printFailure("暫不支持本機型打印"); // listener.printFailure("暫不支持本機型打印");
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new Exception("暫不支持本機型打印")); PrinterFlowProxy.newInstance().dispatchConnectionError(new Exception("暫不支持本機型打印"));
} }
} }
...@@ -268,7 +264,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -268,7 +264,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
*/ */
private void sunmiPrint(List<Bitmap> bitmaps, PrintListener listener) { private void sunmiPrint(List<Bitmap> bitmaps, PrintListener listener) {
//商米打印 //商米打印
PrinterPlugins.getOnPrinterFlowHandler().connectionSuccess(); PrinterFlowProxy.newInstance().dispatchConnectionSuccess();
AidlUtil.getInstance().printBitmaps(bitmaps, SUNMI_PAPER_WIDTH, new InnerResultCallbcak() { AidlUtil.getInstance().printBitmaps(bitmaps, SUNMI_PAPER_WIDTH, new InnerResultCallbcak() {
@Override @Override
public void onRunResult(boolean isSuccess) { public void onRunResult(boolean isSuccess) {
...@@ -288,14 +284,14 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -288,14 +284,14 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
@Override @Override
public void onRaiseException(int code, String msg) { public void onRaiseException(int code, String msg) {
//接⼝执⾏失败时,返回的异常状态 //接⼝执⾏失败时,返回的异常状态
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(msg), code); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception(msg), code);
LoganManager.w_printer(TAG, "商米onRaiseException: " + code + msg); LoganManager.w_printer(TAG, "商米onRaiseException: " + code + msg);
} }
@Override @Override
public void onPrintResult(int code, String msg) { public void onPrintResult(int code, String msg) {
//事务模式下真实的打印结果返回 //事务模式下真实的打印结果返回
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterFlowProxy.newInstance().dispatchPrintSuccess();
} }
}); });
} }
...@@ -308,7 +304,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -308,7 +304,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
if (i == 0) { if (i == 0) {
//打印成功 //打印成功
listener.printSuccess(); listener.printSuccess();
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterFlowProxy.newInstance().dispatchPrintSuccess();
} else { } else {
//打印失敗 //打印失敗
listener.printFailure(UpdateBean.getStateByCode(i)); listener.printFailure(UpdateBean.getStateByCode(i));
......
...@@ -21,7 +21,7 @@ import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager; ...@@ -21,7 +21,7 @@ import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.user.UserContext; import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.logan.LoganManager; import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.AidlUtil; import com.gingersoft.gsa.cloud.common.printer.AidlUtil;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowProxy;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils; import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils; import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils;
...@@ -367,7 +367,7 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -367,7 +367,7 @@ public class PrjService extends Service implements ReceiveListener {
if (beans != null && beans.size() > 0) { if (beans != null && beans.size() > 0) {
orderType = beans.get(0).getOrderType(); orderType = beans.get(0).getOrderType();
} }
PrinterPlugins.getOnPrinterFlowHandler().onPrinterDataBefore(orderType, PrintConstans.PRINT_KITCHEN, GsonUtils.GsonString(beans), GsonUtils.GsonString(printerDeviceBean)); PrinterFlowProxy.newInstance().dispatchPrinterDataBefore(orderType, PrintConstans.PRINT_KITCHEN, GsonUtils.GsonString(beans), GsonUtils.GsonString(printerDeviceBean));
if (isPinPrinter(printerDeviceBean) && printerDeviceBean.getPrinterDeviceType() == PRINT_IP) { if (isPinPrinter(printerDeviceBean) && printerDeviceBean.getPrinterDeviceType() == PRINT_IP) {
//針式打印 //針式打印
...@@ -516,11 +516,11 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -516,11 +516,11 @@ public class PrjService extends Service implements ReceiveListener {
boolean initResult = EpsonPrint.getInstance().initializeObject(this, this, errorCode -> updatePrjState(errorCode, getPrintIds(bitmapMaps))); boolean initResult = EpsonPrint.getInstance().initializeObject(this, this, errorCode -> updatePrjState(errorCode, getPrintIds(bitmapMaps)));
if (!initResult) { if (!initResult) {
//初始化打印機失敗 //初始化打印機失敗
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new ConnectException("初始化針式打印機失敗")); PrinterFlowProxy.newInstance().dispatchConnectionError(new ConnectException("初始化針式打印機失敗"));
updatePrjState(UpdateBean.FAIL_EPSON_INIT, getPrintIds(bitmapMaps)); updatePrjState(UpdateBean.FAIL_EPSON_INIT, getPrintIds(bitmapMaps));
return; return;
} }
PrinterPlugins.getOnPrinterFlowHandler().connectionBefore("針式打印機" + bitmapMaps.size(), printerDeviceBean.getIp(), printerDeviceBean.getPort(), 0, 0); PrinterFlowProxy.newInstance().dispatchConnectionBefore("針式打印機" + bitmapMaps.size(), printerDeviceBean.getIp(), printerDeviceBean.getPort(), 0, 0);
Log.d("eee", "針式打印機本次PRJ數量:" + bitmapMaps.size()); Log.d("eee", "針式打印機本次PRJ數量:" + bitmapMaps.size());
for (int i = 0; i < bitmapMaps.size(); i++) { for (int i = 0; i < bitmapMaps.size(); i++) {
for (Map.Entry<String, Bitmap> mapEntry : bitmapMaps.get(i).entrySet()) { for (Map.Entry<String, Bitmap> mapEntry : bitmapMaps.get(i).entrySet()) {
...@@ -565,10 +565,10 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -565,10 +565,10 @@ public class PrjService extends Service implements ReceiveListener {
UsbPrint usbPrint = new UsbPrint(mContext, (code, printId) -> { UsbPrint usbPrint = new UsbPrint(mContext, (code, printId) -> {
//打印結果 //打印結果
if (code == SendResultCode.SEND_SUCCESS) { if (code == SendResultCode.SEND_SUCCESS) {
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterFlowProxy.newInstance().dispatchPrintSuccess();
updatePrjSuccess(key); updatePrjSuccess(key);
} else if (code == SendResultCode.SEND_FAILED) { } else if (code == SendResultCode.SEND_FAILED) {
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("發送打印數據失敗"), code); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception("發送打印數據失敗"), code);
updatePrjFailure(key); updatePrjFailure(key);
} }
}); });
...@@ -679,7 +679,7 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -679,7 +679,7 @@ public class PrjService extends Service implements ReceiveListener {
@Override @Override
public void onRaiseException(int code, String msg) { public void onRaiseException(int code, String msg) {
//接⼝执⾏失败时,返回的异常状态 //接⼝执⾏失败时,返回的异常状态
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(msg), code); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception(msg), code);
LoganManager.w_printer(TAG, "商米onRaiseException: " + code + msg); LoganManager.w_printer(TAG, "商米onRaiseException: " + code + msg);
switch (code) { switch (code) {
case 3: case 3:
...@@ -742,7 +742,7 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -742,7 +742,7 @@ public class PrjService extends Service implements ReceiveListener {
updatePrjSuccess(ids); updatePrjSuccess(ids);
} else { } else {
//打印失敗 //打印失敗
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(UpdateBean.getStateByCode(i)), i); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception(UpdateBean.getStateByCode(i)), i);
updatePrjState(i, ids); updatePrjState(i, ids);
} }
} }
...@@ -755,7 +755,7 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -755,7 +755,7 @@ public class PrjService extends Service implements ReceiveListener {
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(e, i); PrinterFlowProxy.newInstance().dispatchPrintError(e, i);
LoganManager.w_printer(TAG, "N5 RemoteException :" + e.getLocalizedMessage()); LoganManager.w_printer(TAG, "N5 RemoteException :" + e.getLocalizedMessage());
updatePrjFailure(ids); updatePrjFailure(ids);
} }
...@@ -824,7 +824,7 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -824,7 +824,7 @@ public class PrjService extends Service implements ReceiveListener {
bitmapList.add(bitmapIterator.next().getValue()); bitmapList.add(bitmapIterator.next().getValue());
} }
} }
PrinterPlugins.getOnPrinterFlowHandler().onPrinterBitmapBefore(orderType, PrintConstans.PRINT_KITCHEN, prjName, bitmapList); PrinterFlowProxy.newInstance().dispatchPrinterBitmapBefore(orderType, PrintConstans.PRINT_KITCHEN, prjName, bitmapList);
} }
} }
...@@ -901,11 +901,11 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -901,11 +901,11 @@ public class PrjService extends Service implements ReceiveListener {
public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String s) { public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String s) {
//針式打印回調 //針式打印回調
if (i == 0) { if (i == 0) {
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterFlowProxy.newInstance().dispatchPrintSuccess();
//打印成功 //打印成功
updatePrjSuccess(s); updatePrjSuccess(s);
} else { } else {
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("打印失敗"), i); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception("打印失敗"), i);
//打印失敗 //打印失敗
updatePrjFailure(s); updatePrjFailure(s);
} }
......
package com.joe.print.mvp.ui.activity; package com.joe.print.mvp.ui.activity;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
...@@ -20,21 +18,19 @@ import com.gingersoft.gsa.cloud.app.GsaCloudApplication; ...@@ -20,21 +18,19 @@ import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans; import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.logan.LoganManager; import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowListener; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowListener;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowProxy;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils; import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean; import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.FoodModifierDaoUtils;
import com.gingersoft.gsa.cloud.print.PrintExecutor; import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder; import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.gingersoft.gsa.cloud.print.bean.PrintContent; import com.gingersoft.gsa.cloud.print.bean.PrintContent;
import com.gingersoft.gsa.cloud.print.bean.PrjBean; import com.gingersoft.gsa.cloud.print.bean.PrjBean;
import com.jess.arms.base.BaseActivity; import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.integration.AppManager;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.joe.print.di.component.DaggerPrintComponent; import com.joe.print.di.component.DaggerPrintComponent;
import com.joe.print.mvp.contract.PrintContract; import com.joe.print.mvp.contract.PrintContract;
...@@ -53,13 +49,6 @@ import com.lxj.xpopup.XPopup; ...@@ -53,13 +49,6 @@ import com.lxj.xpopup.XPopup;
import java.net.ConnectException; import java.net.ConnectException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimerTask;
import javax.inject.Inject;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_BILL; import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_BILL;
import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_OTHER_CLOSING; import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_OTHER_CLOSING;
...@@ -143,7 +132,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -143,7 +132,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
// .asLoading("加载中..."); // .asLoading("加载中...");
// loadingPopup.show(); // loadingPopup.show();
PrinterPlugins.setOnPrinterFlowHandler(new PrinterFlowListener() { PrinterFlowProxy.newInstance().registerPrinterFlowListener(new PrinterFlowListener() {
@Override @Override
public void connectionBefore(String deviceName, String IP, int port, long ioTimeout, long printTimeout) { public void connectionBefore(String deviceName, String IP, int port, long ioTimeout, long printTimeout) {
...@@ -152,13 +141,11 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -152,13 +141,11 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override @Override
public void connectionSuccess() { public void connectionSuccess() {
LoganManager.w_code(TAG, "PrinterPlugins connectionSuccess ThreadName=" + Thread.currentThread().getName());
printerLoadingDialog.setStep(2, PrinterLoadingDialog.status_success, null); printerLoadingDialog.setStep(2, PrinterLoadingDialog.status_success, null);
} }
@Override @Override
public void connectionError(Exception e) { public void connectionError(Exception e) {
LoganManager.w_code(TAG, "PrinterPlugins connectionError ThreadName=" + Thread.currentThread().getName());
printerResult = false; printerResult = false;
printerLoadingDialog.setStep(2, PrinterLoadingDialog.status_error, e.getMessage()); printerLoadingDialog.setStep(2, PrinterLoadingDialog.status_error, e.getMessage());
} }
...@@ -169,26 +156,22 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -169,26 +156,22 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override @Override
public void onPrinterDataBefore(int orderType, int printType, String printerData, String printerDeviceInfo) { public void onPrinterDataBefore(int orderType, int printType, String printerData, String printerDeviceInfo) {
LoganManager.w_code(TAG, "PrinterPlugins onPrinterDataBefore ThreadName=" + Thread.currentThread().getName());
printerLoadingDialog.setStep(1, PrinterLoadingDialog.status_success, null); printerLoadingDialog.setStep(1, PrinterLoadingDialog.status_success, null);
} }
@Override @Override
public void onPrinterBitmapBefore(int orderType, int printType, String directoryName, List<Bitmap> bitmaps) { public void onPrinterBitmapBefore(int orderType, int printType, String directoryName, List<Bitmap> bitmaps) {
LoganManager.w_code(TAG, "PrinterPlugins onPrinterBitmapBefore ThreadName=" + Thread.currentThread().getName());
printerLoadingDialog.setStep(1, PrinterLoadingDialog.status_success, null); printerLoadingDialog.setStep(1, PrinterLoadingDialog.status_success, null);
} }
@Override @Override
public void onPrintSuccess() { public void onPrintSuccess() {
LoganManager.w_code(TAG, "PrinterPlugins onPrintSuccess ThreadName=" + Thread.currentThread().getName());
printerResult = true; printerResult = true;
printerLoadingDialog.setStep(3, PrinterLoadingDialog.status_success, null); printerLoadingDialog.setStep(3, PrinterLoadingDialog.status_success, null);
} }
@Override @Override
public void onPrintError(Exception e, int errorCode) { public void onPrintError(Exception e, int errorCode) {
LoganManager.w_code(TAG, "PrinterPlugins onPrintError ThreadName=" + Thread.currentThread().getName());
printerResult = false; printerResult = false;
printerLoadingDialog.setStep(3, PrinterLoadingDialog.status_error, e.getMessage()); printerLoadingDialog.setStep(3, PrinterLoadingDialog.status_error, e.getMessage());
} }
...@@ -254,7 +237,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -254,7 +237,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
private void initPrintConfig(PrintContent printContent) { private void initPrintConfig(PrintContent printContent) {
PrinterPlugins.getOnPrinterFlowHandler().onPrinterDataBefore(type, type, GsonUtils.GsonString(printContent), GsonUtils.GsonString(defaultPrint)); PrinterFlowProxy.newInstance().dispatchPrinterDataBefore(type, type, GsonUtils.GsonString(printContent), GsonUtils.GsonString(defaultPrint));
//獲取通用打印配置 //獲取通用打印配置
PrintCurrencyBean printCurrencyBean = getCurrencyConfig(); PrintCurrencyBean printCurrencyBean = getCurrencyConfig();
...@@ -420,7 +403,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -420,7 +403,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
private void setPrinterBitmapToLocation(int orderType, int printType, String orderNo, Map<String, List<Bitmap>> bitmapMaps) { private void setPrinterBitmapToLocation(int orderType, int printType, String orderNo, Map<String, List<Bitmap>> bitmapMaps) {
if (bitmapMaps.size() > 0 && bitmapMaps.get("") != null) { if (bitmapMaps.size() > 0 && bitmapMaps.get("") != null) {
String prjName = orderNo + "-" + System.currentTimeMillis(); String prjName = orderNo + "-" + System.currentTimeMillis();
PrinterPlugins.getOnPrinterFlowHandler().onPrinterBitmapBefore(orderType, printType, prjName, bitmapMaps.get("")); PrinterFlowProxy.newInstance().dispatchPrinterBitmapBefore(orderType, printType, prjName, bitmapMaps.get(""));
} }
} }
...@@ -451,38 +434,38 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -451,38 +434,38 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
switch (state) { switch (state) {
case PrintSocketHolder.ERROR_0: case PrintSocketHolder.ERROR_0:
tip = "打印成功"; tip = "打印成功";
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterFlowProxy.newInstance().dispatchPrintSuccess();
break; break;
case PrintSocketHolder.ERROR_6: case PrintSocketHolder.ERROR_6:
tip = "生成打印數據失敗"; tip = "生成打印數據失敗";
break; break;
case PrintSocketHolder.ERROR_7: case PrintSocketHolder.ERROR_7:
tip = "連接打印機失敗"; tip = "連接打印機失敗";
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new ConnectException(tip)); PrinterFlowProxy.newInstance().dispatchConnectionError(new ConnectException(tip));
break; break;
case PrintSocketHolder.ERROR_4: case PrintSocketHolder.ERROR_4:
tip = "寫入數據失敗"; tip = "寫入數據失敗";
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(tip), 0); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception(tip), 0);
break; break;
case PrintSocketHolder.ERROR_9: case PrintSocketHolder.ERROR_9:
tip = "ip地址不能為空"; tip = "ip地址不能為空";
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new ConnectException(tip)); PrinterFlowProxy.newInstance().dispatchConnectionError(new ConnectException(tip));
break; break;
case PrintSocketHolder.ERROR_10: case PrintSocketHolder.ERROR_10:
tip = "打印機連接成功,獲取輸入流失敗或者發送數據出現問題"; tip = "打印機連接成功,獲取輸入流失敗或者發送數據出現問題";
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(tip), 0); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception(tip), 0);
break; break;
case PrintSocketHolder.ERROR_11: case PrintSocketHolder.ERROR_11:
tip = "打印機沒紙了"; tip = "打印機沒紙了";
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(tip), 0); PrinterFlowProxy.newInstance().dispatchPrintError(new Exception(tip), 0);
break; break;
case PrintSocketHolder.ERROR_12: case PrintSocketHolder.ERROR_12:
tip = " 打印機初始化失敗,暫時只有針式打印機有"; tip = " 打印機初始化失敗,暫時只有針式打印機有";
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new ConnectException(tip)); PrinterFlowProxy.newInstance().dispatchConnectionError(new ConnectException(tip));
break; break;
case PrintSocketHolder.ERROR_TIMEOUT: case PrintSocketHolder.ERROR_TIMEOUT:
tip = "連接打印機超時"; tip = "連接打印機超時";
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new ConnectException(tip)); PrinterFlowProxy.newInstance().dispatchConnectionError(new ConnectException(tip));
break; break;
case PrintSocketHolder.STATE_0: case PrintSocketHolder.STATE_0:
break; break;
...@@ -509,7 +492,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -509,7 +492,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
//缺紙 //缺紙
printFailure("打印機缺紙"); printFailure("打印機缺紙");
tip = "打印機缺紙"; tip = "打印機缺紙";
// PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(tip), 0); // PrinterPlugins.newInstance().dispatchPrintError(new Exception(tip), 0);
break; break;
default: default:
break; break;
...@@ -588,9 +571,9 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -588,9 +571,9 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override @Override
public void killMyself() { public void killMyself() {
if (printerResult) { // if (printerResult) {
finish(); finish();
} // }
} }
@Override @Override
......
...@@ -5,10 +5,22 @@ import android.os.Bundle; ...@@ -5,10 +5,22 @@ import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.common.utils.threadPool.ThreadPoolManager;
import com.gingersoft.gsa.cloud.table.R; import com.gingersoft.gsa.cloud.table.R;
import com.jess.arms.base.BaseActivity; import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import java.util.Timer;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;
import java.util.concurrent.RecursiveTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import io.reactivex.internal.schedulers.ScheduledDirectTask;
/** /**
* @作者: bin * @作者: bin
* @創建時間: 2021-02-02 11:42 * @創建時間: 2021-02-02 11:42
...@@ -34,7 +46,6 @@ public class CoordinatorlayoutActivity extends BaseActivity { ...@@ -34,7 +46,6 @@ public class CoordinatorlayoutActivity extends BaseActivity {
@Override @Override
public void initIntent() { public void initIntent() {
} }
@Override @Override
......
...@@ -14,7 +14,6 @@ import androidx.annotation.NonNull; ...@@ -14,7 +14,6 @@ import androidx.annotation.NonNull;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.dianping.logan.Logan; import com.dianping.logan.Logan;
import com.dianping.logan.OnLoganProtocolStatus; import com.dianping.logan.OnLoganProtocolStatus;
import com.didichuxing.doraemonkit.DoraemonKit;
import com.elvishew.xlog.LogConfiguration; import com.elvishew.xlog.LogConfiguration;
import com.elvishew.xlog.LogLevel; import com.elvishew.xlog.LogLevel;
import com.elvishew.xlog.XLog; import com.elvishew.xlog.XLog;
...@@ -27,7 +26,6 @@ import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy; ...@@ -27,7 +26,6 @@ import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy;
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator; import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator;
import com.gingersoft.gsa.cloud.common.BuildConfig; import com.gingersoft.gsa.cloud.common.BuildConfig;
import com.gingersoft.gsa.cloud.common.R; import com.gingersoft.gsa.cloud.common.R;
import com.gingersoft.gsa.cloud.common.config.DoraemonKitConfig;
import com.gingersoft.gsa.cloud.common.config.LoganConfig; import com.gingersoft.gsa.cloud.common.config.LoganConfig;
import com.gingersoft.gsa.cloud.common.config.expandconfig.ExpandInfoSetting; import com.gingersoft.gsa.cloud.common.config.expandconfig.ExpandInfoSetting;
import com.gingersoft.gsa.cloud.common.config.expandconfig.FunctionExtendedConfiguration; import com.gingersoft.gsa.cloud.common.config.expandconfig.FunctionExtendedConfiguration;
...@@ -49,35 +47,27 @@ import com.gingersoft.gsa.cloud.common.oaId.DeviceID; ...@@ -49,35 +47,27 @@ import com.gingersoft.gsa.cloud.common.oaId.DeviceID;
import com.gingersoft.gsa.cloud.common.printer.AidlUtil; import com.gingersoft.gsa.cloud.common.printer.AidlUtil;
import com.gingersoft.gsa.cloud.common.printer.PrinterFileUtils; import com.gingersoft.gsa.cloud.common.printer.PrinterFileUtils;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowListener; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowListener;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowProxy;
import com.gingersoft.gsa.cloud.common.utils.AppDevices; import com.gingersoft.gsa.cloud.common.utils.AppDevices;
import com.gingersoft.gsa.cloud.common.utils.FileUtils; import com.gingersoft.gsa.cloud.common.utils.FileUtils;
import com.gingersoft.gsa.cloud.common.utils.crash.AppCrashHandler; import com.gingersoft.gsa.cloud.common.utils.crash.AppCrashHandler;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil; import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils; import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.common.utils.view.BitmapUtil;
import com.gingersoft.gsa.cloud.common.utils.xlog.MyBackupStrategy; import com.gingersoft.gsa.cloud.common.utils.xlog.MyBackupStrategy;
import com.gingersoft.gsa.cloud.component.ComponentAction; import com.gingersoft.gsa.cloud.component.ComponentAction;
import com.gingersoft.gsa.cloud.component.ComponentName; import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.database.DaoManager; import com.gingersoft.gsa.cloud.database.DaoManager;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.hyweb.n5.lib.exception.NoInitPrinterException; import com.hyweb.n5.lib.exception.NoInitPrinterException;
import com.hyweb.n5.lib.util.PrinterUtil; import com.hyweb.n5.lib.util.PrinterUtil;
import com.jess.arms.base.BaseApplication; import com.jess.arms.base.BaseApplication;
import com.kingja.loadsir.core.LoadSir; import com.kingja.loadsir.core.LoadSir;
import com.qmuiteam.qmui.arch.QMUISwipeBackActivityManager;
import com.scwang.smartrefresh.layout.SmartRefreshLayout; import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter; import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader; import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.io.File; import java.io.File;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.Set;
import io.reactivex.functions.Consumer; import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.plugins.RxJavaPlugins;
...@@ -166,7 +156,6 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -166,7 +156,6 @@ public class GsaCloudApplication extends BaseApplication {
//上傳餐廳擴展信息 //上傳餐廳擴展信息
ExpandInfoSetting.initUpdateExtendedConfiguration(uiStyleConfiguration, functionConfiguration); ExpandInfoSetting.initUpdateExtendedConfiguration(uiStyleConfiguration, functionConfiguration);
LoganManager.w_action(TAG, TAG + ": onCreate end....."); LoganManager.w_action(TAG, TAG + ": onCreate end.....");
} }
...@@ -184,7 +173,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -184,7 +173,7 @@ public class GsaCloudApplication extends BaseApplication {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
LoganConfig.UPLOAD_LOG_URL = "http://192.168.1.131:8080/logan-web/logan/upload.json"; LoganConfig.UPLOAD_LOG_URL = "http://192.168.1.131:8080/logan-web/logan/upload.json";
} else { } else {
LoganConfig.UPLOAD_LOG_URL = HttpsConstans.HTTP_ADDRESS_URL_HK + "/logan-web/logan/upload.json"; LoganConfig.UPLOAD_LOG_URL = HttpsConstans.ROOT_HK_TEST_URL + "/logan-web/logan/upload.json";
} }
com.dianping.logan.LoganConfig config = new com.dianping.logan.LoganConfig.Builder() com.dianping.logan.LoganConfig config = new com.dianping.logan.LoganConfig.Builder()
.setCachePath(getFilesDir().getAbsolutePath()) .setCachePath(getFilesDir().getAbsolutePath())
...@@ -347,7 +336,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -347,7 +336,7 @@ public class GsaCloudApplication extends BaseApplication {
SPUtils.put(PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT); SPUtils.put(PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT);
} }
//打印流程 //打印流程
PrinterPlugins.setOnPrinterFlowHandler(new PrinterFlowListener() { PrinterFlowProxy.newInstance().registerPrinterFlowListener(new PrinterFlowListener() {
private final String TAG = "PrinterPlugins"; private final String TAG = "PrinterPlugins";
......
...@@ -15,7 +15,7 @@ public class LoganConfig { ...@@ -15,7 +15,7 @@ public class LoganConfig {
public static final String EncryptIV16 = "0123456789012345"; public static final String EncryptIV16 = "0123456789012345";
public static final String APP_ID = "gingersoft1008611"; public static final String APP_ID = "gingersoft1008611";
// public static final String UPLOAD_LOG_URL = HttpsConstans.HTTP_ADDRESS_URL_HK+ "/logan-web/logan/upload.json"; // public static final String UPLOAD_LOG_URL = HttpsConstans.HTTP_ADDRESS_URL_HK+ "/logan-web/logan/upload.json";
public static String UPLOAD_LOG_URL = "http://192.168.1.131:8080/logan-web/logan/upload.json"; public static String UPLOAD_LOG_URL = "https://hktest.ricepon.com:64377/logan-web/logan/upload.json";
/** /**
* 日誌保留天數 * 日誌保留天數
......
package com.gingersoft.gsa.cloud.common.printer.plugins;
import android.graphics.Bitmap;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.annotations.NonNull;
import io.reactivex.annotations.Nullable;
import io.reactivex.functions.Consumer;
/**
* @作者: bin
* @創建時間: 2021-01-25 9:46
* @更新時間: 2021-01-25 9:46
* @描述:
*/
public class PrinterFlowProxy {
private static volatile PrinterFlowProxy sPrinterPlugins = null;
private ArrayList<PrinterFlowListener> mPrinterFlowListeners = new ArrayList<>();
@Nullable
private Consumer<? super Throwable> errorHandler;
private PrinterFlowProxy() {
}
public static PrinterFlowProxy newInstance() {
if (sPrinterPlugins == null) {
synchronized (PrinterFlowProxy.class) {
if (sPrinterPlugins == null) {
sPrinterPlugins = new PrinterFlowProxy();
}
}
}
return sPrinterPlugins;
}
public void onError(@NonNull Throwable error) {
Consumer<? super Throwable> f = errorHandler;
if (error == null) {
error = new NullPointerException("onError called with null");
}
if (f != null) {
try {
f.accept(error);
return;
} catch (Throwable e) {
e.printStackTrace();
uncaught(e);
}
}
error.printStackTrace();
uncaught(error);
}
void uncaught(@NonNull Throwable error) {
Thread currentThread = Thread.currentThread();
Thread.UncaughtExceptionHandler handler = currentThread.getUncaughtExceptionHandler();
handler.uncaughtException(currentThread, error);
}
public void setErrorHandler(Consumer<? super Throwable> errorHandler) {
this.errorHandler = errorHandler;
}
public void registerPrinterFlowListener(PrinterFlowListener listener) {
mPrinterFlowListeners.add(listener);
}
public void unregisterPrinterFlowListener(PrinterFlowListener listener) {
mPrinterFlowListeners.remove(listener);
}
public void dispatchPrinterDataBefore(int orderType, int printType, String printerData, String printerDeviceInfo) {
Object[] listeners = collectPrinterFlowListener();
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
((PrinterFlowListener) listeners[i]).onPrinterDataBefore(orderType, printType, printerData, printerDeviceInfo);
}
}
}
public void dispatchPrinterBitmapBefore(int orderType, int printType, String directoryName, List<Bitmap> bitmaps) {
Object[] listeners = collectPrinterFlowListener();
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
((PrinterFlowListener) listeners[i]).onPrinterBitmapBefore(orderType, printType, directoryName, bitmaps);
}
}
}
public void dispatchPrintSuccess() {
Object[] listeners = collectPrinterFlowListener();
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
((PrinterFlowListener) listeners[i]).onPrintSuccess();
}
}
}
public void dispatchPrintError(Exception e, int errorCode) {
Object[] listeners = collectPrinterFlowListener();
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
((PrinterFlowListener) listeners[i]).onPrintError(e, errorCode);
}
}
}
public void dispatchConnectionBefore(String deviceName, String IP, int port, long ioTimeout, long printTimeout) {
Object[] listeners = collectPrinterFlowListener();
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
((PrinterFlowListener) listeners[i]).connectionBefore(deviceName, IP, port, ioTimeout, printTimeout);
}
}
}
public void dispatchConnectionSuccess() {
Object[] listeners = collectPrinterFlowListener();
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
((PrinterFlowListener) listeners[i]).connectionSuccess();
}
}
}
public void dispatchConnectionError(Exception e) {
Object[] listeners = collectPrinterFlowListener();
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
((PrinterFlowListener) listeners[i]).connectionError(e);
}
}
}
public void dispatchDisconnect(Exception e) {
Object[] listeners = collectPrinterFlowListener();
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
((PrinterFlowListener) listeners[i]).disconnect(e);
}
}
}
private Object[] collectPrinterFlowListener() {
Object[] listeners = null;
synchronized (mPrinterFlowListeners) {
if (mPrinterFlowListeners.size() > 0) {
listeners = mPrinterFlowListeners.toArray();
}
}
return listeners;
}
}
package com.gingersoft.gsa.cloud.common.printer.plugins;
import io.reactivex.annotations.NonNull;
import io.reactivex.annotations.Nullable;
import io.reactivex.functions.Consumer;
/**
* @作者: bin
* @創建時間: 2021-01-25 9:46
* @更新時間: 2021-01-25 9:46
* @描述:
*/
public class PrinterPlugins {
@Nullable
static volatile Consumer<? super Throwable> errorHandler;
@Nullable
static volatile PrinterFlowListener onPrinterFlowHandler;
public static void onError(@NonNull Throwable error) {
Consumer<? super Throwable> f = errorHandler;
if (error == null) {
error = new NullPointerException("onError called with null");
}
if (f != null) {
try {
f.accept(error);
return;
} catch (Throwable e) {
e.printStackTrace();
uncaught(e);
}
}
error.printStackTrace();
uncaught(error);
}
static void uncaught(@NonNull Throwable error) {
Thread currentThread = Thread.currentThread();
Thread.UncaughtExceptionHandler handler = currentThread.getUncaughtExceptionHandler();
handler.uncaughtException(currentThread, error);
}
public static void setErrorHandler(Consumer<? super Throwable> errorHandler) {
PrinterPlugins.errorHandler = errorHandler;
}
public static PrinterFlowListener getOnPrinterFlowHandler() {
if (onPrinterFlowHandler == null) {
new NullPointerException("onPrinterFlowHandler called with null");
}
return onPrinterFlowHandler;
}
public static void setOnPrinterFlowHandler(PrinterFlowListener onPrinterFlowHandler) {
PrinterPlugins.onPrinterFlowHandler = onPrinterFlowHandler;
}
}
...@@ -2,7 +2,7 @@ package com.gingersoft.gsa.cloud.print; ...@@ -2,7 +2,7 @@ package com.gingersoft.gsa.cloud.print;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans; import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.logan.LoganManager; import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterFlowProxy;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import java.io.IOException; import java.io.IOException;
...@@ -62,7 +62,7 @@ public class PrintSocketHolder { ...@@ -62,7 +62,7 @@ public class PrintSocketHolder {
return ERROR_9; return ERROR_9;
} }
try { try {
PrinterPlugins.getOnPrinterFlowHandler().connectionBefore("網絡打印機", ip, port, PrintConstans.SO_TIMEOUT, PrintConstans.PRINT_TIMEOUT); PrinterFlowProxy.newInstance().dispatchConnectionBefore("網絡打印機", ip, port, PrintConstans.SO_TIMEOUT, PrintConstans.PRINT_TIMEOUT);
socket = new Socket(); socket = new Socket();
//建立連接 //建立連接
InetSocketAddress socketAddress = new InetSocketAddress(ip, port); InetSocketAddress socketAddress = new InetSocketAddress(ip, port);
...@@ -79,7 +79,7 @@ public class PrintSocketHolder { ...@@ -79,7 +79,7 @@ public class PrintSocketHolder {
return ERROR_7; return ERROR_7;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
PrinterPlugins.getOnPrinterFlowHandler().connectionError(e); PrinterFlowProxy.newInstance().dispatchConnectionError(e);
return ERROR_7; return ERROR_7;
} catch (Exception e) { } catch (Exception e) {
closeSocket(); closeSocket();
...@@ -97,7 +97,7 @@ public class PrintSocketHolder { ...@@ -97,7 +97,7 @@ public class PrintSocketHolder {
} catch (IOException e) { } catch (IOException e) {
LoganManager.w_printer(TAG, "獲取打印機輸入流異常: " + socket.getInetAddress() + e.getMessage()); LoganManager.w_printer(TAG, "獲取打印機輸入流異常: " + socket.getInetAddress() + e.getMessage());
closeSocket(); closeSocket();
PrinterPlugins.getOnPrinterFlowHandler().connectionError(e); PrinterFlowProxy.newInstance().dispatchConnectionError(e);
return ERROR_10; return ERROR_10;
} }
return ERROR_0; return ERROR_0;
...@@ -127,7 +127,7 @@ public class PrintSocketHolder { ...@@ -127,7 +127,7 @@ public class PrintSocketHolder {
out.flush(); out.flush();
} catch (IOException | NullPointerException e) { } catch (IOException | NullPointerException e) {
LoganManager.w_printer(TAG, "打印prj寫入數據异常: " + e.getMessage()); LoganManager.w_printer(TAG, "打印prj寫入數據异常: " + e.getMessage());
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(e, ERROR_10); PrinterFlowProxy.newInstance().dispatchPrintError(e, ERROR_10);
closeSocket(); closeSocket();
return ERROR_10; return ERROR_10;
} }
...@@ -147,9 +147,9 @@ public class PrintSocketHolder { ...@@ -147,9 +147,9 @@ public class PrintSocketHolder {
//獲取打印機寫入 //獲取打印機寫入
int result = getOutputStream(); int result = getOutputStream();
if (result == ERROR_0) { if (result == ERROR_0) {
PrinterPlugins.getOnPrinterFlowHandler().connectionSuccess(); PrinterFlowProxy.newInstance().dispatchConnectionSuccess();
} else { } else {
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new Exception("失敗")); PrinterFlowProxy.newInstance().dispatchConnectionError(new Exception("失敗"));
} }
return result; return result;
} }
...@@ -182,7 +182,7 @@ public class PrintSocketHolder { ...@@ -182,7 +182,7 @@ public class PrintSocketHolder {
socket = null; socket = null;
error = true; error = true;
} }
PrinterPlugins.getOnPrinterFlowHandler().disconnect(null); PrinterFlowProxy.newInstance().dispatchDisconnect(null);
return error ? ERROR_66 : ERROR_0; return error ? ERROR_66 : ERROR_0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment