|
|
@@ -0,0 +1,1029 @@
|
|
|
+package com.uas.pda_wps.fragment;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+import android.os.AsyncTask;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
+import android.support.v7.app.AlertDialog;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.text.TextWatcher;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.Gravity;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.AutoCompleteTextView;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.CheckBox;
|
|
|
+import android.widget.CompoundButton;
|
|
|
+import android.widget.GridView;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
+import android.widget.RadioButton;
|
|
|
+import android.widget.RadioGroup;
|
|
|
+import android.widget.SimpleAdapter;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.android.volley.AuthFailureError;
|
|
|
+import com.android.volley.DefaultRetryPolicy;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.android.volley.Response;
|
|
|
+import com.android.volley.VolleyError;
|
|
|
+import com.android.volley.toolbox.StringRequest;
|
|
|
+import com.uas.pda_wps.R;
|
|
|
+import com.uas.pda_wps.application.PdaApplication;
|
|
|
+import com.uas.pda_wps.bean.LineInfoBean;
|
|
|
+import com.uas.pda_wps.global.GloableParams;
|
|
|
+import com.uas.pda_wps.tools.DataSourceManager;
|
|
|
+import com.uas.pda_wps.tools.SharedPreUtil;
|
|
|
+import com.uas.pda_wps.tools.VolleyUtil;
|
|
|
+import com.uas.pda_wps.util.CommonUtil;
|
|
|
+import com.uas.pda_wps.util.Constants;
|
|
|
+import com.uas.pda_wps.util.FragmentUtils;
|
|
|
+import com.uas.pda_wps.util.HttpCallback;
|
|
|
+import com.uas.pda_wps.util.HttpParams;
|
|
|
+import com.uas.pda_wps.util.JsonUtils;
|
|
|
+import com.uas.pda_wps.util.MyArrayAdapter;
|
|
|
+import com.uas.pda_wps.util.VolleyRequest;
|
|
|
+import com.uas.pda_wps.view.ClearableEditText;
|
|
|
+import com.uas.pda_wps.view.ConfirmDialog;
|
|
|
+
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+public
|
|
|
+ /**
|
|
|
+ * Created by sw on 2026-01-12
|
|
|
+ */
|
|
|
+class SMTStandbyFunction extends BaseFragment implements AdapterView.OnItemClickListener {
|
|
|
+ private static final String TAG = "SCSMTIndexFragment";
|
|
|
+ private static final int MACODE_FUZZY = 0;
|
|
|
+ private static final int PRODCODE_FUZZY = 1;
|
|
|
+
|
|
|
+ GridView lvIndex;
|
|
|
+ List<Map<String, Object>> operationIndexList;
|
|
|
+ private LineInfoBean mLineInfoBean;
|
|
|
+ private PopupWindow mPasswordPopupWindow, mMachinePopupWindow;
|
|
|
+ private ClearableEditText mPasswordEditText;
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private int dl_madeqty, ma_qty;//产出数,工单数
|
|
|
+ private MyArrayAdapter mAutoStringAdapter;
|
|
|
+ View downAllView;
|
|
|
+ AlertDialog switchDialog;
|
|
|
+
|
|
|
+ private String dl_linecode; //线别
|
|
|
+ private String dl_mainline; //实际线别
|
|
|
+ private String dl_table; //板面
|
|
|
+ private String dl_macode; //工单号
|
|
|
+ private String dl_prodcode; //产品编号
|
|
|
+
|
|
|
+ private TextView mCancelTextView;
|
|
|
+ private TextView mConfirmTextView;
|
|
|
+ private TextView tv_dl_linecode, tv_dl_mainline, tv_dl_table, tv_dl_macode, tv_dl_prodcode;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fra_scmake_smtcontent;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.smt_materia_preparation);
|
|
|
+ ((Button) (getActivity().findViewById(R.id.btn_actionbar_right))).setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tv_dl_linecode = root.findViewById(R.id.tv_dl_linecode);
|
|
|
+ tv_dl_mainline = root.findViewById(R.id.tv_dl_mainline);
|
|
|
+ tv_dl_table = root.findViewById(R.id.tv_dl_table);
|
|
|
+ tv_dl_macode = root.findViewById(R.id.tv_dl_macode);
|
|
|
+ tv_dl_prodcode = root.findViewById(R.id.tv_dl_prodcode);
|
|
|
+
|
|
|
+ downAllView = View.inflate(getActivity(), R.layout.pop_smt_down_all, null);
|
|
|
+ switchDialog = new AlertDialog.Builder(getActivity()).setView(downAllView).create();
|
|
|
+
|
|
|
+ lvIndex = (GridView) root.findViewById(R.id.lv_index_smt);
|
|
|
+
|
|
|
+ //接口回调
|
|
|
+ VolleyUtil.setVolleyHandler(volleyHandler);
|
|
|
+ //获取数据
|
|
|
+ operationIndexList = DataSourceManager.getDataSourceManager().getFeederOperationIndex2();
|
|
|
+
|
|
|
+ mLineInfoBean = (LineInfoBean) PdaApplication.getDataCacheFromMap(Constants.FLAG.SMT_DEVICE_LINE_CACHE);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ //配置监听
|
|
|
+ lvIndex.setOnItemClickListener(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ SimpleAdapter adapter = new SimpleAdapter(mActivity, operationIndexList, R.layout.item_grid_first,
|
|
|
+ new String[]{DataSourceManager.KEY_GRID_ITEMIMG, DataSourceManager.KEY_GRID_ITEMNAME},
|
|
|
+ new int[]{R.id.first_griditem_img, R.id.first_griditem_name});
|
|
|
+ lvIndex.setAdapter(adapter);
|
|
|
+
|
|
|
+ if (mLineInfoBean != null) {
|
|
|
+ if (CommonUtil.isNetWorkConnected(mActivity)) {
|
|
|
+ getSmtLocation();
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.net_not_connect));
|
|
|
+ SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Bundle arguments = getArguments();
|
|
|
+ if (arguments != null) {
|
|
|
+ dl_linecode = arguments.getString("DL_LINECODE") == null ? "" : arguments.getString("DL_LINECODE");
|
|
|
+ dl_mainline = arguments.getString("DL_MAINLINE") == null ? "" : arguments.getString("DL_MAINLINE");
|
|
|
+ dl_table = arguments.getString("DL_TABLE") == null ? "" : arguments.getString("DL_TABLE");
|
|
|
+ dl_macode = arguments.getString("DL_MACODE") == null ? "" : arguments.getString("DL_MACODE");
|
|
|
+ dl_prodcode = arguments.getString("DL_PRODCODE") == null ? "" : arguments.getString("DL_PRODCODE");
|
|
|
+ }
|
|
|
+
|
|
|
+ tv_dl_linecode.setText(dl_linecode);
|
|
|
+ tv_dl_mainline.setText(dl_mainline);
|
|
|
+ tv_dl_table.setText(dl_table + "面");
|
|
|
+ tv_dl_macode.setText(dl_macode);
|
|
|
+ tv_dl_prodcode.setText(dl_prodcode);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (!hidden) {
|
|
|
+ VolleyUtil.setVolleyHandler(volleyHandler);
|
|
|
+ ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.smt_materia_preparation);
|
|
|
+ ((Button) (getActivity().findViewById(R.id.btn_actionbar_right))).setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前工单站位信息
|
|
|
+ */
|
|
|
+ private void getSmtLocation() {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = GloableParams.ADDRESS_SMT_GET_SMT_LOCATION
|
|
|
+ + "?ps_id=" + mLineInfoBean.getPS_ID()
|
|
|
+ + "&dl_table=" + mLineInfoBean.getDL_TABLE();
|
|
|
+
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "location");
|
|
|
+
|
|
|
+ mStringRequest = new StringRequest(Request.Method.GET, url,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ JSONObject resultObject = new JSONObject(s);
|
|
|
+ if (resultObject.optBoolean("success")) {
|
|
|
+ String smtLocation = resultObject.optString("data");
|
|
|
+ Log.d("smtLocation", smtLocation);
|
|
|
+ SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, smtLocation);
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.showErrorToast(volleyError, true);
|
|
|
+ SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, "");
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "location");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ VolleyUtil.distoryVolley();
|
|
|
+ PdaApplication.removeDataCacheFromMap(Constants.FLAG.SMT_REQUEST_CACHE);
|
|
|
+ super.onDestroy();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ if (!CommonUtil.isRepeatClick()) {
|
|
|
+ String mSmtLocationCache = SharedPreUtil.getString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, null);
|
|
|
+ if (TextUtils.isEmpty(mSmtLocationCache)) {
|
|
|
+ new AlertDialog.Builder(mActivity).setTitle("提示")
|
|
|
+ .setMessage("获取站位表失败,无法进行后续操作。点击确定重新获取站位表!")
|
|
|
+ .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ if (CommonUtil.isNetWorkConnected(mActivity)) {
|
|
|
+ getSmtLocation();
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.net_not_connect));
|
|
|
+ SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton(R.string.cancel, null).create().show();
|
|
|
+ } else {
|
|
|
+ //获取选择的列表Name
|
|
|
+ String selectedName = operationIndexList.get(position).get(DataSourceManager.KEY_GRID_ITEMNAME).toString();
|
|
|
+ Fragment fragment;
|
|
|
+ switch (selectedName) {
|
|
|
+ //上料
|
|
|
+ case GloableParams.LISTNAME_FEEDER_IN2:
|
|
|
+ fragment = new SCSMTInFragment();
|
|
|
+ FragmentUtils.switchFragment(this, fragment);
|
|
|
+ break;
|
|
|
+ //下料
|
|
|
+ case GloableParams.LISTNAME_FEEDER_DOWN2:
|
|
|
+ fragment = new SCSMTDownFragment();
|
|
|
+ FragmentUtils.switchFragment(this, fragment);
|
|
|
+ break;
|
|
|
+ //全部下料
|
|
|
+ case GloableParams.LISTNAME_FEEDER_DOWNALL2:
|
|
|
+ queryMakeqty(1);
|
|
|
+ break;
|
|
|
+ //料卷查询
|
|
|
+ case GloableParams.LISTNAME_FEEDER_QUERY2:
|
|
|
+ fragment = new SCSMTQueryFragment();
|
|
|
+ FragmentUtils.switchFragment(this, fragment);
|
|
|
+ break;
|
|
|
+ //品质校验
|
|
|
+ case GloableParams.LISTNAME_QUALITY_VERIFICATION2:
|
|
|
+ fragment = new QualityVerificationFra();
|
|
|
+ FragmentUtils.switchFragment(this, fragment);
|
|
|
+ break;
|
|
|
+ //上线
|
|
|
+ case GloableParams.LISTNAME_GO_ONLINE:
|
|
|
+ confirmOnline();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void confirmOnline() {
|
|
|
+ String dl_mainline = "";
|
|
|
+ if (mLineInfoBean == null) {
|
|
|
+ dl_mainline = "";
|
|
|
+ }else {
|
|
|
+ dl_mainline = mLineInfoBean.getDL_MAINLINE();
|
|
|
+ }
|
|
|
+ new android.app.AlertDialog.Builder(mActivity).setTitle("提示")
|
|
|
+ .setMessage("是否确认上线到实际线别(" + dl_mainline + ")?")
|
|
|
+ .setPositiveButton("是", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ setGoOnline();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton("否", null).create().show();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setGoOnline() {
|
|
|
+ String li_code = mLineInfoBean.getDL_LINECODE(); //线别
|
|
|
+ String ma_code = mLineInfoBean.getDL_MACODE(); //工单
|
|
|
+ String dl_table = mLineInfoBean.getDL_TABLE(); //板面
|
|
|
+
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_PRE_ONLINE)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("li_code", li_code)
|
|
|
+ .addParam("ma_code", ma_code)
|
|
|
+ .addParam("dl_table", dl_table)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ if (progressDialog.isShowing()) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ JSONObject resultObject = new JSONObject(o.toString());
|
|
|
+ if (resultObject.optBoolean("success")) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "上线成功");
|
|
|
+
|
|
|
+ Fragment tmpFragment = new SMTMaterialPreparation();
|
|
|
+ getFragmentManager().beginTransaction()
|
|
|
+ .addToBackStack(null)
|
|
|
+ .replace(R.id.container_function_fragment, tmpFragment, null)
|
|
|
+ .commit();
|
|
|
+
|
|
|
+ // SMTMaterialPreparation fragment = new SMTMaterialPreparation();
|
|
|
+ // FragmentUtils.switchFragment(SMTStandbyFunction.this, fragment);
|
|
|
+
|
|
|
+ String data = resultObject.optString("data");
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ if (progressDialog.isShowing()) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取对应工单产出数
|
|
|
+ *
|
|
|
+ * @param i
|
|
|
+ */
|
|
|
+ private void queryMakeqty(final int i) {
|
|
|
+ progressDialog.show();
|
|
|
+
|
|
|
+ String url = GloableParams.ADDRESS_SMT_QUERY_MADEQTY + "?dl_macode=" + mLineInfoBean.getDL_MACODE()
|
|
|
+ + "&dl_linecode=" + mLineInfoBean.getDL_LINECODE();
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "downall");
|
|
|
+
|
|
|
+ mStringRequest = new StringRequest(Request.Method.GET, url,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (s != null) {
|
|
|
+ try {
|
|
|
+ Log.d("madeqty", s);
|
|
|
+ JSONObject resultObject = new JSONObject(s);
|
|
|
+ if (!resultObject.isNull("data")) {
|
|
|
+ JSONObject dataObject = resultObject.optJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ dl_madeqty = (int) JsonUtils.optLongNotNull(dataObject, "DL_MADEQTY");
|
|
|
+ ma_qty = (int) JsonUtils.optLongNotNull(dataObject, "MA_QTY");
|
|
|
+ showVerificationPop(i);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "产出数获取失败,请重新获取");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dl_madeqty = 0;
|
|
|
+ ma_qty = 0;
|
|
|
+ showVerificationPop(i);
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "产出数获取异常,请重新获取");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "产出数获取失败,请重新获取");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.showErrorToast(volleyError, true);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "downall");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证登录密码
|
|
|
+ *
|
|
|
+ * @param whichFunc 1:全部下料;2:工单切换
|
|
|
+ */
|
|
|
+ private void showVerificationPop(final int whichFunc) {
|
|
|
+ LayoutInflater layoutInflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
+ View popView = layoutInflater.inflate(R.layout.pop_password_verification, null);
|
|
|
+ mCancelTextView = (TextView) popView.findViewById(R.id.pop_password_verification_cancel_tv);
|
|
|
+ mConfirmTextView = (TextView) popView.findViewById(R.id.pop_password_verification_confirm_tv);
|
|
|
+ mPasswordEditText = (ClearableEditText) popView.findViewById(R.id.pop_password_verification_et);
|
|
|
+
|
|
|
+ mConfirmTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ verificationPassword(whichFunc);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mCancelTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closePasswordPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mPasswordPopupWindow = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ mPasswordPopupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ mPasswordPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closePasswordPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
+ mPasswordPopupWindow.showAtLocation(mActivity.getWindow().getDecorView(), Gravity.CENTER, 0, -100);
|
|
|
+ CommonUtil.openKeybord(mPasswordEditText, mActivity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证登录密码
|
|
|
+ *
|
|
|
+ * @param whichFunc
|
|
|
+ */
|
|
|
+ private void verificationPassword(int whichFunc) {
|
|
|
+ String input = mPasswordEditText.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(input)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请输入密码!");
|
|
|
+ } else {
|
|
|
+ String verificationPwd = SharedPreUtil.getString(mActivity, Constants.FLAG.VERIFICATION_PASSWORD, null);
|
|
|
+ if (TextUtils.isEmpty(verificationPwd)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "密码丢失,请重新登录!");
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ closePasswordPopupWindow();
|
|
|
+ } else {
|
|
|
+ if (verificationPwd.equals(input)) {
|
|
|
+ // CommonUtil.toastNoRepeat(mActivity, "验证通过!");
|
|
|
+ closePasswordPopupWindow();
|
|
|
+
|
|
|
+ if (whichFunc == 1)
|
|
|
+ showConfirmAllDownDialog();
|
|
|
+ else if (whichFunc == 2) {
|
|
|
+ showWitchPopupWindow();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "密码错误,请重新输入!");
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ mPasswordEditText.setText("");
|
|
|
+ mPasswordEditText.requestFocus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 切换工单
|
|
|
+ */
|
|
|
+ private void showWitchPopupWindow() {
|
|
|
+ View switchView = View.inflate(mActivity, R.layout.popupwindom_switch_jobs, null);
|
|
|
+ final AlertDialog switchDialog = new AlertDialog.Builder(mActivity).setView(switchView).create();
|
|
|
+
|
|
|
+ final AutoCompleteTextView jobsEditText = (AutoCompleteTextView) switchView.findViewById(R.id.pop_switch_jobs_number_et);
|
|
|
+ jobsEditText.setThreshold(1);
|
|
|
+ final ClearableEditText outputEditText = (ClearableEditText) switchView.findViewById(R.id.pop_switch_jobs_output_et);
|
|
|
+ final ImageView cleanIv = (ImageView) switchView.findViewById(R.id.pop_switch_jobs_clean_iv);
|
|
|
+ RadioGroup mTableRadioGroup = (RadioGroup) switchView.findViewById(R.id.pop_switch_jobs_table_rg);
|
|
|
+ final RadioButton mARadioButton = (RadioButton) switchView.findViewById(R.id.pop_switch_jobs_a_rb);
|
|
|
+ final RadioButton mBRadioButton = (RadioButton) switchView.findViewById(R.id.pop_switch_jobs_b_rb);
|
|
|
+ final TextView mConfirmTextView = (TextView) switchView.findViewById(R.id.pop_switch_jobs_confirm_tv);
|
|
|
+ TextView mCancelTextView = (TextView) switchView.findViewById(R.id.pop_switch_jobs_cancel_tv);
|
|
|
+ final CheckBox orderCheckBox = (CheckBox) switchView.findViewById(R.id.pop_switch_jobs_order_cb);
|
|
|
+ LinearLayout mOperationLinearLayout = (LinearLayout) switchView.findViewById(R.id.pop_switch_jobs_operation_ll);
|
|
|
+ final LinearLayout mExceptionLinearLayout = (LinearLayout) switchView.findViewById(R.id.pop_switch_jobs_exception_ll);
|
|
|
+ final TextView mExceptionTextView = (TextView) switchView.findViewById(R.id.pop_switch_jobs_exception_msg_tv);
|
|
|
+ final TextView mKnownTextView = (TextView) switchView.findViewById(R.id.pop_switch_jobs_exception_confirm_tv);
|
|
|
+
|
|
|
+ mOperationLinearLayout.setVisibility(View.VISIBLE);
|
|
|
+ mExceptionLinearLayout.setVisibility(View.GONE);
|
|
|
+ outputEditText.requestFocus();
|
|
|
+ outputEditText.setText(dl_madeqty + "");
|
|
|
+ outputEditText.setSelection(outputEditText.getText().toString().trim().length());
|
|
|
+
|
|
|
+ cleanIv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ jobsEditText.setText("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mKnownTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mExceptionLinearLayout.setVisibility(View.GONE);
|
|
|
+ mExceptionTextView.setText("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ jobsEditText.addTextChangedListener(new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+ if (!orderCheckBox.isChecked()) {
|
|
|
+ if (s.length() >= 3) {
|
|
|
+ if (!s.toString().matches(Constants.REGEX.NO_SYMBOL)) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.note_number_cannot_contain_special));
|
|
|
+ jobsEditText.setText(null);
|
|
|
+ jobsEditText.requestFocus();
|
|
|
+ } else {
|
|
|
+ fuzzySearch(jobsEditText, MACODE_FUZZY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (s.length() >= 3) {
|
|
|
+ if (!s.toString().matches(Constants.REGEX.NO_SYMBOL)) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.product_code_cannot_contain_special));
|
|
|
+ jobsEditText.setText(null);
|
|
|
+ jobsEditText.requestFocus();
|
|
|
+ } else {
|
|
|
+ fuzzySearch(jobsEditText, PRODCODE_FUZZY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ if (s == null || s.length() == 0) {
|
|
|
+ mConfirmTextView.setEnabled(false);
|
|
|
+ cleanIv.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ mConfirmTextView.setEnabled(true);
|
|
|
+ cleanIv.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ orderCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ if (!isChecked) {
|
|
|
+ jobsEditText.setHint("请输入新工单号");
|
|
|
+ mAutoStringAdapter = new MyArrayAdapter<String>(mActivity, android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
|
|
|
+ jobsEditText.setAdapter(mAutoStringAdapter);
|
|
|
+ } else {
|
|
|
+ jobsEditText.setHint("请输入产品代码");
|
|
|
+ mAutoStringAdapter = new MyArrayAdapter<String>(mActivity, android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
|
|
|
+ jobsEditText.setAdapter(mAutoStringAdapter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ mConfirmTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ final String linecode = mLineInfoBean.getDL_LINECODE();
|
|
|
+ final String jobs = jobsEditText.getText().toString().trim();
|
|
|
+ String outputStr = outputEditText.getText().toString().trim();
|
|
|
+
|
|
|
+ String table = "A";
|
|
|
+ if (!TextUtils.isEmpty(jobs)) {
|
|
|
+ if (mARadioButton.isChecked()) {
|
|
|
+ table = "A";
|
|
|
+ } else if (mBRadioButton.isChecked()) {
|
|
|
+ table = "B";
|
|
|
+ }
|
|
|
+ if (jobs.equals(mLineInfoBean.getDL_MACODE()) && table.equals(mLineInfoBean.getDL_TABLE())) {
|
|
|
+ if (!orderCheckBox.isChecked()) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "无法切换至相同的工单号+板面!");
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "无法切换至相同的产品代码+板面!");
|
|
|
+ }
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ if (TextUtils.isEmpty(outputStr)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请输入原工单产出数");
|
|
|
+ } else {
|
|
|
+ int quantity = (int) Long.parseLong(outputStr);
|
|
|
+ if (quantity >= dl_madeqty && quantity <= ma_qty) {
|
|
|
+ switchJobs(linecode, jobs, table, jobsEditText, outputEditText, switchDialog, orderCheckBox.isChecked(), mExceptionLinearLayout, mExceptionTextView);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "数量必须介于产出数和工单数之间");
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ outputEditText.setText(dl_madeqty + "");
|
|
|
+ outputEditText.setSelection(outputEditText.getText().toString().trim().length());
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "产出数应为正整数");
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mCancelTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ // closeSwitchPopupWindow();
|
|
|
+ switchDialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ switchDialog.show();
|
|
|
+ CommonUtil.openKeybord(outputEditText, mActivity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 模糊查询
|
|
|
+ *
|
|
|
+ * @param jobsEditText
|
|
|
+ * @param fuzzy
|
|
|
+ */
|
|
|
+ private void fuzzySearch(final AutoCompleteTextView jobsEditText, final int fuzzy) {
|
|
|
+ String url = null;
|
|
|
+ try {
|
|
|
+ if (fuzzy == MACODE_FUZZY)
|
|
|
+ url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH
|
|
|
+ + "?inoutNo=" + URLEncoder.encode(jobsEditText.getText().toString().toLowerCase(), "utf-8");
|
|
|
+ else if (fuzzy == PRODCODE_FUZZY)
|
|
|
+ url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH_PRODUCT
|
|
|
+ + "?pr_code=" + URLEncoder.encode(jobsEditText.getText().toString().toLowerCase(), "utf-8");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if (fuzzy == MACODE_FUZZY)
|
|
|
+ url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH
|
|
|
+ + "?inoutNo=" + jobsEditText.getText().toString().toLowerCase();
|
|
|
+ else
|
|
|
+ url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH_PRODUCT
|
|
|
+ + "?pr_code=" + jobsEditText.getText().toString().toLowerCase();
|
|
|
+ }
|
|
|
+
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "fuzzysearch");
|
|
|
+
|
|
|
+ mStringRequest = new StringRequest(Request.Method.GET, url,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ Log.e("autoStrings", s);
|
|
|
+ List<String> mAutoStrings = new ArrayList<String>();
|
|
|
+ try {
|
|
|
+ mAutoStrings.clear();
|
|
|
+ mAutoStringAdapter = new MyArrayAdapter<String>(mActivity, android.R.layout.simple_dropdown_item_1line, mAutoStrings);
|
|
|
+ if (jobsEditText != null) {
|
|
|
+ jobsEditText.setAdapter(mAutoStringAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject resultObject = new JSONObject(s);
|
|
|
+ JSONArray dataArray = resultObject.optJSONArray("data");
|
|
|
+ if (dataArray != null) {
|
|
|
+ for (int i = 0; i < dataArray.length(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.optJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ String pi_inoutno = JsonUtils.optStringNotNull(dataObject, fuzzy == MACODE_FUZZY ? "MA_CODE" : "PR_CODE");
|
|
|
+ if (!TextUtils.isEmpty(pi_inoutno))
|
|
|
+ mAutoStringAdapter.add(pi_inoutno);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ CommonUtil.showErrorToast(volleyError);
|
|
|
+ jobsEditText.setText("");
|
|
|
+ jobsEditText.requestFocus();
|
|
|
+ CommonUtil.openKeybord(jobsEditText, mActivity);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "fuzzysearch");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 切换工单
|
|
|
+ *
|
|
|
+ * @param linecode 线别
|
|
|
+ * @param jobs 工单
|
|
|
+ * @param table 板面
|
|
|
+ * @param jobsEditText 工单输入框
|
|
|
+ * @param outputEditText
|
|
|
+ * @param switchDialog 弹出框
|
|
|
+ * @param checked 是否被选中
|
|
|
+ * @param mExceptionLinearLayout
|
|
|
+ * @param mExceptionTextView
|
|
|
+ */
|
|
|
+ private void switchJobs(final String linecode, final String jobs, String table, final AutoCompleteTextView jobsEditText, final ClearableEditText outputEditText, final AlertDialog switchDialog, final boolean checked, final LinearLayout mExceptionLinearLayout, final TextView mExceptionTextView) {
|
|
|
+ progressDialog.show();
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "change");
|
|
|
+
|
|
|
+ final String finalTable = table;
|
|
|
+ mStringRequest = new StringRequest(Request.Method.POST, GloableParams.ADDRESS_SMT_CHANGE_MAKE,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ switchDialog.dismiss();
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ Log.d("result", s);
|
|
|
+ JSONObject resultObject = new JSONObject(s);
|
|
|
+ if (resultObject.optBoolean("success")) {
|
|
|
+ JSONObject dataObject = resultObject.optJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ JSONObject devicelineObject = dataObject.optJSONObject("deviceline");
|
|
|
+ if (devicelineObject != null) {
|
|
|
+ mLineInfoBean = new LineInfoBean();
|
|
|
+ mLineInfoBean.setDL_ID(JsonUtils.optLongNotNull(devicelineObject, "DL_ID"));
|
|
|
+ mLineInfoBean.setDL_DECODE(JsonUtils.optStringNull(devicelineObject, "DL_DECODE"));
|
|
|
+ mLineInfoBean.setDL_LINECODE(JsonUtils.optStringNull(devicelineObject, "DL_LINECODE"));
|
|
|
+ mLineInfoBean.setDL_MACODE(JsonUtils.optStringNull(devicelineObject, "DL_MACODE"));
|
|
|
+ mLineInfoBean.setDL_TABLE(JsonUtils.optStringNull(devicelineObject, "DL_TABLE"));
|
|
|
+ mLineInfoBean.setDL_STATUSCODE(JsonUtils.optStringNull(devicelineObject, "DL_STATUSCODE"));
|
|
|
+ mLineInfoBean.setDL_STATUS(JsonUtils.optStringNull(devicelineObject, "DL_STATUS"));
|
|
|
+ mLineInfoBean.setPS_ID(JsonUtils.optLongNotNull(devicelineObject, "PS_ID"));
|
|
|
+ mLineInfoBean.setMA_ID(JsonUtils.optLongNotNull(devicelineObject, "MA_ID"));
|
|
|
+ mLineInfoBean.setDL_PRODCODE(JsonUtils.optStringNotNull(devicelineObject, "DL_PRODCODE"));
|
|
|
+
|
|
|
+ mLineInfoBean.setDL_MAINLINE(JsonUtils.optStringNotNull(devicelineObject, "DL_MAINLINE"));
|
|
|
+
|
|
|
+ PdaApplication.putDataCache2Map(Constants.FLAG.SMT_DEVICE_LINE_CACHE, mLineInfoBean);
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "工单切换成功!");
|
|
|
+
|
|
|
+ tv_dl_linecode.setText(mLineInfoBean.getDL_LINECODE());
|
|
|
+ tv_dl_mainline.setText(mLineInfoBean.getDL_MAINLINE());
|
|
|
+ tv_dl_table.setText(mLineInfoBean.getDL_TABLE() + "面");
|
|
|
+ tv_dl_macode.setText(mLineInfoBean.getDL_MACODE());
|
|
|
+ tv_dl_prodcode.setText(mLineInfoBean.getDL_PRODCODE());
|
|
|
+ }
|
|
|
+ String smtLocation = dataObject.optString("smtlocation");
|
|
|
+ Log.d("smtLocation", smtLocation);
|
|
|
+ if (!TextUtils.isEmpty(smtLocation))
|
|
|
+ SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, smtLocation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String errorToast = CommonUtil.showErrorToast(volleyError, false);
|
|
|
+ mExceptionLinearLayout.setVisibility(View.VISIBLE);
|
|
|
+ mExceptionTextView.setText(errorToast);
|
|
|
+ jobsEditText.setText("");
|
|
|
+ outputEditText.setText(dl_madeqty + "");
|
|
|
+ outputEditText.setSelection(outputEditText.getText().toString().trim().length());
|
|
|
+ outputEditText.requestFocus();
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Map<String, String> getParams() throws AuthFailureError {
|
|
|
+ Map<String, String> params = new HashMap<String, String>();
|
|
|
+ params.put("dl_linecode", linecode);
|
|
|
+ params.put("ma_code", jobs);
|
|
|
+ params.put("table", finalTable);
|
|
|
+ params.put("dl_actmadeqty", outputEditText.getText().toString().trim());
|
|
|
+ params.put("has_noma", checked + "");
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "change");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closePasswordPopupWindow() {
|
|
|
+ if (mPasswordPopupWindow != null) {
|
|
|
+ mPasswordPopupWindow.dismiss();
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*=============================全部下料=========================================*/
|
|
|
+ //全部下料对话框
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 弹出全部下料对话框
|
|
|
+ */
|
|
|
+ private void showConfirmAllDownDialog() {
|
|
|
+ final ClearableEditText quantityEditText = (ClearableEditText) downAllView.findViewById(R.id.pop_smt_down_all_et);
|
|
|
+ CheckBox unbindCheckBox = downAllView.findViewById(R.id.pop_smt_down_unbind_cb);
|
|
|
+ unbindCheckBox.setChecked(true);
|
|
|
+ final TextView mConfirmTextView = (TextView) downAllView.findViewById(R.id.pop_smt_down_all_confirm_tv);
|
|
|
+ TextView mCancelTextView = (TextView) downAllView.findViewById(R.id.pop_smt_down_all_cancel_tv);
|
|
|
+
|
|
|
+ quantityEditText.setText(dl_madeqty + "");
|
|
|
+ quantityEditText.setSelection(quantityEditText.getText().toString().trim().length());
|
|
|
+
|
|
|
+ mConfirmTextView.addTextChangedListener(new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ if (s == null || s.length() == 0) {
|
|
|
+ mConfirmTextView.setEnabled(false);
|
|
|
+ } else {
|
|
|
+ mConfirmTextView.setEnabled(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mConfirmTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String quantityStr = quantityEditText.getText().toString().trim();
|
|
|
+ try {
|
|
|
+ int quantity = (int) Long.parseLong(quantityStr);
|
|
|
+ if (quantity >= dl_madeqty && quantity <= ma_qty) {
|
|
|
+ disposeAllDown(quantity, unbindCheckBox.isChecked());
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "数量必须介于产出数和工单数之间");
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ quantityEditText.setText(dl_madeqty + "");
|
|
|
+ quantityEditText.setSelection(quantityEditText.getText().toString().trim().length());
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "产出数应为正整数");
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mCancelTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ // closeDownAllPopupWindow();
|
|
|
+ switchDialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ switchDialog.show();
|
|
|
+ //
|
|
|
+ // mDownAllPopupWindow = new PopupWindow(downAllView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ //
|
|
|
+ // mDownAllPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ // @Override
|
|
|
+ // public void onDismiss() {
|
|
|
+ // closeDownAllPopupWindow();
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
+ // mDownAllPopupWindow.showAtLocation(mActivity.getWindow().getDecorView(), Gravity.CENTER, 0, -100);
|
|
|
+ CommonUtil.openKeybord(quantityEditText, mActivity);
|
|
|
+ }
|
|
|
+
|
|
|
+ //全部下料
|
|
|
+ private void disposeAllDown(int quantity, boolean unbind) {
|
|
|
+ showLoadingView();
|
|
|
+ VolleyUtil.getVolleyUtil().requestSMTAllDown(getActivity(),
|
|
|
+ GloableParams.ADDRESS_SMT_CUTTING_ALLSTOCK,
|
|
|
+ VolleyUtil.METHOD_POST,
|
|
|
+ VolleyUtil.FRAGMENT_SCMAKE_SMTALLDOWN,
|
|
|
+ mLineInfoBean.getDL_MACODE(),
|
|
|
+ mLineInfoBean.getDL_LINECODE(),
|
|
|
+ quantity,
|
|
|
+ unbind);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*======================ConfirmDialog==========================================*/
|
|
|
+ ConfirmDialog confirmDialog;
|
|
|
+ boolean isOk = false;
|
|
|
+
|
|
|
+ //关闭确认对话框
|
|
|
+ public void closeConfirmDialog() {
|
|
|
+ confirmDialog.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*============================Volley Handler=========================================*/
|
|
|
+ Handler volleyHandler = new Handler() {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ // closeDownAllPopupWindow();
|
|
|
+ switchDialog.dismiss();
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String noticeMsg = (String) msg.obj;
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, noticeMsg);
|
|
|
+ if (msg.what == VolleyUtil.SUCCESS_SUCCESS) {
|
|
|
+ SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, "");
|
|
|
+ getActivity().getSupportFragmentManager().popBackStack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ /*============================公用方法=========================================*/
|
|
|
+ /**
|
|
|
+ * @注释:显示错误提示
|
|
|
+ */
|
|
|
+ ConfirmDialog noticeDialog;
|
|
|
+
|
|
|
+ private void showNotice(String noticeMsg) {
|
|
|
+ noticeDialog = new ConfirmDialog(getActivity());
|
|
|
+ noticeDialog.show(noticeMsg, ConfirmDialog.NOTICE);
|
|
|
+
|
|
|
+ new AsyncTask<String, Void, Float>() {
|
|
|
+ @Override
|
|
|
+ protected Float doInBackground(String... params) {
|
|
|
+ try {
|
|
|
+ //notice显示1.5s
|
|
|
+ Thread.sleep(1500);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onPostExecute(Float aFloat) {
|
|
|
+ //notice退出
|
|
|
+ //noticeTextView.startAnimation(noticeOut);
|
|
|
+ // noticeTextView.setVisibility(View.GONE);
|
|
|
+ noticeDialog.dismiss();
|
|
|
+ }
|
|
|
+ }.execute();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示loadingView
|
|
|
+ */
|
|
|
+ private void showLoadingView() {
|
|
|
+ if (!progressDialog.isShowing()) {
|
|
|
+ progressDialog.show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ Log.e("SMTINDEX", "onKeyDown");
|
|
|
+ if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
|
|
+ if (progressDialog != null && progressDialog.isShowing()) {
|
|
|
+ // loadingView.dismiss();
|
|
|
+ // VolleyUtil.distoryVolley();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (confirmDialog != null && confirmDialog.isShowing()) {
|
|
|
+ Log.e("SMTINDEX", "confirmDialog");
|
|
|
+ closeConfirmDialog();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (noticeDialog != null && noticeDialog.isShowing()) {
|
|
|
+ noticeDialog.dismiss();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|