|
@@ -0,0 +1,193 @@
|
|
|
|
|
+package com.uas.uaspda.fragment;
|
|
|
|
|
+
|
|
|
|
|
+import android.app.Activity;
|
|
|
|
|
+import android.content.Intent;
|
|
|
|
|
+import android.text.Editable;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
|
|
+import android.text.TextWatcher;
|
|
|
|
|
+import android.view.KeyEvent;
|
|
|
|
|
+import android.view.View;
|
|
|
|
|
+import android.widget.Button;
|
|
|
|
|
+import android.widget.ImageView;
|
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.android.volley.Request;
|
|
|
|
|
+import com.uas.uaspda.R;
|
|
|
|
|
+import com.uas.uaspda.activity.FunctionActivity;
|
|
|
|
|
+import com.uas.uaspda.global.GloableParams;
|
|
|
|
|
+import com.uas.uaspda.listener.MyEditorActionListener;
|
|
|
|
|
+import com.uas.uaspda.util.CameraUtil;
|
|
|
|
|
+import com.uas.uaspda.util.CommonUtil;
|
|
|
|
|
+import com.uas.uaspda.util.Constants;
|
|
|
|
|
+import com.uas.uaspda.util.FastjsonUtil;
|
|
|
|
|
+import com.uas.uaspda.util.HttpCallback;
|
|
|
|
|
+import com.uas.uaspda.util.HttpParams;
|
|
|
|
|
+import com.uas.uaspda.util.LogUtil;
|
|
|
|
|
+import com.uas.uaspda.util.VolleyRequest;
|
|
|
|
|
+import com.uas.uaspda.view.ClearableEditText;
|
|
|
|
|
+import com.uas.uaspda.view.business.MsdRankSelectPop;
|
|
|
|
|
+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 2020/8/4
|
|
|
|
|
+ * Desc: 真空密封登记
|
|
|
|
|
+ */
|
|
|
|
|
+public class MSDVacuumSealRegisterFragment extends BaseFragment {
|
|
|
|
|
+ private static final int SCAN_BARCODE_CODE = 203;
|
|
|
|
|
+
|
|
|
|
|
+ private ImageView mScanImageView;
|
|
|
|
|
+ private int mFocusId;
|
|
|
|
|
+ private ClearableEditText mBarcodeEditText;
|
|
|
|
|
+ private Button mConfirmButton;
|
|
|
|
|
+ private TextView mResultTextView;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected int getLayout() {
|
|
|
|
|
+ return R.layout.fragment_msd_vacuum_seal_register;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void initViews() {
|
|
|
|
|
+ ((FunctionActivity) getActivity()).setTitle("真空密封登记");
|
|
|
|
|
+
|
|
|
|
|
+ ((FunctionActivity) getActivity()).setScanIvVisible(true);
|
|
|
|
|
+
|
|
|
|
|
+ mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
|
|
|
|
|
+ mBarcodeEditText = root.findViewById(R.id.msd_vacuum_seal_barcode_et);
|
|
|
|
|
+ mConfirmButton = root.findViewById(R.id.msd_vacuum_seal_confirm_btn);
|
|
|
|
|
+ mResultTextView = root.findViewById(R.id.msd_vacuum_seal_result_tv);
|
|
|
|
|
+
|
|
|
|
|
+ mBarcodeEditText.requestFocus();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void initEvents() {
|
|
|
|
|
+// mConfirmButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void onClick(View v) {
|
|
|
|
|
+// confirmEvent("");
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ mScanImageView.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ if (CameraUtil.hasCamera()) {
|
|
|
|
|
+ if (root.findFocus() != null) {
|
|
|
|
|
+ mFocusId = root.findFocus().getId();
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
|
+ intent.setClass(mActivity, CaptureActivity.class);
|
|
|
|
|
+ startActivityForResult(intent, SCAN_BARCODE_CODE);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ CommonUtil.setEditorActionListener(mBarcodeEditText, new MyEditorActionListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
|
|
+ if (!TextUtils.isEmpty(text)) {
|
|
|
|
|
+ mResultTextView.setVisibility(View.GONE);
|
|
|
|
|
+ mResultTextView.setText("");
|
|
|
|
|
+ confirmEvent(text);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void confirmEvent(String barcode) {
|
|
|
|
|
+ progressDialog.show();
|
|
|
|
|
+ if (barcode.endsWith("\n") || barcode.endsWith("\r")) {
|
|
|
|
|
+ barcode.replaceAll("\r|\n", "");
|
|
|
|
|
+ }
|
|
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
|
|
+ .url(GloableParams.ADDRESS_MSD_CONFIRMSEALBARCODE)
|
|
|
|
|
+ .method(Request.Method.POST)
|
|
|
|
|
+ .tag(TAG + "msdregister")
|
|
|
|
|
+ .flag(0)
|
|
|
|
|
+ .addParam("bar_code", barcode)
|
|
|
|
|
+ .build(), new HttpCallback() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
|
|
+ progressDialog.dismiss();
|
|
|
|
|
+
|
|
|
|
|
+ String result = o.toString();
|
|
|
|
|
+ if (FastjsonUtil.validate(result)) {
|
|
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "确认登记成功");
|
|
|
|
|
+ if (dataObject != null) {
|
|
|
|
|
+ mResultTextView.setVisibility(View.VISIBLE);
|
|
|
|
|
+
|
|
|
|
|
+ mResultTextView.setText("确认登记成功" +
|
|
|
|
|
+ "\n条码:" + FastjsonUtil.getText(dataObject, "MB_BARCODE") +
|
|
|
|
|
+ "\n物料:" + FastjsonUtil.getText(dataObject, "MB_PRODCODE") +
|
|
|
|
|
+ "\n名称:" + FastjsonUtil.getText(dataObject, "PR_DETAIL") +
|
|
|
|
|
+ "\n规格:" + FastjsonUtil.getText(dataObject, "PR_SPEC") +
|
|
|
|
|
+ "\n湿敏等级:" + FastjsonUtil.getText(dataObject, "MB_MSDLEVEL") +
|
|
|
|
|
+ "\n车间寿命:" + FastjsonUtil.getText(dataObject, "MB_FLOORLIFE") +
|
|
|
|
|
+ "\n暴露时长:" + FastjsonUtil.getText(dataObject, "MB_EXPOSURETIME")
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
|
|
+ progressDialog.dismiss();
|
|
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
|
|
+ mResultTextView.setVisibility(View.VISIBLE);
|
|
|
|
|
+ mResultTextView.setText(failStr);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void initDatas() {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @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());
|
|
|
|
|
+ confirmEvent(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onDestroyView() {
|
|
|
|
|
+ super.onDestroyView();
|
|
|
|
|
+ ((FunctionActivity) getActivity()).setScanIvVisible(false);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|