|
@@ -4,21 +4,31 @@ import android.app.Activity;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.os.AsyncTask;
|
|
import android.os.AsyncTask;
|
|
|
|
|
+import android.os.Bundle;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
import android.view.KeyEvent;
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
|
|
+import android.widget.Button;
|
|
|
import android.widget.EditText;
|
|
import android.widget.EditText;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TableLayout;
|
|
import android.widget.TableLayout;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.uas.aowei_wms.R;
|
|
import com.uas.aowei_wms.R;
|
|
|
import com.uas.aowei_wms.activity.FunctionActivity;
|
|
import com.uas.aowei_wms.activity.FunctionActivity;
|
|
|
import com.uas.aowei_wms.global.GloableParams;
|
|
import com.uas.aowei_wms.global.GloableParams;
|
|
|
|
|
+import com.uas.aowei_wms.tools.SharedPreUtil;
|
|
|
import com.uas.aowei_wms.tools.VolleyUtil;
|
|
import com.uas.aowei_wms.tools.VolleyUtil;
|
|
|
import com.uas.aowei_wms.util.CameraUtil;
|
|
import com.uas.aowei_wms.util.CameraUtil;
|
|
|
import com.uas.aowei_wms.util.CommonUtil;
|
|
import com.uas.aowei_wms.util.CommonUtil;
|
|
|
|
|
+import com.uas.aowei_wms.util.Constants;
|
|
|
|
|
+import com.uas.aowei_wms.util.FragmentUtils;
|
|
|
|
|
+import com.uas.aowei_wms.util.MyLog;
|
|
|
|
|
+import com.uas.aowei_wms.util.PrintUtils;
|
|
|
import com.uas.aowei_wms.view.ClearableEditText;
|
|
import com.uas.aowei_wms.view.ClearableEditText;
|
|
|
import com.uas.aowei_wms.view.ConfirmDialog;
|
|
import com.uas.aowei_wms.view.ConfirmDialog;
|
|
|
import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
@@ -27,6 +37,9 @@ import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @note:条码信息核查页面
|
|
* @note:条码信息核查页面
|
|
|
*/
|
|
*/
|
|
@@ -34,11 +47,18 @@ public class WHCheckBarcodeFragment extends BaseFragment implements View.OnClick
|
|
|
private static final int SCAN_BARCODE_CODE = 402;
|
|
private static final int SCAN_BARCODE_CODE = 402;
|
|
|
ClearableEditText etCollect;
|
|
ClearableEditText etCollect;
|
|
|
TableLayout tlMsg;
|
|
TableLayout tlMsg;
|
|
|
- TextView tvBarcode, tvBarProcode,tv_type_value,tvPrDetail, tvPrSpec, tvVeShortname,
|
|
|
|
|
- tvBarWhcode, tvBarRemain, tvBarLocation, tvStatus;
|
|
|
|
|
|
|
+ TextView tvBarcode, tvBarProcode, tv_type_value, tvPrDetail, tvPrSpec, tvVeShortname,
|
|
|
|
|
+ tvBarWhcode, tvBarRemain, tvBarLocation, tvStatus, tv_production_date;
|
|
|
private TextView btnSearch;
|
|
private TextView btnSearch;
|
|
|
private ImageView mScanImageView;
|
|
private ImageView mScanImageView;
|
|
|
private int mFocusId;
|
|
private int mFocusId;
|
|
|
|
|
+ private Button bt_print;
|
|
|
|
|
+
|
|
|
|
|
+ private com.alibaba.fastjson.JSONArray listArray;
|
|
|
|
|
+ private boolean isConnected = false;
|
|
|
|
|
+ private String mOldAddress = "";
|
|
|
|
|
+ private int mPrintDpi = 203;
|
|
|
|
|
+ private boolean isPrinting = false;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected int getLayout() {
|
|
protected int getLayout() {
|
|
@@ -52,7 +72,7 @@ public class WHCheckBarcodeFragment extends BaseFragment implements View.OnClick
|
|
|
tlMsg = (TableLayout) root.findViewById(R.id.tl_msg);
|
|
tlMsg = (TableLayout) root.findViewById(R.id.tl_msg);
|
|
|
tvBarcode = (TextView) root.findViewById(R.id.tv_bar_code);
|
|
tvBarcode = (TextView) root.findViewById(R.id.tv_bar_code);
|
|
|
tvBarProcode = (TextView) root.findViewById(R.id.tv_bar_procode);
|
|
tvBarProcode = (TextView) root.findViewById(R.id.tv_bar_procode);
|
|
|
- tv_type_value=root.findViewById(R.id.tv_type_value);
|
|
|
|
|
|
|
+ tv_type_value = root.findViewById(R.id.tv_type_value);
|
|
|
tvPrDetail = (TextView) root.findViewById(R.id.tv_pr_detail);
|
|
tvPrDetail = (TextView) root.findViewById(R.id.tv_pr_detail);
|
|
|
tvPrSpec = (TextView) root.findViewById(R.id.tv_pr_spec);
|
|
tvPrSpec = (TextView) root.findViewById(R.id.tv_pr_spec);
|
|
|
tvVeShortname = (TextView) root.findViewById(R.id.tv_pr_ve_shortname);
|
|
tvVeShortname = (TextView) root.findViewById(R.id.tv_pr_ve_shortname);
|
|
@@ -60,10 +80,15 @@ public class WHCheckBarcodeFragment extends BaseFragment implements View.OnClick
|
|
|
tvBarRemain = (TextView) root.findViewById(R.id.tv_bar_remain);
|
|
tvBarRemain = (TextView) root.findViewById(R.id.tv_bar_remain);
|
|
|
tvBarLocation = (TextView) root.findViewById(R.id.tv_bar_location);
|
|
tvBarLocation = (TextView) root.findViewById(R.id.tv_bar_location);
|
|
|
tvStatus = root.findViewById(R.id.tv_bar_status);
|
|
tvStatus = root.findViewById(R.id.tv_bar_status);
|
|
|
|
|
+ tv_production_date = (TextView) mActivity.findViewById(R.id.tv_production_date);
|
|
|
btnSearch = (TextView) root.findViewById(R.id.btn_collect);
|
|
btnSearch = (TextView) root.findViewById(R.id.btn_collect);
|
|
|
|
|
+ bt_print = root.findViewById(R.id.bt_print);
|
|
|
((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.title_barcode_whmm);
|
|
((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.title_barcode_whmm);
|
|
|
mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
|
|
mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
|
|
|
|
|
|
|
|
|
|
+ isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
|
|
|
|
|
+ mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
|
|
|
|
|
+ mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -99,8 +124,63 @@ public class WHCheckBarcodeFragment extends BaseFragment implements View.OnClick
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ bt_print.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ if (listArray != null && listArray.size() > 0) {
|
|
|
|
|
+ printEvent(listArray);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "数据为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void printEvent(com.alibaba.fastjson.JSONArray printArray) {
|
|
|
|
|
+ MyLog.e("aaa","打印的数组是:" + printArray.get(0));
|
|
|
|
|
+ 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(WHCheckBarcodeFragment.this, blueToothPrintFragment);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印失败,条码数据为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ isPrinting = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
protected void initDatas() {
|
|
protected void initDatas() {
|
|
|
etCollect.setHint(R.string.hint_whcheck_bar_code);
|
|
etCollect.setHint(R.string.hint_whcheck_bar_code);
|
|
@@ -185,31 +265,65 @@ public class WHCheckBarcodeFragment extends BaseFragment implements View.OnClick
|
|
|
String strBarcode = changeNulltoBlank(dataJson, "BAR_CODE");
|
|
String strBarcode = changeNulltoBlank(dataJson, "BAR_CODE");
|
|
|
String strProduct = changeNulltoBlank(dataJson, "BAR_PRODCODE");
|
|
String strProduct = changeNulltoBlank(dataJson, "BAR_PRODCODE");
|
|
|
String strDetail = changeNulltoBlank(dataJson, "PR_DETAIL");
|
|
String strDetail = changeNulltoBlank(dataJson, "PR_DETAIL");
|
|
|
- String strSpec = changeNulltoBlank(dataJson, "PR_SPEC");
|
|
|
|
|
|
|
+ String strSpec = changeNulltoBlank(dataJson, "PR_SPEC"); //规格
|
|
|
String strShortname = changeNulltoBlank(dataJson, "VE_SHORTNAME");
|
|
String strShortname = changeNulltoBlank(dataJson, "VE_SHORTNAME");
|
|
|
String strWhcode = changeNulltoBlank(dataJson, "BAR_WHCODE");
|
|
String strWhcode = changeNulltoBlank(dataJson, "BAR_WHCODE");
|
|
|
String strRemain = changeNulltoBlank(dataJson, "BAR_REMAIN");
|
|
String strRemain = changeNulltoBlank(dataJson, "BAR_REMAIN");
|
|
|
String strLocation = changeNulltoBlank(dataJson, "BAR_LOCATION");
|
|
String strLocation = changeNulltoBlank(dataJson, "BAR_LOCATION");
|
|
|
- String strStatus = changeNulltoBlank(dataJson, "BAR_STATUS");
|
|
|
|
|
- String strType=changeNulltoBlank(dataJson,"PR_ORISPECCODE");
|
|
|
|
|
|
|
+ String strStatus = changeNulltoBlank(dataJson, "BAR_STATUS"); //条码状态
|
|
|
|
|
+ String strType = changeNulltoBlank(dataJson, "PR_ORISPECCODE");
|
|
|
|
|
+ String barMadedate = changeNulltoBlank(dataJson, "BAR_MADEDATE");
|
|
|
|
|
|
|
|
//显示数据
|
|
//显示数据
|
|
|
tvBarcode.setText(strBarcode);
|
|
tvBarcode.setText(strBarcode);
|
|
|
tvBarProcode.setText(strProduct);
|
|
tvBarProcode.setText(strProduct);
|
|
|
tv_type_value.setText(strType);
|
|
tv_type_value.setText(strType);
|
|
|
tvPrDetail.setText(strDetail);
|
|
tvPrDetail.setText(strDetail);
|
|
|
- tvPrSpec.setText(strSpec);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String PR_SPEC = "";
|
|
|
|
|
+ if (!TextUtils.isEmpty(strSpec)) {
|
|
|
|
|
+ String[] split = strSpec.split(",");
|
|
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
|
|
+ if (i == split.length -1) {
|
|
|
|
|
+ PR_SPEC += split[i];
|
|
|
|
|
+ }else {
|
|
|
|
|
+ PR_SPEC += split[i] + "\n";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ tvPrSpec.setText(PR_SPEC); //规格
|
|
|
tvVeShortname.setText(strShortname);
|
|
tvVeShortname.setText(strShortname);
|
|
|
tvBarWhcode.setText(strWhcode);
|
|
tvBarWhcode.setText(strWhcode);
|
|
|
tvBarRemain.setText(strRemain);
|
|
tvBarRemain.setText(strRemain);
|
|
|
tvBarLocation.setText(strLocation);
|
|
tvBarLocation.setText(strLocation);
|
|
|
- if(strStatus.equals("1")){
|
|
|
|
|
|
|
+ if (strStatus.equals("1")) {
|
|
|
tvStatus.setText("在库");
|
|
tvStatus.setText("在库");
|
|
|
- }else if(strStatus.equals("2")){
|
|
|
|
|
|
|
+ } else if (strStatus.equals("2")) {
|
|
|
tvStatus.setText("出库");
|
|
tvStatus.setText("出库");
|
|
|
- }else{
|
|
|
|
|
- tvStatus.setText(strStatus);
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ tvStatus.setText(strStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+ tv_production_date.setText(barMadedate);
|
|
|
|
|
+
|
|
|
|
|
+ bt_print.setEnabled(true);
|
|
|
|
|
+ bt_print.setTextColor(getResources().getColor(R.color.black));
|
|
|
|
|
+
|
|
|
|
|
+ //新增数据
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject resultObject = JSON.parseObject(result);
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject jb = resultObject.getJSONObject("data");
|
|
|
|
|
+
|
|
|
|
|
+ List<Object> list = new ArrayList<>();;
|
|
|
|
|
+ list.add(jb);
|
|
|
|
|
+ JSONArray jsonArray = new JSONArray(list);
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
+ Object o = jsonArray.get(0);
|
|
|
|
|
+ jsonArray.getJSONObject(0);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //listArray = FastjsonUtil.getJSONArray(dataJson.toString(), "nolist");
|
|
|
|
|
+ listArray = jsonArray;
|
|
|
} catch (JSONException e) {
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -239,7 +353,7 @@ public class WHCheckBarcodeFragment extends BaseFragment implements View.OnClick
|
|
|
@Override
|
|
@Override
|
|
|
protected Float doInBackground(String... params) {
|
|
protected Float doInBackground(String... params) {
|
|
|
try {
|
|
try {
|
|
|
- Thread.sleep(1000);
|
|
|
|
|
|
|
+ Thread.sleep(3000);
|
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -309,8 +423,8 @@ public class WHCheckBarcodeFragment extends BaseFragment implements View.OnClick
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
|
|
if (progressDialog != null && progressDialog.isShowing()) {
|
|
if (progressDialog != null && progressDialog.isShowing()) {
|
|
|
-// loadingView.dismiss();
|
|
|
|
|
-// VolleyUtil.distoryVolley();
|
|
|
|
|
|
|
+ // loadingView.dismiss();
|
|
|
|
|
+ // VolleyUtil.distoryVolley();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|