Commit 33ba7f75 by Wyh

1、優化prj查詢頁面 2、歷史訂單顯示優化 3、針式打印回調問題修改 4、增加多種打印失敗問題返回給後台 5、供應鏈發送BUG修復 6、打印類修改

parent f410baeb
......@@ -77,6 +77,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo
}
}, {
//出錯
it.printStackTrace()
})
}
......
......@@ -120,6 +120,7 @@ public class PrjQueryPresenter extends BasePresenter<PrjQueryContract.Model, Prj
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
//打印成功後,再次調用查詢,刷新頁面
getKitchenPrint(orderNo);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
......
......@@ -24,6 +24,7 @@ import com.gingersoft.gsa.cloud.print.bean.UpdateBean;
import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.gsa.delivery_pick_mode.R;
......@@ -101,7 +102,7 @@ public class PrjQueryActivity extends BaseActivity<PrjQueryPresenter> implements
if (TextUtil.isNotEmptyOrNullOrUndefined(orderId)) {
layoutPrjOrderNumber.setVisibility(View.VISIBLE);
tvPrjRecordOrderId.setText(orderId);
mPresenter.getKitchenPrint(orderId);
getKitchenPrintRecord();
} else {
editLayout.setVisibility(View.VISIBLE);
}
......@@ -123,6 +124,9 @@ public class PrjQueryActivity extends BaseActivity<PrjQueryPresenter> implements
topBarPrjPrint.setTitle("廚房打印查詢");
topBarPrjPrint.setBackgroundColor(ContextCompat.getColor(this, R.color.theme_color));
topBarPrjPrint.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener(v -> killMyself());
topBarPrjPrint.addRightImageButton(R.drawable.icon_refresh, R.id.topbar_refresh).setOnClickListener(v -> {
getKitchenPrintRecord();
});
}
@Override
......@@ -175,9 +179,16 @@ public class PrjQueryActivity extends BaseActivity<PrjQueryPresenter> implements
public void onClick(View v) {
int viewId = v.getId();
if (viewId == R.id.iv_search_order_prj) {
if (TextUtil.isNotEmptyOrNullOrUndefined(edOrderNumber)) {
mPresenter.getKitchenPrint(edOrderNumber.getText().toString());
}
getKitchenPrintRecord();
}
}
private void getKitchenPrintRecord() {
if (TextUtil.isNotEmptyOrNullOrUndefined(edOrderNumber)) {
mPresenter.getKitchenPrint(edOrderNumber.getText().toString());
} else {
showMessage("請輸入訂單號");
edOrderNumber.requestFocus();
}
}
......@@ -188,6 +199,7 @@ public class PrjQueryActivity extends BaseActivity<PrjQueryPresenter> implements
if (prjStateAdapter == null) {
prjStateAdapter = new PrjStateAdapter(mContext, prjQueryBean.getData());
rvPrjRecordList.setAdapter(prjStateAdapter);
rvPrjRecordList.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
prjStateAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if (view.getId() == R.id.tv_prj_record_print_operation) {
//重印
......
package com.gingersoft.gsa.delivery_pick_mode.mvp.ui.adapter;
import android.content.Context;
import android.graphics.Color;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.print.bean.PrjBean;
import com.gingersoft.gsa.cloud.print.bean.UpdateBean;
import com.gingersoft.gsa.delivery_pick_mode.R;
import org.jetbrains.annotations.NotNull;
......@@ -20,41 +24,80 @@ public class PrjStateAdapter extends BaseQuickAdapter<PrjBean.DataBean.Bean, Bas
private Context context;
private int indentation;
/**
* 打印成功、打印失敗、飛單失敗的顏色
*/
private int successColor, failColor, flyFailColor;
public PrjStateAdapter(Context context, @Nullable List<PrjBean.DataBean.Bean> data) {
super(R.layout.item_prj_state, data);
this.context = context;
addChildClickViewIds(R.id.tv_prj_record_print_operation);
successColor = ContextCompat.getColor(context, R.color.order_state4_color);
failColor = ContextCompat.getColor(context, R.color.other_order_details_cancel_btn_color);
flyFailColor = ContextCompat.getColor(context, R.color.bright_orange);
}
@Override
protected void convert(@NotNull BaseViewHolder baseViewHolder, PrjBean.DataBean.Bean dataBean) {
TextView state = baseViewHolder.getView(R.id.tv_prj_record_print_state);
//食品組名稱
baseViewHolder.setText(R.id.tv_prj_record_food_group_name, dataBean.getFoodGroupName());
//食品名稱
TextView foodName = baseViewHolder.getView(R.id.tv_prj_record_food_name);
foodName.setText(dataBean.getProductName());
if (dataBean.getPrinterType() == 3) {
state.setText("已打印");
state.setTextColor(ContextCompat.getColor(context, R.color.order_state4_color));
} else if (dataBean.getPresence() == 0) {
state.setText("未生成打印記錄");
state.setTextColor(ContextCompat.getColor(context, R.color.red));
} else if (dataBean.getPrinterDeviceId() == -1) {
state.setText("未配置打印位置");
state.setTextColor(ContextCompat.getColor(context, R.color.red));
//打印失敗原因
TextView tvFailReason = baseViewHolder.getView(R.id.tv_prj_record_fail_reason);
tvFailReason.setText(UpdateBean.getStateByCode(dataBean.getPrinterType()));
//打印狀態
foodName.setTextColor(Color.WHITE);
if (dataBean.getPrinterType() == UpdateBean.ALREADY_PRINT) {
//打印成功
baseViewHolder.setBackgroundColor(R.id.tv_prj_record_food_name, successColor);
tvFailReason.setText("");
} else if (dataBean.getPrinterType() == UpdateBean.FAILED_PRINT) {
//打印失敗
if (dataBean.getPresence() == PrjBean.DataBean.Bean.NOT_GENERATED_PRJ) {
//未生成PRJ記錄
baseViewHolder.setBackgroundColor(R.id.tv_prj_record_food_name, failColor);
tvFailReason.setText("未生成打印記錄");
} else if (dataBean.getPrinterDeviceId() == -1) {
//打印機id為-1
baseViewHolder.setBackgroundColor(R.id.tv_prj_record_food_name, failColor);
tvFailReason.setText("未配置打印位置");
} else if (TextUtil.isNotEmptyOrNullOrUndefined(dataBean.getFlyingSinglePosition()) && dataBean.getRequests() > PrjBean.DataBean.Bean.REQUEST_COUNT_FLY) {
//飛單位置不為空並且請求次數大於5此,說明飛單打印失敗
baseViewHolder.setBackgroundColor(R.id.tv_prj_record_food_name, flyFailColor);
}
} else {
state.setText("打印失敗");
state.setTextColor(ContextCompat.getColor(context, R.color.red));
baseViewHolder.setBackgroundColor(R.id.tv_prj_record_food_name, failColor);
}
state.setSelected(true);
//設置打印位置
setPrintPosition(baseViewHolder, dataBean);
//請求次數
baseViewHolder.setText(R.id.tv_prj_record_print_count, String.valueOf(dataBean.getRequests() <= 0 ? 1 : dataBean.getRequests()));
//設置縮進
if (baseViewHolder.getAdapterPosition() == 0) {
//只第一次測量一下
indentation = new BigDecimal(foodName.getPaint().measureText("哈")).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
}
LinearLayout foodNameLayout = baseViewHolder.getView(R.id.layout_print_state);
if (dataBean.getParentId() != 0) {
foodName.setPadding(indentation, foodName.getPaddingTop(), foodName.getPaddingRight(), foodName.getPaddingBottom());
foodNameLayout.setPadding(indentation, foodNameLayout.getPaddingTop(), foodNameLayout.getPaddingRight(), foodNameLayout.getPaddingBottom());
} else {
foodNameLayout.setPadding(0, foodNameLayout.getPaddingTop(), foodNameLayout.getPaddingRight(), foodNameLayout.getPaddingBottom());
}
}
private void setPrintPosition(@NotNull BaseViewHolder baseViewHolder, PrjBean.DataBean.Bean dataBean) {
if (TextUtil.isNotEmptyOrNullOrUndefined(dataBean.getPrintPosition())) {
//打印位置
baseViewHolder.setText(R.id.tv_prj_record_print_position, dataBean.getPrintPosition());
if (TextUtil.isNotEmptyOrNullOrUndefined(dataBean.getFlyingSinglePosition())) {
//打印位置+飛單位置
baseViewHolder.setText(R.id.tv_prj_record_print_position, dataBean.getPrintPosition() + "/" + dataBean.getFlyingSinglePosition());
}
} else {
foodName.setPadding(0, foodName.getPaddingTop(), foodName.getPaddingRight(), foodName.getPaddingBottom());
baseViewHolder.setText(R.id.tv_prj_record_print_position, "");
}
}
}
......@@ -29,13 +29,12 @@ class HistoryFragment : BaseFragment(R.layout.fragment_other_order) {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProvider(requireActivity().viewModelStore, InjectorUtil.getHistoryModelFactory())[HistoryOrderViewModel::class.java].apply {
historyData.observe(viewLifecycleOwner, Observer { it ->
historyData.observe(viewLifecycleOwner, { it ->
cancelDialogForLoading()
refresh_layout.finishRefresh()
refresh_layout.finishLoadMore()
it?.let { _ ->
refresh_layout.setEnableLoadMore((it.data != null && it.data.list != null && it.data.list!!.size > 0))
refresh_layout.setEnableLoadMore((it.data.list.size > 0))
if (mHistoryOrderAdapter == null) {
mHistoryOrderAdapter = it.data.list.let { it1 -> context?.let { it2 -> HistoryOrderAdapter(status.value, it2, it1) } }
rv_other_order.layoutManager = LinearLayoutManager(context)
......@@ -46,18 +45,15 @@ class HistoryFragment : BaseFragment(R.layout.fragment_other_order) {
cancelDialogForLoading()
if (it2.data != null && it2.data!!.isNotEmpty()) {
//顯示彈窗
context?.let { context ->
var reasonDesc = it.reasonDesc
OtherOrderUtils.showOrderDetailsDialog(context, it2, it.orderStatus, it.orderType,it.orderPayType,it.payType, it.status, reasonDesc, true) { _, _, _ ->
//重印
showLoading()
viewModel.printOrder(context, it) {
cancelDialogForLoading()
if (it) {
ToastUtils.show(context, "打印成功")
} else {
ToastUtils.show(context, "打印失敗")
}
OtherOrderUtils.showOrderDetailsDialog(requireContext(), it2, it.orderStatus, it.orderType, it.orderPayType, it.payType, it.status, it.reasonDesc, true) { _, _, _ ->
//重印
showLoading()
viewModel.printOrder(requireContext(), it) {
cancelDialogForLoading()
if (it) {
ToastUtils.show(context, "打印成功")
} else {
ToastUtils.show(context, "打印失敗")
}
}
}
......@@ -72,26 +68,27 @@ class HistoryFragment : BaseFragment(R.layout.fragment_other_order) {
mHistoryOrderAdapter!!.notifyDataSetChanged()
}
}
layout_nodata.setState(it?.data == null || it.data?.list == null || it.data.list!!.size <= 0)
layout_nodata.setState(it?.data?.list == null || it.data.list.size <= 0)
})
historyStartTime.observe(viewLifecycleOwner, Observer {
//當時間發生變化,請求數據
historyStartTime.observe(viewLifecycleOwner, {
//當開始時間發生變化,請求數據
pageIndex = 1
getHistoryInfo()
})
historyEndTime.observe(viewLifecycleOwner, Observer {
//當時間發生變化,請求數據
historyEndTime.observe(viewLifecycleOwner, {
//當結束時間發生變化,請求數據
pageIndex = 1
getHistoryInfo()
})
status.observe(viewLifecycleOwner, Observer {
status.observe(viewLifecycleOwner, {
//用戶切換到已取消頁面或切換到已完成頁面
pageIndex = 1
getHistoryInfo()
})
searchValue.observe(viewLifecycleOwner, Observer {
searchValue.observe(viewLifecycleOwner, {
//搜索
pageIndex = 1
getHistoryInfo()
})
......
......@@ -16,44 +16,45 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.gingersoft.gsa.cloud.app.GsaCloudApplication
import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails
import com.gingersoft.gsa.cloud.common.utils.ClipboardUtils
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.pay.contract.PayTypeContract
import com.gingersoft.gsa.cloud.ui.utils.DialogUtils
import com.gingersoft.gsa.delivery_pick_mode.R
import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.BillBean
import com.gingersoft.gsa.delivery_pick_mode.databinding.LayoutOrderInfoDialogNewBinding
import com.gingersoft.gsa.delivery_pick_mode.ui.adapter.FoodListAdapter
import com.gingersoft.gsa.delivery_pick_mode.ui.adapter.HistoryOrderAdapter
import com.gingersoft.gsa.delivery_pick_mode.ui.adapter.PayBillAdapter
import com.jess.arms.utils.ArmsUtils
import java.lang.Double.parseDouble
object OtherOrderUtils {
fun showOrderDetailsDialog(context: Context, data: OrderDetails, orderStuats: Int, orderType: Int,orderPayType :Int, payType: Int, refundStatus: Int, reasonDesc: String = "", isHistory: Boolean = false, listenter: ((view: View, data: OrderDetails.DataBean, dialog: Dialog) -> Unit)?) {
fun showOrderDetailsDialog(context: Context, data: OrderDetails, orderStuats: Int, orderType: Int,orderPayType :Int, payType: Int, refundStatus: Int, reasonDesc: String? = "", isHistory: Boolean = false, listenter: ((view: View, data: OrderDetails.DataBean, dialog: Dialog) -> Unit)?) {
object : DialogUtils(context, R.layout.layout_order_info_dialog_new) {
override fun initLayout(hepler: ViewHepler, dialog: Dialog) {
if (data.data != null) {
val tvStatus = hepler.getView<TextView>(R.id.tv_order_state)
val ivOrderState = hepler.getView<ImageView>(R.id.iv_order_state)
var tv_receive_address_text = hepler.getView<TextView>(R.id.tv_receive_address_text)
var tv_receive_address = hepler.getView<TextView>(R.id.tv_receive_address)
var tv_cancel_reason_text = hepler.getView<TextView>(R.id.tv_cancel_reason_text)
var tv_cancel_reason = hepler.getView<TextView>(R.id.tv_cancel_reason)
var tv_refund_reason_text = hepler.getView<TextView>(R.id.tv_refund_reason_text)
var tv_refund_reason = hepler.getView<TextView>(R.id.tv_refund_reason)
val tvReceiveAddressText = hepler.getView<TextView>(R.id.tv_receive_address_text)
val tvReceiveAddress = hepler.getView<TextView>(R.id.tv_receive_address)
val tvCancelReasonText = hepler.getView<TextView>(R.id.tv_cancel_reason_text)
val tvCancelReason = hepler.getView<TextView>(R.id.tv_cancel_reason)
val tvRefundReasonText = hepler.getView<TextView>(R.id.tv_refund_reason_text)
val tvRefundReason = hepler.getView<TextView>(R.id.tv_refund_reason)
val orderData = data.data!![0]
val layoutOrderInfoDialogBinding: LayoutOrderInfoDialogNewBinding = DataBindingUtil.bind(hepler.contentView)!!
var totalAmount = orderData.TOTAL_AMOUNT!!.toDouble()
orderData.couponList?.let {
for (coupon in it) {
totalAmount = MoneyUtil.sub(totalAmount, coupon.discount_amount)
}
//訂單編號
hepler.setOnClickListenter(R.id.tv_order_no) {
ClipboardUtils.copyText(orderData.ORDER_NO)
ToastUtils.show(context, "複製成功")
}
val layoutOrderInfoDialogBinding: LayoutOrderInfoDialogNewBinding = DataBindingUtil.bind(hepler.contentView)!!
val totalAmount = orderData.TOTAL_AMOUNT!!.toDouble()
layoutOrderInfoDialogBinding.data = orderData
layoutOrderInfoDialogBinding.isSelf = orderType == 7
layoutOrderInfoDialogBinding.totalAmount = totalAmount
layoutOrderInfoDialogBinding.totalAmount = orderData.PAY_AMOUNT
//是歷史訂單,就不顯示訂單狀態
layoutOrderInfoDialogBinding.isHistory = isHistory
var btnContent: String
......@@ -107,12 +108,12 @@ object OtherOrderUtils {
4 -> {
//已完成訂單
ivOrderState.setImageResource(R.drawable.ic_has_end)
tv_cancel_reason_text.visibility = View.GONE
tv_cancel_reason.visibility = View.GONE
tv_refund_reason_text.visibility = View.GONE
tv_refund_reason.visibility = View.GONE
tv_receive_address_text.visibility = View.GONE
tv_receive_address.visibility = View.GONE
tvCancelReasonText.visibility = View.GONE
tvCancelReason.visibility = View.GONE
tvRefundReasonText.visibility = View.GONE
tvRefundReason.visibility = View.GONE
tvReceiveAddressText.visibility = View.GONE
tvReceiveAddress.visibility = View.GONE
}
6 -> {
//已取消訂單
......@@ -152,6 +153,7 @@ object OtherOrderUtils {
if (orderData.DELIVERY_CHARGE != 0.0) {
billBeans.add(BillBean("送貨費:", orderData.DELIVERY_CHARGE, 0))
}
billBeans.add(BillBean("總金額:", totalAmount))
// if (orderData.discount_amount != 0.0) {
// billBeans.add(BillBean("折扣:", orderData.discount_amount, 0))
// }
......@@ -163,7 +165,7 @@ object OtherOrderUtils {
}
}
}
billBeans.add(BillBean("支付金額:", totalAmount, 1))
billBeans.add(BillBean("支付金額:", orderData.PAY_AMOUNT, 1))
orderData.payMultiple?.let {
for (payMultiple in it) {
......@@ -209,7 +211,7 @@ object OtherOrderUtils {
.show()
}
private fun setOrderReason(holder: DialogUtils.ViewHepler, orderStatus: Int, refundStatus: Int, orderPayType: Int,payType: Int, reasonDesc: String) {
private fun setOrderReason(holder: DialogUtils.ViewHepler, orderStatus: Int, refundStatus: Int, orderPayType: Int,payType: Int, reasonDesc: String?) {
var tv_address_text = holder.getView<TextView>(R.id.tv_receive_address_text)
var tv_address = holder.getView<TextView>(R.id.tv_receive_address)
var tv_cancel_reason_text = holder.getView<TextView>(R.id.tv_cancel_reason_text)
......
......@@ -19,11 +19,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:visibility="gone"
android:layout_marginRight="@dimen/dp_10"
android:orientation="horizontal"
android:paddingTop="@dimen/dp_20"
android:paddingBottom="@dimen/dp_20">
android:paddingBottom="@dimen/dp_20"
android:visibility="gone">
<EditText
android:id="@+id/ed_input_order_number"
......@@ -32,6 +32,8 @@
android:background="@drawable/shape_login_edit_border"
android:hint="請輸入訂單號"
android:padding="@dimen/dp_10"
android:maxLength="50"
android:singleLine="true"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
......@@ -54,6 +56,56 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:gravity="center_vertical"
android:orientation="horizontal">
<View
android:layout_width="@dimen/dp_15"
android:layout_height="@dimen/dp_15"
android:background="@drawable/shape_oval_green" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="打印成功"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_12" />
<View
android:layout_width="@dimen/dp_15"
android:layout_height="@dimen/dp_15"
android:layout_marginLeft="@dimen/dp_15"
android:background="@drawable/shape_oval_red_wine" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="打印失敗"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_12" />
<View
android:layout_width="@dimen/dp_15"
android:layout_height="@dimen/dp_15"
android:layout_marginLeft="@dimen/dp_15"
android:background="@drawable/shape_oval_bright_orange" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="飛單失敗"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_12" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_prj_order_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -90,47 +142,58 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/color_e4"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_5">
android:layout_marginTop="@dimen/dp_5"
android:background="@color/theme_color"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
style="@style/PrjQueryTitleStyle"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="食品名稱"
android:textColor="@color/theme_color"
android:textSize="@dimen/dp_16" />
android:layout_weight="0.2"
android:text="食品組" />
<include layout="@layout/include_vertical_color_white_dividing_line" />
<TextView
style="@style/PrjQueryTitleStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="打印狀態"
android:textColor="@color/theme_color"
android:textSize="@dimen/dp_16" />
android:layout_weight="0.2"
android:text="食品名稱" />
<include layout="@layout/include_vertical_color_white_dividing_line" />
<TextView
style="@style/PrjQueryTitleStyle"
android:layout_width="0dp"
android:layout_weight="0.5"
android:gravity="center"
android:layout_height="wrap_content"
android:text="操作"
android:textColor="@color/theme_color"
android:textSize="@dimen/dp_16" />
android:layout_weight="0.26"
android:text="打印/飛單位置" />
<include layout="@layout/include_vertical_color_white_dividing_line" />
<TextView
style="@style/PrjQueryTitleStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.18"
android:text="嘗試次數" />
<include layout="@layout/include_vertical_color_white_dividing_line" />
<TextView
style="@style/PrjQueryTitleStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.16"
android:text="操作" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_prj_record_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10" />
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
......@@ -3,39 +3,68 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_5"
android:gravity="center"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_5">
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_prj_record_food_name"
android:id="@+id/tv_prj_record_food_group_name"
style="@style/PrjQueryItemStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="0.2"
android:padding="@dimen/dp_2"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_16"
tools:text="食品名稱一" />
tools:text="食品組名稱" />
<include layout="@layout/include_vertical_color_ccc_dividing_line" />
<LinearLayout
android:id="@+id/layout_print_state"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_5"
android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_5">
<TextView
android:id="@+id/tv_prj_record_food_name"
style="@style/PrjQueryItemStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="食品名稱一" />
<TextView
android:id="@+id/tv_prj_record_fail_reason"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_2"
android:textColor="@color/required_color"
android:textSize="@dimen/dp_10"
tools:text="失敗原因" />
</LinearLayout>
<TextView
android:id="@+id/tv_prj_record_print_state"
android:id="@+id/tv_prj_record_print_position"
style="@style/PrjQueryItemStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="marquee"
android:focusableInTouchMode="true"
android:gravity="center"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_16"
tools:text="打印狀態" />
android:layout_weight="0.26"
tools:text="打印位置/飛單位置" />
<TextView
android:id="@+id/tv_prj_record_print_count"
style="@style/PrjQueryItemStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.18"
tools:text="嘗試次數" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:layout_weight="0.16"
android:orientation="vertical">
<TextView
......@@ -53,7 +82,6 @@
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -103,7 +103,7 @@
android:id="@+id/tv_total_amount_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="金額"
android:text="支付金額"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
......@@ -154,7 +154,7 @@
app:layout_constraintLeft_toRightOf="@id/tv_take_food_code"
app:layout_constraintTop_toTopOf="@id/tv_take_food_code" />
<TextView
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_order_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -52,4 +52,16 @@
<item name="android:textColorHint">@color/color_ccc</item>
</style>
<style name="PrjQueryTitleStyle">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">@dimen/dp_14</item>
<item name="android:gravity">center</item>
<item name="android:paddingTop">@dimen/dp_10</item>
<item name="android:paddingBottom">@dimen/dp_10</item>
</style>
<style name="PrjQueryItemStyle">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_14</item>
<item name="android:gravity">center</item>
</style>
</resources>
......@@ -8,6 +8,7 @@ import com.epson.epos2.Epos2Exception;
import com.epson.epos2.printer.Printer;
import com.epson.epos2.printer.PrinterStatusInfo;
import com.epson.epos2.printer.ReceiveListener;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins;
import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.joe.print.mvp.model.bean.PrintInfoBean;
......@@ -42,7 +43,7 @@ public class EpsonPrint implements ReceiveListener {
*
* @return
*/
public boolean initializeObject(Context context, ReceiveListener receiveListener,PrintExecutor.OnPrintResultListener resultListener) {
public boolean initializeObject(Context context, ReceiveListener receiveListener, PrintExecutor.OnPrintResultListener resultListener) {
try {
this.resultListener = resultListener;
this.receiveListener = receiveListener;
......@@ -83,13 +84,16 @@ public class EpsonPrint implements ReceiveListener {
}
}
/**
* 暫不使用這個方法,避免在打印中,另外線程調用,使得邏輯出現問題
*/
public void finalizeObject() {
if (mPrinter == null) {
return;
}
mPrinter.clearCommandBuffer();
mPrinter.setReceiveEventListener(null);
mPrinter = null;
// if (mPrinter == null) {
// return;
// }
// mPrinter.clearCommandBuffer();
// mPrinter.setReceiveEventListener(null);
// mPrinter = null;
}
/**
......@@ -127,7 +131,14 @@ public class EpsonPrint implements ReceiveListener {
*/
private boolean isPrint = false;
private String ipAddress;
/**
* 打印隊列
*/
private List<Bitmap> bitmaps = new ArrayList<>();
/**
* 打印的食品id隊列
*/
private List<String> ids = new ArrayList<>();
public void putPrintString(String ip, int paperWidth, List<PrintInfoBean> printInfoBeans) {
if (mPrinter == null) {
......@@ -254,9 +265,10 @@ public class EpsonPrint implements ReceiveListener {
}
}
public void putPrintData(String ip, Bitmap bitmap) {
public void putPrintData(String ip, Bitmap bitmap,String foodId) {
//把bitmap存隊列中,下次打印
bitmaps.add(bitmap);
ids.add(foodId);
if (isPrint) {
return;
}
......@@ -264,32 +276,34 @@ public class EpsonPrint implements ReceiveListener {
printData(ip, bitmap);
}
//重試次數5次
private int resetCount = 5;
private void printData(String ip, Bitmap bitmap) {
mPrinter.clearCommandBuffer();
if (!createPrintData(bitmap)) {
updatePrintState(PrintSocketHolder.ERROR_1);
updatePrintState(PrintSocketHolder.ERROR_6);
return;
}
//連接打印機
connectByIp(ip, mPrinter.getStatus());
if (mPrinter == null) {
updatePrintState(PrintSocketHolder.ERROR_2);
//連接失敗
updatePrintState(PrintSocketHolder.ERROR_7);
PrinterPlugins.getOnPrinterFlowHandler().connectionError(new Exception("連接針式打印機失敗:" + ip));
return;
}
PrinterStatusInfo statusInfo = mPrinter.getStatus();
if (statusInfo.getPaper() == 2) {
//沒紙了
updatePrintState(PrintSocketHolder.ERROR_2);
updatePrintState(PrintSocketHolder.ERROR_11);
return;
} else if(statusInfo.getConnection() != 1){
} else if (statusInfo.getConnection() != 1) {
//未連接到打印機
updatePrintState(PrintSocketHolder.ERROR_2);
updatePrintState(PrintSocketHolder.ERROR_7);
return;
}
try {
mPrinter.sendData(Printer.PARAM_DEFAULT);
} catch (Exception e) {
updatePrintState(PrintSocketHolder.ERROR_4);
updatePrintState(PrintSocketHolder.ERROR_10);
mPrinter.clearCommandBuffer();
disconnectPrinter();
isPrint = false;
......@@ -347,6 +361,7 @@ public class EpsonPrint implements ReceiveListener {
mPrinter.connect("TCP:" + ip, Printer.PARAM_DEFAULT);
} catch (Exception e) {
Log.e(TAG, "連接打印機報錯" + e.getMessage() + e.getClass().getName());
PrinterPlugins.getOnPrinterFlowHandler().connectionError(e);
e.printStackTrace();
disconnectPrinter();
finalizeObject();
......@@ -355,23 +370,23 @@ public class EpsonPrint implements ReceiveListener {
return true;
}
private void updatePrintState(int code){
if(resultListener != null){
private void updatePrintState(int code) {
if (resultListener != null) {
resultListener.onResult(code);
}
}
public void setPrint(boolean print) {
isPrint = print;
}
@Override
public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String s) {
this.mPrinter = printer;
mPrinter.clearCommandBuffer();
resetCount = 5;
if (bitmaps.size() > 0) {
if (receiveListener != null) {
receiveListener.onPtrReceive(printer, i, printerStatusInfo, ids.get(0));
}
bitmaps.remove(0);
ids.remove(0);
}
if (bitmaps.size() > 0) {
printData(ipAddress, bitmaps.get(0));
......@@ -379,9 +394,7 @@ public class EpsonPrint implements ReceiveListener {
isPrint = false;
disconnectPrinter();
finalizeObject();
if (receiveListener != null) {
receiveListener.onPtrReceive(printer, i, printerStatusInfo, s);
}
}
}
}
......@@ -32,7 +32,6 @@ 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.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.core.table.TableBean;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.AidlUtil;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins;
......@@ -43,10 +42,7 @@ import com.gingersoft.gsa.cloud.common.utils.view.ImageUtils;
import com.gingersoft.gsa.cloud.common.utils.view.LayoutToBitmapUtils;
import com.gingersoft.gsa.cloud.common.utils.view.QRCodeUtil;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.order.billItem.BillItem;
import com.gingersoft.gsa.cloud.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.order.order.DoshokuOrder;
import com.gingersoft.gsa.cloud.pay.bean.PayMethod;
import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.gingersoft.gsa.cloud.print.PrinterWriter58mm;
......@@ -67,15 +63,12 @@ import com.joe.print.mvp.model.bean.HtmlLable;
import com.joe.print.mvp.print.common.HtmlContract;
import com.joe.print.mvp.print.common.PrinterFinderCallback;
import com.joe.print.mvp.print.common.SendResultCode;
import com.joe.print.mvp.print.maker.IpPrintMaker;
import com.joe.print.mvp.print.usb.EscCommand;
import com.joe.print.mvp.print.usb.UsbPrint;
import com.joe.print.mvp.print.usb.UsbPrinter;
import com.joe.print.mvp.print.usb.UsbPrinterFinder;
import com.joe.print.mvp.print.utils.BBposPrint;
import com.joe.print.mvp.ui.adapter.BillAdapter;
import com.joe.print.mvp.ui.adapter.BillItemAdapter;
import com.joe.print.mvp.ui.adapter.BillTypeAdapter;
import com.joe.print.mvp.ui.adapter.FoodAdapter;
import com.joe.print.mvp.ui.view.BillItemView;
import com.joe.print.mvp.ui.view.BillTypeView;
import com.joe.print.mvp.ui.view.BillView;
......@@ -287,11 +280,14 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
@Override
public void onRaiseException(int code, String msg) {
//接⼝执⾏失败时,返回的异常状态
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(code);
LoganManager.w_printer(TAG, "商米onRaiseException: " + code + msg);
}
@Override
public void onPrintResult(int code, String msg) {
//事务模式下真实的打印结果返回
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess();
}
});
}
......@@ -305,9 +301,11 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
if (i == 0) {
//打印成功
listener.printSuccess();
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess();
} else {
//打印失敗
listener.printFailure("打印失敗");
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(i);
}
}
......@@ -316,7 +314,8 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
return this;
}
});
} catch (RemoteException e) {
} catch (
RemoteException e) {
e.printStackTrace();
//打印失敗
listener.printFailure("打印失敗");
......@@ -335,11 +334,10 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
if (printerDeviceBean.getModel() != null) {
if (printerDeviceBean.getModel().toLowerCase().contains("TM-U220B".toLowerCase())) {
ThreadPoolManager.getInstence().putExecutableTasks(() -> {
EpsonPrint mPrinter = EpsonPrint.getInstance();
mPrinter.setPrint(false);
EpsonPrint mPrinter = new EpsonPrint();
mPrinter.initializeObject(GsaCloudApplication.getAppContext(), PrinterRoot.this, PrinterRoot.this);
for (int j = 0; j < bitmaps.size(); j++) {
mPrinter.putPrintData(printerDeviceBean.getIp(), bitmaps.get(j));
mPrinter.putPrintData(printerDeviceBean.getIp(), bitmaps.get(j), "");
}
}
);
......@@ -441,32 +439,25 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess();
printSuccess();
return;
case PrintSocketHolder.ERROR_1:
case PrintSocketHolder.ERROR_6:
LoganManager.w_printer(TAG, "生成打印數據失敗");
printFailure("生成打印數據失敗");
break;
case PrintSocketHolder.ERROR_2:
case PrintSocketHolder.ERROR_7:
LoganManager.w_printer(TAG, "連接打印機失敗");
printFailure("連接打印機失敗");
break;
case PrintSocketHolder.ERROR_3:
LoganManager.w_printer(TAG, "連接打印機失敗(获取输出流失败)");
printFailure("連接打印機失敗");
break;
case PrintSocketHolder.ERROR_4:
LoganManager.w_printer(TAG, "連接打印機失敗(写入页面数据失败)");
printFailure("連接打印機失敗");
case PrintSocketHolder.ERROR_10:
LoganManager.w_printer(TAG, "連接打印機失敗(写入页面数据失败),Code:" + PrintSocketHolder.ERROR_10);
printFailure("打印失敗,錯誤碼:" + errorCode);
break;
case PrintSocketHolder.ERROR_5:
case PrintSocketHolder.ERROR_9:
LoganManager.w_printer(TAG, "連接打印機失敗(必要参数不能为空)");
printFailure("連接打印機失敗");
printFailure("連接打印機失敗,沒有ip地址,錯誤碼:" + errorCode);
break;
case PrintSocketHolder.ERROR_6:
case PrintSocketHolder.ERROR_66:
LoganManager.w_printer(TAG, "关闭Socket出错");
break;
case PrintSocketHolder.ERROR_100:
LoganManager.w_printer(TAG, "打印失败");
break;
}
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(errorCode);
setPrintState(errorCode);
......@@ -924,55 +915,6 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
parentView.findViewById(viewId).setVisibility(isShow ? View.VISIBLE : View.GONE);
}
protected String getHtmlPrintHeadInfo() {
return getPLable(RestaurantInfoManager.newInstance().getBrandName(), HTML_PRINT_GRAVITY_CENTER) +
getPLable(RestaurantInfoManager.newInstance().getRestaurantName(), HTML_PRINT_GRAVITY_CENTER);
}
protected String getHtmlPrintHeadOrderInfo(TableBean.DataBean tableBean) {
String orderNum = "單號:";
if (TextUtil.isNotEmptyOrNullOrUndefined(DoshokuOrder.getInstance().getOrderNo())) {
orderNum = "單號:" + DoshokuOrder.getInstance().getOrderNo();
}
return getWholeLine() +
getPLable("餐檯:" + tableBean.getTableName(), HTML_PRINT_GRAVITY_LEFT) +
getPLable("人數:" + DoshokuOrder.getInstance().getOpenTableInfo().getPerson(), HTML_PRINT_GRAVITY_LEFT) +
getPLable(orderNum, HTML_PRINT_GRAVITY_LEFT) +
getPLable("日期:" + TimeUtils.parseTimeRepeat(tableBean.getCreateTime(), TimeUtils.DEFAULT_DATE_FORMAT), HTML_PRINT_GRAVITY_LEFT) +
getWholeLine();
}
protected String getHtmlBillInfo() {
//添加合計項
StringBuilder amountStr = new StringBuilder(getPLable("合計 " + DoshokuOrder.getInstance().getShoppingCart().getWholeAmount(), HTML_PRINT_GRAVITY_RIGHT));
//添加其他金額項
if (DoshokuOrder.getInstance().getShoppingCart().getBillItemList().size() > 0) {
for (BillItem item : DoshokuOrder.getInstance().getShoppingCart().getBillItemList()) {
amountStr.append(getPLable(item.getName() + " " + item.getMoney(), HTML_PRINT_GRAVITY_RIGHT));
}
}
amountStr.append(getLine(21, HTML_PRINT_GRAVITY_RIGHT));
amountStr.append("總金額 ").append(DoshokuOrder.getInstance().getShoppingCart().getTotalAmount());
return getLine(21, HTML_PRINT_GRAVITY_RIGHT)
+ amountStr;
}
protected String getHtmlBillPayInfo() {
StringBuilder payInfo = new StringBuilder();
for (PayMethod payMethod : DoshokuOrder.getInstance().getBillMoney()) {
payInfo.append(getPLable(payMethod.getPayName() + " $" + payMethod.getPayMoney(), HTML_PRINT_GRAVITY_LEFT));
}
return getWholeLine() +
payInfo +
getWholeLine();
}
protected String getHtmlFooter() {
return getPLable("Thank you!", HTML_PRINT_GRAVITY_CENTER) +
getPLable(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT), HTML_PRINT_GRAVITY_CENTER);
}
public final int HTML_PRINT_GRAVITY_LEFT = 0;
public final int HTML_PRINT_GRAVITY_CENTER = 1;
public final int HTML_PRINT_GRAVITY_RIGHT = 2;
......
package com.joe.print.mvp.print;
package com.joe.print.mvp.print.maker;
import com.gingersoft.gsa.cloud.print.PrintDataMaker;
import com.gingersoft.gsa.cloud.print.PrinterWriter;
......
......@@ -3,6 +3,7 @@ package com.joe.print.mvp.print.maker;
import android.graphics.Bitmap;
import com.gingersoft.gsa.cloud.print.PrintDataMaker;
import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrinterWriter;
import com.gingersoft.gsa.cloud.print.PrinterWriterExecutor;
......@@ -20,6 +21,12 @@ public class PrjPrintMaker implements PrintDataMaker {
private String ip;
private int port;
private PrintExecutor.OnPrjPrintResultListener onPrjPrintResultListener;
public PrintExecutor.OnPrjPrintResultListener getOnPrjPrintResultListener() {
return onPrjPrintResultListener;
}
public PrjPrintMaker(Map<String, Bitmap> bitmapMap, String ip, int port) {
this.bitmapMap = bitmapMap;
this.ip = ip;
......
package com.joe.print.mvp.ui.activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.print.NewPrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.gingersoft.gsa.cloud.print.bean.PrintContent;
......@@ -43,42 +28,27 @@ import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.ui.utils.DialogUtils;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.joe.print.R;
import com.joe.print.di.component.DaggerPrintComponent;
import com.joe.print.mvp.contract.PrintContract;
import com.joe.print.mvp.presenter.PrintPresenter;
import com.joe.print.mvp.print.EpsonPrint;
import com.joe.print.mvp.print.OpenCashBoxMaker;
import com.joe.print.mvp.print.maker.OpenCashBoxMaker;
import com.joe.print.mvp.print.PrintInstruction;
import com.joe.print.mvp.print.PrintListener;
import com.joe.print.mvp.print.PrintPrjKitchen;
import com.joe.print.mvp.print.PrinterRoot;
import com.joe.print.mvp.print.utils.MyPrintUtils;
import com.joe.print.mvp.ui.adapter.DialogPrinterListAdapter;
import com.joe.print.mvp.ui.adapter.PrintProgressAdapter;
import com.joe.print.mvp.ui.view.SelectPrintDevicePopup;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.CenterPopupView;
import com.lxj.xpopup.enums.PopupAnimation;
import com.lxj.xpopup.impl.LoadingPopupView;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxAsyncTask;
import com.xuexiang.rxutil2.rxjava.task.RxUITask;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
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_ORDER;
......@@ -365,18 +335,17 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
case PrintSocketHolder.ERROR_0:
tip = "打印成功";
break;
case PrintSocketHolder.ERROR_1:
case PrintSocketHolder.ERROR_6:
tip = "生成打印數據失敗";
break;
case PrintSocketHolder.ERROR_2:
case PrintSocketHolder.ERROR_3:
case PrintSocketHolder.ERROR_7:
tip = "連接打印機失敗";
break;
case PrintSocketHolder.ERROR_4:
tip = "寫入測試頁面數據失敗";
break;
case PrintSocketHolder.ERROR_5:
tip = "必要的參數不能為空";
case PrintSocketHolder.ERROR_9:
tip = "ip地址不能為空";
break;
case PrintSocketHolder.STATE_0:
break;
......@@ -526,9 +495,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
//關閉打印頁面時,關閉所有打印連接
//關閉ip打印連接
PrintSocketHolder.getInstance().closeSocket();
//關閉針式打印連接
EpsonPrint.getInstance().disconnectPrinter();
EpsonPrint.getInstance().finalizeObject();
}
@Override
......
......@@ -221,7 +221,7 @@ public class SendMsgPresenter extends BasePresenter<SendMsgContract.Model, SendM
return currentSelectedSupplier;
}
public void setSendSuccess(){
public void setSendSuccess() {
SendSupplierMsgBean sendSupplierMsgBean = sendSupplierMsgBeans.get(currentSelectedSupplier);
sendSupplierMsgBean.setSend(true);
}
......@@ -237,9 +237,11 @@ public class SendMsgPresenter extends BasePresenter<SendMsgContract.Model, SendM
currentSelectedSupplier = supplierIndex;
supplierId = sendSupplierMsgBeans.get(supplierIndex).getId() + "";
List<SupplierInfoBean.SupplierContacts> supplierContacts = sendSupplierMsgBeans.get(supplierIndex).getSupplierContacts();
//把所有的供應鏈聯繫方式關閉
for (SendSupplierMsgBean sendSupplierMsgBean : sendSupplierMsgBeans) {
sendSupplierMsgBean.setOpen(false);
}
//展開當前選中的供應商的聯繫方式
sendSupplierMsgBeans.get(supplierIndex).setOpen(true);
if (supplierContacts != null) {
//如果已有聯繫方式,就不用調用接口
......@@ -248,14 +250,21 @@ public class SendMsgPresenter extends BasePresenter<SendMsgContract.Model, SendM
mRootView.loadSupplierList(sendSupplierMsgBeans);
return;
} else {
// getPurchaseOrderQrCode(sendSupplierMsgBeans.get(supplierIndex).getOrderId() + "");
mRootView.loadSupplierList(sendSupplierMsgBeans);
}
}
} else {
// mRootView.showMessage("未獲取到供應商聯繫方式");
return;
}
getSupplierContactById(supplierIndex, supplierId);
}
/**
* 跟進供應商id 獲取供應商聯繫方式
* @param supplierIndex 供應商下標,獲取到聯繫方式之後刷新
* @param supplierId 供應商id
*/
private void getSupplierContactById(int supplierIndex, String supplierId) {
mModel.getSupplierContact(supplierId)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("查詢中..."))
......@@ -279,7 +288,6 @@ public class SendMsgPresenter extends BasePresenter<SendMsgContract.Model, SendM
}
SendSupplierMsgBean sendSupplierMsgBean = sendSupplierMsgBeans.get(supplierIndex);
sendSupplierMsgBean.setSupplierContacts(supplierContacts);
// getPurchaseOrderQrCode(sendSupplierMsgBean.getOrderId() + "");
mRootView.loadSupplierList(sendSupplierMsgBeans);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
......
......@@ -4,7 +4,6 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
......@@ -41,11 +40,16 @@ public class SendSupplierMsgAdapter extends BaseQuickAdapter<SendSupplierMsgBean
viewHolder.setGone(R.id.tv_supplier_send_state, !sendSupplierMsgBean.isSend());
RecyclerView rvContacts = viewHolder.getView(R.id.rv_item_send_supplier_msg);
ContactsListAdapter contactsListAdapter = new ContactsListAdapter(sendSupplierMsgBean.getSupplierContacts());
contactsListAdapter.setSelectIndex(sendSupplierMsgBean.getCheckPosition());
contactsListAdapter.setOnItemClickListener((adapter, view, position) -> {
if (DoubleClickUtils.isFastDoubleClick()) {
return;
}
contactsListAdapter.setSelectIndex(position);
contactsListAdapter.notifyItemChanged(sendSupplierMsgBean.getCheckPosition());
contactsListAdapter.notifyItemChanged(position);
// contactsListAdapter.notifyItemChanged(sendSupplierMsgBean.getCheckPosition());
// contactsListAdapter.notifyItemChanged(position);
sendSupplierMsgBean.setCheckPosition(position);
contactsListAdapter.notifyDataSetChanged();
});
rvContacts.setAdapter(contactsListAdapter);
LinearLayout contactsLayout = viewHolder.getView(R.id.layout_send_supplier_msg_hide_show);
......@@ -81,15 +85,15 @@ public class SendSupplierMsgAdapter extends BaseQuickAdapter<SendSupplierMsgBean
}
viewHolder.setText(R.id.tv_item_pic_radio_title, SupplierInfoBean.SupplierContacts.getContractTitleByType(item.getType()));
viewHolder.setImageResource(R.id.iv_item_pic_radio_pic, getContractPicByType(item.getType()));
radioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (DoubleClickUtils.isFastDoubleClick()) {
return;
}
if (isChecked) {
setSelectIndex(viewHolder.getAdapterPosition());
notifyDataSetChanged();
}
});
// radioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
// if (DoubleClickUtils.isFastDoubleClick()) {
// return;
// }
// if (isChecked) {
// setSelectIndex(viewHolder.getAdapterPosition());
// notifyDataSetChanged();
// }
// });
}
public void setSelectIndex(int selectIndex) {
......@@ -100,5 +104,4 @@ public class SendSupplierMsgAdapter extends BaseQuickAdapter<SendSupplierMsgBean
return selectIndex;
}
}
}
......@@ -7,7 +7,6 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.utils.ClipboardUtils;
......@@ -117,12 +116,13 @@ public class SendMsgFragment extends BaseSupplyChainFragment<SendMsgPresenter> i
DeviceUtils.shareLine(mContext, "", url);
} else if (type == Kakao_Talk) {
//分享到kakao
ToastUtils.show(mContext, "暫未開放此app發送,訂單已複製,請手動打開Kakao粘貼發送");
ToastUtils.show(mContext, "暫未開放此應用發送,訂單鏈接已複製,請手動打開應用粘貼發送");
}
}
@Override
public void loadSupplierList(List<SendSupplierMsgBean> sendSupplierMsgBeans) {
isSend = false;
if (sendSupplierMsgAdapter == null) {
sendSupplierMsgAdapter = new SendSupplierMsgAdapter(sendSupplierMsgBeans);
rvSupplier.setAdapter(sendSupplierMsgAdapter);
......@@ -139,7 +139,18 @@ public class SendMsgFragment extends BaseSupplyChainFragment<SendMsgPresenter> i
@Override
public void sendSuccess() {
isSend = true;
mPresenter.setSendSuccess();
mPresenter.getContactsBySupplier(mPresenter.getCurrentSelectedSupplier() + 1);
}
private boolean isSend = false;
@Override
public void onResume() {
super.onResume();
if (isSend) {
sendSupplierMsgAdapter.notifyDataSetChanged();
mPresenter.getContactsBySupplier(mPresenter.getCurrentSelectedSupplier() + 1);
}
}
}
package com.gingersoft.supply_chain.mvp.utils;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
/**
* @author 宇航.
* User: admin
......@@ -13,6 +16,7 @@ public class DoubleClickUtils {
public static boolean isFastDoubleClick() {
long nowTime = System.currentTimeMillis();
if (nowTime - lastClickTime < 500) {//500ms
ToastUtils.show(GsaCloudApplication.getAppContext(), "請慢一點");
return true;
}
lastClickTime = nowTime;
......
......@@ -107,12 +107,13 @@ public class DeviceUtils {
List<PackageInfo> pInfo = packageManager.getInstalledPackages(0);
for (int i = 0; i < pInfo.size(); i++) {
String pn = pInfo.get(i).packageName;
if (app_package.equals(pn)){
if (app_package.equals(pn)) {
return true;
}
}
return false;
}
/**
* 直接分享文本到WhatsApp
*
......@@ -134,6 +135,8 @@ public class DeviceUtils {
/**
* 直接分享文本到微信好友
* 由於這樣分享,成功之後會有一個彈窗可以選擇返回第三方工具,但是並不能返回
* 所以我們只需要複製鏈接,打開微信就好,不必要調用分享
*
* @param context 上下文
*/
......@@ -146,7 +149,25 @@ public class DeviceUtils {
intent.putExtra("android.intent.extra.TEXT", content);
// intent.putExtra("sms_body", content);
intent.putExtra("Kdescription", !TextUtils.isEmpty(content) ? content : "");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} else {
Toast.makeText(context, "檢測到未安裝微信,請安裝後重試", Toast.LENGTH_LONG).show();
}
}
/**
* 打開微信
* @param context
*/
public static void openWeChat(Context context) {
if (isInstallApp(context, PACKAGE_WECHAT)) {
Intent intent = new Intent();
ComponentName cmp = new ComponentName(PACKAGE_WECHAT, "com.tencent.mm.ui.LauncherUI");
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(cmp);
context.startActivity(intent);
} else {
Toast.makeText(context, "檢測到未安裝微信,請安裝後重試", Toast.LENGTH_LONG).show();
......@@ -166,7 +187,7 @@ public class DeviceUtils {
* line的包名,line的接收资料的类名--》 </intent-filter> MainFist里面
*/
public static void shareLine(Context context, String title, String content) {
if(isInstallApp(context, PACKAGE_LINE)) {
if (isInstallApp(context, PACKAGE_LINE)) {
ComponentName cn = new ComponentName(PACKAGE_LINE
, "jp.naver.line.android.activity.selectchat.SelectChatActivity");
Intent shareIntent = new Intent();
......@@ -1112,30 +1133,31 @@ public class DeviceUtils {
/**
* 取SHA1
*
* @param data 数据
* @return 对应的hash值
*/
private static byte[] getHashByString(String data)
{
try{
private static byte[] getHashByString(String data) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
messageDigest.reset();
messageDigest.update(data.getBytes("UTF-8"));
return messageDigest.digest();
} catch (Exception e){
} catch (Exception e) {
return "".getBytes();
}
}
/**
* 转16进制字符串
*
* @param data 数据
* @return 16进制字符串
*/
private static String bytesToHex(byte[] data){
private static String bytesToHex(byte[] data) {
StringBuilder sb = new StringBuilder();
String stmp;
for (int n = 0; n < data.length; n++){
for (int n = 0; n < data.length; n++) {
stmp = (Integer.toHexString(data[n] & 0xFF));
if (stmp.length() == 1)
sb.append("0");
......@@ -1148,7 +1170,7 @@ public class DeviceUtils {
* 判断服务是否正在运行
*
* @param serviceName 服务类的全路径名称 例如: com.jaychan.demo.service.PushService
* @param context 上下文对象
* @param context 上下文对象
* @return
*/
public static boolean isServiceRunning(String serviceName, Context context) {
......
......@@ -5,6 +5,8 @@ import android.graphics.Bitmap;
import android.os.RemoteException;
import android.widget.Toast;
import androidx.core.content.ContextCompat;
import com.gingersoft.gsa.cloud.common.utils.LanguageUtils;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.view.ImageUtils;
......@@ -303,7 +305,7 @@ public class AidlUtil {
*
* @return
*/
public int updatePrinterState() {
public int updatePrinterState(Context context) {
if (sunmiPrinterService == null) {
Toast.makeText(context, LanguageUtils.get_language_system(context, "server.disconnected", "未連接上打印機!"), Toast.LENGTH_LONG).show();
return 2;
......
......@@ -14,12 +14,35 @@ import java.util.Map;
* @描述:打印整體打印流程(打印前數據信息,圖片->連接成功(失敗)->打印成功(失敗)->斷開連接)
*/
public interface PrinterFlowListener extends ExternalPrinterConnection {
/**
* 打印前,還未生成圖片之前
*
* @param orderType
* @param printType
* @param printerData
* @param printerDeviceInfo
*/
void onPrinterDataBefore(int orderType, int printType, String printerData, String printerDeviceInfo);
/**
* 生成圖片之後,打印之前
*
* @param orderType
* @param printType
* @param directoryName
* @param bitmaps
*/
void onPrinterBitmapBefore(int orderType, int printType, String directoryName, List<Bitmap> bitmaps);
/**
* 打印之前
*/
void onPrintSuccess();
/**
* 打印失敗
*
* @param errorCode 錯誤碼
*/
void onPrintError(int errorCode);
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/print_success_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vertical_dividing_line"
android:layout_width="@dimen/dp_0_5"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical" />
......@@ -3,10 +3,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/dp_5"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical"
android:paddingTop="@dimen/dp_10"
android:gravity="center_vertical">
android:paddingBottom="@dimen/dp_5">
<ImageView
android:id="@+id/iv_item_pic_radio_pic"
......@@ -30,5 +30,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_10"
android:button="@drawable/selector_radio_circle_bg" />
android:button="@drawable/selector_radio_circle_bg"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
</LinearLayout>
\ No newline at end of file
......@@ -538,4 +538,5 @@
<color name="add_deputy_unit_bg">#F19149</color>
<color name="dk_color_999999">#999</color>
<color name="bright_orange">#FF7A0E</color>
<color name="print_success_color">#019944</color>
</resources>
\ No newline at end of file
......@@ -19,6 +19,7 @@
<item name="qmui_arch_swipe_layout_in_back" type="id"/>
<item name="iv_left_back" type="id"/>
<item name="iv_history" type="id"/>
<item name="topbar_refresh" type="id"/>
<item name="topbar_right_change_button" type="id"/>
<item name="topbar_right_add_button" type="id"/>
......
......@@ -31,7 +31,9 @@ public class DaoManager {
* @return
*/
public static DaoManager getInstance() {
return manager;
synchronized (manager){
return manager;
}
}
private DaoManager() {
......
package com.gingersoft.gsa.cloud.print;
import android.util.Log;
import java.util.List;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import okio.ByteString;
/**
* @author 宇航.
* User: admin
* Date: 2021/2/5
* Time: 16:38
* Use: 將需要打印的數據傳進來,這裡就會進行打印,並且處理對應的狀態
*/
public class NewPrintExecutor {
private static NewPrintExecutor newPrintExecutor;
private String ip;
private int port;
public static NewPrintExecutor getInstance() {
if (newPrintExecutor == null) {
newPrintExecutor = new NewPrintExecutor();
}
return newPrintExecutor;
}
private PrintSocketHolder.OnStateChangedListener onStateChangedListener;
private PrintExecutor.OnPrintResultListener onPrintResultListener;
public NewPrintExecutor setConnect(String ip, int port) {
this.ip = ip;
this.port = port;
return this;
}
public void print() {
Request request = new Request.Builder()
.url("http://" + ip + ":" + port)
.build();
OkHttpClient client = new OkHttpClient();
client.newWebSocket(request, new WebSocketListener() {
@Override
public void onOpen(WebSocket webSocket, Response response) {
super.onOpen(webSocket, response);
Log.e("aaa", "連接已打開");
}
@Override
public void onMessage(WebSocket webSocket, String text) {
super.onMessage(webSocket, text);
Log.e("aaa", "onMessage:" + text);
}
@Override
public void onMessage(WebSocket webSocket, ByteString bytes) {
super.onMessage(webSocket, bytes);
Log.e("aaa", "onMessage2:" + bytes);
}
@Override
public void onClosing(WebSocket webSocket, int code, String reason) {
super.onClosing(webSocket, code, reason);
Log.e("aaa", "onClosing" + code + reason);
}
@Override
public void onClosed(WebSocket webSocket, int code, String reason) {
super.onClosed(webSocket, code, reason);
Log.e("aaa", "onClosed" + code + reason);
}
@Override
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
super.onFailure(webSocket, t, response);
Log.e("aaa", "onFailure" + t.getMessage());
}
});
client.dispatcher().executorService().shutdown();
}
/**
* 设置状态监听
*
* @param listener 监听
*/
public void setOnStateChangedListener(PrintSocketHolder.OnStateChangedListener listener) {
onStateChangedListener = listener;
}
/**
* 设置结果回调
*
* @param listener 回调
*/
public void setOnPrintResultListener(PrintExecutor.OnPrintResultListener listener) {
onPrintResultListener = listener;
}
}
......@@ -26,4 +26,6 @@ public interface PrintDataMaker {
String getIp();
int getPort();
}
......@@ -18,6 +18,15 @@ import io.reactivex.disposables.Disposable;
*/
public class PrintExecutor {
protected final String TAG = this.getClass().getSimpleName();
private static PrintExecutor printExecutor;
public static PrintExecutor getInstance() {
if (printExecutor == null) {
printExecutor = new PrintExecutor();
}
return printExecutor;
}
private PrintSocketHolder holder;
/**
* 存儲所有prj的id集合
......
......@@ -12,8 +12,10 @@ import com.scwang.smartrefresh.layout.listener.OnStateChangedListener;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.ref.WeakReference;
import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.List;
/**
......@@ -31,30 +33,37 @@ public class PrintSocketHolder {
protected final String TAG = this.getClass().getSimpleName();
public static final int STATE_0 = 10;// 生成测试页面数据
public static final int STATE_1 = 1;// 创建Socket连接
public static final int STATE_2 = 2;// 获取输出流
public static final int STATE_3 = 3;// 写入测试页面数据
public static final int STATE_4 = 4;// 关闭输出流
public static final int ERROR_0 = 0;// 成功
public static final int ERROR_1 = -1;// 生成测试页面数据失败
public static final int ERROR_2 = -2;// 创建Socket失败,未連接到打印機
public static final int ERROR_3 = -3;// 获取输出流失败
public static final int ERROR_4 = -4;// 写入测试页面数据失败
public static final int ERROR_5 = -5;// 必要参数不能为空
public static final int ERROR_6 = -6;// 关闭Socket出错
public static final int ERROR_100 = -100;// 失败
public static final int STATE_0 = 0;// 生成测试页面数据
public static final int STATE_1 = -1;// 创建Socket连接
public static final int STATE_2 = -2;// 获取输出流
public static final int STATE_3 = -3;// 写入测试页面数据
public static final int STATE_4 = -4;// 关闭输出流
public static final int ERROR_0 = 3;// 成功
public static final int ERROR_4 = 4;// 打印失败
public static final int ERROR_6 = 6;// 生成打印数据失败
public static final int ERROR_7 = 7;// 创建Socket失败,未連接到打印機
public static final int ERROR_TIMEOUT = 8;// 連接打印機超時
public static final int ERROR_9 = 9;// IP地址为空
public static final int ERROR_10 = 10;// 打印機連接成功,獲取輸入流失敗或者發送數據出現問題
public static final int ERROR_11 = 11;// 打印機沒紙了
public static final int ERROR_12 = 12;// 打印機初始化失敗,暫時只有針式打印機有
public static final int ERROR_66 = 66;// 关闭Socket出错
private Socket socket;
private OutputStream out;
private WeakReference<OnStateChangedListener> mListener;
private PrintSocketHolder() {
}
public int createSocket(String ip, int port) {
onPrinterStateChanged(STATE_1);
if (TextUtil.isEmptyOrNullOrUndefined(ip)) {
return ERROR_5;
return ERROR_9;
}
try {
PrinterPlugins.getOnPrinterFlowHandler().connectionBefore("網絡打印機", ip, port, PrintConstans.SO_TIMEOUT, PrintConstans.PRINT_TIMEOUT);
......@@ -64,10 +73,19 @@ public class PrintSocketHolder {
//设置超时时间
socket.setSoTimeout(PrintConstans.SO_TIMEOUT);
socket.connect(socketAddress, PrintConstans.PRINT_TIMEOUT);//开始连接ip
} catch (SocketTimeoutException e) {
e.printStackTrace();
LoganManager.w_printer(TAG, "連接打印機超時: " + ip + ":" + port + "." + e.getMessage());
return ERROR_TIMEOUT;
} catch (ConnectException e) {
e.printStackTrace();
LoganManager.w_printer(TAG, "連接打印機失敗: " + ip + ":" + port + "." + e.getMessage());
return ERROR_7;
} catch (Exception e) {
closeSocket();
e.printStackTrace();
return ERROR_2;
LoganManager.w_printer(TAG, "連接打印機異常: " + ip + ":" + port + "." + e.getMessage());
return ERROR_7;
}
return ERROR_0;
}
......@@ -77,8 +95,9 @@ public class PrintSocketHolder {
try {
out = socket.getOutputStream();
} catch (IOException e) {
LoganManager.w_printer(TAG, "獲取打印機輸入流異常: " + socket.getInetAddress() + e.getMessage());
closeSocket();
return ERROR_3;
return ERROR_10;
}
return ERROR_0;
}
......@@ -99,16 +118,16 @@ public class PrintSocketHolder {
public int sendData(List<byte[]> data) {
onPrinterStateChanged(STATE_3);
if (data == null || data.size() <= 0) {
return ERROR_0;
return ERROR_6;
}
for (byte[] item : data) {
try {
out.write(item);
out.flush();
} catch (IOException | NullPointerException e) {
LoganManager.w_printer(TAG, "打印异常: " + e.getMessage());
LoganManager.w_printer(TAG, "打印prj寫入數據异常: " + e.getMessage());
closeSocket();
return ERROR_4;
return ERROR_10;
}
}
closeSocket();//成功後關閉連接
......@@ -157,12 +176,12 @@ public class PrintSocketHolder {
LoganManager.w_printer(TAG, "关闭打印机socket连接");
}
} catch (IOException e) {
LoganManager.w_printer(TAG, "关闭打印机连接异常");
LoganManager.w_printer(TAG, "关闭打印机连接异常" + e.getMessage());
socket = null;
error = true;
}
PrinterPlugins.getOnPrinterFlowHandler().disconnect();
return error ? ERROR_6 : ERROR_0;
return error ? ERROR_66 : ERROR_0;
}
/**
......
......@@ -54,7 +54,13 @@ public class PrjBean {
private String productName2;
private String productName3;
private int parentId;
/**
* 食品类型#3:食品;4:细项;
*/
private int type;
/**
* 打印狀態
*/
private int printerType;
private Long printerTime;
private int number;
......@@ -62,6 +68,11 @@ public class PrjBean {
private Long createTime;
private int requests;
/**
* 請求多少次開始飛單
*/
public static final int REQUEST_COUNT_FLY = 5;
private int actualPrinterDeviceId;
private String takeFoodCode; //取餐碼
private String billNo;//訂單碼
......@@ -88,7 +99,6 @@ public class PrjBean {
public final static int FOOD_SECONDARY = 2;
public final static int FOOD_THREE_LEVEL = 3;
private String sender;
private String takeTime;
......@@ -99,7 +109,12 @@ public class PrjBean {
private int isFirstSendOrder;//是否首次送單,1是 2否
private int quantity;//統計打印數量
private int presence;//presence:是否生成prj記錄 0:否,1:是
public static final int NOT_GENERATED_PRJ = 0;
public static final int GENERATED_PRJ = 1;
private String printPosition;//廚房位置
private String foodGroupName;//食品組
private String flyingSinglePosition;//飛單位置
}
}
}
......@@ -11,12 +11,160 @@ import lombok.Data;
*/
@Data
public class UpdateBean {
// 1未打印 2打印中 3已打印
// 1未打印 2打印中 3已打印 4 打印失敗,5 未查詢到打印機請查詢打印管理配置是否正確,6 未生成打印數據請嘗試重印,7 未連接打印機請重啟打印機,8 打印機連接超時請重啟打印機,9 用戶沒有配置IP請查詢打印管理配置是否正確,10 打印機連接成功數據未發送請嘗試重印
/**
* 1未打印
*/
public static final int NO_PRINT = 1;
/**
* 2打印中
*/
public static final int PRINTING = 2;
/**
* 3已打印
*/
public static final int ALREADY_PRINT = 3;
/**
* 4 打印失敗
*/
public static final int FAILED_PRINT = 4;
/**
* 5 未查詢到打印機請查詢打印管理配置是否正確
* 通過打印位置沒有找到對應的打印機
*/
public static final int FAIL_PRINT_BY_NOT_FIND_DEVICE = 5;
/**
* 6 未生成打印數據請嘗試重印
* 沒有生成打印數據
*/
public static final int FAIL_PRINT_BY_NOT_PRINT_INFO = 6;
/**
* 7 未連接打印機請重啟打印機
*/
public static final int FAIL_PRINT_BY_NOT_CONNECT = 7;
/**
* 8 打印機連接超時請重啟打印機
*/
public static final int FAIL_PRINT_BY_CONNECT_TIMEOUT = 8;
/**
* 9 用戶沒有配置IP請查詢打印管理配置是否正確
* 沒有配置ip
*/
public static final int FAIL_PRINT_IS_NOT_IP = 9;
/**
* 10 打印機連接成功數據未發送請嘗試重印
* 1、寫入數據時出現異常
* 2、獲取socket輸出流失敗
*/
public static final int FAIL_PRINT_IS_NOT_SEND = 10;
/**
* 11 打印機沒紙
*/
public static final int FAIL_NOT_PAPER = 11;
/**
* 12 針式打印機初始化失敗
*/
public static final int FAIL_EPSON_INIT = 12;
/**
* 13 sunmi打印機過熱
*/
public static final int FAIL_SUNMI_PRINT_HOT = 13;
/**
* 14 SUNMI打印機蓋子未合上
*/
public static final int FAIL_LID_NOT_CLOSED_SUNMI = 14;
/**
* 15 SUNMI打印機切刀異常
*/
public static final int FAIL_CUT_ABNORMAL_SUNMI = 15;
/**
* 16 SUNMI打印機未檢測到黑標
*/
public static final int FAIL_SUNMI_NO_BLACK_MARK_DETECTED = 16;
/**
* 18 本地打印但是沒有找到這個型號的打印機
*/
public static final int FAIL_LOCAL_PRINT_NOT_DEVICE = 17;
/**
* 505 SUNMI未查詢到打印機請查詢打印管理配置是否正確
* 通過打印位置沒有找到對應的打印機
*/
public static final int FAIL_PRINT_BY_NOT_FIND_DEVICE_SUNMI = 505;
/**
* 507 SUNMI打印機固件升級失敗
*/
public static final int FAIL_SUNMI_FIRMWARE_UPGRADE_FAILED = 507;
/**
* -1 N5未知錯誤
*/
public static final int FAIL_N5_PRINT_UNKNOWN = -1;
/**
* -1001 N5打印失败
*/
public static final int FAILED_PRINT_N5 = -1001;
/**
* -1005 N5打印缺紙
*/
public static final int FAILED_PRINT_NOT_PAPER_N5 = -1005;
/**
* -1008 N5打印過熱
*/
public static final int FAIL_N5_PRINT_HOT = -1008;
/**
* -1009 N5打印了但是沒有完全打印完
*/
public static final int FAIL_PRINT_N5_INCOMPLETE = -1009;
public static String getStateByCode(int code) {
switch (code) {
case NO_PRINT:
return "未打印";
case PRINTING:
return "打印中";
case FAIL_PRINT_BY_NOT_FIND_DEVICE:
return "未查詢到打印機,請檢查打印配置是否正確";
case FAIL_PRINT_BY_NOT_PRINT_INFO:
return "生成打印數據失敗,請嘗試重印";
case FAIL_PRINT_BY_NOT_CONNECT:
return "連接打印機失敗,請檢查打印機網絡";
case FAIL_PRINT_BY_CONNECT_TIMEOUT:
return "打印機連接超時,請檢查打印機網絡";
case FAIL_PRINT_IS_NOT_IP:
return "沒有配置IP,請檢查打印配置是否正確";
case FAIL_PRINT_IS_NOT_SEND:
return "打印機連接成功,數據未發送,請嘗試重印";
case FAIL_NOT_PAPER:
return "打印機缺紙,請檢查打印紙";
case FAIL_EPSON_INIT:
return "打印機初始化失敗,請檢查設備";
case FAIL_SUNMI_PRINT_HOT:
return "sunmi打印機過熱,導致無法打印,請檢查設備";
case FAIL_LID_NOT_CLOSED_SUNMI:
return "sunmi打印機未關閉紙蓋,請檢查設備";
case FAIL_CUT_ABNORMAL_SUNMI:
return "sunmi打印機切刀異常,請檢查設備";
case FAIL_SUNMI_NO_BLACK_MARK_DETECTED:
return "sunmi打印機未檢測到黑標,請檢查設備";
case FAIL_LOCAL_PRINT_NOT_DEVICE:
return "未找到對應型號的本地打印機,請檢查設備型號";
case FAIL_PRINT_BY_NOT_FIND_DEVICE_SUNMI:
return "sunmi連接失敗,請檢查設備";
case FAIL_SUNMI_FIRMWARE_UPGRADE_FAILED:
return "sunmi固件升級失敗,請檢查設備";
case FAIL_N5_PRINT_UNKNOWN:
case FAILED_PRINT_N5:
return "NEXGO打印失敗,請重試";
case FAILED_PRINT_NOT_PAPER_N5:
return "NEXGO缺紙,請檢查打印紙";
case FAIL_N5_PRINT_HOT:
return "NEXGO打印過熱終止,請檢查設備";
case FAIL_PRINT_N5_INCOMPLETE:
return "NEXGO打印異常終止,請檢查設備";
default:
return "" + code;
}
}
public UpdateBean(String id, int printerType, Long printerTime) {
this.id = id;
......
......@@ -60,7 +60,7 @@ public class ConnectPrintUtil {
socketMap.put(ip, socket);
} catch (IOException e) {
socketMap.remove(ip);
setState(PrintSocketHolder.ERROR_2, "連接失敗" + e.getMessage());
setState(PrintSocketHolder.ERROR_7, "連接失敗" + e.getMessage());
e.printStackTrace();
}
}
......
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