Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supplier
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王宇航
supplier
Commits
19f0450f
Commit
19f0450f
authored
Mar 05, 2021
by
Wyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合併代碼、修改打印回調
parent
6781f282
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
64 deletions
+41
-64
component-print/src/main/java/com/joe/print/mvp/print/EpsonPrint.java
+9
-7
component-print/src/main/java/com/joe/print/mvp/print/PrinterRoot.java
+9
-9
component-print/src/main/java/com/joe/print/mvp/print/service/PrjService.java
+3
-1
component-print/src/main/java/com/joe/print/mvp/print/utils/BBposPrint.java
+3
-3
component-print/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
+15
-43
library-print/src/main/java/com/gingersoft/gsa/cloud/print/PrintSocketHolder.java
+2
-1
No files found.
component-print/src/main/java/com/joe/print/mvp/print/EpsonPrint.java
View file @
19f0450f
...
...
@@ -10,7 +10,7 @@ import com.epson.epos2.printer.Printer;
import
com.epson.epos2.printer.PrinterStatusInfo
;
import
com.epson.epos2.printer.ReceiveListener
;
import
com.gingersoft.gsa.cloud.common.logan.LoganManager
;
import
com.gingersoft.gsa.cloud.common.printer.plugins.Printer
Plugins
;
import
com.gingersoft.gsa.cloud.common.printer.plugins.Printer
FlowProxy
;
import
com.gingersoft.gsa.cloud.common.utils.log.LogUtil
;
import
com.gingersoft.gsa.cloud.print.PrintExecutor
;
import
com.gingersoft.gsa.cloud.print.PrintSocketHolder
;
...
...
@@ -285,7 +285,7 @@ public class EpsonPrint implements ReceiveListener {
prjIds
.
add
(
foodId
);
if
(
isPrint
)
{
LogUtil
.
d
(
"eee"
,
"prj針式打印機隊列中,前面還有"
+
bitmaps
.
size
()
+
"個任務"
);
Printer
Plugins
.
getOnPrinterFlowHandler
().
c
onnectionBefore
(
"針式打印機隊列中,前面還有"
+
bitmaps
.
size
()
+
"個任務"
,
ip
,
0
,
0
,
0
);
Printer
FlowProxy
.
newInstance
().
dispatchC
onnectionBefore
(
"針式打印機隊列中,前面還有"
+
bitmaps
.
size
()
+
"個任務"
,
ip
,
0
,
0
,
0
);
return
;
}
isPrint
=
true
;
...
...
@@ -293,7 +293,8 @@ public class EpsonPrint implements ReceiveListener {
}
private
void
printData
(
String
ip
,
String
ids
,
Bitmap
bitmap
)
{
PrinterPlugins
.
getOnPrinterFlowHandler
().
onPrinterDataBefore
(
0
,
0
,
"針式打印機"
,
ip
);
PrinterFlowProxy
.
newInstance
().
dispatchPrinterDataBefore
(
0
,
0
,
"針式打印機"
,
ip
);
mPrinter
.
clearCommandBuffer
();
LogUtil
.
d
(
"eee"
,
"prj針式打印機創建數據中,任務數:"
+
bitmaps
.
size
());
if
(!
createPrintData
(
bitmap
))
{
LogUtil
.
d
(
"eee"
,
"prj針式打印機創建數據失敗"
);
...
...
@@ -324,7 +325,7 @@ public class EpsonPrint implements ReceiveListener {
}
try
{
mPrinter
.
sendData
(
SEND_DATA_TIMEOUT
);
Printer
Plugins
.
getOnPrinterFlowHandler
().
on
PrintSuccess
();
Printer
FlowProxy
.
newInstance
().
dispatch
PrintSuccess
();
LogUtil
.
d
(
"eee"
,
"prj針式打印機打印成功"
+
",任務數:"
+
bitmaps
.
size
());
}
catch
(
Exception
e
)
{
LogUtil
.
d
(
"eee"
,
"prj針式打印機打印失敗"
+
",任務數:"
+
bitmaps
.
size
()
+
e
.
getMessage
());
...
...
@@ -342,7 +343,7 @@ public class EpsonPrint implements ReceiveListener {
private
void
printErrorProcess
(
String
ids
,
Bitmap
bitmap
,
Exception
e
,
int
errorCode
)
{
bitmaps
.
remove
(
bitmap
);
prjIds
.
remove
(
ids
);
Printer
Plugins
.
getOnPrinterFlowHandler
().
c
onnectionError
(
e
);
Printer
FlowProxy
.
newInstance
().
dispatchC
onnectionError
(
e
);
updatePrintState
(
ids
,
errorCode
);
isPrint
=
false
;
isExecutionNextTask
();
...
...
@@ -405,10 +406,11 @@ public class EpsonPrint implements ReceiveListener {
LoganManager
.
w_printer
(
TAG
,
"連接打印機報錯:"
+
e
.
getMessage
());
disconnectPrinter
();
finalizeObject
();
PrinterPlugins
.
getOnPrinterFlowHandler
().
connectionError
(
e
);
PrinterFlowProxy
.
newInstance
().
dispatchConnectionError
(
e
);
return
false
;
}
Printer
Plugins
.
getOnPrinterFlowHandler
().
c
onnectionSuccess
();
Printer
FlowProxy
.
newInstance
().
dispatchC
onnectionSuccess
();
return
true
;
}
...
...
component-print/src/main/java/com/joe/print/mvp/print/PrinterRoot.java
View file @
19f0450f
...
...
@@ -28,6 +28,7 @@ import com.epson.epos2.printer.PrinterStatusInfo;
import
com.epson.epos2.printer.ReceiveListener
;
import
com.gingersoft.gsa.cloud.app.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.common.constans.AppConstans
;
import
com.gingersoft.gsa.cloud.common.constans.DeliveryPickConstans
;
import
com.gingersoft.gsa.cloud.common.constans.ExpandConstant
;
import
com.gingersoft.gsa.cloud.common.constans.PrintConstans
;
import
com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails
;
...
...
@@ -35,10 +36,9 @@ 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.logan.LoganManager
;
import
com.gingersoft.gsa.cloud.common.printer.AidlUtil
;
import
com.gingersoft.gsa.cloud.common.printer.plugins.Printer
Plugins
;
import
com.gingersoft.gsa.cloud.common.utils.
gson.GsonUtils
;
import
com.gingersoft.gsa.cloud.common.printer.plugins.Printer
FlowProxy
;
import
com.gingersoft.gsa.cloud.common.utils.
log.LogUtil
;
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.view.ImageUtils
;
import
com.gingersoft.gsa.cloud.common.utils.view.LayoutToBitmapUtils
;
...
...
@@ -55,6 +55,7 @@ import com.gingersoft.gsa.cloud.print.bean.UpdateBean;
import
com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem
;
import
com.gingersoft.gsa.cloud.print.bean.base.PrintFoodItem
;
import
com.gingersoft.gsa.cloud.print.bean.base.PrintPayTypeItem
;
import
com.gingersoft.gsa.cloud.print.impl.OnPrjPrintResultListener
;
import
com.google.zxing.WriterException
;
import
com.hyweb.n5.lib.constant.PrinterConstant
;
import
com.hyweb.n5.lib.util.PrinterUtil
;
...
...
@@ -477,7 +478,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintExecut
public
void
onResult
(
int
errorCode
)
{
switch
(
errorCode
)
{
case
PrintSocketHolder
.
ERROR_0
:
Printer
Plugins
.
getOnPrinterFlowHandler
().
on
PrintSuccess
();
Printer
FlowProxy
.
newInstance
().
dispatch
PrintSuccess
();
printSuccess
();
return
;
case
PrintSocketHolder
.
ERROR_6
:
...
...
@@ -525,22 +526,21 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintExecut
}
private
void
printSuccess
()
{
Printer
Plugins
.
getOnPrinterFlowHandler
().
on
PrintSuccess
();
Printer
FlowProxy
.
newInstance
().
dispatch
PrintSuccess
();
}
private
void
printFailure
(
String
msg
,
int
code
)
{
Printer
Plugins
.
getOnPrinterFlowHandler
().
on
PrintError
(
new
Exception
(
msg
),
code
);
Printer
FlowProxy
.
newInstance
().
dispatch
PrintError
(
new
Exception
(
msg
),
code
);
}
private
void
printConnectError
(
String
msg
)
{
Printer
Plugins
.
getOnPrinterFlowHandler
().
c
onnectionError
(
new
Exception
(
msg
));
Printer
FlowProxy
.
newInstance
().
dispatchC
onnectionError
(
new
Exception
(
msg
));
}
private
void
printDisconnect
(
String
msg
)
{
Printer
Plugins
.
getOnPrinterFlowHandler
().
d
isconnect
(
new
Exception
(
msg
));
Printer
FlowProxy
.
newInstance
().
dispatchD
isconnect
(
new
Exception
(
msg
));
}
public
View
getLine
(
Context
mContext
)
{
TextView
textView
=
new
TextView
(
mContext
);
textView
.
setMaxLines
(
1
);
...
...
component-print/src/main/java/com/joe/print/mvp/print/service/PrjService.java
View file @
19f0450f
...
...
@@ -15,6 +15,7 @@ import androidx.annotation.Nullable;
import
com.epson.epos2.printer.Printer
;
import
com.epson.epos2.printer.PrinterStatusInfo
;
import
com.epson.epos2.printer.ReceiveListener
;
import
com.gingersoft.gsa.cloud.common.bean.BaseResult
;
import
com.gingersoft.gsa.cloud.common.constans.HttpsConstans
;
import
com.gingersoft.gsa.cloud.common.constans.PrintConstans
;
import
com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager
;
...
...
@@ -54,6 +55,7 @@ import com.joe.print.mvp.print.utils.MyPrintUtils;
import
com.sunmi.peripheral.printer.InnerResultCallbcak
;
import
com.xuexiang.rxutil2.rxjava.RxJavaUtils
;
import
org.jetbrains.annotations.NotNull
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
...
...
@@ -392,7 +394,7 @@ public class PrjService extends Service implements ReceiveListener {
if
(
beans
!=
null
&&
beans
.
size
()
>
0
)
{
orderType
=
beans
.
get
(
0
).
getOrderType
();
}
else
{
Printer
Plugins
.
getOnPrinterFlowHandler
().
on
PrintError
(
new
Exception
(
"prj解析數據為空:"
+
GsonUtils
.
GsonString
(
beans
)),
UpdateBean
.
FAIL_PRINT_BY_NOT_PRINT_INFO
);
Printer
FlowProxy
.
newInstance
().
dispatch
PrintError
(
new
Exception
(
"prj解析數據為空:"
+
GsonUtils
.
GsonString
(
beans
)),
UpdateBean
.
FAIL_PRINT_BY_NOT_PRINT_INFO
);
return
;
}
PrinterFlowProxy
.
newInstance
().
dispatchPrinterDataBefore
(
orderType
,
PrintConstans
.
PRINT_KITCHEN
,
GsonUtils
.
GsonString
(
beans
),
GsonUtils
.
GsonString
(
printerDeviceBean
));
...
...
component-print/src/main/java/com/joe/print/mvp/print/utils/BBposPrint.java
View file @
19f0450f
...
...
@@ -5,7 +5,7 @@ import android.text.TextUtils;
import
android.util.Xml
;
import
com.gingersoft.gsa.cloud.app.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.common.printer.plugins.Printer
Plugins
;
import
com.gingersoft.gsa.cloud.common.printer.plugins.Printer
FlowProxy
;
import
com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils
;
import
com.joe.print.mvp.ui.activity.PrintActivity
;
...
...
@@ -287,11 +287,11 @@ public class BBposPrint {
}
private
void
printSuccess
()
{
Printer
Plugins
.
getOnPrinterFlowHandler
().
on
PrintSuccess
();
Printer
FlowProxy
.
newInstance
().
dispatch
PrintSuccess
();
}
private
void
printFailure
(
String
msg
,
int
code
)
{
Printer
Plugins
.
getOnPrinterFlowHandler
().
on
PrintError
(
new
Exception
(
msg
),
code
);
Printer
FlowProxy
.
newInstance
().
dispatch
PrintError
(
new
Exception
(
msg
),
code
);
}
}
component-print/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
View file @
19f0450f
package
com
.
joe
.
print
.
mvp
.
ui
.
activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.os.Build
;
...
...
@@ -16,32 +13,27 @@ import androidx.annotation.Nullable;
import
com.billy.cc.core.component.CC
;
import
com.billy.cc.core.component.CCResult
;
import
com.billy.cc.core.component.CCUtil
;
import
com.gingersoft.gsa.cloud.app.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.common.constans.PrintConstans
;
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.Printer
Plugins
;
import
com.gingersoft.gsa.cloud.common.printer.plugins.Printer
FlowProxy
;
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.TextUtil
;
import
com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean
;
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.PrintSocketHolder
;
import
com.gingersoft.gsa.cloud.print.bean.PrintContent
;
import
com.gingersoft.gsa.cloud.print.bean.PrjBean
;
import
com.jess.arms.base.BaseActivity
;
import
com.jess.arms.di.component.AppComponent
;
import
com.jess.arms.integration.AppManager
;
import
com.jess.arms.utils.ArmsUtils
;
import
com.joe.print.di.component.DaggerPrintComponent
;
import
com.joe.print.mvp.contract.PrintContract
;
import
com.joe.print.mvp.presenter.PrintPresenter
;
import
com.joe.print.mvp.print.EpsonPrint
;
import
com.joe.print.mvp.print.PrintInstruction
;
import
com.joe.print.mvp.print.PrintListener
;
import
com.joe.print.mvp.print.PrintPrjKitchen
;
import
com.joe.print.mvp.print.PrinterRoot
;
import
com.joe.print.mvp.print.maker.OpenCashBoxMaker
;
...
...
@@ -50,16 +42,8 @@ import com.joe.print.mvp.ui.view.PrinterLoadingDialog;
import
com.joe.print.mvp.ui.view.SelectPrintDevicePopup
;
import
com.lxj.xpopup.XPopup
;
import
java.net.ConnectException
;
import
java.util.List
;
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_OTHER_CLOSING
;
...
...
@@ -144,8 +128,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override
public
void
connectionError
(
Exception
e
)
{
printerResult
=
false
;
printerLoadingDialog
.
setStep
(
PrinterLoadingDialog
.
PROGRESS_PRINTING
,
PrinterLoadingDialog
.
STATUS_ERROR
,
e
.
getMessage
());
printFail
();
}
@Override
...
...
@@ -171,18 +155,22 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override
public
void
onPrintError
(
Exception
e
,
int
errorCode
)
{
printerResult
=
false
;
printerLoadingDialog
.
setStep
(
PrinterLoadingDialog
.
PROGRESS_RESULT
,
PrinterLoadingDialog
.
STATUS_ERROR
,
e
.
getMessage
());
//延遲兩秒關閉
RxJavaUtils
.
delay
(
2
,
aLong
->
{
LogUtil
.
e
(
"eee"
,
"打印失敗"
);
CC
.
sendCCResult
(
callId
,
CCResult
.
error
(
"print error"
));
killMyself
();
});
printFail
();
}
});
}
private
void
printFail
()
{
printerResult
=
false
;
//延遲兩秒關閉
// RxJavaUtils.delay(2, aLong -> {
// LogUtil.e("eee", "打印失敗");
// CC.sendCCResult(callId, CCResult.error("print error"));
// killMyself();
// });
}
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
super
.
onNewIntent
(
intent
);
...
...
@@ -239,8 +227,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
private
void
initPrintConfig
(
PrintContent
printContent
)
{
//開始
PrinterPlugins
.
getOnPrinterFlowHandler
().
dispatchPrinterDataBefore
(
type
,
type
,
GsonUtils
.
GsonString
(
printContent
),
GsonUtils
.
GsonString
(
defaultPrint
));
PrinterFlowProxy
.
newInstance
().
dispatchPrinterDataBefore
(
type
,
type
,
GsonUtils
.
GsonString
(
printContent
),
GsonUtils
.
GsonString
(
defaultPrint
));
//獲取通用打印配置
...
...
@@ -292,7 +278,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
//如果彈窗已經關閉,打印機還是為空,說明用戶沒有選擇打印機
if
(
this
.
defaultPrint
==
null
)
{
printFailure
(
"沒有找到打印機,無法打印"
);
PrinterPlugins
.
getOnPrinterFlowHandler
().
onPrintError
(
new
Exception
(
"沒有找到打印機,無法打印"
),
UpdateBean
.
FAIL_PRINT_BY_NOT_FIND_DEVICE
);
}
});
new
XPopup
.
Builder
(
mContext
).
asCustom
(
selectPrintDevicePopup
).
show
();
...
...
@@ -457,28 +442,15 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
// addPrintProgress(tip);
// }
//
// /**
// * 打印成功
// */
// @Override
public
void
printSuccess
()
{
LoganManager
.
w_printer
(
TAG
,
"printFailure 打印成功"
);
killMyself
();
CC
.
sendCCResult
(
callId
,
CCResult
.
success
());
}
//
// @Override
public
void
printFailure
(
String
msg
)
{
LogUtil
.
d
(
"PrinterLoadingDialog"
,
"printFailure"
);
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
msg
))
{
PrinterPlugins
.
getOnPrinterFlowHandler
().
onPrintError
(
new
Exception
(
msg
),
0
);
ToastUtils
.
show
(
GsaCloudApplication
.
getAppContext
(),
msg
);
CC
.
sendCCResult
(
callId
,
CCResult
.
error
(
msg
));
}
else
{
CC
.
sendCCResult
(
callId
,
CCResult
.
error
(
"print error"
));
PrinterPlugins
.
getOnPrinterFlowHandler
().
onPrintError
(
new
Exception
(
"print error"
),
0
);
}
PrinterFlowProxy
.
newInstance
().
dispatchPrintError
(
new
Exception
(
msg
),
0
);
}
@Override
...
...
library-print/src/main/java/com/gingersoft/gsa/cloud/print/PrintSocketHolder.java
View file @
19f0450f
...
...
@@ -2,7 +2,8 @@ package com.gingersoft.gsa.cloud.print;
import
com.gingersoft.gsa.cloud.common.constans.PrintConstans
;
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.log.LogUtil
;
import
com.gingersoft.gsa.cloud.common.utils.other.TextUtil
;
import
java.io.IOException
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment