Commit 1e28402f by Wyh

1、prj打印不顯示問題

2、prj沒有食品時不需要打印
parent d1f85c82
......@@ -76,7 +76,6 @@ android {
}
}
}
//dokit 扩展
dokitExt {
//通用设置
......@@ -125,8 +124,8 @@ dependencies {
addComponent 'component-coldchain'
// addComponent 'component-supply-chain'
addComponent 'component-webview'
addComponent 'component-scan'
addComponent 'component-pay'
// addComponent 'component-scan'
// addComponent 'component-pay'
implementation 'androidx.viewpager2:viewpager2:1.0.0-alpha03'
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
......
......@@ -108,7 +108,7 @@ public class PrjService extends Service implements ReceiveListener {
public int onStartCommand(Intent intent, int flags, int startId) {
mContext = this;
ThreadPoolManager.getInstence().putExecutableTasks(() -> {
LoganManager.w_printer(TAG,"開始請求 PRJ 數據");
LoganManager.w_printer(TAG, "開始請求 PRJ 數據");
getPrintList();
//開始請求
startGetPrjInfo();
......@@ -170,23 +170,23 @@ public class PrjService extends Service implements ReceiveListener {
@Override
public void onSubscribe(Disposable d) {
disposable = d;
LoganManager.w_printer(TAG,"startGetPrjInfo onSubscribe");
LoganManager.w_printer(TAG, "startGetPrjInfo onSubscribe");
}
@Override
public void onNext(Long aLong) {
LoganManager.w_printer(TAG,"startGetPrjInfo onNext");
LoganManager.w_printer(TAG, "startGetPrjInfo onNext");
getPrjInfo();
}
@Override
public void onError(Throwable e) {
LoganManager.w_printer(TAG,"startGetPrjInfo onError:" + e.getMessage());
LoganManager.w_printer(TAG, "startGetPrjInfo onError:" + e.getMessage());
}
@Override
public void onComplete() {
LoganManager.w_printer(TAG,"startGetPrjInfo onComplete");
LoganManager.w_printer(TAG, "startGetPrjInfo onComplete");
}
});
}
......@@ -202,12 +202,12 @@ public class PrjService extends Service implements ReceiveListener {
@Override
public void onSubscribe(Disposable d) {
LoganManager.w_printer(TAG,"getPrjInfo onSubscribe");
LoganManager.w_printer(TAG, "getPrjInfo onSubscribe");
}
@Override
public void onNext(String s) {
LoganManager.w_printer(TAG,"getPrjInfo onNext: " + s);
LoganManager.w_printer(TAG, "getPrjInfo onNext: " + s);
//請求到數據,停止輪詢,開始打印,在打印完之後再重新開始輪詢
// startPrint(s);
newPrint(s);
......@@ -218,35 +218,35 @@ public class PrjService extends Service implements ReceiveListener {
@Override
public void onSubscribe(Disposable d) {
wakeDisposable = d;
LoganManager.w_printer(TAG,"getPrjInfo timer onSubscribe");
LoganManager.w_printer(TAG, "getPrjInfo timer onSubscribe");
}
@Override
public void onNext(Long aLong) {
LoganManager.w_printer(TAG,"getPrjInfo timer onNext");
LoganManager.w_printer(TAG, "getPrjInfo timer onNext");
startGetPrjInfo();
}
@Override
public void onError(Throwable e) {
LoganManager.w_printer(TAG,"getPrjInfo timer onError: " + e.getMessage());
LoganManager.w_printer(TAG, "getPrjInfo timer onError: " + e.getMessage());
}
@Override
public void onComplete() {
LoganManager.w_printer(TAG,"getPrjInfo timer onComplete");
LoganManager.w_printer(TAG, "getPrjInfo timer onComplete");
}
});
}
@Override
public void onError(Throwable e) {
LoganManager.w_printer(TAG,"getPrjInfo onError:" + e.getMessage());
LoganManager.w_printer(TAG, "getPrjInfo onError:" + e.getMessage());
}
@Override
public void onComplete() {
LoganManager.w_printer(TAG,"getPrjInfo onComplete");
LoganManager.w_printer(TAG, "getPrjInfo onComplete");
}
});
}
......@@ -351,7 +351,7 @@ public class PrjService extends Service implements ReceiveListener {
totalPrj = 0;
PrjBean prjBean = JsonUtils.parseObject(json, PrjBean.class);
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 ");
return;
}
//有數據,取消輪詢,等待打印結束。
......@@ -388,7 +388,11 @@ public class PrjService extends Service implements ReceiveListener {
}
} catch (JSONException e) {
e.printStackTrace();
LoganManager.w_printer(TAG,"newPrint JSONException: " + e.getMessage());
LoganManager.w_printer(TAG, "newPrint JSONException: " + e.getMessage());
}
if (listMap.size() <= 0) {
LoganManager.w_printer(TAG, "newPrint listMap.size()<=0");
return;
}
setPrjIndex(listMap, totalPrj);
initPrinterDevices();
......@@ -396,7 +400,7 @@ public class PrjService extends Service implements ReceiveListener {
}
private Map<String, List<PrjBean.DataBean.Bean>> setPrjIndex(Map<String, List<PrjBean.DataBean.Bean>> listMap, int totalPrj) {
LoganManager.w_printer(TAG,"setPrjIndex totalPrj: "+totalPrj);
LoganManager.w_printer(TAG, "setPrjIndex totalPrj: " + totalPrj);
for (Map.Entry<String, List<PrjBean.DataBean.Bean>> prjMap : listMap.entrySet()) {
//上一個對象是否切紙
boolean lastIsCute = false;
......@@ -460,7 +464,7 @@ public class PrjService extends Service implements ReceiveListener {
}
private void foreachPrint(Map<String, List<PrjBean.DataBean.Bean>> listMap) {
LoganManager.w_printer(TAG,"foreachPrint");
LoganManager.w_printer(TAG, "foreachPrint");
//雙重遍歷可以以後優化
//第二步:遍歷 Map<廚房位置,需要打印的數據>,通過廚房位置找到對應的打印機,並且通過數據拿到對應的通用配置
for (Map.Entry<String, List<PrjBean.DataBean.Bean>> prjMap : listMap.entrySet()) {
......@@ -482,7 +486,7 @@ public class PrjService extends Service implements ReceiveListener {
}
private void initPrinterDevices() {
LoganManager.w_printer(TAG,"initPrinterDevices");
LoganManager.w_printer(TAG, "initPrinterDevices");
//讀取打印機和通用配置,可以優化
//獲取所有打印機
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(this);
......@@ -513,7 +517,7 @@ public class PrjService extends Service implements ReceiveListener {
*/
private void generatePrintData(String key, List<PrjBean.DataBean.Bean> beans, PrinterDeviceBean printerDeviceBean) {
LoganManager.w_printer(TAG,"generatePrintData PrinterDeviceBean deviceType: " + printerDeviceBean.getPrinterDeviceType()
LoganManager.w_printer(TAG, "generatePrintData PrinterDeviceBean deviceType: " + printerDeviceBean.getPrinterDeviceType()
+ " ip: " + printerDeviceBean.getIp());
if (isPinPrinter(printerDeviceBean) && printerDeviceBean.getPrinterDeviceType() == PRINT_IP) {
......@@ -704,7 +708,7 @@ public class PrjService extends Service implements ReceiveListener {
* ip設備打印
*/
public void ipPrint(PrinterDeviceBean printerDeviceBean, List<Map<String, Bitmap>> bitmapMaps) {
LoganManager.w_printer(TAG,"ipPrint: " + printerDeviceBean.getPrinterDeviceType()
LoganManager.w_printer(TAG, "ipPrint: " + printerDeviceBean.getPrinterDeviceType()
+ " ip: " + printerDeviceBean.getIp());
for (int i = 0; i < bitmapMaps.size(); i++) {
PrintExecutor executor = new PrintExecutor(printerDeviceBean);
......@@ -713,18 +717,18 @@ public class PrjService extends Service implements ReceiveListener {
switch (errorCode) {
case PrintSocketHolder.ERROR_0:
//更新狀態
LoganManager.w_printer(TAG,"ipPrint errorCode ERROR_0 i: " + finalI);
LoganManager.w_printer(TAG, "ipPrint errorCode ERROR_0 i: " + finalI);
updatePrjSuccess(ids);
Log.e(TAG, "打印成功");
break;
case PrintSocketHolder.ERROR_2:
LoganManager.w_printer(TAG,"ipPrint errorCode ERROR_2 i: " + finalI);
LoganManager.w_printer(TAG, "ipPrint errorCode ERROR_2 i: " + finalI);
Log.e(TAG, "创建Socket失败");
updatePrjFailure(ids);
break;
}
});
LoganManager.w_printer(TAG,"ipPrint for doPrinterRequestAsync i:" + i);
LoganManager.w_printer(TAG, "ipPrint for doPrinterRequestAsync i:" + i);
PrjPrintMaker maker = new PrjPrintMaker(bitmapMaps.get(i));
executor.doPrinterRequestAsync(maker);
}
......
......@@ -55,6 +55,7 @@ public class KitChenPrjFoodView extends LinearLayout {
}
private void init() {
setOrientation(LinearLayout.VERTICAL);
for (PrjBean.DataBean.Bean item : data) {
View view = View.inflate(getContext(), R.layout.print_kitchen_item_parent, null);
LinearLayout layout = view.findViewById(R.id.layout_print_kitchen_parent);
......@@ -80,6 +81,7 @@ public class KitChenPrjFoodView extends LinearLayout {
}
}
}
addView(view);
}
}
......
......@@ -3,13 +3,14 @@ package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
......@@ -53,12 +54,15 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
*/
private Map<Integer, PurchaseFoodBean> integerMap;
private String moneyString;
public FoodListAdapter(Context context, @Nullable List<PurchaseFoodBean> data, int adapterType) {
super(R.layout.item_food_ingredient, data);
addChildClickViewIds(R.id.iv_supplier_edit, R.id.iv_supplier_delete);
this.context = context;
this.adapterType = adapterType;
integerMap = new HashMap<>(8);
moneyString = context.getString(R.string.amount_string_s);
}
public FoodListAdapter(int layoutId, Context context, @Nullable List<PurchaseFoodBean> data, int adapterType) {
......@@ -67,6 +71,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
this.context = context;
this.adapterType = adapterType;
integerMap = new HashMap<>(8);
moneyString = context.getString(R.string.amount_string_s);
}
@Override
......@@ -98,7 +103,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
viewHolder.setGone(R.id.iv_supplier_delete, false);
viewHolder.setGone(R.id.layout_operation_food_num, false);
viewHolder.setGone(R.id.cb_order_item_all_select, false);
viewHolder.setGone(R.id.line_supplier_info, true);
// viewHolder.setGone(R.id.line_supplier_info, true);
setEdit(viewHolder, foodInfoBean);
CheckBox checkBox = viewHolder.getView(R.id.cb_order_item_all_select);
checkBox.setChecked(foodInfoBean.isChecked());
......@@ -152,7 +157,10 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
* @param foodInfoBean
*/
private void setEdit(@NotNull BaseViewHolder viewHolder, PurchaseFoodBean foodInfoBean) {
//食品數量
EditText editText = viewHolder.getView(R.id.ed_food_ingredient_number);
//當前食品總價
TextView mTvTotalAmount = viewHolder.getViewOrNull(R.id.tv_food_item_total_amount);
//從緩存中取出這個食品信息,如果沒有對應的食品信息,說明沒操作過這個食品
//這裡是採購頁面和購物車頁面共用
PurchaseFoodBean food = integerMap.get(foodInfoBean.getId());
......@@ -162,6 +170,9 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
integerMap.put(foodInfoBean.getId(), foodInfoBean);
}
}
if (mTvTotalAmount != null) {
mTvTotalAmount.setText(String.format(moneyString, MoneyUtil.formatDouble(MoneyUtil.priceCalculation(food.getUnitPrice(), food.getFoodQuantity()))));
}
editText.setText(String.valueOf(food.getFoodQuantity()));
//食材減少按鈕監聽
viewHolder.getView(R.id.btn_food_operation_sub).setOnClickListener(v -> {
......@@ -169,6 +180,9 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
onNumberChangeListener.onChanged(foodInfoBean.getFoodQuantity(), foodInfoBean.getFoodQuantity() - 1, viewHolder.getAdapterPosition());
}
subNumber(editText, foodInfoBean);
if (mTvTotalAmount != null) {
mTvTotalAmount.setText(String.format(moneyString, MoneyUtil.formatDouble(MoneyUtil.priceCalculation(foodInfoBean.getUnitPrice(), foodInfoBean.getFoodQuantity()))));
}
});
//食材增加按鈕監聽
viewHolder.getView(R.id.btn_food_operation_add).setOnClickListener(v -> {
......@@ -176,8 +190,10 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
onNumberChangeListener.onChanged(foodInfoBean.getFoodQuantity(), foodInfoBean.getFoodQuantity() + 1, viewHolder.getAdapterPosition());
}
addNumber(editText, foodInfoBean);
if (mTvTotalAmount != null) {
mTvTotalAmount.setText(String.format(moneyString, MoneyUtil.formatDouble(MoneyUtil.priceCalculation(foodInfoBean.getUnitPrice(), foodInfoBean.getFoodQuantity()))));
}
});
//手動輸入食材數量變化監聽
TextWatcher foodNumTextWatcher = new TextWatcher() {
@Override
......@@ -205,6 +221,10 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
if (purchaseFoodBean.getFoodQuantity() > 0) {
integerMap.put(purchaseFoodBean.getId(), purchaseFoodBean);
}
//當前食品總價修改
if (mTvTotalAmount != null) {
mTvTotalAmount.setText(String.format(moneyString, MoneyUtil.formatDouble(MoneyUtil.priceCalculation(purchaseFoodBean.getUnitPrice(), purchaseFoodBean.getFoodQuantity()))));
}
}
}
};
......
......@@ -7,7 +7,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="vertical">
<LinearLayout
......@@ -15,10 +14,10 @@
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:layout_marginLeft="@dimen/dp_8"
android:visibility="gone"
android:layout_marginRight="@dimen/dp_8"
android:gravity="center_vertical"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
......@@ -54,14 +53,14 @@
</LinearLayout>
<include
android:id="@+id/line_supplier_info"
layout="@layout/include_horizontal_color_eee_dividing_line" />
<!-- <include-->
<!-- android:id="@+id/line_supplier_info"-->
<!-- layout="@layout/include_horizontal_color_eee_dividing_line" />-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_8"
android:layout_margin="@dimen/dp_5"
android:orientation="horizontal">
<CheckBox
......@@ -107,12 +106,6 @@
android:orientation="horizontal">
<TextView
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="編號:" />
<TextView
android:id="@+id/tv_food_item_no"
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="0dp"
......@@ -127,25 +120,13 @@
android:src="@drawable/ic_red_delete" />
</LinearLayout>
<LinearLayout
<TextView
android:id="@+id/tv_food_item_name"
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:orientation="horizontal">
<TextView
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="品名:" />
<TextView
android:id="@+id/tv_food_item_name"
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="巴西肥牛" />
</LinearLayout>
tools:text="巴西肥牛" />
<LinearLayout
android:layout_width="match_parent"
......@@ -157,13 +138,23 @@
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="單位:" />
android:text="單價:" />
<TextView
android:id="@+id/tv_food_item_price"
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:text="$100.00" />
<TextView
android:id="@+id/tv_food_item_unit"
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
tools:text="3KG/盒" />
</LinearLayout>
......@@ -177,51 +168,53 @@
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="價格:" />
android:text="總價:" />
<TextView
android:id="@+id/tv_food_item_price"
android:id="@+id/tv_food_item_total_amount"
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="$100.00" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_operation_food_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_food_operation_sub"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_gray_sub" />
android:layout_weight="1"
tools:text="$100.000" />
<EditText
android:id="@+id/ed_food_ingredient_number"
<LinearLayout
android:id="@+id/layout_operation_food_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@null"
android:inputType="number"
android:maxLength="4"
android:paddingLeft="@dimen/dp_4"
android:paddingRight="@dimen/dp_4"
android:text="0"
android:textColor="@color/black"
android:textSize="@dimen/dp_22" />
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_food_operation_add"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_theme_add" />
android:gravity="center_vertical"
android:orientation="horizontal">
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_food_operation_sub"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_gray_sub" />
<EditText
android:id="@+id/ed_food_ingredient_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@null"
android:inputType="number"
android:maxLength="4"
android:paddingLeft="@dimen/dp_4"
android:paddingRight="@dimen/dp_4"
android:text="10"
android:textColor="@color/black"
android:textSize="@dimen/dp_22" />
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_food_operation_add"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_theme_add" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
......
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