Browse Source

条码数量修改和合并批次页面增加蓝牙打印弹窗及功能

songw 5 months ago
parent
commit
72997a8478

+ 0 - 1
app/src/main/java/com/uas/pda_smart_com/adapter/StorageRechargeAdapter.java

@@ -85,7 +85,6 @@ public class StorageRechargeAdapter extends BaseAdapter {
                         .setView(dialogView)
                         .setNegativeButton(R.string.cancel, null)
                         .setPositiveButton(R.string.confirm, null).create();
-
                 alertDialog.show();
                 modifyEditText.setText(objects.get(position).getQuantity()+"");
                 modifyEditText.setSelection(modifyEditText.getText().length());

+ 164 - 0
app/src/main/java/com/uas/pda_smart_com/bean/CodePrinBean.java

@@ -0,0 +1,164 @@
+package com.uas.pda_smart_com.bean;
+
+public class CodePrinBean {
+
+    /**
+     * success : true
+     * data : {"BAR_LASTPRINTMAN":"打印人:优软-杨鹏","BAR_WHCODE":"仓库:03","BAR_REMAIN":8,"MADEDATE":"生产周期:2024-06-29","VE_NAME":"供应商:null","PR_CODE":"料号:5.01.03.02.010","BAR_CODE":null,"BAR_LASTPRINTDATE":"打印日期:2024-09-26 13:48:53","BAR_BATCHCODE":null,"BAR_VENDBARCODE":"批次号:null","BAR_QR":null,"PR_SPEC":"规格:LB01-AC-1.2M(T5)","BAR_LOCATION":"仓位:null"}
+     */
+
+    private boolean success;
+    private DataBean data;
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+
+    public DataBean getData() {
+        return data;
+    }
+
+    public void setData(DataBean data) {
+        this.data = data;
+    }
+
+    public static class DataBean {
+        /**
+         * BAR_LASTPRINTMAN : 打印人:优软-杨鹏
+         * BAR_WHCODE : 仓库:03
+         * BAR_REMAIN : 8.0
+         * MADEDATE : 生产周期:2024-06-29
+         * VE_NAME : 供应商:null
+         * PR_CODE : 料号:5.01.03.02.010
+         * BAR_CODE : null
+         * BAR_LASTPRINTDATE : 打印日期:2024-09-26 13:48:53
+         * BAR_BATCHCODE : null
+         * BAR_VENDBARCODE : 批次号:null
+         * BAR_QR : null
+         * PR_SPEC : 规格:LB01-AC-1.2M(T5)
+         * BAR_LOCATION : 仓位:null
+         */
+
+        private String BAR_LASTPRINTMAN;
+        private String BAR_WHCODE;
+        private double BAR_REMAIN;
+        private String MADEDATE;
+        private String VE_NAME;
+        private String PR_CODE;
+        private Object BAR_CODE;
+        private String BAR_LASTPRINTDATE;
+        private Object BAR_BATCHCODE;
+        private String BAR_VENDBARCODE;
+        private Object BAR_QR;
+        private String PR_SPEC;
+        private String BAR_LOCATION;
+
+        public String getBAR_LASTPRINTMAN() {
+            return BAR_LASTPRINTMAN;
+        }
+
+        public void setBAR_LASTPRINTMAN(String BAR_LASTPRINTMAN) {
+            this.BAR_LASTPRINTMAN = BAR_LASTPRINTMAN;
+        }
+
+        public String getBAR_WHCODE() {
+            return BAR_WHCODE;
+        }
+
+        public void setBAR_WHCODE(String BAR_WHCODE) {
+            this.BAR_WHCODE = BAR_WHCODE;
+        }
+
+        public double getBAR_REMAIN() {
+            return BAR_REMAIN;
+        }
+
+        public void setBAR_REMAIN(double BAR_REMAIN) {
+            this.BAR_REMAIN = BAR_REMAIN;
+        }
+
+        public String getMADEDATE() {
+            return MADEDATE;
+        }
+
+        public void setMADEDATE(String MADEDATE) {
+            this.MADEDATE = MADEDATE;
+        }
+
+        public String getVE_NAME() {
+            return VE_NAME;
+        }
+
+        public void setVE_NAME(String VE_NAME) {
+            this.VE_NAME = VE_NAME;
+        }
+
+        public String getPR_CODE() {
+            return PR_CODE;
+        }
+
+        public void setPR_CODE(String PR_CODE) {
+            this.PR_CODE = PR_CODE;
+        }
+
+        public Object getBAR_CODE() {
+            return BAR_CODE;
+        }
+
+        public void setBAR_CODE(Object BAR_CODE) {
+            this.BAR_CODE = BAR_CODE;
+        }
+
+        public String getBAR_LASTPRINTDATE() {
+            return BAR_LASTPRINTDATE;
+        }
+
+        public void setBAR_LASTPRINTDATE(String BAR_LASTPRINTDATE) {
+            this.BAR_LASTPRINTDATE = BAR_LASTPRINTDATE;
+        }
+
+        public Object getBAR_BATCHCODE() {
+            return BAR_BATCHCODE;
+        }
+
+        public void setBAR_BATCHCODE(Object BAR_BATCHCODE) {
+            this.BAR_BATCHCODE = BAR_BATCHCODE;
+        }
+
+        public String getBAR_VENDBARCODE() {
+            return BAR_VENDBARCODE;
+        }
+
+        public void setBAR_VENDBARCODE(String BAR_VENDBARCODE) {
+            this.BAR_VENDBARCODE = BAR_VENDBARCODE;
+        }
+
+        public Object getBAR_QR() {
+            return BAR_QR;
+        }
+
+        public void setBAR_QR(Object BAR_QR) {
+            this.BAR_QR = BAR_QR;
+        }
+
+        public String getPR_SPEC() {
+            return PR_SPEC;
+        }
+
+        public void setPR_SPEC(String PR_SPEC) {
+            this.PR_SPEC = PR_SPEC;
+        }
+
+        public String getBAR_LOCATION() {
+            return BAR_LOCATION;
+        }
+
+        public void setBAR_LOCATION(String BAR_LOCATION) {
+            this.BAR_LOCATION = BAR_LOCATION;
+        }
+    }
+}

+ 1 - 0
app/src/main/java/com/uas/pda_smart_com/fragment/BlueToothPrintFragment.java

@@ -52,6 +52,7 @@ public class BlueToothPrintFragment extends BaseFragment {
     private ImageView mRefreshImageView;
     private SwitchView mSwitchView;
     private TextView mDpiTextView;
+
     private RecyclerView mRecyclerView;
     private ConnectHelper connectHelper;
     private RotateAnimation mRotateAnimation;//动画

+ 230 - 0
app/src/main/java/com/uas/pda_smart_com/fragment/ModifyBarcodeQuantityFragment.java

@@ -1,44 +1,79 @@
 package com.uas.pda_smart_com.fragment;
 
 import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
 import android.content.Intent;
+import android.graphics.drawable.BitmapDrawable;
 import android.os.Bundle;
+import android.os.Message;
 import android.text.Editable;
 import android.text.TextUtils;
 import android.text.TextWatcher;
+import android.util.Log;
+import android.view.Gravity;
 import android.view.KeyEvent;
+import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.inputmethod.EditorInfo;
+import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.PopupWindow;
 import android.widget.TextView;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.android.volley.AuthFailureError;
 import com.android.volley.DefaultRetryPolicy;
 import com.android.volley.Request;
 import com.android.volley.Response;
 import com.android.volley.VolleyError;
 import com.android.volley.toolbox.StringRequest;
+import com.google.gson.Gson;
 import com.uas.pda_smart_com.R;
 import com.uas.pda_smart_com.activity.FunctionActivity;
 import com.uas.pda_smart_com.application.PdaApplication;
+import com.uas.pda_smart_com.bean.CodePrinBean;
+import com.uas.pda_smart_com.bean.WHBreakingBatchBreakingBtnClickEvent;
 import com.uas.pda_smart_com.global.GloableParams;
+import com.uas.pda_smart_com.tools.SharedPreUtil;
 import com.uas.pda_smart_com.tools.VolleyUtil;
 import com.uas.pda_smart_com.util.CameraUtil;
 import com.uas.pda_smart_com.util.CommonUtil;
 import com.uas.pda_smart_com.util.Constants;
+import com.uas.pda_smart_com.util.FastjsonUtil;
+import com.uas.pda_smart_com.util.FragmentUtils;
+import com.uas.pda_smart_com.util.HttpCallback;
+import com.uas.pda_smart_com.util.HttpParams;
 import com.uas.pda_smart_com.util.JsonUtils;
+import com.uas.pda_smart_com.util.PrintUtils;
+import com.uas.pda_smart_com.util.VolleyRequest;
 import com.uas.pda_smart_com.view.ClearableEditText;
+import com.umeng.commonsdk.debug.E;
 import com.uuzuche.lib_zxing.activity.CaptureActivity;
 import com.uuzuche.lib_zxing.activity.CodeUtils;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.FormBody;
+import okhttp3.RequestBody;
 
 /**
  * Created by RaoMeng on 2017/5/4.
@@ -58,6 +93,16 @@ public class ModifyBarcodeQuantityFragment extends BaseFragment {
     private boolean mIgnoreFocusChange = false;
     private boolean isShop = false;
 
+    private View popView;
+    private PopupWindow pop;
+    private Button btnBack, btnPrintf, btnClose, btnPrintfSet;
+    private List<WHBreakingBatchBreakingBtnClickEvent.DataBean> messages = new ArrayList<>();
+    private ListView listView;
+    private MyAdapter adapter;
+    private boolean isConnected = false;
+    private String mOldAddress = "";
+    private int mPrintDpi = 203;
+
     @Override
     protected int getLayout() {
         return R.layout.fragment_modify_barcode_quantity;
@@ -75,6 +120,10 @@ public class ModifyBarcodeQuantityFragment extends BaseFragment {
         mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
 
         mBarcodeEditText.requestFocus();
+
+        isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
+        mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
+        mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
     }
 
     @Override
@@ -155,6 +204,8 @@ public class ModifyBarcodeQuantityFragment extends BaseFragment {
                                             mResultTextView.setVisibility(View.VISIBLE);
                                             mResultTextView.setText("修改数量成功,条码:" + barcode + " 修改后数量为:" + quantity);
                                             mBarcodeEditText.requestFocus();
+
+                                            initPopupWindow(s);
                                         }
                                     } catch (JSONException e) {
                                         e.printStackTrace();
@@ -210,6 +261,181 @@ public class ModifyBarcodeQuantityFragment extends BaseFragment {
         });
     }
 
+
+    /**
+     * 蓝牙打印pop
+     * @param s
+     */
+    protected void initPopupWindow(String s) {
+        JSONArray listArray = new JSONArray();
+        try {
+            Gson gson = new Gson();
+            CodePrinBean codePrinBean = gson.fromJson(s, CodePrinBean.class);
+            if (codePrinBean.getData() == null){
+                return;
+            }
+            CodePrinBean.DataBean data = codePrinBean.getData();
+            String json = gson.toJson(data);
+            com.alibaba.fastjson.JSONObject resultObject = JSON.parseObject(json);
+            listArray.add(new com.alibaba.fastjson.JSONObject(resultObject));
+            messages.clear();
+            for (int i = 0; i < listArray.size(); i++) {
+                com.alibaba.fastjson.JSONObject barcodeObject = listArray.getJSONObject(i);
+                WHBreakingBatchBreakingBtnClickEvent.DataBean dataBean = new WHBreakingBatchBreakingBtnClickEvent.DataBean();
+                dataBean.setBAR_CODE(barcodeObject.getString("BAR_CODE"));
+                dataBean.setBAR_REMAIN(barcodeObject.getString("BAR_REMAIN"));
+                messages.add(dataBean);
+            }
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        popView = LayoutInflater.from(getActivity()).inflate(R.layout.popupwindow_whbreaking_batch, null);
+        listView = (ListView) popView.findViewById(R.id.list_view);
+        btnPrintf = (Button) popView.findViewById(R.id.btn_print);
+        btnPrintfSet = (Button) popView.findViewById(R.id.btn_print_setting);
+        btnClose = (Button) popView.findViewById(R.id.btn_close);
+        btnBack = (Button) popView.findViewById(R.id.btn_back);
+
+        btnBack.setVisibility(View.GONE);
+        btnClose.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                closePopupWindow();
+            }
+        });
+        btnPrintf.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (isConnected) {
+                    progressDialog.show();
+                    printEvent(listArray);
+                } else {
+                    closePopupWindow();
+
+                    BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
+                    Bundle bundle = new Bundle();
+                    bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
+                    blueToothPrintFragment.setArguments(bundle);
+                    FragmentUtils.switchFragment(ModifyBarcodeQuantityFragment.this, blueToothPrintFragment);
+                }
+            }
+        });
+
+        btnPrintfSet.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                closePopupWindow();
+
+                BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
+                Bundle bundle = new Bundle();
+                bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
+                blueToothPrintFragment.setArguments(bundle);
+                FragmentUtils.switchFragment(ModifyBarcodeQuantityFragment.this, blueToothPrintFragment);
+            }
+        });
+
+        MyAdapter adapter = new MyAdapter(getActivity(), R.layout.item_list_whbreakingbatchfragment, messages);
+        listView.setAdapter(adapter);
+        //当只有一条数据的时候可以加上
+        /*
+        if (messages.size()>1){
+            btnBack.setVisibility(View.GONE);
+        }*/
+        // PopupWindow实例化,参数的意思是 view,长(不包括状态栏),高(不包括状态栏),是否聚焦
+        pop = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT,
+                LinearLayout.LayoutParams.WRAP_CONTENT, true);
+        pop.setAnimationStyle(R.style.MenuAnimationFade);
+        pop.setBackgroundDrawable(new BitmapDrawable());
+        // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
+        pop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
+        pop.setOnDismissListener(new PopupWindow.OnDismissListener() {
+            @Override
+            public void onDismiss() {
+                closePopupWindow();
+            }
+        });
+        CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
+    }
+
+    /**
+     * 关闭窗口
+     */
+    private void closePopupWindow() {
+        if (pop != null) {
+            pop.dismiss();
+            pop = null;
+            CommonUtil.setBackgroundAlpha(mActivity, 1f);
+        }
+    }
+
+    public void reset() {
+        progressDialog.dismiss();
+    }
+
+    private void printEvent(JSONArray printArray) {
+        if (printArray != null && printArray.size() > 0) {
+            boolean isFail = false;
+            for (int i = 0; i < printArray.size(); i++) {
+                try {
+                    com.alibaba.fastjson.JSONObject printObject = printArray.getJSONObject(i);
+                    int printResult = PrintUtils.printBar(mActivity, printObject.toString(), mPrintDpi, null);
+                    if (printResult <= 0) {
+                        isFail = true;
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+            closePopupWindow();
+            progressDialog.dismiss();
+            if (isFail) {
+                isConnected = false;
+                SharedPreUtil.saveInt(mActivity, "printConnect", 0);
+                CommonUtil.toastNoRepeat(mActivity, "打印失败,请重新连接打印机");
+
+                BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
+
+                Bundle bundle = new Bundle();
+                bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, printArray.toString());
+                blueToothPrintFragment.setArguments(bundle);
+                FragmentUtils.switchFragment(ModifyBarcodeQuantityFragment.this, blueToothPrintFragment);
+            } else {
+                CommonUtil.toastNoRepeat(mActivity, "打印成功");
+            }
+        } else {
+            CommonUtil.toastNoRepeat(mActivity, "打印失败,条码数据为空");
+        }
+    }
+
+    /**
+     * popupWindow 设置适配器
+     */
+    private class MyAdapter extends ArrayAdapter<WHBreakingBatchBreakingBtnClickEvent.DataBean> {
+        private int resourceId;
+
+        public MyAdapter(Context context, int resource, List<WHBreakingBatchBreakingBtnClickEvent.DataBean> objects) {
+            super(context, resource, objects);
+            resourceId = resource;
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            //WHBreakingBatchBreakingBtnClickEvent.Message target = getItem(position);
+            WHBreakingBatchBreakingBtnClickEvent.DataBean person = getItem(position);
+            convertView = LayoutInflater.from(getContext()).inflate(resourceId, null);
+            TextView tv_bar_code = (TextView) convertView.findViewById(R.id.tv_bar_code);
+            TextView tv_bar_remain = (TextView) convertView.findViewById(R.id.tv_bar_remain);
+            // tv_bar_code.setText(target.bar_code);
+            // tv_bar_remain.setText(target.bar_remain);
+            tv_bar_code.setText(person.getBAR_CODE());
+            tv_bar_remain.setText(person.getBAR_REMAIN());
+            return convertView;
+        }
+    }
+
+
+
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
@@ -315,6 +541,10 @@ public class ModifyBarcodeQuantityFragment extends BaseFragment {
         if (!hidden) {
             FunctionActivity.setTitle("条码数量修改");
             ((FunctionActivity) mActivity).setScanIvVisible(true);
+
+            isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
+            mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
+            mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
         }
     }
 

+ 180 - 1
app/src/main/java/com/uas/pda_smart_com/fragment/WHCombineBatchFragment.java

@@ -8,6 +8,7 @@ import android.content.Intent;
 import android.graphics.drawable.BitmapDrawable;
 import android.net.Uri;
 import android.os.Build;
+import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
 import android.support.v4.content.FileProvider;
@@ -30,6 +31,8 @@ import android.widget.PopupWindow;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.android.volley.AuthFailureError;
 import com.android.volley.Request;
 import com.android.volley.RequestQueue;
@@ -40,16 +43,21 @@ import com.android.volley.toolbox.Volley;
 import com.google.gson.Gson;
 import com.uas.pda_smart_com.R;
 import com.uas.pda_smart_com.activity.FunctionActivity;
+import com.uas.pda_smart_com.bean.CodePrinBean;
+import com.uas.pda_smart_com.bean.WHBreakingBatchBreakingBtnClickEvent;
 import com.uas.pda_smart_com.bean.WHBreakingBatchGetBarcodeData;
 import com.uas.pda_smart_com.bean.WHCombineBatchFragmentCombineBtnClickEvent;
 import com.uas.pda_smart_com.global.GloableParams;
+import com.uas.pda_smart_com.tools.SharedPreUtil;
 import com.uas.pda_smart_com.tools.VolleyUtil;
 import com.uas.pda_smart_com.util.CameraUtil;
 import com.uas.pda_smart_com.util.CommonUtil;
 import com.uas.pda_smart_com.util.Constants;
 import com.uas.pda_smart_com.util.FileUtils;
+import com.uas.pda_smart_com.util.FragmentUtils;
 import com.uas.pda_smart_com.util.JsonTools;
 import com.uas.pda_smart_com.util.LogUtil;
+import com.uas.pda_smart_com.util.PrintUtils;
 import com.uas.pda_smart_com.view.ClearableEditText;
 import com.uuzuche.lib_zxing.activity.CaptureActivity;
 import com.uuzuche.lib_zxing.activity.CodeUtils;
@@ -88,6 +96,13 @@ public class WHCombineBatchFragment extends BaseFragment implements View.OnClick
     private int lastPress = 0;
     private boolean delState = false;
     private String mPrintUrl = "";
+
+    private ListView listPrintView;
+    private boolean isConnected = false;
+    private String mOldAddress = "";
+    private int mPrintDpi = 203;
+    private List<WHBreakingBatchBreakingBtnClickEvent.DataBean> messages = new ArrayList<>();
+
     private Handler mHandler = new Handler() {
         @Override
         public void handleMessage(Message msg) {
@@ -149,6 +164,10 @@ public class WHCombineBatchFragment extends BaseFragment implements View.OnClick
         myAdapter = new MyAdapter(getActivity(), R.layout.item_list_whcombatchfragment, dataList);
         listView.setAdapter(myAdapter);
         btnMerge = (Button) root.findViewById(R.id.btn_merge);
+
+        isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
+        mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
+        mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
     }
 
     @Override
@@ -497,7 +516,10 @@ public class WHCombineBatchFragment extends BaseFragment implements View.OnClick
                 sum = 0;
                 tvToatal.setText(sum + "");
                 btnMerge.setEnabled(false);
-                initPopuptWindow(whc2.getData().getBAR_CODE(), CommonUtil.doubleFormat(whc2.getData().getBAR_REMAIN()));
+                //下载pdf文件在其它打印APP打印
+//                initPopuptWindow(whc2.getData().getBAR_CODE(), CommonUtil.doubleFormat(whc2.getData().getBAR_REMAIN()));
+                //蓝牙打印机打印
+                initPrintPopupWindow(s);
             }
         }, new Response.ErrorListener() {
             @Override
@@ -533,6 +555,102 @@ public class WHCombineBatchFragment extends BaseFragment implements View.OnClick
 
     }
 
+    /**
+     * 蓝牙打印pop
+     * @param s
+     */
+    protected void initPrintPopupWindow(String s) {
+        JSONArray listArray = new JSONArray();
+        try {
+            Gson gson = new Gson();
+            CodePrinBean codePrinBean = gson.fromJson(s, CodePrinBean.class);
+            if (codePrinBean.getData() == null){
+                return;
+            }
+            CodePrinBean.DataBean data = codePrinBean.getData();
+            String json = gson.toJson(data);
+            com.alibaba.fastjson.JSONObject resultObject = JSON.parseObject(json);
+            listArray.add(new com.alibaba.fastjson.JSONObject(resultObject));
+            messages.clear();
+            for (int i = 0; i < listArray.size(); i++) {
+                com.alibaba.fastjson.JSONObject barcodeObject = listArray.getJSONObject(i);
+                WHBreakingBatchBreakingBtnClickEvent.DataBean dataBean = new WHBreakingBatchBreakingBtnClickEvent.DataBean();
+                dataBean.setBAR_CODE(barcodeObject.getString("BAR_CODE"));
+                dataBean.setBAR_REMAIN(barcodeObject.getString("BAR_REMAIN"));
+                messages.add(dataBean);
+            }
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        popView = LayoutInflater.from(getActivity()).inflate(R.layout.popupwindow_whbreaking_batch, null);
+        listPrintView = (ListView) popView.findViewById(R.id.list_view);
+        Button btnPrintf = (Button) popView.findViewById(R.id.btn_print);
+        Button btnPrintfSet = (Button) popView.findViewById(R.id.btn_print_setting);
+        Button btnClose = (Button) popView.findViewById(R.id.btn_close);
+        Button btnBack = (Button) popView.findViewById(R.id.btn_back);
+
+        btnBack.setVisibility(View.GONE);
+        btnClose.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                closePopupWindow();
+            }
+        });
+        btnPrintf.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (isConnected) {
+                    progressDialog.show();
+                    printEvent(listArray);
+                } else {
+                    closePopupWindow();
+
+                    BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
+                    Bundle bundle = new Bundle();
+                    bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
+                    blueToothPrintFragment.setArguments(bundle);
+                    FragmentUtils.switchFragment(WHCombineBatchFragment.this, blueToothPrintFragment);
+                }
+            }
+        });
+
+        btnPrintfSet.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                closePopupWindow();
+
+                BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
+                Bundle bundle = new Bundle();
+                bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
+                blueToothPrintFragment.setArguments(bundle);
+                FragmentUtils.switchFragment(WHCombineBatchFragment.this, blueToothPrintFragment);
+            }
+        });
+
+        MyPrintAdapter adapter = new MyPrintAdapter(getActivity(), R.layout.item_list_whbreakingbatchfragment, messages);
+        listPrintView.setAdapter(adapter);
+        //当只有一条数据的时候可以加上
+        /*
+        if (messages.size()>1){
+            btnBack.setVisibility(View.GONE);
+        }*/
+        // PopupWindow实例化,参数的意思是 view,长(不包括状态栏),高(不包括状态栏),是否聚焦
+        pop = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT,
+                LinearLayout.LayoutParams.WRAP_CONTENT, true);
+        pop.setAnimationStyle(R.style.MenuAnimationFade);
+        pop.setBackgroundDrawable(new BitmapDrawable());
+        // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
+        pop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
+        pop.setOnDismissListener(new PopupWindow.OnDismissListener() {
+            @Override
+            public void onDismiss() {
+                closePopupWindow();
+            }
+        });
+        CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
+    }
+
     public static final String GETPRINTDATA = "getPrintData";
 
     private void getPrintData() {
@@ -642,4 +760,65 @@ public class WHCombineBatchFragment extends BaseFragment implements View.OnClick
             return convertView;
         }
     }
