Commit da8dbb14 by Wyh

.

parent 80964ac0
...@@ -3,6 +3,7 @@ package com.gingersoft.coldchain_module.mvp.presenter; ...@@ -3,6 +3,7 @@ package com.gingersoft.coldchain_module.mvp.presenter;
import android.app.Application; import android.app.Application;
import android.util.Log; import android.util.Log;
import com.billy.cc.core.component.CC;
import com.gingersoft.coldchain_module.mvp.constans.ColdChainConstants; import com.gingersoft.coldchain_module.mvp.constans.ColdChainConstants;
import com.gingersoft.coldchain_module.mvp.contract.ColdChainMainContract; import com.gingersoft.coldchain_module.mvp.contract.ColdChainMainContract;
import com.gingersoft.coldchain_module.mvp.model.bean.BalanceBean; import com.gingersoft.coldchain_module.mvp.model.bean.BalanceBean;
...@@ -13,12 +14,18 @@ import com.gingersoft.coldchain_module.mvp.model.bean.SupplementInfoBean; ...@@ -13,12 +14,18 @@ import com.gingersoft.coldchain_module.mvp.model.bean.SupplementInfoBean;
import com.gingersoft.coldchain_module.mvp.model.bean.ThirdItem; import com.gingersoft.coldchain_module.mvp.model.bean.ThirdItem;
import com.gingersoft.coldchain_module.mvp.model.bean.UpdateOrderStatusBean; import com.gingersoft.coldchain_module.mvp.model.bean.UpdateOrderStatusBean;
import com.gingersoft.coldchain_module.mvp.model.bean.UpdateRestaurantStateBean; import com.gingersoft.coldchain_module.mvp.model.bean.UpdateRestaurantStateBean;
import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager; import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils; import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails; import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.order.order.TakeawayOrder;
import com.gingersoft.gsa.cloud.print.bean.PrintContent;
import com.gingersoft.gsa.cloud.print.bean.adapter.PrintContentAdapter;
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;
...@@ -27,16 +34,13 @@ import com.jess.arms.utils.RxLifecycleUtils; ...@@ -27,16 +34,13 @@ import com.jess.arms.utils.RxLifecycleUtils;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull; import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers; 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;
...@@ -350,6 +354,29 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract. ...@@ -350,6 +354,29 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract.
}); });
} }
private void printColdChainOrder(OrderDetails.DataBean dataBean) {
if (RestaurantExpandInfoUtils.getValue(ExpandConstant.AutoPrinterPaper, true)) {
//打印凍鏈上菜紙
dataBean.setOrder_type(8);
TakeawayOrder.getInstance().getShoppingCart().setDeliveryAndPickupData(dataBean);
PrintContentAdapter contentAdapter = new PrintContentAdapter();
PrintContent printContent = contentAdapter.adaptationPrintTakeawayFormContent(dataBean);
Log.e("eee", "打印凍鏈上菜紙");
CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.addParam(PrintConstans.PRINT_TYPE, PrintConstans.PRINT_OTHER_ORDER)
.addParam(PrintConstans.PRINT_CONTENT, printContent)
.addParam(PrintConstans.PRINT_ORDER_NO, dataBean.getORDER_NO())
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread((cc, result) -> {
// if (result.isSuccess()) {
//打印成功
// }
TakeawayOrder.getInstance().getShoppingCart().setDeliveryAndPickupData(null);
});
}
}
/** /**
* 修改訂單狀態 * 修改訂單狀態
* *
...@@ -380,6 +407,8 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract. ...@@ -380,6 +407,8 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract.
@Override @Override
public void onNext(@NonNull UpdateOrderStatusBean info) { public void onNext(@NonNull UpdateOrderStatusBean info) {
mRootView.refreshOrderState(dataBean.getID()); mRootView.refreshOrderState(dataBean.getID());
//打印凍鏈上菜紙
printColdChainOrder(dataBean);
} }
}); });
} }
...@@ -411,7 +440,8 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract. ...@@ -411,7 +440,8 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract.
.add("orderDetailsIds", ids.toString()) .add("orderDetailsIds", ids.toString())
.build(); .build();
Disposable subscribe = mModel.addPrj(requestBody) Disposable subscribe = mModel.addPrj(requestBody)
.subscribeOn(Schedulers.io()).subscribe(s -> {}); .subscribeOn(Schedulers.io()).subscribe(s -> {
});
} }
} }
......
package com.gingersoft.coldchain_module.mvp.presenter; package com.gingersoft.coldchain_module.mvp.presenter;
import android.app.Application; import android.app.Application;
import android.util.Log;
import com.billy.cc.core.component.CC;
import com.gingersoft.coldchain_module.mvp.constans.ColdChainConstants; import com.gingersoft.coldchain_module.mvp.constans.ColdChainConstants;
import com.gingersoft.coldchain_module.mvp.contract.OrderDetailsContract; import com.gingersoft.coldchain_module.mvp.contract.OrderDetailsContract;
import com.gingersoft.coldchain_module.mvp.model.bean.CancelLogisticsBean; import com.gingersoft.coldchain_module.mvp.model.bean.CancelLogisticsBean;
...@@ -10,13 +12,20 @@ import com.gingersoft.coldchain_module.mvp.model.bean.ShipAnyOrdersNewBean; ...@@ -10,13 +12,20 @@ import com.gingersoft.coldchain_module.mvp.model.bean.ShipAnyOrdersNewBean;
import com.gingersoft.coldchain_module.mvp.model.bean.ThirdItem; import com.gingersoft.coldchain_module.mvp.model.bean.ThirdItem;
import com.gingersoft.coldchain_module.mvp.model.bean.UpdateOrderStatusBean; import com.gingersoft.coldchain_module.mvp.model.bean.UpdateOrderStatusBean;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails; import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager; import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.core.user.UserContext; import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.utils.FileUtils; import com.gingersoft.gsa.cloud.common.utils.FileUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil; import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.order.order.TakeawayOrder;
import com.gingersoft.gsa.cloud.print.bean.PrintContent;
import com.gingersoft.gsa.cloud.print.bean.adapter.PrintContentAdapter;
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;
...@@ -57,6 +66,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -57,6 +66,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
@Inject @Inject
AppManager mAppManager; AppManager mAppManager;
private OrderDetails.DataBean dataBean;
@Inject @Inject
public OrderDetailsPresenter(OrderDetailsContract.Model model, OrderDetailsContract.View rootView) { public OrderDetailsPresenter(OrderDetailsContract.Model model, OrderDetailsContract.View rootView) {
super(model, rootView); super(model, rootView);
...@@ -95,7 +105,8 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -95,7 +105,8 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
public void onNext(@NonNull OrderDetails info) { public void onNext(@NonNull OrderDetails info) {
if (info != null) { if (info != null) {
if (info.getData() != null && info.getData().size() > 0) { if (info.getData() != null && info.getData().size() > 0) {
mRootView.loadOrderDetails(info.getData().get(0)); dataBean = info.getData().get(0);
mRootView.loadOrderDetails(dataBean);
if (isRead == 0) { if (isRead == 0) {
setIsRead(info.getData().get(0).getID()); setIsRead(info.getData().get(0).getID());
} }
...@@ -182,7 +193,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -182,7 +193,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
if (info != null) { if (info != null) {
if (info.isSuccess()) { if (info.isSuccess()) {
//修改訂單狀態 //修改訂單狀態
updateOrderState(dataBean, ColdChainConstants.ORDER_CONFIRMED, info.getData().getLab_url()); updateOrderState(ColdChainConstants.ORDER_CONFIRMED, info.getData().getLab_url());
} else { } else {
if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) { if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg()); mRootView.showMessage(info.getErrMsg());
...@@ -206,7 +217,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -206,7 +217,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
}); });
} }
public void updateOrderState(OrderDetails.DataBean dataBean, int status, String labUrl) { public void updateOrderState(int status, String labUrl) {
//驗證訂單金額是否正確 //驗證訂單金額是否正確
if (OrderDetails.verificationAmount(dataBean)) { if (OrderDetails.verificationAmount(dataBean)) {
mRootView.showMessage(OrderDetails.getVerifiAmountTip()); mRootView.showMessage(OrderDetails.getVerifiAmountTip());
...@@ -232,6 +243,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -232,6 +243,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
if (info != null) { if (info != null) {
//添加PRJ //添加PRJ
addPrj(dataBean); addPrj(dataBean);
printColdChainOrder(RestaurantExpandInfoUtils.getValue(ExpandConstant.AutoPrinterPaper, true));
if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrorMsg())) { if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrorMsg())) {
mRootView.showMessage(info.getErrorMsg()); mRootView.showMessage(info.getErrorMsg());
} }
...@@ -287,7 +299,8 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -287,7 +299,8 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
.add("orderDetailsIds", ids.toString()) .add("orderDetailsIds", ids.toString())
.build(); .build();
Disposable subscribe = mModel.addPrj(requestBody) Disposable subscribe = mModel.addPrj(requestBody)
.subscribeOn(Schedulers.io()).subscribe(s -> {}); .subscribeOn(Schedulers.io()).subscribe(s -> {
});
} }
} }
...@@ -486,4 +499,28 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -486,4 +499,28 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
}); });
} }
public void printColdChainOrder(boolean isPrint) {
if (isPrint) {
//打印凍鏈上菜紙
dataBean.setOrder_type(8);
TakeawayOrder.getInstance().getShoppingCart().setDeliveryAndPickupData(dataBean);
PrintContentAdapter contentAdapter = new PrintContentAdapter();
PrintContent printContent = contentAdapter.adaptationPrintTakeawayFormContent(dataBean);
Log.e("eee", "打印凍鏈上菜紙");
CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.addParam(PrintConstans.PRINT_TYPE, PrintConstans.PRINT_OTHER_ORDER)
.addParam(PrintConstans.PRINT_CONTENT, printContent)
.addParam(PrintConstans.PRINT_ORDER_NO, dataBean.getORDER_NO())
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread((cc, result) -> {
// if (result.isSuccess()) {
//打印成功
// }
TakeawayOrder.getInstance().getShoppingCart().setDeliveryAndPickupData(null);
});
}
}
} }
...@@ -136,8 +136,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre ...@@ -136,8 +136,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
return R.layout.frozen_chain_main; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0 return R.layout.frozen_chain_main; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
} }
private Disposable autoOrderDisposable;
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
mPresenter.getBalance(); mPresenter.getBalance();
...@@ -153,18 +151,7 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre ...@@ -153,18 +151,7 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
initService(); initService();
initHearBroadcast(); initHearBroadcast();
autoReceivingOrders.setOnCheckedChangeListener((buttonView, isChecked) -> { autoReceivingOrders.setOnCheckedChangeListener((buttonView, isChecked) -> RestaurantExpandInfoUtils.setValue(ExpandConstant.FrozenChainAutoOrder, isChecked));
RestaurantExpandInfoUtils.setValue(ExpandConstant.FrozenChainAutoOrder, isChecked);
if (autoOrderDisposable != null && !autoOrderDisposable.isDisposed()) {
autoOrderDisposable.dispose();
}
if (isChecked) {
//開始自動接單
autoOrderDisposable = RxJavaUtils.polling(1, autoReceivingOrderInterval, aLong -> mPresenter.startToBeConfirmedOrderList(restaurantId));
} else {
mPresenter.stopAutoReceivingOrders();
}
});
autoReceivingOrders.setChecked(RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false)); autoReceivingOrders.setChecked(RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false));
} }
...@@ -249,6 +236,10 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre ...@@ -249,6 +236,10 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
|| type == 6 || type == 7) {//ColdChainConstants.orderType || type == 6 || type == 7) {//ColdChainConstants.orderType
fragments.get(viewPager.getCurrentItem()).onRefreshData(); fragments.get(viewPager.getCurrentItem()).onRefreshData();
mPresenter.getBalance(); mPresenter.getBalance();
//判斷要不要自動接單
if(autoReceivingOrders.isChecked()){
mPresenter.startToBeConfirmedOrderList(restaurantId);
}
} }
if (type == 3 || type == 6 || type == 7) { if (type == 3 || type == 6 || type == 7) {
getNumByOrderTypeInvoke("loadNumber"); getNumByOrderTypeInvoke("loadNumber");
...@@ -432,9 +423,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre ...@@ -432,9 +423,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
if (autoOrderDisposable != null) {
autoOrderDisposable.dispose();
}
if (bind != null) { if (bind != null) {
bind.setOnPostCallBack(null); bind.setOnPostCallBack(null);
} }
......
...@@ -34,6 +34,7 @@ import com.gingersoft.gsa.cloud.common.constans.FunctionManagerConstants; ...@@ -34,6 +34,7 @@ import com.gingersoft.gsa.cloud.common.constans.FunctionManagerConstants;
import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails; import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails;
import com.gingersoft.gsa.cloud.common.function.FunctionManager; import com.gingersoft.gsa.cloud.common.function.FunctionManager;
import com.gingersoft.gsa.cloud.common.ui.utils.BtnBuilder; import com.gingersoft.gsa.cloud.common.ui.utils.BtnBuilder;
import com.gingersoft.gsa.cloud.common.utils.ClipboardUtils;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil; import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
...@@ -67,6 +68,8 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im ...@@ -67,6 +68,8 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im
TextView mTvOrderStatus; TextView mTvOrderStatus;
@BindView(R2.id.tv_order_no) @BindView(R2.id.tv_order_no)
TextView mTvOrderNo; TextView mTvOrderNo;
@BindView(R2.id.tv_order_id)
TextView mTvOrderId;
@BindView(R2.id.tv_create_time) @BindView(R2.id.tv_create_time)
TextView mTvCreateTime; TextView mTvCreateTime;
@BindView(R2.id.tv_receiver) @BindView(R2.id.tv_receiver)
...@@ -222,6 +225,10 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im ...@@ -222,6 +225,10 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im
@Override @Override
public void loadOrderDetails(OrderDetails.DataBean bean) { public void loadOrderDetails(OrderDetails.DataBean bean) {
//打印訂單上菜紙
topBar.addRightImageButton(R.drawable.ic_white_print, R.id.id_topbar_print).setOnClickListener(v ->
mPresenter.printColdChainOrder(true)
);
labUrl = bean.getLabUrl(); labUrl = bean.getLabUrl();
mTvOrderFrom.setText(getResources().getString(bean.getOrder_from() == 7 ? R.string.h5_order : R.string.ricepon_order)); mTvOrderFrom.setText(getResources().getString(bean.getOrder_from() == 7 ? R.string.h5_order : R.string.ricepon_order));
if (bean.getOrderStatus() == 2) { if (bean.getOrderStatus() == 2) {
...@@ -234,7 +241,12 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im ...@@ -234,7 +241,12 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im
mTvOrderStatus.setText("待確認訂單"); mTvOrderStatus.setText("待確認訂單");
mTvOrderStatus.setTextColor(ContextCompat.getColor(mContext, R.color.order_state0_color)); mTvOrderStatus.setTextColor(ContextCompat.getColor(mContext, R.color.order_state0_color));
} }
mTvOrderNo.setText(getResources().getString(R.string.order_no) + bean.getID()); mTvOrderId.setText(String.format(getString(R.string.str_order_id), bean.getID()));
mTvOrderNo.setText(getResources().getString(R.string.order_no) + bean.getORDER_NO());
mTvOrderNo.setOnClickListener(v -> {
ClipboardUtils.copyText(bean.getORDER_NO());
showMessage("已複製到剪貼板");
});
mTvCreateTime.setText(getResources().getString(R.string.create_order_time) + TimeUtils.parseTimeRepeat(bean.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT)); mTvCreateTime.setText(getResources().getString(R.string.create_order_time) + TimeUtils.parseTimeRepeat(bean.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT));
if (TextUtil.isNotEmptyOrNullOrUndefined(bean.getRECEIVER())) { if (TextUtil.isNotEmptyOrNullOrUndefined(bean.getRECEIVER())) {
mTvReceiver.setText(bean.getRECEIVER()); mTvReceiver.setText(bean.getRECEIVER());
......
...@@ -22,6 +22,9 @@ import java.util.List; ...@@ -22,6 +22,9 @@ import java.util.List;
import static com.bin.david.form.utils.DensityUtils.dp2px; import static com.bin.david.form.utils.DensityUtils.dp2px;
/**
* @author admin
*/
public class OrderListAdapter extends BaseQuickAdapter<OrderList.DataBeanX.DataBean, BaseViewHolder> { public class OrderListAdapter extends BaseQuickAdapter<OrderList.DataBeanX.DataBean, BaseViewHolder> {
......
...@@ -72,16 +72,26 @@ ...@@ -72,16 +72,26 @@
</RelativeLayout> </RelativeLayout>
<include layout="@layout/include_horizontal_color_eee_dividing_line" /> <include layout="@layout/include_horizontal_color_eee_dividing_line" />
<!-- 訂單號-->
<!-- 訂單編號-->
<TextView <TextView
android:id="@+id/tv_order_no" android:id="@+id/tv_order_id"
style="@style/otherOrder_details_twelve_text_Style" style="@style/otherOrder_details_twelve_text_Style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/other_order_info_dialog_content_marginLeft" android:layout_margin="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10"
tools:text="訂單號:" /> tools:text="訂單號:" />
<!-- 訂單編號-->
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_order_no"
style="@style/otherOrder_details_twelve_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:drawablePadding="@dimen/dp_5"
android:drawableRight="@drawable/ic_black_copy"
tools:text="訂單編號:" />
<TextView <TextView
android:id="@+id/tv_create_time" android:id="@+id/tv_create_time"
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:background="@color/white">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/dp_14" android:paddingLeft="@dimen/dp_14"
android:paddingTop="@dimen/dp_10" android:paddingTop="@dimen/dp_10"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.scwang.smartrefresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" <com.scwang.smartrefresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cold_chain_refresh_layout" android:id="@+id/cold_chain_refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent" android:background="@color/white"
android:layout_height="match_parent"> android:layout_height="match_parent">
<FrameLayout <FrameLayout
......
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
android:id="@+id/coldchain_main_tabs" android:id="@+id/coldchain_main_tabs"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/white"
app:tabBackground="@color/white" app:tabBackground="@color/white"
app:tabTextColor="@color/color_75"
app:tabSelectedTextColor="@color/theme_333_color"
app:tabIndicatorColor="@color/theme_color" app:tabIndicatorColor="@color/theme_color"
app:tabPaddingEnd="-1dp" app:tabPaddingEnd="-1dp"
app:tabPaddingStart="-1dp" /> app:tabPaddingStart="-1dp" />
......
...@@ -181,13 +181,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -181,13 +181,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}) })
} }
private var autoPolling: Disposable? = null;
/** /**
* 開始自動確認訂單 * 開始自動確認訂單
*/ */
fun startAutoConfirmOrder() { fun startAutoConfirmOrder() {
autoPolling = RxJavaUtils.polling(10) {
launch({ launch({
//獲取即時單 //獲取即時單
repository.requestOrderList(restaurantId.toString(), fragmentStatus[1] + ",8", fragmentType[0], "1", orderNo, phone, 0).apply { repository.requestOrderList(restaurantId.toString(), fragmentStatus[1] + ",8", fragmentType[0], "1", orderNo, phone, 0).apply {
...@@ -235,9 +232,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -235,9 +232,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} else { } else {
} }
} else { } else {}
}
} }
//獲取預約單 //獲取預約單
repository.requestOrderList(restaurantId.toString(), fragmentStatus[1], fragmentType[0], "1", orderNo, phone, 1).apply { repository.requestOrderList(restaurantId.toString(), fragmentStatus[1], fragmentType[0], "1", orderNo, phone, 1).apply {
...@@ -265,12 +260,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -265,12 +260,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
LoganManager.w_delivery(LoganManager.EVENT_QUERY, "自動接單" + it.message) LoganManager.w_delivery(LoganManager.EVENT_QUERY, "自動接單" + it.message)
}) })
} }
}
fun stopAutoConfirmOrder() {
autoPolling?.dispose()
}
private fun OrderList.loadInfo(isLoadMore: Boolean, position: Int) { private fun OrderList.loadInfo(isLoadMore: Boolean, position: Int) {
getData()?.statistics?.let { getData()?.statistics?.let {
......
...@@ -112,19 +112,11 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen ...@@ -112,19 +112,11 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
initOrderType() initOrderType()
//是否自動接單 //是否自動接單
cb_takeaway_auto_receiving_orders.setOnCheckedChangeListener { _, isChecked -> cb_takeaway_auto_receiving_orders.setOnCheckedChangeListener { _, isChecked ->
if(isChecked){
pageViewModel.startAutoConfirmOrder()
} else {
pageViewModel.stopAutoConfirmOrder()
}
RestaurantExpandInfoUtils.setValue(ExpandConstant.TakeawayAutoOrder, isChecked) RestaurantExpandInfoUtils.setValue(ExpandConstant.TakeawayAutoOrder, isChecked)
} }
cb_takeaway_auto_receiving_orders.isChecked = RestaurantExpandInfoUtils.getValue<Boolean>(ExpandConstant.TakeawayAutoOrder, false) cb_takeaway_auto_receiving_orders.isChecked = RestaurantExpandInfoUtils.getValue<Boolean>(ExpandConstant.TakeawayAutoOrder, false)
pageViewModel.apply { pageViewModel.apply {
if(cb_takeaway_auto_receiving_orders.isChecked){
startAutoConfirmOrder()
}
getDeliveryInfo(restaurantId.toString(), memberId.toString()) getDeliveryInfo(restaurantId.toString(), memberId.toString())
balanceBean.observe(this@DeliveryOrderMainActivity, Observer { balanceBean.observe(this@DeliveryOrderMainActivity, Observer {
it?.data?.let { data -> it?.data?.let { data ->
...@@ -438,7 +430,6 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen ...@@ -438,7 +430,6 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
pageViewModel.stopAutoConfirmOrder()
bind?.setOnPostCallBack(null) bind?.setOnPostCallBack(null)
bind?.execute {} bind?.execute {}
cancelDialogForLoading() cancelDialogForLoading()
...@@ -466,6 +457,10 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen ...@@ -466,6 +457,10 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
} }
//刷新餘額 //刷新餘額
pageViewModel.getBanlance(RestaurantInfoManager.newInstance().getBrandId()) pageViewModel.getBanlance(RestaurantInfoManager.newInstance().getBrandId())
//選擇了自動接單
if(cb_takeaway_auto_receiving_orders.isChecked){
pageViewModel.startAutoConfirmOrder()
}
} }
}) })
it.execute { it.execute {
......
...@@ -286,7 +286,7 @@ public class BusinessReportPresenter extends BasePresenter<BusinessReportContrac ...@@ -286,7 +286,7 @@ public class BusinessReportPresenter extends BasePresenter<BusinessReportContrac
businessBeans.add(new BusinessBean(itemNames[5], String.valueOf(MoneyUtil.get_ItemDecimals_money(dataBean.getTisAmount())))); businessBeans.add(new BusinessBean(itemNames[5], String.valueOf(MoneyUtil.get_ItemDecimals_money(dataBean.getTisAmount()))));
businessBeans.add(new BusinessBean(itemNames[6], String.valueOf(MoneyUtil.get_ItemDecimals_money(dataBean.getBoxAmount())))); businessBeans.add(new BusinessBean(itemNames[6], String.valueOf(MoneyUtil.get_ItemDecimals_money(dataBean.getBoxAmount()))));
businessBeans.add(new BusinessBean(itemNames[7], String.valueOf(MoneyUtil.get_ItemDecimals_money(dataBean.getDelAmount())))); businessBeans.add(new BusinessBean(itemNames[7], String.valueOf(MoneyUtil.get_ItemDecimals_money(dataBean.getDelAmount()))));
double netProfit = MoneyUtil.sub(dataBean.getFoodAmount(), dataBean.getDisAmount(), dataBean.getSeramount(), dataBean.getRoundAmount(), dataBean.getSaleAmount(), dataBean.getTisAmount(), dataBean.getBoxAmount(), dataBean.getDelAmount()); double netProfit = MoneyUtil.sum(dataBean.getFoodAmount(), dataBean.getDisAmount(), dataBean.getSeramount(), dataBean.getRoundAmount(), dataBean.getSaleAmount(), dataBean.getTisAmount(), dataBean.getBoxAmount(), dataBean.getDelAmount());
businessBeans.add(new BusinessBean(itemNames[8], String.valueOf(MoneyUtil.get_ItemDecimals_money(netProfit)))); businessBeans.add(new BusinessBean(itemNames[8], String.valueOf(MoneyUtil.get_ItemDecimals_money(netProfit))));
} else { } else {
//為空,全部顯示0 //為空,全部顯示0
......
...@@ -6,10 +6,8 @@ import com.billy.cc.core.component.CC; ...@@ -6,10 +6,8 @@ import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult; import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil; import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent; import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.component.ComponentName; import com.gingersoft.gsa.cloud.component.ComponentName;
import com.jess.arms.utils.ArmsUtils; import com.joe.print.mvp.print.printerManger.PrjPtinterManager;
import com.joe.print.mvp.print.PrinterManger.PrjPtinterManager;
import com.joe.print.mvp.print.service.PrjService; import com.joe.print.mvp.print.service.PrjService;
import com.joe.print.mvp.ui.activity.PrintActivity; import com.joe.print.mvp.ui.activity.PrintActivity;
import com.joe.print.mvp.ui.activity.PrinterListActivity; import com.joe.print.mvp.ui.activity.PrinterListActivity;
......
...@@ -3,7 +3,7 @@ package com.joe.print.mvp.presenter; ...@@ -3,7 +3,7 @@ package com.joe.print.mvp.presenter;
import android.app.Application; import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.joe.print.mvp.print.PrinterManger.PrinterManager; import com.joe.print.mvp.print.printerManger.PrinterManager;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils; import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean; import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
......
...@@ -4,7 +4,7 @@ import android.app.Application; ...@@ -4,7 +4,7 @@ import android.app.Application;
import android.content.Context; import android.content.Context;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.joe.print.mvp.print.PrinterManger.PrinterManager; import com.joe.print.mvp.print.printerManger.PrinterManager;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils; import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
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;
......
...@@ -2,6 +2,7 @@ package com.joe.print.mvp.print; ...@@ -2,6 +2,7 @@ package com.joe.print.mvp.print;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.Looper;
import android.util.Log; import android.util.Log;
import com.epson.epos2.Epos2Exception; import com.epson.epos2.Epos2Exception;
...@@ -10,6 +11,7 @@ import com.epson.epos2.printer.PrinterStatusInfo; ...@@ -10,6 +11,7 @@ import com.epson.epos2.printer.PrinterStatusInfo;
import com.epson.epos2.printer.ReceiveListener; import com.epson.epos2.printer.ReceiveListener;
import com.gingersoft.gsa.cloud.common.logan.LoganManager; import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
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.impl.OnPrjPrintResultListener; import com.gingersoft.gsa.cloud.print.impl.OnPrjPrintResultListener;
...@@ -19,6 +21,9 @@ import com.joe.print.mvp.print.utils.MyPrintUtils; ...@@ -19,6 +21,9 @@ import com.joe.print.mvp.print.utils.MyPrintUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* @author admin
*/
public class EpsonPrint implements ReceiveListener { public class EpsonPrint implements ReceiveListener {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
...@@ -27,6 +32,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -27,6 +32,7 @@ public class EpsonPrint implements ReceiveListener {
private ReceiveListener receiveListener; private ReceiveListener receiveListener;
private OnPrjPrintResultListener onPrjPrintResultListener; private OnPrjPrintResultListener onPrjPrintResultListener;
private static final int SEND_DATA_TIMEOUT = 20 * 1000;
private static EpsonPrint epsonPrint; private static EpsonPrint epsonPrint;
public static EpsonPrint public static EpsonPrint
...@@ -278,7 +284,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -278,7 +284,7 @@ public class EpsonPrint implements ReceiveListener {
bitmaps.add(bitmap); bitmaps.add(bitmap);
prjIds.add(foodId); prjIds.add(foodId);
if (isPrint) { if (isPrint) {
Log.d("eee", "prj針式打印機隊列中,前面還有" + bitmaps.size() + "個任務"); LogUtil.d("eee", "prj針式打印機隊列中,前面還有" + bitmaps.size() + "個任務");
PrinterPlugins.getOnPrinterFlowHandler().connectionBefore("針式打印機隊列中,前面還有" + bitmaps.size() + "個任務", ip, 0, 0, 0); PrinterPlugins.getOnPrinterFlowHandler().connectionBefore("針式打印機隊列中,前面還有" + bitmaps.size() + "個任務", ip, 0, 0, 0);
return; return;
} }
...@@ -288,10 +294,9 @@ public class EpsonPrint implements ReceiveListener { ...@@ -288,10 +294,9 @@ public class EpsonPrint implements ReceiveListener {
private void printData(String ip, String ids, Bitmap bitmap) { private void printData(String ip, String ids, Bitmap bitmap) {
PrinterPlugins.getOnPrinterFlowHandler().onPrinterDataBefore(0, 0, "針式打印機", ip); PrinterPlugins.getOnPrinterFlowHandler().onPrinterDataBefore(0, 0, "針式打印機", ip);
mPrinter.clearCommandBuffer(); LogUtil.d("eee", "prj針式打印機創建數據中,任務數:" + bitmaps.size());
Log.d("eee", "prj針式打印機創建數據中,任務數:" + bitmaps.size());
if (!createPrintData(bitmap)) { if (!createPrintData(bitmap)) {
Log.d("eee", "prj針式打印機創建數據失敗"); LogUtil.d("eee", "prj針式打印機創建數據失敗");
//如果是創建數據失敗,說明這個數據有問題,移除掉 //如果是創建數據失敗,說明這個數據有問題,移除掉
printErrorProcess(ids, bitmap, new Exception("針式打印機添加數據失敗" + ip), PrintSocketHolder.ERROR_6); printErrorProcess(ids, bitmap, new Exception("針式打印機添加數據失敗" + ip), PrintSocketHolder.ERROR_6);
return; return;
...@@ -300,10 +305,10 @@ public class EpsonPrint implements ReceiveListener { ...@@ -300,10 +305,10 @@ public class EpsonPrint implements ReceiveListener {
connectByIp(ip, mPrinter.getStatus()); connectByIp(ip, mPrinter.getStatus());
//獲取打印機狀態 //獲取打印機狀態
PrinterStatusInfo statusInfo = mPrinter.getStatus(); PrinterStatusInfo statusInfo = mPrinter.getStatus();
Log.d("eee", "prj針式打印機:" + "紙張狀態:" + statusInfo.getPaper() + "連接狀態:" + statusInfo.getConnection() + ",任務數:" + bitmaps.size()); LogUtil.d("eee", "prj針式打印機:" + "紙張狀態:" + statusInfo.getPaper() + "連接狀態:" + statusInfo.getConnection() + ",任務數:" + bitmaps.size());
if (statusInfo.getConnection() != 1) { if (statusInfo.getConnection() != 1) {
//未連接到打印機 //未連接到打印機
Log.d("eee", "prj針式打印機連接失敗:" + ids); LogUtil.d("eee", "prj針式打印機連接失敗:" + ids);
printErrorProcess(ids, bitmap, new Exception("針式打印機連接失敗" + ip), PrintSocketHolder.ERROR_7); printErrorProcess(ids, bitmap, new Exception("針式打印機連接失敗" + ip), PrintSocketHolder.ERROR_7);
return; return;
} else if (statusInfo.getPaper() != 0) { } else if (statusInfo.getPaper() != 0) {
...@@ -318,11 +323,11 @@ public class EpsonPrint implements ReceiveListener { ...@@ -318,11 +323,11 @@ public class EpsonPrint implements ReceiveListener {
return; return;
} }
try { try {
mPrinter.sendData(Printer.PARAM_DEFAULT); mPrinter.sendData(SEND_DATA_TIMEOUT);
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess();
Log.d("eee", "prj針式打印機打印成功" + ",任務數:" + bitmaps.size()); LogUtil.d("eee", "prj針式打印機打印成功" + ",任務數:" + bitmaps.size());
} catch (Exception e) { } catch (Exception e) {
Log.d("eee", "prj針式打印機打印失敗" + ",任務數:" + bitmaps.size() + e.getMessage()); LogUtil.d("eee", "prj針式打印機打印失敗" + ",任務數:" + bitmaps.size() + e.getMessage());
printErrorProcess(ids, bitmap, new Exception("針式打印機打印報錯" + ip), PrintSocketHolder.ERROR_10); printErrorProcess(ids, bitmap, new Exception("針式打印機打印報錯" + ip), PrintSocketHolder.ERROR_10);
mPrinter.clearCommandBuffer(); mPrinter.clearCommandBuffer();
} }
...@@ -330,6 +335,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -330,6 +335,7 @@ public class EpsonPrint implements ReceiveListener {
/** /**
* 打印異常處理 * 打印異常處理
*
* @param ids * @param ids
* @param bitmap * @param bitmap
*/ */
...@@ -414,6 +420,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -414,6 +420,7 @@ public class EpsonPrint implements ReceiveListener {
/** /**
* 打印結果回調 * 打印結果回調
*
* @param printer 打印類 * @param printer 打印類
* @param i 打印結果 * @param i 打印結果
* @param printerStatusInfo 打印機狀態 * @param printerStatusInfo 打印機狀態
...@@ -428,6 +435,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -428,6 +435,7 @@ public class EpsonPrint implements ReceiveListener {
/** /**
* 執行下一個打印任務 * 執行下一個打印任務
*
* @param printer * @param printer
* @param i * @param i
* @param printerStatusInfo * @param printerStatusInfo
...@@ -437,7 +445,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -437,7 +445,7 @@ public class EpsonPrint implements ReceiveListener {
if (receiveListener != null) { if (receiveListener != null) {
receiveListener.onPtrReceive(printer, i, printerStatusInfo, prjIds.get(0)); receiveListener.onPtrReceive(printer, i, printerStatusInfo, prjIds.get(0));
} }
Log.d("eee", "prj移除前:onPtrReceive" + prjIds.get(0) + ",任務數:" + bitmaps.size()); LogUtil.d("eee", "prj移除前:onPtrReceive" + prjIds.get(0) + ",任務數:" + bitmaps.size());
bitmaps.remove(0); bitmaps.remove(0);
prjIds.remove(0); prjIds.remove(0);
} }
......
...@@ -43,11 +43,8 @@ public class PrintOtherOrder extends PrinterRoot<PrintTakeawayFormContent> { ...@@ -43,11 +43,8 @@ public class PrintOtherOrder extends PrinterRoot<PrintTakeawayFormContent> {
//打印完成之後,返回所有打印結果。 //打印完成之後,返回所有打印結果。
//如果需要打印印單,加上 //如果需要打印印單,加上
List<Bitmap> bitmaps = new ArrayList<>(); List<Bitmap> bitmaps = new ArrayList<>();
// Bitmap bitmap = initPrintView(mContext, dataBean);
Bitmap bitmap = getBitmap(mContext, dataBean, deviceBean); Bitmap bitmap = getBitmap(mContext, dataBean, deviceBean);
// for (int i = 0; i < getPrintCount(mContext); i++) {
bitmaps.add(bitmap); bitmaps.add(bitmap);
// }
merge2ResultMap(bitmapMaps, "", bitmaps); merge2ResultMap(bitmapMaps, "", bitmaps);
return bitmapMaps; return bitmapMaps;
} }
...@@ -96,6 +93,7 @@ public class PrintOtherOrder extends PrinterRoot<PrintTakeawayFormContent> { ...@@ -96,6 +93,7 @@ public class PrintOtherOrder extends PrinterRoot<PrintTakeawayFormContent> {
if (data.getDELIVERY_CHARGE() != 0) { if (data.getDELIVERY_CHARGE() != 0) {
billData.add(getBillBean("送貨費:", MONETARY_UNIT + data.getDELIVERY_CHARGE())); billData.add(getBillBean("送貨費:", MONETARY_UNIT + data.getDELIVERY_CHARGE()));
} }
billData.add(getBillBean("總金額:", MONETARY_UNIT + data.getTOTAL_AMOUNT()));
double totalAmount = Double.parseDouble(data.getTOTAL_AMOUNT()); double totalAmount = Double.parseDouble(data.getTOTAL_AMOUNT());
if (data.getCouponList() != null && data.getCouponList().size() > 0) { if (data.getCouponList() != null && data.getCouponList().size() > 0) {
for (OrderDetails.DataBean.CouponBean coupon : data.getCouponList()) { for (OrderDetails.DataBean.CouponBean coupon : data.getCouponList()) {
...@@ -106,8 +104,8 @@ public class PrintOtherOrder extends PrinterRoot<PrintTakeawayFormContent> { ...@@ -106,8 +104,8 @@ public class PrintOtherOrder extends PrinterRoot<PrintTakeawayFormContent> {
layout.addView(getTakeawayBillInfoView(mContext, billData)); layout.addView(getTakeawayBillInfoView(mContext, billData));
layout.addView(getLine(mContext)); layout.addView(getLine(mContext));
//總金額34sp //總金額34sp
layout.addView(getTakeawayLargeAmount(mContext, "總金額:", MONETARY_UNIT + data.getTOTAL_AMOUNT())); // layout.addView(getTakeawayLargeAmount(mContext, "總金額:", MONETARY_UNIT + data.getTOTAL_AMOUNT()));
layout.addView(getLine(mContext)); // layout.addView(getLine(mContext));
//支付信息 //支付信息
addTakeawayPayViews(mContext, layout, data.getPayMultiple(), totalAmount); addTakeawayPayViews(mContext, layout, data.getPayMultiple(), totalAmount);
//用戶信息 //用戶信息
......
...@@ -28,6 +28,7 @@ import com.epson.epos2.printer.PrinterStatusInfo; ...@@ -28,6 +28,7 @@ import com.epson.epos2.printer.PrinterStatusInfo;
import com.epson.epos2.printer.ReceiveListener; import com.epson.epos2.printer.ReceiveListener;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication; import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.constans.AppConstans; import com.gingersoft.gsa.cloud.common.constans.AppConstans;
import com.gingersoft.gsa.cloud.common.constans.DeliveryPickConstans;
import com.gingersoft.gsa.cloud.common.constans.ExpandConstant; import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans; import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails; import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails;
...@@ -470,7 +471,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -470,7 +471,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
printFailure("連接打印機失敗"); printFailure("連接打印機失敗");
break; break;
case PrintSocketHolder.ERROR_10: case PrintSocketHolder.ERROR_10:
LoganManager.w_printer(TAG, "打印機連接成功,發送數據出現問題" ); LoganManager.w_printer(TAG, "打印機連接成功,發送數據出現問題");
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("打印機連接成功,發送數據出現問題"), errorCode); PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("打印機連接成功,發送數據出現問題"), errorCode);
printFailure("打印失敗,錯誤碼:" + errorCode); printFailure("打印失敗,錯誤碼:" + errorCode);
break; break;
...@@ -572,28 +573,35 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -572,28 +573,35 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
TextView tvClosingTime = view.findViewById(R.id.tv_print_model_order_closing_time); TextView tvClosingTime = view.findViewById(R.id.tv_print_model_order_closing_time);
TextView tvRemark = view.findViewById(R.id.tv_print_model_remark); TextView tvRemark = view.findViewById(R.id.tv_print_model_remark);
//訂單類型 //訂單類型
tvOrderType.setText(data.getOrder_type() == 2 ? "外送" : "自取"); tvOrderType.setText(data.getShowTextByOrderType());
String payType = ""; // String payType = "";
tvClosingTime.setVisibility(View.GONE); tvClosingTime.setVisibility(View.GONE);
if (data.getOrderPayType() == 1) { // if (data.getOrderPayType() == 1) {
//貨到付款 // //貨到付款
payType = "貨到付款"; // payType = "貨到付款";
} else if (data.getOrderPayType() == 0) { // } else if (data.getOrderPayType() == 0) {
payType = "店內支付"; // payType = "店內支付";
} else if (data.getOrderPayType() == 2) { // } else if (data.getOrderPayType() == 2) {
if (data.getPayMultiple() != null) { // if (data.getPayMultiple() != null) {
StringBuilder payName = new StringBuilder(); // StringBuilder payName = new StringBuilder();
for (OrderDetails.DataBean.PayMultiple payMultiple : data.getPayMultiple()) { // for (OrderDetails.DataBean.PayMultiple payMultiple : data.getPayMultiple()) {
payName.append(payMultiple.getPayName()); // payName.append(payMultiple.getPayName());
payName.append(","); // payName.append(",");
} // }
if (payName.length() > 0) { // if (payName.length() > 0) {
payName.deleteCharAt(payName.length() - 1); // payName.deleteCharAt(payName.length() - 1);
} // }
payType = "在線支付:" + payName.toString(); // payType = "在線支付:" + payName.toString();
} else { // } else {
payType = "在線支付"; // payType = "在線支付";
} // }
// //支付時間,只有在線支付有
// if (!TextUtil.isEmptyOrNullOrUndefined(data.getPayTime())) {
// tvClosingTime.setText("支付時間:" + data.getPayTime());
// tvClosingTime.setVisibility(View.VISIBLE);
// }
// }
if (data.getOrderPayType() == 2) {
//支付時間,只有在線支付有 //支付時間,只有在線支付有
if (!TextUtil.isEmptyOrNullOrUndefined(data.getPayTime())) { if (!TextUtil.isEmptyOrNullOrUndefined(data.getPayTime())) {
tvClosingTime.setText("支付時間:" + data.getPayTime()); tvClosingTime.setText("支付時間:" + data.getPayTime());
...@@ -601,16 +609,22 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -601,16 +609,22 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
} }
} }
//支付類型 //支付類型
tvPayType.setText(payType); tvPayType.setText(data.getShowTextByOrderPayType());
//送達時間 //送達時間
tvDeliveryTime.setText(data.getOrder_type() == 2 ? data.getSEND_TIME() : data.getTakeTime()); tvDeliveryTime.setText(data.getOrder_type() == 2 ? data.getSEND_TIME() : data.getTakeTime());
if (TextUtil.isEmptyOrNullOrUndefined(tvDeliveryTime.getText().toString())) { if (TextUtil.isEmptyOrNullOrUndefined(tvDeliveryTime.getText().toString())) {
tvDeliveryTime.setVisibility(View.GONE); tvDeliveryTime.setVisibility(View.GONE);
} }
tvBillNumber.setText("號:" + data.getORDER_NO()); tvBillNumber.setText("號:" + data.getORDER_NO());
if (TextUtil.isEmptyOrNullOrUndefined(data.getBillNo())) { if (TextUtil.isEmptyOrNullOrUndefined(data.getBillNo())) {
if (DeliveryPickConstans.COLD_CHAIN_TYPE.equals(data.getOrder_type() + "")) {
//凍鏈
tvOrderNumber.setText("訂單號:" +data.getID());
tvOrderNumber.setVisibility(View.VISIBLE);
} else {
tvOrderNumber.setVisibility(View.GONE); tvOrderNumber.setVisibility(View.GONE);
}
} else { } else {
tvOrderNumber.setText("訂單碼:" + data.getBillNo()); tvOrderNumber.setText("訂單碼:" + data.getBillNo());
} }
......
package com.joe.print.mvp.print.PrinterManger; package com.joe.print.mvp.print.printerManger;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
......
...@@ -25,6 +25,7 @@ import com.gingersoft.gsa.cloud.common.printer.AidlUtil; ...@@ -25,6 +25,7 @@ import com.gingersoft.gsa.cloud.common.printer.AidlUtil;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils; import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils; import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.threadPool.ThreadPoolManager; import com.gingersoft.gsa.cloud.common.utils.threadPool.ThreadPoolManager;
...@@ -222,12 +223,11 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -222,12 +223,11 @@ public class PrjService extends Service implements ReceiveListener {
} }
} }
private String prjJson = "{\"success\":true,\"sysTime\":1613789540248,\"data\":{\"K1\":[{\"id\":71387,\"printerDeviceId\":186,\"status\":2,\"tableName\":\"堂食1\",\"orderNo\":\"0013\",\"orderTime\":2021,\"person\":1,\"number\":1,\"orderDetailsTime\":\"Feb 23, 2021 1:52:06 PM\",\"orderDetailsId\":372,\"productName\":\"N1. Mr.Arita華盛丼>得獎和牛使用定食\",\"productName2\":\"\",\"productName3\":\"\",\"parentId\":0,\"type\":3,\"createTime\":1614059526281,\"productId\":61256,\"requests\":1,\"actualPrinterDeviceId\":186,\"orderType\":1,\"isFirstSendOrder\":1,\"quantity\":21,\"memberName\":\"96761128\"}]}}"; private String prjJson = "{\"success\":true,\"sysTime\":1614581072400,\"data\":{\"K3\":[{\"id\":44419,\"printerDeviceId\":149,\"status\":2,\"orderNo\":\"233212281076117397\",\"orderTime\":2021,\"sender\":\"\",\"sendTime\":\"盡快送達 預計 15:49-16:04\",\"person\":0,\"number\":1,\"orderDetailsTime\":\"Mar 1, 2021 2:43:38 PM\",\"orderDetailsId\":12895,\"productName\":\"鬥獸場大什扒\",\"productName2\":\"\",\"productName3\":\"\",\"parentId\":0,\"type\":3,\"createTime\":1614581044514,\"productId\":27921,\"requests\":1,\"actualPrinterDeviceId\":149,\"flyPrinterDeviceId\":150,\"takeFoodCode\":\"1074\",\"billNo\":\"\",\"orderType\":2,\"userName\":\"wyh\",\"isFirstSendOrder\":1,\"quantity\":49,\"memberName\":\"\"}],\"K4\":[{\"id\":44420,\"printerDeviceId\":150,\"status\":2,\"orderNo\":\"233212281076117397\",\"orderTime\":2021,\"sender\":\"\",\"sendTime\":\"盡快送達 預計 15:49-16:04\",\"person\":0,\"number\":1,\"orderDetailsTime\":\"Mar 1, 2021 2:43:38 PM\",\"orderDetailsId\":12896,\"productName\":\"芝士焗龍蝦\",\"productName2\":\"\",\"productName3\":\"\",\"parentId\":0,\"type\":3,\"createTime\":1614581044521,\"productId\":27926,\"requests\":1,\"actualPrinterDeviceId\":150,\"takeFoodCode\":\"1074\",\"billNo\":\"\",\"orderType\":2,\"userName\":\"wyh\",\"isFirstSendOrder\":1,\"quantity\":50,\"memberName\":\"\"}]}}\n";
private void newPrint(String json) { private void newPrint(String json) {
Map<String, List<PrjBean>> listMap = new HashMap<>(); Map<String, List<PrjBean>> listMap = new HashMap<>();
int totalPrj = 0; int totalPrj = 0;
BaseResult prjBean = JsonUtils.parseObject(json, BaseResult.class); BaseResult prjBean = JsonUtils.parseObject(json, BaseResult.class);
if (prjBean == null || prjBean.getData() == null) { if (prjBean == null || prjBean.getData() == null) {
LoganManager.w_printer(TAG, "newPrint prjBean == null || prjBean.getData() == null "); LoganManager.w_printer(TAG, "newPrint prjBean == null || prjBean.getData() == null ");
...@@ -393,6 +393,9 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -393,6 +393,9 @@ public class PrjService extends Service implements ReceiveListener {
int orderType = 1; int orderType = 1;
if (beans != null && beans.size() > 0) { if (beans != null && beans.size() > 0) {
orderType = beans.get(0).getOrderType(); orderType = beans.get(0).getOrderType();
} else {
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("prj解析數據為空:" + GsonUtils.GsonString(beans)), UpdateBean.FAIL_PRINT_BY_NOT_PRINT_INFO);
return;
} }
PrinterPlugins.getOnPrinterFlowHandler().onPrinterDataBefore(orderType, PrintConstans.PRINT_KITCHEN, GsonUtils.GsonString(beans), GsonUtils.GsonString(printerDeviceBean)); PrinterPlugins.getOnPrinterFlowHandler().onPrinterDataBefore(orderType, PrintConstans.PRINT_KITCHEN, GsonUtils.GsonString(beans), GsonUtils.GsonString(printerDeviceBean));
...@@ -539,17 +542,16 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -539,17 +542,16 @@ public class PrjService extends Service implements ReceiveListener {
List<Map<String, Bitmap>> bitmapMaps = generatePrintMaps(key, beans, printerDeviceBean); List<Map<String, Bitmap>> bitmapMaps = generatePrintMaps(key, beans, printerDeviceBean);
//將打印的圖片保存到手機中 //將打印的圖片保存到手機中
hookPrinterBitmap(bitmapMaps, beans); hookPrinterBitmap(bitmapMaps, beans);
boolean initResult = EpsonPrint.getInstance().initializeObject(this, this, this::updatePrjState); boolean initResult = EpsonPrint.getInstance().initializeObject(this, this, this::updatePrjState);
if (!initResult) { if (!initResult) {
//初始化打印機失敗 //初始化打印機失敗
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new ConnectException("初始化針式打印機失敗")); PrinterPlugins.getOnPrinterFlowHandler().connectionError(new ConnectException("初始化針式打印機失敗"));
Log.e("eee", "prj初始化打印失敗" + getPrintIds(bitmapMaps)); LogUtil.e("eee", "prj初始化打印失敗" + getPrintIds(bitmapMaps));
updatePrjState(UpdateBean.FAIL_EPSON_INIT, getPrintIds(bitmapMaps)); updatePrjState(UpdateBean.FAIL_EPSON_INIT, getPrintIds(bitmapMaps));
return; return;
} }
PrinterPlugins.getOnPrinterFlowHandler().connectionBefore("針式打印機" + bitmapMaps.size(), printerDeviceBean.getIp(), printerDeviceBean.getPort(), 0, 0); PrinterPlugins.getOnPrinterFlowHandler().connectionBefore("針式打印機" + bitmapMaps.size(), printerDeviceBean.getIp(), printerDeviceBean.getPort(), 0, 0);
Log.d("eee", "針式打印機本次PRJ數量:" + bitmapMaps.size()); LogUtil.d("eee", "針式打印機本次PRJ數量:" + bitmapMaps.size());
for (int i = 0; i < bitmapMaps.size(); i++) { for (int i = 0; i < bitmapMaps.size(); i++) {
for (Map.Entry<String, Bitmap> mapEntry : bitmapMaps.get(i).entrySet()) { for (Map.Entry<String, Bitmap> mapEntry : bitmapMaps.get(i).entrySet()) {
EpsonPrint.getInstance().putPrintData(printerDeviceBean.getIp(), mapEntry.getValue(), mapEntry.getKey()); EpsonPrint.getInstance().putPrintData(printerDeviceBean.getIp(), mapEntry.getValue(), mapEntry.getKey());
...@@ -1108,7 +1110,7 @@ public class PrjService extends Service implements ReceiveListener { ...@@ -1108,7 +1110,7 @@ public class PrjService extends Service implements ReceiveListener {
@Override @Override
public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String
s) { s) {
Log.e("eee", "prj針式打印結果" + i); LogUtil.e("eee", "prj針式打印結果" + i);
//針式打印回調 //針式打印回調
if (i == 0) { if (i == 0) {
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess(); PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess();
......
package com.joe.print.mvp.ui.activity; package com.joe.print.mvp.ui.activity;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
...@@ -27,19 +25,17 @@ import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; ...@@ -27,19 +25,17 @@ import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean; import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.FoodModifierDaoUtils;
import com.gingersoft.gsa.cloud.print.PrintExecutor; import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder; import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.gingersoft.gsa.cloud.print.bean.PrintContent; import com.gingersoft.gsa.cloud.print.bean.PrintContent;
import com.gingersoft.gsa.cloud.print.bean.PrjBean; import com.gingersoft.gsa.cloud.print.bean.PrjBean;
import com.gingersoft.gsa.cloud.print.bean.UpdateBean;
import com.jess.arms.base.BaseActivity; import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.integration.AppManager;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.joe.print.di.component.DaggerPrintComponent; import com.joe.print.di.component.DaggerPrintComponent;
import com.joe.print.mvp.contract.PrintContract; import com.joe.print.mvp.contract.PrintContract;
import com.joe.print.mvp.presenter.PrintPresenter; import com.joe.print.mvp.presenter.PrintPresenter;
import com.joe.print.mvp.print.EpsonPrint;
import com.joe.print.mvp.print.PrintInstruction; import com.joe.print.mvp.print.PrintInstruction;
import com.joe.print.mvp.print.PrintListener; import com.joe.print.mvp.print.PrintListener;
import com.joe.print.mvp.print.PrintPrjKitchen; import com.joe.print.mvp.print.PrintPrjKitchen;
...@@ -49,19 +45,11 @@ import com.joe.print.mvp.print.utils.MyPrintUtils; ...@@ -49,19 +45,11 @@ import com.joe.print.mvp.print.utils.MyPrintUtils;
import com.joe.print.mvp.ui.view.PrinterLoadingDialog; import com.joe.print.mvp.ui.view.PrinterLoadingDialog;
import com.joe.print.mvp.ui.view.SelectPrintDevicePopup; import com.joe.print.mvp.ui.view.SelectPrintDevicePopup;
import com.lxj.xpopup.XPopup; import com.lxj.xpopup.XPopup;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxUITask;
import java.net.ConnectException; import java.net.ConnectException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.inject.Inject;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_BILL; import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_BILL;
import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_OTHER_CLOSING; import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_OTHER_CLOSING;
import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_OTHER_ORDER; import static com.gingersoft.gsa.cloud.common.constans.PrintConstans.PRINT_OTHER_ORDER;
...@@ -138,15 +126,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -138,15 +126,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
// loadingPopup = new XPopup.Builder(mContext)
// .popupAnimation(PopupAnimation.ScaleAlphaFromCenter)
// .asLoading("加载中...");
// loadingPopup.show();
actionPrinter(); actionPrinter();
PrinterPlugins.setOnPrinterFlowHandler(new PrinterFlowListener() { PrinterPlugins.setOnPrinterFlowHandler(new PrinterFlowListener() {
@Override @Override
public void connectionBefore(String deviceName, String IP, int port, long ioTimeout, long printTimeout) { public void connectionBefore(String deviceName, String IP, int port, long ioTimeout, long printTimeout) {
...@@ -154,13 +135,13 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -154,13 +135,13 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override @Override
public void connectionSuccess() { public void connectionSuccess() {
printerLoadingDialog.setStep(2, PrinterLoadingDialog.status_success, null); printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_PRINTING, PrinterLoadingDialog.STATUS_SUCCESS, null);
} }
@Override @Override
public void connectionError(Exception e) { public void connectionError(Exception e) {
printerResult = false; printerResult = false;
printerLoadingDialog.setStep(2, PrinterLoadingDialog.status_error, e.getMessage()); printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_PRINTING, PrinterLoadingDialog.STATUS_ERROR, e.getMessage());
} }
@Override @Override
...@@ -169,24 +150,24 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -169,24 +150,24 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override @Override
public void onPrinterDataBefore(int orderType, int printType, String printerData, String printerDeviceInfo) { public void onPrinterDataBefore(int orderType, int printType, String printerData, String printerDeviceInfo) {
printerLoadingDialog.setStep(1, PrinterLoadingDialog.status_success, null); printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_CONNECTING, PrinterLoadingDialog.STATUS_SUCCESS, null);
} }
@Override @Override
public void onPrinterBitmapBefore(int orderType, int printType, String directoryName, List<Bitmap> bitmaps) { public void onPrinterBitmapBefore(int orderType, int printType, String directoryName, List<Bitmap> bitmaps) {
printerLoadingDialog.setStep(1, PrinterLoadingDialog.status_success, null); printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_CONNECTING, PrinterLoadingDialog.STATUS_SUCCESS, null);
} }
@Override @Override
public void onPrintSuccess() { public void onPrintSuccess() {
printerResult = true; printerResult = true;
printerLoadingDialog.setStep(3, PrinterLoadingDialog.status_success, null); printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_RESULT, PrinterLoadingDialog.STATUS_SUCCESS, null);
} }
@Override @Override
public void onPrintError(Exception e, int errorCode) { public void onPrintError(Exception e, int errorCode) {
printerResult = false; printerResult = false;
printerLoadingDialog.setStep(3, PrinterLoadingDialog.status_error, e.getMessage()); printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_RESULT, PrinterLoadingDialog.STATUS_ERROR, e.getMessage());
} }
}); });
} }
...@@ -223,16 +204,13 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -223,16 +204,13 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
} else { } else {
printerLoadingDialog = new PrinterLoadingDialog(mContext).build(); printerLoadingDialog = new PrinterLoadingDialog(mContext).build();
} }
printerLoadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { printerLoadingDialog.setOnCancelListener(dialog -> {
@Override
public void onCancel(DialogInterface dialog) {
finish(); finish();
if (printerResult) { if (printerResult) {
CC.sendCCResult(callId, CCResult.success()); CC.sendCCResult(callId, CCResult.success());
} else { } else {
CC.sendCCResult(callId, CCResult.error("print error")); CC.sendCCResult(callId, CCResult.error("print error"));
} }
}
}); });
printerLoadingDialog.show(); printerLoadingDialog.show();
} }
...@@ -281,7 +259,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -281,7 +259,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
//如果彈窗已經關閉,打印機還是為空,說明用戶沒有選擇打印機 //如果彈窗已經關閉,打印機還是為空,說明用戶沒有選擇打印機
if (this.defaultPrint == null) { if (this.defaultPrint == null) {
printFailure("沒有找到打印機,無法打印"); printFailure("沒有找到打印機,無法打印");
killMyself(); PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception("沒有找到打印機,無法打印"), UpdateBean.FAIL_PRINT_BY_NOT_FIND_DEVICE);
} }
}); });
new XPopup.Builder(mContext).asCustom(selectPrintDevicePopup).show(); new XPopup.Builder(mContext).asCustom(selectPrintDevicePopup).show();
...@@ -375,7 +353,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -375,7 +353,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
} }
} else { } else {
//獲取打印圖片 //獲取打印圖片
listMap = printerInIt.getPrintBitmapByCount(mContext, defaultPrint); listMap = printerInIt.getPrintBitmapByCount(mContext, defaultPrint);
if (listMap != null) { if (listMap != null) {
zoomBitmaps = listMap.get(""); zoomBitmaps = listMap.get("");
......
...@@ -25,7 +25,7 @@ import com.joe.print.di.component.DaggerIpPrintListActivityComponent; ...@@ -25,7 +25,7 @@ import com.joe.print.di.component.DaggerIpPrintListActivityComponent;
import com.joe.print.di.module.IpPrintListActivityModule; import com.joe.print.di.module.IpPrintListActivityModule;
import com.joe.print.mvp.contract.IpPrintListActivityContract; import com.joe.print.mvp.contract.IpPrintListActivityContract;
import com.joe.print.mvp.presenter.IpPrintListActivityPresenter; import com.joe.print.mvp.presenter.IpPrintListActivityPresenter;
import com.joe.print.mvp.print.PrinterManger.PrinterManager; import com.joe.print.mvp.print.printerManger.PrinterManager;
import com.joe.print.mvp.ui.activity.PrinterAddActivity; import com.joe.print.mvp.ui.activity.PrinterAddActivity;
import com.joe.print.mvp.ui.adapter.PrinterListAdapter; import com.joe.print.mvp.ui.adapter.PrinterListAdapter;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton; import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.layout.QMUILinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <com.qmuiteam.qmui.layout.QMUILinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll_container" android:id="@+id/ll_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center"
android:background="@color/theme_white_color" android:background="@color/theme_white_color"
android:gravity="center"
android:orientation="vertical"> android:orientation="vertical">
<com.airbnb.lottie.LottieAnimationView <com.airbnb.lottie.LottieAnimationView
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10"
android:textColor="@color/red" android:textColor="@color/red"
android:textSize="@dimen/font_small" android:textSize="@dimen/font_small"
android:text="連接打印機超時"/> tools:text="連接打印機超時" />
</com.qmuiteam.qmui.layout.QMUILinearLayout> </com.qmuiteam.qmui.layout.QMUILinearLayout>
\ No newline at end of file
...@@ -202,7 +202,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -202,7 +202,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE)); infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "基本信息")); infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "基本信息"));
infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "所屬供應商", true, "請輸入/選擇供應商", SELECT_SUPPLIER_RESULTCODE, true, new InputFilter[]{InputFilterUtils.getLengthFilter(context, 16), InputFilterUtils.getChAndEnAndNumInputFilter(context)}, SupplierListFragment.class)); infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "所屬供應商", true, "請輸入/選擇供應商", SELECT_SUPPLIER_RESULTCODE, true, new InputFilter[]{InputFilterUtils.getLengthFilter(context, 16), InputFilterUtils.getChAndEnAndNumInputFilter(context)}, SupplierListFragment.class));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材名稱", true, "請輸入名稱", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 16), InputFilterUtils.getChAndEnAndNumInputFilter(context)})); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材名稱", true, "請輸入名稱", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 100), InputFilterUtils.getChAndEnAndNumAndPtInputFilter(context)}));
infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "食材類別", true, "請選擇食材類別", SELECT_FOOD_CATEGORY_REQUEST_CODE, CategorySelectFragment.class)); infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "食材類別", true, "請選擇食材類別", SELECT_FOOD_CATEGORY_REQUEST_CODE, CategorySelectFragment.class));
infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "基本單位", true, "請選擇食材單位", SELECT_PACKAGE_SPECIFICATION_REQUEST_CODE, FoodUnitPageFragment.class)); infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "基本單位", true, "請選擇食材單位", SELECT_PACKAGE_SPECIFICATION_REQUEST_CODE, FoodUnitPageFragment.class));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "包裝說明", false, "請輸入包裝說明", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 10), InputFilterUtils.getTypeFilter(context, InputFilterUtils.chAndEnAndNumAndSlash)})); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "包裝說明", false, "請輸入包裝說明", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 10), InputFilterUtils.getTypeFilter(context, InputFilterUtils.chAndEnAndNumAndSlash)}));
......
...@@ -134,7 +134,7 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode ...@@ -134,7 +134,7 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE)); infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "基本信息")); infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "基本信息"));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "供應商編號", false, "請輸入編號", new InputFilter[]{new InputFilter.LengthFilter(11), new EnAndNumInputFilter()})); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "供應商編號", false, "請輸入編號", new InputFilter[]{new InputFilter.LengthFilter(11), new EnAndNumInputFilter()}));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "名稱", true, "請輸入名稱", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)}, mSupplierNameChangeListener)); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "名稱", true, "請輸入名稱", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 100), InputFilterUtils.getChAndEnAndNumAndPtInputFilter(mContext)}, mSupplierNameChangeListener));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人", true, "請輸入聯繫人", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)})); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人", true, "請輸入聯繫人", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)}));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "詳細地址", true, "請輸入詳細地址", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)})); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "詳細地址", true, "請輸入詳細地址", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)}));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人電話", true, "請輸入聯繫人電話", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 11)}, EditorInfo.TYPE_CLASS_PHONE)); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人電話", true, "請輸入聯繫人電話", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 11)}, EditorInfo.TYPE_CLASS_PHONE));
......
...@@ -165,7 +165,7 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr ...@@ -165,7 +165,7 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
basicUnitAdapter.setOnItemClickListener((adapter, view, position) -> { basicUnitAdapter.setOnItemClickListener((adapter, view, position) -> {
if (position == basicUnitAdapter.getItemCount() - 1) { if (position == basicUnitAdapter.getItemCount() - 1) {
//新增 //新增
EditTextPopup popup = new EditTextPopup(requireContext(), new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 4), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)}); EditTextPopup popup = new EditTextPopup(requireContext(), new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 5), InputFilterUtils.getEnAndChInputFilter(mContext)});
popup.setListener(text -> { popup.setListener(text -> {
if (TextUtil.isNotEmptyOrNullOrUndefined(text)) { if (TextUtil.isNotEmptyOrNullOrUndefined(text)) {
mPresenter.addBasicUnit(text, basicUnitAdapter.getData()); mPresenter.addBasicUnit(text, basicUnitAdapter.getData());
......
...@@ -28,7 +28,7 @@ public class CategoryPopup extends ConfirmPopupView { ...@@ -28,7 +28,7 @@ public class CategoryPopup extends ConfirmPopupView {
private EditText et_input; private EditText et_input;
private OnClickListener onDeleteListener; private OnClickListener onDeleteListener;
private String inputText; private String inputText;
private final int nameMaxLength = 4; private final int nameMaxLength = 100;
public CategoryPopup(@NonNull Context context, CharSequence title, CharSequence content, CharSequence hint, String inputText, boolean showDelete) { public CategoryPopup(@NonNull Context context, CharSequence title, CharSequence content, CharSequence hint, String inputText, boolean showDelete) {
super(context, R.layout.dialog_new_category); super(context, R.layout.dialog_new_category);
...@@ -45,15 +45,15 @@ public class CategoryPopup extends ConfirmPopupView { ...@@ -45,15 +45,15 @@ public class CategoryPopup extends ConfirmPopupView {
tvDelete.setVisibility(showDelete ? View.VISIBLE : GONE); tvDelete.setVisibility(showDelete ? View.VISIBLE : GONE);
tvDelete.setOnClickListener(onDeleteListener); tvDelete.setOnClickListener(onDeleteListener);
et_input = findViewById(R.id.et_input); et_input = findViewById(R.id.et_input);
if (TextUtil.isNotEmptyOrNullOrUndefined(inputText)) { // if (TextUtil.isNotEmptyOrNullOrUndefined(inputText)) {
if (inputText.length() > nameMaxLength) { // if (inputText.length() > nameMaxLength) {
et_input.setText(inputText.substring(0, 4)); // et_input.setText(inputText.substring(0, 4));
} else { // } else {
et_input.setText(inputText); // et_input.setText(inputText);
} // }
et_input.setSelection(et_input.length()); // et_input.setSelection(et_input.length());
} // }
et_input.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(getContext(), 4), InputFilterUtils.getChAndEnAndNumInputFilter(getContext())}); et_input.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(getContext(), 100), InputFilterUtils.getChAndEnAndNumAndPtInputFilter(getContext())});
} }
public EditText getEditText() { public EditText getEditText() {
......
...@@ -55,6 +55,7 @@ import com.jess.arms.di.component.AppComponent; ...@@ -55,6 +55,7 @@ import com.jess.arms.di.component.AppComponent;
import com.jess.arms.integration.AppManager; import com.jess.arms.integration.AppManager;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton; import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter; import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter;
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;
...@@ -114,7 +115,9 @@ public class OrderContentActivity extends BaseFragmentActivity<OrderContentPrese ...@@ -114,7 +115,9 @@ public class OrderContentActivity extends BaseFragmentActivity<OrderContentPrese
@BindView(R2.id.tv_time) @BindView(R2.id.tv_time)
TextView tv_time; TextView tv_time;
@BindView(R2.id.btn_people_num) @BindView(R2.id.btn_people_num)
QMUIAlphaButton btn_people_num; QMUIAlphaTextView btn_people_num;
@BindView(R2.id.tv_order_no)
TextView tvOrderNo;
@BindView(R2.id.rv_top_function) @BindView(R2.id.rv_top_function)
RecyclerView rv_top_function; RecyclerView rv_top_function;
@BindView(R2.id.rv_food) @BindView(R2.id.rv_food)
...@@ -221,9 +224,10 @@ public class OrderContentActivity extends BaseFragmentActivity<OrderContentPrese ...@@ -221,9 +224,10 @@ public class OrderContentActivity extends BaseFragmentActivity<OrderContentPrese
private void initTopInfo() { private void initTopInfo() {
if (BaseOrder.isCurrentOrderType(FoodSummaryConstans.TAKEAWAY_TYPE)) { if (BaseOrder.isCurrentOrderType(FoodSummaryConstans.TAKEAWAY_TYPE)) {
btn_table.setText("外賣"); btn_table.setText("外賣");
btn_people_num.setText("1"); btn_people_num.setText(String.format(getString(R.string.meal_numberman_colon), 1));
tv_time.setText("時間:" + TimeUtils.getCurrentDate(TimeUtils.DATE_FORMAT_DATE_HM)); tv_time.setText("時間:" + TimeUtils.getCurrentDate(TimeUtils.DATE_FORMAT_DATE_HM));
tv_server_main.setText(""); tv_server_main.setText("");
tvOrderNo.setVisibility(View.GONE);
} else { } else {
TableBean.DataBean tableInfo = mDoshokuOrder.getOpenTableInfo(); TableBean.DataBean tableInfo = mDoshokuOrder.getOpenTableInfo();
Date dd = mDoshokuOrder.getOpenTableTime(); Date dd = mDoshokuOrder.getOpenTableTime();
...@@ -235,7 +239,8 @@ public class OrderContentActivity extends BaseFragmentActivity<OrderContentPrese ...@@ -235,7 +239,8 @@ public class OrderContentActivity extends BaseFragmentActivity<OrderContentPrese
tableno = tableInfo.getTableName(); tableno = tableInfo.getTableName();
} }
btn_table.setText(tableno); btn_table.setText(tableno);
btn_people_num.setText(tableInfo.getPerson() + ""); tvOrderNo.setText(String.format(getString(R.string.meal_order_number), DoshokuOrder.getInstance().getOrderNo()));
btn_people_num.setText(String.format(getString(R.string.meal_numberman_colon), tableInfo.getPerson()));
tv_time.setText("時間:" + openTime); tv_time.setText("時間:" + openTime);
tv_server_main.setText(UserContext.newInstance().getMemberName()); tv_server_main.setText(UserContext.newInstance().getMemberName());
} }
...@@ -317,11 +322,12 @@ public class OrderContentActivity extends BaseFragmentActivity<OrderContentPrese ...@@ -317,11 +322,12 @@ public class OrderContentActivity extends BaseFragmentActivity<OrderContentPrese
@Override @Override
public void showLoading(String message) { public void showLoading(String message) {
if (message != null) if (message != null) {
LoadingDialog.showDialogForLoading(this, message, true); LoadingDialog.showDialogForLoading(this, message, true);
else } else {
LoadingDialog.showDialogForLoading(this); LoadingDialog.showDialogForLoading(this);
} }
}
@Override @Override
public void hideLoading() { public void hideLoading() {
......
...@@ -88,4 +88,6 @@ ...@@ -88,4 +88,6 @@
<string name="mealheight">菜單高度</string> <string name="mealheight">菜單高度</string>
<string name="datadown">數據下載</string> <string name="datadown">數據下載</string>
<string name="meal_numberman_colon">人數:%1$d</string>
<string name="meal_order_number">單號:%1$s</string>
</resources> </resources>
...@@ -7,8 +7,8 @@ ext { ...@@ -7,8 +7,8 @@ ext {
targetSdkVersion : 29, targetSdkVersion : 29,
//正式版: 1.0.3 3 //正式版: 1.0.3 3
//內部測試版:1.2.0 20 //內部測試版:1.2.0 20
versionCode : 25, versionCode : 26,
versionName : "1.2.5" versionName : "1.2.6"
] ]
version = [ version = [
...@@ -27,7 +27,7 @@ ext { ...@@ -27,7 +27,7 @@ ext {
buildType = [ buildType = [
debugLogDebug : "true", debugLogDebug : "true",
debugUseCanary : "true", debugUseCanary : "true",
releaseLogDebug : "true", releaseLogDebug : "false",
releaseUseCanary: "false" releaseUseCanary: "false"
] ]
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html # http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
...@@ -46,3 +45,10 @@ DOKIT_METHOD_STRATEGY=0 ...@@ -46,3 +45,10 @@ DOKIT_METHOD_STRATEGY=0
kapt.use.worker.api=true kapt.use.worker.api=true
#避免执行注解处理。 #避免执行注解处理。
kapt.include.compile.classpath=false kapt.include.compile.classpath=false
#org.gradle.jvmargs=-Xmx1536m
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
\ No newline at end of file
...@@ -43,7 +43,7 @@ public class HttpsConstans { ...@@ -43,7 +43,7 @@ public class HttpsConstans {
public static String RESTAURANT_API_PATH = "/ricepon-restaurant/api/";//餐廳模塊路徑 public static String RESTAURANT_API_PATH = "/ricepon-restaurant/api/";//餐廳模塊路徑
public static String PURCHASE_API_PATH = "/ricepon-purchase/api/";//供應鏈路徑 public static String PURCHASE_API_PATH = "/ricepon-purchase/api/";//供應鏈路徑
public static String ROOT_SERVER_YOU_CHANG_HK = "http://192.168.1.142:9015/api"; //友常本地 public static String ROOT_SERVER_YOU_CHANG_HK = "http://192.168.1.149:9015/api"; //友常本地
public static String ROOT_SERVER_ZHI_WANG_HK = "http://192.168.1.169:9012/api"; //世維本地 public static String ROOT_SERVER_ZHI_WANG_HK = "http://192.168.1.169:9012/api"; //世維本地
public static String ROOT_SERVER_SHI_SHU_HK = "http://192.168.1.154:9012/api"; //石书本地 public static String ROOT_SERVER_SHI_SHU_HK = "http://192.168.1.154:9012/api"; //石书本地
...@@ -97,8 +97,8 @@ public class HttpsConstans { ...@@ -97,8 +97,8 @@ public class HttpsConstans {
* 修改這個值控制是否是正式 * 修改這個值控制是否是正式
* 0=正式 * 0=正式
* 1=香港 * 1=香港
* 2=友常 * 2=預發佈
* 3=世维 * 3=友常
* 4=石书 * 4=石书
*/ */
public static int isFormal = 0; public static int isFormal = 0;
......
package com.gingersoft.gsa.cloud.common.core.delivery package com.gingersoft.gsa.cloud.common.core.delivery
import android.util.Log import android.util.Log
import android.view.View
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil import com.gingersoft.gsa.cloud.common.utils.MoneyUtil
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil
import java.io.Serializable import java.io.Serializable
import kotlin.math.abs import kotlin.math.abs
...@@ -110,6 +112,37 @@ class OrderDetails { ...@@ -110,6 +112,37 @@ class OrderDetails {
var companyType: Int = -1 //物流公司類型 0 本店配送 1:zeek;2:lalamove var companyType: Int = -1 //物流公司類型 0 本店配送 1:zeek;2:lalamove
var labUrl: String? = null //打印文檔鏈接 var labUrl: String? = null //打印文檔鏈接
fun getShowTextByOrderType(): String {
return when (order_type) {
2 -> "外送"
8 -> "凍鏈"
else -> "自取"
}
}
fun getShowTextByOrderPayType(): String {
return when (orderPayType) {
1 -> "貨到付款"
0 -> "店內支付"
2 -> ({
if (payMultiple != null) {
val payName = StringBuilder()
for (payMultiple in payMultiple!!) {
payName.append(payMultiple.payName)
payName.append(",")
}
if (payName.isNotEmpty()) {
payName.deleteCharAt(payName.length - 1)
}
"在線支付:$payName"
} else {
"在線支付"
}
}).toString()
else -> ""
}
}
class PRODUCTNAMEBean : Serializable { class PRODUCTNAMEBean : Serializable {
/** /**
* odsId : 1654481 * odsId : 1654481
...@@ -196,10 +229,12 @@ class OrderDetails { ...@@ -196,10 +229,12 @@ class OrderDetails {
* 店內支付 * 店內支付
*/ */
const val inStorePay: Int = 0 const val inStorePay: Int = 0
/** /**
* 貨到付款 * 貨到付款
*/ */
const val payOnDelivery: Int = 1 const val payOnDelivery: Int = 1
/** /**
* 在線支付 * 在線支付
*/ */
...@@ -217,10 +252,11 @@ class OrderDetails { ...@@ -217,10 +252,11 @@ class OrderDetails {
* 第三方配送 * 第三方配送
*/ */
const val thirdPartyDistribution: Int = 0 const val thirdPartyDistribution: Int = 0
/** /**
* 本店配送 * 本店配送
*/ */
const val ourStoreDelivery:Int = 1 const val ourStoreDelivery: Int = 1
//配送方式 //配送方式
......
...@@ -31,10 +31,10 @@ public class RestaurantInfoManager { ...@@ -31,10 +31,10 @@ public class RestaurantInfoManager {
if (restaurantInfo == null) { if (restaurantInfo == null) {
restaurantInfo = new RestaurantInfo(); restaurantInfo = new RestaurantInfo();
} }
brandInfo.setBrandId((Integer) SPUtils.get(UserConstans.brandId, 0)); brandInfo.setBrandId((Integer) SPUtils.get(UserConstans.brandId, 1));
brandInfo.setBrandName((String) SPUtils.get(UserConstans.brandName, "")); brandInfo.setBrandName((String) SPUtils.get(UserConstans.brandName, ""));
restaurantInfo.setGsPosShopId((String) SPUtils.get(UserConstans.gsPosShopId, "-1")); restaurantInfo.setGsPosShopId((String) SPUtils.get(UserConstans.gsPosShopId, "-1"));
restaurantInfo.setRestaurantId((Integer) SPUtils.get(UserConstans.restaurantId, 0)); restaurantInfo.setRestaurantId((Integer) SPUtils.get(UserConstans.restaurantId, 26));
restaurantInfo.setRestaurantName((String) SPUtils.get(UserConstans.restaurantName, "")); restaurantInfo.setRestaurantName((String) SPUtils.get(UserConstans.restaurantName, ""));
} }
......
...@@ -200,7 +200,21 @@ public class MoneyUtil { ...@@ -200,7 +200,21 @@ public class MoneyUtil {
BigDecimal b2 = BigDecimal.valueOf(price2); BigDecimal b2 = BigDecimal.valueOf(price2);
return price.add(b2); return price.add(b2);
} }
/**
* 計算差
*
* @param v1
* @param v2
* @return
*/
public static double sum(double v1, double... v2) {
BigDecimal b1 = BigDecimal.valueOf(v1);
for (int i = 0; i < v2.length; i++) {
BigDecimal b2 = BigDecimal.valueOf(v2[i]);
b1 = b1.add(b2);
}
return b1.doubleValue();
}
/** /**
* 計算差 * 計算差
* *
......
...@@ -21,6 +21,10 @@ public class InputFilterUtils { ...@@ -21,6 +21,10 @@ public class InputFilterUtils {
/** /**
* 只能輸入中英文和數字 * 只能輸入中英文和數字
*/ */
public static final Pattern chAndEn = Pattern.compile("[a-zA-Z\u4E00-\u9FA5]+");
/**
* 只能輸入中英文和數字
*/
public static final Pattern chAndEnAndNum = Pattern.compile("[a-zA-Z0-9\u4E00-\u9FA5]+"); public static final Pattern chAndEnAndNum = Pattern.compile("[a-zA-Z0-9\u4E00-\u9FA5]+");
/** /**
* 只能輸入英文和數字 * 只能輸入英文和數字
...@@ -30,7 +34,7 @@ public class InputFilterUtils { ...@@ -30,7 +34,7 @@ public class InputFilterUtils {
* 只能輸入中英文和數字還有一些標點符號 * 只能輸入中英文和數字還有一些標點符號
* Punctuation * Punctuation
*/ */
public static final Pattern chAndEnAndNumAndPt = Pattern.compile("[-a-zA-Z0-9\u4E00-\u9FA5/,.;,。;!!??]+"); public static final Pattern chAndEnAndNumAndPt = Pattern.compile("[-a-zA-Z0-9\u4E00-\u9FA5/,.;,。;!!??~…&'*()()—+:_@ ̄―#_]+");
/** /**
* 只能輸入中英文和數字還有/ * 只能輸入中英文和數字還有/
* Punctuation * Punctuation
...@@ -45,7 +49,7 @@ public class InputFilterUtils { ...@@ -45,7 +49,7 @@ public class InputFilterUtils {
Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE); Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);
public static InputFilter getChAndEnAndNumAndPtInputFilter(Context mContext) { public static InputFilter getChAndEnAndNumAndPtInputFilter(Context mContext) {
return InputFilterUtils.getTypeFilter(mContext, "請輸入中英文和數字", chAndEnAndNumAndPt); return InputFilterUtils.getTypeFilter(mContext, "請輸入正確的字符", chAndEnAndNumAndPt);
} }
public static InputFilter getTypeFilter(Context mContext, Pattern p) { public static InputFilter getTypeFilter(Context mContext, Pattern p) {
...@@ -60,6 +64,10 @@ public class InputFilterUtils { ...@@ -60,6 +64,10 @@ public class InputFilterUtils {
return InputFilterUtils.getTypeFilter(mContext, "請輸入英文和數字", enAndNum); return InputFilterUtils.getTypeFilter(mContext, "請輸入英文和數字", enAndNum);
} }
public static InputFilter getEnAndChInputFilter(Context mContext) {
return InputFilterUtils.getTypeFilter(mContext, "只允許輸入中英文", chAndEn);
}
public static InputFilter getLengthFilter(Context mContext, int maxLength) { public static InputFilter getLengthFilter(Context mContext, int maxLength) {
return InputFilterUtils.getMaxLengthFilter(mContext, "最多輸入" + maxLength + "個字", maxLength); return InputFilterUtils.getMaxLengthFilter(mContext, "最多輸入" + maxLength + "個字", maxLength);
} }
...@@ -116,17 +124,21 @@ public class InputFilterUtils { ...@@ -116,17 +124,21 @@ public class InputFilterUtils {
* @param context * @param context
* @param tipString 超過最大長度限制的提示 * @param tipString 超過最大長度限制的提示
* @param maxLength 最大長度 * @param maxLength 最大長度
* @return * @return source 當前輸入內容
* dest 輸入框中的內容
*/ */
private static InputFilter getMaxLengthFilter(Context context, String tipString, int maxLength) { private static InputFilter getMaxLengthFilter(Context context, String tipString, int maxLength) {
return (source, start, end, dest, dstart, dend) -> { return (source, start, end, dest, dstart, dend) -> {
int keep = maxLength - (dest.length() - (dend - dstart)); int destLength = TextUtil.getStringLength(dest.toString());
int sourceLength = TextUtil.getStringLength(source.toString());
// int keep = maxLength - (dest.length() - (dend - dstart));
int keep = maxLength - destLength;
if (keep <= 0) { if (keep <= 0) {
if (TextUtil.isNotEmptyOrNullOrUndefined(source.toString()) && TextUtil.isNotEmptyOrNullOrUndefined(tipString)) { if (TextUtil.isNotEmptyOrNullOrUndefined(source.toString()) && TextUtil.isNotEmptyOrNullOrUndefined(tipString)) {
ToastUtils.show(context, tipString); ToastUtils.show(context, tipString);
} }
return ""; return "";
} else if (keep >= end - start) { } else if (keep >= sourceLength) {
return null; // keep original return null; // keep original
} else { } else {
keep += start; keep += start;
...@@ -143,31 +155,5 @@ public class InputFilterUtils { ...@@ -143,31 +155,5 @@ public class InputFilterUtils {
} }
}; };
} }
/**
* 輸入最大長度限制
*
* @param maxLength 最大長度
* @return
*/
private static InputFilter getMaxLengthFilter(int maxLength) {
return (source, start, end, dest, dstart, dend) -> {
int keep = maxLength - (dest.length() - (dend - dstart));
if (keep <= 0) {
return "";
} else if (keep >= end - start) {
return null; // keep original
} else {
keep += start;
if (Character.isHighSurrogate(source.charAt(keep - 1))) {
--keep;
if (keep == start) {
return "";
}
}
return source.subSequence(start, keep);
}
};
}
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/dp_10"> android:padding="@dimen/dp_10">
...@@ -43,11 +44,11 @@ ...@@ -43,11 +44,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:paddingTop="@dimen/dp_10" android:background="@drawable/shape_cloas_btn"
android:paddingBottom="@dimen/dp_10"
android:paddingLeft="@dimen/dp_10" android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_10" android:paddingRight="@dimen/dp_10"
android:background="@drawable/shape_cloas_btn" android:paddingBottom="@dimen/dp_10"
android:text="停止接單" android:text="停止接單"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/dp_14" /> android:textSize="@dimen/dp_14" />
......
...@@ -477,6 +477,7 @@ ...@@ -477,6 +477,7 @@
<color name="color_222">#222222</color> <color name="color_222">#222222</color>
<color name="color_53">#535353</color> <color name="color_53">#535353</color>
<color name="color_48">#484848</color> <color name="color_48">#484848</color>
<color name="color_75">#757575</color>
<color name="tran_twenty_send_order_btn_bg_color">#331196DB</color> <color name="tran_twenty_send_order_btn_bg_color">#331196DB</color>
<color name="tran_fifty_order_state0_color">#7F009788</color> <color name="tran_fifty_order_state0_color">#7F009788</color>
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
<item name="iv_left_back" type="id"/> <item name="iv_left_back" type="id"/>
<item name="iv_history" type="id"/> <item name="iv_history" type="id"/>
<item name="topbar_refresh" type="id"/> <item name="topbar_refresh" type="id"/>
<item name="id_topbar_print" type="id"/>
<item name="topbar_right_change_button" type="id"/> <item name="topbar_right_change_button" type="id"/>
<item name="topbar_right_add_button" type="id"/> <item name="topbar_right_add_button" type="id"/>
......
...@@ -186,6 +186,7 @@ ...@@ -186,6 +186,7 @@
<string name="open">營業中</string> <string name="open">營業中</string>
<string name="resting">休息中</string> <string name="resting">休息中</string>
<string name="str_order_id">訂單號:%1$d</string>
<string name="order_no">訂單編號:</string> <string name="order_no">訂單編號:</string>
<string name="deliveryman">送貨員:</string> <string name="deliveryman">送貨員:</string>
<string name="deliveryman_phone">送貨員手機號:</string> <string name="deliveryman_phone">送貨員手機號:</string>
......
package com.gingersoft.gsa.cloud.print; package com.gingersoft.gsa.cloud.print;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log;
import com.gingersoft.gsa.cloud.common.logan.LoganManager; import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.print.impl.OnPrjPrintResultListener; import com.gingersoft.gsa.cloud.print.impl.OnPrjPrintResultListener;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils; import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
...@@ -58,18 +58,24 @@ public class PrintExecutor { ...@@ -58,18 +58,24 @@ public class PrintExecutor {
*/ */
public void doPrinterRequestAsync(PrintDataMaker maker) { public void doPrinterRequestAsync(PrintDataMaker maker) {
if (printDataMakers.size() <= 0) { if (printDataMakers.size() <= 0) {
LogUtil.i("eee", "prj熱敏打印執行第一個任務");
printDataMakers.add(maker); printDataMakers.add(maker);
new PrintTask().execute(maker); new PrintTask().execute(maker);
} else { } else {
//如果隊列裡有任務在執行,只添加進去,等待執行完成之後,再來執行這個 //如果隊列裡有任務在執行,只添加進去,等待執行完成之後,再來執行這個
LogUtil.i("eee", "prj熱敏打印添加隊列,前面還有" + printDataMakers.size() + "個任務");
printDataMakers.add(maker); printDataMakers.add(maker);
startReset(); startReset();
} }
} }
private void startReset() { private void startReset() {
resetPrintDis = RxJavaUtils.delay(10, aLong -> { if (resetPrintDis != null) {
//如果十秒之後,任務還沒在打印完成方法中取消,可能打印程序卡住了,在這裡執行下一個任務 resetPrintDis.dispose();
}
resetPrintDis = RxJavaUtils.delay(30, aLong -> {
//如果三十秒之後,任務還沒在打印完成方法中取消,可能打印程序卡住了,在這裡執行下一個任務
LogUtil.e("eee", "prj熱敏打印等待時間超過三十秒,自動重新打印");
if (printDataMakers.size() > 0) { if (printDataMakers.size() > 0) {
new PrintTask().execute(printDataMakers.get(0)); new PrintTask().execute(printDataMakers.get(0));
} }
...@@ -88,6 +94,7 @@ public class PrintExecutor { ...@@ -88,6 +94,7 @@ public class PrintExecutor {
List<byte[]> data = maker.getPrintData(); List<byte[]> data = maker.getPrintData();
//如果是打印prj,需要獲取prj的id //如果是打印prj,需要獲取prj的id
prjIds = maker.getPrjIds(); prjIds = maker.getPrjIds();
LogUtil.d("eee", "prj doRequest食品id:" + prjIds);
//判斷是否連接,如果未連接就先連接 //判斷是否連接,如果未連接就先連接
int prepare = holder.prepareSocket(maker.getIp(), maker.getPort()); int prepare = holder.prepareSocket(maker.getIp(), maker.getPort());
if (prepare != PrintSocketHolder.ERROR_0) { if (prepare != PrintSocketHolder.ERROR_0) {
...@@ -105,22 +112,25 @@ public class PrintExecutor { ...@@ -105,22 +112,25 @@ public class PrintExecutor {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
Log.e("eee", "任務數量:" + printDataMakers.size()); LogUtil.i("eee", "prj熱敏任務onPreExecute");
holder.setOnStateChangedListener(this); holder.setOnStateChangedListener(this);
} }
@Override @Override
protected Integer doInBackground(PrintDataMaker... makers) { protected Integer doInBackground(PrintDataMaker... makers) {
LogUtil.i("eee", "prj熱敏任務開始");
holder.closeSocket(); holder.closeSocket();
if (makers == null || makers.length < 1) { if (makers == null || makers.length < 1) {
return PrintSocketHolder.ERROR_0; return PrintSocketHolder.ERROR_0;
} }
LogUtil.e("eee", "prj熱敏任務開始" + makers[0].getPrjIds());
return doRequest(makers[0]); return doRequest(makers[0]);
} }
@Override @Override
protected void onProgressUpdate(Integer... values) { protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values); super.onProgressUpdate(values);
LogUtil.i("eee", "prj熱敏任務onProgressUpdate" + values);
if (values == null || values.length < 1) { if (values == null || values.length < 1) {
return; return;
} }
...@@ -132,6 +142,7 @@ public class PrintExecutor { ...@@ -132,6 +142,7 @@ public class PrintExecutor {
@Override @Override
protected void onPostExecute(Integer integer) { protected void onPostExecute(Integer integer) {
super.onPostExecute(integer); super.onPostExecute(integer);
LogUtil.i("eee", "prj熱敏任務onPostExecute" + integer);
if (resetPrintDis != null) { if (resetPrintDis != null) {
resetPrintDis.dispose(); resetPrintDis.dispose();
} }
...@@ -144,7 +155,7 @@ public class PrintExecutor { ...@@ -144,7 +155,7 @@ public class PrintExecutor {
new PrintTask().execute(printDataMakers.get(0)); new PrintTask().execute(printDataMakers.get(0));
startReset(); startReset();
} }
Log.e("eee", "完成後任務數量:" + printDataMakers.size()); LogUtil.d("eee", "prj熱敏打印完成後,任務數量" + printDataMakers.size());
//返回結果 //返回結果
if (integer != null) { if (integer != null) {
onResult(integer); onResult(integer);
......
package com.gingersoft.gsa.cloud.print; package com.gingersoft.gsa.cloud.print;
import android.util.Log;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans; import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.logan.LoganManager; import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins; import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
...@@ -69,21 +73,33 @@ public class PrintSocketHolder { ...@@ -69,21 +73,33 @@ public class PrintSocketHolder {
//设置超时时间 //设置超时时间
socket.setSoTimeout(PrintConstans.SO_TIMEOUT); socket.setSoTimeout(PrintConstans.SO_TIMEOUT);
socket.connect(socketAddress, PrintConstans.PRINT_TIMEOUT);//开始连接ip socket.connect(socketAddress, PrintConstans.PRINT_TIMEOUT);//开始连接ip
LogUtil.d("eee", "prj 熱敏開始連接打印機" + ip + ":" + port);
// if (socket != null && socket.isConnected()) {
// //如果不為空,並且已連接,可以和當前的ip比較,如果ip是一樣的,就不用再次連接,如果ip不一樣,斷開當前,再鏈接新的ip
//但是要在打印完所有之後關閉socket,避免打印機被這台機器佔用
//還要避免沒打印完的時候,app被關閉了,也要處理斷開
// InetAddress inetAddress = socket.getInetAddress();
// String hostName = inetAddress.getHostName();
// }
} catch (SocketTimeoutException e) { } catch (SocketTimeoutException e) {
e.printStackTrace(); e.printStackTrace();
LoganManager.w_printer(TAG, "連接打印機超時: " + ip + ":" + port + "." + e.getMessage()); LoganManager.w_printer(TAG, "連接打印機超時: " + ip + ":" + port + "." + e.getMessage());
LogUtil.e("eee", "prj 熱敏連接打印機超時" + ip + ":" + port);
return ERROR_TIMEOUT; return ERROR_TIMEOUT;
} catch (ConnectException e) { } catch (ConnectException e) {
e.printStackTrace(); e.printStackTrace();
LoganManager.w_printer(TAG, "連接打印機失敗: " + ip + ":" + port + "." + e.getMessage()); LoganManager.w_printer(TAG, "連接打印機失敗: " + ip + ":" + port + "." + e.getMessage());
LogUtil.e("eee", "prj 熱敏打印機連接失敗:" + ip + ":" + port);
return ERROR_7; return ERROR_7;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
PrinterPlugins.getOnPrinterFlowHandler().connectionError(e); PrinterPlugins.getOnPrinterFlowHandler().connectionError(e);
LogUtil.e("eee", "prj 熱敏連接打印機出錯IOException:" + ip + ":" + port + "詳細:" + e.getMessage());
return ERROR_7; return ERROR_7;
} catch (Exception e) { } catch (Exception e) {
closeSocket(); closeSocket();
e.printStackTrace(); e.printStackTrace();
LogUtil.e("eee", "prj 熱敏連接打印機出錯Exception:" + ip + ":" + port + "詳細:" + e.getMessage());
LoganManager.w_printer(TAG, "連接打印機異常: " + ip + ":" + port + "." + e.getMessage()); LoganManager.w_printer(TAG, "連接打印機異常: " + ip + ":" + port + "." + e.getMessage());
return ERROR_7; return ERROR_7;
} }
...@@ -119,6 +135,7 @@ public class PrintSocketHolder { ...@@ -119,6 +135,7 @@ public class PrintSocketHolder {
public int sendData(List<byte[]> data) { public int sendData(List<byte[]> data) {
onPrinterStateChanged(STATE_3); onPrinterStateChanged(STATE_3);
if (data == null || data.size() <= 0) { if (data == null || data.size() <= 0) {
LogUtil.e("eee", "prj 熱敏數據為空");
return ERROR_6; return ERROR_6;
} }
for (byte[] item : data) { for (byte[] item : data) {
...@@ -127,6 +144,7 @@ public class PrintSocketHolder { ...@@ -127,6 +144,7 @@ public class PrintSocketHolder {
out.flush(); out.flush();
} catch (IOException | NullPointerException e) { } catch (IOException | NullPointerException e) {
LoganManager.w_printer(TAG, "打印prj寫入數據异常: " + e.getMessage()); LoganManager.w_printer(TAG, "打印prj寫入數據异常: " + e.getMessage());
LogUtil.e("eee", "prj 熱敏寫入數據異常" + e.getMessage());
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(e, ERROR_10); PrinterPlugins.getOnPrinterFlowHandler().onPrintError(e, ERROR_10);
closeSocket(); closeSocket();
return ERROR_10; return ERROR_10;
...@@ -138,14 +156,17 @@ public class PrintSocketHolder { ...@@ -138,14 +156,17 @@ public class PrintSocketHolder {
public int prepareSocket(String ip, int port) { public int prepareSocket(String ip, int port) {
LoganManager.w_printer(TAG, "准备尝试连接打印机" + ip + ":" + port); LoganManager.w_printer(TAG, "准备尝试连接打印机" + ip + ":" + port);
LogUtil.i("eee", "prj 熱敏準備連接打印機" + ip + ":" + port);
//創建連接 //創建連接
int create = createSocket(ip, port); int create = createSocket(ip, port);
//判斷連接狀態 //判斷連接狀態
if (create != PrintSocketHolder.ERROR_0) { if (create != PrintSocketHolder.ERROR_0) {
LogUtil.e("eee", "prj 熱敏" + ip + ":" + port + "狀態:" + create);
return create; return create;
} }
//獲取打印機寫入 //獲取打印機寫入
int result = getOutputStream(); int result = getOutputStream();
LogUtil.d("eee", "prj 熱敏獲取輸入流:" + (result == ERROR_0));
if (result == ERROR_0) { if (result == ERROR_0) {
PrinterPlugins.getOnPrinterFlowHandler().connectionSuccess(); PrinterPlugins.getOnPrinterFlowHandler().connectionSuccess();
} else { } else {
...@@ -158,6 +179,7 @@ public class PrintSocketHolder { ...@@ -158,6 +179,7 @@ public class PrintSocketHolder {
* 销毁 * 销毁
*/ */
public int closeSocket() { public int closeSocket() {
LogUtil.i("eee", "prj熱敏打印執行closeSocket");
onPrinterStateChanged(STATE_4); onPrinterStateChanged(STATE_4);
boolean error = false; boolean error = false;
try { try {
......
...@@ -88,6 +88,7 @@ ...@@ -88,6 +88,7 @@
<item name="app_skin_span_normal_bg_color">@color/qmui_config_color_gray_8</item> <item name="app_skin_span_normal_bg_color">@color/qmui_config_color_gray_8</item>
<item name="app_skin_span_pressed_bg_color">@color/qmui_config_color_gray_6</item> <item name="app_skin_span_pressed_bg_color">@color/qmui_config_color_gray_6</item>
<item name="app_skin_alpha_test">1</item> <item name="app_skin_alpha_test">1</item>
<item name="android:windowBackground">@color/qmui_config_color_white</item>
</style> </style>
<style name="AppTheme.Launcher"> <style name="AppTheme.Launcher">
......
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