|
|
@@ -0,0 +1,837 @@
|
|
|
+package com.uas.keg_wms_new.fragment;
|
|
|
+
|
|
|
+import android.app.Activity;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+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;
|
|
|
+import com.bin.david.form.data.table.TableData;
|
|
|
+import com.uas.keg_wms_new.R;
|
|
|
+import com.uas.keg_wms_new.activity.FunctionActivity;
|
|
|
+import com.uas.keg_wms_new.bean.InventoryCollctBean;
|
|
|
+import com.uas.keg_wms_new.bean.WHBreakingBatchBreakingBtnClickEventNew;
|
|
|
+import com.uas.keg_wms_new.global.GloableParams;
|
|
|
+import com.uas.keg_wms_new.listener.MyEditorActionListener;
|
|
|
+import com.uas.keg_wms_new.tools.SharedPreUtil;
|
|
|
+import com.uas.keg_wms_new.util.CameraUtil;
|
|
|
+import com.uas.keg_wms_new.util.CommonUtil;
|
|
|
+import com.uas.keg_wms_new.util.Constants;
|
|
|
+import com.uas.keg_wms_new.util.FastjsonUtil;
|
|
|
+import com.uas.keg_wms_new.util.FragmentUtils;
|
|
|
+import com.uas.keg_wms_new.util.HttpCallback;
|
|
|
+import com.uas.keg_wms_new.util.HttpParams;
|
|
|
+import com.uas.keg_wms_new.util.PrintUtils;
|
|
|
+import com.uas.keg_wms_new.util.StringUtil;
|
|
|
+import com.uas.keg_wms_new.util.VolleyRequest;
|
|
|
+import com.uas.keg_wms_new.util.VollyRequest;
|
|
|
+import com.uas.keg_wms_new.view.ClearableEditText;
|
|
|
+import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
+import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by RaoMeng on 2019/3/23
|
|
|
+ * Desc: 盘点采集页面
|
|
|
+ */
|
|
|
+public class InventoryCollectFragment2 extends BaseFragment implements View.OnClickListener {
|
|
|
+ private static final int SCAN_BARCODE_CODE = 101;
|
|
|
+ private ClearableEditText mTagEditText, mBarcodeEditText;
|
|
|
+ private ImageView mScanImageView;
|
|
|
+ private TextView mResultTextView, mNumTextView, mClassTextView,tvPiInoutno;
|
|
|
+ private Button mMoreButton;
|
|
|
+ private PopupWindow mMenuPopupWindow;
|
|
|
+ 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;
|
|
|
+ private Column<Double> STD_BATCHQTY, STD_ACTQTY;
|
|
|
+ private TableData<InventoryCollctBean> mTableData;
|
|
|
+ private List<InventoryCollctBean> mStockTaskMultipleBeans;
|
|
|
+ private CheckBox mCheckBox;
|
|
|
+ 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_collect2;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ ((FunctionActivity) getActivity()).setTitle("盘点作业");
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
|
|
|
+
|
|
|
+ mMoreButton = mActivity.findViewById(R.id.btn_actionbar_more);
|
|
|
+ mTagEditText = root.findViewById(R.id.inventory_collect_tag_et);
|
|
|
+ mBarcodeEditText = root.findViewById(R.id.inventory_collect_barcode_et);
|
|
|
+ mScanImageView = root.findViewById(R.id.inventory_collect_scan_iv);
|
|
|
+ mResultTextView = root.findViewById(R.id.inventory_collect_result_tv);
|
|
|
+ mNumTextView = root.findViewById(R.id.inventory_collect_num_tv);
|
|
|
+ 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();
|
|
|
+
|
|
|
+ mCheckBox = root.findViewById(R.id.stock_data_summary_cb);
|
|
|
+ mSmartTable = root.findViewById(R.id.st_data);
|
|
|
+ CommonUtil.getDefaultTable(mActivity, mSmartTable);
|
|
|
+ ST_WHCODE = new Column<String>("仓库", "ST_WHCODE");
|
|
|
+ STD_PRODCODE = new Column<String>("料号", "STD_PRODCODE");
|
|
|
+ PR_DETAIL = new Column<String>("名称", "PR_DETAIL");
|
|
|
+ BAR_LOCATION = new Column<String>("储位", "BAR_LOCATION");
|
|
|
+ STD_BATCHQTY = new Column<Double>("账面库存", "STD_BATCHQTY", new IFormat<Double>() {
|
|
|
+ @Override
|
|
|
+ public String format(Double aDouble) {
|
|
|
+ return CommonUtil.doubleFormat(aDouble);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ STD_ACTQTY = new Column<Double>("实盘库存", "STD_ACTQTY", new IFormat<Double>() {
|
|
|
+ @Override
|
|
|
+ public String format(Double aDouble) {
|
|
|
+ return CommonUtil.doubleFormat(aDouble);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ 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
|
|
|
+ protected void initEvents() {
|
|
|
+ mMoreButton.setOnClickListener(this);
|
|
|
+ mScanImageView.setOnClickListener(this);
|
|
|
+ cb_caiji.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ InventoryCollectFragment2.this.isChecked=isChecked;
|
|
|
+ }
|
|
|
+ });
|
|
|
+// mTagEditText.setOnFocusChangeListener(new View.OnFocusChangeListen) {
|
|
|
+// @Override
|
|
|
+// public void onFocusChange(View v, boolean hasFocus) {
|
|
|
+// if (!hasFocus) {
|
|
|
+// String tag = mTagEditText.getText().toString().trim();
|
|
|
+// SharedPreUtil.saveString(mActivity, Constants.FLAG.INVENTORY_DC_TIME_CACHE, tag);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// CommonUtil.setEditorActionListener(mTagEditText, new MyEditorActionListener() {
|
|
|
+// @Override
|
|
|
+// public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
+// SharedPreUtil.saveString(mActivity, Constants.FLAG.INVENTORY_DC_TIME_CACHE, text);
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+ CommonUtil.setEditorActionListener(mBarcodeEditText, new MyEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
+// String deadLine = mTagEditText.getText().toString().trim();
|
|
|
+ String barcode = mBarcodeEditText.getText().toString().trim();
|
|
|
+
|
|
|
+// if (TextUtils.isEmpty(deadLine)) {
|
|
|
+// CommonUtil.toastNoRepeat(mActivity, "请输入临界校验日期");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(barcode)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请采集条码");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ progressDialog.show();
|
|
|
+ if (isChecked) {
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_BARSTOCK_GETBARCODEINFO)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "getbarcodeinfo")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("inoutno", pi_inoutno)
|
|
|
+ //.addParam("deadline", deadLine)
|
|
|
+ .addParam("barcode", barcode)
|
|
|
+ .addParam("iscancel", isChecked + "")
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ try {
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ String type = FastjsonUtil.getText(dataObject, "BI_TYPE");
|
|
|
+ String prompt = "采集成功!";
|
|
|
+ if (!"超期".equals(type)) {
|
|
|
+ mResultTextView.setTextColor(mActivity.getResources().getColor(R.color.black));
|
|
|
+ prompt = "采集成功!";
|
|
|
+ } else {
|
|
|
+ mResultTextView.setTextColor(mActivity.getResources().getColor(R.color.red));
|
|
|
+ prompt = "采集成功!已超期";
|
|
|
+ }
|
|
|
+ mResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mResultTextView.setText(prompt
|
|
|
+ + "\n物料:" + FastjsonUtil.getText(dataObject, "BI_PRODCODE")
|
|
|
+ // + "\n品牌:" + FastjsonUtil.getText(dataObject, "BI_BRAND")
|
|
|
+ // + "\nLOTNO:" + FastjsonUtil.getText(dataObject, "BI_LOTNO")
|
|
|
+ // + "\nDC:" + FastjsonUtil.getText(dataObject, "BI_DATECODE")
|
|
|
+ + "\n型号:" + FastjsonUtil.getText(dataObject, "PR_ORISPECCODE")
|
|
|
+ + "\n条码号:" + FastjsonUtil.getText(dataObject, "BI_BARCODE")
|
|
|
+ + "\n数量:" + FastjsonUtil.getText(dataObject, "BI_INQTY")
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ mResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mResultTextView.setText(failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_GET_BARCODE_DATA)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "getbarcodeinfo")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("barcode", barcode)
|
|
|
+// .addParam("code", pi_inoutno)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ bar_remain = "";
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ bar_remain = FastjsonUtil.getText(dataObject, "BAR_REMAIN");
|
|
|
+ }
|
|
|
+
|
|
|
+ View dialogView = View.inflate(getActivity(), R.layout.dialog_confirm_quantity, null);
|
|
|
+ final EditText modifyEditText = dialogView.findViewById(R.id.recharge_modify_et);
|
|
|
+
|
|
|
+// TextView tv_uninventoried_quantity = dialogView.findViewById(R.id.tv_uninventoried_quantity);
|
|
|
+// TextView tv_material_no = dialogView.findViewById(R.id.tv_material_no);
|
|
|
+// TextView tv_material_name = dialogView.findViewById(R.id.tv_material_name);
|
|
|
+// TextView tv_material_specification = dialogView.findViewById(R.id.tv_material_specification);
|
|
|
+//
|
|
|
+// tv_uninventoried_quantity.setText(FastjsonUtil.getText(dataObject, "UNQTY"));
|
|
|
+// tv_material_no.setText(FastjsonUtil.getText(dataObject, "BAR_PRODCODE"));
|
|
|
+// tv_material_name.setText(FastjsonUtil.getText(dataObject, "PR_DETAIL"));
|
|
|
+// tv_material_specification.setText(FastjsonUtil.getText(dataObject, "PR_SPEC"));
|
|
|
+
|
|
|
+ alertDialog = new AlertDialog.Builder(getActivity()).setTitle("确认数量")
|
|
|
+ .setView(dialogView)
|
|
|
+ .setNegativeButton(R.string.cancel, null)
|
|
|
+ .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ if (StringUtil.isEmpty(modifyEditText.getText().toString().trim())) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "请输入条码数量");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ double quantity = -1;
|
|
|
+ try {
|
|
|
+ quantity = Double.parseDouble(modifyEditText.getText().toString().trim());
|
|
|
+ } catch (Exception e) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "请输入正确的数字");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (quantity < 0) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "数量不能小于0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_BARSTOCK_GETBARCODEINFO)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "getbarcodeinfo")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("inoutno", pi_inoutno)
|
|
|
+ //.addParam("deadline", deadLine)
|
|
|
+ .addParam("barcode", barcode)
|
|
|
+ .addParam("iscancel", isChecked + "")
|
|
|
+ .addParam("bar_remain", modifyEditText.getText().toString().trim())
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ alertDialog.dismiss();
|
|
|
+ try {
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ String type = FastjsonUtil.getText(dataObject, "BI_TYPE");
|
|
|
+ String prompt = "采集成功!";
|
|
|
+ if (!"超期".equals(type)) {
|
|
|
+ mResultTextView.setTextColor(mActivity.getResources().getColor(R.color.black));
|
|
|
+ prompt = "采集成功!";
|
|
|
+ } else {
|
|
|
+ mResultTextView.setTextColor(mActivity.getResources().getColor(R.color.red));
|
|
|
+ prompt = "采集成功!已超期";
|
|
|
+ }
|
|
|
+
|
|
|
+ mResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mResultTextView.setText(prompt
|
|
|
+ + "\n物料:" + FastjsonUtil.getText(dataObject, "BI_PRODCODE")
|
|
|
+ // + "\n品牌:" + FastjsonUtil.getText(dataObject, "BI_BRAND")
|
|
|
+ // + "\nLOTNO:" + FastjsonUtil.getText(dataObject, "BI_LOTNO")
|
|
|
+ // + "\nDC:" + FastjsonUtil.getText(dataObject, "BI_DATECODE")
|
|
|
+ + "\n型号:" + FastjsonUtil.getText(dataObject, "PR_ORISPECCODE")
|
|
|
+ + "\n条码号:" + FastjsonUtil.getText(dataObject, "BI_BARCODE")
|
|
|
+ + "\n数量:" + FastjsonUtil.getText(dataObject, "BI_INQTY")
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ alertDialog.dismiss();
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ mResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mResultTextView.setText(failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).create();
|
|
|
+ modifyEditText.setText(bar_remain);
|
|
|
+ modifyEditText.setSelection(modifyEditText.getText().length());
|
|
|
+// alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
|
|
|
+// @Override
|
|
|
+// public void onClick(View view) {
|
|
|
+//
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+ // 禁用屏幕外点击
|
|
|
+ alertDialog.setCancelable(false);
|
|
|
+ alertDialog.setCanceledOnTouchOutside(false);
|
|
|
+ alertDialog.show();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ mResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mResultTextView.setText(failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ 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");
|
|
|
+ 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 {
|
|
|
+ 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(InventoryCollectFragment2.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(InventoryCollectFragment2.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 {
|
|
|
+ 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(InventoryCollectFragment2.this, blueToothPrintFragment);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印成功");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印失败,条码数据为空");
|
|
|
+ }
|
|
|
+ isPrinting = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ Bundle bundle = getArguments();
|
|
|
+ if (bundle != null) {
|
|
|
+ pi_inoutno = bundle.getString("pi_inoutno");
|
|
|
+ pi_id = bundle.getString("pi_id");
|
|
|
+ pi_class = bundle.getString("pi_class");
|
|
|
+
|
|
|
+ mNumTextView.setText(pi_inoutno);
|
|
|
+ mClassTextView.setText(pi_class);
|
|
|
+ }
|
|
|
+
|
|
|
+// String deadLine = SharedPreUtil.getString(mActivity, Constants.FLAG.INVENTORY_DC_TIME_CACHE, "");
|
|
|
+// if (!TextUtils.isEmpty(deadLine)) {
|
|
|
+// mTagEditText.setText(deadLine);
|
|
|
+// mBarcodeEditText.requestFocus();
|
|
|
+// } else {
|
|
|
+// mTagEditText.requestFocus();
|
|
|
+// }
|
|
|
+
|
|
|
+ if (pi_inoutno != null) {
|
|
|
+ tvPiInoutno.setText(pi_inoutno);
|
|
|
+ }
|
|
|
+
|
|
|
+ mStockTaskMultipleBeans = new ArrayList<>();
|
|
|
+ setTableData(mStockTaskMultipleBeans);
|
|
|
+ getDataList();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getDataList() {
|
|
|
+ progressDialog.show();
|
|
|
+ mStockTaskMultipleBeans.clear();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_GET_PRE_MATERIAL_LIST)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("code", pi_id)
|
|
|
+ .addParam("showall", mCheckBox.isChecked() ? "-1" : "0")
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ com.alibaba.fastjson.JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.getJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ //物料编号pr_code,物料名称pr_detail,出库数量pd_outqty,已采集数量pd_pdaqty,'
|
|
|
+ // 仓库pd_whcode,仓位V_PW_WHCODE,实物库存V_PW_ONHAND,
|
|
|
+ // 条码库存V_BA_REMAIN,型号PR_ORISPECCODE
|
|
|
+ InventoryCollctBean inventoryCollctBean = new InventoryCollctBean();
|
|
|
+ inventoryCollctBean.setST_WHCODE(FastjsonUtil.getText(dataObject, "ST_WHCODE"));
|
|
|
+ inventoryCollctBean.setSTD_PRODCODE(FastjsonUtil.getText(dataObject, "STD_PRODCODE"));
|
|
|
+ inventoryCollctBean.setPR_DETAIL(FastjsonUtil.getText(dataObject, "PR_DETAIL"));
|
|
|
+ inventoryCollctBean.setBAR_LOCATION(FastjsonUtil.getText(dataObject, "BAR_LOCATION"));
|
|
|
+ inventoryCollctBean.setSTD_BATCHQTY(FastjsonUtil.getDouble(dataObject, "STD_BATCHQTY"));
|
|
|
+ inventoryCollctBean.setSTD_ACTQTY(FastjsonUtil.getDouble(dataObject, "STD_ACTQTY"));
|
|
|
+ inventoryCollctBean.setPR_SPEC(FastjsonUtil.getText(dataObject, "PR_SPEC"));
|
|
|
+ mStockTaskMultipleBeans.add(inventoryCollctBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setTableData(mStockTaskMultipleBeans);
|
|
|
+ } catch (Exception e) {
|
|
|
+ setTableData(mStockTaskMultipleBeans);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ setTableData(mStockTaskMultipleBeans);
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setTableData(List<InventoryCollctBean> filterTableData) {
|
|
|
+ mTableData = new TableData<InventoryCollctBean>("出库单列表", filterTableData,
|
|
|
+ ST_WHCODE, STD_PRODCODE, PR_DETAIL, BAR_LOCATION, STD_BATCHQTY, STD_ACTQTY, PR_SPEC);
|
|
|
+ mSmartTable.setTableData(mTableData);
|
|
|
+ mSmartTable.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mSmartTable.postInvalidate();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ switch (v.getId()) {
|
|
|
+ case R.id.btn_actionbar_more:
|
|
|
+ showMoreMenu();
|
|
|
+ break;
|
|
|
+ case R.id.pop_inventory_collect_menu_1:
|
|
|
+ closeMenuPopupWindow();
|
|
|
+ Fragment fragment = new InventoryDetailListFragment();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString("pi_inoutno", pi_inoutno);
|
|
|
+ bundle.putString("piid", pi_id);
|
|
|
+ fragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(this, fragment);
|
|
|
+ break;
|
|
|
+ case R.id.pop_inventory_collect_menu_2:
|
|
|
+ closeMenuPopupWindow();
|
|
|
+ fragment = new InventorySummaryListFragment();
|
|
|
+ bundle = new Bundle();
|
|
|
+ bundle.putString("pi_inoutno", pi_inoutno);
|
|
|
+ bundle.putString("piid", pi_id);
|
|
|
+ fragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(this, fragment);
|
|
|
+ break;
|
|
|
+ case R.id.inventory_collect_scan_iv:
|
|
|
+ if (CameraUtil.hasCamera()) {
|
|
|
+ if (root.findFocus() != null) {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(mActivity, CaptureActivity.class);
|
|
|
+ startActivityForResult(intent, SCAN_BARCODE_CODE);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 展示扩展菜单
|
|
|
+ */
|
|
|
+ private void showMoreMenu() {
|
|
|
+ View view = View.inflate(getActivity(), R.layout.pop_inventory_collect_menu, null);
|
|
|
+ Button detailBtn = (Button) view.findViewById(R.id.pop_inventory_collect_menu_1);
|
|
|
+ Button summaryBtn = (Button) view.findViewById(R.id.pop_inventory_collect_menu_2);
|
|
|
+
|
|
|
+ detailBtn.setOnClickListener(this);
|
|
|
+ summaryBtn.setOnClickListener(this);
|
|
|
+ detailBtn.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ mMenuPopupWindow = new PopupWindow(view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ mMenuPopupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ mMenuPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeMenuPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CommonUtil.setBackgroundAlpha(getActivity(), 0.5f);
|
|
|
+ mMenuPopupWindow.showAsDropDown(mMoreButton);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closeMenuPopupWindow() {
|
|
|
+ if (mMenuPopupWindow != null) {
|
|
|
+ mMenuPopupWindow.dismiss();
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (!hidden) {
|
|
|
+ ((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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (resultCode != Activity.RESULT_OK) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (requestCode == SCAN_BARCODE_CODE && data != null) {
|
|
|
+ if (data.getExtras() != null) {
|
|
|
+ String result = data.getExtras().getString(CodeUtils.RESULT_STRING);
|
|
|
+ mBarcodeEditText.setText(result);
|
|
|
+ mBarcodeEditText.setSelection(result.length());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroyView() {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|