Browse Source

BOM校验标题改成条码料号校验

ChengJH 1 year ago
parent
commit
381dc1836e

+ 5 - 0
app/src/main/java/com/uas/uas_mes_stw/fragment/IndexWareHouseContentFragment.java

@@ -160,6 +160,11 @@ public class IndexWareHouseContentFragment extends BaseFragment implements Adapt
                     getFragmentManager().beginTransaction().addToBackStack(null)
                             .replace(R.id.container_function_fragment, fragment).commit();
                     break;
+                case GloableParams.GRIDNAME_SMART_GYS:
+                    fragment = new IntelligentShelvingFragment();
+                    getFragmentManager().beginTransaction().addToBackStack(null)
+                            .replace(R.id.container_function_fragment, fragment).commit();
+                    break;
             }
             if (mFragment != null) {
                 FragmentUtils.switchFragment(IndexWareHouseContentFragment.this, mFragment);

+ 373 - 0
app/src/main/java/com/uas/uas_mes_stw/fragment/IntelligentShelvingFragment.java

@@ -0,0 +1,373 @@
+package com.uas.uas_mes_stw.fragment;
+
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.BitmapDrawable;
+import android.support.v4.app.Fragment;
+import android.support.v7.app.AlertDialog;
+import android.text.TextUtils;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.PopupWindow;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSONObject;
+import com.android.volley.Request;
+import com.uas.uas_mes_stw.R;
+import com.uas.uas_mes_stw.activity.FunctionActivity;
+import com.uas.uas_mes_stw.global.GloableParams;
+import com.uas.uas_mes_stw.listener.MyEditorActionListener;
+import com.uas.uas_mes_stw.util.CameraUtil;
+import com.uas.uas_mes_stw.util.CommonUtil;
+import com.uas.uas_mes_stw.util.FastjsonUtil;
+import com.uas.uas_mes_stw.util.FragmentUtils;
+import com.uas.uas_mes_stw.util.HttpCallback;
+import com.uas.uas_mes_stw.util.HttpParams;
+import com.uas.uas_mes_stw.util.StringUtil;
+import com.uas.uas_mes_stw.util.VolleyRequest;
+import com.uas.uas_mes_stw.view.ClearableEditText;
+import com.uuzuche.lib_zxing.activity.CaptureActivity;
+import com.uuzuche.lib_zxing.activity.CodeUtils;
+
+public class IntelligentShelvingFragment extends BaseFragment {
+    private static final int SCAN_BARCODE_CODE = 101;
+    private ClearableEditText mBarcodeEditText;
+    private TextView mResultTextView;
+    private ImageView mScanImageView;
+    private int mFocusId;
+    private String mBarCode;
+    private org.json.JSONObject jsonObject;
+    private Button btn_kill;
+    private TextView tv_newtext1;
+    private TextView tv_newtext2;
+    private Button mMenuButton;
+    private PopupWindow mMenuPopupWindow;
+    private Fragment mFragment;
+    @Override
+    protected int getLayout() {
+        return R.layout.fragment_intelligentshelving;
+    }
+
+    @Override
+    protected void initViews() {
+        FunctionActivity.setTitle("智能上架(感应式)");
+        ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
+        mMenuButton = (Button) mActivity.findViewById(R.id.btn_actionbar_more);
+        mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
+        mBarcodeEditText = root.findViewById(R.id.barcode_info_collect_barcode_et);
+        mResultTextView = root.findViewById(R.id.barcode_info_collect_result_tv);
+        btn_kill = mActivity.findViewById(R.id.btn_kill);
+        tv_newtext1 = mActivity.findViewById(R.id.tv_newtext1);
+        tv_newtext2 = mActivity.findViewById(R.id.tv_newtext2);
+        mBarcodeEditText.requestFocus();
+        jsonObject=new org.json.JSONObject();
+    }
+
+    @Override
+    protected void initEvents() {
+        CommonUtil.setEditorActionListener(mBarcodeEditText, new MyEditorActionListener() {
+            @Override
+            public void MyEditorAction(String text, int actionId, KeyEvent event) {
+                getBarAcceptCode(text);
+            }
+        });
+
+
+
+        btn_kill.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                savekillAcceptCode();
+            }
+        });
+
+        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));
+                }
+            }
+        });
+        initPopupWindow();
+        mMenuButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                CommonUtil.setBackgroundAlpha(getActivity(), 0.5f);
+                mMenuPopupWindow.showAsDropDown(mMenuButton);
+            }
+        });
+    }
+    private void initPopupWindow() {
+        View view = View.inflate(getActivity(), R.layout.pop_storage_recharge_menu, null);
+
+        Button doneButton = (Button) view.findViewById(R.id.pop_storage_recharge_menu_1);
+        Button todoButton = (Button) view.findViewById(R.id.pop_storage_recharge_menu_2);
+        doneButton.setText("仓位物料查询");
+        todoButton.setVisibility(View.GONE);
+        mFragment = new PositionInquiryFragment();
+
+        doneButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                closeMenuPopupWindow();
+//                Bundle bundle = new Bundle();
+//                bundle.putString(Constants.FLAG.FLAG_RECHARGE_CALLER, "AcceptNotify!Have");
+//                mFragment.setArguments(bundle);
+                FragmentUtils.switchFragment(IntelligentShelvingFragment.this, mFragment);
+            }
+        });
+
+        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();
+            }
+        });
+    }
+
+
+    private void closeMenuPopupWindow() {
+        if (mMenuPopupWindow != null) {
+            mMenuPopupWindow.dismiss();
+            CommonUtil.setBackgroundAlpha(mActivity, 1f);
+        }
+    }
+    @Override
+    protected void initDatas() { ;
+
+    }
+
+
+
+
+    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_COMMON_SCANGETBARDATA)
+                    .method(Request.Method.GET)
+                    .addParam("code", barcode)
+                    .build(), new HttpCallback() {
+                @Override
+                public void onSuccess(int flag, Object o) throws Exception {
+                    progressDialog.dismiss();
+                    mBarcodeEditText.requestFocus();
+                    mBarcodeEditText.setSelection(mBarcodeEditText.getText().length());
+                    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 PR_LOCATION = dataObject.getString("PR_LOCATION") == null ? "" : dataObject.getString("PR_LOCATION");
+                    String LOCATION = dataObject.getString("LOCATION") == null ? "" : dataObject.getString("LOCATION");
+                    String TYPE = dataObject.getString("TYPE") == null ? "" : dataObject.getString("TYPE");
+                    String LOCATIONS = dataObject.getString("LOCATIONS") == null ? "" : dataObject.getString("LOCATIONS");
+                    mResultTextView.setTextColor(getResources().getColor(R.color.blue));
+                    mResultTextView.setVisibility(View.VISIBLE);
+                    tv_newtext1.setVisibility(View.VISIBLE);
+                    tv_newtext2.setVisibility(View.VISIBLE);
+                    mResultTextView.setText(TYPE+":"+mBarcodeEditText.getText().toString().trim()
+                                            +"\n编号:"+BAR_PRODCODE+" 数量:"+BAR_REMAIN
+                                            +"\n物料:"+PR_DETAIL
+                                            +"\n规格:"+PR_SPEC
+                                            +"\n默认仓位:"+PR_LOCATION);
+                    tv_newtext1.setText("目前仓位:"+BAR_LOCATION
+                            +"\n已存放仓位:"+LOCATIONS);
+                    tv_newtext2.setText("建议仓位:"+LOCATION);
+                }
+
+                @Override
+                public void onFail(int flag, String failStr) throws Exception {
+                    progressDialog.dismiss();
+                    CommonUtil.toastNoRepeat(mActivity, failStr);
+                    mResultTextView.setTextColor(Color.RED);
+                    mResultTextView.setVisibility(View.VISIBLE);
+                    tv_newtext1.setVisibility(View.GONE);
+                    tv_newtext2.setVisibility(View.GONE);
+                    mResultTextView.setText(failStr);
+                    mBarcodeEditText.requestFocus();
+                    mBarcodeEditText.setText(null);
+
+                }
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void saveBarAcceptCode(String ifmix) {
+        String barcode = mBarcodeEditText.getText().toString();
+        if (TextUtils.isEmpty(barcode)) {
+            CommonUtil.toastNoRepeat(mActivity, "请采集条码");
+            mBarcodeEditText.requestFocus();
+            return;
+        }
+
+        progressDialog.show();
+        VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
+                .url(GloableParams.ADDRESS_COMMON_SCANCONFIRMTRANS)
+                .method(Request.Method.POST)
+                .addParam("code", barcode)
+                .addParam("ifmix",ifmix)
+                .build(), new HttpCallback() {
+            @Override
+            public void onSuccess(int flag, Object o) throws Exception {
+                progressDialog.dismiss();
+                mResultTextView.setVisibility(View.VISIBLE);
+                tv_newtext1.setVisibility(View.GONE);
+                tv_newtext2.setVisibility(View.GONE);
+                mResultTextView.setTextColor(getResources().getColor(R.color.blue));
+
+
+
+                JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(),"data");
+                String LOG = dataObject.getString("log") == null ? "" : dataObject.getString("log");
+                String IFMIX = dataObject.getString("ifmix") == null ? "" : dataObject.getString("ifmix");
+                String PRODCODE = dataObject.getString("prodcode") == null ? "" : dataObject.getString("prodcode");
+                if (StringUtil.isEmpty(IFMIX)){
+                    mResultTextView.setText(null);
+                    mBarcodeEditText.setText(null);
+                }
+                if (StringUtil.isEmpty(IFMIX)){
+                    mResultTextView.setText(LOG);
+                }else {
+                    new AlertDialog.Builder(getActivity()).setTitle("提示")
+                            .setCancelable(true)
+                            .setMessage("是否允许混物料放置? 已经放置物料:"+PRODCODE)
+                            .setPositiveButton("是", new DialogInterface.OnClickListener() {
+                                @Override
+                                public void onClick(DialogInterface dialog, int which) {
+                                    saveBarAcceptCode(IFMIX);
+                                }
+                            })
+                            .setNegativeButton("否", null).show();
+                }
+
+                mBarcodeEditText.requestFocus();
+
+
+
+            }
+
+            @Override
+            public void onFail(int flag, String failStr) throws Exception {
+                progressDialog.dismiss();
+                CommonUtil.toastNoRepeat(mActivity, failStr);
+                mBarcodeEditText.requestFocus();
+                mBarcodeEditText.setText(null);
+                mResultTextView.setVisibility(View.VISIBLE);
+                tv_newtext1.setVisibility(View.GONE);
+                tv_newtext2.setVisibility(View.GONE);
+                mResultTextView.setTextColor(getResources().getColor(R.color.red));
+                mResultTextView.setText(failStr);
+
+
+            }
+        });
+
+    }
+    private void savekillAcceptCode() {
+        progressDialog.show();
+        VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
+                .url(GloableParams.ADDRESS_COMMON_SCANENDTRANS)
+                .method(Request.Method.POST)
+                .build(), new HttpCallback() {
+            @Override
+            public void onSuccess(int flag, Object o) throws Exception {
+                progressDialog.dismiss();
+                mResultTextView.setVisibility(View.VISIBLE);
+                tv_newtext1.setVisibility(View.GONE);
+                tv_newtext2.setVisibility(View.GONE);
+                mResultTextView.setText(null);
+                mBarcodeEditText.setText(null);
+                mBarcodeEditText.requestFocus();
+                mResultTextView.setTextColor(getResources().getColor(R.color.blue));
+                mResultTextView.setText("结束上架操作成功");
+
+
+            }
+
+            @Override
+            public void onFail(int flag, String failStr) throws Exception {
+                progressDialog.dismiss();
+                CommonUtil.toastNoRepeat(mActivity, failStr);
+                mResultTextView.setTextColor(getResources().getColor(R.color.red));
+                mResultTextView.setVisibility(View.VISIBLE);
+                tv_newtext1.setVisibility(View.GONE);
+                tv_newtext2.setVisibility(View.GONE);
+                mResultTextView.setText(failStr);
+                mBarcodeEditText.requestFocus();
+                mBarcodeEditText.setText(null);
+            }
+        });
+
+    }
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent 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);
+                if (mFocusId == R.id.barcode_info_collect_barcode_et) {
+                    mBarcodeEditText.setText(result);
+                    mBarcodeEditText.setSelection(result.length());
+                    getBarAcceptCode(result);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void onHiddenChanged(boolean hidden) {
+        super.onHiddenChanged(hidden);
+        if (!hidden) {
+            FunctionActivity.setTitle("智能上架(感应式)");
+            ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
+        }else {
+            ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
+        }
+    }
+
+    @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);
+    }
+}

