|
@@ -1,6 +1,7 @@
|
|
|
package com.uas.jc_wms.fragment;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
+import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
@@ -8,20 +9,27 @@ import android.os.Bundle;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.text.TextUtils;
|
|
|
+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.CheckBox;
|
|
|
import android.widget.CompoundButton;
|
|
|
import android.widget.EditText;
|
|
|
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.JSONObject;
|
|
|
import com.android.volley.Request;
|
|
|
+import com.android.volley.toolbox.StringRequest;
|
|
|
import com.bin.david.form.core.SmartTable;
|
|
|
import com.bin.david.form.data.column.Column;
|
|
|
import com.bin.david.form.data.format.IFormat;
|
|
@@ -29,16 +37,21 @@ import com.bin.david.form.data.table.TableData;
|
|
|
import com.uas.jc_wms.R;
|
|
|
import com.uas.jc_wms.activity.FunctionActivity;
|
|
|
import com.uas.jc_wms.bean.InventoryCollctBean;
|
|
|
+import com.uas.jc_wms.bean.WHBreakingBatchBreakingBtnClickEventNew;
|
|
|
import com.uas.jc_wms.global.GloableParams;
|
|
|
import com.uas.jc_wms.listener.MyEditorActionListener;
|
|
|
+import com.uas.jc_wms.tools.SharedPreUtil;
|
|
|
import com.uas.jc_wms.util.CameraUtil;
|
|
|
import com.uas.jc_wms.util.CommonUtil;
|
|
|
+import com.uas.jc_wms.util.Constants;
|
|
|
import com.uas.jc_wms.util.FastjsonUtil;
|
|
|
import com.uas.jc_wms.util.FragmentUtils;
|
|
|
import com.uas.jc_wms.util.HttpCallback;
|
|
|
import com.uas.jc_wms.util.HttpParams;
|
|
|
+import com.uas.jc_wms.util.PrintUtils;
|
|
|
import com.uas.jc_wms.util.StringUtil;
|
|
|
import com.uas.jc_wms.util.VolleyRequest;
|
|
|
+import com.uas.jc_wms.util.VollyRequest;
|
|
|
import com.uas.jc_wms.view.ClearableEditText;
|
|
|
import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
@@ -60,6 +73,7 @@ public class InventoryCollectFragment extends BaseFragment implements View.OnCli
|
|
|
private String pi_inoutno, pi_id, pi_class;
|
|
|
private CheckBox cb_caiji;
|
|
|
private boolean isChecked=false;
|
|
|
+ private Button btn_oneprint, bt_inventory_barcode_printing;
|
|
|
|
|
|
private SmartTable mSmartTable;
|
|
|
private Column<String> ST_WHCODE, STD_PRODCODE, PR_DETAIL, BAR_LOCATION, PR_SPEC;
|
|
@@ -70,6 +84,13 @@ public class InventoryCollectFragment extends BaseFragment implements View.OnCli
|
|
|
private String bar_remain;
|
|
|
private AlertDialog alertDialog;
|
|
|
|
|
|
+ private List<WHBreakingBatchBreakingBtnClickEventNew.DataBean> messages = new ArrayList<>();
|
|
|
+ private PopupWindow splitPop;
|
|
|
+ private boolean isConnected = false;
|
|
|
+ private String mOldAddress = "";
|
|
|
+ private int mPrintDpi = 203;
|
|
|
+ private boolean isPrinting = false;
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_inventory_collect;
|
|
@@ -89,7 +110,7 @@ public class InventoryCollectFragment extends BaseFragment implements View.OnCli
|
|
|
mClassTextView = root.findViewById(R.id.inventory_collect_class_tv);
|
|
|
cb_caiji=root.findViewById(R.id.cb_caiji);
|
|
|
tvPiInoutno=root.findViewById(R.id.tv_pi_inoutno);
|
|
|
-
|
|
|
+ bt_inventory_barcode_printing = root.findViewById(R.id.bt_inventory_barcode_printing);
|
|
|
|
|
|
mBarcodeEditText.requestFocus();
|
|
|
|
|
@@ -113,6 +134,10 @@ public class InventoryCollectFragment extends BaseFragment implements View.OnCli
|
|
|
}
|
|
|
});
|
|
|
PR_SPEC = new Column<String>("规格", "PR_SPEC");
|
|
|
+
|
|
|
+ isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
|
|
|
+ mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
|
|
|
+ mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -363,6 +388,216 @@ public class InventoryCollectFragment extends BaseFragment implements View.OnCli
|
|
|
getDataList();
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ bt_inventory_barcode_printing.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ getWhcode();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getWhcode() {
|
|
|
+ View mPopView = View.inflate(mActivity, R.layout.pop_inventory_barcode_dialog, null);
|
|
|
+ ClearableEditText cet_barcode = (ClearableEditText) mPopView.findViewById(R.id.cet_barcode);
|
|
|
+ Button bt_ok = (Button) mPopView.findViewById(R.id.bt_ok);
|
|
|
+ AlertDialog mWarehouseDialog = new AlertDialog.Builder(mActivity)
|
|
|
+ .setView(mPopView)
|
|
|
+ .create();
|
|
|
+ mWarehouseDialog.show();
|
|
|
+
|
|
|
+ cet_barcode.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_SEND
|
|
|
+ || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ if (!TextUtils.isEmpty(cet_barcode.getText().toString().trim())) {
|
|
|
+ getInvertoryBarcode(cet_barcode.getText().toString().trim());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ bt_ok.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mWarehouseDialog.cancel();
|
|
|
+ getInvertoryBarcode(cet_barcode.getText().toString().trim());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private void getInvertoryBarcode(String barcode) {
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_GET_INVENTORY_BARCODE_DATA)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "getInvertoryBarcode")
|
|
|
+ .addParam("code", barcode)
|
|
|
+ .flag(0)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
|
|
|
+ com.alibaba.fastjson.JSONObject data = FastjsonUtil.getJSONObject(o.toString(), "data");
|
|
|
+ // com.alibaba.fastjson.JSONArray dataArray = FastjsonUtil.getJSONArray(data.toString(), "data");
|
|
|
+ if (isSuccess) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson.JSONArray listArray = new com.alibaba.fastjson.JSONArray();
|
|
|
+ String data1 = data.getString("data");
|
|
|
+ listArray.add(JSON.parseObject(data1));
|
|
|
+ initBreakPopupWindow(listArray);
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void initBreakPopupWindow(com.alibaba.fastjson.JSONArray listArray) {
|
|
|
+ messages.clear();
|
|
|
+ for (int i = 0; i < listArray.size(); i++) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson.JSONObject barcodeObject = listArray.getJSONObject(i);
|
|
|
+ if (barcodeObject != null) {
|
|
|
+ WHBreakingBatchBreakingBtnClickEventNew.DataBean dataBean = new WHBreakingBatchBreakingBtnClickEventNew.DataBean();
|
|
|
+ dataBean.setBAR_CODE(barcodeObject.getString("BAR_CODE"));
|
|
|
+ dataBean.setBAR_REMAIN(barcodeObject.getString("BAR_REMAIN"));//RESTQTY
|
|
|
+ messages.add(dataBean);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ View popView = LayoutInflater.from(getActivity()).inflate(R.layout.popupwindow_whbreaking_batch, null);
|
|
|
+ ListView listView = (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) {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ btnPrintf.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (isConnected) {
|
|
|
+ progressDialog.show();
|
|
|
+ printEvent(listArray);
|
|
|
+ } else {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
|
|
|
+
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
|
|
|
+ blueToothPrintFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(InventoryCollectFragment.this, blueToothPrintFragment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ btnPrintfSet.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
|
|
|
+
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
|
|
|
+ blueToothPrintFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(InventoryCollectFragment.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,长(不包括状态栏),高(不包括状态栏),是否聚焦
|
|
|
+ splitPop = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
|
+ LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ splitPop.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
+ splitPop.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
|
|
|
+ splitPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
+ splitPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ // confirmEvent();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closeSplitPopupWindow() {
|
|
|
+ if (splitPop != null) {
|
|
|
+ splitPop.dismiss();
|
|
|
+ splitPop = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void printEvent(com.alibaba.fastjson.JSONArray printArray) {
|
|
|
+ if (isPrinting) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "正在打印中,请勿重复操作");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isPrinting = true;
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ 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(InventoryCollectFragment.this, blueToothPrintFragment);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印成功");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印失败,条码数据为空");
|
|
|
+ }
|
|
|
+ isPrinting = false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -534,6 +769,10 @@ public class InventoryCollectFragment extends BaseFragment implements View.OnCli
|
|
|
((FunctionActivity) getActivity()).setTitle("盘点作业");
|
|
|
((FunctionActivity) getActivity()).setMoreBtnVisible(true);
|
|
|
mBarcodeEditText.requestFocus();
|
|
|
+
|
|
|
+ isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
|
|
|
+ mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
|
|
|
+ mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
|
|
|
} else {
|
|
|
((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
}
|
|
@@ -569,4 +808,30 @@ public class InventoryCollectFragment extends BaseFragment implements View.OnCli
|
|
|
super.onDestroyView();
|
|
|
((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
}
|
|
|
+
|
|
|
+ private class MyAdapter extends ArrayAdapter<WHBreakingBatchBreakingBtnClickEventNew.DataBean> {
|
|
|
+ private int resourceId;
|
|
|
+
|
|
|
+ public MyAdapter(Context context, int resource, List<WHBreakingBatchBreakingBtnClickEventNew.DataBean> objects) {
|
|
|
+ super(context, resource, objects);
|
|
|
+ resourceId = resource;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ //WHBreakingBatchBreakingBtnClickEventNew.Message target = getItem(position);
|
|
|
+ WHBreakingBatchBreakingBtnClickEventNew.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;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|