|
|
@@ -0,0 +1,341 @@
|
|
|
+package com.uas.bgdq.fragment;
|
|
|
+
|
|
|
+import android.graphics.Color;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.ArrayAdapter;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+import android.widget.Spinner;
|
|
|
+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.uas.bgdq.R;
|
|
|
+import com.uas.bgdq.activity.FunctionActivity;
|
|
|
+import com.uas.bgdq.global.GloableParams;
|
|
|
+import com.uas.bgdq.listener.MyEditorActionListener;
|
|
|
+import com.uas.bgdq.util.CommonUtil;
|
|
|
+import com.uas.bgdq.util.FastjsonUtil;
|
|
|
+import com.uas.bgdq.util.HttpCallback;
|
|
|
+import com.uas.bgdq.util.HttpParams;
|
|
|
+import com.uas.bgdq.util.StringUtil;
|
|
|
+import com.uas.bgdq.util.VolleyRequest;
|
|
|
+import com.uas.bgdq.view.ClearableEditText;
|
|
|
+
|
|
|
+import org.json.JSONException;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+public
|
|
|
+ /**
|
|
|
+ * Created by sw on 2024-12-23
|
|
|
+ */
|
|
|
+class AGVPickup extends BaseFragment {
|
|
|
+
|
|
|
+ private Spinner masterSpinner;
|
|
|
+ private String selectedItem = "无";
|
|
|
+ static ArrayAdapter adapter;
|
|
|
+ private List<String> masterFuncList;
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private ClearableEditText mBarcodeEditText;
|
|
|
+ private Button bt_pickup, bt_cancel_pickup;
|
|
|
+ private LinearLayout ll_content;
|
|
|
+ private RelativeLayout rl_msg;
|
|
|
+ private TextView tv_msg_result, tv_barcode_value, tv_liaohao_value, tv_number_value,
|
|
|
+ tv_name_value, tv_spec_value, tv_location_value, tv_msg_value;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_agv_pickup;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ FunctionActivity.setTitle(getResources().getString(R.string.agv_pickup));
|
|
|
+ masterSpinner = (Spinner) root.findViewById(R.id.sp_login);
|
|
|
+ mBarcodeEditText = root.findViewById(R.id.barcode_info_collect_barcode_et);
|
|
|
+ bt_pickup = root.findViewById(R.id.bt_pickup);
|
|
|
+ bt_cancel_pickup = root.findViewById(R.id.bt_cancel_pickup);
|
|
|
+ ll_content = root.findViewById(R.id.ll_content);
|
|
|
+ rl_msg = root.findViewById(R.id.rl_msg);
|
|
|
+ tv_msg_result = root.findViewById(R.id.tv_msg_result);
|
|
|
+ tv_barcode_value = root.findViewById(R.id.tv_barcode_value);
|
|
|
+ tv_liaohao_value = root.findViewById(R.id.tv_liaohao_value);
|
|
|
+ tv_number_value = root.findViewById(R.id.tv_number_value);
|
|
|
+ tv_name_value = root.findViewById(R.id.tv_name_value);
|
|
|
+ tv_spec_value = root.findViewById(R.id.tv_spec_value);
|
|
|
+ tv_location_value = root.findViewById(R.id.tv_location_value);
|
|
|
+ tv_msg_value = root.findViewById(R.id.tv_msg_value);
|
|
|
+
|
|
|
+ masterFuncList = new ArrayList<String>();
|
|
|
+ mBarcodeEditText.requestFocus();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ masterSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ //选中值
|
|
|
+ selectedItem = parent.getItemAtPosition(position).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNothingSelected(AdapterView<?> parent) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CommonUtil.setEditorActionListener(mBarcodeEditText, new MyEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
+ getBarAcceptCode(text);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ bt_pickup.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ getPickUp(selectedItem,mBarcodeEditText.getText().toString().trim());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ bt_cancel_pickup.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ getCancelPickUp(mBarcodeEditText.getText().toString().trim());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getBarAcceptCode(String barcode) {
|
|
|
+ if (StringUtil.isEmpty(barcode)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请输入条码号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ progressDialog.show();
|
|
|
+ try {
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_AGVOUTGETBAR)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("barcode", barcode)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(), "data");
|
|
|
+ String BAR_PRODCODE = dataObject.getString("BAR_PRODCODE") == null ? "" : dataObject.getString("BAR_PRODCODE");
|
|
|
+ String PR_DETAIL = dataObject.getString("PR_DETAIL") == null ? "" : dataObject.getString("PR_DETAIL");
|
|
|
+ String PR_SPEC = dataObject.getString("PR_SPEC") == null ? "" : dataObject.getString("PR_SPEC");
|
|
|
+ String PR_ORISPECCODE = dataObject.getString("PR_ORISPECCODE") == null ? "" : dataObject.getString("PR_ORISPECCODE");
|
|
|
+ String BAR_LOCATION = dataObject.getString("BAR_LOCATION") == null ? "" : dataObject.getString("BAR_LOCATION");
|
|
|
+ String BAR_CODE = dataObject.getString("BAR_CODE") == null ? "" : dataObject.getString("BAR_CODE");
|
|
|
+ String BAR_REMAIN = dataObject.getString("BAR_REMAIN") == null ? "" : dataObject.getString("BAR_REMAIN");
|
|
|
+ String BAR_WHCODE = dataObject.getString("BAR_WHCODE") == null ? "" : dataObject.getString("BAR_WHCODE");
|
|
|
+ String ok = dataObject.getString("ok") == null ? "" : dataObject.getString("ok");
|
|
|
+ String msg = dataObject.getString("msg") == null ? "" : dataObject.getString("msg");
|
|
|
+ tv_msg_result.setVisibility(View.GONE);
|
|
|
+ tv_msg_result.setText("");
|
|
|
+ ll_content.setVisibility(View.VISIBLE);
|
|
|
+ String barCode = mBarcodeEditText.getText().toString().trim();
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ tv_barcode_value.setText(BAR_CODE);
|
|
|
+ tv_liaohao_value.setText(BAR_PRODCODE);
|
|
|
+ tv_number_value.setText(BAR_REMAIN);
|
|
|
+ tv_name_value.setText(PR_DETAIL);
|
|
|
+ tv_spec_value.setText(PR_SPEC);
|
|
|
+ tv_location_value.setText(BAR_LOCATION);
|
|
|
+ if (!TextUtils.isEmpty(msg)) {
|
|
|
+ rl_msg.setVisibility(View.VISIBLE);
|
|
|
+ tv_msg_value.setText(msg);
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(ok) && ok.equals("1")) {
|
|
|
+ //ok 的值是1 ,则自动再发送取货按钮的请求
|
|
|
+ //ok 的值是0 ,则只展示数据
|
|
|
+ getPickUp(selectedItem,barCode);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ tv_msg_result.setTextColor(Color.RED);
|
|
|
+ tv_msg_result.setVisibility(View.VISIBLE);
|
|
|
+ ll_content.setVisibility(View.GONE);
|
|
|
+ rl_msg.setVisibility(View.GONE);
|
|
|
+ tv_msg_result.setText(failStr);
|
|
|
+ mBarcodeEditText.requestFocus();
|
|
|
+ mBarcodeEditText.setText(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getPickUp(String trackNo,String barcode) {
|
|
|
+ if (StringUtil.isEmpty(barcode)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请输入条码号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ progressDialog.show();
|
|
|
+ try {
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_AGV_OUT_PICKUP)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("trackNo", trackNo)
|
|
|
+ .addParam("barcode", barcode)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ tv_msg_result.setVisibility(View.GONE);
|
|
|
+ tv_msg_result.setText("");
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ try {
|
|
|
+ org.json.JSONObject resultObject = new org.json.JSONObject(o.toString());
|
|
|
+ if (resultObject.optBoolean("success")) {
|
|
|
+ tv_msg_result.setVisibility(View.VISIBLE);
|
|
|
+ tv_msg_result.setTextColor(getResources().getColor(R.color.blue));
|
|
|
+ tv_msg_result.setText("发送取货任务成功");
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ tv_msg_result.setTextColor(Color.RED);
|
|
|
+ tv_msg_result.setVisibility(View.VISIBLE);
|
|
|
+ ll_content.setVisibility(View.GONE);
|
|
|
+ rl_msg.setVisibility(View.GONE);
|
|
|
+ tv_msg_result.setText(failStr);
|
|
|
+ mBarcodeEditText.requestFocus();
|
|
|
+ mBarcodeEditText.setText(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getCancelPickUp(String barcode) {
|
|
|
+ if (StringUtil.isEmpty(barcode)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请输入条码号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ progressDialog.show();
|
|
|
+ try {
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_AGV_OUT_CANCEL_PICKUP)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("barcode", barcode)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ tv_msg_result.setVisibility(View.GONE);
|
|
|
+ tv_msg_result.setText("");
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ try {
|
|
|
+ org.json.JSONObject resultObject = new org.json.JSONObject(o.toString());
|
|
|
+ if (resultObject.optBoolean("success")) {
|
|
|
+ tv_msg_result.setVisibility(View.VISIBLE);
|
|
|
+ tv_msg_result.setTextColor(getResources().getColor(R.color.blue));
|
|
|
+ tv_msg_result.setText("取消取货操作成功");
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ tv_msg_result.setTextColor(Color.RED);
|
|
|
+ tv_msg_result.setVisibility(View.VISIBLE);
|
|
|
+ ll_content.setVisibility(View.GONE);
|
|
|
+ rl_msg.setVisibility(View.GONE);
|
|
|
+ tv_msg_result.setText(failStr);
|
|
|
+ mBarcodeEditText.requestFocus();
|
|
|
+ mBarcodeEditText.setText(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ getSpinnerData();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getSpinnerData() {
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_GETAGV_CODE)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG)
|
|
|
+ .flag(1)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ masterFuncList.clear();
|
|
|
+ String result = o.toString();
|
|
|
+ com.alibaba.fastjson.JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ com.alibaba.fastjson.JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
+ for (Object index : dataArray) {
|
|
|
+ com.alibaba.fastjson.JSONObject data = (com.alibaba.fastjson.JSONObject) index;
|
|
|
+ String SH_CODE = data.getString("SH_CODE");
|
|
|
+ masterFuncList.add(SH_CODE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (masterFuncList.size() > 0) {
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ adapter = new ArrayAdapter(mActivity, R.layout.item_spinner, R.id.text_spinner, masterFuncList);
|
|
|
+ masterSpinner.setAdapter(adapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|