+ 1 - 0
app/src/main/java/com/uas/uas_mes_stw/global/GloableParams.java

@@ -893,6 +893,7 @@ public class GloableParams {
     public static final String GRIDNAME_BOM_CHECK = "BOM校验";
     public static final String MENU_STORAGE_STOCK_INFO_COLLECT = "库存条码绑定";
     public static final String GRIDNAME_SMART_SHELVES = "智能上架(扫码)";
+    public static final String GRIDNAME_SMART_GYS = "智能上架(感应式)";
     public static final String[] storageGridNames = {
             GRIDNAME_GOOD_SEARCH,
             GRIDNAME_BATCH_OPRATION,

+ 95 - 0
app/src/main/res/layout/fragment_intelligentshelving.xml

@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:ndroid="http://schemas.android.com/apk/res-auto"
+    android:orientation="vertical"
+    android:padding="@dimen/root_layout_padding">
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <LinearLayout
+            android:layout_marginTop="@dimen/dp_10"
+            android:orientation="horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+            <TextView
+                android:layout_width="110dp"
+                android:layout_height="match_parent"
+                android:background="@color/gray_light"
+                android:gravity="center"
+                android:padding="6dp"
+                android:text="条码"
+                android:textColor="@color/body_text_1"
+                android:textSize="16sp" />
+                <com.uas.uas_mes_stw.view.ClearableEditText
+                    android:id="@+id/barcode_info_collect_barcode_et"
+                    style="@style/EditTextStyle"
+                    android:layout_width="0dp"
+                    android:layout_weight="1"
+                    android:hint="@string/please_collect_barcode"
+                    android:focusable="true"
+                    android:focusableInTouchMode="true"
+                    android:imeOptions="actionSend"
+                    android:textColor="@color/black" />
+            </LinearLayout>
+    </LinearLayout>
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+        <Button
+            android:id="@+id/barcode_info_collect_confirm_btn"
+            style="@style/ButtonStyle"
+            android:layout_marginTop="16dp"
+            android:text="上架"
+            android:layout_weight="1"/>
+        <Button
+            android:id="@+id/btn_kill"
+            style="@style/ButtonStyle"
+            android:layout_marginTop="16dp"
+            android:text="结束上架"
+            android:layout_weight="1"/>
+
+    </LinearLayout>
+
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/spacing_big"
+        android:background="@drawable/shape_msg_block"
+        android:padding="10dp">
+        <TextView
+            android:id="@+id/barcode_info_collect_result_tv"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:visibility="gone"
+            tools:visibility="visible"
+            tools:text="采集成功,条码:786528238;数量:2;料号:1209837;名称规格:瓶子" />
+
+        <TextView
+            android:id="@+id/tv_newtext1"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:visibility="gone"
+            tools:visibility="visible"
+            android:textColor="@color/green"
+            tools:text="采集成功,条码:786528238;数量:2;料号:1209837;名称规格:瓶子" />
+        <TextView
+            android:id="@+id/tv_newtext2"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:visibility="gone"
+            tools:visibility="visible"
+            android:textColor="@color/blue"
+            tools:text="采集成功,条码:786528238;数量:2;料号:1209837;名称规格:瓶子" />
+    </LinearLayout>
+
+
+</LinearLayout>