+
+    private void printEvent(JSONArray printArray) {
+        if (printArray != null && printArray.size() > 0) {
+            boolean isFail = false;
+            for (int i = 0; i < printArray.size(); i++) {
+                try {
+                    com.alibaba.fastjson.JSONObject printObject = printArray.getJSONObject(i);
+                    int printResult = PrintUtils.printBar(mActivity, printObject.toString(), mPrintDpi, null);
+                    if (printResult <= 0) {
+                        isFail = true;
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+            closePopupWindow();
+            progressDialog.dismiss();
+            if (isFail) {
+                isConnected = false;
+                SharedPreUtil.saveInt(mActivity, "printConnect", 0);
+                CommonUtil.toastNoRepeat(mActivity, "打印失败,请重新连接打印机");
+
+                BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
+
+                Bundle bundle = new Bundle();
+                bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, printArray.toString());
+                blueToothPrintFragment.setArguments(bundle);
+                FragmentUtils.switchFragment(WHCombineBatchFragment.this, blueToothPrintFragment);
+            } else {
+                CommonUtil.toastNoRepeat(mActivity, "打印成功");
+            }
+        } else {
+            CommonUtil.toastNoRepeat(mActivity, "打印失败,条码数据为空");
+        }
+    }
+
+    /**
+     * popupWindow 设置适配器
+     */
+    private class MyPrintAdapter extends ArrayAdapter<WHBreakingBatchBreakingBtnClickEvent.DataBean> {
+        private int resourceId;
+
+        public MyPrintAdapter(Context context, int resource, List<WHBreakingBatchBreakingBtnClickEvent.DataBean> objects) {
+            super(context, resource, objects);
+            resourceId = resource;
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            //WHBreakingBatchBreakingBtnClickEvent.Message target = getItem(position);
+            WHBreakingBatchBreakingBtnClickEvent.DataBean person = getItem(position);
+            convertView = LayoutInflater.from(getContext()).inflate(resourceId, null);
+            TextView tv_bar_code = (TextView) convertView.findViewById(R.id.tv_bar_code);
+            TextView tv_bar_remain = (TextView) convertView.findViewById(R.id.tv_bar_remain);
+            // tv_bar_code.setText(target.bar_code);
+            // tv_bar_remain.setText(target.bar_remain);
+            tv_bar_code.setText(person.getBAR_CODE());
+            tv_bar_remain.setText(person.getBAR_REMAIN());
+            return convertView;
+        }
+    }
 }

+ 2 - 2
build.gradle

@@ -50,8 +50,8 @@ ext {
             targetSdkVersion : 28,
             compileSdkVersion: 28,
             buildToolsVersion: "28.0.3",
-            versionCode      : 28,
-            versionName      : "v2.2.6"
+            versionCode      : 29,
+            versionName      : "v2.2.7"
     ]
 
     depsVersion = [