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
6bdf3095
Commit
6bdf3095
authored
Jul 29, 2020
by
Wyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
7.29 1.心跳斷開提示圖標和聲音 2.獲取不到訂單時提示音 3.出現問題推送給相應人員 4.每日營業報表打印功能
Signed-off-by: Wyh <1239658231>
parent
183a3d74
Show whitespace changes
Inline
Side-by-side
Showing
81 changed files
with
2324 additions
and
731 deletions
+2324
-731
base-module/build.gradle
+2
-2
base-module/src/main/java/com/gingersoft/gsa/cloud/base/adapter/print/FoodAdapter.java
+74
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/base/application/GsaCloudApplication.java
+15
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/base/common/bean/OrderDetail.java
+83
-2
base-module/src/main/java/com/gingersoft/gsa/cloud/base/common/bean/TableBean.java
+159
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/base/common/bean/TableExtBean.java
+86
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/base/utils/AidlUtil.java
+8
-8
base-module/src/main/java/com/gingersoft/gsa/cloud/base/utils/okhttpUtils/OkHttp3Utils.java
+4
-4
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/AppConstans.java
+4
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/HttpsConstans.java
+1
-1
base-module/src/main/java/com/gingersoft/gsa/cloud/database/bean/PrinterDeviceBean.java
+23
-2
base-module/src/main/java/com/gingersoft/gsa/cloud/database/greendao/PrinterDeviceBeanDao.java
+54
-42
base-module/src/main/java/com/gingersoft/gsa/cloud/globalconfig/applyOptions/intercept/LoggingInterceptor.java
+1
-3
base-module/src/main/java/com/gingersoft/gsa/cloud/print/PrintDataMaker.java
+2
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/print/PrintExecutor.java
+18
-9
base-module/src/main/java/com/gingersoft/gsa/cloud/print/PrinterWriter.java
+11
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/print/bean/OrderDetails.kt
+6
-0
base-module/src/main/res/drawable-xhdpi/ic_heart_disconnect.png
+0
-0
base-module/src/main/res/layout/base_print_bill_adapter_item_bill.xml
+2
-0
base-module/src/main/res/layout/include_horizontal_color_black_one_dividing_line.xml
+6
-0
base-module/src/main/res/layout/include_vertical_color_black_one_dividing_line.xml
+7
-0
base-module/src/main/res/layout/print_item_food.xml
+2
-4
base-module/src/main/res/values/ids.xml
+3
-0
config.gradle
+2
-2
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/model/bean/BusinessBean.java
+1
-0
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/presenter/BusinessReportPresenter.java
+1
-1
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/activity/NewMainActivity.java
+4
-4
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/adapter/BusinessInfoAdapter.java
+4
-2
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/fragment/BusinessReportFragment.java
+62
-6
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/view/DividerGridItemDecoration.java
+147
-0
main-module/src/main/res/layout/fragment_business_report.xml
+40
-9
main-module/src/main/res/layout/layout_print_business.xml
+28
-0
main-module/src/main/res/layout/report_business_info_item.xml
+2
-4
main-module/src/main/res/layout/report_business_info_item_print.xml
+50
-0
main-module/src/main/res/layout/report_business_info_item_two.xml
+47
-0
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/WeatherRepository.kt
+17
-1
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/CoolWeatherNetwork.kt
+9
-0
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/ServiceCreator.kt
+3
-1
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/api/AppService.kt
+13
-0
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/api/WeatherService.kt
+3
-0
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/model/viewModel/PageViewModel.kt
+25
-11
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/service/GetInfoUpdateService.kt
+51
-83
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/activity/OrderDetailsActivity.kt
+26
-16
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/activity/OtherOrderActivity.kt
+14
-52
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/fragment/PlaceholderFragment.kt
+0
-59
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/util/OtherOrderUtils.kt
+61
-0
other_order_mode/src/main/res/layout/activity_other_order.xml
+2
-2
other_order_mode/src/main/res/layout/layout_order_receiving.xml
+2
-1
other_order_mode/src/main/res/raw/raw_disconnect.m4a
+0
-0
other_order_mode/src/main/res/raw/raw_get_order_list_error.m4a
+0
-0
print-module/src/main/java/com/joe/print/mvp/model/bean/PrintInfoBean.java
+14
-42
print-module/src/main/java/com/joe/print/mvp/model/bean/PrjBean.java
+1
-1
print-module/src/main/java/com/joe/print/mvp/presenter/PrintPresenter.java
+0
-6
print-module/src/main/java/com/joe/print/mvp/print/EpsonPrint.java
+10
-39
print-module/src/main/java/com/joe/print/mvp/print/IpPrintMaker.java
+9
-2
print-module/src/main/java/com/joe/print/mvp/print/OpenCashBoxMaker.java
+5
-0
print-module/src/main/java/com/joe/print/mvp/print/PrintBill.java
+4
-2
print-module/src/main/java/com/joe/print/mvp/print/PrintCleanMachine.java
+3
-3
print-module/src/main/java/com/joe/print/mvp/print/PrintOtherOrder.java
+59
-1
print-module/src/main/java/com/joe/print/mvp/print/PrintOtherOrderClosing.java
+3
-3
print-module/src/main/java/com/joe/print/mvp/print/PrintPrjKitchen.java
+8
-2
print-module/src/main/java/com/joe/print/mvp/print/PrinterRoot.java
+223
-77
print-module/src/main/java/com/joe/print/mvp/print/PrjPrintCallbackListener.java
+5
-0
print-module/src/main/java/com/joe/print/mvp/print/SendPrint.java
+5
-0
print-module/src/main/java/com/joe/print/mvp/print/TestPrintMaker.java
+5
-0
print-module/src/main/java/com/joe/print/mvp/print/maker/PrjPrintMaker.java
+51
-0
print-module/src/main/java/com/joe/print/mvp/print/service/PrjService.java
+472
-127
print-module/src/main/java/com/joe/print/mvp/print/utils/MyPrintUtils.java
+30
-1
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
+17
-68
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrinterAddActivity.java
+1
-1
print-module/src/main/res/layout/print_bill_adapter_item_bill.xml
+2
-0
print-module/src/main/res/layout/print_model_takeaway_member_integer_info.xml
+56
-0
print-module/src/main/res/layout/print_model_takeaway_order_info.xml
+84
-0
print-module/src/main/res/layout/print_model_takeaway_total_amount.xml
+26
-0
print-module/src/main/res/layout/print_model_text_line.xml
+35
-0
print-module/src/main/res/layout/print_model_textview.xml
+5
-0
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/contract/OrderContentContract.java
+1
-1
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/model/OrderContentModel.java
+1
-1
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/OrderContentPresenter.java
+0
-12
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/OrderPayPresenter.java
+0
-6
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/activity/MealStandActivity.java
+4
-5
No files found.
base-module/build.gradle
View file @
6bdf3095
...
@@ -100,13 +100,13 @@ dependencies {
...
@@ -100,13 +100,13 @@ dependencies {
api
'cn.yipianfengye.android:zxing-library:2.2'
api
'cn.yipianfengye.android:zxing-library:2.2'
// // 斜角标签
// // 斜角标签
// api 'com.github.poqiao:BeveLabelView:1.0.3'
// api 'com.github.poqiao:BeveLabelView:1.0.3'
compile
"androidx.core:core-ktx:+"
api
"androidx.core:core-ktx:+"
implementation
'org.projectlombok:lombok:1.18.8'
implementation
'org.projectlombok:lombok:1.18.8'
annotationProcessor
'org.projectlombok:lombok:1.18.8'
annotationProcessor
'org.projectlombok:lombok:1.18.8'
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api
"com.github.huangyanbin:SmartTable:2.2.0"
}
}
repositories
{
repositories
{
mavenCentral
()
mavenCentral
()
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/base/adapter/print/FoodAdapter.java
View file @
6bdf3095
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
adapter
.
print
;
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
adapter
.
print
;
import
android.graphics.Typeface
;
import
android.text.TextPaint
;
import
android.text.style.StyleSpan
;
import
android.widget.TextView
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.gingersoft.gsa.cloud.base.R
;
import
com.gingersoft.gsa.cloud.base.R
;
import
com.gingersoft.gsa.cloud.base.common.bean.OrderDetail
;
import
com.gingersoft.gsa.cloud.base.common.bean.OrderDetail
;
import
com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean
;
import
com.qmuiteam.qmui.util.QMUIDisplayHelper
;
import
java.util.List
;
import
java.util.List
;
...
@@ -14,21 +21,88 @@ import java.util.List;
...
@@ -14,21 +21,88 @@ import java.util.List;
*/
*/
public
class
FoodAdapter
extends
BaseQuickAdapter
<
OrderDetail
,
BaseViewHolder
>
{
public
class
FoodAdapter
extends
BaseQuickAdapter
<
OrderDetail
,
BaseViewHolder
>
{
private
int
foodFontSize
=
24
;
private
int
modifierFontSize
=
24
;
private
int
foodIsBold
=
2
;
private
int
modifierIsBold
=
2
;
private
int
foodIsItalic
=
2
;
private
int
modifierIsItalic
=
2
;
private
int
numberIsFlip
=
2
;
//熱敏打印沒有顏色,翻轉用不了
public
FoodAdapter
(
@Nullable
List
<
OrderDetail
>
data
,
PrinterDeviceBean
deviceBean
)
{
super
(
R
.
layout
.
print_item_food
,
data
);
try
{
this
.
foodFontSize
=
Integer
.
parseInt
(
deviceBean
.
getFoodFont
())
*
2
;
this
.
modifierFontSize
=
Integer
.
parseInt
(
deviceBean
.
getModifierFont
())
*
2
;
}
catch
(
NumberFormatException
e
)
{
e
.
printStackTrace
();
}
this
.
foodIsBold
=
deviceBean
.
getFoodIsBold
();
this
.
modifierIsBold
=
deviceBean
.
getModifierIsBold
();
this
.
foodIsItalic
=
deviceBean
.
getFoodIsItalic
();
this
.
modifierIsItalic
=
deviceBean
.
getModifierIsItalic
();
this
.
numberIsFlip
=
deviceBean
.
getNumberIsFlip
();
}
public
FoodAdapter
(
@Nullable
List
<
OrderDetail
>
data
)
{
public
FoodAdapter
(
@Nullable
List
<
OrderDetail
>
data
)
{
super
(
R
.
layout
.
print_item_food
,
data
);
super
(
R
.
layout
.
print_item_food
,
data
);
}
}
@Override
@Override
protected
void
convert
(
BaseViewHolder
helper
,
OrderDetail
item
)
{
protected
void
convert
(
BaseViewHolder
helper
,
OrderDetail
item
)
{
TextView
tvFoodName
=
helper
.
getView
(
R
.
id
.
tv_food_name
);
TextView
tvNum
=
helper
.
getView
(
R
.
id
.
tv_food_quantity
);
TextView
tvPrice
=
helper
.
getView
(
R
.
id
.
tv_food_price
);
boolean
isBold
,
isItalic
;
if
(
item
.
getItemType
()
==
2
)
{
if
(
item
.
getItemType
()
==
2
)
{
//細項,縮進
//細項,縮進
helper
.
setText
(
R
.
id
.
tv_food_name
,
"\u3000"
+
item
.
getProductName
());
helper
.
setText
(
R
.
id
.
tv_food_name
,
"\u3000"
+
item
.
getProductName
());
tvFoodName
.
setTextSize
(
modifierFontSize
);
tvNum
.
setTextSize
(
modifierFontSize
);
tvPrice
.
setTextSize
(
modifierFontSize
);
isBold
=
modifierIsBold
==
1
;
isItalic
=
modifierIsItalic
==
1
;
}
else
if
(
item
.
getItemType
()
==
3
)
{
}
else
if
(
item
.
getItemType
()
==
3
)
{
//細項,縮進
//細項,縮進
helper
.
setText
(
R
.
id
.
tv_food_name
,
"\u3000\u3000"
+
item
.
getProductName
());
helper
.
setText
(
R
.
id
.
tv_food_name
,
"\u3000\u3000"
+
item
.
getProductName
());
tvFoodName
.
setTextSize
(
modifierFontSize
);
tvNum
.
setTextSize
(
modifierFontSize
);
tvPrice
.
setTextSize
(
modifierFontSize
);
isBold
=
modifierIsBold
==
1
;
isItalic
=
modifierIsItalic
==
1
;
}
else
{
}
else
{
helper
.
setText
(
R
.
id
.
tv_food_name
,
item
.
getProductName
());
helper
.
setText
(
R
.
id
.
tv_food_name
,
item
.
getProductName
());
tvFoodName
.
setTextSize
(
foodFontSize
);
tvNum
.
setTextSize
(
foodFontSize
);
tvPrice
.
setTextSize
(
foodFontSize
);
isBold
=
foodIsBold
==
1
;
isItalic
=
foodIsItalic
==
1
;
}
if
(
isBold
&&
isItalic
)
{
tvFoodName
.
setTypeface
(
null
,
Typeface
.
BOLD_ITALIC
);
tvNum
.
setTypeface
(
null
,
Typeface
.
BOLD_ITALIC
);
tvPrice
.
setTypeface
(
null
,
Typeface
.
BOLD_ITALIC
);
}
else
if
(
isBold
)
{
tvFoodName
.
setTypeface
(
null
,
Typeface
.
BOLD
);
tvNum
.
setTypeface
(
null
,
Typeface
.
BOLD
);
tvPrice
.
setTypeface
(
null
,
Typeface
.
BOLD
);
}
else
if
(
isItalic
)
{
tvFoodName
.
setTypeface
(
null
,
Typeface
.
ITALIC
);
tvNum
.
setTypeface
(
null
,
Typeface
.
ITALIC
);
tvPrice
.
setTypeface
(
null
,
Typeface
.
ITALIC
);
}
else
{
tvFoodName
.
setTypeface
(
null
,
Typeface
.
NORMAL
);
tvNum
.
setTypeface
(
null
,
Typeface
.
NORMAL
);
tvPrice
.
setTypeface
(
null
,
Typeface
.
NORMAL
);
}
}
// tvFoodName.setTypeface(null, Typeface.BOLD_ITALIC);
// tvFoodName.setTypeface(null, Typeface.BOLD);
// tvFoodName.setTypeface(null, Typeface.ITALIC);
// tvFoodName.setTypeface(null, Typeface.NORMAL);
helper
.
setText
(
R
.
id
.
tv_food_quantity
,
String
.
valueOf
(
item
.
getNumber
()));
helper
.
setText
(
R
.
id
.
tv_food_quantity
,
String
.
valueOf
(
item
.
getNumber
()));
helper
.
setText
(
R
.
id
.
tv_food_price
,
"$"
+
item
.
getPrice
());
helper
.
setText
(
R
.
id
.
tv_food_price
,
"$"
+
item
.
getPrice
());
}
}
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/base/application/GsaCloudApplication.java
View file @
6bdf3095
...
@@ -2,6 +2,8 @@ package com.gingersoft.gsa.cloud.base.application;
...
@@ -2,6 +2,8 @@ package com.gingersoft.gsa.cloud.base.application;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.content.res.Configuration
;
import
android.content.res.Configuration
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.RemoteException
;
import
android.os.RemoteException
;
...
@@ -377,6 +379,19 @@ public class GsaCloudApplication extends BaseApplication {
...
@@ -377,6 +379,19 @@ public class GsaCloudApplication extends BaseApplication {
return
(
String
)
SPUtils
.
get
(
context
,
UserConstans
.
gsPosShopId
,
""
);
return
(
String
)
SPUtils
.
get
(
context
,
UserConstans
.
gsPosShopId
,
""
);
}
}
public
static
String
getAppName
()
{
try
{
PackageManager
packageManager
=
mAppContext
.
getPackageManager
();
PackageInfo
packageInfo
=
packageManager
.
getPackageInfo
(
mAppContext
.
getPackageName
(),
0
);
int
labelRes
=
packageInfo
.
applicationInfo
.
labelRes
;
return
mAppContext
.
getResources
().
getString
(
labelRes
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
void
setLoginToken
(
Context
context
,
String
token
)
{
public
static
void
setLoginToken
(
Context
context
,
String
token
)
{
SPUtils
.
put
(
context
,
UserConstans
.
token
,
token
);
SPUtils
.
put
(
context
,
UserConstans
.
token
,
token
);
}
}
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/base/common/bean/OrderDetail.java
View file @
6bdf3095
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
common
.
bean
;
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
common
.
bean
;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage
;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
import
com.gingersoft.gsa.cloud.database.bean.ComboItem
;
import
com.gingersoft.gsa.cloud.database.bean.ComboItem
;
...
@@ -66,8 +69,10 @@ public class OrderDetail implements Serializable {
...
@@ -66,8 +69,10 @@ public class OrderDetail implements Serializable {
private
int
ComboLevel
=
0
;
private
int
ComboLevel
=
0
;
//套餐食品是否自動跟餐
//套餐食品是否自動跟餐
private
boolean
isComboAuto
=
false
;
private
boolean
isComboAuto
=
false
;
/**動態的最大選中數*/
/**
private
String
currentMaxNumber
=
""
;
* 動態的最大選中數
*/
private
String
currentMaxNumber
=
""
;
//"food" or "discount" or "modifiy"
//"food" or "discount" or "modifiy"
private
int
prop
=
FOOD_PROP
;
private
int
prop
=
FOOD_PROP
;
/**
/**
...
@@ -223,6 +228,7 @@ public class OrderDetail implements Serializable {
...
@@ -223,6 +228,7 @@ public class OrderDetail implements Serializable {
* 是否打印价格
* 是否打印价格
*/
*/
private
long
ktShowPrice
;
private
long
ktShowPrice
;
public
OrderDetail
()
{
public
OrderDetail
()
{
}
}
...
@@ -675,6 +681,81 @@ public class OrderDetail implements Serializable {
...
@@ -675,6 +681,81 @@ public class OrderDetail implements Serializable {
}
}
/**
/**
* @param type 是食品清單還是賬單 0清單 1賬單
* @param productnameBeans 訂單食品項
* @return
*/
public
static
List
<
OrderDetail
>
productMameBeanToOrderDetail
(
int
type
,
List
<
OrderDetails
.
DataBean
.
PRODUCTNAMEBean
>
productnameBeans
)
{
List
<
OrderDetail
>
orderDetailList
=
new
ArrayList
<>();
if
(
productnameBeans
!=
null
)
{
for
(
OrderDetails
.
DataBean
.
PRODUCTNAMEBean
productnameBean
:
productnameBeans
)
{
if
(!(
productnameBean
.
getPrintToBill
()
==
0
&&
Double
.
valueOf
(
productnameBean
.
getPRICE
())
==
0
)
||
isPrint
(
productnameBean
.
getPrintTo
(),
type
))
{
//食品金額不為0的不打印
//或者printTo成立
//打印
orderDetailList
.
add
(
getOrderDetailByProductnameBean
(
productnameBean
.
getPRODUCT_NAME
(),
Integer
.
parseInt
(
productnameBean
.
getNum
()),
Double
.
valueOf
(
productnameBean
.
getPRICE
()),
1
));
if
(
productnameBean
.
getChild
()
!=
null
)
{
for
(
OrderDetails
.
DataBean
.
PRODUCTNAMEBean
.
ChildBeanX
childBeanX
:
productnameBean
.
getChild
())
{
if
(
childBeanX
!=
null
)
{
orderDetailList
.
add
(
getOrderDetailByProductnameBean
(
childBeanX
.
getPRODUCT_NAME
(),
Integer
.
parseInt
(
childBeanX
.
getNum
()),
Double
.
valueOf
(
childBeanX
.
getPRICE
()),
2
));
if
(
childBeanX
.
getChild
()
!=
null
)
{
for
(
OrderDetails
.
DataBean
.
PRODUCTNAMEBean
.
ChildBeanX
.
ChildBean
childBean
:
childBeanX
.
getChild
())
{
orderDetailList
.
add
(
getOrderDetailByProductnameBean
(
childBean
.
getPRODUCT_NAME
(),
Integer
.
parseInt
(
childBean
.
getNum
()),
Double
.
valueOf
(
childBean
.
getPRICE
()),
3
));
}
}
}
}
}
}
}
}
return
orderDetailList
;
}
/**
* 是否打印
*
* @param printTo
* @param type
* @return
*/
private
static
boolean
isPrint
(
int
printTo
,
int
type
)
{
if
(
printTo
==
0
)
{
//清單和賬單都打印
return
true
;
}
else
if
(
printTo
==
1
)
{
//食品清单不打印 账单不打印
return
false
;
}
else
if
(
printTo
==
2
)
{
//食品清单打印 账单不打印
return
type
==
0
;
}
else
if
(
printTo
==
3
)
{
//食品清单不打印 账单打印
return
type
==
1
;
}
return
true
;
}
/**
* @param foodName
* @param foodNum
* @param foodPrice
* @param itemType 1主食品,2細項,3二級細項
* @return
*/
private
static
OrderDetail
getOrderDetailByProductnameBean
(
String
foodName
,
int
foodNum
,
double
foodPrice
,
int
itemType
)
{
OrderDetail
orderDetail
=
new
OrderDetail
();
orderDetail
.
setProductName
(
foodName
);
orderDetail
.
setNumber
(
foodNum
);
orderDetail
.
setPrice
(
foodPrice
);
orderDetail
.
setItemType
(
itemType
);
return
orderDetail
;
}
/**
* 已送單食品轉換
* 已送單食品轉換
*
*
* @param orderList
* @param orderList
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/base/common/bean/TableBean.java
View file @
6bdf3095
...
@@ -161,6 +161,165 @@ public class TableBean {
...
@@ -161,6 +161,165 @@ public class TableBean {
this
.
tableNumber
=
dataBean
.
tableNumber
;
this
.
tableNumber
=
dataBean
.
tableNumber
;
}
}
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getTableName
()
{
return
tableName
;
}
public
void
setTableName
(
String
tableName
)
{
this
.
tableName
=
tableName
;
}
public
int
getRestaurantId
()
{
return
restaurantId
;
}
public
void
setRestaurantId
(
int
restaurantId
)
{
this
.
restaurantId
=
restaurantId
;
}
public
Long
getOrderId
()
{
return
orderId
;
}
public
void
setOrderId
(
Long
orderId
)
{
this
.
orderId
=
orderId
;
}
public
String
getQrCode
()
{
return
qrCode
;
}
public
void
setQrCode
(
String
qrCode
)
{
this
.
qrCode
=
qrCode
;
}
public
int
getSeatCount
()
{
return
seatCount
;
}
public
void
setSeatCount
(
int
seatCount
)
{
this
.
seatCount
=
seatCount
;
}
public
Integer
getMaxSeatCount
()
{
return
maxSeatCount
;
}
public
void
setMaxSeatCount
(
Integer
maxSeatCount
)
{
this
.
maxSeatCount
=
maxSeatCount
;
}
public
Integer
getMinSeatCount
()
{
return
minSeatCount
;
}
public
void
setMinSeatCount
(
Integer
minSeatCount
)
{
this
.
minSeatCount
=
minSeatCount
;
}
public
String
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
String
createTime
)
{
this
.
createTime
=
createTime
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
;
}
public
String
getQrCodeImg
()
{
return
qrCodeImg
;
}
public
void
setQrCodeImg
(
String
qrCodeImg
)
{
this
.
qrCodeImg
=
qrCodeImg
;
}
public
int
getPosTableId
()
{
return
posTableId
;
}
public
void
setPosTableId
(
int
posTableId
)
{
this
.
posTableId
=
posTableId
;
}
public
long
getServiceCharge
()
{
return
serviceCharge
;
}
public
void
setServiceCharge
(
long
serviceCharge
)
{
this
.
serviceCharge
=
serviceCharge
;
}
public
long
getMemberId
()
{
return
memberId
;
}
public
void
setMemberId
(
long
memberId
)
{
this
.
memberId
=
memberId
;
}
public
int
getStatus
()
{
return
status
;
}
public
void
setStatus
(
int
status
)
{
this
.
status
=
status
;
}
public
int
getPerson
()
{
return
person
;
}
public
void
setPerson
(
int
person
)
{
this
.
person
=
person
;
}
public
int
getUseStatus
()
{
return
useStatus
;
}
public
void
setUseStatus
(
int
useStatus
)
{
this
.
useStatus
=
useStatus
;
}
public
int
getSort
()
{
return
sort
;
}
public
void
setSort
(
int
sort
)
{
this
.
sort
=
sort
;
}
public
int
getType
()
{
return
type
;
}
public
void
setType
(
int
type
)
{
this
.
type
=
type
;
}
public
String
getTableNumber
()
{
return
tableNumber
;
}
public
void
setTableNumber
(
String
tableNumber
)
{
this
.
tableNumber
=
tableNumber
;
}
}
}
public
static
TableBean
.
DataBean
splitTableTransformTable
(
TableBean
.
DataBean
mainTable
,
TableExtBean
.
DataBean
dataBean
)
{
public
static
TableBean
.
DataBean
splitTableTransformTable
(
TableBean
.
DataBean
mainTable
,
TableExtBean
.
DataBean
dataBean
)
{
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/base/common/bean/TableExtBean.java
View file @
6bdf3095
...
@@ -31,6 +31,92 @@ public class TableExtBean {
...
@@ -31,6 +31,92 @@ public class TableExtBean {
private
String
deviceName
;
private
String
deviceName
;
private
String
tableNumber
;
private
String
tableNumber
;
public
long
getId
()
{
return
id
;
}
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
long
getTableId
()
{
return
tableId
;
}
public
void
setTableId
(
long
tableId
)
{
this
.
tableId
=
tableId
;
}
public
long
getOrderId
()
{
return
orderId
;
}
public
void
setOrderId
(
long
orderId
)
{
this
.
orderId
=
orderId
;
}
public
int
getInUse
()
{
return
inUse
;
}
public
void
setInUse
(
int
inUse
)
{
this
.
inUse
=
inUse
;
}
public
int
getTableStatus
()
{
return
tableStatus
;
}
public
void
setTableStatus
(
int
tableStatus
)
{
this
.
tableStatus
=
tableStatus
;
}
public
long
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
long
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
long
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
long
createTime
)
{
this
.
createTime
=
createTime
;
}
public
String
getDeviceName
()
{
return
deviceName
;
}
public
void
setDeviceName
(
String
deviceName
)
{
this
.
deviceName
=
deviceName
;
}
public
String
getTableNumber
()
{
return
tableNumber
;
}
public
void
setTableNumber
(
String
tableNumber
)
{
this
.
tableNumber
=
tableNumber
;
}
}
public
TableBean
.
DataBean
getRestaurantTable
()
{
return
restaurantTable
;
}
public
void
setRestaurantTable
(
TableBean
.
DataBean
restaurantTable
)
{
this
.
restaurantTable
=
restaurantTable
;
}
public
List
<
DataBean
>
getRestaurantTableExtList
()
{
return
restaurantTableExtList
;
}
public
void
setRestaurantTableExtList
(
List
<
DataBean
>
restaurantTableExtList
)
{
this
.
restaurantTableExtList
=
restaurantTableExtList
;
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/base/utils/AidlUtil.java
View file @
6bdf3095
...
@@ -164,10 +164,10 @@ public class AidlUtil {
...
@@ -164,10 +164,10 @@ public class AidlUtil {
*打印图片
*打印图片
*/
*/
public
void
printBitmap
(
Bitmap
bitmap
,
InnerResultCallbcak
mInnerResultCallbcak
)
{
public
void
printBitmap
(
Bitmap
bitmap
,
InnerResultCallbcak
mInnerResultCallbcak
)
{
if
(
sunmiPrinterService
==
null
)
{
//
if (sunmiPrinterService == null) {
Toast
.
makeText
(
context
,
LanguageUtils
.
get_language_system
(
context
,
"server.disconnected"
,
"未連接上打印機!"
),
Toast
.
LENGTH_LONG
).
show
();
//
Toast.makeText(context, LanguageUtils.get_language_system(context, "server.disconnected", "未連接上打印機!"), Toast.LENGTH_LONG).show();
return
;
//
return;
}
//
}
try
{
try
{
sunmiPrinterService
.
setAlignment
(
1
,
null
);
sunmiPrinterService
.
setAlignment
(
1
,
null
);
...
@@ -182,10 +182,10 @@ public class AidlUtil {
...
@@ -182,10 +182,10 @@ public class AidlUtil {
*打印图片
*打印图片
*/
*/
public
void
printBitmaps
(
List
<
Bitmap
>
bitmaps
,
int
paperWidth
,
InnerResultCallbcak
mInnerResultCallbcak
)
{
public
void
printBitmaps
(
List
<
Bitmap
>
bitmaps
,
int
paperWidth
,
InnerResultCallbcak
mInnerResultCallbcak
)
{
if
(
sunmiPrinterService
==
null
)
{
//
if (sunmiPrinterService == null) {
Toast
.
makeText
(
context
,
LanguageUtils
.
get_language_system
(
context
,
"server.disconnected"
,
"未連接上打印機!"
),
Toast
.
LENGTH_LONG
).
show
();
//
Toast.makeText(context, LanguageUtils.get_language_system(context, "server.disconnected", "未連接上打印機!"), Toast.LENGTH_LONG).show();
return
;
//
return;
}
//
}
try
{
try
{
sunmiPrinterService
.
setAlignment
(
1
,
null
);
sunmiPrinterService
.
setAlignment
(
1
,
null
);
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/base/utils/okhttpUtils/OkHttp3Utils.java
View file @
6bdf3095
...
@@ -67,7 +67,7 @@ public class OkHttp3Utils {
...
@@ -67,7 +67,7 @@ public class OkHttp3Utils {
@Override
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
public
void
onFailure
(
Call
call
,
IOException
e
)
{
emitter
.
onError
(
e
);
//
emitter.onError(e);
emitter
.
onComplete
();
emitter
.
onComplete
();
call
.
cancel
();
call
.
cancel
();
}
}
...
@@ -95,7 +95,7 @@ public class OkHttp3Utils {
...
@@ -95,7 +95,7 @@ public class OkHttp3Utils {
@Override
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
public
void
onFailure
(
Call
call
,
IOException
e
)
{
emitter
.
onError
(
e
);
//
emitter.onError(e);
emitter
.
onComplete
();
emitter
.
onComplete
();
call
.
cancel
();
call
.
cancel
();
}
}
...
@@ -148,7 +148,7 @@ public class OkHttp3Utils {
...
@@ -148,7 +148,7 @@ public class OkHttp3Utils {
@Override
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
public
void
onFailure
(
Call
call
,
IOException
e
)
{
emitter
.
onError
(
e
);
//
emitter.onError(e);
emitter
.
onComplete
();
emitter
.
onComplete
();
call
.
cancel
();
call
.
cancel
();
}
}
...
@@ -200,7 +200,7 @@ public class OkHttp3Utils {
...
@@ -200,7 +200,7 @@ public class OkHttp3Utils {
@Override
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
public
void
onFailure
(
Call
call
,
IOException
e
)
{
emitter
.
onError
(
e
);
//
emitter.onError(e);
emitter
.
onComplete
();
emitter
.
onComplete
();
call
.
cancel
();
call
.
cancel
();
}
}
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/AppConstans.java
View file @
6bdf3095
...
@@ -5,6 +5,10 @@ package com.gingersoft.gsa.cloud.constans;
...
@@ -5,6 +5,10 @@ package com.gingersoft.gsa.cloud.constans;
*/
*/
public
class
AppConstans
{
public
class
AppConstans
{
public
static
final
String
RP_HEART_ERROR
=
"RP_HD"
;
//心跳斷開錯誤碼
public
static
final
String
RP_ORDER_LIST_ERROR
=
"RP_OL"
;
//訂單列表錯誤碼
public
static
final
String
SECRETKEY_VALUES
=
"2309485937845783"
;
public
static
final
String
SECRETKEY_VALUES
=
"2309485937845783"
;
public
static
final
String
APP_TYPE
=
"9"
;
public
static
final
String
APP_TYPE
=
"9"
;
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/HttpsConstans.java
View file @
6bdf3095
...
@@ -36,7 +36,7 @@ public class HttpsConstans {
...
@@ -36,7 +36,7 @@ public class HttpsConstans {
//--------------------------------------------其他全局----------------------------------------------------------------------------
//--------------------------------------------其他全局----------------------------------------------------------------------------
private
static
String
HTTP_ADDRESS_URL_FORMAL
=
"https://m.ricepon.com:8444"
;
//正式服務器
private
static
String
HTTP_ADDRESS_URL_FORMAL
=
"https://m.ricepon.com:8444"
;
//正式服務器
private
static
String
HTTP_ADDRESS_URL_SZ
=
"http://gingersoft.tpddns.cn:58201"
;
//深圳測試
private
static
String
HTTP_ADDRESS_URL_SZ
=
"http://gingersoft.tpddns.cn:58201"
;
//深圳測試
private
static
String
HTTP_ADDRESS_URL_HK
=
"http://a.ricepon.com:58201"
;
//香港測試
private
static
String
HTTP_ADDRESS_URL_HK
=
"http
s
://a.ricepon.com:58201"
;
//香港測試
private
static
String
PATH
=
"/ricepon-cloud-gsa/api/"
;
//路徑
private
static
String
PATH
=
"/ricepon-cloud-gsa/api/"
;
//路徑
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/database/bean/PrinterDeviceBean.java
View file @
6bdf3095
...
@@ -47,6 +47,10 @@ public class PrinterDeviceBean implements Serializable {
...
@@ -47,6 +47,10 @@ public class PrinterDeviceBean implements Serializable {
*/
*/
private
Long
flyPrinterDeviceId2
;
private
Long
flyPrinterDeviceId2
;
private
int
foodComplexion
;
//食品顔色 0 黑色 2 紅色
private
int
modifierComplexion
;
//細項顔色 0 黑色 2 紅色
private
int
foodIsBold
;
//食品是否加粗 0預設 1是 2否
private
int
foodIsBold
;
//食品是否加粗 0預設 1是 2否
private
String
foodFont
;
//食品字體大小 0預設
private
String
foodFont
;
//食品字體大小 0預設
...
@@ -72,8 +76,9 @@ public class PrinterDeviceBean implements Serializable {
...
@@ -72,8 +76,9 @@ public class PrinterDeviceBean implements Serializable {
this
.
paperSpecification
=
paperSpecification
;
this
.
paperSpecification
=
paperSpecification
;
}
}
@Generated
(
hash
=
23385471
)
@Generated
(
hash
=
1569426879
)
public
PrinterDeviceBean
(
Long
id
,
Long
dbid
,
String
name
,
Integer
restaurantId
,
String
ip
,
Long
uid
,
Integer
port
,
Integer
type
,
Long
printerModelId
,
String
paperSpecification
,
int
lineFontStop
,
String
printerName
,
String
model
,
String
noteContent
,
Long
printerDeviceDefaultId
,
int
printerDeviceType
,
Long
flyPrinterDeviceId
,
Long
flyPrinterDeviceId2
,
int
foodIsBold
,
String
foodFont
,
int
foodIsItalic
,
int
modifierIsBold
,
String
modifierFont
,
int
modifierIsItalic
,
int
numberIsFlip
)
{
public
PrinterDeviceBean
(
Long
id
,
Long
dbid
,
String
name
,
Integer
restaurantId
,
String
ip
,
Long
uid
,
Integer
port
,
Integer
type
,
Long
printerModelId
,
String
paperSpecification
,
int
lineFontStop
,
String
printerName
,
String
model
,
String
noteContent
,
Long
printerDeviceDefaultId
,
int
printerDeviceType
,
Long
flyPrinterDeviceId
,
Long
flyPrinterDeviceId2
,
int
foodComplexion
,
int
modifierComplexion
,
int
foodIsBold
,
String
foodFont
,
int
foodIsItalic
,
int
modifierIsBold
,
String
modifierFont
,
int
modifierIsItalic
,
int
numberIsFlip
)
{
this
.
id
=
id
;
this
.
id
=
id
;
this
.
dbid
=
dbid
;
this
.
dbid
=
dbid
;
this
.
name
=
name
;
this
.
name
=
name
;
...
@@ -92,6 +97,8 @@ public class PrinterDeviceBean implements Serializable {
...
@@ -92,6 +97,8 @@ public class PrinterDeviceBean implements Serializable {
this
.
printerDeviceType
=
printerDeviceType
;
this
.
printerDeviceType
=
printerDeviceType
;
this
.
flyPrinterDeviceId
=
flyPrinterDeviceId
;
this
.
flyPrinterDeviceId
=
flyPrinterDeviceId
;
this
.
flyPrinterDeviceId2
=
flyPrinterDeviceId2
;
this
.
flyPrinterDeviceId2
=
flyPrinterDeviceId2
;
this
.
foodComplexion
=
foodComplexion
;
this
.
modifierComplexion
=
modifierComplexion
;
this
.
foodIsBold
=
foodIsBold
;
this
.
foodIsBold
=
foodIsBold
;
this
.
foodFont
=
foodFont
;
this
.
foodFont
=
foodFont
;
this
.
foodIsItalic
=
foodIsItalic
;
this
.
foodIsItalic
=
foodIsItalic
;
...
@@ -308,5 +315,19 @@ public class PrinterDeviceBean implements Serializable {
...
@@ -308,5 +315,19 @@ public class PrinterDeviceBean implements Serializable {
this
.
printerDeviceType
=
printerDeviceType
;
this
.
printerDeviceType
=
printerDeviceType
;
}
}
public
int
getFoodComplexion
()
{
return
foodComplexion
;
}
public
void
setFoodComplexion
(
int
foodComplexion
)
{
this
.
foodComplexion
=
foodComplexion
;
}
public
int
getModifierComplexion
()
{
return
modifierComplexion
;
}
public
void
setModifierComplexion
(
int
modifierComplexion
)
{
this
.
modifierComplexion
=
modifierComplexion
;
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/database/greendao/PrinterDeviceBeanDao.java
View file @
6bdf3095
...
@@ -42,13 +42,15 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
...
@@ -42,13 +42,15 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
public
final
static
Property
PrinterDeviceType
=
new
Property
(
15
,
int
.
class
,
"printerDeviceType"
,
false
,
"PRINTER_DEVICE_TYPE"
);
public
final
static
Property
PrinterDeviceType
=
new
Property
(
15
,
int
.
class
,
"printerDeviceType"
,
false
,
"PRINTER_DEVICE_TYPE"
);
public
final
static
Property
FlyPrinterDeviceId
=
new
Property
(
16
,
Long
.
class
,
"flyPrinterDeviceId"
,
false
,
"FLY_PRINTER_DEVICE_ID"
);
public
final
static
Property
FlyPrinterDeviceId
=
new
Property
(
16
,
Long
.
class
,
"flyPrinterDeviceId"
,
false
,
"FLY_PRINTER_DEVICE_ID"
);
public
final
static
Property
FlyPrinterDeviceId2
=
new
Property
(
17
,
Long
.
class
,
"flyPrinterDeviceId2"
,
false
,
"FLY_PRINTER_DEVICE_ID2"
);
public
final
static
Property
FlyPrinterDeviceId2
=
new
Property
(
17
,
Long
.
class
,
"flyPrinterDeviceId2"
,
false
,
"FLY_PRINTER_DEVICE_ID2"
);
public
final
static
Property
FoodIsBold
=
new
Property
(
18
,
int
.
class
,
"foodIsBold"
,
false
,
"FOOD_IS_BOLD"
);
public
final
static
Property
FoodComplexion
=
new
Property
(
18
,
int
.
class
,
"foodComplexion"
,
false
,
"FOOD_COMPLEXION"
);
public
final
static
Property
FoodFont
=
new
Property
(
19
,
String
.
class
,
"foodFont"
,
false
,
"FOOD_FONT"
);
public
final
static
Property
ModifierComplexion
=
new
Property
(
19
,
int
.
class
,
"modifierComplexion"
,
false
,
"MODIFIER_COMPLEXION"
);
public
final
static
Property
FoodIsItalic
=
new
Property
(
20
,
int
.
class
,
"foodIsItalic"
,
false
,
"FOOD_IS_ITALIC"
);
public
final
static
Property
FoodIsBold
=
new
Property
(
20
,
int
.
class
,
"foodIsBold"
,
false
,
"FOOD_IS_BOLD"
);
public
final
static
Property
ModifierIsBold
=
new
Property
(
21
,
int
.
class
,
"modifierIsBold"
,
false
,
"MODIFIER_IS_BOLD"
);
public
final
static
Property
FoodFont
=
new
Property
(
21
,
String
.
class
,
"foodFont"
,
false
,
"FOOD_FONT"
);
public
final
static
Property
ModifierFont
=
new
Property
(
22
,
String
.
class
,
"modifierFont"
,
false
,
"MODIFIER_FONT"
);
public
final
static
Property
FoodIsItalic
=
new
Property
(
22
,
int
.
class
,
"foodIsItalic"
,
false
,
"FOOD_IS_ITALIC"
);
public
final
static
Property
ModifierIsItalic
=
new
Property
(
23
,
int
.
class
,
"modifierIsItalic"
,
false
,
"MODIFIER_IS_ITALIC"
);
public
final
static
Property
ModifierIsBold
=
new
Property
(
23
,
int
.
class
,
"modifierIsBold"
,
false
,
"MODIFIER_IS_BOLD"
);
public
final
static
Property
NumberIsFlip
=
new
Property
(
24
,
int
.
class
,
"numberIsFlip"
,
false
,
"NUMBER_IS_FLIP"
);
public
final
static
Property
ModifierFont
=
new
Property
(
24
,
String
.
class
,
"modifierFont"
,
false
,
"MODIFIER_FONT"
);
public
final
static
Property
ModifierIsItalic
=
new
Property
(
25
,
int
.
class
,
"modifierIsItalic"
,
false
,
"MODIFIER_IS_ITALIC"
);
public
final
static
Property
NumberIsFlip
=
new
Property
(
26
,
int
.
class
,
"numberIsFlip"
,
false
,
"NUMBER_IS_FLIP"
);
}
}
...
@@ -82,13 +84,15 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
...
@@ -82,13 +84,15 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
"\"PRINTER_DEVICE_TYPE\" INTEGER NOT NULL ,"
+
// 15: printerDeviceType
"\"PRINTER_DEVICE_TYPE\" INTEGER NOT NULL ,"
+
// 15: printerDeviceType
"\"FLY_PRINTER_DEVICE_ID\" INTEGER,"
+
// 16: flyPrinterDeviceId
"\"FLY_PRINTER_DEVICE_ID\" INTEGER,"
+
// 16: flyPrinterDeviceId
"\"FLY_PRINTER_DEVICE_ID2\" INTEGER,"
+
// 17: flyPrinterDeviceId2
"\"FLY_PRINTER_DEVICE_ID2\" INTEGER,"
+
// 17: flyPrinterDeviceId2
"\"FOOD_IS_BOLD\" INTEGER NOT NULL ,"
+
// 18: foodIsBold
"\"FOOD_COMPLEXION\" INTEGER NOT NULL ,"
+
// 18: foodComplexion
"\"FOOD_FONT\" TEXT,"
+
// 19: foodFont
"\"MODIFIER_COMPLEXION\" INTEGER NOT NULL ,"
+
// 19: modifierComplexion
"\"FOOD_IS_ITALIC\" INTEGER NOT NULL ,"
+
// 20: foodIsItalic
"\"FOOD_IS_BOLD\" INTEGER NOT NULL ,"
+
// 20: foodIsBold
"\"MODIFIER_IS_BOLD\" INTEGER NOT NULL ,"
+
// 21: modifierIsBold
"\"FOOD_FONT\" TEXT,"
+
// 21: foodFont
"\"MODIFIER_FONT\" TEXT,"
+
// 22: modifierFont
"\"FOOD_IS_ITALIC\" INTEGER NOT NULL ,"
+
// 22: foodIsItalic
"\"MODIFIER_IS_ITALIC\" INTEGER NOT NULL ,"
+
// 23: modifierIsItalic
"\"MODIFIER_IS_BOLD\" INTEGER NOT NULL ,"
+
// 23: modifierIsBold
"\"NUMBER_IS_FLIP\" INTEGER NOT NULL );"
);
// 24: numberIsFlip
"\"MODIFIER_FONT\" TEXT,"
+
// 24: modifierFont
"\"MODIFIER_IS_ITALIC\" INTEGER NOT NULL ,"
+
// 25: modifierIsItalic
"\"NUMBER_IS_FLIP\" INTEGER NOT NULL );"
);
// 26: numberIsFlip
}
}
/** Drops the underlying database table. */
/** Drops the underlying database table. */
...
@@ -182,21 +186,23 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
...
@@ -182,21 +186,23 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
if
(
flyPrinterDeviceId2
!=
null
)
{
if
(
flyPrinterDeviceId2
!=
null
)
{
stmt
.
bindLong
(
18
,
flyPrinterDeviceId2
);
stmt
.
bindLong
(
18
,
flyPrinterDeviceId2
);
}
}
stmt
.
bindLong
(
19
,
entity
.
getFoodIsBold
());
stmt
.
bindLong
(
19
,
entity
.
getFoodComplexion
());
stmt
.
bindLong
(
20
,
entity
.
getModifierComplexion
());
stmt
.
bindLong
(
21
,
entity
.
getFoodIsBold
());
String
foodFont
=
entity
.
getFoodFont
();
String
foodFont
=
entity
.
getFoodFont
();
if
(
foodFont
!=
null
)
{
if
(
foodFont
!=
null
)
{
stmt
.
bindString
(
2
0
,
foodFont
);
stmt
.
bindString
(
2
2
,
foodFont
);
}
}
stmt
.
bindLong
(
2
1
,
entity
.
getFoodIsItalic
());
stmt
.
bindLong
(
2
3
,
entity
.
getFoodIsItalic
());
stmt
.
bindLong
(
2
2
,
entity
.
getModifierIsBold
());
stmt
.
bindLong
(
2
4
,
entity
.
getModifierIsBold
());
String
modifierFont
=
entity
.
getModifierFont
();
String
modifierFont
=
entity
.
getModifierFont
();
if
(
modifierFont
!=
null
)
{
if
(
modifierFont
!=
null
)
{
stmt
.
bindString
(
2
3
,
modifierFont
);
stmt
.
bindString
(
2
5
,
modifierFont
);
}
}
stmt
.
bindLong
(
2
4
,
entity
.
getModifierIsItalic
());
stmt
.
bindLong
(
2
6
,
entity
.
getModifierIsItalic
());
stmt
.
bindLong
(
2
5
,
entity
.
getNumberIsFlip
());
stmt
.
bindLong
(
2
7
,
entity
.
getNumberIsFlip
());
}
}
@Override
@Override
...
@@ -284,21 +290,23 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
...
@@ -284,21 +290,23 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
if
(
flyPrinterDeviceId2
!=
null
)
{
if
(
flyPrinterDeviceId2
!=
null
)
{
stmt
.
bindLong
(
18
,
flyPrinterDeviceId2
);
stmt
.
bindLong
(
18
,
flyPrinterDeviceId2
);
}
}
stmt
.
bindLong
(
19
,
entity
.
getFoodIsBold
());
stmt
.
bindLong
(
19
,
entity
.
getFoodComplexion
());
stmt
.
bindLong
(
20
,
entity
.
getModifierComplexion
());
stmt
.
bindLong
(
21
,
entity
.
getFoodIsBold
());
String
foodFont
=
entity
.
getFoodFont
();
String
foodFont
=
entity
.
getFoodFont
();
if
(
foodFont
!=
null
)
{
if
(
foodFont
!=
null
)
{
stmt
.
bindString
(
2
0
,
foodFont
);
stmt
.
bindString
(
2
2
,
foodFont
);
}
}
stmt
.
bindLong
(
2
1
,
entity
.
getFoodIsItalic
());
stmt
.
bindLong
(
2
3
,
entity
.
getFoodIsItalic
());
stmt
.
bindLong
(
2
2
,
entity
.
getModifierIsBold
());
stmt
.
bindLong
(
2
4
,
entity
.
getModifierIsBold
());
String
modifierFont
=
entity
.
getModifierFont
();
String
modifierFont
=
entity
.
getModifierFont
();
if
(
modifierFont
!=
null
)
{
if
(
modifierFont
!=
null
)
{
stmt
.
bindString
(
2
3
,
modifierFont
);
stmt
.
bindString
(
2
5
,
modifierFont
);
}
}
stmt
.
bindLong
(
2
4
,
entity
.
getModifierIsItalic
());
stmt
.
bindLong
(
2
6
,
entity
.
getModifierIsItalic
());
stmt
.
bindLong
(
2
5
,
entity
.
getNumberIsFlip
());
stmt
.
bindLong
(
2
7
,
entity
.
getNumberIsFlip
());
}
}
@Override
@Override
...
@@ -327,13 +335,15 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
...
@@ -327,13 +335,15 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
cursor
.
getInt
(
offset
+
15
),
// printerDeviceType
cursor
.
getInt
(
offset
+
15
),
// printerDeviceType
cursor
.
isNull
(
offset
+
16
)
?
null
:
cursor
.
getLong
(
offset
+
16
),
// flyPrinterDeviceId
cursor
.
isNull
(
offset
+
16
)
?
null
:
cursor
.
getLong
(
offset
+
16
),
// flyPrinterDeviceId
cursor
.
isNull
(
offset
+
17
)
?
null
:
cursor
.
getLong
(
offset
+
17
),
// flyPrinterDeviceId2
cursor
.
isNull
(
offset
+
17
)
?
null
:
cursor
.
getLong
(
offset
+
17
),
// flyPrinterDeviceId2
cursor
.
getInt
(
offset
+
18
),
// foodIsBold
cursor
.
getInt
(
offset
+
18
),
// foodComplexion
cursor
.
isNull
(
offset
+
19
)
?
null
:
cursor
.
getString
(
offset
+
19
),
// foodFont
cursor
.
getInt
(
offset
+
19
),
// modifierComplexion
cursor
.
getInt
(
offset
+
20
),
// foodIsItalic
cursor
.
getInt
(
offset
+
20
),
// foodIsBold
cursor
.
getInt
(
offset
+
21
),
// modifierIsBold
cursor
.
isNull
(
offset
+
21
)
?
null
:
cursor
.
getString
(
offset
+
21
),
// foodFont
cursor
.
isNull
(
offset
+
22
)
?
null
:
cursor
.
getString
(
offset
+
22
),
// modifierFont
cursor
.
getInt
(
offset
+
22
),
// foodIsItalic
cursor
.
getInt
(
offset
+
23
),
// modifierIsItalic
cursor
.
getInt
(
offset
+
23
),
// modifierIsBold
cursor
.
getInt
(
offset
+
24
)
// numberIsFlip
cursor
.
isNull
(
offset
+
24
)
?
null
:
cursor
.
getString
(
offset
+
24
),
// modifierFont
cursor
.
getInt
(
offset
+
25
),
// modifierIsItalic
cursor
.
getInt
(
offset
+
26
)
// numberIsFlip
);
);
return
entity
;
return
entity
;
}
}
...
@@ -358,13 +368,15 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
...
@@ -358,13 +368,15 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
entity
.
setPrinterDeviceType
(
cursor
.
getInt
(
offset
+
15
));
entity
.
setPrinterDeviceType
(
cursor
.
getInt
(
offset
+
15
));
entity
.
setFlyPrinterDeviceId
(
cursor
.
isNull
(
offset
+
16
)
?
null
:
cursor
.
getLong
(
offset
+
16
));
entity
.
setFlyPrinterDeviceId
(
cursor
.
isNull
(
offset
+
16
)
?
null
:
cursor
.
getLong
(
offset
+
16
));
entity
.
setFlyPrinterDeviceId2
(
cursor
.
isNull
(
offset
+
17
)
?
null
:
cursor
.
getLong
(
offset
+
17
));
entity
.
setFlyPrinterDeviceId2
(
cursor
.
isNull
(
offset
+
17
)
?
null
:
cursor
.
getLong
(
offset
+
17
));
entity
.
setFoodIsBold
(
cursor
.
getInt
(
offset
+
18
));
entity
.
setFoodComplexion
(
cursor
.
getInt
(
offset
+
18
));
entity
.
setFoodFont
(
cursor
.
isNull
(
offset
+
19
)
?
null
:
cursor
.
getString
(
offset
+
19
));
entity
.
setModifierComplexion
(
cursor
.
getInt
(
offset
+
19
));
entity
.
setFoodIsItalic
(
cursor
.
getInt
(
offset
+
20
));
entity
.
setFoodIsBold
(
cursor
.
getInt
(
offset
+
20
));
entity
.
setModifierIsBold
(
cursor
.
getInt
(
offset
+
21
));
entity
.
setFoodFont
(
cursor
.
isNull
(
offset
+
21
)
?
null
:
cursor
.
getString
(
offset
+
21
));
entity
.
setModifierFont
(
cursor
.
isNull
(
offset
+
22
)
?
null
:
cursor
.
getString
(
offset
+
22
));
entity
.
setFoodIsItalic
(
cursor
.
getInt
(
offset
+
22
));
entity
.
setModifierIsItalic
(
cursor
.
getInt
(
offset
+
23
));
entity
.
setModifierIsBold
(
cursor
.
getInt
(
offset
+
23
));
entity
.
setNumberIsFlip
(
cursor
.
getInt
(
offset
+
24
));
entity
.
setModifierFont
(
cursor
.
isNull
(
offset
+
24
)
?
null
:
cursor
.
getString
(
offset
+
24
));
entity
.
setModifierIsItalic
(
cursor
.
getInt
(
offset
+
25
));
entity
.
setNumberIsFlip
(
cursor
.
getInt
(
offset
+
26
));
}
}
@Override
@Override
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/globalconfig/applyOptions/intercept/LoggingInterceptor.java
View file @
6bdf3095
package
com
.
gingersoft
.
gsa
.
cloud
.
globalconfig
.
applyOptions
.
intercept
;
package
com
.
gingersoft
.
gsa
.
cloud
.
globalconfig
.
applyOptions
.
intercept
;
import
android.util.Log
;
import
com.gingersoft.gsa.cloud.base.utils.log.LogUtil
;
import
com.gingersoft.gsa.cloud.base.utils.log.LogUtil
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -15,7 +13,7 @@ import okhttp3.ResponseBody;
...
@@ -15,7 +13,7 @@ import okhttp3.ResponseBody;
public
class
LoggingInterceptor
implements
Interceptor
{
public
class
LoggingInterceptor
implements
Interceptor
{
@Override
@Override
public
Response
intercept
(
Chain
chain
)
throws
IOException
{
public
Response
intercept
(
Chain
chain
)
throws
IOException
,
NullPointerException
{
//这个chain里面包含了request和response,所以你要什么都可以从这里拿
//这个chain里面包含了request和response,所以你要什么都可以从这里拿
Request
request
=
chain
.
request
();
Request
request
=
chain
.
request
();
long
t1
=
System
.
nanoTime
();
//请求发起的时间
long
t1
=
System
.
nanoTime
();
//请求发起的时间
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/print/PrintDataMaker.java
View file @
6bdf3095
...
@@ -20,4 +20,6 @@ import java.util.List;
...
@@ -20,4 +20,6 @@ import java.util.List;
public
interface
PrintDataMaker
{
public
interface
PrintDataMaker
{
List
<
byte
[]>
getPrintData
();
List
<
byte
[]>
getPrintData
();
String
getPrjIds
();
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/print/PrintExecutor.java
View file @
6bdf3095
...
@@ -32,8 +32,10 @@ public class PrintExecutor {
...
@@ -32,8 +32,10 @@ public class PrintExecutor {
private
PrintSocketHolder
holder
;
private
PrintSocketHolder
holder
;
private
int
mReconnectTimes
=
0
;
private
int
mReconnectTimes
=
0
;
private
int
time
=
0
;
private
int
time
=
0
;
private
String
prjIds
;
private
PrintSocketHolder
.
OnStateChangedListener
listener
;
private
PrintSocketHolder
.
OnStateChangedListener
listener
;
private
OnPrintResultListener
mListener
;
private
OnPrintResultListener
mListener
;
private
OnPrjPrintResultListener
onPrjPrintResultListener
;
public
PrintExecutor
(
BluetoothDevice
device
)
{
public
PrintExecutor
(
BluetoothDevice
device
)
{
holder
=
new
PrintSocketHolder
(
device
);
holder
=
new
PrintSocketHolder
(
device
);
...
@@ -52,6 +54,7 @@ public class PrintExecutor {
...
@@ -52,6 +54,7 @@ public class PrintExecutor {
if
(
mReconnectTimes
==
0
)
{
if
(
mReconnectTimes
==
0
)
{
holder
.
onPrinterStateChanged
(
PrintSocketHolder
.
STATE_0
);
holder
.
onPrinterStateChanged
(
PrintSocketHolder
.
STATE_0
);
List
<
byte
[]>
data
=
maker
.
getPrintData
();
List
<
byte
[]>
data
=
maker
.
getPrintData
();
prjIds
=
maker
.
getPrjIds
();
if
(!
holder
.
isSocketPrepared
())
{
if
(!
holder
.
isSocketPrepared
())
{
int
prepare
=
holder
.
prepareSocket
();
int
prepare
=
holder
.
prepareSocket
();
if
(
prepare
!=
PrintSocketHolder
.
ERROR_0
)
if
(
prepare
!=
PrintSocketHolder
.
ERROR_0
)
...
@@ -61,6 +64,7 @@ public class PrintExecutor {
...
@@ -61,6 +64,7 @@ public class PrintExecutor {
}
else
{
}
else
{
holder
.
onPrinterStateChanged
(
PrintSocketHolder
.
STATE_0
);
holder
.
onPrinterStateChanged
(
PrintSocketHolder
.
STATE_0
);
List
<
byte
[]>
data
=
maker
.
getPrintData
();
List
<
byte
[]>
data
=
maker
.
getPrintData
();
prjIds
=
maker
.
getPrjIds
();
if
(
holder
.
isSocketPrepared
())
{
if
(
holder
.
isSocketPrepared
())
{
if
(
sendData
(
data
))
if
(
sendData
(
data
))
return
PrintSocketHolder
.
ERROR_0
;
return
PrintSocketHolder
.
ERROR_0
;
...
@@ -132,15 +136,6 @@ public class PrintExecutor {
...
@@ -132,15 +136,6 @@ public class PrintExecutor {
}
}
/**
/**
* 设置打印类型
*
* @param type 打印类型
*/
// public void setType(int type) {
// this.type = type;
// }
/**
* 设置状态监听
* 设置状态监听
*
*
* @param listener 监听
* @param listener 监听
...
@@ -171,6 +166,17 @@ public class PrintExecutor {
...
@@ -171,6 +166,17 @@ public class PrintExecutor {
void
onResult
(
int
errorCode
,
PrinterDeviceBean
printerDeviceBean
);
void
onResult
(
int
errorCode
,
PrinterDeviceBean
printerDeviceBean
);
}
}
/**
* PRJ打印結果回調
*/
public
interface
OnPrjPrintResultListener
{
void
onResult
(
int
errorCode
,
String
ids
);
}
public
void
setOnPrjPrintResultListener
(
OnPrjPrintResultListener
onPrjPrintResultListener
)
{
this
.
onPrjPrintResultListener
=
onPrjPrintResultListener
;
}
private
class
PrintTask
extends
AsyncTask
<
PrintDataMaker
,
Integer
,
Integer
>
implements
private
class
PrintTask
extends
AsyncTask
<
PrintDataMaker
,
Integer
,
Integer
>
implements
PrintSocketHolder
.
OnStateChangedListener
{
PrintSocketHolder
.
OnStateChangedListener
{
...
@@ -214,6 +220,9 @@ public class PrintExecutor {
...
@@ -214,6 +220,9 @@ public class PrintExecutor {
try
{
try
{
if
(
mListener
!=
null
)
if
(
mListener
!=
null
)
mListener
.
onResult
(
errorCode
,
holder
.
getPrinterDeviceBean
());
mListener
.
onResult
(
errorCode
,
holder
.
getPrinterDeviceBean
());
if
(
onPrjPrintResultListener
!=
null
){
onPrjPrintResultListener
.
onResult
(
errorCode
,
prjIds
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/print/PrinterWriter.java
View file @
6bdf3095
...
@@ -632,6 +632,17 @@ public abstract class PrinterWriter {
...
@@ -632,6 +632,17 @@ public abstract class PrinterWriter {
}
}
/**
/**
* 输出并换行
*
* @throws IOException 异常
*/
public
void
printLineFeed
(
int
n
)
throws
IOException
{
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
write
(
PrinterUtils
.
printLineFeed
());
}
}
/**
* 进纸切割
* 进纸切割
*
*
* @throws IOException 异常
* @throws IOException 异常
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/print/bean/OrderDetails.kt
View file @
6bdf3095
...
@@ -116,6 +116,12 @@ class OrderDetails {
...
@@ -116,6 +116,12 @@ class OrderDetails {
var
PRODUCT_NAME
:
String
?
=
null
var
PRODUCT_NAME
:
String
?
=
null
var
child
:
List
<
ChildBeanX
>?
=
null
var
child
:
List
<
ChildBeanX
>?
=
null
var
printseting
:
String
?
=
null
var
printseting
:
String
?
=
null
var
printToBill
:
Int
=
1
//當金額=0時,是否打印在賬單上 0 否 1 是
//0食品清单打印 账单打印
//1食品清单不打印 账单不打印
//2食品清单打印 账单不打印
//3食品清单不打印 账单打印
var
PrintTo
:
Int
=
0
class
ChildBeanX
:
Serializable
{
class
ChildBeanX
:
Serializable
{
/**
/**
...
...
base-module/src/main/res/drawable-xhdpi/ic_heart_disconnect.png
0 → 100644
View file @
6bdf3095
818 Bytes
base-module/src/main/res/layout/base_print_bill_adapter_item_bill.xml
View file @
6bdf3095
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"0.3"
android:layout_weight=
"0.3"
android:layout_gravity=
"bottom"
android:gravity=
"right"
android:gravity=
"right"
style=
"@style/Print_text_style"
/>
style=
"@style/Print_text_style"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
base-module/src/main/res/layout/include_horizontal_color_black_one_dividing_line.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<View
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/horizontal_dividing_line"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_1"
android:background=
"@color/black"
/>
base-module/src/main/res/layout/include_vertical_color_black_one_dividing_line.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<View
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/vertical_dividing_line"
android:layout_width=
"@dimen/dp_1"
android:layout_height=
"match_parent"
android:background=
"@color/black"
android:orientation=
"vertical"
/>
base-module/src/main/res/layout/print_item_food.xml
View file @
6bdf3095
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
style=
"@style/Print_text_style"
style=
"@style/Print_text_style"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"0.5"
/>
android:layout_weight=
"0.5"
/>
<TextView
<TextView
...
@@ -19,7 +18,7 @@
...
@@ -19,7 +18,7 @@
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"0.2"
android:layout_weight=
"0.2"
android:layout_gravity=
"bottom"
android:gravity=
"right"
/>
android:gravity=
"right"
/>
<TextView
<TextView
...
@@ -27,7 +26,7 @@
...
@@ -27,7 +26,7 @@
style=
"@style/Print_text_style"
style=
"@style/Print_text_style"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:layout_weight=
"0.3"
android:layout_weight=
"0.3"
android:gravity=
"right"
/>
android:gravity=
"right"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
base-module/src/main/res/values/ids.xml
View file @
6bdf3095
...
@@ -23,4 +23,6 @@
...
@@ -23,4 +23,6 @@
<item
name=
"topbar_right_change_button"
type=
"id"
/>
<item
name=
"topbar_right_change_button"
type=
"id"
/>
<item
name=
"layout_for_test"
type=
"id"
/>
<item
name=
"layout_for_test"
type=
"id"
/>
<item
name=
"topbar_heart_disconnect"
type=
"id"
/>
</resources>
</resources>
\ No newline at end of file
config.gradle
View file @
6bdf3095
...
@@ -7,8 +7,8 @@ ext {
...
@@ -7,8 +7,8 @@ ext {
targetSdkVersion
:
28
,
targetSdkVersion
:
28
,
//正式版: 1.0.3 3
//正式版: 1.0.3 3
//內部測試版:1.1.7 17
//內部測試版:1.1.7 17
versionCode
:
1
7
,
versionCode
:
1
8
,
versionName
:
"1.1.
7
"
versionName
:
"1.1.
8
"
]
]
version
=
[
version
=
[
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/model/bean/BusinessBean.java
View file @
6bdf3095
...
@@ -4,6 +4,7 @@ package com.gingersoft.gsa.cloud.main.mvp.model.bean;
...
@@ -4,6 +4,7 @@ package com.gingersoft.gsa.cloud.main.mvp.model.bean;
* Created by Wyh on 2020/2/24.
* Created by Wyh on 2020/2/24.
*/
*/
public
class
BusinessBean
{
public
class
BusinessBean
{
private
String
projectName
;
private
String
projectName
;
private
String
amount
;
private
String
amount
;
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/presenter/BusinessReportPresenter.java
View file @
6bdf3095
...
@@ -118,7 +118,7 @@ public class BusinessReportPresenter extends BasePresenter<BusinessReportContrac
...
@@ -118,7 +118,7 @@ public class BusinessReportPresenter extends BasePresenter<BusinessReportContrac
});
});
}
}
private
String
[]
itemNames
=
new
String
[]{
"項目銷售總金額($)"
,
"折扣($)"
,
"服務費($)"
,
"賬單小數($)"
,
"簽單($)"
,
"營業金額淨值($)"
,
"貼士($)"
,
"堂食總金額數($)"
,
"外賣總金額數($)"
,
"單數"
,
"平均每單
($)"
,
"人數"
,
"平均每人
($)"
,
"送貨費($)"
,
"餐盒費($)"
};
private
String
[]
itemNames
=
new
String
[]{
"項目銷售總金額($)"
,
"折扣($)"
,
"服務費($)"
,
"賬單小數($)"
,
"簽單($)"
,
"營業金額淨值($)"
,
"貼士($)"
,
"堂食總金額數($)"
,
"外賣總金額數($)"
,
"單數"
,
"平均每單
消費金額($)"
,
"人數"
,
"平均每人消費金額
($)"
,
"送貨費($)"
,
"餐盒費($)"
};
private
void
loadAdapterInfo
(
BusinessDetailsBean
.
DataBean
dataBean
)
{
private
void
loadAdapterInfo
(
BusinessDetailsBean
.
DataBean
dataBean
)
{
//底部信息默認顯示今天的數據
//底部信息默認顯示今天的數據
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/activity/NewMainActivity.java
View file @
6bdf3095
...
@@ -253,9 +253,9 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
...
@@ -253,9 +253,9 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
functions
.
add
(
new
Function
((
long
)
138
,
150
,
5
,
"餐檯模式"
,
R
.
drawable
.
ic_dining_table_mode
,
0
));
functions
.
add
(
new
Function
((
long
)
138
,
150
,
5
,
"餐檯模式"
,
R
.
drawable
.
ic_dining_table_mode
,
0
));
}
}
functions
.
add
(
new
Function
((
long
)
139
,
150
,
5
,
"外送/自取"
,
R
.
drawable
.
ic_delivery_mode
,
0
));
functions
.
add
(
new
Function
((
long
)
139
,
150
,
5
,
"外送/自取"
,
R
.
drawable
.
ic_delivery_mode
,
0
));
functions
.
add
(
new
Function
((
long
)
140
,
150
,
5
,
"外賣模式"
,
R
.
drawable
.
ic_outsourcing_model_close
,
0
));
//
functions.add(new Function((long) 140, 150, 5, "外賣模式", R.drawable.ic_outsourcing_model_close, 0));
functions
.
add
(
new
Function
((
long
)
141
,
150
,
5
,
"預點餐模式"
,
R
.
drawable
.
ic_pre_order_mode_close
,
1
));
//
functions.add(new Function((long) 141, 150, 5, "預點餐模式", R.drawable.ic_pre_order_mode_close, 1));
if
(
BuildConfig
.
DEBUG
)
{
functions
.
add
(
new
Function
((
long
)
151
,
0
,
5
,
"管理"
,
0
,
0
));
functions
.
add
(
new
Function
((
long
)
151
,
0
,
5
,
"管理"
,
0
,
0
));
functions
.
add
(
new
Function
((
long
)
142
,
151
,
5
,
"賬單管理"
,
R
.
drawable
.
ic_meals_menu_management
,
0
));
functions
.
add
(
new
Function
((
long
)
142
,
151
,
5
,
"賬單管理"
,
R
.
drawable
.
ic_meals_menu_management
,
0
));
functions
.
add
(
new
Function
((
long
)
143
,
151
,
5
,
"餐檯管理"
,
R
.
drawable
.
ic_dining_table_management
,
0
));
functions
.
add
(
new
Function
((
long
)
143
,
151
,
5
,
"餐檯管理"
,
R
.
drawable
.
ic_dining_table_management
,
0
));
...
@@ -263,7 +263,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
...
@@ -263,7 +263,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
functions
.
add
(
new
Function
((
long
)
145
,
151
,
5
,
"支付管理"
,
R
.
drawable
.
ic_pay_management_close
,
1
));
functions
.
add
(
new
Function
((
long
)
145
,
151
,
5
,
"支付管理"
,
R
.
drawable
.
ic_pay_management_close
,
1
));
functions
.
add
(
new
Function
((
long
)
146
,
151
,
5
,
"折扣管理"
,
R
.
drawable
.
ic_discount_management_close
,
1
));
functions
.
add
(
new
Function
((
long
)
146
,
151
,
5
,
"折扣管理"
,
R
.
drawable
.
ic_discount_management_close
,
1
));
functions
.
add
(
new
Function
((
long
)
147
,
151
,
5
,
"沽清管理"
,
R
.
drawable
.
ic_sell_off_manger
,
0
));
functions
.
add
(
new
Function
((
long
)
147
,
151
,
5
,
"沽清管理"
,
R
.
drawable
.
ic_sell_off_manger
,
0
));
}
// functions.add(new Function((long) 152, 0, 5, "員工", 0, 0));
// functions.add(new Function((long) 152, 0, 5, "員工", 0, 0));
// functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management_close, 1));
// functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management_close, 1));
// functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management_close, 1));
// functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management_close, 1));
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/adapter/BusinessInfoAdapter.java
View file @
6bdf3095
...
@@ -14,8 +14,10 @@ import java.util.List;
...
@@ -14,8 +14,10 @@ import java.util.List;
*/
*/
public
class
BusinessInfoAdapter
extends
BaseQuickAdapter
<
BusinessBean
,
BaseViewHolder
>
{
public
class
BusinessInfoAdapter
extends
BaseQuickAdapter
<
BusinessBean
,
BaseViewHolder
>
{
public
BusinessInfoAdapter
(
@Nullable
List
<
BusinessBean
>
data
)
{
public
BusinessInfoAdapter
(
int
layout
,
@Nullable
List
<
BusinessBean
>
data
)
{
super
(
R
.
layout
.
report_business_info_item
,
data
);
// super(R.layout.report_business_info_item, data);
super
(
layout
,
data
);
}
}
@Override
@Override
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/fragment/BusinessReportFragment.java
View file @
6bdf3095
...
@@ -6,18 +6,26 @@ import android.os.Message;
...
@@ -6,18 +6,26 @@ import android.os.Message;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.Fragment
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.billy.cc.core.component.CC
;
import
com.bin.david.form.core.SmartTable
;
import
com.bin.david.form.data.column.Column
;
import
com.bin.david.form.data.table.TableData
;
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.base.utils.PrintTransitUtils
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimePickerUtils
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimePickerUtils
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
;
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.constans.PrintConstans
;
import
com.gingersoft.gsa.cloud.main.R
;
import
com.gingersoft.gsa.cloud.main.R
;
import
com.gingersoft.gsa.cloud.main.R2
;
import
com.gingersoft.gsa.cloud.main.R2
;
import
com.gingersoft.gsa.cloud.main.di.component.DaggerBusinessReportComponent
;
import
com.gingersoft.gsa.cloud.main.di.component.DaggerBusinessReportComponent
;
...
@@ -25,7 +33,9 @@ import com.gingersoft.gsa.cloud.main.mvp.contract.BusinessReportContract;
...
@@ -25,7 +33,9 @@ import com.gingersoft.gsa.cloud.main.mvp.contract.BusinessReportContract;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.BusinessBean
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.BusinessBean
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.MainBusinessBean
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.MainBusinessBean
;
import
com.gingersoft.gsa.cloud.main.mvp.presenter.BusinessReportPresenter
;
import
com.gingersoft.gsa.cloud.main.mvp.presenter.BusinessReportPresenter
;
import
com.gingersoft.gsa.cloud.main.mvp.ui.activity.SettlementActivity
;
import
com.gingersoft.gsa.cloud.main.mvp.ui.adapter.BusinessInfoAdapter
;
import
com.gingersoft.gsa.cloud.main.mvp.ui.adapter.BusinessInfoAdapter
;
import
com.gingersoft.gsa.cloud.main.mvp.ui.view.DividerGridItemDecoration
;
import
com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartConfiger.AAChartModel
;
import
com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartConfiger.AAChartModel
;
import
com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartConfiger.AAChartView
;
import
com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartConfiger.AAChartView
;
import
com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartConfiger.AASeriesElement
;
import
com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartConfiger.AASeriesElement
;
...
@@ -37,10 +47,10 @@ import com.gingersoft.gsa.cloud.ui.view.TriangleView;
...
@@ -37,10 +47,10 @@ import com.gingersoft.gsa.cloud.ui.view.TriangleView;
import
com.jess.arms.base.BaseFragment
;
import
com.jess.arms.base.BaseFragment
;
import
com.jess.arms.di.component.AppComponent
;
import
com.jess.arms.di.component.AppComponent
;
import
com.jess.arms.utils.ArmsUtils
;
import
com.jess.arms.utils.ArmsUtils
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaButton
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -81,8 +91,14 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
...
@@ -81,8 +91,14 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
TriangleView
triangleView
;
TriangleView
triangleView
;
@BindView
(
R2
.
id
.
iv_end_time_triangle
)
@BindView
(
R2
.
id
.
iv_end_time_triangle
)
TriangleView
endTimeTriangleView
;
TriangleView
endTimeTriangleView
;
// @BindView(R2.id.table_business)
// SmartTable mTableBusiness;
@BindView
(
R2
.
id
.
btn_print_business
)
QMUIAlphaButton
btnPintBusiness
;
private
BusinessInfoAdapter
businessInfoAdapter
;
private
BusinessInfoAdapter
businessInfoAdapter
;
private
BusinessInfoAdapter
printBusinessInfoAdapter
;
//查詢多少天的數據
//查詢多少天的數據
private
int
manyDay
=
7
;
private
int
manyDay
=
7
;
...
@@ -248,7 +264,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
...
@@ -248,7 +264,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
Object
[][]
stopsArr
=
{
Object
[][]
stopsArr
=
{
{
0.00
,
"#018EF2"
},
{
0.00
,
"#018EF2"
},
};
//颜色字符串设置支持十六进制类型和 rgba 类型
};
//颜色字符串设置支持十六进制类型和 rgba 类型
Map
linearGradientColor
=
AAGradientColor
.
linearGradient
(
Map
<
String
,
Object
>
linearGradientColor
=
AAGradientColor
.
linearGradient
(
AALinearGradientDirection
.
ToLeft
,
AALinearGradientDirection
.
ToLeft
,
stopsArr
stopsArr
);
//颜色字符串设置支持十六进制类型和 rgba 类型
);
//颜色字符串设置支持十六进制类型和 rgba 类型
...
@@ -285,24 +301,61 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
...
@@ -285,24 +301,61 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
@Override
@Override
public
void
loadAdapter
(
List
<
BusinessBean
>
businessBeans
)
{
public
void
loadAdapter
(
List
<
BusinessBean
>
businessBeans
)
{
// Column<String> column1 = new Column<>("姓名", "name");
// Column<Integer> column2 = new Column<>("年龄", "age");
// Column<Long> column3 = new Column<>("更新时间", "time");
// Column<String> column4 = new Column<>("头像", "portrait");
// //如果是多层,可以通过.来实现多级查询
// Column<String> column5 = new Column<>("班级", "class.className");
// //组合列
// Column totalColumn1 = new Column("组合列名",column1,column2);
// //表格数据 datas是需要填充的数据
//
//
// final TableData<BusinessBean> tableData = new TableData<>("表格名", businessBeans, column3);
//
// mTableBusiness.setTableData(tableData);
businessBeans
.
add
(
0
,
new
BusinessBean
(
"餐廳名稱"
,
GsaCloudApplication
.
getBrandName
(
mContext
)
+
","
+
GsaCloudApplication
.
getRestaurantName
(
mContext
)));
if
(
businessInfoAdapter
==
null
)
{
if
(
businessInfoAdapter
==
null
)
{
mBusinessDetails
.
setLayoutManager
(
new
GridLayoutManager
(
mContext
,
3
)
{
mBusinessDetails
.
setLayoutManager
(
new
LinearLayoutManager
(
mContext
)
{
@Override
@Override
public
boolean
canScrollVertically
()
{
public
boolean
canScrollVertically
()
{
return
false
;
return
false
;
}
}
});
});
businessInfoAdapter
=
new
BusinessInfoAdapter
(
businessBeans
);
printBusinessInfoAdapter
=
new
BusinessInfoAdapter
(
R
.
layout
.
report_business_info_item_print
,
businessBeans
);
businessInfoAdapter
=
new
BusinessInfoAdapter
(
R
.
layout
.
report_business_info_item_two
,
businessBeans
);
mBusinessDetails
.
setAdapter
(
businessInfoAdapter
);
mBusinessDetails
.
setAdapter
(
businessInfoAdapter
);
}
else
{
}
else
{
printBusinessInfoAdapter
.
setNewInstance
(
businessBeans
);
businessInfoAdapter
.
setNewInstance
(
businessBeans
);
businessInfoAdapter
.
setNewInstance
(
businessBeans
);
}
}
}
}
@OnClick
({
R2
.
id
.
tv_start_time
,
R2
.
id
.
iv_start_time_triangle
,
R2
.
id
.
tv_end_time
,
R2
.
id
.
iv_end_time_triangle
})
@OnClick
({
R2
.
id
.
btn_print_business
,
R2
.
id
.
tv_start_time
,
R2
.
id
.
iv_start_time_triangle
,
R2
.
id
.
tv_end_time
,
R2
.
id
.
iv_end_time_triangle
})
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
int
viewId
=
v
.
getId
();
int
viewId
=
v
.
getId
();
if
(
viewId
==
R
.
id
.
btn_print_business
)
{
//打印
View
view
=
View
.
inflate
(
mContext
,
R
.
layout
.
layout_print_business
,
null
);
RecyclerView
recyclerView
=
view
.
findViewById
(
R
.
id
.
rv_print_business_details
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
mContext
));
recyclerView
.
setAdapter
(
printBusinessInfoAdapter
);
//清機成功,打印
PrintTransitUtils
.
getInstance
().
setPrintView
(
view
);
CC
.
obtainBuilder
(
"Component.Print"
)
.
addParam
(
PrintConstans
.
PRINT_TYPE
,
4
)
//清機打印
.
setActionName
(
"printActivity"
)
.
build
()
.
callAsyncCallbackOnMainThread
((
cc
,
result
)
->
{
//打印完之後,清除view
PrintTransitUtils
.
getInstance
().
setPrintView
(
null
);
});
}
else
if
(
viewId
==
R
.
id
.
tv_start_time
||
viewId
==
R
.
id
.
iv_start_time_triangle
||
viewId
==
R
.
id
.
tv_end_time
||
viewId
==
R
.
id
.
iv_end_time_triangle
)
{
try
{
try
{
String
time
=
null
;
String
time
=
null
;
Calendar
startTime
=
Calendar
.
getInstance
();
Calendar
startTime
=
Calendar
.
getInstance
();
...
@@ -315,7 +368,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
...
@@ -315,7 +368,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
time
=
mTvStartTime
.
getText
().
toString
();
time
=
mTvStartTime
.
getText
().
toString
();
endTime
.
setTime
(
TimeUtils
.
DATE_FORMAT_DATE
.
parse
(
mTvEndTime
.
getText
().
toString
()));
endTime
.
setTime
(
TimeUtils
.
DATE_FORMAT_DATE
.
parse
(
mTvEndTime
.
getText
().
toString
()));
}
else
if
(
viewId
==
R
.
id
.
tv_end_time
||
viewId
==
R
.
id
.
iv_end_time_triangle
)
{
}
else
{
endTimeTriangleView
.
toggle
();
endTimeTriangleView
.
toggle
();
time
=
mTvEndTime
.
getText
().
toString
();
time
=
mTvEndTime
.
getText
().
toString
();
startTime
.
setTime
(
TimeUtils
.
DATE_FORMAT_DATE
.
parse
(
mTvStartTime
.
getText
().
toString
()));
startTime
.
setTime
(
TimeUtils
.
DATE_FORMAT_DATE
.
parse
(
mTvStartTime
.
getText
().
toString
()));
...
@@ -369,7 +422,10 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
...
@@ -369,7 +422,10 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
}
private
String
startTime
;
private
String
startTime
;
private
void
getInfo
()
{
private
void
getInfo
()
{
startTime
=
TimeUtils
.
getDatebyDate
(
mTvStartTime
.
getText
().
toString
(),
-
1
);
startTime
=
TimeUtils
.
getDatebyDate
(
mTvStartTime
.
getText
().
toString
(),
-
1
);
String
endTime
=
TimeUtils
.
getDatebyDate
(
mTvEndTime
.
getText
().
toString
(),
1
);
String
endTime
=
TimeUtils
.
getDatebyDate
(
mTvEndTime
.
getText
().
toString
(),
1
);
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/view/DividerGridItemDecoration.java
0 → 100644
View file @
6bdf3095
package
com
.
gingersoft
.
gsa
.
cloud
.
main
.
mvp
.
ui
.
view
;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.graphics.Canvas
;
import
android.graphics.Rect
;
import
android.graphics.drawable.Drawable
;
import
android.view.View
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
;
public
class
DividerGridItemDecoration
extends
RecyclerView
.
ItemDecoration
{
private
static
final
int
[]
ATTRS
=
new
int
[]{
android
.
R
.
attr
.
listDivider
};
private
Drawable
mDivider
;
public
DividerGridItemDecoration
(
Context
context
)
{
final
TypedArray
a
=
context
.
obtainStyledAttributes
(
ATTRS
);
mDivider
=
a
.
getDrawable
(
0
);
a
.
recycle
();
}
@Override
public
void
onDraw
(
Canvas
c
,
RecyclerView
parent
,
RecyclerView
.
State
state
)
{
drawHorizontal
(
c
,
parent
);
drawVertical
(
c
,
parent
);
}
private
int
getSpanCount
(
RecyclerView
parent
)
{
// 列数
int
spanCount
=
-
1
;
RecyclerView
.
LayoutManager
layoutManager
=
parent
.
getLayoutManager
();
if
(
layoutManager
instanceof
GridLayoutManager
)
{
spanCount
=
((
GridLayoutManager
)
layoutManager
).
getSpanCount
();
}
else
if
(
layoutManager
instanceof
StaggeredGridLayoutManager
)
{
spanCount
=
((
StaggeredGridLayoutManager
)
layoutManager
)
.
getSpanCount
();
}
return
spanCount
;
}
public
void
drawHorizontal
(
Canvas
c
,
RecyclerView
parent
)
{
int
childCount
=
parent
.
getChildCount
();
for
(
int
i
=
0
;
i
<
childCount
;
i
++)
{
final
View
child
=
parent
.
getChildAt
(
i
);
final
RecyclerView
.
LayoutParams
params
=
(
RecyclerView
.
LayoutParams
)
child
.
getLayoutParams
();
final
int
left
=
child
.
getLeft
()
-
params
.
leftMargin
;
final
int
right
=
child
.
getRight
()
+
params
.
rightMargin
+
mDivider
.
getIntrinsicWidth
();
final
int
top
=
child
.
getBottom
()
+
params
.
bottomMargin
;
final
int
bottom
=
top
+
mDivider
.
getIntrinsicHeight
();
mDivider
.
setBounds
(
left
,
top
,
right
,
bottom
);
mDivider
.
draw
(
c
);
}
}
public
void
drawVertical
(
Canvas
c
,
RecyclerView
parent
)
{
final
int
childCount
=
parent
.
getChildCount
();
for
(
int
i
=
0
;
i
<
childCount
;
i
++)
{
final
View
child
=
parent
.
getChildAt
(
i
);
final
RecyclerView
.
LayoutParams
params
=
(
RecyclerView
.
LayoutParams
)
child
.
getLayoutParams
();
final
int
top
=
child
.
getTop
()
-
params
.
topMargin
;
final
int
bottom
=
child
.
getBottom
()
+
params
.
bottomMargin
;
final
int
left
=
child
.
getRight
()
+
params
.
rightMargin
;
final
int
right
=
left
+
mDivider
.
getIntrinsicWidth
();
mDivider
.
setBounds
(
left
,
top
,
right
,
bottom
);
mDivider
.
draw
(
c
);
}
}
private
boolean
isLastColum
(
RecyclerView
parent
,
int
pos
,
int
spanCount
,
int
childCount
)
{
RecyclerView
.
LayoutManager
layoutManager
=
parent
.
getLayoutManager
();
if
(
layoutManager
instanceof
GridLayoutManager
)
{
if
((
pos
+
1
)
%
spanCount
==
0
)
// 如果是最后一列,则不需要绘制右边
{
return
true
;
}
}
else
if
(
layoutManager
instanceof
StaggeredGridLayoutManager
)
{
int
orientation
=
((
StaggeredGridLayoutManager
)
layoutManager
)
.
getOrientation
();
if
(
orientation
==
StaggeredGridLayoutManager
.
VERTICAL
)
{
if
((
pos
+
1
)
%
spanCount
==
0
)
// 如果是最后一列,则不需要绘制右边
{
return
true
;
}
}
else
{
childCount
=
childCount
-
childCount
%
spanCount
;
if
(
pos
>=
childCount
)
// 如果是最后一列,则不需要绘制右边
return
true
;
}
}
return
false
;
}
private
boolean
isLastRaw
(
RecyclerView
parent
,
int
pos
,
int
spanCount
,
int
childCount
)
{
RecyclerView
.
LayoutManager
layoutManager
=
parent
.
getLayoutManager
();
if
(
layoutManager
instanceof
GridLayoutManager
)
{
childCount
=
childCount
-
childCount
%
spanCount
;
if
(
pos
>=
childCount
)
// 如果是最后一行,则不需要绘制底部
return
true
;
}
else
if
(
layoutManager
instanceof
StaggeredGridLayoutManager
)
{
int
orientation
=
((
StaggeredGridLayoutManager
)
layoutManager
)
.
getOrientation
();
// StaggeredGridLayoutManager 且纵向滚动
if
(
orientation
==
StaggeredGridLayoutManager
.
VERTICAL
)
{
childCount
=
childCount
-
childCount
%
spanCount
;
// 如果是最后一行,则不需要绘制底部
if
(
pos
>=
childCount
)
return
true
;
}
else
// StaggeredGridLayoutManager 且横向滚动
{
// 如果是最后一行,则不需要绘制底部
if
((
pos
+
1
)
%
spanCount
==
0
)
{
return
true
;
}
}
}
return
false
;
}
@Override
public
void
getItemOffsets
(
Rect
outRect
,
int
itemPosition
,
RecyclerView
parent
)
{
int
spanCount
=
getSpanCount
(
parent
);
int
childCount
=
parent
.
getAdapter
().
getItemCount
();
if
(
isLastRaw
(
parent
,
itemPosition
,
spanCount
,
childCount
))
// 如果是最后一行,则不需要绘制底部
{
outRect
.
set
(
0
,
0
,
mDivider
.
getIntrinsicWidth
(),
0
);
}
else
if
(
isLastColum
(
parent
,
itemPosition
,
spanCount
,
childCount
))
// 如果是最后一列,则不需要绘制右边
{
outRect
.
set
(
0
,
0
,
0
,
mDivider
.
getIntrinsicHeight
());
}
else
{
outRect
.
set
(
0
,
0
,
mDivider
.
getIntrinsicWidth
(),
mDivider
.
getIntrinsicHeight
());
}
}
}
main-module/src/main/res/layout/fragment_business_report.xml
View file @
6bdf3095
...
@@ -57,10 +57,10 @@
...
@@ -57,10 +57,10 @@
<com.gingersoft.gsa.cloud.ui.view.TriangleView
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id=
"@+id/iv_start_time_triangle"
android:id=
"@+id/iv_start_time_triangle"
android:paddingLeft=
"@dimen/dp_2"
android:layout_width=
"@dimen/dp_10"
android:layout_width=
"@dimen/dp_10"
app:trv_direction=
"bottom"
android:layout_height=
"@dimen/dp_5"
android:layout_height=
"@dimen/dp_5"
/>
android:paddingLeft=
"@dimen/dp_2"
app:trv_direction=
"bottom"
/>
<TextView
<TextView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
...
@@ -81,10 +81,10 @@
...
@@ -81,10 +81,10 @@
<com.gingersoft.gsa.cloud.ui.view.TriangleView
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id=
"@+id/iv_end_time_triangle"
android:id=
"@+id/iv_end_time_triangle"
android:layout_marginLeft=
"@dimen/dp_2"
android:layout_width=
"@dimen/dp_8"
android:layout_width=
"@dimen/dp_8"
app:trv_direction=
"bottom"
android:layout_height=
"@dimen/dp_5"
android:layout_height=
"@dimen/dp_5"
/>
android:layout_marginLeft=
"@dimen/dp_2"
app:trv_direction=
"bottom"
/>
</LinearLayout>
</LinearLayout>
<com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartConfiger.AAChartView
<com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartConfiger.AAChartView
...
@@ -134,14 +134,45 @@
...
@@ -134,14 +134,45 @@
android:focusableInTouchMode=
"true"
android:focusableInTouchMode=
"true"
android:text=
"餐廳名稱"
android:text=
"餐廳名稱"
android:textColor=
"#3c3c3c"
android:textColor=
"#3c3c3c"
android:textSize=
"@dimen/dp_16"
/>
android:textSize=
"@dimen/dp_16"
android:visibility=
"gone"
/>
<include
layout=
"@layout/include_horizontal_color_ccc_dividing_line"
/>
<!-- <include layout="@layout/include_horizontal_color_ccc_dividing_line" />-->
<!-- <com.bin.david.form.core.SmartTable-->
<!-- android:id="@+id/table_business"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- />-->
<androidx.recyclerview.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_business_details"
android:id=
"@+id/rv_business_details"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"match_parent"
android:layout_marginLeft=
"@dimen/dp_10"
android:layout_marginTop=
"@dimen/dp_10"
android:layout_marginRight=
"@dimen/dp_10"
/>
<View
android:id=
"@+id/horizontal_dividing_line"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_0_5"
android:layout_marginLeft=
"@dimen/dp_10"
android:layout_marginRight=
"@dimen/dp_10"
android:background=
"@color/color_ccc"
/>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id=
"@+id/btn_print_business"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"@dimen/dp_10"
android:layout_marginTop=
"@dimen/dp_10"
android:layout_marginRight=
"@dimen/dp_10"
android:layout_marginBottom=
"@dimen/dp_10"
android:background=
"@drawable/shape_app_btn"
android:text=
"打印"
android:textColor=
"@color/white"
android:textSize=
"@dimen/dp_16"
/>
</LinearLayout>
</LinearLayout>
</com.lihang.ShadowLayout>
</com.lihang.ShadowLayout>
...
...
main-module/src/main/res/layout/layout_print_business.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/layout_print_business"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"@dimen/dp_10"
android:layout_marginRight=
"@dimen/dp_10"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_margin=
"@dimen/dp_10"
android:text=
"每日營業報表"
android:textColor=
"@color/black"
android:textSize=
"@dimen/dp_30"
tools:text=
"GSA"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_print_business_details"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<include
layout=
"@layout/include_horizontal_color_black_one_dividing_line"
/>
</LinearLayout>
main-module/src/main/res/layout/report_business_info_item.xml
View file @
6bdf3095
...
@@ -18,9 +18,8 @@
...
@@ -18,9 +18,8 @@
android:layout_marginLeft=
"@dimen/dp_5"
android:layout_marginLeft=
"@dimen/dp_5"
android:layout_marginTop=
"@dimen/dp_20"
android:layout_marginTop=
"@dimen/dp_20"
android:layout_marginRight=
"@dimen/dp_5"
android:layout_marginRight=
"@dimen/dp_5"
android:singleLine=
"true"
android:textColor=
"@color/theme_color"
android:textColor=
"@color/theme_color"
android:textSize=
"@dimen/
sp_17
"
/>
android:textSize=
"@dimen/
dp_20
"
/>
<TextView
<TextView
android:id=
"@+id/tv_business_info_name"
android:id=
"@+id/tv_business_info_name"
...
@@ -31,9 +30,8 @@
...
@@ -31,9 +30,8 @@
android:layout_marginRight=
"@dimen/dp_5"
android:layout_marginRight=
"@dimen/dp_5"
android:layout_marginBottom=
"@dimen/dp_20"
android:layout_marginBottom=
"@dimen/dp_20"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:singleLine=
"true"
android:textColor=
"@color/color_3c"
android:textColor=
"@color/color_3c"
android:textSize=
"@dimen/sp_1
2
"
/>
android:textSize=
"@dimen/sp_1
6
"
/>
<include
layout=
"@layout/include_horizontal_color_ccc_dividing_line"
/>
<include
layout=
"@layout/include_horizontal_color_ccc_dividing_line"
/>
...
...
main-module/src/main/res/layout/report_business_info_item_print.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<include
layout=
"@layout/include_horizontal_color_black_one_dividing_line"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<include
layout=
"@layout/include_vertical_color_black_one_dividing_line"
/>
<TextView
android:id=
"@+id/tv_business_info_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"@dimen/dp_10"
android:layout_weight=
"1"
android:textColor=
"@color/black"
android:textSize=
"@dimen/dp_26"
tools:text=
"餐廳名稱"
/>
<include
layout=
"@layout/include_vertical_color_black_one_dividing_line"
/>
<TextView
android:id=
"@+id/tv_business_info_amount"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"@dimen/dp_10"
android:layout_weight=
"1"
android:textColor=
"@color/black"
android:textSize=
"@dimen/dp_26"
tools:text=
"GSA"
/>
<include
layout=
"@layout/include_vertical_color_black_one_dividing_line"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
main-module/src/main/res/layout/report_business_info_item_two.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<include
layout=
"@layout/include_horizontal_color_ccc_dividing_line"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<include
layout=
"@layout/include_vertical_color_ccc_dividing_line"
/>
<TextView
android:id=
"@+id/tv_business_info_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"@dimen/dp_10"
android:layout_weight=
"1"
android:textColor=
"@color/color_3c"
android:textSize=
"@dimen/sp_12"
tools:text=
"餐廳名稱"
/>
<include
layout=
"@layout/include_vertical_color_ccc_dividing_line"
/>
<TextView
android:id=
"@+id/tv_business_info_amount"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"@dimen/dp_10"
android:layout_weight=
"1"
android:textColor=
"@color/theme_color"
android:textSize=
"@dimen/sp_17"
tools:text=
"GSA"
/>
<include
layout=
"@layout/include_vertical_color_ccc_dividing_line"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/WeatherRepository.kt
View file @
6bdf3095
package
com.gingersoft.gsa.other_order_mode.data
package
com.gingersoft.gsa.other_order_mode.data
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import
com.gingersoft.gsa.cloud.constans.AppConstans
import
com.gingersoft.gsa.other_order_mode.R
import
com.gingersoft.gsa.other_order_mode.data.model.bean.ThirdItem
import
com.gingersoft.gsa.other_order_mode.data.model.bean.ThirdItem
import
com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork
import
com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork
import
com.google.gson.Gson
import
com.google.gson.Gson
import
com.jess.arms.utils.DeviceUtils
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
import
okhttp3.FormBody
import
okhttp3.FormBody
...
@@ -94,7 +98,7 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
...
@@ -94,7 +98,7 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
network
.
gsUpdateOrderStatus
(
requestBody
)
network
.
gsUpdateOrderStatus
(
requestBody
)
}
}
suspend
fun
updateIsRead
(
orderId
:
String
)
=
withContext
(
Dispatchers
.
IO
){
suspend
fun
updateIsRead
(
orderId
:
String
)
=
withContext
(
Dispatchers
.
IO
)
{
network
.
updateIsRead
(
getBody
(
"id"
to
orderId
))
network
.
updateIsRead
(
getBody
(
"id"
to
orderId
))
}
}
...
@@ -161,6 +165,18 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
...
@@ -161,6 +165,18 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
network
.
addPrj
(
getBody
(
"orderId"
to
orderId
,
"restaurantId"
to
restaurantId
,
"orderDetailsIds"
to
orderDetailsIds
))
network
.
addPrj
(
getBody
(
"orderId"
to
orderId
,
"restaurantId"
to
restaurantId
,
"orderDetailsIds"
to
orderDetailsIds
))
}
}
suspend
fun
noticePersonnel
(
pushContent
:
String
?,
code
:
String
)
{
val
requestBody
=
FormBody
.
Builder
()
.
add
(
"code"
,
code
)
//錯誤碼AppConstans.RP_HEART_ERROR
.
add
(
"shopId"
,
GsaCloudApplication
.
getGsPosShopId
(
GsaCloudApplication
.
getAppContext
()))
.
add
(
"source"
,
GsaCloudApplication
.
getAppName
())
//錯誤來源
.
add
(
"pushContent"
,
pushContent
+
""
)
//推送內容
.
add
(
"version"
,
DeviceUtils
.
getVersionName
(
GsaCloudApplication
.
getAppContext
()))
//系統版本
.
build
()
network
.
noticePersonnel
(
requestBody
)
// OkHttp3Utils.post(HttpsConstans.ROOT_URL + "/member-web/api/monitor/pushAlarm", requestBody)
// .subscribeOn(Schedulers.io()).subscribe()
}
fun
getBody
(
vararg
pair
:
Pair1
<
String
,
String
>):
RequestBody
{
fun
getBody
(
vararg
pair
:
Pair1
<
String
,
String
>):
RequestBody
{
val
requestBody
=
FormBody
.
Builder
()
val
requestBody
=
FormBody
.
Builder
()
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/CoolWeatherNetwork.kt
View file @
6bdf3095
package
com.gingersoft.gsa.other_order_mode.data.network
package
com.gingersoft.gsa.other_order_mode.data.network
import
com.gingersoft.gsa.other_order_mode.data.network.api.AppService
import
com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import
com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import
okhttp3.FormBody
import
okhttp3.RequestBody
import
okhttp3.RequestBody
import
retrofit2.Call
import
retrofit2.Call
import
retrofit2.Callback
import
retrofit2.Callback
...
@@ -15,6 +17,8 @@ class CoolWeatherNetwork {
...
@@ -15,6 +17,8 @@ class CoolWeatherNetwork {
private
val
service
=
ServiceCreator
.
create2
(
WeatherService
::
class
.
java
)
private
val
service
=
ServiceCreator
.
create2
(
WeatherService
::
class
.
java
)
private
val
appService
=
ServiceCreator
.
create2
(
AppService
::
class
.
java
)
private
val
gsposService
=
ServiceCreator
.
create3
(
WeatherService
::
class
.
java
)
private
val
gsposService
=
ServiceCreator
.
create3
(
WeatherService
::
class
.
java
)
private
val
cloudService
=
ServiceCreator
.
create4
(
WeatherService
::
class
.
java
)
private
val
cloudService
=
ServiceCreator
.
create4
(
WeatherService
::
class
.
java
)
...
@@ -70,11 +74,16 @@ class CoolWeatherNetwork {
...
@@ -70,11 +74,16 @@ class CoolWeatherNetwork {
suspend
fun
addPrj
(
requestBody
:
RequestBody
)
=
cloudService
.
addPrj
(
requestBody
).
await
()
suspend
fun
addPrj
(
requestBody
:
RequestBody
)
=
cloudService
.
addPrj
(
requestBody
).
await
()
suspend
fun
noticePersonnel
(
requestBody
:
RequestBody
)
=
appService
.
noticePersonnel
(
requestBody
).
await
()
private
suspend
fun
<
T
>
Call
<
T
>.
await
():
T
{
private
suspend
fun
<
T
>
Call
<
T
>.
await
():
T
{
return
suspendCoroutine
{
continuation
->
return
suspendCoroutine
{
continuation
->
enqueue
(
object
:
Callback
<
T
>
{
enqueue
(
object
:
Callback
<
T
>
{
override
fun
onFailure
(
call
:
Call
<
T
>,
t
:
Throwable
)
{
override
fun
onFailure
(
call
:
Call
<
T
>,
t
:
Throwable
)
{
// val request = orderService.getOrderList(FormBody.Builder().build()).request()
// if(call.request().url().toString().contains(request.url().toString())){
// //訂單列表接口報錯,推送相關人員
// }
t
.
printStackTrace
()
t
.
printStackTrace
()
continuation
.
resumeWithException
(
t
)
continuation
.
resumeWithException
(
t
)
}
}
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/ServiceCreator.kt
View file @
6bdf3095
...
@@ -14,6 +14,7 @@ import retrofit2.Retrofit
...
@@ -14,6 +14,7 @@ import retrofit2.Retrofit
import
retrofit2.converter.gson.GsonConverterFactory
import
retrofit2.converter.gson.GsonConverterFactory
import
retrofit2.converter.scalars.ScalarsConverterFactory
import
retrofit2.converter.scalars.ScalarsConverterFactory
import
java.io.IOException
import
java.io.IOException
import
java.net.UnknownHostException
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.TimeUnit
object
ServiceCreator
{
object
ServiceCreator
{
...
@@ -23,6 +24,7 @@ object ServiceCreator {
...
@@ -23,6 +24,7 @@ object ServiceCreator {
.
addInterceptor
(
LoggingInterceptor
())
.
addInterceptor
(
LoggingInterceptor
())
.
addInterceptor
(
UserAgentIntercepter
())
.
addInterceptor
(
UserAgentIntercepter
())
var
ROOT_URL
:
String
=
HttpsConstans
.
ROOT_URL
var
ROOT_URL
:
String
=
HttpsConstans
.
ROOT_URL
var
CLOUD_BASE_URL
:
String
=
HttpsConstans
.
ROOT_SERVER_ADDRESS_FORMAL
var
CLOUD_BASE_URL
:
String
=
HttpsConstans
.
ROOT_SERVER_ADDRESS_FORMAL
...
@@ -65,7 +67,7 @@ object ServiceCreator {
...
@@ -65,7 +67,7 @@ object ServiceCreator {
* 添加请求头
* 添加请求头
*/
*/
class
UserAgentIntercepter
:
Interceptor
{
class
UserAgentIntercepter
:
Interceptor
{
@Throws
(
IOException
::
class
)
override
fun
intercept
(
chain
:
Interceptor
.
Chain
):
Response
{
override
fun
intercept
(
chain
:
Interceptor
.
Chain
):
Response
{
val
request
=
chain
.
request
()
val
request
=
chain
.
request
()
val
headers
=
request
.
headers
()
val
headers
=
request
.
headers
()
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/api/AppService.kt
0 → 100644
View file @
6bdf3095
package
com.gingersoft.gsa.other_order_mode.data.network.api
import
okhttp3.RequestBody
import
retrofit2.Call
import
retrofit2.http.Body
import
retrofit2.http.POST
interface
AppService
{
@POST
(
"monitor/pushAlarm"
)
fun
noticePersonnel
(
@Body
requestBody
:
RequestBody
):
Call
<
String
>
}
\ No newline at end of file
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/network/api/WeatherService.kt
View file @
6bdf3095
...
@@ -62,4 +62,6 @@ interface WeatherService {
...
@@ -62,4 +62,6 @@ interface WeatherService {
@POST
(
"printerRecording/add"
)
@POST
(
"printerRecording/add"
)
fun
addPrj
(
@Body
requestBody
:
RequestBody
):
Call
<
String
>
fun
addPrj
(
@Body
requestBody
:
RequestBody
):
Call
<
String
>
}
}
\ No newline at end of file
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/model/viewModel/PageViewModel.kt
View file @
6bdf3095
...
@@ -2,6 +2,7 @@ package com.gingersoft.gsa.other_order_mode.model.viewModel
...
@@ -2,6 +2,7 @@ package com.gingersoft.gsa.other_order_mode.model.viewModel
import
android.app.Dialog
import
android.app.Dialog
import
android.content.Context
import
android.content.Context
import
android.os.Message
import
android.util.Log
import
android.util.Log
import
android.view.Gravity
import
android.view.Gravity
import
android.view.WindowManager
import
android.view.WindowManager
...
@@ -19,6 +20,7 @@ import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils
...
@@ -19,6 +20,7 @@ import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import
com.gingersoft.gsa.cloud.base.widget.DialogUtils
import
com.gingersoft.gsa.cloud.base.widget.DialogUtils
import
com.gingersoft.gsa.cloud.constans.AppConstans
import
com.gingersoft.gsa.cloud.constans.PrintConstans
import
com.gingersoft.gsa.cloud.constans.PrintConstans
import
com.gingersoft.gsa.cloud.print.bean.OrderDetails
import
com.gingersoft.gsa.cloud.print.bean.OrderDetails
import
com.gingersoft.gsa.other_order_mode.R
import
com.gingersoft.gsa.other_order_mode.R
...
@@ -26,10 +28,12 @@ import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
...
@@ -26,10 +28,12 @@ import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
import
com.gingersoft.gsa.other_order_mode.data.model.bean.*
import
com.gingersoft.gsa.other_order_mode.data.model.bean.*
import
com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService
import
com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService
import
com.gingersoft.gsa.other_order_mode.ui.adapter.DeliveryAdapter
import
com.gingersoft.gsa.other_order_mode.ui.adapter.DeliveryAdapter
import
com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import
com.jess.arms.utils.ArmsUtils
import
com.jess.arms.utils.ArmsUtils
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
import
java.lang.NullPointerException
class
PageViewModel
(
private
val
repository
:
WeatherRepository
)
:
ViewModel
()
{
class
PageViewModel
(
private
val
repository
:
WeatherRepository
)
:
ViewModel
()
{
...
@@ -125,12 +129,18 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -125,12 +129,18 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
fun
getOrderList
(
restaurantId
:
String
,
position
:
Int
,
page
:
String
,
isLoadMore
:
Boolean
)
{
fun
getOrderList
(
restaurantId
:
String
,
position
:
Int
,
page
:
String
,
isLoadMore
:
Boolean
)
{
launch
({
launch
({
repository
.
requestOrderList
(
restaurantId
,
fragmentStatus
[
position
],
fragmentType
[
position
],
page
,
orderNo
,
phone
).
apply
{
repository
.
requestOrderList
(
restaurantId
,
fragmentStatus
[
position
],
fragmentType
[
position
],
page
,
orderNo
,
phone
).
apply
{
// throw NullPointerException("測試獲取訂單列表異常")
getOrderGroupNum
(
restaurantId
)
getOrderGroupNum
(
restaurantId
)
loadInfo
(
isLoadMore
,
position
)
loadInfo
(
isLoadMore
,
position
)
}
}
},
{
},
{
//出錯
//出錯
mOrderList
[
position
].
value
=
null
mOrderList
[
position
].
value
=
null
launch
({
repository
.
noticePersonnel
(
it
.
message
,
AppConstans
.
RP_ORDER_LIST_ERROR
)
},{
})
OtherOrderUtils
.
initSoundPool
(
GsaCloudApplication
.
getAppContext
(),
R
.
raw
.
raw_get_order_list_error
)
})
})
}
}
...
@@ -249,7 +259,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -249,7 +259,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
}
val
estimatedBean
=
withContext
(
Dispatchers
.
Default
)
{
repository
.
getShipanyOrderTime
(
restaurantId
,
orderId
,
type
)
}
//1、预计整张订单完成时间2、預計配送員接單時間3、預計配送員到店時間4、配送員預計送達時間
val
estimatedBean
=
withContext
(
Dispatchers
.
Default
)
{
repository
.
getShipanyOrderTime
(
restaurantId
,
orderId
,
type
)
}
//1、预计整张订单完成时间2、預計配送員接單時間3、預計配送員到店時間4、配送員預計送達時間
// if (estimatedBean.data.estimated_time > 0) {
// if (estimatedBean.data.estimated_time > 0) {
if
(
estimatedBean
.
data
!=
null
)
{
if
(
estimatedBean
.
data
!=
null
)
{
data
.
estimatedTime
=
estimatedTime
+
(
"${estimatedBean.data.estimated_time}分鐘後"
)
data
.
estimatedTime
=
estimatedTime
+
(
"${estimatedBean.data.estimated_time}分鐘後"
)
}
}
orderDetails
.
postValue
(
orderDetail
)
orderDetails
.
postValue
(
orderDetail
)
...
@@ -275,7 +285,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -275,7 +285,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
}
fun
updateOrderStatusByBtn
(
btnId
:
Int
,
dataBean
:
OrderDetails
.
DataBean
,
restaurantId
:
String
,
listener
:
(
Int
,
Bool
ean
)
->
Unit
)
{
fun
updateOrderStatusByBtn
(
btnId
:
Int
,
dataBean
:
OrderDetails
.
DataBean
,
restaurantId
:
String
,
listener
:
(
MessageB
ean
)
->
Unit
)
{
launch
({
launch
({
when
(
btnId
)
{
when
(
btnId
)
{
BtnBuilder
.
sureBtn
->
{
BtnBuilder
.
sureBtn
->
{
...
@@ -306,12 +316,12 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -306,12 +316,12 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
BtnBuilder
.
ProductionCompletedBtn
->
{
BtnBuilder
.
ProductionCompletedBtn
->
{
//製作完成
//製作完成
repository
.
gsUpdateOrderStatus
(
dataBean
.
ID
.
toString
(),
3
,
dataBean
.
order_type
,
1
,
""
,
""
,
""
,
"0"
,
""
,
1
,
0
).
apply
{
repository
.
gsUpdateOrderStatus
(
dataBean
.
ID
.
toString
(),
3
,
dataBean
.
order_type
,
1
,
""
,
""
,
""
,
"0"
,
""
,
1
,
0
).
apply
{
listener
.
invoke
(
ProductionComplete
,
code
==
"1"
)
listener
.
invoke
(
getMsgBean
(
ProductionComplete
,
errorMsg
,
code
==
"1"
)
)
}
}
}
}
}
}
},
{
},
{
listener
.
invoke
(
0
,
false
)
listener
.
invoke
(
getMsgBean
(
0
,
""
,
false
)
)
it
.
printStackTrace
()
it
.
printStackTrace
()
Log
.
e
(
"eee"
,
it
.
javaClass
.
name
+
"錯誤信息111:"
+
it
.
message
)
Log
.
e
(
"eee"
,
it
.
javaClass
.
name
+
"錯誤信息111:"
+
it
.
message
)
GetInfoUpdateService
.
loginfo
.
append
(
"錯誤信息111:"
+
it
.
message
+
" LOCALIZEDMESSAGE:"
+
it
.
localizedMessage
+
it
.
cause
)
GetInfoUpdateService
.
loginfo
.
append
(
"錯誤信息111:"
+
it
.
message
+
" LOCALIZEDMESSAGE:"
+
it
.
localizedMessage
+
it
.
cause
)
...
@@ -343,7 +353,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -343,7 +353,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
/**
* 修改訂單狀態並打印
* 修改訂單狀態並打印
*/
*/
private
suspend
fun
updateOrderAndPrint
(
restaurantId
:
String
,
dataBean
:
OrderDetails
.
DataBean
,
status
:
Int
,
listener
:
(
Int
,
Bool
ean
)
->
Unit
)
{
private
suspend
fun
updateOrderAndPrint
(
restaurantId
:
String
,
dataBean
:
OrderDetails
.
DataBean
,
status
:
Int
,
listener
:
(
MessageB
ean
)
->
Unit
)
{
repository
.
gsUpdateOrderStatus
(
dataBean
.
ID
.
toString
(),
status
,
dataBean
.
order_type
,
1
,
""
,
""
,
""
,
"0"
,
""
,
1
,
0
).
apply
{
repository
.
gsUpdateOrderStatus
(
dataBean
.
ID
.
toString
(),
status
,
dataBean
.
order_type
,
1
,
""
,
""
,
""
,
"0"
,
""
,
1
,
0
).
apply
{
if
(
status
==
0
||
status
==
1
||
status
==
2
)
{
if
(
status
==
0
||
status
==
1
||
status
==
2
)
{
//確認送單
//確認送單
...
@@ -392,11 +402,11 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -392,11 +402,11 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
printOrder
(
DeliveryPrint
,
it
,
listener
)
printOrder
(
DeliveryPrint
,
it
,
listener
)
}
}
}
else
{
}
else
{
listener
.
invoke
(
OrderDelivery
,
false
)
listener
.
invoke
(
getMsgBean
(
OrderDelivery
,
errorMsg
,
false
)
)
}
}
}
}
}
else
{
}
else
{
listener
.
invoke
(
OrderDelivery
,
false
)
listener
.
invoke
(
getMsgBean
(
OrderDelivery
,
errorMsg
,
false
)
)
}
}
}
}
}
}
...
@@ -405,7 +415,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -405,7 +415,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
/**
* 打印訂單
* 打印訂單
*/
*/
private
fun
printOrder
(
code
:
Int
,
dataBean
:
OrderDetails
.
DataBean
,
listener
:
(
Int
,
Bool
ean
)
->
Unit
)
{
private
fun
printOrder
(
code
:
Int
,
dataBean
:
OrderDetails
.
DataBean
,
listener
:
(
MessageB
ean
)
->
Unit
)
{
//訂單信息和廚房單,打印前需要修改dataBean的order_type和orderPayType
//訂單信息和廚房單,打印前需要修改dataBean的order_type和orderPayType
MyOrderManage
.
setDataBean
(
dataBean
)
MyOrderManage
.
setDataBean
(
dataBean
)
CC
.
obtainBuilder
(
"Component.Print"
)
CC
.
obtainBuilder
(
"Component.Print"
)
...
@@ -414,7 +424,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -414,7 +424,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
.
build
()
.
build
()
.
callAsyncCallbackOnMainThread
{
_
,
result
->
.
callAsyncCallbackOnMainThread
{
_
,
result
->
MyOrderManage
.
setDataBean
(
null
)
MyOrderManage
.
setDataBean
(
null
)
listener
.
invoke
(
code
,
result
.
isSuccess
)
listener
.
invoke
(
getMsgBean
(
code
,
"打印"
,
result
.
isSuccess
)
)
}
}
}
}
...
@@ -457,7 +467,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -457,7 +467,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
/**
* 第三方派送
* 第三方派送
*/
*/
private
suspend
fun
thirdSend
(
restaurantId
:
String
,
dataBean
:
OrderDetails
.
DataBean
,
status
:
Int
,
listener
:
(
Int
,
Bool
ean
)
->
Unit
)
{
private
suspend
fun
thirdSend
(
restaurantId
:
String
,
dataBean
:
OrderDetails
.
DataBean
,
status
:
Int
,
listener
:
(
MessageB
ean
)
->
Unit
)
{
val
third
=
ThirdItem
()
val
third
=
ThirdItem
()
//將食品數據轉為第三方需要的數據
//將食品數據轉為第三方需要的數據
dataBean
.
PRODUCT_NAME
?.
let
{
dataBean
.
PRODUCT_NAME
?.
let
{
...
@@ -477,7 +487,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -477,7 +487,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
// listener.invoke(OrderDelivery, true)
// listener.invoke(OrderDelivery, true)
updateOrderAndPrint
(
restaurantId
,
dataBean
,
status
,
listener
)
updateOrderAndPrint
(
restaurantId
,
dataBean
,
status
,
listener
)
}
else
{
}
else
{
listener
.
invoke
(
OrderDelivery
,
false
)
listener
.
invoke
(
getMsgBean
(
OrderDelivery
,
errMsg
,
false
)
)
}
}
}
}
}
}
...
@@ -668,6 +678,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...
@@ -668,6 +678,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
})
}
}
fun
getMsgBean
(
what
:
Int
,
msg
:
String
,
state
:
Boolean
):
MessageBean
{
return
MessageBean
(
what
.
toString
(),
msg
,
state
,
System
.
currentTimeMillis
(),
null
)
}
var
payTypeBean
=
MutableLiveData
<
PayTypeInfo
.
DataBean
>()
var
payTypeBean
=
MutableLiveData
<
PayTypeInfo
.
DataBean
>()
/**
/**
* 獲取支付方式
* 獲取支付方式
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/service/GetInfoUpdateService.kt
View file @
6bdf3095
...
@@ -5,10 +5,7 @@ import android.app.NotificationChannel
...
@@ -5,10 +5,7 @@ import android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.NotificationManager
import
android.app.PendingIntent
import
android.app.PendingIntent
import
android.app.Service
import
android.app.Service
import
android.content.BroadcastReceiver
import
android.content.*
import
android.content.Context
import
android.content.Intent
import
android.content.IntentFilter
import
android.graphics.BitmapFactory
import
android.graphics.BitmapFactory
import
android.media.AudioAttributes
import
android.media.AudioAttributes
import
android.media.AudioManager
import
android.media.AudioManager
...
@@ -30,8 +27,10 @@ import com.gingersoft.gsa.cloud.constans.HttpsConstans
...
@@ -30,8 +27,10 @@ import com.gingersoft.gsa.cloud.constans.HttpsConstans
import
com.gingersoft.gsa.other_order_mode.R
import
com.gingersoft.gsa.other_order_mode.R
import
com.gingersoft.gsa.other_order_mode.data.network.ServiceCreator
import
com.gingersoft.gsa.other_order_mode.data.network.ServiceCreator
import
com.gingersoft.gsa.other_order_mode.ui.activity.OtherOrderActivity
import
com.gingersoft.gsa.other_order_mode.ui.activity.OtherOrderActivity
import
com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import
com.gingersoft.gsa.other_order_mode.util.RxTimerUtil
import
com.gingersoft.gsa.other_order_mode.util.RxTimerUtil
import
com.google.gson.Gson
import
com.google.gson.Gson
import
com.jess.arms.utils.DeviceUtils
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
okhttp3.*
import
okhttp3.*
import
okio.ByteString
import
okio.ByteString
...
@@ -45,7 +44,7 @@ class GetInfoUpdateService : Service() {
...
@@ -45,7 +44,7 @@ class GetInfoUpdateService : Service() {
/**
/**
* 心跳检测时间
* 心跳检测时间
*/
*/
private
val
HEART_BEAT_RATE
=
(
27
*
1000
).
toLong
()
//每隔15秒进行一次对长连接的心跳检测
private
val
HEART_BEAT_RATE
=
(
15
*
1000
).
toLong
()
//每隔15秒进行一次对长连接的心跳检测
private
val
WEBSOCKET_HOST_AND_PORT
=
"${ServiceCreator.ROOT_URL}/ricepon-websocket/js/webSocketServer"
//可替换为自己的主机名和端口号
private
val
WEBSOCKET_HOST_AND_PORT
=
"${ServiceCreator.ROOT_URL}/ricepon-websocket/js/webSocketServer"
//可替换为自己的主机名和端口号
private
var
mWebSocket
:
WebSocket
?
=
null
private
var
mWebSocket
:
WebSocket
?
=
null
...
@@ -56,6 +55,8 @@ class GetInfoUpdateService : Service() {
...
@@ -56,6 +55,8 @@ class GetInfoUpdateService : Service() {
private
var
newWakeLock
:
PowerManager
.
WakeLock
?
=
null
private
var
newWakeLock
:
PowerManager
.
WakeLock
?
=
null
private
var
myBind
:
MyBind
?
=
null
companion
object
{
companion
object
{
@kotlin
.
jvm
.
JvmField
@kotlin
.
jvm
.
JvmField
var
loginfo
=
StringBuffer
()
var
loginfo
=
StringBuffer
()
...
@@ -67,7 +68,8 @@ class GetInfoUpdateService : Service() {
...
@@ -67,7 +68,8 @@ class GetInfoUpdateService : Service() {
}
}
override
fun
onBind
(
intent
:
Intent
?):
IBinder
?
{
override
fun
onBind
(
intent
:
Intent
?):
IBinder
?
{
return
MyBind
()
myBind
=
MyBind
()
return
myBind
}
}
...
@@ -148,9 +150,15 @@ class GetInfoUpdateService : Service() {
...
@@ -148,9 +150,15 @@ class GetInfoUpdateService : Service() {
}
}
inner
class
MyBind
:
Binder
()
{
inner
class
MyBind
:
Binder
()
{
lateinit
var
block
:
(
isShow
:
Boolean
)
->
Unit
fun
setOnPostCallBack
(
postCallBack
:
PostCallBack
?)
{
fun
setOnPostCallBack
(
postCallBack
:
PostCallBack
?)
{
this
@GetInfoUpdateService
.
postCallBack
=
postCallBack
this
@GetInfoUpdateService
.
postCallBack
=
postCallBack
}
}
fun
execute
(
block
:
(
isShow
:
Boolean
)
->
Unit
)
{
this
.
block
=
block
}
}
}
internal
inner
class
InitSocketThread
:
Thread
()
{
internal
inner
class
InitSocketThread
:
Thread
()
{
...
@@ -192,6 +200,8 @@ class GetInfoUpdateService : Service() {
...
@@ -192,6 +200,8 @@ class GetInfoUpdateService : Service() {
Log
.
e
(
TAG
,
"token:$token"
)
Log
.
e
(
TAG
,
"token:$token"
)
webSocket
.
send
(
Gson
().
toJson
(
MsgBean
(
1
,
token
)))
webSocket
.
send
(
Gson
().
toJson
(
MsgBean
(
1
,
token
)))
putTimeLog
(
"連接成功"
)
putTimeLog
(
"連接成功"
)
RxTimerUtil
.
cancelTimerDisposable
()
myBind
?.
block
?.
invoke
(
false
)
}
}
}
}
...
@@ -209,7 +219,7 @@ class GetInfoUpdateService : Service() {
...
@@ -209,7 +219,7 @@ class GetInfoUpdateService : Service() {
}
else
{
}
else
{
//播放提示音
//播放提示音
initSoundPool
()
initSoundPool
(
R
.
raw
.
newordervocal
)
}
}
}
}
//收到服务器端传过来的消息text
//收到服务器端传过来的消息text
...
@@ -239,13 +249,12 @@ class GetInfoUpdateService : Service() {
...
@@ -239,13 +249,12 @@ class GetInfoUpdateService : Service() {
super
.
onClosed
(
webSocket
,
code
,
reason
)
super
.
onClosed
(
webSocket
,
code
,
reason
)
Log
.
e
(
TAG
,
"onClosed"
)
Log
.
e
(
TAG
,
"onClosed"
)
putTimeLog
(
"onClosed斷開連接"
)
putTimeLog
(
"onClosed斷開連接"
)
webSocket
?.
cancel
()
webSocket
?.
cancel
()
}
}
override
fun
onFailure
(
webSocket
:
WebSocket
?,
t
:
Throwable
?,
response
:
Response
?)
{
//长连接连接失败的回调
override
fun
onFailure
(
webSocket
:
WebSocket
?,
t
:
Throwable
?,
response
:
Response
?)
{
//长连接连接失败的回调
super
.
onFailure
(
webSocket
,
t
,
response
)
super
.
onFailure
(
webSocket
,
t
,
response
)
Log
.
e
(
TAG
,
"onFailure"
+
t
!!
.
message
)
Log
.
e
(
TAG
,
"onFailure
"
+
t
!!
.
message
)
if
(!
this
@GetInfoUpdateService
.
isDestroy
)
{
if
(!
this
@GetInfoUpdateService
.
isDestroy
)
{
// Log.e(TAG, "沒銷毀")
// Log.e(TAG, "沒銷毀")
// initSocket()//创建一个新的连接Expected HTTP 101 response but was '502 Bad Gateway'
// initSocket()//创建一个新的连接Expected HTTP 101 response but was '502 Bad Gateway'
...
@@ -253,6 +262,13 @@ class GetInfoUpdateService : Service() {
...
@@ -253,6 +262,13 @@ class GetInfoUpdateService : Service() {
webSocket
?.
cancel
()
webSocket
?.
cancel
()
it
.
dispatcher
().
cancelAll
()
it
.
dispatcher
().
cancelAll
()
}
}
//連接斷開,定時五秒,如果未重連,播放提示音
RxTimerUtil
.
delayFun
({
initSoundPool
(
R
.
raw
.
raw_disconnect
)
myBind
?.
block
?.
invoke
(
true
)
//推送給相關人員
noticePersonnel
(
t
.
message
)
},
10
)
putTimeLog
(
"onFailure連接失敗,等待一分鐘後重新連接"
)
putTimeLog
(
"onFailure連接失敗,等待一分鐘後重新連接"
)
}
}
})
})
...
@@ -261,62 +277,18 @@ class GetInfoUpdateService : Service() {
...
@@ -261,62 +277,18 @@ class GetInfoUpdateService : Service() {
},
HEART_BEAT_RATE
)
},
HEART_BEAT_RATE
)
}
}
private
var
soundPool
:
SoundPool
?
=
null
private
var
lastSoundTime
:
Long
=
0L
private
var
lastSoundTime
:
Long
=
0L
fun
initSoundPool
(
resId
:
Int
)
{
fun
initSoundPool
()
{
//实例化SoundPool
//sdk版本21是SoundPool 的一个分水岭
if
(
soundPool
==
null
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
21
)
{
val
builder
=
SoundPool
.
Builder
()
//传入最多播放音频数量,
builder
.
setMaxStreams
(
1
)
//AudioAttributes是一个封装音频各种属性的方法
val
attrBuilder
=
AudioAttributes
.
Builder
()
//设置音频流的合适的属性
attrBuilder
.
setLegacyStreamType
(
AudioManager
.
STREAM_MUSIC
)
//加载一个AudioAttributes
builder
.
setAudioAttributes
(
attrBuilder
.
build
())
soundPool
=
builder
.
build
()
}
else
{
/**
* 第一个参数:int maxStreams:SoundPool对象的最大并发流数
* 第二个参数:int streamType:AudioManager中描述的音频流类型
*第三个参数:int srcQuality:采样率转换器的质量。 目前没有效果。 使用0作为默认值。
*/
soundPool
=
SoundPool
(
1
,
AudioManager
.
STREAM_MUSIC
,
0
)
}
}
//可以通过四种途径来记载一个音频资源:
//1.通过一个AssetFileDescriptor对象
//int load(AssetFileDescriptor afd, int priority)
//2.通过一个资源ID
//int load(Context context, int resId, int priority)
//3.通过指定的路径加载
//int load(String path, int priority)
//4.通过FileDescriptor加载
//int load(FileDescriptor fd, long offset, long length, int priority)
//声音ID 加载音频资源,这里用的是第二种,第三个参数为priority,声音的优先级*API中指出,priority参数目前没有效果,建议设置为1。
val
nowTime
=
System
.
currentTimeMillis
()
//當前時間減去上次播放的時間,如果超過五秒,那麼才會再次播放提示聲
val
nowTime
=
System
.
currentTimeMillis
()
//當前時間減去上次播放的時間,如果超過五秒,那麼才會再次播放提示聲
Log
.
e
(
"eee"
,
"間隔時間"
+
(
nowTime
-
lastSoundTime
))
Log
.
e
(
"eee"
,
"間隔時間"
+
(
nowTime
-
lastSoundTime
))
putTimeLog
(
"現在時間:$nowTime 上次播放時間:$lastSoundTime"
)
putTimeLog
(
"現在時間:$nowTime 上次播放時間:$lastSoundTime"
)
if
(
nowTime
-
lastSoundTime
>
5000
)
{
putTimeLog
(
"新訂單播放:$nowTime"
)
putTimeLog
(
"新訂單播放:$nowTime"
)
if
(
resId
==
R
.
raw
.
newordervocal
&&
nowTime
-
lastSoundTime
>
5000
)
{
lastSoundTime
=
System
.
currentTimeMillis
()
lastSoundTime
=
System
.
currentTimeMillis
()
val
voiceId
=
soundPool
!!
.
load
(
this
,
R
.
raw
.
newordervocal
,
1
)
OtherOrderUtils
.
initSoundPool
(
this
,
resId
)
//异步需要等待加载完成,音频才能播放成功
}
else
{
soundPool
!!
.
setOnLoadCompleteListener
{
soundPool
,
sampleId
,
status
->
lastSoundTime
=
System
.
currentTimeMillis
()
if
(
status
==
0
)
{
OtherOrderUtils
.
initSoundPool
(
this
,
resId
)
//第一个参数soundID
//第二个参数leftVolume为左侧音量值(范围= 0.0到1.0)
//第三个参数rightVolume为右的音量值(范围= 0.0到1.0)
//第四个参数priority 为流的优先级,值越大优先级高,影响当同时播放数量超出了最大支持数时SoundPool对该流的处理
//第五个参数loop 为音频重复播放次数,0为值播放一次,-1为无限循环,其他值为播放loop+1次
//第六个参数 rate为播放的速率,范围0.5-2.0(0.5为一半速率,1.0为正常速率,2.0为两倍速率)
soundPool
.
play
(
voiceId
,
1f
,
1f
,
1
,
0
,
1f
)
}
}
}
}
}
}
...
@@ -332,30 +304,6 @@ class GetInfoUpdateService : Service() {
...
@@ -332,30 +304,6 @@ class GetInfoUpdateService : Service() {
return
sb
.
toString
()
return
sb
.
toString
()
}
}
// private var sendTime = 0L
// 发送心跳包
// private val mHandler = Handler()
// private val heartBeatRunnable = object : Runnable {
// override fun run() {
// if (!isDestroy) {
// if (System.currentTimeMillis() - sendTime >= HEART_BEAT_RATE) {
// val isSuccess = mWebSocket?.send("0")//发送一个空消息给服务器,通过发送消息的成功失败来判断长连接的连接状态
// Log.e(TAG, "連接狀態:$isSuccess")
//// if (isSuccess != null && !isSuccess) {//长连接已断开
// mHandler.removeCallbacks(this)
// mWebSocket?.cancel()//取消掉以前的长连接
// InitSocketThread().start()//创建一个新的连接
//// } else {//长连接处于连接状态
////
//// }
// sendTime = System.currentTimeMillis()
// }
//// mHandler.postDelayed(this, HEART_BEAT_RATE)//每隔一定的时间,对长连接进行一次心跳检测
// }
// }
// }
private
var
isDestroy
=
false
private
var
isDestroy
=
false
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
...
@@ -379,6 +327,8 @@ class GetInfoUpdateService : Service() {
...
@@ -379,6 +327,8 @@ class GetInfoUpdateService : Service() {
}
}
//停止定時心跳
//停止定時心跳
RxTimerUtil
.
cancelInterval
()
RxTimerUtil
.
cancelInterval
()
//停止延遲執行任務
RxTimerUtil
.
cancelTimerDisposable
()
//停止前台服務
//停止前台服務
stopForeground
(
true
)
stopForeground
(
true
)
//清除保持喚醒
//清除保持喚醒
...
@@ -394,6 +344,21 @@ class GetInfoUpdateService : Service() {
...
@@ -394,6 +344,21 @@ class GetInfoUpdateService : Service() {
.
subscribeOn
(
Schedulers
.
io
()).
subscribe
()
.
subscribeOn
(
Schedulers
.
io
()).
subscribe
()
}
}
/**
* 心跳接口報錯,推送給相關人員
*/
private
fun
noticePersonnel
(
pushContent
:
String
?){
val
requestBody
=
FormBody
.
Builder
()
.
add
(
"code"
,
AppConstans
.
RP_HEART_ERROR
)
//錯誤碼
.
add
(
"shopId"
,
GsaCloudApplication
.
getGsPosShopId
(
this
))
.
add
(
"source"
,
getString
(
R
.
string
.
app_name
))
//錯誤來源
.
add
(
"pushContent"
,
pushContent
+
""
)
//推送內容
.
add
(
"version"
,
DeviceUtils
.
getVersionName
(
this
))
//系統版本
.
build
()
OkHttp3Utils
.
post
(
HttpsConstans
.
ROOT_URL
+
"/member-web/api/monitor/pushAlarm"
,
requestBody
)
.
subscribeOn
(
Schedulers
.
io
()).
subscribe
()
}
inner
class
ClearHeartBroadcastReceiver
:
BroadcastReceiver
()
{
inner
class
ClearHeartBroadcastReceiver
:
BroadcastReceiver
()
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
//關閉service,會調用service的onDestroy
//關閉service,會調用service的onDestroy
...
@@ -401,6 +366,9 @@ class GetInfoUpdateService : Service() {
...
@@ -401,6 +366,9 @@ class GetInfoUpdateService : Service() {
}
}
}
}
/**
* 向日誌添加數據
*/
private
fun
putTimeLog
(
content
:
String
)
{
private
fun
putTimeLog
(
content
:
String
)
{
loginfo
.
append
(
TimeUtil
.
getCurrentDate
(
TimeUtil
.
dateFormatYMDHMS
))
loginfo
.
append
(
TimeUtil
.
getCurrentDate
(
TimeUtil
.
dateFormatYMDHMS
))
loginfo
.
append
(
":"
)
loginfo
.
append
(
":"
)
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/activity/OrderDetailsActivity.kt
View file @
6bdf3095
...
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
...
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import
com.ethanhua.skeleton.Skeleton
import
com.ethanhua.skeleton.Skeleton
import
com.ethanhua.skeleton.ViewSkeletonScreen
import
com.ethanhua.skeleton.ViewSkeletonScreen
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import
com.gingersoft.gsa.cloud.base.utils.other.TextUtil
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import
com.gingersoft.gsa.cloud.print.bean.OrderDetails
import
com.gingersoft.gsa.cloud.print.bean.OrderDetails
import
com.gingersoft.gsa.cloud.ui.utils.AppDialog
import
com.gingersoft.gsa.cloud.ui.utils.AppDialog
...
@@ -24,6 +25,7 @@ import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Compani
...
@@ -24,6 +25,7 @@ import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Compani
import
com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.DeliveryPrint
import
com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.DeliveryPrint
import
com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.OrderDelivery
import
com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.OrderDelivery
import
com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.PrintCode
import
com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.PrintCode
import
com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.ProductionComplete
import
com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.SendCode
import
com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.SendCode
import
com.gingersoft.gsa.other_order_mode.ui.adapter.FoodListAdapter
import
com.gingersoft.gsa.other_order_mode.ui.adapter.FoodListAdapter
import
com.gingersoft.gsa.other_order_mode.ui.adapter.OrderDetailsAdapter
import
com.gingersoft.gsa.other_order_mode.ui.adapter.OrderDetailsAdapter
...
@@ -191,57 +193,65 @@ class OrderDetailsActivity : BaseActivity() {
...
@@ -191,57 +193,65 @@ class OrderDetailsActivity : BaseActivity() {
}
}
else
->
{
else
->
{
showLoading
()
showLoading
()
updateOrderStatusByBtn
(
btnList
[
position
].
type
,
orderDetails
,
GsaCloudApplication
.
getRestaurantId
(
this
@OrderDetailsActivity
).
toString
())
{
status
,
isSuccess
->
updateOrderStatusByBtn
(
btnList
[
position
].
type
,
orderDetails
,
GsaCloudApplication
.
getRestaurantId
(
this
@OrderDetailsActivity
).
toString
())
{
msg
->
cancelDialogForLoading
()
cancelDialogForLoading
()
when
(
status
)
{
when
(
msg
.
code
)
{
DeliveryPrint
->
{
//訂單已確認,是否打印成功
DeliveryPrint
.
toString
()
->
{
//訂單已確認,是否打印成功
finish
()
finish
()
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
isS
uccess
)
{
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
msg
.
s
uccess
)
{
"打印成功"
"打印成功"
}
else
{
}
else
{
"打印失敗"
"打印失敗"
})
})
}
}
PrintCode
->
{
PrintCode
.
toString
()
->
{
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
isS
uccess
)
{
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
msg
.
s
uccess
)
{
"打印成功"
"打印成功"
}
else
{
}
else
{
"打印失敗"
"打印失敗"
})
})
}
}
SendCode
->
{
SendCode
.
toString
()
->
{
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
isS
uccess
)
{
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
msg
.
s
uccess
)
{
"已成功指派"
"已成功指派"
}
else
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
msg
.
errorMsg
)){
msg
.
errorMsg
}
else
{
}
else
{
"指派送貨失敗"
"指派送貨失敗"
})
})
if
(
isS
uccess
){
if
(
msg
.
s
uccess
){
finish
()
finish
()
}
}
}
}
OrderDelivery
->
{
OrderDelivery
.
toString
()
->
{
//已確認訂單,重新刷新當前頁面
//已確認訂單,重新刷新當前頁面
if
(
isS
uccess
)
{
if
(
msg
.
s
uccess
)
{
finish
()
finish
()
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
"訂單已確認"
)
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
"訂單已確認"
)
}
else
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
msg
.
errorMsg
)){
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
msg
.
errorMsg
)
}
else
{
}
else
{
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
"訂單確認失敗"
)
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
"訂單確認失敗"
)
}
}
// getOrderDetails(orderId, binding)
// getOrderDetails(orderId, binding)
}
}
Closing
->
{
Closing
.
toString
()
->
{
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
isS
uccess
)
{
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
msg
.
s
uccess
)
{
"結賬成功"
"結賬成功"
}
else
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
msg
.
errorMsg
)){
msg
.
errorMsg
}
else
{
}
else
{
"結賬失敗"
"結賬失敗"
})
})
}
}
P
ageViewModel
.
ProductionComplete
->
{
P
roductionComplete
.
toString
()
->
{
if
(
isS
uccess
)
{
if
(
msg
.
s
uccess
)
{
finish
()
finish
()
}
}
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
isS
uccess
)
{
ToastUtils
.
show
(
this
@OrderDetailsActivity
,
if
(
msg
.
s
uccess
)
{
"製作完成"
"製作完成"
}
else
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
msg
.
errorMsg
)){
msg
.
errorMsg
}
else
{
}
else
{
"修改訂單狀態失敗"
"修改訂單狀態失敗"
})
})
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/activity/OtherOrderActivity.kt
View file @
6bdf3095
...
@@ -34,6 +34,7 @@ import com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService
...
@@ -34,6 +34,7 @@ import com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService
import
com.gingersoft.gsa.other_order_mode.ui.adapter.SectionsPagerAdapter
import
com.gingersoft.gsa.other_order_mode.ui.adapter.SectionsPagerAdapter
import
com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import
com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import
com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import
com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import
com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
import
com.qmuiteam.qmui.alpha.QMUIAlphaTextView
import
com.qmuiteam.qmui.alpha.QMUIAlphaTextView
import
com.qmuiteam.qmui.util.QMUIDisplayHelper
import
com.qmuiteam.qmui.util.QMUIDisplayHelper
import
com.qmuiteam.qmui.widget.popup.QMUIPopup
import
com.qmuiteam.qmui.widget.popup.QMUIPopup
...
@@ -289,6 +290,7 @@ class OtherOrderActivity : BaseActivity() {
...
@@ -289,6 +290,7 @@ class OtherOrderActivity : BaseActivity() {
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
super
.
onDestroy
()
super
.
onDestroy
()
bind
?.
setOnPostCallBack
(
null
)
bind
?.
setOnPostCallBack
(
null
)
bind
?.
execute
{}
unregisterReceiver
(
mReceiver
)
unregisterReceiver
(
mReceiver
)
unbindService
(
serviceConnection
)
unbindService
(
serviceConnection
)
}
}
...
@@ -306,62 +308,19 @@ class OtherOrderActivity : BaseActivity() {
...
@@ -306,62 +308,19 @@ class OtherOrderActivity : BaseActivity() {
}
}
}
}
})
})
bind
?.
execute
{
Log
.
e
(
"eee"
,
"執行"
+
it
)
if
(
it
)
{
ivDisconnectView
.
visibility
=
View
.
VISIBLE
}
else
{
ivDisconnectView
.
visibility
=
View
.
INVISIBLE
}
}
}
}
override
fun
onServiceDisconnected
(
name
:
ComponentName
)
{
override
fun
onServiceDisconnected
(
name
:
ComponentName
)
{
}
}
}
}
// private var soundPool: SoundPool? = null
// fun initSoundPool() {
// //实例化SoundPool
// //sdk版本21是SoundPool 的一个分水岭
// if (soundPool == null) {
// if (Build.VERSION.SDK_INT >= 21) {
// val builder = SoundPool.Builder()
// //传入最多播放音频数量,
// builder.setMaxStreams(1)
// //AudioAttributes是一个封装音频各种属性的方法
// val attrBuilder = AudioAttributes.Builder()
// //设置音频流的合适的属性
// attrBuilder.setLegacyStreamType(AudioManager.STREAM_MUSIC)
// //加载一个AudioAttributes
// builder.setAudioAttributes(attrBuilder.build())
// soundPool = builder.build()
// } else {
// /**
// * 第一个参数:int maxStreams:SoundPool对象的最大并发流数
// * 第二个参数:int streamType:AudioManager中描述的音频流类型
// *第三个参数:int srcQuality:采样率转换器的质量。 目前没有效果。 使用0作为默认值。
// */
// soundPool = SoundPool(1, AudioManager.STREAM_MUSIC, 0)
// }
// }
// //可以通过四种途径来记载一个音频资源:
// //1.通过一个AssetFileDescriptor对象
// //int load(AssetFileDescriptor afd, int priority)
// //2.通过一个资源ID
// //int load(Context context, int resId, int priority)
// //3.通过指定的路径加载
// //int load(String path, int priority)
// //4.通过FileDescriptor加载
// //int load(FileDescriptor fd, long offset, long length, int priority)
// //声音ID 加载音频资源,这里用的是第二种,第三个参数为priority,声音的优先级*API中指出,priority参数目前没有效果,建议设置为1。
// val voiceId = soundPool!!.load(this, R.raw.newordervocal, 1)
// //异步需要等待加载完成,音频才能播放成功
// soundPool!!.setOnLoadCompleteListener { soundPool, sampleId, status ->
// if (status == 0) {
// //第一个参数soundID
// //第二个参数leftVolume为左侧音量值(范围= 0.0到1.0)
// //第三个参数rightVolume为右的音量值(范围= 0.0到1.0)
// //第四个参数priority 为流的优先级,值越大优先级高,影响当同时播放数量超出了最大支持数时SoundPool对该流的处理
// //第五个参数loop 为音频重复播放次数,0为值播放一次,-1为无限循环,其他值为播放loop+1次
// //第六个参数 rate为播放的速率,范围0.5-2.0(0.5为一半速率,1.0为正常速率,2.0为两倍速率)
// soundPool.play(voiceId, 1f, 1f, 1, 0, 1f)
// }
// }
// }
private
var
isOpen
:
Boolean
=
true
private
var
isOpen
:
Boolean
=
true
private
val
btnOpenBg
by
lazy
{
ContextCompat
.
getDrawable
(
this
,
R
.
drawable
.
shape_white_bottom_border
)
!!
}
private
val
btnOpenBg
by
lazy
{
ContextCompat
.
getDrawable
(
this
,
R
.
drawable
.
shape_white_bottom_border
)
!!
}
private
val
btnCloseBg
by
lazy
{
ContextCompat
.
getDrawable
(
this
,
R
.
drawable
.
shape_dialog_bg
)
!!
}
private
val
btnCloseBg
by
lazy
{
ContextCompat
.
getDrawable
(
this
,
R
.
drawable
.
shape_dialog_bg
)
!!
}
...
@@ -409,6 +368,7 @@ class OtherOrderActivity : BaseActivity() {
...
@@ -409,6 +368,7 @@ class OtherOrderActivity : BaseActivity() {
}
}
private
var
pop
:
QMUIPopup
?
=
null
private
var
pop
:
QMUIPopup
?
=
null
lateinit
var
ivDisconnectView
:
QMUIAlphaImageButton
/**
/**
* 初始化標題欄
* 初始化標題欄
*/
*/
...
@@ -459,7 +419,9 @@ class OtherOrderActivity : BaseActivity() {
...
@@ -459,7 +419,9 @@ class OtherOrderActivity : BaseActivity() {
// //歷史訂單
// //歷史訂單
// startActivity(Intent(this, HistoryOrderActivity::class.java))
// startActivity(Intent(this, HistoryOrderActivity::class.java))
// }
// }
qm_other_order_bar
.
setBackgroundColor
(
resources
.
getColor
(
R
.
color
.
theme_color
))
ivDisconnectView
=
qm_other_order_bar
.
addRightImageButton
(
R
.
drawable
.
ic_heart_disconnect
,
R
.
id
.
topbar_heart_disconnect
)
ivDisconnectView
.
visibility
=
View
.
INVISIBLE
qm_other_order_bar
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
theme_color
))
}
}
override
fun
onStart
()
{
override
fun
onStart
()
{
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/fragment/PlaceholderFragment.kt
View file @
6bdf3095
...
@@ -62,65 +62,6 @@ class PlaceholderFragment : BaseFragment(R.layout.fragment_other_order) {
...
@@ -62,65 +62,6 @@ class PlaceholderFragment : BaseFragment(R.layout.fragment_other_order) {
intent
.
putExtra
(
"orderPayType"
,
data
.
orderPayType
)
intent
.
putExtra
(
"orderPayType"
,
data
.
orderPayType
)
intent
.
putExtra
(
"isRead"
,
data
.
isRead
)
intent
.
putExtra
(
"isRead"
,
data
.
isRead
)
startActivity
(
intent
)
startActivity
(
intent
)
// showLoading()
// pageViewModel.getShipanyAndOrderInfo(data.curStat, GsaCloudApplication.getRestaurantId(context).toString(), data.Id.toString()) { it1 ->
// cancelDialogForLoading()
// //顯示彈窗
// if (this@PlaceholderFragment.context != null && it1 != null) {
// OtherOrderUtils.showOrderDetailsDialog(this@PlaceholderFragment.context!!, it1, data.STATUS, data.order_type) { view, _, dialog ->
// when (view.id) {
// R.id.btn_assign_shipping -> {
// //修改訂單狀態
// pageViewModel.updateOrderStatus(this@PlaceholderFragment.context!!, data, it1) {
// dialog.dismiss()
// if (it) {
// // 關閉彈窗,並刷新當前頁面
// refresh()
// }
// }
// }
// R.id.btn_cancel_order -> {
// //取消訂單,先判斷有沒有物流
// if (it1.data!![0].isDelete == 0) {
// //第三方物流單
// //彈出彈窗詢問是否確認取消
// AppDialog.showWaringDialog(context, "是否確認取消第三方派送?") { v, dialog ->
// when (v.id) {
// R.id.tv_dialog_confirm -> {
// //取消物流
// showLoading()
// pageViewModel.cancelLogistics(GsaCloudApplication.getRestaurantId(context).toString(), data.Id.toString()) {
// ToastUtils.show(context, it)
// cancelDialogForLoading()
// refresh()//刷新當前頁面
// }
// dialog.dismiss()
// }
// R.id.tv_dialog_cancel -> dialog.dismiss()
// }
// }
// } else {
// //本店配送的單
// pageViewModel.cancelOrder(context!!, data.Id.toString()) {
// ToastUtils.show(context, if (it) {
// "取消訂單成功"
// } else {
// "取消訂單失敗"
// })
// cancelDialogForLoading()
// refresh()//刷新當前頁面
// }
// }
// dialog.dismiss()
// }
// }
// }
// } else {
// ToastUtils.show(context, "獲取訂單詳情失敗")
// }
// }
}
}
rv_other_order
.
adapter
=
adapter
rv_other_order
.
adapter
=
adapter
...
...
other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/util/OtherOrderUtils.kt
View file @
6bdf3095
...
@@ -2,6 +2,11 @@ package com.gingersoft.gsa.other_order_mode.util
...
@@ -2,6 +2,11 @@ package com.gingersoft.gsa.other_order_mode.util
import
android.app.Dialog
import
android.app.Dialog
import
android.content.Context
import
android.content.Context
import
android.media.AudioAttributes
import
android.media.AudioManager
import
android.media.SoundPool
import
android.os.Build
import
android.util.Log
import
android.view.View
import
android.view.View
import
android.widget.ImageView
import
android.widget.ImageView
import
android.widget.TextView
import
android.widget.TextView
...
@@ -121,4 +126,59 @@ object OtherOrderUtils {
...
@@ -121,4 +126,59 @@ object OtherOrderUtils {
}
}
private
var
soundPool
:
SoundPool
?
=
null
fun
initSoundPool
(
context
:
Context
,
resId
:
Int
)
{
//实例化SoundPool
//sdk版本21是SoundPool 的一个分水岭
if
(
soundPool
==
null
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
21
)
{
val
builder
=
SoundPool
.
Builder
()
//传入最多播放音频数量,
builder
.
setMaxStreams
(
1
)
//AudioAttributes是一个封装音频各种属性的方法
val
attrBuilder
=
AudioAttributes
.
Builder
()
//设置音频流的合适的属性
attrBuilder
.
setLegacyStreamType
(
AudioManager
.
STREAM_MUSIC
)
//加载一个AudioAttributes
builder
.
setAudioAttributes
(
attrBuilder
.
build
())
soundPool
=
builder
.
build
()
}
else
{
/**
* 第一个参数:int maxStreams:SoundPool对象的最大并发流数
* 第二个参数:int streamType:AudioManager中描述的音频流类型
*第三个参数:int srcQuality:采样率转换器的质量。 目前没有效果。 使用0作为默认值。
*/
soundPool
=
SoundPool
(
1
,
AudioManager
.
STREAM_MUSIC
,
0
)
}
}
//可以通过四种途径来记载一个音频资源:
//1.通过一个AssetFileDescriptor对象
//int load(AssetFileDescriptor afd, int priority)
//2.通过一个资源ID
//int load(Context context, int resId, int priority)
//3.通过指定的路径加载
//int load(String path, int priority)
//4.通过FileDescriptor加载
//int load(FileDescriptor fd, long offset, long length, int priority)
//声音ID 加载音频资源,这里用的是第二种,第三个参数为priority,声音的优先级*API中指出,priority参数目前没有效果,建议设置为1。
loadSound
(
context
,
resId
)
}
private
fun
loadSound
(
context
:
Context
,
resId
:
Int
)
{
val
voiceId
=
soundPool
!!
.
load
(
context
,
resId
,
1
)
//异步需要等待加载完成,音频才能播放成功
soundPool
!!
.
setOnLoadCompleteListener
{
soundPool
,
sampleId
,
status
->
if
(
status
==
0
)
{
//第一个参数soundID
//第二个参数leftVolume为左侧音量值(范围= 0.0到1.0)
//第三个参数rightVolume为右的音量值(范围= 0.0到1.0)
//第四个参数priority 为流的优先级,值越大优先级高,影响当同时播放数量超出了最大支持数时SoundPool对该流的处理
//第五个参数loop 为音频重复播放次数,0为值播放一次,-1为无限循环,其他值为播放loop+1次
//第六个参数 rate为播放的速率,范围0.5-2.0(0.5为一半速率,1.0为正常速率,2.0为两倍速率)
soundPool
.
play
(
voiceId
,
1f
,
1f
,
1
,
0
,
1f
)
}
}
}
}
}
\ No newline at end of file
other_order_mode/src/main/res/layout/activity_other_order.xml
View file @
6bdf3095
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:layout_marginTop=
"@dimen/dp_5"
android:text=
"
本月
外賣訂單數:"
android:text=
"外賣訂單數:"
android:textColor=
"@color/color_a9"
android:textColor=
"@color/color_a9"
android:textSize=
"@dimen/dp_12"
android:textSize=
"@dimen/dp_12"
app:layout_constraintRight_toLeftOf=
"@id/tv_month_takeaway_num"
app:layout_constraintRight_toLeftOf=
"@id/tv_month_takeaway_num"
...
@@ -130,7 +130,7 @@
...
@@ -130,7 +130,7 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:layout_marginTop=
"@dimen/dp_5"
android:text=
"
本月
自取訂單數:"
android:text=
"自取訂單數:"
android:textColor=
"@color/color_a9"
android:textColor=
"@color/color_a9"
android:textSize=
"@dimen/dp_12"
android:textSize=
"@dimen/dp_12"
app:layout_constraintRight_toLeftOf=
"@id/tv_month_self_num"
app:layout_constraintRight_toLeftOf=
"@id/tv_month_self_num"
...
...
other_order_mode/src/main/res/layout/layout_order_receiving.xml
View file @
6bdf3095
...
@@ -42,11 +42,12 @@
...
@@ -42,11 +42,12 @@
android:id=
"@+id/btn_stop_service"
android:id=
"@+id/btn_stop_service"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParent
End
=
"true"
android:layout_alignParent
Right
=
"true"
android:paddingTop=
"@dimen/dp_5"
android:paddingTop=
"@dimen/dp_5"
android:paddingBottom=
"@dimen/dp_5"
android:paddingBottom=
"@dimen/dp_5"
android:paddingLeft=
"@dimen/dp_10"
android:paddingLeft=
"@dimen/dp_10"
android:paddingRight=
"@dimen/dp_10"
android:paddingRight=
"@dimen/dp_10"
android:layout_centerVertical=
"true"
android:background=
"@drawable/shape_cloas_btn"
android:background=
"@drawable/shape_cloas_btn"
android:text=
"停止接單"
android:text=
"停止接單"
android:textColor=
"@color/white"
android:textColor=
"@color/white"
...
...
other_order_mode/src/main/res/raw/raw_disconnect.m4a
0 → 100644
View file @
6bdf3095
File added
other_order_mode/src/main/res/raw/raw_get_order_list_error.m4a
0 → 100644
View file @
6bdf3095
File added
print-module/src/main/java/com/joe/print/mvp/model/bean/PrintInfoBean.java
View file @
6bdf3095
...
@@ -185,10 +185,9 @@ public class PrintInfoBean {
...
@@ -185,10 +185,9 @@ public class PrintInfoBean {
* @param datas prj數據
* @param datas prj數據
* @param printLocation 廚房位置
* @param printLocation 廚房位置
* @param deviceBean 打印機信息
* @param deviceBean 打印機信息
* @param printCurrencyBean 堂食or外賣配置
* @return 打印類集合
* @return 打印類集合
*/
*/
public
static
List
<
List
<
PrintInfoBean
>>
transPrjBean
(
List
<
PrjBean
.
DataBean
.
Bean
>
datas
,
String
printLocation
,
PrinterDeviceBean
deviceBean
,
PrintCurrencyBean
printCurrencyBean
)
{
public
static
List
<
List
<
PrintInfoBean
>>
transPrjBean
(
List
<
PrjBean
.
DataBean
.
Bean
>
datas
,
String
printLocation
,
PrinterDeviceBean
deviceBean
)
{
List
<
List
<
PrintInfoBean
>>
prjPrintBeans
=
new
ArrayList
<>();
List
<
List
<
PrintInfoBean
>>
prjPrintBeans
=
new
ArrayList
<>();
//通過打印位置生成多張用於打印的bitmap
//通過打印位置生成多張用於打印的bitmap
List
<
PrjBean
.
DataBean
.
Bean
>
noCut
=
new
ArrayList
<>();
List
<
PrjBean
.
DataBean
.
Bean
>
noCut
=
new
ArrayList
<>();
...
@@ -198,14 +197,14 @@ public class PrintInfoBean {
...
@@ -198,14 +197,14 @@ public class PrintInfoBean {
//切紙,單獨生成一條prj數據
//切紙,單獨生成一條prj數據
List
<
PrjBean
.
DataBean
.
Bean
>
beans
=
new
ArrayList
<>();
List
<
PrjBean
.
DataBean
.
Bean
>
beans
=
new
ArrayList
<>();
beans
.
add
(
prjbean
);
beans
.
add
(
prjbean
);
prjPrintBeans
.
add
(
getPrjPrintInfoBean
(
printLocation
,
beans
,
deviceBean
,
printCurrencyBean
));
prjPrintBeans
.
add
(
getPrjPrintInfoBean
(
printLocation
,
beans
,
deviceBean
));
}
else
{
}
else
{
//不切紙,保存到單獨的集合里,之後生成一組數據
//不切紙,保存到單獨的集合里,之後生成一組數據
noCut
.
add
(
prjbean
);
noCut
.
add
(
prjbean
);
}
}
}
}
if
(
noCut
.
size
()
>
0
)
{
if
(
noCut
.
size
()
>
0
)
{
prjPrintBeans
.
add
(
getPrjPrintInfoBean
(
printLocation
,
noCut
,
deviceBean
,
printCurrencyBean
));
prjPrintBeans
.
add
(
getPrjPrintInfoBean
(
printLocation
,
noCut
,
deviceBean
));
}
}
return
prjPrintBeans
;
return
prjPrintBeans
;
}
}
...
@@ -230,9 +229,9 @@ public class PrintInfoBean {
...
@@ -230,9 +229,9 @@ public class PrintInfoBean {
*
*
* @return
* @return
*/
*/
private
static
List
<
PrintInfoBean
>
getPrjPrintInfoBean
(
String
key
,
List
<
PrjBean
.
DataBean
.
Bean
>
prjBeans
,
PrinterDeviceBean
deviceBean
,
PrintCurrencyBean
printCurrencyBean
)
{
private
static
List
<
PrintInfoBean
>
getPrjPrintInfoBean
(
String
key
,
List
<
PrjBean
.
DataBean
.
Bean
>
prjBeans
,
PrinterDeviceBean
deviceBean
)
{
List
<
PrintInfoBean
>
printInfoBeans
=
new
ArrayList
<>();
List
<
PrintInfoBean
>
printInfoBeans
=
new
ArrayList
<>();
initPrintConfig
(
deviceBean
,
printCurrencyBean
);
initPrintConfig
(
deviceBean
);
if
(
prjBeans
==
null
||
prjBeans
.
size
()
<=
0
)
{
if
(
prjBeans
==
null
||
prjBeans
.
size
()
<=
0
)
{
return
null
;
return
null
;
}
}
...
@@ -331,7 +330,7 @@ public class PrintInfoBean {
...
@@ -331,7 +330,7 @@ public class PrintInfoBean {
*/
*/
public
static
List
<
PrintInfoBean
>
getTakeAwayBillPrint
(
Context
context
,
OrderDetails
.
DataBean
data
,
PrinterDeviceBean
deviceBean
,
PrintCurrencyBean
printCurrencyBean
)
{
public
static
List
<
PrintInfoBean
>
getTakeAwayBillPrint
(
Context
context
,
OrderDetails
.
DataBean
data
,
PrinterDeviceBean
deviceBean
,
PrintCurrencyBean
printCurrencyBean
)
{
List
<
PrintInfoBean
>
printInfoBeans
=
new
ArrayList
<>();
List
<
PrintInfoBean
>
printInfoBeans
=
new
ArrayList
<>();
initPrintConfig
(
deviceBean
,
printCurrencyBean
);
initPrintConfig
(
deviceBean
);
if
(
data
==
null
)
{
if
(
data
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -519,42 +518,15 @@ public class PrintInfoBean {
...
@@ -519,42 +518,15 @@ public class PrintInfoBean {
* 初始化打印配置
* 初始化打印配置
*
*
* @param deviceBean 打印機
* @param deviceBean 打印機
* @param printCurrencyBean 通用打印配置
*/
*/
private
static
void
initPrintConfig
(
PrinterDeviceBean
deviceBean
,
PrintCurrencyBean
printCurrencyBean
)
{
private
static
void
initPrintConfig
(
PrinterDeviceBean
deviceBean
)
{
if
(
printCurrencyBean
!=
null
)
{
foodColor
=
deviceBean
.
getFoodComplexion
();
foodColor
=
printCurrencyBean
.
getFoodComplexion
();
modifierColor
=
deviceBean
.
getModifierComplexion
();
modifierColor
=
printCurrencyBean
.
getModifierComplexion
();
foodIsBold
=
deviceBean
.
getFoodIsBold
()
==
1
;
}
foodItemIsBold
=
deviceBean
.
getModifierIsBold
()
==
1
;
foodIsItalic
=
deviceBean
.
getFoodIsItalic
()
==
1
;
if
(
deviceBean
.
getFoodIsBold
()
==
1
)
{
modifierIsItalic
=
deviceBean
.
getModifierIsItalic
()
==
1
;
foodIsBold
=
true
;
numberIsFlip
=
deviceBean
.
getNumberIsFlip
()
==
1
;
}
else
if
(
printCurrencyBean
!=
null
)
{
foodIsBold
=
printCurrencyBean
.
getFoodIsBold
()
==
1
;
}
if
(
deviceBean
.
getModifierIsBold
()
==
1
)
{
foodItemIsBold
=
true
;
}
else
if
(
printCurrencyBean
!=
null
)
{
foodItemIsBold
=
printCurrencyBean
.
getModifierIsBold
()
==
1
;
}
if
(
deviceBean
.
getFoodIsItalic
()
==
1
)
{
foodIsItalic
=
true
;
}
else
if
(
printCurrencyBean
!=
null
)
{
foodIsItalic
=
printCurrencyBean
.
getFoodIsItalic
()
==
1
;
}
if
(
deviceBean
.
getModifierIsItalic
()
==
1
)
{
modifierIsItalic
=
true
;
}
else
if
(
printCurrencyBean
!=
null
)
{
modifierIsItalic
=
printCurrencyBean
.
getModifierIsItalic
()
==
1
;
}
if
(
deviceBean
.
getNumberIsFlip
()
==
1
)
{
numberIsFlip
=
true
;
}
else
if
(
printCurrencyBean
!=
null
)
{
numberIsFlip
=
printCurrencyBean
.
getNumberIsFlip
()
==
1
;
}
if
((
deviceBean
.
getPrinterName
()
!=
null
&&
deviceBean
.
getPrinterName
().
toLowerCase
().
contains
(
"EPSON"
.
toLowerCase
()))
if
((
deviceBean
.
getPrinterName
()
!=
null
&&
deviceBean
.
getPrinterName
().
toLowerCase
().
contains
(
"EPSON"
.
toLowerCase
()))
&&
(
deviceBean
.
getModel
()
!=
null
&&
deviceBean
.
getModel
().
toLowerCase
().
contains
(
"TM-U220B"
.
toLowerCase
())))
{
&&
(
deviceBean
.
getModel
()
!=
null
&&
deviceBean
.
getModel
().
toLowerCase
().
contains
(
"TM-U220B"
.
toLowerCase
())))
{
cnLength
=
1.5
;
cnLength
=
1.5
;
...
...
print-module/src/main/java/com/joe/print/mvp/model/bean/PrjBean.java
View file @
6bdf3095
...
@@ -58,7 +58,7 @@ public class PrjBean {
...
@@ -58,7 +58,7 @@ public class PrjBean {
*/
*/
private
int
id
;
private
int
id
;
private
int
printerDeviceId
;
private
int
printerDeviceId
;
private
int
status
;
private
int
status
;
//為2是帶*,需要切紙的
private
String
tableName
;
private
String
tableName
;
private
String
orderNo
;
private
String
orderNo
;
private
int
orderTime
;
private
int
orderTime
;
...
...
print-module/src/main/java/com/joe/print/mvp/presenter/PrintPresenter.java
View file @
6bdf3095
...
@@ -2,12 +2,10 @@ package com.joe.print.mvp.presenter;
...
@@ -2,12 +2,10 @@ package com.joe.print.mvp.presenter;
import
android.app.Application
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.Context
;
import
android.util.Log
;
import
com.gingersoft.gsa.cloud.base.common.bean.BaseResult
;
import
com.gingersoft.gsa.cloud.base.common.bean.BaseResult
;
import
com.gingersoft.gsa.cloud.base.common.bean.PrinterManger.PrinterManager
;
import
com.gingersoft.gsa.cloud.base.common.bean.PrinterManger.PrinterManager
;
import
com.gingersoft.gsa.cloud.base.utils.JsonUtils
;
import
com.gingersoft.gsa.cloud.base.utils.JsonUtils
;
import
com.gingersoft.gsa.cloud.base.utils.other.SPUtils
;
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.bean.PrinterListBean
;
import
com.gingersoft.gsa.cloud.database.bean.PrinterListBean
;
...
@@ -19,7 +17,6 @@ import com.jess.arms.integration.AppManager;
...
@@ -19,7 +17,6 @@ import com.jess.arms.integration.AppManager;
import
com.jess.arms.mvp.BasePresenter
;
import
com.jess.arms.mvp.BasePresenter
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
com.joe.print.mvp.contract.PrintContract
;
import
com.joe.print.mvp.contract.PrintContract
;
import
com.joe.print.mvp.model.bean.PrjBean
;
import
com.joe.print.mvp.print.PrintBill
;
import
com.joe.print.mvp.print.PrintBill
;
import
com.joe.print.mvp.print.PrintCleanMachine
;
import
com.joe.print.mvp.print.PrintCleanMachine
;
import
com.joe.print.mvp.print.PrintInstruction
;
import
com.joe.print.mvp.print.PrintInstruction
;
...
@@ -30,7 +27,6 @@ import com.joe.print.mvp.print.PrintServe;
...
@@ -30,7 +27,6 @@ import com.joe.print.mvp.print.PrintServe;
import
com.joe.print.mvp.print.PrintSlip
;
import
com.joe.print.mvp.print.PrintSlip
;
import
com.joe.print.mvp.print.PrintTest
;
import
com.joe.print.mvp.print.PrintTest
;
import
com.joe.print.mvp.print.PrinterRoot
;
import
com.joe.print.mvp.print.PrinterRoot
;
import
com.joe.print.mvp.print.utils.MyPrintUtils
;
import
java.util.List
;
import
java.util.List
;
...
@@ -41,8 +37,6 @@ import io.reactivex.schedulers.Schedulers;
...
@@ -41,8 +37,6 @@ import io.reactivex.schedulers.Schedulers;
import
me.jessyan.rxerrorhandler.core.RxErrorHandler
;
import
me.jessyan.rxerrorhandler.core.RxErrorHandler
;
import
me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber
;
import
me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber
;
import
static
com
.
joe
.
print
.
mvp
.
print
.
PrinterRoot
.
PRINT_TEST
;
/**
/**
* ================================================
* ================================================
...
...
print-module/src/main/java/com/joe/print/mvp/print/EpsonPrint.java
View file @
6bdf3095
...
@@ -23,6 +23,8 @@ public class EpsonPrint implements ReceiveListener {
...
@@ -23,6 +23,8 @@ public class EpsonPrint implements ReceiveListener {
private
ReceiveListener
receiveListener
;
private
ReceiveListener
receiveListener
;
// private PrjPrintCallbackListener
private
static
EpsonPrint
epsonPrint
;
private
static
EpsonPrint
epsonPrint
;
public
static
EpsonPrint
getInstance
()
{
public
static
EpsonPrint
getInstance
()
{
...
@@ -168,17 +170,6 @@ public class EpsonPrint implements ReceiveListener {
...
@@ -168,17 +170,6 @@ public class EpsonPrint implements ReceiveListener {
// textData.delete(0, textData.length());
// textData.delete(0, textData.length());
//
//
// textData.append("400 OHEIDA 3PK SPRINGF 9.99 R\n");
// textData.append("400 OHEIDA 3PK SPRINGF 9.99 R\n");
// textData.append("410 3 CUP BLK TEAPOT 9.99 R\n");
// textData.append("445 EMERIL GRIDDLE/PAN 17.99 R\n");
// textData.append("438 CANDYMAKER ASSORT 4.99 R\n");
// textData.append("474 TRIPOD 8.99 R\n");
// textData.append("433 BLK LOGO PRNTED ZO 7.99 R\n");
// textData.append("458 AQUA MICROTERRY SC 6.99 R\n");
// textData.append("493 30L BLK FF DRESS 16.99 R\n");
// textData.append("407 LEVITATING DESKTOP 7.99 R\n");
// textData.append("441 **Blue Overprint P 2.99 R\n");
// textData.append("476 REPOSE 4PCPM CHOC 5.49 R\n");
// textData.append("461 WESTGATE BLACK 25 59.99 R\n");
// textData.append("------------------------------\n");
// textData.append("------------------------------\n");
// method = "addText";
// method = "addText";
// mPrinter.addText(textData.toString());
// mPrinter.addText(textData.toString());
...
@@ -328,62 +319,43 @@ public class EpsonPrint implements ReceiveListener {
...
@@ -328,62 +319,43 @@ public class EpsonPrint implements ReceiveListener {
}
}
}
}
public
int
putPrintData
(
String
ip
,
Bitmap
bitmap
)
{
public
void
putPrintData
(
String
ip
,
Bitmap
bitmap
)
{
//把bitmap存隊列中,下次打印
//把bitmap存隊列中,下次打印
bitmaps
.
add
(
bitmap
);
bitmaps
.
add
(
bitmap
);
if
(
isPrint
)
{
if
(
isPrint
)
{
//開啟定時,如果在10秒後沒執行回調,就修改打印狀態為沒打印
return
;
// startTimer(10);
return
0
;
}
}
isPrint
=
true
;
isPrint
=
true
;
return
printData
(
ip
,
bitmap
);
printData
(
ip
,
bitmap
);
}
}
//重試次數5次
//重試次數5次
private
int
resetCount
=
5
;
private
int
resetCount
=
5
;
private
int
printData
(
String
ip
,
Bitmap
bitmap
)
{
private
void
printData
(
String
ip
,
Bitmap
bitmap
)
{
mPrinter
.
clearCommandBuffer
();
mPrinter
.
clearCommandBuffer
();
if
(!
createPrintData
(
bitmap
))
{
if
(!
createPrintData
(
bitmap
))
{
return
0
;
return
;
}
}
if
(
mPrinter
==
null
)
{
if
(
mPrinter
==
null
)
{
return
0
;
return
;
}
}
connectByIp
(
ip
,
mPrinter
.
getStatus
());
connectByIp
(
ip
,
mPrinter
.
getStatus
());
if
(
mPrinter
==
null
)
{
if
(
mPrinter
==
null
)
{
return
0
;
return
;
}
}
PrinterStatusInfo
statusInfo
=
mPrinter
.
getStatus
();
PrinterStatusInfo
statusInfo
=
mPrinter
.
getStatus
();
// if (statusInfo.getConnection() != 1) {
// if (resetCount > 0) {
// //沒連接上打印機,延遲2秒後再試
// resetCount--;
// if (resetCount < 3) {
// //試了兩次還不能連接上,斷開連接
// disconnectPrinter();
// }
// startTimer(5);
// }
// return 0;
// }
if
(
statusInfo
.
getPaper
()
==
2
)
{
if
(
statusInfo
.
getPaper
()
==
2
)
{
//沒紙了
//沒紙了
return
2
;
return
;
}
}
try
{
try
{
mPrinter
.
sendData
(
Printer
.
PARAM_DEFAULT
);
mPrinter
.
sendData
(
Printer
.
PARAM_DEFAULT
);
if
(
timerDisposable
!=
null
)
{
timerDisposable
.
dispose
();
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
mPrinter
.
clearCommandBuffer
();
mPrinter
.
clearCommandBuffer
();
disconnectPrinter
();
disconnectPrinter
();
isPrint
=
false
;
isPrint
=
false
;
return
0
;
}
}
return
1
;
}
}
private
Disposable
timerDisposable
;
private
Disposable
timerDisposable
;
...
@@ -493,7 +465,6 @@ public class EpsonPrint implements ReceiveListener {
...
@@ -493,7 +465,6 @@ public class EpsonPrint implements ReceiveListener {
bitmaps
.
remove
(
0
);
bitmaps
.
remove
(
0
);
}
}
if
(
bitmaps
.
size
()
>
0
)
{
if
(
bitmaps
.
size
()
>
0
)
{
// startTimer(2);
printData
(
ipAddress
,
bitmaps
.
get
(
0
));
printData
(
ipAddress
,
bitmaps
.
get
(
0
));
}
else
{
}
else
{
isPrint
=
false
;
isPrint
=
false
;
...
...
print-module/src/main/java/com/joe/print/mvp/print/IpPrintMaker.java
View file @
6bdf3095
...
@@ -5,6 +5,7 @@ import android.graphics.Bitmap;
...
@@ -5,6 +5,7 @@ import android.graphics.Bitmap;
import
android.graphics.Canvas
;
import
android.graphics.Canvas
;
import
android.graphics.Matrix
;
import
android.graphics.Matrix
;
import
android.graphics.Rect
;
import
android.graphics.Rect
;
import
android.util.Log
;
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.print.PrintDataMaker
;
import
com.gingersoft.gsa.cloud.print.PrintDataMaker
;
...
@@ -43,14 +44,15 @@ public class IpPrintMaker implements PrintDataMaker {
...
@@ -43,14 +44,15 @@ public class IpPrintMaker implements PrintDataMaker {
ToastUtils
.
show
(
mContext
,
"打印失敗"
);
ToastUtils
.
show
(
mContext
,
"打印失敗"
);
return
null
;
return
null
;
}
}
Log
.
e
(
"eee"
,
"個數:"
+
bitmaps
.
size
());
for
(
int
i
=
0
;
i
<
bitmaps
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
bitmaps
.
size
();
i
++)
{
ArrayList
<
byte
[]>
image1
=
printer
.
getImageByte
(
bitmaps
.
get
(
i
));
//將bitmap縮放到打印機紙張大小再添加到集合中。
ArrayList
<
byte
[]>
image1
=
printer
.
getImageByte
(
bitmaps
.
get
(
i
));
//將bitmap縮放到打印機紙張大小再添加到集合中。
data
.
addAll
(
image1
);
//draw2PxPoint2(bitmaps.get(i)
data
.
addAll
(
image1
);
//draw2PxPoint2(bitmaps.get(i)
printer
.
printLineFeed
();
printer
.
printLineFeed
();
printer
.
printLineFeed
();
printer
.
printLineFeed
();
printer
.
printLineFeed
();
printer
.
printLineFeed
();
printer
.
printLineFeed
();
//
printer.printLineFeed();
printer
.
printLineFeed
();
//
printer.printLineFeed();
printer
.
feedPaperCutPartial
();
printer
.
feedPaperCutPartial
();
data
.
add
(
printer
.
getDataAndReset
());
data
.
add
(
printer
.
getDataAndReset
());
}
}
...
@@ -60,4 +62,9 @@ public class IpPrintMaker implements PrintDataMaker {
...
@@ -60,4 +62,9 @@ public class IpPrintMaker implements PrintDataMaker {
return
new
ArrayList
<>();
return
new
ArrayList
<>();
}
}
}
}
@Override
public
String
getPrjIds
()
{
return
null
;
}
}
}
print-module/src/main/java/com/joe/print/mvp/print/OpenCashBoxMaker.java
View file @
6bdf3095
...
@@ -26,4 +26,9 @@ public class OpenCashBoxMaker implements PrintDataMaker {
...
@@ -26,4 +26,9 @@ public class OpenCashBoxMaker implements PrintDataMaker {
return
new
ArrayList
<>();
return
new
ArrayList
<>();
}
}
}
}
@Override
public
String
getPrjIds
()
{
return
null
;
}
}
}
print-module/src/main/java/com/joe/print/mvp/print/PrintBill.java
View file @
6bdf3095
...
@@ -41,7 +41,7 @@ public class PrintBill extends PrinterRoot {
...
@@ -41,7 +41,7 @@ public class PrintBill extends PrinterRoot {
public
Map
<
String
,
List
<
Bitmap
>>
getPrintBitmap
(
Context
mContext
,
PrinterDeviceBean
deviceBean
)
{
public
Map
<
String
,
List
<
Bitmap
>>
getPrintBitmap
(
Context
mContext
,
PrinterDeviceBean
deviceBean
)
{
Map
<
String
,
List
<
Bitmap
>>
bitmapMaps
=
new
HashMap
<>();
Map
<
String
,
List
<
Bitmap
>>
bitmapMaps
=
new
HashMap
<>();
List
<
Bitmap
>
bitmaps
=
new
ArrayList
<>();
List
<
Bitmap
>
bitmaps
=
new
ArrayList
<>();
bitmaps
.
add
(
get
ServeBitmap
(
mContext
));
bitmaps
.
add
(
get
Bitmap
(
mContext
,
deviceBean
));
bitmapMaps
.
put
(
""
,
bitmaps
);
bitmapMaps
.
put
(
""
,
bitmaps
);
return
bitmapMaps
;
return
bitmapMaps
;
}
}
...
@@ -158,7 +158,7 @@ public class PrintBill extends PrinterRoot {
...
@@ -158,7 +158,7 @@ public class PrintBill extends PrinterRoot {
layout
.
addView
(
getLine
(
mContext
));
layout
.
addView
(
getLine
(
mContext
));
//食品信息
//食品信息
layout
.
addView
(
getDiningFoodList
(
mContext
,
foodList
));
layout
.
addView
(
getDiningFoodList
(
mContext
,
foodList
,
deviceBean
));
layout
.
addView
(
getHalfLine
(
mContext
));
layout
.
addView
(
getHalfLine
(
mContext
));
//訂單金額信息
//訂單金額信息
...
@@ -172,6 +172,8 @@ public class PrintBill extends PrinterRoot {
...
@@ -172,6 +172,8 @@ public class PrintBill extends PrinterRoot {
}
}
}
}
layout
.
addView
(
getDiningBillInfo
(
mContext
,
billingBeans
));
layout
.
addView
(
getDiningBillInfo
(
mContext
,
billingBeans
));
layout
.
addView
(
getHalfLine
(
mContext
));
layout
.
addView
(
getHalfLine
(
mContext
));
BigDecimal
totalAmount
=
new
BigDecimal
(
0
);
BigDecimal
totalAmount
=
new
BigDecimal
(
0
);
...
...
print-module/src/main/java/com/joe/print/mvp/print/PrintCleanMachine.java
View file @
6bdf3095
...
@@ -21,7 +21,7 @@ public class PrintCleanMachine extends PrinterRoot {
...
@@ -21,7 +21,7 @@ public class PrintCleanMachine extends PrinterRoot {
public
Map
<
String
,
List
<
Bitmap
>>
getPrintBitmap
(
Context
mContext
,
PrinterDeviceBean
deviceBean
)
{
public
Map
<
String
,
List
<
Bitmap
>>
getPrintBitmap
(
Context
mContext
,
PrinterDeviceBean
deviceBean
)
{
Map
<
String
,
List
<
Bitmap
>>
bitmapMaps
=
new
HashMap
<>();
Map
<
String
,
List
<
Bitmap
>>
bitmapMaps
=
new
HashMap
<>();
List
<
Bitmap
>
bitmaps
=
new
ArrayList
<>();
List
<
Bitmap
>
bitmaps
=
new
ArrayList
<>();
bitmaps
.
add
(
getServeBitmap
(
mContext
));
bitmaps
.
add
(
getServeBitmap
(
mContext
,
deviceBean
));
bitmapMaps
.
put
(
""
,
bitmaps
);
bitmapMaps
.
put
(
""
,
bitmaps
);
return
bitmapMaps
;
return
bitmapMaps
;
}
}
...
@@ -38,10 +38,10 @@ public class PrintCleanMachine extends PrinterRoot {
...
@@ -38,10 +38,10 @@ public class PrintCleanMachine extends PrinterRoot {
* @param mContext
* @param mContext
* @return
* @return
*/
*/
private
Bitmap
getServeBitmap
(
Context
mContext
)
{
private
Bitmap
getServeBitmap
(
Context
mContext
,
PrinterDeviceBean
deviceBean
)
{
View
view
=
PrintTransitUtils
.
getInstance
().
getPrintView
();
View
view
=
PrintTransitUtils
.
getInstance
().
getPrintView
();
if
(
view
!=
null
)
{
if
(
view
!=
null
)
{
return
viewTo
Bitmap
(
mContext
,
view
);
return
viewTo
ZoomBitmap
(
mContext
,
view
,
deviceBean
);
}
}
return
null
;
return
null
;
}
}
...
...
print-module/src/main/java/com/joe/print/mvp/print/PrintOtherOrder.java
View file @
6bdf3095
...
@@ -11,6 +11,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
...
@@ -11,6 +11,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.base.common.bean.OrderDetail
;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage
;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
import
com.gingersoft.gsa.cloud.base.utils.other.TextUtil
;
import
com.gingersoft.gsa.cloud.base.utils.other.TextUtil
;
...
@@ -31,6 +32,9 @@ import java.util.List;
...
@@ -31,6 +32,9 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
/**
* 外送接單,印單
*/
public
class
PrintOtherOrder
extends
PrinterRoot
{
public
class
PrintOtherOrder
extends
PrinterRoot
{
...
@@ -129,7 +133,8 @@ public class PrintOtherOrder extends PrinterRoot {
...
@@ -129,7 +133,8 @@ public class PrintOtherOrder extends PrinterRoot {
// }
// }
//如果需要打印印單,加上
//如果需要打印印單,加上
List
<
Bitmap
>
bitmaps
=
new
ArrayList
<>();
List
<
Bitmap
>
bitmaps
=
new
ArrayList
<>();
Bitmap
bitmap
=
initPrintView
(
mContext
,
dataBean
);
// Bitmap bitmap = initPrintView(mContext, dataBean);
Bitmap
bitmap
=
getBitmap
(
mContext
,
dataBean
,
deviceBean
);
bitmaps
.
add
(
bitmap
);
bitmaps
.
add
(
bitmap
);
merge2ResultMap
(
bitmapMaps
,
""
,
bitmaps
);
merge2ResultMap
(
bitmapMaps
,
""
,
bitmaps
);
return
bitmapMaps
;
return
bitmapMaps
;
...
@@ -207,6 +212,59 @@ public class PrintOtherOrder extends PrinterRoot {
...
@@ -207,6 +212,59 @@ public class PrintOtherOrder extends PrinterRoot {
return
viewToBitmap
(
context
,
view
);
return
viewToBitmap
(
context
,
view
);
}
}
private
Bitmap
getBitmap
(
Context
mContext
,
OrderDetails
.
DataBean
data
,
PrinterDeviceBean
deviceBean
)
{
LinearLayout
layout
=
new
LinearLayout
(
mContext
);
layout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
//頭部
layout
.
addView
(
getHeader
(
mContext
));
//訂單信息
layout
.
addView
(
getTakeawayOrderInfo
(
mContext
,
data
));
//食品
layout
.
addView
(
getTextLine
(
mContext
,
"項目"
));
layout
.
addView
(
getDiningFoodList
(
mContext
,
OrderDetail
.
productMameBeanToOrderDetail
(
0
,
data
.
getPRODUCT_NAME
()),
deviceBean
));
layout
.
addView
(
getLine
(
mContext
));
//訂單金額信息
List
<
PrintBillBean
>
billData
=
new
ArrayList
<>();
billData
.
add
(
getBillBean
(
"合計:"
,
MONETARY_UNIT
+
MoneyUtil
.
sub
(
MoneyUtil
.
sub
(
Double
.
parseDouble
(
data
.
getTOTAL_AMOUNT
()),
data
.
getLunchbox
()),
data
.
getDELIVERY_CHARGE
())));
if
(
data
.
getLunchbox
()
!=
0
)
{
billData
.
add
(
getBillBean
(
"餐盒費:"
,
MONETARY_UNIT
+
data
.
getLunchbox
()));
}
if
(
data
.
getDELIVERY_CHARGE
()
!=
0
)
{
billData
.
add
(
getBillBean
(
"送貨費:"
,
MONETARY_UNIT
+
data
.
getDELIVERY_CHARGE
()));
}
if
(
data
.
getCouponList
()
!=
null
&&
data
.
getCouponList
().
size
()
>
0
)
{
for
(
OrderDetails
.
DataBean
.
CouponBean
coupon
:
data
.
getCouponList
())
{
billData
.
add
(
getBillBean
(
coupon
.
getCouponName
()
+
":"
,
"-"
+
MONETARY_UNIT
+
coupon
.
getDiscount_amount
()));
}
}
layout
.
addView
(
getTakeawayBillInfoView
(
mContext
,
billData
));
layout
.
addView
(
getLine
(
mContext
));
//總金額34sp
layout
.
addView
(
getTakeawayLargeAmount
(
mContext
,
"總金額:"
,
MONETARY_UNIT
+
data
.
getTOTAL_AMOUNT
()));
layout
.
addView
(
getLine
(
mContext
));
//支付金額
layout
.
addView
(
getTakeawayLargeAmount
(
mContext
,
"支付金額:"
,
MONETARY_UNIT
+
MoneyUtil
.
sub
(
Double
.
parseDouble
(
data
.
getTOTAL_AMOUNT
()),
data
.
getDiscount_amount
())
+
""
));
layout
.
addView
(
getLine
(
mContext
));
//用戶信息
String
address
=
""
;
String
receiver
=
""
;
if
(
data
.
getOrder_type
()
==
2
)
{
//收貨地址
address
=
"地址:"
+
data
.
getAddressDetail
();
//收貨人
receiver
=
"收貨人:"
+
data
.
getRECEIVER
();
}
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
address
))
{
layout
.
addView
(
getTakeawayTextView
(
mContext
,
address
));
}
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
receiver
))
{
layout
.
addView
(
getTakeawayTextView
(
mContext
,
receiver
));
}
layout
.
addView
(
getTakeawayTextView
(
mContext
,
"手機號:"
+
data
.
getPHONE
()));
//尾部
return
viewToZoomBitmap
(
mContext
,
layout
,
deviceBean
);
}
private
Bitmap
initPrintView
(
Context
context
,
OrderDetails
.
DataBean
data
)
{
private
Bitmap
initPrintView
(
Context
context
,
OrderDetails
.
DataBean
data
)
{
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
print_confirm_order_view
,
null
,
false
);
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
print_confirm_order_view
,
null
,
false
);
...
...
print-module/src/main/java/com/joe/print/mvp/print/PrintOtherOrderClosing.java
View file @
6bdf3095
...
@@ -39,7 +39,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
...
@@ -39,7 +39,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
if
(
dataBean
!=
null
)
{
if
(
dataBean
!=
null
)
{
Map
<
String
,
List
<
Bitmap
>>
bitmapMaps
=
new
HashMap
<>();
Map
<
String
,
List
<
Bitmap
>>
bitmapMaps
=
new
HashMap
<>();
List
<
Bitmap
>
bitmaps
=
new
ArrayList
<>();
List
<
Bitmap
>
bitmaps
=
new
ArrayList
<>();
bitmaps
.
add
(
initPrintView
(
mContext
,
dataBean
));
bitmaps
.
add
(
initPrintView
(
mContext
,
dataBean
,
deviceBean
));
bitmapMaps
.
put
(
""
,
bitmaps
);
bitmapMaps
.
put
(
""
,
bitmaps
);
return
bitmapMaps
;
return
bitmapMaps
;
}
}
...
@@ -61,7 +61,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
...
@@ -61,7 +61,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
return
printCount
;
return
printCount
;
}
}
private
Bitmap
initPrintView
(
Context
context
,
OrderDetails
.
DataBean
data
)
{
private
Bitmap
initPrintView
(
Context
context
,
OrderDetails
.
DataBean
data
,
PrinterDeviceBean
deviceBean
)
{
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
print_confirm_order_view
,
null
,
false
);
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
print_confirm_order_view
,
null
,
false
);
TextView
tvMemberNum
=
view
.
findViewById
(
R
.
id
.
tv_member_number
);
//會員號碼
TextView
tvMemberNum
=
view
.
findViewById
(
R
.
id
.
tv_member_number
);
//會員號碼
TextView
tvMemberName
=
view
.
findViewById
(
R
.
id
.
tv_member_name
);
//會員名稱
TextView
tvMemberName
=
view
.
findViewById
(
R
.
id
.
tv_member_name
);
//會員名稱
...
@@ -185,7 +185,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
...
@@ -185,7 +185,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
tvOldPoints
.
setVisibility
(
View
.
VISIBLE
);
tvOldPoints
.
setVisibility
(
View
.
VISIBLE
);
lineMember
.
setVisibility
(
View
.
VISIBLE
);
lineMember
.
setVisibility
(
View
.
VISIBLE
);
}
}
return
viewTo
Bitmap
(
context
,
view
);
return
viewTo
ZoomBitmap
(
context
,
view
,
deviceBean
);
}
}
private
PrintBillBean
getBillBean
(
String
title
,
String
value
)
{
private
PrintBillBean
getBillBean
(
String
title
,
String
value
)
{
...
...
print-module/src/main/java/com/joe/print/mvp/print/PrintPrjKitchen.java
View file @
6bdf3095
...
@@ -64,13 +64,19 @@ public class PrintPrjKitchen extends PrinterRoot {
...
@@ -64,13 +64,19 @@ public class PrintPrjKitchen extends PrinterRoot {
return
1
;
return
1
;
}
}
public
Bitmap
getKitChenPrintBitmap
(
Context
context
,
String
key
,
PrjBean
.
DataBean
.
Bean
data
)
{
List
<
PrjBean
.
DataBean
.
Bean
>
beans
=
new
ArrayList
<>();
beans
.
add
(
data
);
return
getKitChenPrintBitmap
(
context
,
key
,
beans
);
}
/**
/**
* 獲取"廚房單"圖片
* 獲取"廚房單"圖片
*
*
* @param context
* @param context
* @return
* @return
*/
*/
p
rivate
Bitmap
getKitChenPrintBitmap
(
Context
context
,
String
key
,
List
<
PrjBean
.
DataBean
.
Bean
>
data
)
{
p
ublic
Bitmap
getKitChenPrintBitmap
(
Context
context
,
String
key
,
List
<
PrjBean
.
DataBean
.
Bean
>
data
)
{
if
(
data
==
null
||
data
.
size
()
<=
0
)
{
if
(
data
==
null
||
data
.
size
()
<=
0
)
{
return
null
;
return
null
;
}
}
...
@@ -134,7 +140,7 @@ public class PrintPrjKitchen extends PrinterRoot {
...
@@ -134,7 +140,7 @@ public class PrintPrjKitchen extends PrinterRoot {
if
(
prjBean
.
getOrderType
()
==
7
)
{
if
(
prjBean
.
getOrderType
()
==
7
)
{
tvTableNumber
.
setText
(
"自取"
);
tvTableNumber
.
setText
(
"自取"
);
tvTableNumber2
.
setText
(
"自取"
);
tvTableNumber2
.
setText
(
"自取"
);
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
prjBean
.
getTakeFoodCode
()))
{
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
prjBean
.
getTakeFoodCode
()))
{
tvTakeCodeText
.
setVisibility
(
View
.
VISIBLE
);
tvTakeCodeText
.
setVisibility
(
View
.
VISIBLE
);
tvTakeCode
.
setVisibility
(
View
.
VISIBLE
);
tvTakeCode
.
setVisibility
(
View
.
VISIBLE
);
tvTakeCode
.
setText
(
prjBean
.
getTakeFoodCode
());
tvTakeCode
.
setText
(
prjBean
.
getTakeFoodCode
());
...
...
print-module/src/main/java/com/joe/print/mvp/print/PrinterRoot.java
View file @
6bdf3095
...
@@ -14,6 +14,7 @@ import android.view.View;
...
@@ -14,6 +14,7 @@ import android.view.View;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
androidx.annotation.ColorRes
;
import
androidx.core.content.ContextCompat
;
import
androidx.core.content.ContextCompat
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView
;
...
@@ -29,7 +30,10 @@ import com.gingersoft.gsa.cloud.base.common.bean.BillingBean;
...
@@ -29,7 +30,10 @@ import com.gingersoft.gsa.cloud.base.common.bean.BillingBean;
import
com.gingersoft.gsa.cloud.base.common.bean.OrderDetail
;
import
com.gingersoft.gsa.cloud.base.common.bean.OrderDetail
;
import
com.gingersoft.gsa.cloud.base.common.bean.PayMethod
;
import
com.gingersoft.gsa.cloud.base.common.bean.PayMethod
;
import
com.gingersoft.gsa.cloud.base.utils.AidlUtil
;
import
com.gingersoft.gsa.cloud.base.utils.AidlUtil
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
import
com.gingersoft.gsa.cloud.base.utils.other.SPUtils
;
import
com.gingersoft.gsa.cloud.base.utils.other.SPUtils
;
import
com.gingersoft.gsa.cloud.base.utils.other.TextUtil
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
;
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.base.utils.view.ImageUtils
;
import
com.gingersoft.gsa.cloud.base.utils.view.ImageUtils
;
import
com.gingersoft.gsa.cloud.base.utils.view.LayoutToBitmapUtils
;
import
com.gingersoft.gsa.cloud.base.utils.view.LayoutToBitmapUtils
;
...
@@ -39,11 +43,13 @@ import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
...
@@ -39,11 +43,13 @@ import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
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.PrinterWriter58mm
;
import
com.gingersoft.gsa.cloud.print.PrinterWriter58mm
;
import
com.gingersoft.gsa.cloud.print.bean.OrderDetails
;
import
com.hyweb.n5.lib.constant.PrinterConstant
;
import
com.hyweb.n5.lib.constant.PrinterConstant
;
import
com.hyweb.n5.lib.util.PrinterUtil
;
import
com.hyweb.n5.lib.util.PrinterUtil
;
import
com.hyweb.n5.server.aidl.IOnPrintCallback
;
import
com.hyweb.n5.server.aidl.IOnPrintCallback
;
import
com.jess.arms.utils.ArmsUtils
;
import
com.jess.arms.utils.ArmsUtils
;
import
com.joe.print.R
;
import
com.joe.print.R
;
import
com.joe.print.mvp.model.bean.PrintBillBean
;
import
com.joe.print.mvp.print.common.PrinterFinderCallback
;
import
com.joe.print.mvp.print.common.PrinterFinderCallback
;
import
com.joe.print.mvp.print.common.SendResultCode
;
import
com.joe.print.mvp.print.common.SendResultCode
;
import
com.joe.print.mvp.print.usb.EscCommand
;
import
com.joe.print.mvp.print.usb.EscCommand
;
...
@@ -51,10 +57,13 @@ import com.joe.print.mvp.print.usb.UsbPrint;
...
@@ -51,10 +57,13 @@ import com.joe.print.mvp.print.usb.UsbPrint;
import
com.joe.print.mvp.print.usb.UsbPrinter
;
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.ui.activity.PrintActivity
;
import
com.joe.print.mvp.ui.activity.PrintActivity
;
import
com.joe.print.mvp.ui.adapter.BillItemAdapter
;
import
com.joe.print.mvp.ui.adapter.DialogPrinterListAdapter
;
import
com.joe.print.mvp.ui.adapter.DialogPrinterListAdapter
;
import
com.sunmi.peripheral.printer.InnerResultCallbcak
;
import
com.sunmi.peripheral.printer.InnerResultCallbcak
;
import
com.yanzhenjie.recyclerview.widget.DefaultItemDecoration
;
import
com.yanzhenjie.recyclerview.widget.DefaultItemDecoration
;
import
org.w3c.dom.Text
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
...
@@ -74,6 +83,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
...
@@ -74,6 +83,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
public
final
static
int
PRINT_INSTRUCTION
=
6
;
//開錢箱
public
final
static
int
PRINT_INSTRUCTION
=
6
;
//開錢箱
public
final
static
int
PRINT_OTHER_CLOSING
=
7
;
//外賣結賬單
public
final
static
int
PRINT_OTHER_CLOSING
=
7
;
//外賣結賬單
protected
final
String
MONETARY_UNIT
=
"$"
;
private
final
static
int
SUNMI_PAPER_WIDTH
=
360
;
//商米打印機紙張寬度
private
final
static
int
SUNMI_PAPER_WIDTH
=
360
;
//商米打印機紙張寬度
private
final
static
int
N5_PAPER_WIDTH
=
500
;
//N5打印機紙張寬度
private
final
static
int
N5_PAPER_WIDTH
=
500
;
//N5打印機紙張寬度
...
@@ -518,17 +528,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
...
@@ -518,17 +528,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
ipDevicePrint
(
printerDeviceBean
,
bitmaps
,
this
,
this
);
ipDevicePrint
(
printerDeviceBean
,
bitmaps
,
this
,
this
);
}
}
public
Bitmap
zoomBitmap
(
PrinterDeviceBean
printerDeviceBean
,
Bitmap
bitmap
)
{
int
printWidth
;
if
(
printerDeviceBean
!=
null
&&
printerDeviceBean
.
getPaperSpecification
()
!=
null
)
{
printWidth
=
Double
.
valueOf
(
printerDeviceBean
.
getPaperSpecification
()).
intValue
();
}
else
{
//如果打印機沒設置寬度
printWidth
=
480
;
}
return
ImageUtils
.
zoomDrawable
(
bitmap
,
printWidth
);
}
private
EpsonPrint
mPrinter
;
private
EpsonPrint
mPrinter
;
...
@@ -538,64 +537,23 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
...
@@ -538,64 +537,23 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
public
void
ipDevicePrint
(
PrinterDeviceBean
public
void
ipDevicePrint
(
PrinterDeviceBean
printerDeviceBean
,
List
<
Bitmap
>
bitmaps
,
PrintSocketHolder
.
OnStateChangedListener
printerDeviceBean
,
List
<
Bitmap
>
bitmaps
,
PrintSocketHolder
.
OnStateChangedListener
stateChangedListener
,
PrintExecutor
.
OnPrintResultListener
resultListener
)
{
stateChangedListener
,
PrintExecutor
.
OnPrintResultListener
resultListener
)
{
// if (printerDeviceBean == null)
// return;
// int printWidth;//打印出來的內容寬度
// if (printerDeviceBean.getPaperSpecification() != null) {
// printWidth = Double.valueOf(printerDeviceBean.getPaperSpecification()).intValue();
// } else {
// //如果打印機沒設置寬度
// printWidth = 480;
// printerDeviceBean.setPaperSpecification(printWidth + "");
// }
//獲取打印機機型,如果是EPSON的打印機,調用EPSON的打印方法
//獲取打印機機型,如果是EPSON的打印機,調用EPSON的打印方法
if
((
printerDeviceBean
.
getPrinterName
()
!=
null
&&
printerDeviceBean
.
getPrinterName
().
toLowerCase
().
contains
(
"EPSON"
.
toLowerCase
()))
if
((
printerDeviceBean
.
getPrinterName
()
!=
null
&&
printerDeviceBean
.
getPrinterName
().
toLowerCase
().
contains
(
"EPSON"
.
toLowerCase
()))
&&
(
printerDeviceBean
.
getModel
()
!=
null
&&
printerDeviceBean
.
getModel
().
toLowerCase
().
contains
(
"TM-U220B"
.
toLowerCase
())))
{
&&
(
printerDeviceBean
.
getModel
()
!=
null
&&
printerDeviceBean
.
getModel
().
toLowerCase
().
contains
(
"TM-U220B"
.
toLowerCase
())))
{
// List<Bitmap> zoomBitmap = null;
// if (bitmaps != null) {
// zoomBitmap = new ArrayList<>();
// for (int i = 0; i < bitmaps.size(); i++) {
// if (bitmaps.get(i) != null) {
// Bitmap newBitmap = ImageUtils.zoomDrawable(bitmaps.get(i), printWidth, 2d);
// zoomBitmap.add(newBitmap);
// }
// }
// }
// if (zoomBitmap == null) {
// printListener.printFile();
// return;
// }
// List<Bitmap> finalZoomBitmap = zoomBitmap;
mPrinter
=
EpsonPrint
.
getInstance
();
mPrinter
=
EpsonPrint
.
getInstance
();
mPrinter
.
initializeObject
(
GsaCloudApplication
.
getAppContext
(),
this
);
mPrinter
.
initializeObject
(
GsaCloudApplication
.
getAppContext
(),
this
);
new
Thread
(()
->
{
int
state
=
0
;
//0打印失敗,1打印成功,2沒紙
for
(
int
j
=
0
;
j
<
bitmaps
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
bitmaps
.
size
();
j
++)
{
state
=
mPrinter
.
putPrintData
(
printerDeviceBean
.
getIp
(),
bitmaps
.
get
(
j
));
mPrinter
.
putPrintData
(
printerDeviceBean
.
getIp
(),
bitmaps
.
get
(
j
));
}
}
if
(
printListener
!=
null
)
{
// if (printListener != null) {
if
(
state
==
2
)
{
// if (state == 2) {
printListener
.
printStateChanged
(
PrintActivity
.
LACK_OF_PAPER
);
// printListener.printStateChanged(PrintActivity.LACK_OF_PAPER);
}
else
{
// } else {
printListener
.
printStateChanged
(
PrintActivity
.
FINISH
);
// printListener.printStateChanged(PrintActivity.FINISH);
}
}
}).
start
();
}
else
{
// List<Bitmap> zoomBitmap = null;
// if (bitmaps != null) {
// zoomBitmap = new ArrayList<>();
// for (int i = 0; i < bitmaps.size(); i++) {
// Bitmap newBitmap = ImageUtils.zoomDrawable(bitmaps.get(i), printWidth);
// Log.e("eee", "寬度:" + newBitmap.getWidth() + "高度:" + newBitmap.getHeight());
// zoomBitmap.add(newBitmap);
// }
// }
// }
// if (zoomBitmap == null) {
// printListener.printFile();
// return;
// }
// }
}
else
{
PrintExecutor
executor
=
new
PrintExecutor
(
printerDeviceBean
);
PrintExecutor
executor
=
new
PrintExecutor
(
printerDeviceBean
);
executor
.
setOnStateChangedListener
(
stateChangedListener
);
executor
.
setOnStateChangedListener
(
stateChangedListener
);
executor
.
setOnPrintResultListener
(
resultListener
);
executor
.
setOnPrintResultListener
(
resultListener
);
...
@@ -676,6 +634,23 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
...
@@ -676,6 +634,23 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return
LayoutToBitmapUtils
.
loadBitmapFromView
(
view
);
return
LayoutToBitmapUtils
.
loadBitmapFromView
(
view
);
}
}
final
Bitmap
viewToZoomBitmap
(
Context
context
,
View
view
,
PrinterDeviceBean
printerDeviceBean
)
{
LayoutToBitmapUtils
.
layoutView
(
context
,
view
);
//先测量view
//轉為bitmap
return
zoomBitmap
(
printerDeviceBean
,
LayoutToBitmapUtils
.
loadBitmapFromView
(
view
));
}
public
Bitmap
zoomBitmap
(
PrinterDeviceBean
printerDeviceBean
,
Bitmap
bitmap
)
{
int
printWidth
;
if
(
printerDeviceBean
!=
null
&&
printerDeviceBean
.
getPaperSpecification
()
!=
null
)
{
printWidth
=
Double
.
valueOf
(
printerDeviceBean
.
getPaperSpecification
()).
intValue
();
}
else
{
//如果打印機沒設置寬度
printWidth
=
480
;
}
return
ImageUtils
.
zoomDrawable
(
bitmap
,
printWidth
);
}
//打印失敗設備map
//打印失敗設備map
private
List
<
PrinterDeviceBean
>
printerFileDevices
=
new
ArrayList
<>();
private
List
<
PrinterDeviceBean
>
printerFileDevices
=
new
ArrayList
<>();
...
@@ -848,6 +823,18 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
...
@@ -848,6 +823,18 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return
textView
;
return
textView
;
}
}
/**
* 獲取中間是文字的線條
*
* @param content 文字內容
*/
public
View
getTextLine
(
Context
mContext
,
String
content
)
{
View
view
=
View
.
inflate
(
mContext
,
R
.
layout
.
print_model_text_line
,
null
);
TextView
textView
=
view
.
findViewById
(
R
.
id
.
print_model_center_text
);
textView
.
setText
(
content
);
return
view
;
}
public
View
getHalfLine
(
Context
mContext
)
{
public
View
getHalfLine
(
Context
mContext
)
{
return
View
.
inflate
(
mContext
,
R
.
layout
.
print_model_half_line
,
null
);
return
View
.
inflate
(
mContext
,
R
.
layout
.
print_model_half_line
,
null
);
}
}
...
@@ -862,6 +849,159 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
...
@@ -862,6 +849,159 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return
view
;
return
view
;
}
}
public
View
getTakeawayOrderInfo
(
Context
mContext
,
OrderDetails
.
DataBean
data
)
{
View
view
=
View
.
inflate
(
mContext
,
R
.
layout
.
print_model_takeaway_order_info
,
null
);
// 訂單類型
TextView
tvOrderType
=
view
.
findViewById
(
R
.
id
.
print_model_center_text
);
TextView
tvPayType
=
view
.
findViewById
(
R
.
id
.
tv_print_model_pay_type
);
TextView
tvDeliveryTime
=
view
.
findViewById
(
R
.
id
.
tv_print_model_delivery_time
);
TextView
tvBillNumber
=
view
.
findViewById
(
R
.
id
.
tv_print_model_bill_number
);
TextView
tvOrderNumber
=
view
.
findViewById
(
R
.
id
.
tv_print_model_order_number
);
TextView
tvTakeFoodCode
=
view
.
findViewById
(
R
.
id
.
tv_print_model_order_take_food_code
);
TextView
tvCreateTime
=
view
.
findViewById
(
R
.
id
.
tv_print_model_order_create_time
);
TextView
tvClosingTime
=
view
.
findViewById
(
R
.
id
.
tv_print_model_order_closing_time
);
TextView
tvRemark
=
view
.
findViewById
(
R
.
id
.
tv_print_model_remark
);
//訂單類型
tvOrderType
.
setText
(
data
.
getOrder_type
()
==
2
?
"外送"
:
"自取"
);
String
payType
=
""
;
tvClosingTime
.
setVisibility
(
View
.
GONE
);
if
(
data
.
getOrderPayType
()
==
1
)
{
//貨到付款
payType
=
"貨到付款"
;
}
else
if
(
data
.
getOrderPayType
()
==
0
)
{
payType
=
"店內支付"
;
}
else
if
(
data
.
getOrderPayType
()
==
2
)
{
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
data
.
getPayName
()))
{
payType
=
"在線支付:"
+
data
.
getPayName
();
}
else
{
payType
=
"在線支付"
;
}
//支付時間,只有在線支付有
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
data
.
getPayTime
()))
{
tvClosingTime
.
setText
(
"支付時間:"
+
data
.
getPayTime
());
tvClosingTime
.
setVisibility
(
View
.
VISIBLE
);
}
}
//支付類型
tvPayType
.
setText
(
payType
);
//送達時間
tvDeliveryTime
.
setText
(
data
.
getOrder_type
()
==
2
?
data
.
getSEND_TIME
()
:
data
.
getTakeTime
());
tvBillNumber
.
setText
(
"單號:"
+
data
.
getORDER_NO
());
if
(
TextUtil
.
isEmptyOrNullOrUndefined
(
data
.
getBillNo
()))
{
tvOrderNumber
.
setVisibility
(
View
.
GONE
);
}
else
{
tvOrderNumber
.
setText
(
"訂單碼:"
+
data
.
getBillNo
());
}
//取餐碼
if
(
data
.
getOrder_type
()
==
7
)
{
//自取 顯示 取餐碼+訂單碼
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
data
.
getTakeFoodCode
()))
{
tvTakeFoodCode
.
setText
(
"取餐碼:"
+
data
.
getTakeFoodCode
());
}
}
else
{
//外送 顯示訂單碼
tvTakeFoodCode
.
setText
(
"訂單碼:"
+
data
.
getTakeFoodCode
());
}
if
(
data
.
getTakeFoodCode
()
==
null
||
data
.
getTakeFoodCode
().
equals
(
"0"
))
{
tvTakeFoodCode
.
setVisibility
(
View
.
GONE
);
}
tvCreateTime
.
setText
(
"開單時間:"
+
TimeUtils
.
parseTimeRepeat
(
data
.
getCREATE_TIME
(),
TimeUtils
.
DEFAULT_DATE_FORMAT
));
//備註
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
data
.
getRemark
()))
{
tvRemark
.
setText
(
"備註:"
+
data
.
getRemark
());
tvRemark
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
tvRemark
.
setVisibility
(
View
.
GONE
);
}
return
view
;
}
protected
View
getTakeawayMemberIntegerView
(
Context
mContext
,
OrderDetails
.
DataBean
data
)
{
View
view
=
View
.
inflate
(
mContext
,
R
.
layout
.
print_model_takeaway_member_integer_info
,
null
);
TextView
tvMemberNum
=
view
.
findViewById
(
R
.
id
.
tv_print_model_member_number
);
//會員號碼
TextView
tvMemberName
=
view
.
findViewById
(
R
.
id
.
tv_print_model_member_name
);
//會員名稱
TextView
tvMemberPhone
=
view
.
findViewById
(
R
.
id
.
tv_print_model_member_phone
);
//會員電話
TextView
tvNowPoint
=
view
.
findViewById
(
R
.
id
.
tv_print_model_nowPoints
);
//現在的積分
TextView
tvAddPoints
=
view
.
findViewById
(
R
.
id
.
tv_print_model_addPoints
);
//本次添加積分
TextView
tvOldPoints
=
view
.
findViewById
(
R
.
id
.
tv_print_model_oldPoints
);
//之前的積分
if
(
data
.
getAddPoints
()
!=
0
||
data
.
getOldPoints
()
!=
0
||
data
.
getAddPoints
()
!=
0
)
{
tvAddPoints
.
setText
(
"本次積分:"
+
data
.
getAddPoints
());
tvNowPoint
.
setText
(
"結餘積分:"
+
data
.
getNowPoints
());
tvOldPoints
.
setText
(
"上次積分:"
+
data
.
getOldPoints
());
//名稱中間替換為*號
if
(
data
.
getMEMBER_NAME
()
!=
null
&&
data
.
getMEMBER_NAME
().
length
()
>
0
)
{
tvMemberName
.
setText
(
"會員名稱:"
+
getReplaceAfter
(
data
.
getMEMBER_NAME
()));
}
if
(
data
.
getPHONE
()
!=
null
&&
data
.
getPHONE
().
length
()
>
0
)
{
tvMemberPhone
.
setText
(
"會員電話:"
+
getReplaceAfter
(
data
.
getPHONE
()));
}
}
return
view
;
}
private
String
getReplaceAfter
(
String
str
)
{
if
(
str
!=
null
&&
str
.
length
()
>
0
)
{
int
replaceStrCount
=
str
.
length
()
/
2
;
StringBuilder
buffer
=
new
StringBuilder
();
if
(
replaceStrCount
>=
5
)
{
replaceStrCount
=
str
.
length
()
-
5
;
}
for
(
int
i
=
0
;
i
<
replaceStrCount
;
i
++)
{
buffer
.
append
(
"*"
);
}
String
header
=
str
.
substring
(
0
,
1
);
String
tail
=
str
.
substring
(
replaceStrCount
+
1
);
return
header
+
buffer
.
toString
()
+
tail
;
}
return
""
;
}
protected
View
getTakeawayLargeAmount
(
Context
mContext
,
String
title
,
String
amount
)
{
View
view
=
View
.
inflate
(
mContext
,
R
.
layout
.
print_model_takeaway_total_amount
,
null
);
TextView
tvTitle
=
view
.
findViewById
(
R
.
id
.
tv_total_text
);
TextView
tvAmount
=
view
.
findViewById
(
R
.
id
.
tv_total
);
tvTitle
.
setText
(
title
);
tvAmount
.
setText
(
amount
);
return
view
;
}
protected
View
getTakeawayBillInfoView
(
Context
mContext
,
List
<
PrintBillBean
>
data
)
{
return
getVerticalRecyclerView
(
mContext
,
new
BillItemAdapter
(
data
));
}
protected
View
getTakeawayMemberInfoView
(
Context
mContext
,
String
address
,
String
receiver
,
String
phone
)
{
LinearLayout
layout
=
new
LinearLayout
(
mContext
);
LinearLayout
.
LayoutParams
layoutParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
layoutParams
.
topMargin
=
getDimensionPixelSize
(
mContext
,
R
.
dimen
.
dp_5
);
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
address
))
{
View
addressView
=
getTakeawayTextView
(
mContext
,
address
);
addressView
.
setLayoutParams
(
layoutParams
);
layout
.
addView
(
addressView
);
}
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
receiver
))
{
View
receiverView
=
getTakeawayTextView
(
mContext
,
receiver
);
receiverView
.
setLayoutParams
(
layoutParams
);
layout
.
addView
(
receiverView
);
}
if
(!
TextUtil
.
isEmptyOrNullOrUndefined
(
phone
))
{
View
phoneView
=
getTakeawayTextView
(
mContext
,
phone
);
phoneView
.
setLayoutParams
(
layoutParams
);
layout
.
addView
(
phoneView
);
}
return
layout
;
}
protected
View
getTakeawayTextView
(
Context
mContext
,
String
text
)
{
return
getTextView
(
mContext
,
text
,
Gravity
.
LEFT
,
26
,
getColor
(
mContext
,
R
.
color
.
black
));
}
public
View
getDiningTableOrderInfo
(
Context
mContext
,
String
diningTable
,
String
people
,
String
orderNum
,
String
createTime
)
{
public
View
getDiningTableOrderInfo
(
Context
mContext
,
String
diningTable
,
String
people
,
String
orderNum
,
String
createTime
)
{
View
view
=
View
.
inflate
(
mContext
,
R
.
layout
.
print_model_dining_table_order_info
,
null
);
View
view
=
View
.
inflate
(
mContext
,
R
.
layout
.
print_model_dining_table_order_info
,
null
);
TextView
tvDiningTable
=
view
.
findViewById
(
R
.
id
.
tv_print_model_dining_table
);
TextView
tvDiningTable
=
view
.
findViewById
(
R
.
id
.
tv_print_model_dining_table
);
...
@@ -880,35 +1020,34 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
...
@@ -880,35 +1020,34 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return
view
;
return
view
;
}
}
public
View
getDiningFoodList
(
Context
mContext
,
List
<
OrderDetail
>
foodList
)
{
public
View
getDiningFoodList
(
Context
mContext
,
List
<
OrderDetail
>
foodList
,
PrinterDeviceBean
deviceBean
)
{
RecyclerView
recyclerView
=
new
RecyclerView
(
mContext
);
return
getVerticalRecyclerView
(
mContext
,
new
FoodAdapter
(
foodList
,
deviceBean
));
FoodAdapter
foodAdapter
=
new
FoodAdapter
(
foodList
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
mContext
));
recyclerView
.
setAdapter
(
foodAdapter
);
return
recyclerView
;
}
}
public
View
getDiningBillInfo
(
Context
mContext
,
List
<
BillingBean
>
billingBeans
)
{
public
View
getDiningBillInfo
(
Context
mContext
,
List
<
BillingBean
>
billingBeans
)
{
RecyclerView
rvBillAmount
=
new
RecyclerView
(
mContext
);
return
getVerticalRecyclerView
(
mContext
,
new
BillAdapter
(
billingBeans
));
BillAdapter
billAdapter
=
new
BillAdapter
(
billingBeans
);
rvBillAmount
.
setLayoutManager
(
new
LinearLayoutManager
(
mContext
));
rvBillAmount
.
setAdapter
(
billAdapter
);
return
rvBillAmount
;
}
}
public
View
getDiningBillPayMethod
(
Context
mContext
,
List
<
PayMethod
>
payBillMoneys
)
{
public
View
getDiningBillPayMethod
(
Context
mContext
,
List
<
PayMethod
>
payBillMoneys
)
{
RecyclerView
rvPayType
=
new
RecyclerView
(
mContext
);
return
getVerticalRecyclerView
(
mContext
,
new
BillTypeAdapter
(
payBillMoneys
));
rvPayType
.
setLayoutManager
(
new
LinearLayoutManager
(
mContext
));
}
rvPayType
.
setAdapter
(
new
BillTypeAdapter
(
payBillMoneys
));
return
rvPayType
;
public
View
getVerticalRecyclerView
(
Context
mContext
,
RecyclerView
.
Adapter
adapter
)
{
RecyclerView
recyclerView
=
new
RecyclerView
(
mContext
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
mContext
));
recyclerView
.
setAdapter
(
adapter
);
return
recyclerView
;
}
}
public
View
getAmountText
(
Context
mContext
,
String
text
)
{
public
View
getAmountText
(
Context
mContext
,
String
text
)
{
return
getTextView
(
mContext
,
text
,
Gravity
.
RIGHT
,
mContext
.
getResources
().
getDimensionPixelSize
(
R
.
dimen
.
dp_24
)
,
ContextCompat
.
getColor
(
mContext
,
R
.
color
.
black
));
return
getTextView
(
mContext
,
text
,
Gravity
.
RIGHT
,
24
,
ContextCompat
.
getColor
(
mContext
,
R
.
color
.
black
));
}
}
public
View
getTextView
(
Context
mContext
,
String
text
,
int
gravity
,
in
t
textSize
,
int
textColor
)
{
public
TextView
getTextView
(
Context
mContext
,
String
text
,
int
gravity
,
floa
t
textSize
,
int
textColor
)
{
TextView
textView
=
new
TextView
(
mContext
);
TextView
textView
=
new
TextView
(
mContext
);
textView
.
setWidth
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
);
textView
.
setWidth
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
);
textView
.
setText
(
text
);
textView
.
setText
(
text
);
...
@@ -918,4 +1057,11 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
...
@@ -918,4 +1057,11 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return
textView
;
return
textView
;
}
}
public
int
getDimensionPixelSize
(
Context
mContext
,
int
textSizeId
)
{
return
mContext
.
getResources
().
getDimensionPixelSize
(
textSizeId
);
}
public
int
getColor
(
Context
mContext
,
@ColorRes
int
colorId
)
{
return
ContextCompat
.
getColor
(
mContext
,
colorId
);
}
}
}
print-module/src/main/java/com/joe/print/mvp/print/PrjPrintCallbackListener.java
0 → 100644
View file @
6bdf3095
package
com
.
joe
.
print
.
mvp
.
print
;
public
interface
PrjPrintCallbackListener
{
// void
}
print-module/src/main/java/com/joe/print/mvp/print/SendPrint.java
View file @
6bdf3095
...
@@ -77,6 +77,11 @@ public class SendPrint implements PrintDataMaker {
...
@@ -77,6 +77,11 @@ public class SendPrint implements PrintDataMaker {
}
}
}
}
@Override
public
String
getPrjIds
()
{
return
null
;
}
/*************************************************************************
/*************************************************************************
* 假设一个240*240的图片,分辨率设为24, 共分10行打印
* 假设一个240*240的图片,分辨率设为24, 共分10行打印
* 每一行,是一个 240*24 的点阵, 每一列有24个点,存储在3个byte里面。
* 每一行,是一个 240*24 的点阵, 每一列有24个点,存储在3个byte里面。
...
...
print-module/src/main/java/com/joe/print/mvp/print/TestPrintMaker.java
View file @
6bdf3095
...
@@ -46,6 +46,11 @@ public class TestPrintMaker implements PrintDataMaker {
...
@@ -46,6 +46,11 @@ public class TestPrintMaker implements PrintDataMaker {
}
}
}
}
@Override
public
String
getPrjIds
()
{
return
null
;
}
private
void
print
(
PrintInfoBean
printInfoBean
,
int
i
)
throws
IOException
{
private
void
print
(
PrintInfoBean
printInfoBean
,
int
i
)
throws
IOException
{
// if (i == 0) {
// if (i == 0) {
// location = 0;
// location = 0;
...
...
print-module/src/main/java/com/joe/print/mvp/print/maker/PrjPrintMaker.java
0 → 100644
View file @
6bdf3095
package
com
.
joe
.
print
.
mvp
.
print
.
maker
;
import
android.graphics.Bitmap
;
import
com.gingersoft.gsa.cloud.print.PrintDataMaker
;
import
com.gingersoft.gsa.cloud.print.PrinterWriter
;
import
com.gingersoft.gsa.cloud.print.PrinterWriterExecutor
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* Created by Wyh on 2020/1/9.
* ip打印類
*/
public
class
PrjPrintMaker
implements
PrintDataMaker
{
private
Map
<
String
,
Bitmap
>
bitmapMap
;
public
PrjPrintMaker
(
Map
<
String
,
Bitmap
>
bitmapMap
)
{
this
.
bitmapMap
=
bitmapMap
;
}
@Override
public
List
<
byte
[]>
getPrintData
()
{
ArrayList
<
byte
[]>
data
=
new
ArrayList
<>();
try
{
PrinterWriter
printer
=
new
PrinterWriterExecutor
(
255
,
380
);
for
(
Map
.
Entry
<
String
,
Bitmap
>
bitmapMap
:
bitmapMap
.
entrySet
())
{
ArrayList
<
byte
[]>
image1
=
printer
.
getImageByte
(
bitmapMap
.
getValue
());
data
.
addAll
(
image1
);
}
printer
.
printLineFeed
(
5
);
printer
.
feedPaperCutPartial
();
data
.
add
(
printer
.
getDataAndReset
());
data
.
add
(
printer
.
getDataAndClose
());
return
data
;
}
catch
(
Exception
e
)
{
return
new
ArrayList
<>();
}
}
@Override
public
String
getPrjIds
()
{
for
(
Map
.
Entry
<
String
,
Bitmap
>
bitmapMap
:
bitmapMap
.
entrySet
())
{
return
bitmapMap
.
getKey
();
}
return
""
;
}
}
print-module/src/main/java/com/joe/print/mvp/print/service/PrjService.java
View file @
6bdf3095
package
com
.
joe
.
print
.
mvp
.
print
.
service
;
package
com
.
joe
.
print
.
mvp
.
print
.
service
;
import
android.app.Service
;
import
android.app.Service
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.os.Build
;
import
android.os.IBinder
;
import
android.os.IBinder
;
import
android.os.RemoteException
;
import
android.util.Log
;
import
android.util.Log
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
...
@@ -12,6 +15,7 @@ import com.epson.epos2.printer.Printer;
...
@@ -12,6 +15,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.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.base.utils.AidlUtil
;
import
com.gingersoft.gsa.cloud.base.utils.JsonUtils
;
import
com.gingersoft.gsa.cloud.base.utils.JsonUtils
;
import
com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils
;
import
com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
;
...
@@ -21,16 +25,30 @@ import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
...
@@ -21,16 +25,30 @@ import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import
com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils
;
import
com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils
;
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.PrinterWriter58mm
;
import
com.hyweb.n5.lib.constant.PrinterConstant
;
import
com.hyweb.n5.lib.util.PrinterUtil
;
import
com.hyweb.n5.server.aidl.IOnPrintCallback
;
import
com.joe.print.mvp.model.bean.PrintInfoBean
;
import
com.joe.print.mvp.model.bean.PrjBean
;
import
com.joe.print.mvp.model.bean.PrjBean
;
import
com.joe.print.mvp.print.EpsonPrint
;
import
com.joe.print.mvp.print.PrintPrjKitchen
;
import
com.joe.print.mvp.print.PrintPrjKitchen
;
import
com.joe.print.mvp.print.PrinterRoot
;
import
com.joe.print.mvp.print.PrinterRoot
;
import
com.joe.print.mvp.print.common.PrinterFinderCallback
;
import
com.joe.print.mvp.print.common.SendResultCode
;
import
com.joe.print.mvp.print.maker.PrjPrintMaker
;
import
com.joe.print.mvp.print.usb.EscCommand
;
import
com.joe.print.mvp.print.usb.UsbPrint
;
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
org.json.JSONArray
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
...
@@ -46,12 +64,10 @@ import io.reactivex.schedulers.Schedulers;
...
@@ -46,12 +64,10 @@ import io.reactivex.schedulers.Schedulers;
import
okhttp3.MediaType
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
import
okhttp3.RequestBody
;
import
static
com
.
joe
.
print
.
mvp
.
print
.
PrinterRoot
.
PRINT_KITCHEN
;
/**
/**
* 在用戶登錄成功後,打開打印service,每隔3~5秒請求一次。請求到了數據就進行打印邏輯
* 在用戶登錄成功後,打開打印service,每隔3~5秒請求一次。請求到了數據就進行打印邏輯
*/
*/
public
class
PrjService
extends
Service
implements
PrintSocketHolder
.
OnStateChangedListener
,
PrintExecutor
.
OnPrintResultListener
,
ReceiveListener
{
public
class
PrjService
extends
Service
implements
ReceiveListener
{
private
Disposable
disposable
;
private
Disposable
disposable
;
private
Disposable
wakeDisposable
;
private
Disposable
wakeDisposable
;
...
@@ -59,15 +75,19 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
...
@@ -59,15 +75,19 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
private
List
<
PrjBean
.
DataBean
.
Bean
>
printDatas
=
new
ArrayList
<>();
private
List
<
PrjBean
.
DataBean
.
Bean
>
printDatas
=
new
ArrayList
<>();
private
Map
<
String
,
List
<
PrjBean
.
DataBean
.
Bean
>>
listMap
=
new
HashMap
<>();
private
Map
<
String
,
List
<
PrjBean
.
DataBean
.
Bean
>>
listMap
=
new
HashMap
<>();
private
List
<
PrintCurrencyBean
>
printCurrencyBeans
;
//通用打印配置
private
List
<
PrintCurrencyBean
>
printCurrencyBeans
;
//通用打印配置
private
Context
mContext
;
@Override
@Override
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
mContext
=
this
;
initUsbPrint
();
initUsbPrint
();
}
}
@Override
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
mContext
=
this
;
Log
.
e
(
"eee"
,
"開啟打印服務"
);
Log
.
e
(
"eee"
,
"開啟打印服務"
);
getPrintList
();
getPrintList
();
//開始請求
//開始請求
...
@@ -75,9 +95,27 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
...
@@ -75,9 +95,27 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
return
super
.
onStartCommand
(
intent
,
flags
,
startId
);
return
super
.
onStartCommand
(
intent
,
flags
,
startId
);
}
}
private
UsbPrinterFinder
printerFinder
;
private
List
<
UsbPrinter
>
mUsbPrinters
;
public
void
initUsbPrint
()
{
public
void
initUsbPrint
()
{
printerFinder
=
new
UsbPrinterFinder
(
mContext
,
new
PrinterFinderCallback
<
UsbPrinter
>()
{
@Override
public
void
onStart
()
{
}
@Override
public
void
onFound
(
UsbPrinter
usbPrinter
)
{
}
@Override
public
void
onFinished
(
List
<
UsbPrinter
>
usbPrinters
)
{
mUsbPrinters
=
usbPrinters
;
}
});
//開啟監聽USB連接
//開啟監聽USB連接
UsbPrinterFinder
printerFinder
=
new
UsbPrinterFinder
(
this
,
null
);
printerFinder
.
startFinder
();
printerFinder
.
startFinder
();
}
}
...
@@ -145,7 +183,8 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
...
@@ -145,7 +183,8 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
public
void
onNext
(
String
s
)
{
public
void
onNext
(
String
s
)
{
Log
.
e
(
"eee"
,
"請求到PRJ數據:"
+
s
);
Log
.
e
(
"eee"
,
"請求到PRJ數據:"
+
s
);
//請求到數據,停止輪詢,開始打印,在打印完之後再重新開始輪詢
//請求到數據,停止輪詢,開始打印,在打印完之後再重新開始輪詢
startPrint
(
s
);
// startPrint(s);
newPrint
(
s
);
//開啟另一個定時,三十秒之後自動請求,避免上面的打印成功或失敗時沒有回調。
//開啟另一個定時,三十秒之後自動請求,避免上面的打印成功或失敗時沒有回調。
cancel
(
wakeDisposable
);
cancel
(
wakeDisposable
);
Observable
.
timer
(
30
,
TimeUnit
.
SECONDS
)
Observable
.
timer
(
30
,
TimeUnit
.
SECONDS
)
...
@@ -199,16 +238,90 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
...
@@ -199,16 +238,90 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
/**
/**
* 開始打印
* 開始打印
*/
*/
private
void
startPrint
(
String
json
)
{
// private void startPrint(String json) {
// printDatas.clear();
// listMap.clear();
// PrjBean prjBean = JsonUtils.parseObject(json, PrjBean.class);
// if (prjBean == null || prjBean.getData() == null) {
// return;
// }
// PrintCurrencyBean printCurrencyBean;
// //有數據,取消輪詢,等待打印結束。
// cancel(disposable);
// try {
// JSONObject jsonObject = new JSONObject(prjBean.getData());
// //通过迭代器获取这段json当中所有的key值
// Iterator keys = jsonObject.keys();
// //然后通过一个循环取出所有的key值
// while (keys.hasNext()) {
// String key = String.valueOf(keys.next());
// //最后就可以通过刚刚得到的key值去解析后面的json了
// JSONArray dataJson = (JSONArray) jsonObject.get(key);
// List<PrjBean.DataBean.Bean> datas = JsonUtils.parseArray(dataJson.toString(), PrjBean.DataBean.Bean.class);
// listMap.put(key, datas);//打印位置和需要打印的數據
// PrintPrjKitchen.getPrjMap().put(key, datas);
// printDatas.addAll(datas);
// }
// } catch (JSONException e) {
// e.printStackTrace();
// }
// if (printerInIt == null) {
// printerInIt = PrinterRoot.getPrinterByType(PRINT_KITCHEN);
// }
// //獲取打印機列表
// getPrintList();
//// for (Map.Entry<String, List<PrjBean.DataBean.Bean>> prjMap : listMap.entrySet()) {
//// for (PrinterDeviceBean deviceBean : printerDeviceBeans) {
//// if (prjMap.getKey().equalsIgnoreCase(deviceBean.getName())) {
//// if ((deviceBean.getPrinterName() != null && deviceBean.getPrinterName().toLowerCase().contains("EPSON".toLowerCase()))
//// && (deviceBean.getModel() != null && deviceBean.getModel().toLowerCase().contains("TM-U220B".toLowerCase()))) {
//// //針式打印
//// //Epson打印機打印,調用對應的方法
//// EpsonPrint mPrinter = EpsonPrint.getInstance();
//// mPrinter.initializeObject(GsaCloudApplication.getAppContext(), this);
//// int paperWidth = 42;
//// if (deviceBean.getPaperSpecification() != null) {
//// paperWidth = (int) (Double.parseDouble(deviceBean.getPaperSpecification()) / 6);
//// }
//// List<List<PrintInfoBean>> prjBeans = PrintInfoBean.transPrjBean(prjMap.getValue(), prjMap.getKey(), deviceBean, printCurrencyBean);
//// for (List<PrintInfoBean> prjPrintBean : prjBeans) {
//// mPrinter.putPrintString(deviceBean.getIp(), paperWidth, prjPrintBean);
//// }
//// }
//// }
//// }
//// }
// if (printerInIt != null) {
// printerInIt.setmContext(this);
// for (Map.Entry<String, List<Bitmap>> entry : printerInIt.getPrintBitmap(this, null).entrySet()) {
// //遍歷所有的需要打印的內容
// for (PrinterDeviceBean deviceBean : printerDeviceBeans) {
// //遍歷打印機列表,找到對應的打印機,沒找到的就不打印
// if (entry.getKey().toLowerCase().equals(deviceBean.getName().toLowerCase())) {
//// if ((deviceBean.getPrinterName() != null && deviceBean.getPrinterName().toLowerCase().contains("EPSON".toLowerCase()))
//// && (deviceBean.getModel() != null && deviceBean.getModel().toLowerCase().contains("TM-U220B".toLowerCase()))) {
//// //針式打印機在上面處理
//// } else {
// Log.e("eee", entry.getKey() + "開始打印IP:" + deviceBean.getIp());
// printerInIt.ipDevicePrint(deviceBean, entry.getValue(), this, this);
// break;
//// }
// }
// }
// }
// }
// }
private
void
newPrint
(
String
json
)
{
printDatas
.
clear
();
printDatas
.
clear
();
listMap
.
clear
();
listMap
.
clear
();
PrjBean
prjBean
=
JsonUtils
.
parseObject
(
json
,
PrjBean
.
class
);
PrjBean
prjBean
=
JsonUtils
.
parseObject
(
json
,
PrjBean
.
class
);
if
(
prjBean
==
null
||
prjBean
.
getData
()
==
null
)
{
if
(
prjBean
==
null
||
prjBean
.
getData
()
==
null
)
{
return
;
return
;
}
}
PrintCurrencyBean
printCurrencyBean
;
//有數據,取消輪詢,等待打印結束。
//有數據,取消輪詢,等待打印結束。
cancel
(
disposable
);
cancel
(
disposable
);
//第一步:解析PRJ數據,格式為 Map<廚房位置,需要打印的數據>
try
{
try
{
JSONObject
jsonObject
=
new
JSONObject
(
prjBean
.
getData
());
JSONObject
jsonObject
=
new
JSONObject
(
prjBean
.
getData
());
//通过迭代器获取这段json当中所有的key值
//通过迭代器获取这段json当中所有的key值
...
@@ -219,82 +332,316 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
...
@@ -219,82 +332,316 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
//最后就可以通过刚刚得到的key值去解析后面的json了
//最后就可以通过刚刚得到的key值去解析后面的json了
JSONArray
dataJson
=
(
JSONArray
)
jsonObject
.
get
(
key
);
JSONArray
dataJson
=
(
JSONArray
)
jsonObject
.
get
(
key
);
List
<
PrjBean
.
DataBean
.
Bean
>
datas
=
JsonUtils
.
parseArray
(
dataJson
.
toString
(),
PrjBean
.
DataBean
.
Bean
.
class
);
List
<
PrjBean
.
DataBean
.
Bean
>
datas
=
JsonUtils
.
parseArray
(
dataJson
.
toString
(),
PrjBean
.
DataBean
.
Bean
.
class
);
if
(
datas
==
null
||
datas
.
size
()
<=
0
)
{
return
;
}
listMap
.
put
(
key
,
datas
);
//打印位置和需要打印的數據
listMap
.
put
(
key
,
datas
);
//打印位置和需要打印的數據
PrintPrjKitchen
.
getPrjMap
().
put
(
key
,
datas
);
//
PrintPrjKitchen.getPrjMap().put(key, datas);
printDatas
.
addAll
(
datas
);
//
printDatas.addAll(datas);
}
}
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
//獲取通用打印配置
//讀取打印機和通用配置,可以優化
printCurrencyBean
=
getCurrencyBean
();
//獲取所有打印機
PrinterDeviceDaoUtils
printerDeviceDaoUtils
=
new
PrinterDeviceDaoUtils
(
this
);
printerDeviceBeans
=
printerDeviceDaoUtils
.
queryAllPrinterDeviceBean
();
//獲取所有通用配置
printCurrencyBeans
=
MyPrintUtils
.
getPrintCurrencyBeans
(
this
);
//雙重遍歷可以以後優化
//第二步:遍歷 Map<廚房位置,需要打印的數據>,通過廚房位置找到對應的打印機,並且通過數據拿到對應的通用配置
for
(
Map
.
Entry
<
String
,
List
<
PrjBean
.
DataBean
.
Bean
>>
prjMap
:
listMap
.
entrySet
())
{
for
(
PrinterDeviceBean
deviceBean
:
printerDeviceBeans
)
{
//遍歷得到當前打印機,如果沒找到打印機,就不打印
if
(
prjMap
.
getKey
().
toLowerCase
().
equals
(
deviceBean
.
getName
().
toLowerCase
()))
{
//如果PRJ數據的廚房位置和打印機名稱相同,則就是這台打印機打印
//通過需要打印的數據,得到通用配置
PrintCurrencyBean
printCurrencyBean
=
getPrintCurrencyBean
(
prjMap
.
getValue
());
//將通用配置設置給了對應的打印機對象後,得到新的打印機對象
PrinterDeviceBean
configPrinterDeviceBean
=
MyPrintUtils
.
configPrinterProperties
(
printCurrencyBean
,
deviceBean
);
// 判斷打印機的類型,調用不同的打印方式,
// 這裡已經拿到這台打印機需要打印的所有數據,為prjMp.getValue(),
// 生成對應的打印數據,除了針式打印機,其他都生成bitmap
generatePrintData
(
prjMap
.
getKey
(),
prjMap
.
getValue
(),
configPrinterDeviceBean
);
}
}
}
}
if
(
printerInIt
==
null
)
{
private
PrintCurrencyBean
getPrintCurrencyBean
(
List
<
PrjBean
.
DataBean
.
Bean
>
beans
)
{
printerInIt
=
PrinterRoot
.
getPrinterByType
(
PRINT_KITCHEN
);
PrintCurrencyBean
printCurrencyBean
=
null
;
if
(
beans
!=
null
&&
beans
.
size
()
>
0
)
{
if
(
beans
.
get
(
0
).
getOrderType
()
==
1
)
{
//堂食
printCurrencyBean
=
MyPrintUtils
.
getPrintCurrencyBeanByType
(
mContext
,
1
);
}
else
{
//外賣
printCurrencyBean
=
MyPrintUtils
.
getPrintCurrencyBeanByType
(
mContext
,
2
);
}
}
//獲取打印機列表
}
getPrintList
()
;
return
printCurrencyBean
;
// for (Map.Entry<String, List<PrjBean.DataBean.Bean>> prjMap : listMap.entrySet()) {
}
// for (PrinterDeviceBean deviceBean : printerDeviceBeans) {
// if (prjMap.getKey().equalsIgnoreCase(deviceBean.getName())) {
//打印回調了多少次都要記錄下來,所以一次只能傳遞一張prj過去,等到打印回調再打第二張
// if ((deviceBean.getPrinterName() != null && deviceBean.getPrinterName().toLowerCase().contains("EPSON".toLowerCase()))
// && (deviceBean.getModel() != null && deviceBean.getModel().toLowerCase().contains("TM-U220B".toLowerCase()))) {
/**
// //針式打印
* 生成用於打印的prj的Bitmap
// //Epson打印機打印,調用對應的方法
*/
// EpsonPrint mPrinter = EpsonPrint.getInstance();
private
void
generatePrintData
(
String
key
,
List
<
PrjBean
.
DataBean
.
Bean
>
beans
,
PrinterDeviceBean
printerDeviceBean
)
{
// mPrinter.initializeObject(GsaCloudApplication.getAppContext(), this);
if
(
isPinPrinter
(
printerDeviceBean
)
&&
printerDeviceBean
.
getPrinterDeviceType
()
==
1
)
{
// int paperWidth = 42;
//針式打印機並且打印機類型為IP打印,生成獨特的格式
// if (deviceBean.getPaperSpecification() != null) {
EpsonPrint
mPrinter
=
EpsonPrint
.
getInstance
();
// paperWidth = (int) (Double.parseDouble(deviceBean.getPaperSpecification()) / 6
);
mPrinter
.
initializeObject
(
GsaCloudApplication
.
getAppContext
(),
this
);
// }
int
paperWidth
=
42
;
// List<List<PrintInfoBean>> prjBeans = PrintInfoBean.transPrjBean(prjMap.getValue(), prjMap.getKey(), deviceBean, printCurrencyBean);
if
(
printerDeviceBean
.
getPaperSpecification
()
!=
null
)
{
// for (List<PrintInfoBean> prjPrintBean : prjBeans) {
paperWidth
=
(
int
)
(
Double
.
parseDouble
(
printerDeviceBean
.
getPaperSpecification
())
/
6
);
// mPrinter.putPrintString(deviceBean.getIp(), paperWidth, prjPrintBean);
}
// }
List
<
List
<
PrintInfoBean
>>
prjBeans
=
PrintInfoBean
.
transPrjBean
(
beans
,
key
,
printerDeviceBean
);
// }
for
(
List
<
PrintInfoBean
>
prjPrintBean
:
prjBeans
)
{
// }
mPrinter
.
putPrintString
(
printerDeviceBean
.
getIp
(),
paperWidth
,
prjPrintBean
);
//
}
}
// }
}
else
{
if
(
printerInIt
!=
null
)
{
List
<
Map
<
String
,
Bitmap
>>
bitmapMaps
=
generatePrintMaps
(
key
,
beans
,
printerDeviceBean
);
printerInIt
.
setmContext
(
this
);
switch
(
printerDeviceBean
.
getPrinterDeviceType
())
{
for
(
Map
.
Entry
<
String
,
List
<
Bitmap
>>
entry
:
printerInIt
.
getPrintBitmap
(
this
,
null
).
entrySet
())
{
case
1
:
//遍歷所有的需要打印的內容
//IP打印
for
(
PrinterDeviceBean
deviceBean
:
printerDeviceBeans
)
{
ipPrint
(
printerDeviceBean
,
bitmapMaps
);
//遍歷打印機列表,找到對應的打印機,沒找到的就不打印
break
;
if
(
entry
.
getKey
().
toLowerCase
().
equals
(
deviceBean
.
getName
().
toLowerCase
()))
{
case
2
:
// if ((deviceBean.getPrinterName() != null && deviceBean.getPrinterName().toLowerCase().contains("EPSON".toLowerCase()))
//本地N5或Sunmi打印
// && (deviceBean.getModel() != null && deviceBean.getModel().toLowerCase().contains("TM-U220B".toLowerCase()))) {
locationPrint
(
bitmapMaps
);
// //針式打印機在上面處理
break
;
// } else {
case
3
:
Log
.
e
(
"eee"
,
entry
.
getKey
()
+
"開始打印IP:"
+
deviceBean
.
getIp
());
//USB打印
printerInIt
.
ipDevicePrint
(
deviceBean
,
entry
.
getValue
(),
this
,
thi
s
);
usbPrint
(
bitmapMap
s
);
break
;
break
;
// }
}
}
}
}
}
}
/**
* ip設備打印
*/
public
void
ipPrint
(
PrinterDeviceBean
printerDeviceBean
,
List
<
Map
<
String
,
Bitmap
>>
bitmapMaps
)
{
for
(
int
i
=
0
;
i
<
bitmapMaps
.
size
();
i
++)
{
PrintExecutor
executor
=
new
PrintExecutor
(
printerDeviceBean
);
executor
.
setOnPrjPrintResultListener
((
errorCode
,
ids
)
->
{
switch
(
errorCode
)
{
case
PrintSocketHolder
.
ERROR_0
:
//更新狀態
updatePrjSuccess
(
ids
);
Log
.
e
(
"eee"
,
"打印成功"
);
break
;
case
PrintSocketHolder
.
ERROR_2
:
Log
.
e
(
"eee"
,
"创建Socket失败"
);
updatePrjFailure
(
ids
);
break
;
}
});
PrjPrintMaker
maker
=
new
PrjPrintMaker
(
bitmapMaps
.
get
(
i
));
executor
.
doPrinterRequestAsync
(
maker
);
}
}
}
}
private
PrintCurrencyBean
getCurrencyBean
()
{
/**
if
(
printDatas
!=
null
&&
printDatas
.
size
()
>
0
)
{
* usb打印
PrjBean
.
DataBean
.
Bean
bean
=
printDatas
.
get
(
0
);
*/
if
(
bean
!=
null
)
{
public
void
usbPrint
(
List
<
Map
<
String
,
Bitmap
>>
bitmapMaps
)
{
if
(
bean
.
getOrderType
()
==
1
)
{
for
(
int
i
=
0
;
i
<
bitmapMaps
.
size
();
i
++)
{
//堂食
for
(
Map
.
Entry
<
String
,
Bitmap
>
bitmapMap
:
bitmapMaps
.
get
(
i
).
entrySet
())
{
return
MyPrintUtils
.
getInstance
().
getPrintCurrencyBeanByType
(
this
,
1
);
final
String
key
=
bitmapMap
.
getKey
();
UsbPrint
usbPrint
=
new
UsbPrint
(
mContext
,
(
code
,
printId
)
->
{
//打印結果
if
(
code
==
SendResultCode
.
SEND_SUCCESS
)
{
Log
.
e
(
"ddd"
,
"打印成功"
);
updatePrjSuccess
(
key
);
}
else
if
(
code
==
SendResultCode
.
SEND_FAILED
)
{
Log
.
e
(
"ddd"
,
"打印失敗"
);
updatePrjFailure
(
key
);
}
});
if
(
mUsbPrinters
!=
null
&&
mUsbPrinters
.
size
()
>
0
)
{
EscCommand
esc
=
new
EscCommand
();
ArrayList
<
byte
[]>
bytes
=
new
ArrayList
<>();
try
{
bytes
.
addAll
(
new
PrinterWriter58mm
().
getImageByte
(
bitmapMap
.
getValue
()));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
bytes
.
add
(
esc
.
getPrintAndFeedLines
((
byte
)
8
));
bytes
.
add
(
esc
.
getCutPaper
());
bytes
.
add
(
esc
.
getCleanCache
());
usbPrint
.
sendPrintCommand
(
mUsbPrinters
.
get
(
0
),
bytes
);
}
else
{
//打印失敗
updatePrjFailure
(
key
);
}
}
}
}
/**
* 本機打印
*/
public
void
locationPrint
(
List
<
Map
<
String
,
Bitmap
>>
bitmapMaps
)
{
String
model
=
Build
.
MODEL
;
if
(
GsaCloudApplication
.
mV2
.
contains
(
model
))
{
sunmiPrint
(
bitmapMaps
);
}
else
if
(
GsaCloudApplication
.
mN5
.
contains
(
model
))
{
//N5打印
n5Print
(
bitmapMaps
);
}
else
{
}
else
{
return
MyPrintUtils
.
getInstance
().
getPrintCurrencyBeanByType
(
this
,
2
);
StringBuilder
stringBuilder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
bitmapMaps
.
size
();
i
++)
{
for
(
Map
.
Entry
<
String
,
Bitmap
>
mapEntry
:
bitmapMaps
.
get
(
i
).
entrySet
())
{
stringBuilder
.
append
(
mapEntry
.
getKey
());
if
(
stringBuilder
.
toString
().
lastIndexOf
(
","
)
!=
stringBuilder
.
length
()
-
1
)
{
//如果最後一位不是逗號,才添加
stringBuilder
.
append
(
","
);
}
}
}
updatePrjFailure
(
stringBuilder
.
toString
());
}
}
private
final
static
int
SUNMI_PAPER_WIDTH
=
360
;
//商米打印機紙張寬度
private
final
static
int
N5_PAPER_WIDTH
=
500
;
//N5打印機紙張寬度
/**
* 商米打印
*/
private
void
sunmiPrint
(
List
<
Map
<
String
,
Bitmap
>>
bitmapMaps
)
{
//商米打印
for
(
int
i
=
0
;
i
<
bitmapMaps
.
size
();
i
++)
{
for
(
Map
.
Entry
<
String
,
Bitmap
>
mapEntry
:
bitmapMaps
.
get
(
i
).
entrySet
())
{
final
String
ids
=
mapEntry
.
getKey
();
AidlUtil
.
getInstance
().
printBitmap
(
mapEntry
.
getValue
(),
new
InnerResultCallbcak
()
{
@Override
public
void
onRunResult
(
boolean
isSuccess
)
{
//返回接⼝执⾏的情况(并⾮真实打印):成功或失败
if
(
isSuccess
)
{
updatePrjSuccess
(
ids
);
}
else
{
updatePrjFailure
(
ids
);
}
}
@Override
public
void
onReturnString
(
String
result
)
{
//部分接⼝会异步返回查询数据
}
@Override
public
void
onRaiseException
(
int
code
,
String
msg
)
{
//接⼝执⾏失败时,返回的异常状态
}
@Override
public
void
onPrintResult
(
int
code
,
String
msg
)
{
//事务模式下真实的打印结果返回
}
});
}
}
}
/**
* n5打印
*/
private
void
n5Print
(
List
<
Map
<
String
,
Bitmap
>>
bitmapMaps
)
{
for
(
int
i
=
0
;
i
<
bitmapMaps
.
size
();
i
++)
{
for
(
Map
.
Entry
<
String
,
Bitmap
>
mapEntry
:
bitmapMaps
.
get
(
i
).
entrySet
())
{
final
String
ids
=
mapEntry
.
getKey
();
try
{
PrinterUtil
.
appendImage
(
mapEntry
.
getValue
(),
PrinterConstant
.
ALIGN_CENTER
);
PrinterUtil
.
appendPrnStr
(
"\n"
,
24
,
PrinterConstant
.
ALIGN_CENTER
,
false
);
PrinterUtil
.
appendPrnStr
(
"\n"
,
24
,
PrinterConstant
.
ALIGN_CENTER
,
false
);
PrinterUtil
.
startPrint
(
true
,
new
IOnPrintCallback
.
Stub
()
{
@Override
public
void
onPrintResult
(
int
i
)
{
if
(
i
==
0
)
{
//打印成功
updatePrjSuccess
(
ids
);
}
else
{
//打印失敗
updatePrjFailure
(
ids
);
}
}
@Override
public
IBinder
asBinder
()
{
return
this
;
}
});
}
catch
(
RemoteException
e
)
{
e
.
printStackTrace
();
updatePrjFailure
(
ids
);
}
}
}
}
}
}
return
null
;
}
/**
* 生成打印需要的Map集合,Map的key是這張PRJ的所有PRJ記錄的id,然後會同時打印多張,所以是一個List集合
*
* @param key 打印位置
* @param beans 打印的食品和其他的一些信息
*/
private
List
<
Map
<
String
,
Bitmap
>>
generatePrintMaps
(
String
key
,
List
<
PrjBean
.
DataBean
.
Bean
>
beans
,
PrinterDeviceBean
printerDeviceBean
)
{
PrintPrjKitchen
printPrjKitchen
=
new
PrintPrjKitchen
();
//這個Map的key是這張PRJ的所有PRJ記錄的id,然後會同時打印多張,所以是一個List集合
List
<
Map
<
String
,
Bitmap
>>
bitmapMaps
=
new
ArrayList
<>();
List
<
PrjBean
.
DataBean
.
Bean
>
noCut
=
new
ArrayList
<>();
//不帶*號,所有同樣廚房位置的食品都在一張紙上
for
(
PrjBean
.
DataBean
.
Bean
bean
:
beans
)
{
if
(
bean
.
getStatus
()
==
2
)
{
Map
<
String
,
Bitmap
>
map
=
new
HashMap
<>();
//帶*,需要切紙的,單獨放一張紙
map
.
put
(
bean
.
getId
()
+
""
,
printPrjKitchen
.
getKitChenPrintBitmap
(
mContext
,
key
,
bean
));
bitmapMaps
.
add
(
map
);
}
else
{
noCut
.
add
(
bean
);
}
}
if
(
noCut
.
size
()
>
0
)
{
Map
<
String
,
Bitmap
>
map
=
new
HashMap
<>();
//遍歷拿到這張紙所有的PRJ記錄ID
StringBuilder
stringBuffer
=
new
StringBuilder
();
for
(
PrjBean
.
DataBean
.
Bean
noCutData
:
noCut
)
{
stringBuffer
.
append
(
noCutData
.
getId
());
stringBuffer
.
append
(
","
);
}
map
.
put
(
stringBuffer
.
toString
(),
printPrjKitchen
.
getKitChenPrintBitmap
(
mContext
,
key
,
noCut
));
bitmapMaps
.
add
(
map
);
}
return
bitmapMaps
;
}
/**
* 是否為針式打印機
*
* @param printerDeviceBean 打印機實體類
* @return true是
*/
private
boolean
isPinPrinter
(
PrinterDeviceBean
printerDeviceBean
)
{
return
(
printerDeviceBean
!=
null
&&
printerDeviceBean
.
getPrinterName
()
!=
null
&&
printerDeviceBean
.
getPrinterName
().
toLowerCase
().
contains
(
"EPSON"
.
toLowerCase
()))
&&
(
printerDeviceBean
.
getModel
()
!=
null
&&
printerDeviceBean
.
getModel
().
toLowerCase
().
contains
(
"TM-U220B"
.
toLowerCase
()));
}
private
void
updatePrjSuccess
(
String
ids
)
{
updatePrjState
(
3
,
ids
);
}
private
void
updatePrjFailure
(
String
ids
)
{
updatePrjState
(
1
,
ids
);
}
}
/**
/**
* @param printState 打印狀態 1未打印 2打印中 3已打印
* @param printState 打印狀態 1未打印 2打印中 3已打印
*/
*/
private
void
updatePrjState
(
int
printState
)
{
private
void
updatePrjState
(
int
printState
,
String
ids
)
{
if
(
printDatas
==
null
)
{
if
(
printDatas
==
null
)
{
return
;
return
;
}
}
...
@@ -304,9 +651,7 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
...
@@ -304,9 +651,7 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
}
}
List
<
UpdateBean
>
updateBeans
=
new
ArrayList
<>();
List
<
UpdateBean
>
updateBeans
=
new
ArrayList
<>();
for
(
PrjBean
.
DataBean
.
Bean
bean
:
printDatas
)
{
updateBeans
.
add
(
new
UpdateBean
(
ids
,
printState
,
time
));
updateBeans
.
add
(
new
UpdateBean
(
String
.
valueOf
(
bean
.
getId
()),
printState
,
time
));
}
String
json
=
JsonUtils
.
toJson
(
updateBeans
);
String
json
=
JsonUtils
.
toJson
(
updateBeans
);
Log
.
e
(
"eee"
,
""
+
json
);
Log
.
e
(
"eee"
,
""
+
json
);
...
@@ -340,78 +685,78 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
...
@@ -340,78 +685,78 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
});
});
}
}
@Override
//
@Override
public
void
onStateChanged
(
int
state
,
PrinterDeviceBean
printerDeviceBean
)
{
//
public void onStateChanged(int state, PrinterDeviceBean printerDeviceBean) {
String
tip
=
"加載中"
;
//
String tip = "加載中";
switch
(
state
)
{
//
switch (state) {
case
PrintSocketHolder
.
ERROR_0
:
//
case PrintSocketHolder.ERROR_0:
tip
=
"打印成功"
;
//
tip = "打印成功";
break
;
//
break;
case
PrintSocketHolder
.
ERROR_1
:
//
case PrintSocketHolder.ERROR_1:
tip
=
"生成打印數據失敗"
;
//
tip = "生成打印數據失敗";
break
;
//
break;
case
PrintSocketHolder
.
ERROR_2
:
//
case PrintSocketHolder.ERROR_2:
case
PrintSocketHolder
.
ERROR_3
:
//
case PrintSocketHolder.ERROR_3:
tip
=
"連接打印機失敗"
;
//
tip = "連接打印機失敗";
break
;
//
break;
case
PrintSocketHolder
.
ERROR_4
:
//
case PrintSocketHolder.ERROR_4:
tip
=
"寫入測試頁面數據失敗"
;
//
tip = "寫入測試頁面數據失敗";
break
;
//
break;
case
PrintSocketHolder
.
ERROR_5
:
//
case PrintSocketHolder.ERROR_5:
tip
=
"必要的參數不能為空"
;
//
tip = "必要的參數不能為空";
break
;
//
break;
case
PrintSocketHolder
.
STATE_0
:
//
case PrintSocketHolder.STATE_0:
case
PrintSocketHolder
.
STATE_1
:
//
case PrintSocketHolder.STATE_1:
tip
=
"開始創建連接"
;
//
tip = "開始創建連接";
break
;
//
break;
case
PrintSocketHolder
.
STATE_2
:
//
case PrintSocketHolder.STATE_2:
tip
=
"創建連接成功,開始發送數據"
;
//
tip = "創建連接成功,開始發送數據";
break
;
//
break;
case
PrintSocketHolder
.
STATE_3
:
//
case PrintSocketHolder.STATE_3:
tip
=
"開始寫入數據"
;
//
tip = "開始寫入數據";
break
;
//
break;
case
PrintSocketHolder
.
STATE_4
:
//
case PrintSocketHolder.STATE_4:
tip
=
"關閉中"
;
//
tip = "關閉中";
break
;
//
break;
}
//
}
Log
.
e
(
"eee"
,
"打印機狀態:"
+
tip
);
//
Log.e("eee", "打印機狀態:" + tip);
}
//
}
//
@Override
//
@Override
public
void
onResult
(
int
errorCode
,
PrinterDeviceBean
printerDeviceBean
)
{
//
public void onResult(int errorCode, PrinterDeviceBean printerDeviceBean) {
switch
(
errorCode
)
{
//
switch (errorCode) {
case
PrintSocketHolder
.
ERROR_0
:
//
case PrintSocketHolder.ERROR_0:
//更新狀態
//
//更新狀態
updatePrjState
(
3
);
//
updatePrjState(3);
Log
.
e
(
"eee"
,
"打印成功"
);
//
Log.e("eee", "打印成功");
break
;
//
break;
case
PrintSocketHolder
.
ERROR_1
:
//
case PrintSocketHolder.ERROR_1:
break
;
//
break;
case
PrintSocketHolder
.
ERROR_2
:
//
case PrintSocketHolder.ERROR_2:
Log
.
e
(
"eee"
,
"创建Socket失败"
);
//
Log.e("eee", "创建Socket失败");
//再次打開輪詢
//
//再次打開輪詢
updatePrjState
(
1
);
//
updatePrjState(1);
case
PrintSocketHolder
.
ERROR_3
:
//
case PrintSocketHolder.ERROR_3:
Log
.
e
(
"eee"
,
"获取输出流失败"
);
//
Log.e("eee", "获取输出流失败");
break
;
//
break;
case
PrintSocketHolder
.
ERROR_4
:
//
case PrintSocketHolder.ERROR_4:
Log
.
e
(
"eee"
,
"写入测试页面数据失败"
);
//
Log.e("eee", "写入测试页面数据失败");
break
;
//
break;
case
PrintSocketHolder
.
ERROR_5
:
//
case PrintSocketHolder.ERROR_5:
Log
.
e
(
"eee"
,
"必要参数不能为空"
);
//
Log.e("eee", "必要参数不能为空");
break
;
//
break;
}
//
}
}
//
}
@Override
@Override
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
)
{
//打印成功
//打印成功
updatePrjState
(
3
);
//
updatePrjState(3);
}
else
{
}
else
{
//打印失敗
//打印失敗
updatePrjState
(
1
);
//
updatePrjState(1);
}
}
startGetPrjInfo
();
startGetPrjInfo
();
}
}
...
...
print-module/src/main/java/com/joe/print/mvp/print/utils/MyPrintUtils.java
View file @
6bdf3095
...
@@ -39,7 +39,7 @@ public class MyPrintUtils {
...
@@ -39,7 +39,7 @@ public class MyPrintUtils {
* @param type 1:堂食,2:外送
* @param type 1:堂食,2:外送
* @return
* @return
*/
*/
public
PrintCurrencyBean
getPrintCurrencyBeanByType
(
Context
context
,
int
type
)
{
public
static
PrintCurrencyBean
getPrintCurrencyBeanByType
(
Context
context
,
int
type
)
{
if
(
isUpdateCurrencyBeans
||
printCurrencyBeans
==
null
||
printCurrencyBeans
.
size
()
==
0
)
{
if
(
isUpdateCurrencyBeans
||
printCurrencyBeans
==
null
||
printCurrencyBeans
.
size
()
==
0
)
{
PrintCurrencyDaoUtils
printCurrencyDaoUtils
=
new
PrintCurrencyDaoUtils
(
context
);
PrintCurrencyDaoUtils
printCurrencyDaoUtils
=
new
PrintCurrencyDaoUtils
(
context
);
printCurrencyBeans
=
printCurrencyDaoUtils
.
queryAllPrintCurrencyBean
();
printCurrencyBeans
=
printCurrencyDaoUtils
.
queryAllPrintCurrencyBean
();
...
@@ -107,6 +107,35 @@ public class MyPrintUtils {
...
@@ -107,6 +107,35 @@ public class MyPrintUtils {
return
null
;
return
null
;
}
}
/**
* 配置打印機屬性,因為有部分屬性是預設的,如果是預設的,就取通用打印配置
*/
public
static
PrinterDeviceBean
configPrinterProperties
(
PrintCurrencyBean
printCurrencyBean
,
PrinterDeviceBean
defaultPrint
)
{
if
(
printCurrencyBean
!=
null
&&
defaultPrint
!=
null
)
{
if
(
defaultPrint
.
getFoodIsBold
()
==
0
)
{
defaultPrint
.
setFoodIsBold
(
printCurrencyBean
.
getFoodIsBold
());
}
if
(
defaultPrint
.
getFoodFont
().
equals
(
"0"
))
{
defaultPrint
.
setFoodFont
(
printCurrencyBean
.
getFoodFont
());
}
if
(
defaultPrint
.
getFoodIsItalic
()
==
0
)
{
defaultPrint
.
setFoodIsItalic
(
printCurrencyBean
.
getFoodIsItalic
());
}
if
(
defaultPrint
.
getModifierIsBold
()
==
0
)
{
defaultPrint
.
setModifierIsBold
(
printCurrencyBean
.
getModifierIsBold
());
}
if
(
defaultPrint
.
getModifierFont
().
equals
(
"0"
))
{
defaultPrint
.
setModifierFont
(
printCurrencyBean
.
getModifierFont
());
}
if
(
defaultPrint
.
getModifierIsItalic
()
==
0
)
{
defaultPrint
.
setModifierIsItalic
(
printCurrencyBean
.
getModifierIsItalic
());
}
if
(
defaultPrint
.
getNumberIsFlip
()
==
0
)
{
defaultPrint
.
setNumberIsFlip
(
printCurrencyBean
.
getNumberIsFlip
());
}
}
return
defaultPrint
;
}
public
TextView
getBrandName
(
Context
context
)
{
public
TextView
getBrandName
(
Context
context
)
{
return
getNormalTextView
(
context
,
GsaCloudApplication
.
getBrandName
(
context
),
HEADER_TEXTSIZE
);
return
getNormalTextView
(
context
,
GsaCloudApplication
.
getBrandName
(
context
),
HEADER_TEXTSIZE
);
...
...
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
View file @
6bdf3095
...
@@ -44,6 +44,7 @@ import com.joe.print.mvp.print.OpenCashBoxMaker;
...
@@ -44,6 +44,7 @@ import com.joe.print.mvp.print.OpenCashBoxMaker;
import
com.joe.print.mvp.print.PrintInstruction
;
import
com.joe.print.mvp.print.PrintInstruction
;
import
com.joe.print.mvp.print.PrintListener
;
import
com.joe.print.mvp.print.PrintListener
;
import
com.joe.print.mvp.print.PrinterRoot
;
import
com.joe.print.mvp.print.PrinterRoot
;
import
com.joe.print.mvp.print.utils.MyPrintUtils
;
import
com.joe.print.mvp.ui.adapter.DialogPrinterListAdapter
;
import
com.joe.print.mvp.ui.adapter.DialogPrinterListAdapter
;
import
com.yanzhenjie.recyclerview.widget.DefaultItemDecoration
;
import
com.yanzhenjie.recyclerview.widget.DefaultItemDecoration
;
...
@@ -53,7 +54,6 @@ import java.util.List;
...
@@ -53,7 +54,6 @@ import java.util.List;
import
static
com
.
gingersoft
.
gsa
.
cloud
.
constans
.
PrintConstans
.
PRINT_TYPE
;
import
static
com
.
gingersoft
.
gsa
.
cloud
.
constans
.
PrintConstans
.
PRINT_TYPE
;
import
static
com
.
jess
.
arms
.
utils
.
Preconditions
.
checkNotNull
;
import
static
com
.
jess
.
arms
.
utils
.
Preconditions
.
checkNotNull
;
/**
/**
* ================================================
* ================================================
* Description:
* Description:
...
@@ -117,9 +117,9 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -117,9 +117,9 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
return
0
;
//如果你不需要框架帮你设置 setContentView(id) 需要 自行设置,请返回 0
return
0
;
//如果你不需要框架帮你设置 setContentView(id) 需要 自行设置,请返回 0
}
}
@Override
@Override
public
void
initData
(
@Nullable
Bundle
savedInstanceState
)
{
public
void
initData
(
@Nullable
Bundle
savedInstanceState
)
{
Log
.
e
(
"eee"
,
"打開打印界面"
);
callId
=
CCUtil
.
getNavigateCallId
(
this
);
callId
=
CCUtil
.
getNavigateCallId
(
this
);
//獲取打印類型,根據打印類型生成對應的bitmap
//獲取打印類型,根據打印類型生成對應的bitmap
...
@@ -130,24 +130,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -130,24 +130,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
if
(
printerInIt
!=
null
)
{
if
(
printerInIt
!=
null
)
{
printerInIt
.
setmContext
(
mContext
).
setPrintListener
(
this
).
initUsbPrint
();
printerInIt
.
setmContext
(
mContext
).
setPrintListener
(
this
).
initUsbPrint
();
}
}
// PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(this);
// printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean();
// printerDeviceDaoUtils.closeConnection();
// if (type == PrinterRoot.PRINT_TEST) {
// if (deviceBean != null) {
// printerInIt.ipDevicePrint(deviceBean, printerInIt.getPrintBitmap(mContext).get(""));
// } else {
// ToastUtils.show(mContext, "測試失敗");
// finish();
// }
// } else {
// if (printerDeviceBeans == null || printerDeviceBeans.size() <= 0) {
// mPresenter.getPrinterList(GsaCloudApplication.getRestaurantId(mContext));
// } else {
// printerInIt.print(printerDeviceBeans);
// }
// }
initPrintConfig
();
initPrintConfig
();
}
}
...
@@ -188,7 +170,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -188,7 +170,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
mRvPrintList
.
setAdapter
(
printListAdapter
);
mRvPrintList
.
setAdapter
(
printListAdapter
);
printListAdapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
printListAdapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
//用戶選擇的ip打印機打印
//用戶選擇的ip打印機打印
PrinterDeviceBean
defaultPrint
=
configPrinterProperties
(
finalPrintCurrencyBean
,
printerDeviceBeans
.
get
(
position
));
PrinterDeviceBean
defaultPrint
=
MyPrintUtils
.
configPrinterProperties
(
finalPrintCurrencyBean
,
printerDeviceBeans
.
get
(
position
));
printByDevice
(
defaultPrint
);
printByDevice
(
defaultPrint
);
SPUtils
.
put
(
mContext
,
"defaultPrint"
,
printerDeviceBeans
.
get
(
position
).
getName
());
SPUtils
.
put
(
mContext
,
"defaultPrint"
,
printerDeviceBeans
.
get
(
position
).
getName
());
dialog
.
dismiss
();
dialog
.
dismiss
();
...
@@ -203,7 +185,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -203,7 +185,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
ToastUtils
.
show
(
mContext
,
"沒有打印機,請先添加打印機"
);
ToastUtils
.
show
(
mContext
,
"沒有打印機,請先添加打印機"
);
}
}
}
else
{
}
else
{
defaultPrint
=
configPrinterProperties
(
printCurrencyBean
,
defaultPrint
);
defaultPrint
=
MyPrintUtils
.
configPrinterProperties
(
printCurrencyBean
,
defaultPrint
);
printByDevice
(
defaultPrint
);
printByDevice
(
defaultPrint
);
}
}
}
}
...
@@ -212,27 +194,23 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -212,27 +194,23 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
//根據配置生成配置好的圖片----生成圖片邏輯:把打印的單分為幾個模塊,再由不同的單拼接出對應的單,(如果是針式,生成對應的文字)
//根據配置生成配置好的圖片----生成圖片邏輯:把打印的單分為幾個模塊,再由不同的單拼接出對應的單,(如果是針式,生成對應的文字)
//再獲取打印方式(IP、本機、USB、藍牙或其他的),調用打印
//再獲取打印方式(IP、本機、USB、藍牙或其他的),調用打印
private
void
printByDevice
(
PrinterDeviceBean
defaultPrint
)
{
private
void
printByDevice
(
PrinterDeviceBean
defaultPrint
)
{
if
(
isShowDialog
)
{
initDialog
();
}
//獲取對應的打印類
//獲取對應的打印類
if
(
printerInIt
instanceof
PrintInstruction
)
{
if
(
printerInIt
instanceof
PrintInstruction
)
{
//開錢箱
//開錢箱
PrintExecutor
executor
=
new
PrintExecutor
(
defaultPrint
);
PrintExecutor
executor
=
new
PrintExecutor
(
defaultPrint
);
executor
.
doPrinterRequestAsync
(
new
OpenCashBoxMaker
());
executor
.
doPrinterRequestAsync
(
new
OpenCashBoxMaker
());
}
else
{
}
else
{
//先在這裡壓縮,之後在每個類自己生成的時候壓縮
if
(
isShowDialog
)
{
List
<
Bitmap
>
bitmaps
=
printerInIt
.
getPrintBitmap
(
mContext
,
defaultPrint
).
get
(
""
);
initDialog
();
List
<
Bitmap
>
zoomBitmaps
=
new
ArrayList
<>();
if
(
bitmaps
==
null
||
bitmaps
.
size
()
<=
0
)
{
printFile
();
return
;
}
for
(
Bitmap
bitmap
:
bitmaps
)
{
Bitmap
zoomBitmap
=
printerInIt
.
zoomBitmap
(
defaultPrint
,
bitmap
);
zoomBitmaps
.
add
(
zoomBitmap
);
}
}
if
(
zoomBitmaps
.
size
()
>
0
)
{
//先在這裡壓縮,之後在每個類自己生成的時候壓縮
List
<
Bitmap
>
zoomBitmaps
=
printerInIt
.
getPrintBitmap
(
mContext
,
defaultPrint
).
get
(
""
);
// List<Bitmap> zoomBitmaps = new ArrayList<>();
// for (Bitmap bitmap : bitmaps) {
// Bitmap zoomBitmap = printerInIt.zoomBitmap(defaultPrint, bitmap);
// zoomBitmaps.add(zoomBitmap);
// }
if
(
zoomBitmaps
!=
null
&&
zoomBitmaps
.
size
()
>
0
)
{
if
(
defaultPrint
.
getPrinterDeviceType
()
==
1
)
{
if
(
defaultPrint
.
getPrinterDeviceType
()
==
1
)
{
//IP打印
//IP打印
printerInIt
.
ipDevicePrint
(
defaultPrint
,
zoomBitmaps
);
printerInIt
.
ipDevicePrint
(
defaultPrint
,
zoomBitmaps
);
...
@@ -244,44 +222,14 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -244,44 +222,14 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
printerInIt
.
usbPrint
(
mContext
,
zoomBitmaps
);
printerInIt
.
usbPrint
(
mContext
,
zoomBitmaps
);
}
else
{
}
else
{
ToastUtils
.
show
(
mContext
,
"未找到對應的打印類型"
);
ToastUtils
.
show
(
mContext
,
"未找到對應的打印類型"
);
finish
();
printFile
();
}
}
}
else
{
}
else
{
//打印失敗
//打印失敗
Log
.
e
(
"eee"
,
"打印失敗,沒有生成對應的圖片"
);
Log
.
e
(
"eee"
,
"打印失敗,沒有生成對應的圖片"
);
finish
();
printFile
();
}
}
}
/**
* 配置打印機屬性,因為有部分屬性是預設的,如果是預設的,就取通用打印配置
*/
private
PrinterDeviceBean
configPrinterProperties
(
PrintCurrencyBean
printCurrencyBean
,
PrinterDeviceBean
defaultPrint
)
{
if
(
printCurrencyBean
!=
null
&&
defaultPrint
!=
null
)
{
if
(
defaultPrint
.
getFoodIsBold
()
==
0
)
{
defaultPrint
.
setFoodIsBold
(
printCurrencyBean
.
getFoodIsBold
());
}
if
(
defaultPrint
.
getFoodFont
().
equals
(
"0"
))
{
defaultPrint
.
setFoodFont
(
printCurrencyBean
.
getFoodFont
());
}
if
(
defaultPrint
.
getFoodIsItalic
()
==
0
)
{
defaultPrint
.
setFoodIsItalic
(
printCurrencyBean
.
getFoodIsItalic
());
}
if
(
defaultPrint
.
getModifierIsBold
()
==
0
)
{
defaultPrint
.
setModifierIsBold
(
printCurrencyBean
.
getModifierIsBold
());
}
if
(
defaultPrint
.
getModifierFont
().
equals
(
"0"
))
{
defaultPrint
.
setModifierFont
(
printCurrencyBean
.
getModifierFont
());
}
if
(
defaultPrint
.
getModifierIsItalic
()
==
0
)
{
defaultPrint
.
setModifierIsItalic
(
printCurrencyBean
.
getModifierIsItalic
());
}
if
(
defaultPrint
.
getNumberIsFlip
()
==
0
)
{
defaultPrint
.
setNumberIsFlip
(
printCurrencyBean
.
getNumberIsFlip
());
}
}
}
}
return
defaultPrint
;
}
}
private
void
initDialog
()
{
private
void
initDialog
()
{
...
@@ -371,6 +319,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -371,6 +319,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
case
PrintSocketHolder
.
STATE_4
:
case
PrintSocketHolder
.
STATE_4
:
Log
.
e
(
"eee"
,
"關閉中"
);
Log
.
e
(
"eee"
,
"關閉中"
);
tip
=
"關閉中"
;
tip
=
"關閉中"
;
finish
();
break
;
break
;
case
DIMISS_LOADING:
case
DIMISS_LOADING:
disLoadingDialog
();
disLoadingDialog
();
...
...
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrinterAddActivity.java
View file @
6bdf3095
...
@@ -130,7 +130,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
...
@@ -130,7 +130,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
private
int
flipPosition
=
0
;
//數量大於1是否翻轉
private
int
flipPosition
=
0
;
//數量大於1是否翻轉
public
static
List
<
String
>
printTypes
=
Arrays
.
asList
(
"網路打印"
,
"本機打印"
,
"USB打印"
);
public
static
List
<
String
>
printTypes
=
Arrays
.
asList
(
"網路打印"
,
"本機打印"
,
"USB打印"
);
private
List
<
String
>
fontSize
=
Arrays
.
asList
(
"預設"
,
"
0"
,
"1
"
);
private
List
<
String
>
fontSize
=
Arrays
.
asList
(
"預設"
,
"
1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"10"
,
"11"
,
"12"
,
"13"
,
"14"
,
"15"
,
"16"
,
"17"
,
"18"
,
"19"
,
"20"
,
"21"
,
"22"
,
"23"
,
"24"
,
"25"
,
"26"
,
"27"
,
"28"
,
"29"
,
"30
"
);
private
List
<
String
>
booleanSelect
=
Arrays
.
asList
(
"預設"
,
"是"
,
"否"
);
private
List
<
String
>
booleanSelect
=
Arrays
.
asList
(
"預設"
,
"是"
,
"否"
);
...
...
print-module/src/main/res/layout/print_bill_adapter_item_bill.xml
View file @
6bdf3095
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"@dimen/dp_5"
android:layout_marginLeft=
"@dimen/dp_5"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:layout_gravity=
"bottom"
android:gravity=
"right"
/>
android:gravity=
"right"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
print-module/src/main/res/layout/print_model_takeaway_member_integer_info.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/tv_print_model_member_number"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:text=
"會員號碼:"
/>
<TextView
android:id=
"@+id/tv_print_model_member_name"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:text=
"會員名稱:"
/>
<TextView
android:id=
"@+id/tv_print_model_member_phone"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:text=
"會員電話:"
/>
<TextView
android:id=
"@+id/tv_print_model_oldPoints"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:text=
"上次積分:"
/>
<TextView
android:id=
"@+id/tv_print_model_addPoints"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:text=
"本次積分:"
/>
<TextView
android:id=
"@+id/tv_print_model_nowPoints"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:text=
"結餘積分:"
/>
</LinearLayout>
\ No newline at end of file
print-module/src/main/res/layout/print_model_takeaway_order_info.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<include
layout=
"@layout/print_model_text_line"
/>
<TextView
android:id=
"@+id/tv_print_model_pay_type"
style=
"@style/print_other_order_thirty_bold_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"@dimen/dp_5"
tools:text=
"在線支付:Payme"
/>
<TextView
android:id=
"@+id/tv_print_model_delivery_time"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"@dimen/dp_5"
android:textColor=
"@color/theme_333_color"
android:textStyle=
"bold"
tools:text=
"盡快送達"
/>
<TextView
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:maxLines=
"1"
android:text=
"@string/print_split_line"
/>
<TextView
android:id=
"@+id/tv_print_model_bill_number"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools:text=
'單號:'
/>
<TextView
android:id=
"@+id/tv_print_model_order_number"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools:text=
'訂單號:'
/>
<TextView
android:id=
"@+id/tv_print_model_order_take_food_code"
style=
"@style/print_other_order_thirty_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"@dimen/dp_50"
android:textStyle=
"bold"
tools:text=
"取餐碼:"
/>
<TextView
android:id=
"@+id/tv_print_model_order_create_time"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools:text=
'開單時間'
/>
<TextView
android:id=
"@+id/tv_print_model_order_closing_time"
style=
"@style/print_other_order_twenty_six_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools:text=
"結賬時間"
/>
<TextView
android:id=
"@+id/tv_print_model_remark"
style=
"@style/print_other_order_thirty_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:textStyle=
"bold"
tools:text=
"備註:"
/>
</LinearLayout>
\ No newline at end of file
print-module/src/main/res/layout/print_model_takeaway_total_amount.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/tv_total_text"
style=
"@style/print_other_order_thirty_bold_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_10"
tools:text=
"總金額:"
/>
<TextView
android:id=
"@+id/tv_total"
style=
"@style/print_other_order_thirty_bold_style"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_10"
android:layout_weight=
"1"
android:gravity=
"right"
android:textStyle=
"bold"
tools:text=
"$11"
/>
</LinearLayout>
print-module/src/main/res/layout/print_model_text_line.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
xmlns:tools=
"http://schemas.android.com/tools"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
>
<TextView
style=
"@style/Print_text_style"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"0.5"
android:maxLines=
"1"
android:text=
"@string/print_split_line"
/>
<TextView
android:id=
"@+id/print_model_center_text"
style=
"@style/Print_text_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
tools:text=
"外送或自取"
/>
<TextView
style=
"@style/Print_text_style"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"0.5"
android:maxLines=
"1"
android:text=
"@string/print_split_line"
/>
</LinearLayout>
\ No newline at end of file
print-module/src/main/res/layout/print_model_textview.xml
0 → 100644
View file @
6bdf3095
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/tv_print_model_textview"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/contract/OrderContentContract.java
View file @
6bdf3095
...
@@ -81,7 +81,7 @@ public interface OrderContentContract {
...
@@ -81,7 +81,7 @@ public interface OrderContentContract {
Observable
<
TableBean
>
getTables
(
int
restaurantId
);
Observable
<
TableBean
>
getTables
(
int
restaurantId
);
Observable
<
TableDetail
>
getTable
(
int
tableId
);
Observable
<
TableDetail
>
getTable
(
long
tableId
);
Observable
<
BaseRespose
>
transferFood
(
RequestBody
requestBody
);
Observable
<
BaseRespose
>
transferFood
(
RequestBody
requestBody
);
}
}
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/model/OrderContentModel.java
View file @
6bdf3095
...
@@ -96,7 +96,7 @@ public class OrderContentModel extends BaseModel implements OrderContentContract
...
@@ -96,7 +96,7 @@ public class OrderContentModel extends BaseModel implements OrderContentContract
}
}
@Override
@Override
public
Observable
<
TableDetail
>
getTable
(
int
tableId
)
{
public
Observable
<
TableDetail
>
getTable
(
long
tableId
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
TableService
.
class
)
return
mRepositoryManager
.
obtainRetrofitService
(
TableService
.
class
)
.
getTable
(
tableId
);
.
getTable
(
tableId
);
}
}
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/OrderContentPresenter.java
View file @
6bdf3095
...
@@ -18,27 +18,17 @@ import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
...
@@ -18,27 +18,17 @@ import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import
com.gingersoft.gsa.cloud.base.common.bean.TableBean
;
import
com.gingersoft.gsa.cloud.base.common.bean.TableBean
;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage
;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage
;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage
;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage
;
import
com.gingersoft.gsa.cloud.base.utils.LanguageUtils
;
import
com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils
;
import
com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils
;
import
com.gingersoft.gsa.cloud.constans.GoldConstants
;
import
com.gingersoft.gsa.cloud.constans.GoldConstants
;
import
com.gingersoft.gsa.cloud.constans.PrintConstans
;
import
com.gingersoft.gsa.cloud.constans.PrintConstans
;
import
com.gingersoft.gsa.cloud.database.bean.Discount
;
import
com.gingersoft.gsa.cloud.database.bean.Discount
;
import
com.gingersoft.gsa.cloud.database.bean.Food
;
import
com.gingersoft.gsa.cloud.database.bean.Function
;
import
com.gingersoft.gsa.cloud.database.bean.Function
;
import
com.gingersoft.gsa.cloud.database.bean.Modifier
;
import
com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils
;
import
com.gingersoft.gsa.cloud.database.utils.ModifierDaoUtils
;
import
com.gingersoft.gsa.cloud.function.FunctionManager
;
import
com.gingersoft.gsa.cloud.print.PrinterUtils
;
import
com.gingersoft.gsa.cloud.print.PrinterUtils
;
import
com.gingersoft.gsa.cloud.table.ComponentTable
;
import
com.gingersoft.gsa.cloud.table.R
;
import
com.gingersoft.gsa.cloud.table.app.TableOperatTypeConstant
;
import
com.gingersoft.gsa.cloud.table.mvp.contract.OrderContentContract
;
import
com.gingersoft.gsa.cloud.table.mvp.contract.OrderContentContract
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.BaseRespose
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.BaseRespose
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.TableDetail
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.TableDetail
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.request.AddOrderRequest
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.request.AddOrderRequest
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.request.CreateOrderRequest
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.request.CreateOrderRequest
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.request.SoldoutRequest
;
import
com.gingersoft.gsa.cloud.table.mvp.model.utils.OrderAssemblyUtil
;
import
com.gingersoft.gsa.cloud.table.mvp.model.utils.OrderAssemblyUtil
;
import
com.gingersoft.gsa.cloud.table.mvp.ui.activity.MealStandActivity
;
import
com.gingersoft.gsa.cloud.table.mvp.ui.activity.MealStandActivity
;
import
com.gingersoft.gsa.cloud.table.mvp.ui.activity.OrderContentActivity
;
import
com.gingersoft.gsa.cloud.table.mvp.ui.activity.OrderContentActivity
;
...
@@ -48,11 +38,9 @@ import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.OrderMoneyAdapter;
...
@@ -48,11 +38,9 @@ import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.OrderMoneyAdapter;
import
com.gingersoft.gsa.cloud.table.mvp.ui.adapter.OrderTopFunctionAdapter
;
import
com.gingersoft.gsa.cloud.table.mvp.ui.adapter.OrderTopFunctionAdapter
;
import
com.gingersoft.gsa.cloud.table.mvp.ui.widget.DiscountDialog
;
import
com.gingersoft.gsa.cloud.table.mvp.ui.widget.DiscountDialog
;
import
com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog
;
import
com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog
;
import
com.jess.arms.base.DefaultAdapter
;
import
com.jess.arms.di.scope.ActivityScope
;
import
com.jess.arms.di.scope.ActivityScope
;
import
com.jess.arms.http.imageloader.ImageLoader
;
import
com.jess.arms.http.imageloader.ImageLoader
;
import
com.jess.arms.integration.AppManager
;
import
com.jess.arms.integration.AppManager
;
import
com.jess.arms.utils.ArmsUtils
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
com.scwang.smartrefresh.layout.api.RefreshLayout
;
import
com.scwang.smartrefresh.layout.api.RefreshLayout
;
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/OrderPayPresenter.java
View file @
6bdf3095
package
com
.
gingersoft
.
gsa
.
cloud
.
table
.
mvp
.
presenter
;
package
com
.
gingersoft
.
gsa
.
cloud
.
table
.
mvp
.
presenter
;
import
android.app.Application
;
import
android.app.Application
;
import
android.text.TextUtils
;
import
android.view.View
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.base.common.bean.BaseResult
;
import
com.gingersoft.gsa.cloud.base.common.bean.BaseResult
;
import
com.gingersoft.gsa.cloud.base.common.bean.OrderDetail
;
import
com.gingersoft.gsa.cloud.base.common.bean.OrderDetail
;
...
@@ -19,15 +16,12 @@ import com.gingersoft.gsa.cloud.table.mvp.contract.OrderPayContract;
...
@@ -19,15 +16,12 @@ import com.gingersoft.gsa.cloud.table.mvp.contract.OrderPayContract;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.request.AddOrderRequest
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.request.AddOrderRequest
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.request.CreateOrderRequest
;
import
com.gingersoft.gsa.cloud.table.mvp.model.bean.request.CreateOrderRequest
;
import
com.gingersoft.gsa.cloud.table.mvp.ui.activity.OrderPayActivity
;
import
com.gingersoft.gsa.cloud.table.mvp.ui.activity.OrderPayActivity
;
import
com.gingersoft.gsa.cloud.ui.adapter.BillMethodAdapter
;
import
com.gingersoft.gsa.cloud.ui.adapter.BillMoneyAdapter
;
import
com.gingersoft.gsa.cloud.ui.view.OrderPayView
;
import
com.gingersoft.gsa.cloud.ui.view.OrderPayView
;
import
com.jess.arms.di.scope.ActivityScope
;
import
com.jess.arms.di.scope.ActivityScope
;
import
com.jess.arms.http.imageloader.ImageLoader
;
import
com.jess.arms.http.imageloader.ImageLoader
;
import
com.jess.arms.integration.AppManager
;
import
com.jess.arms.integration.AppManager
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
...
...
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/activity/MealStandActivity.java
View file @
6bdf3095
...
@@ -42,7 +42,6 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
...
@@ -42,7 +42,6 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage
;
import
com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage
;
import
com.gingersoft.gsa.cloud.base.utils.LanguageUtils
;
import
com.gingersoft.gsa.cloud.base.utils.LanguageUtils
;
import
com.gingersoft.gsa.cloud.base.utils.VibratorUtils
;
import
com.gingersoft.gsa.cloud.base.utils.VibratorUtils
;
import
com.gingersoft.gsa.cloud.base.utils.encryption.Md5
;
import
com.gingersoft.gsa.cloud.base.utils.other.SPUtils
;
import
com.gingersoft.gsa.cloud.base.utils.other.SPUtils
;
import
com.gingersoft.gsa.cloud.database.bean.Food
;
import
com.gingersoft.gsa.cloud.database.bean.Food
;
import
com.gingersoft.gsa.cloud.database.utils.ComboItemDaoUtils
;
import
com.gingersoft.gsa.cloud.database.utils.ComboItemDaoUtils
;
...
@@ -623,10 +622,10 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
...
@@ -623,10 +622,10 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
private
List
<
SectionTextItem
>
getMemberInfoItem
(
MemberInfo
memberInfo
)
{
private
List
<
SectionTextItem
>
getMemberInfoItem
(
MemberInfo
memberInfo
)
{
List
<
SectionTextItem
>
textItems
=
new
ArrayList
<>();
List
<
SectionTextItem
>
textItems
=
new
ArrayList
<>();
textItems
.
add
(
new
SectionTextItem
(
"會員號碼: "
+
memberInfo
.
getMemberNo
()));
//
textItems.add(new SectionTextItem("會員號碼: " + memberInfo.getMemberNo()));
textItems
.
add
(
new
SectionTextItem
(
"會員電話: "
+
memberInfo
.
getPhone
()));
//
textItems.add(new SectionTextItem("會員電話: " + memberInfo.getPhone()));
textItems
.
add
(
new
SectionTextItem
(
"會員名稱: "
+
memberInfo
.
getMemberName
()));
//
textItems.add(new SectionTextItem("會員名稱: " + memberInfo.getMemberName()));
textItems
.
add
(
new
SectionTextItem
(
"積分: "
+
memberInfo
.
getMemberPoint
()));
//
textItems.add(new SectionTextItem("積分: " + memberInfo.getMemberPoint()));
return
textItems
;
return
textItems
;
}
}
...
...
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