Commit 2abd64bd by 宁斌

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	base-module/build.gradle
#	base-module/src/main/java/com/gingersoft/gsa/cloud/config/globalconfig/GlobalConfiguration.java
#	delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/data/network/ServiceCreator.kt
#	delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/presenter/SendOrderPresenter.java
parents 1d233a8d ceec008e
......@@ -101,6 +101,7 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/javabase64-1.2.jar')
implementation files('libs/sun.misc.BASE64Decoder.jar')
api files('libs/jcifs-1.3.19.jar')
api files('libs/nexgon5lib.jar')
if (project.ext.runAsApp) {
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
......
package com.gingersoft.gsa.cloud.base.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
......@@ -77,4 +82,27 @@ public class CollectionUtils {
}
}
}
/**
* 深拷貝一個list集合,改變當前集合不影響之前的集合數據
* @param src
* @param <E>
* @return
*/
public static <E> List<E> deepCopy(List<E> src) {
try {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(src);
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
ObjectInputStream in = new ObjectInputStream(byteIn);
@SuppressWarnings("unchecked")
List<E> dest = (List<E>) in.readObject();
return dest;
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<E>();
}
}
}
......@@ -4,6 +4,7 @@ import android.content.Context;
import com.gingersoft.gsa.cloud.base.BuildConfig;
import com.gingersoft.gsa.cloud.config.globalconfig.applyOptions.intercept.LoggingInterceptor;
import com.jess.arms.di.module.ClientModule;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
......
......@@ -15,7 +15,10 @@ public class ExpandConstant {
public final static String PrintStatisticsAmount = "PrintStatisticsAmount";//是否顯示統計打印數
public final static String PrintFirstOrder = "PrintFirstOrder";//是否打印"頭單"文字
public final static String FrozenChainAutoOrder = "FrozenChainAutoOrder";//是否自動接單 為0true
public final static String FrozenChainAutoOrder = "FrozenChainAutoOrder";//凍鏈是否自動接單 為0時true
public final static String TakeawayAutoOrder = "TakeawayAutoOrder";//外賣/自取 是否自動接單 為0時true
public final static String Rounding = "Rounding";
public final static String RoundingDecimal = "RoundingDecimal";
......
......@@ -25,7 +25,7 @@ public interface FoodSummaryConstans {
*/
int MEAL_MENU = 4;
/**
* 鏈餐種
* 鏈餐種
*/
int COLD_CHAIN = 5;
/**
......
......@@ -169,7 +169,7 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
@Override
public void onNext(Long aLong) {
mPresenter.updateExpandInfo(ExpandConstant.FrozenChainAutoOrder, new String[]{RestaurantExpandInfoUtils.VALUE_INT}, new String[]{RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false) ? "0" : "1"});
// mPresenter.updateExpandInfo(ExpandConstant.FrozenChainAutoOrder, new String[]{RestaurantExpandInfoUtils.VALUE_INT}, new String[]{RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false) ? "0" : "1"});
if (!isChecked) {
mPresenter.stopAutoReceivingOrders();
} else {
......
......@@ -131,9 +131,10 @@ ext {
"immersionbar" : "com.gyf.immersionbar:immersionbar:3.0.0",
// fragment快速实现(可选)
"immersionbar-components" : "com.gyf.immersionbar:immersionbar-components:3.0.0",
//獲取權限
"permissionx" : 'com.permissionx.guolindev:permissionx:1.3.1',
//美團點評-日誌監聽https://github.com/Meituan-Dianping/Logan/tree/master/Example/Logan-Android
"logan" : 'com.dianping.android.sdk:logan:1.2.4',
//滴滴開源 哆啦A夢:辅助开发工具、测试效率工具、视觉辅助工具
"doraemonkit" : 'com.didichuxing.doraemonkit:dokitx:3.3.3'
]
......
......@@ -54,10 +54,6 @@ public class ExpandInfo implements Serializable {
private int dataType;
private String showName;
//是否被編輯了
@Transient
private boolean isUpdate = false;
public static final byte data_type_int = 1;
public static final byte data_type_string = 2;
public static final byte data_type_boolean = 3;
......
......@@ -8,6 +8,7 @@ import com.gingersoft.gsa.cloud.constans.AppConstans
import com.gingersoft.gsa.cloud.constans.HttpsConstans
import com.gingersoft.gsa.cloud.constans.HttpsConstans.ROOT_SERVER
import com.gingersoft.gsa.cloud.constans.HttpsConstans.URK_RICEPON_GSA
import com.gingersoft.gsa.cloud.config.globalconfig.applyOptions.intercept.LoggingInterceptor
import com.jess.arms.utils.DeviceUtils
import okhttp3.Headers
import okhttp3.Interceptor
......@@ -133,7 +134,6 @@ object ServiceCreator {
token = Aes.aesEncrypt("9_" + memberId + "_" + System.currentTimeMillis() + "_" + loginToken)
token = token.replace("\r|\n".toRegex(), "")
builder.set("token", token)
Log.e("eee", "添加Token:" + token);
}
val request1 = chain.request().newBuilder().headers(builder.build()).build()
return chain.proceed(request1)
......
......@@ -31,6 +31,7 @@ import com.gingersoft.gsa.delivery_pick_mode.data.WeatherRepository
import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.*
import com.gingersoft.gsa.delivery_pick_mode.ui.adapter.DeliveryAdapter
import com.gingersoft.gsa.delivery_pick_mode.util.OtherOrderUtils
import com.gingersoft.gsa.delivery_pick_mode.util.RxTimerUtil
import com.jess.arms.utils.ArmsUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
......@@ -52,11 +53,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
val Transportation = 1009//修改運輸工具成功
}
val restaurantId by lazy { GsaCloudApplication.getRestaurantId() }
var mOrderNum = arrayListOf<MutableLiveData<Int>>()
var mOrderList = arrayListOf<MutableLiveData<ArrayList<OrderList.DataBeanX.DataBean>>>()
var orderList = MutableLiveData<OrderList>()
//其他的所有數據
var otherInfo = MutableLiveData<OrderList.DataBeanX.DataBean>()
......@@ -64,12 +67,16 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
//刷新狀態,值為當前頁面的下標
var refreshState = MutableLiveData(0)
//訂單號
var orderNo: String = ""
//手機號
var phone: String = ""
//派送員信息
var deliveryBean: DeliveryBean? = null
//接單超時時間
var timeOut = 0
......@@ -79,6 +86,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
var bookingConfigTime = MutableLiveData<Int>()//預約單配置時間
var addServiceChargeBean = MutableLiveData<AddServiceChargeBean>()
/**
* 獲取訂單數量
* status
......@@ -144,11 +152,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
if (position > 1) {
orderType = 0
}
// if (orderType != 0 && !fragmentStatus[position].contains("8")) {
// fragmentStatus[position] += ",8"
// } else {
// fragmentStatus[position].removePrefix(",8")
// }
repository.requestOrderList(restaurantId, fragmentStatus[position], fragmentType[position], page, orderNo, phone, orderType
?: 0).apply {
if (isSuccess()) {
......@@ -168,6 +171,86 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
}
/**
* 開始自動確認訂單
*/
fun startAutoConfirmOrder() {
RxTimerUtil.interval({
launch({
//獲取即時單
repository.requestOrderList(restaurantId.toString(), fragmentStatus[1], fragmentType[0], "1", orderNo, phone, 0).apply {
if (isSuccess()) {
val data = getData()
if (data != null) {
val dataList = data.data
//這裡判斷數量大於1,默認有一條配置數據,忽略掉
if (dataList != null && dataList.size > 1) {
//確認訂單之前得先獲取訂單詳情
val orderInfo = repository.getOrderInfo(dataList[0].Id.toString())
if (orderInfo.data != null && orderInfo.data!!.isNotEmpty()) {
val orderDetail = orderInfo.data!![0]
if (orderDetail.order_type == 7) {
//如果是自取單,將物流類型改為本店
orderDetail.companyType = 0
}
var trafficType = ""
if (orderDetail.companyType == 2) {
//lalamove
val transportationBean = getTransportationConfig(restaurantId)
if (transportationBean.success && transportationBean.data != null && transportationBean.data.list != null) {
for (value in transportationBean.data.list) {
if (value.status == 1) {
//默認交通工具,判斷價格是不是在這個金額範圍內,如果在,則不提示,如果不在,提示用戶修改交通工具
trafficType = value.type.toString()
}
}
}
}
confirmOrder(orderDetail, 2, trafficType, restaurantId, isPrintPrj = true, isPrintBill = false) {
//確認之後,刷新列表
refreshState.postValue(0)
}
}
} else {
}
} else {
}
} else {
}
}
//獲取預約單
repository.requestOrderList(restaurantId.toString(), fragmentStatus[1], fragmentType[0], "1", orderNo, phone, 1).apply {
if (isSuccess()) {
val data = getData()
if (data != null) {
val dataList = data.data
//這裡判斷數量大於1,默認有一條配置數據,忽略掉
if (dataList != null && dataList.size > 1) {
//確認訂單之前得先獲取訂單詳情
val orderInfo = repository.getOrderInfo(dataList[0].Id.toString())
if (orderInfo.data != null && orderInfo.data!!.isNotEmpty()) {
val orderDetail = orderInfo.data!![0]
updateOrderAndPrint(restaurantId, orderDetail, 8, false) {
refreshState.postValue(0)
}
}
}
}
}
}
}, {
})
}, 10 * 1000)
}
fun stopAutoConfirmOrder() {
RxTimerUtil.cancelInterval()
}
private fun OrderList.loadInfo(isLoadMore: Boolean, position: Int) {
getData()?.statistics?.let {
bookingOrderNum.value = it.reservationNumber
......@@ -239,20 +322,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
/**
* 根據餐廳ID和訂單ID獲取物流信息
*/
// fun getShipanyOrderTime(restaurantId: String, orderId: String) {
// launch({
// repository.getShipanyOrderTime(restaurantId, orderId).apply {
// }
// }, {
// //出錯
// it.printStackTrace()
// })
// }
var orderDetails = MutableLiveData<OrderDetails>()
//獲取訂單詳情和物流送達時間
......@@ -287,14 +356,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
}
val estimatedBean = withContext(Dispatchers.Default) { repository.getShipanyOrderTime(restaurantId.toString(), orderId, type) }//1、预计整张订单完成时间2、預計配送員接單時間3、預計配送員到店時間4、配送員預計送達時間
// if (estimatedBean.data.estimated_time > 0) {
if (estimatedBean.data != null) {
data.estimatedTime = estimatedTime + ("${estimatedBean.data.estimated_time}分鐘後")
}
orderDetails.postValue(orderDetail)
// } else {
// data.estimatedTime = ""
// }
}
}
}
......@@ -326,20 +391,20 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
fun confirmOrder(dataBean: OrderDetails.DataBean, status: Int, trafficType: String = "", restaurantId: Int, isPrint: Boolean = true, listener: (MessageBean) -> Unit) {
fun confirmOrder(dataBean: OrderDetails.DataBean, status: Int, trafficType: String = "", restaurantId: Int, isPrintPrj: Boolean = true, isPrintBill: Boolean = true, listener: (MessageBean) -> Unit) {
launch({
when (dataBean.companyType) {
0 -> {
//本店
updateOrderAndPrint(restaurantId, dataBean, status, isPrint, listener)
updateOrderAndPrint(restaurantId, dataBean, status, isPrintPrj, listener)
}
1 -> {
//zeek
thirdSend(restaurantId, dataBean, trafficType, status, isPrint, listener)
thirdSend(restaurantId, dataBean, trafficType, status, isPrintPrj, isPrintBill, listener)
}
2 -> {
//lalamove
thirdSend(restaurantId, dataBean, trafficType, status, isPrint, listener)
thirdSend(restaurantId, dataBean, trafficType, status, isPrintPrj, isPrintBill, listener)
}
}
}, {
......@@ -439,16 +504,20 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
}
fun updateOrderAndPrint(restaurantId: Int, dataBean: OrderDetails.DataBean, status: Int, isPrint: Boolean = true, listener: (MessageBean) -> Unit) {
updateOrderAndPrint(restaurantId, dataBean, status, isPrint, isPrint, listener)
}
/**
* 修改訂單狀態並打印,狀態為0,1,2才打印
*/
fun updateOrderAndPrint(restaurantId: Int, dataBean: OrderDetails.DataBean, status: Int, isPrint: Boolean = true, listener: (MessageBean) -> Unit) {
fun updateOrderAndPrint(restaurantId: Int, dataBean: OrderDetails.DataBean, status: Int, isPrintPrj: Boolean = true, isPrintBill: Boolean = true, listener: (MessageBean) -> Unit) {
launch({
repository.gsUpdateOrderStatus(dataBean.ID, status, dataBean.order_type, 1, "", "", "", "0", "", 1, 0).apply {
if (status == 0 || status == 1 || status == 2 || status == 8) {
//確認送單
//添加數據到prj
if (isPrint) {
if (isPrintPrj) {
val ids = StringBuffer()
dataBean.PRODUCT_NAME.let {
if (it != null) {
......@@ -483,7 +552,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
}
if (this.code == "1") {
if (isPrint) {
if (isPrintBill) {
// 打印印單
// 初始化用於打印的view
// 送單成功後,再調用接口獲取取餐碼
......@@ -596,7 +665,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
* 第三方派送
*/
private fun thirdSend(restaurantId: Int, dataBean: OrderDetails.DataBean, trafficType: String, status: Int, isPrint: Boolean = true, listener: (MessageBean) -> Unit) {
private fun thirdSend(restaurantId: Int, dataBean: OrderDetails.DataBean, trafficType: String, status: Int, isPrintPrj: Boolean = true, isPrintBill: Boolean = true, listener: (MessageBean) -> Unit) {
val third = ThirdItem()
//將食品數據轉為第三方需要的數據
dataBean.PRODUCT_NAME?.let {
......@@ -611,16 +680,17 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
}
//調用第三方物流接口
callThird(dataBean, trafficType, third, restaurantId, status, isPrint, listener)
callThird(dataBean, trafficType, third, restaurantId, status, isPrintPrj, isPrintBill, listener)
}
private fun callThird(dataBean: OrderDetails.DataBean, trafficType: String, third: ThirdItem, restaurantId: Int, status: Int, isPrint: Boolean = true, listener: (MessageBean) -> Unit) {
private fun callThird(dataBean: OrderDetails.DataBean, trafficType: String, third: ThirdItem, restaurantId: Int, status: Int, isPrintPrj: Boolean = true, isPrintBill: Boolean = true, listener: (MessageBean) -> Unit) {
launch({
repository.thirdDelivery(dataBean.ID.toString(), trafficType, third).apply {
if (success) {
if (isPrint) {
updateOrderAndPrint(restaurantId, dataBean, status, isPrint, listener)
if (isPrintPrj || isPrintBill) {
updateOrderAndPrint(restaurantId, dataBean, status, isPrintPrj, isPrintBill, listener)
} else {
//都不打印,說明是修改交通工具
listener(getMsgBean(Transportation, errMsg ?: "修改運輸工具成功", success))
}
} else if (!TextUtil.isEmptyOrNullOrUndefined(errMsg)) {
......@@ -642,9 +712,9 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
getOrderInfo(dataBean.ID.toString()) {
if (it?.data != null && it.data!!.isNotEmpty() && it.data!![0].isDelete == 0) {
//已經指派第三方物流,就調用修改訂單狀態接口
updateOrderAndPrint(restaurantId, dataBean, status, isPrint, listener)
updateOrderAndPrint(restaurantId, dataBean, status, isPrintPrj, isPrintBill, listener)
} else {
callThird(dataBean, trafficType, third, restaurantId, status, isPrint, listener)
callThird(dataBean, trafficType, third, restaurantId, status, isPrintPrj, isPrintBill, listener)
}
}
} else {
......@@ -853,6 +923,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
var payTypeBean = MutableLiveData<List<PayMethod>>()
/**
* 獲取支付方式
*/
......
......@@ -3,6 +3,8 @@ package com.gingersoft.gsa.delivery_pick_mode.mvp.presenter;
import android.app.Activity;
import android.app.Application;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.order.order.TakeawayOrder;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
......
......@@ -103,28 +103,24 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
//餐廳營業信息
loadRestaurantInfo(binding)
cl_order_info.post {
layoutHeight = cl_order_info.height.toFloat()
}
btn_open_or_close_info.post {
btnHeight = btn_open_or_close_info.height.toFloat()
}
initInfoHeight()
layout_immediate_order.setOnClickListener {
it.background = ContextCompat.getDrawable(this, R.drawable.shape_left_themecolor_radius_btn)
layout_booking_order.background = ContextCompat.getDrawable(this, R.drawable.shape_right_white_radius_btn)
tv_immediate_order.setTextColor(ContextCompat.getColor(this, R.color.white))
tv_booking_order.setTextColor(ContextCompat.getColor(this, R.color.theme_333_color))
pageViewModel.appointmentType.postValue(0)
initOrderType()
//是否自動接單
cb_takeaway_auto_receiving_orders.setOnCheckedChangeListener { buttonView, isChecked ->
if(isChecked){
pageViewModel.startAutoConfirmOrder()
} else {
pageViewModel.stopAutoConfirmOrder()
}
layout_booking_order.setOnClickListener {
it.background = ContextCompat.getDrawable(this, R.drawable.shape_right_themecolor_radius_btn)
layout_immediate_order.background = ContextCompat.getDrawable(this, R.drawable.shape_left_white_radius_btn)
tv_booking_order.setTextColor(ContextCompat.getColor(this, R.color.white))
tv_immediate_order.setTextColor(ContextCompat.getColor(this, R.color.theme_333_color))
pageViewModel.appointmentType.postValue(1)
RestaurantExpandInfoUtils.setValue(ExpandConstant.TakeawayAutoOrder, isChecked)
}
cb_takeaway_auto_receiving_orders.isChecked = RestaurantExpandInfoUtils.getValue<Boolean>(ExpandConstant.TakeawayAutoOrder, false)
pageViewModel.apply {
if(cb_takeaway_auto_receiving_orders.isChecked){
startAutoConfirmOrder()
}
getDeliveryInfo(restaurantId.toString(), memberId.toString())
balanceBean.observe(this@DeliveryOrderMainActivity, Observer {
it?.data?.let { data ->
......@@ -151,6 +147,38 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
}
}
/**
* 獲取高度用於收起展開
*/
private fun initInfoHeight() {
cl_order_info.post {
layoutHeight = cl_order_info.height.toFloat()
}
btn_open_or_close_info.post {
btnHeight = btn_open_or_close_info.height.toFloat()
}
}
/**
* 初始化即時單,預約單選中狀態
*/
private fun initOrderType() {
layout_immediate_order.setOnClickListener {
it.background = ContextCompat.getDrawable(this, R.drawable.shape_left_themecolor_radius_btn)
layout_booking_order.background = ContextCompat.getDrawable(this, R.drawable.shape_right_white_radius_btn)
tv_immediate_order.setTextColor(ContextCompat.getColor(this, R.color.white))
tv_booking_order.setTextColor(ContextCompat.getColor(this, R.color.theme_333_color))
pageViewModel.appointmentType.postValue(0)
}
layout_booking_order.setOnClickListener {
it.background = ContextCompat.getDrawable(this, R.drawable.shape_right_themecolor_radius_btn)
layout_immediate_order.background = ContextCompat.getDrawable(this, R.drawable.shape_left_white_radius_btn)
tv_booking_order.setTextColor(ContextCompat.getColor(this, R.color.white))
tv_immediate_order.setTextColor(ContextCompat.getColor(this, R.color.theme_333_color))
pageViewModel.appointmentType.postValue(1)
}
}
private fun initViewPager() {
val sectionsPagerAdapter = SectionsPagerAdapter(this, supportFragmentManager, ints)
view_pager.adapter = sectionsPagerAdapter
......@@ -406,6 +434,7 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
override fun onDestroy() {
super.onDestroy()
pageViewModel.stopAutoConfirmOrder()
bind?.setOnPostCallBack(null)
bind?.execute {}
cancelDialogForLoading()
......@@ -603,9 +632,9 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
.setActionName("showMealStandActivity")
.build()
.call()
SPUtils.remove( SendOrderActivity.MEMBER_NAME_KEY)
SPUtils.remove( SendOrderActivity.MEMBER_PHONE_KEY)
SPUtils.remove( SendOrderActivity.MEMBER_ADDRESS_KEY)
SPUtils.remove(SendOrderActivity.MEMBER_NAME_KEY)
SPUtils.remove(SendOrderActivity.MEMBER_PHONE_KEY)
SPUtils.remove(SendOrderActivity.MEMBER_ADDRESS_KEY)
pop!!.dismiss()
}
}
......
......@@ -596,7 +596,7 @@ class OrderDetailsActivity : BaseActivity<IPresenter>() {
private fun PageViewModel.confirmOrder(orderDetails: OrderDetails.DataBean, trafficType: String = "", isPrint: Boolean = true) {
showLoading()
var status = 2
confirmOrder(orderDetails, status, trafficType, restaurantId, if (isBookingOrder) false else isPrint, listener)
confirmOrder(orderDetails, status, trafficType, restaurantId, if (isBookingOrder) false else isPrint, if (isBookingOrder) false else isPrint, listener)
}
/**
......
......@@ -38,7 +38,6 @@ class PlaceholderFragment : BaseFragment(R.layout.fragment_other_order) {
pageViewModel.apply {
// 綁定狀態,如果這個值發生變化
refreshState.observe(viewLifecycleOwner, Observer {
Log.e("CSDN_LQR0", "頁面pageindex$it" + "當前頁面$position")
if (position == it) {
page = 1
getOrderList(false)
......
......@@ -183,7 +183,7 @@
android:background="@drawable/shape_restaurant_state_bg"
android:text="營業中 "
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintRight_toLeftOf="@id/cb_takeaway_auto_receiving_orders"
app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />
<ImageView
......@@ -196,6 +196,18 @@
app:layout_constraintRight_toRightOf="@id/tv_restaurant_state"
app:layout_constraintTop_toTopOf="@id/tv_restaurant_state" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/cb_takeaway_auto_receiving_orders"
style="@style/MyCheckbox_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
android:text="自動接單"
android:textColor="@color/color_a9"
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />
<!-- -->
<!-- <com.gingersoft.gsa.cloud.ui.view.SwitchButton-->
<!-- android:id="@+id/btn_switch_restaurant_state"-->
......
......@@ -4,6 +4,7 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
......@@ -17,6 +18,7 @@ import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
......@@ -40,9 +42,12 @@ public class ExpandListPresenter extends BasePresenter<ExpandListContract.Model,
@Inject
AppManager mAppManager;
private List<ExpandInfo> originalDate;
@Inject
public ExpandListPresenter(ExpandListContract.Model model, ExpandListContract.View rootView) {
super(model, rootView);
originalDate = new ArrayList<>();
}
@Override
......@@ -68,7 +73,22 @@ public class ExpandListPresenter extends BasePresenter<ExpandListContract.Model,
if (result.isSuccess()) {
if (result.getData() != null) {
List<ExpandInfo> expandInfoList = JsonUtils.parseArray(result.getData(), ExpandInfo.class);
if (expandInfoList != null) {
originalDate = CollectionUtils.deepCopy(expandInfoList);
mRootView.loadExpandList(expandInfoList);
} else {
if (TextUtil.isNotEmptyOrNullOrUndefined(result.getErrMsg())) {
mRootView.showMessage(result.getErrMsg());
} else {
mRootView.showMessage("數據獲取失敗");
}
}
} else {
if (TextUtil.isNotEmptyOrNullOrUndefined(result.getErrMsg())) {
mRootView.showMessage(result.getErrMsg());
} else {
mRootView.showMessage("數據獲取失敗");
}
}
}
}
......@@ -77,7 +97,20 @@ public class ExpandListPresenter extends BasePresenter<ExpandListContract.Model,
public void updateExpandInfo(List<ExpandInfo> data) {
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(data));
List<ExpandInfo> changeData = new ArrayList<>();
if (originalDate != null) {
for (ExpandInfo expandInfo : data) {
if (!originalDate.contains(expandInfo)) {
//改變了
changeData.add(expandInfo);
}
}
}
if (changeData.size() <= 0) {
mRootView.killMyself();
return;
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(changeData));
mModel.updateExpandInfo(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
......
......@@ -10,7 +10,6 @@ import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.database.bean.ExpandInfo;
import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.R2;
......@@ -25,9 +24,6 @@ import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import butterknife.BindView;
......@@ -132,28 +128,8 @@ public class ExpandListActivity extends BaseActivity<ExpandListPresenter> implem
int viewId = v.getId();
if (viewId == R.id.btn_expand_save) {
//保存
List<ExpandInfo> data = expandListAdapter.getData();
List<ExpandInfo> updateDate = new ArrayList<>();
for (ExpandInfo expandInfo : data) {
if(expandInfo.isUpdate()){
if(expandInfo.getValueDatetime() != null){
Calendar calendar = Calendar.getInstance();
try {
calendar.setTime(TimeUtils.ENGLISH_DATE_FORMAT.parse(expandInfo.getValueDatetime()));
} catch (ParseException e) {
e.printStackTrace();
}
expandInfo.setValueDatetime(TimeUtils.getStringByFormat(calendar.getTime(), TimeUtils.DEFAULT_DATE_FORMAT));
}
updateDate.add(expandInfo);
}
}
if (updateDate.size() > 0) {
//調用接口批量修改
mPresenter.updateExpandInfo(updateDate);
} else {
killMyself();
}
mPresenter.updateExpandInfo(expandListAdapter.getData());
}
}
}
......@@ -32,7 +32,6 @@ public class ExpandListAdapter extends BaseQuickAdapter<ExpandInfo, BaseViewHold
@Override
protected void convert(@NotNull BaseViewHolder baseViewHolder, ExpandInfo function) {
// baseViewHolder.setText(R.id.tv_expand_name, function.getShowName());
baseViewHolder.setText(R.id.tv_expand_name, function.getRemark());
EditText editText = baseViewHolder.getView(R.id.ed_expand_edit);
Switch btn = baseViewHolder.getView(R.id.switch_expand_boolean);
......@@ -62,14 +61,12 @@ public class ExpandListAdapter extends BaseQuickAdapter<ExpandInfo, BaseViewHold
btn.setChecked(function.getValueInt() == 0);
btn.setOnCheckedChangeListener((buttonView, isChecked) -> {
function.setValueInt(isChecked ? 0 : 1);
function.setUpdate(true);
});
} else if (function.getDataType() == 4) {
//日期
editText.setVisibility(View.GONE);
btn.setVisibility(View.GONE);
tvTime.setVisibility(View.VISIBLE);
Calendar calendar = Calendar.getInstance();
if (function.getValueDatetime() != null) {
try {
......@@ -83,10 +80,9 @@ public class ExpandListAdapter extends BaseQuickAdapter<ExpandInfo, BaseViewHold
//时间选择器
new TimePickerBuilder(getContext(), (date, view) -> {
tvTime.setText(TimeUtils.parseDateToString(date, TimeUtils.DATE_FORMAT_DATE));
function.setUpdate(true);
})
.setDate(calendar)
.setType(new boolean[]{true,true,true,false,false,false})
.setType(new boolean[]{true, true, true, false, false, false})
.setContentTextSize(24)
.setLabel("", "", "", "", "", "")
.build()
......@@ -99,10 +95,11 @@ public class ExpandListAdapter extends BaseQuickAdapter<ExpandInfo, BaseViewHold
tvTime.setVisibility(View.GONE);
editText.setVisibility(View.GONE);
}
if (editText.getVisibility() == View.VISIBLE) {
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
......@@ -112,18 +109,18 @@ public class ExpandListAdapter extends BaseQuickAdapter<ExpandInfo, BaseViewHold
@Override
public void afterTextChanged(Editable s) {
if (function.getDataType() == 1) {
ExpandInfo expandInfo = getData().get(baseViewHolder.getAdapterPosition());
if (expandInfo.getDataType() == 1) {
if (TextUtil.isNotEmptyOrNullOrUndefined(s.toString())) {
function.setValueInt(Integer.parseInt(s.toString()));
function.setUpdate(true);
expandInfo.setValueInt(Integer.parseInt(s.toString()));
}
} else if (function.getDataType() == 2) {
} else if (expandInfo.getDataType() == 2) {
if (TextUtil.isNotEmptyOrNullOrUndefined(s.toString())) {
function.setValueChar(s.toString());
function.setUpdate(true);
expandInfo.setValueChar(s.toString());
}
}
}
});
}
}
}
......@@ -183,9 +183,13 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
return;
}
} else {
if (defaultPrint == null) {
printLocation = "";
} else {
printLocation = defaultPrint.getName();
}
}
}
prjBean.setPrintPosition(printLocation);
prjBean.setCurrentIndex(1);
}
......
......@@ -10,7 +10,6 @@ import com.epson.epos2.printer.Printer;
import com.epson.epos2.printer.PrinterStatusInfo;
import com.epson.epos2.printer.ReceiveListener;
import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.base.utils.time.TimePickerUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.PrintExecutor;
......@@ -21,11 +20,19 @@ import com.joe.print.mvp.print.common.SendCallback;
import com.joe.print.mvp.print.common.SendResultCode;
import com.joe.print.mvp.print.usb.UsbPrinter;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import jcifs.UniAddress;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileInputStream;
import jcifs.smb.SmbFileOutputStream;
import jcifs.smb.SmbSession;
public class PrintTestActivity extends AppCompatActivity implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener, ReceiveListener {
private int lineLength = 42;//一行42個 17.5
......@@ -33,6 +40,51 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH
private static int foodNumSpace = 8;
private static int foodAmountSpace = 10;
private static void run() {
String ip = "192.168.1.144";
String rootPath = "smb://" + ip + "/KuGou/";
try {
UniAddress domain = UniAddress.getByName(ip);
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(rootPath,
"", "");
SmbSession.logon(domain, auth);
SmbFile smbFile = new SmbFile(rootPath, auth);
smbFile.connect();
if (smbFile.isDirectory()) {
String newFilePath = rootPath + System.currentTimeMillis() + ".prj";
SmbFile createFile = new SmbFile(newFilePath, auth);
createFile.connect();
createFile.createNewFile();
if (createFile.exists()) {
SmbFileInputStream in = new SmbFileInputStream(createFile);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new SmbFileOutputStream(createFile, true));
bufferedOutputStream.write("oiasfia按時間肯定很快就愛上檔卡戶時段接口和6556a6d5as65das5das奧術大師大所奧術大師大所".getBytes());
bufferedOutputStream.close();
}
smbFile.delete();
createFile.delete();
} else {
Log.e("eee", "请选择文件夾");
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_print_test);
// System.setProperty("jcifs.smb.client.dfs.disabled", "true");
// System.setProperty("jcifs.smb.client.soTimeout", "1000000");
// System.setProperty("jcifs.smb.client.responseTimeout", "30000");
// 获取跟目录然后获取下面各个盘符
new Thread(//smb://192.168.1.144/KuGou/
PrintTestActivity::run).start();
}
/**
* 獲取縮進,通過文字和最大長度
*
......@@ -167,54 +219,6 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH
return stringList;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_print_test);
// EditText ed_ip = findViewById(R.id.ed_ip);
// UsbPrinterFinder printerFinder = new UsbPrinterFinder(this, printerFinderCallback);
// printerFinder.startFinder();
//
// List<OrderDetail> foodList = new ArrayList<>();
// foodList.add(new OrderDetail("牛肉拉麵", 10, 1));
// foodList.add(new OrderDetail("紅燒牛肉拉麵", 200, 2));
//
// findViewById(R.id.btn_test).setOnClickListener(view -> {
// //打印測試
// String stringBuilder = "<html><body>" +
// getPLable("GingerSoft") +
// getPLable("Gs1") +
// getPLable("開檯時間:" + TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT)) +
// getPLable(getLineChar(lineLength, "_")) +
// getPLable(getFoodListStr(foodList)) +
// "</body></html>";
// OkHttp3Utils.get("http://localhost:8080/pos?transactionType=PRINT&isExternal=false&apiVersion=21&printData=" + stringBuilder).subscribe(new Observer<String>() {
// @Override
// public void onSubscribe(Disposable d) {
//
// }
//
// @Override
// public void onNext(String s) {
// }
//
// @Override
// public void onError(Throwable e) {
//
// }
//
// @Override
// public void onComplete() {
//
// }
// });
// });
TimePickerUtils.showTimePicker(this, null, (date, v1) -> {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
});
}
public String getLineChar(int size, String str) {
StringBuilder stringBuilder = new StringBuilder();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment