|
|
@@ -0,0 +1,1737 @@
|
|
|
+package com.uas.uaspda.fragment;
|
|
|
+
|
|
|
+import android.app.ActionBar;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+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.SpannableString;
|
|
|
+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.view.Window;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
+import android.view.inputmethod.InputMethodManager;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.ArrayAdapter;
|
|
|
+import android.widget.AutoCompleteTextView;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.EditText;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.ListView;
|
|
|
+import android.widget.PopupWindow;
|
|
|
+import android.widget.RadioButton;
|
|
|
+import android.widget.RadioGroup;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+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.uaspda.R;
|
|
|
+import com.uas.uaspda.activity.FunctionActivity;
|
|
|
+import com.uas.uaspda.application.PdaApplication;
|
|
|
+import com.uas.uaspda.bean.LineInfoBean;
|
|
|
+import com.uas.uaspda.bean.SmtDslBean;
|
|
|
+import com.uas.uaspda.global.GloableParams;
|
|
|
+import com.uas.uaspda.tools.DataSourceManager;
|
|
|
+import com.uas.uaspda.tools.SharedPreUtil;
|
|
|
+import com.uas.uaspda.tools.VolleyUtil;
|
|
|
+import com.uas.uaspda.util.CommonUtil;
|
|
|
+import com.uas.uaspda.util.Constants;
|
|
|
+import com.uas.uaspda.util.FragmentUtils;
|
|
|
+import com.uas.uaspda.util.HttpCallback;
|
|
|
+import com.uas.uaspda.util.HttpParams;
|
|
|
+import com.uas.uaspda.util.JsonUtils;
|
|
|
+import com.uas.uaspda.util.LogUtil;
|
|
|
+import com.uas.uaspda.util.MyArrayAdapter;
|
|
|
+import com.uas.uaspda.util.SoundUtil;
|
|
|
+import com.uas.uaspda.util.VolleyRequest;
|
|
|
+import com.uas.uaspda.view.ClearableEditText;
|
|
|
+import com.uas.uaspda.view.TextViewWithButton;
|
|
|
+
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @note:SMTChild复检校验
|
|
|
+ */
|
|
|
+public class SCSMTInspectionFragment extends BaseFragment implements View.OnClickListener {
|
|
|
+ private static final String COLLECT_LOCATION = "请录入站位编号";
|
|
|
+ private static final String COLLECT_PRODCODE = "请录入物料编号";
|
|
|
+ private static final String COLLECT_OLD_PRODCODE = "站位采集成功,请采集原物料号";
|
|
|
+
|
|
|
+ //校验方式
|
|
|
+ private final int FEEDER_WITH_LOCATION = 1;
|
|
|
+ private final int FEEDER_ORDER = 2;
|
|
|
+ private final int BARCODE_WITH_LOCATION = 3;
|
|
|
+ private final int BARCODE_ORDER = 4;
|
|
|
+
|
|
|
+ //当前校验方式,默认为1
|
|
|
+ private int curCheckStyle = FEEDER_WITH_LOCATION;
|
|
|
+ JSONObject makeCraft;
|
|
|
+ JSONArray makeSMTLocation;
|
|
|
+
|
|
|
+ TextView tvMsgNotice;
|
|
|
+ TextView tvMsgProdcode;
|
|
|
+ TextView tvMsgLocation;
|
|
|
+ TextView tvMsgBarcode;
|
|
|
+ TextView tvMsgQuantity;
|
|
|
+ TextView tvMsgSpec;
|
|
|
+
|
|
|
+ ClearableEditText etFecode, etLocation, etOrder;
|
|
|
+ LinearLayout llOrder, llDouble;
|
|
|
+ RelativeLayout rlCollect, rlChange;
|
|
|
+ View parentView;
|
|
|
+
|
|
|
+ String TAG = "SMTCHECK:";
|
|
|
+ int wrongColor, rightColor;
|
|
|
+ TextView tvCheckStyle;
|
|
|
+ int mcId = -1;
|
|
|
+ private Button btnChange;
|
|
|
+ private ImageView mCleanIv, mSmtQueryImageView;
|
|
|
+
|
|
|
+ private TextView mLinecodeTextView, mTableTextView, mMacodeTextView;
|
|
|
+ private LineInfoBean mLineInfoBean;
|
|
|
+ private AutoCompleteTextView mCollectEditText;
|
|
|
+ private Button mConfirmButton;
|
|
|
+ private String mSmtLocationCache;
|
|
|
+ private boolean mIgnoreFocusChange = false;
|
|
|
+ private SmtDslBean mSmtDslBean = new SmtDslBean();
|
|
|
+ private TextViewWithButton mLocationTextView;
|
|
|
+ private RadioGroup mModeRadioGroup;
|
|
|
+ private RadioButton mUpRadioButton, mJoinRadioButton;
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private MyArrayAdapter<String> mAutoStringAdapter;
|
|
|
+ private TextView mRecalibrationTextView;
|
|
|
+ private String mNoticeStr;
|
|
|
+ private boolean mOrderSwitch = false, mMaterialSwitch;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_scmake_smtfeederchild_check;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ ((FunctionActivity) getActivity()).setSmtQueryIvVisible(true);
|
|
|
+
|
|
|
+ mOrderSwitch = SharedPreUtil.getInt(mActivity, Constants.FLAG.CACHE_DEFAULT_ORDER_SWITCH + CommonUtil.getUserName(mActivity), 0) == 1;
|
|
|
+ mMaterialSwitch = SharedPreUtil.getInt(mActivity, Constants.FLAG.CACHE_DEFAULT_MATERIAL_SWITCH + CommonUtil.getUserName(mActivity), 0) == 1;
|
|
|
+ //->校验方式
|
|
|
+ tvCheckStyle = (TextView) root.findViewById(R.id.tvCurCheckContent);
|
|
|
+ btnChange = (Button) root.findViewById(R.id.btn_changecheck_smtcheck);
|
|
|
+ //->提示信息
|
|
|
+ rlChange = (RelativeLayout) root.findViewById(R.id.ll_change_smtchildcheck);
|
|
|
+ tvMsgNotice = (TextView) root.findViewById(R.id.tv_innernotice_msgtitle_scmake);
|
|
|
+ tvMsgProdcode = (TextView) root.findViewById(R.id.tv_innernotice_1_scmake);
|
|
|
+ tvMsgLocation = (TextView) root.findViewById(R.id.tv_innernotice_2_scmake);
|
|
|
+ tvMsgBarcode = (TextView) root.findViewById(R.id.tv_innernotice_3_scmake);
|
|
|
+ tvMsgQuantity = (TextView) root.findViewById(R.id.tv_innernotice_4_scmake);
|
|
|
+ tvMsgSpec = (TextView) root.findViewById(R.id.tv_innernotice_5_scmake);
|
|
|
+ mModeRadioGroup = (RadioGroup) root.findViewById(R.id.smt_check_mode_rg);
|
|
|
+ mUpRadioButton = (RadioButton) root.findViewById(R.id.smt_check_up_rb);
|
|
|
+ mJoinRadioButton = (RadioButton) root.findViewById(R.id.smt_check_join_rb);
|
|
|
+ mCleanIv = (ImageView) root.findViewById(R.id.smt_check_prodcode_clean_iv);
|
|
|
+ mSmtQueryImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_smt_query_iv);
|
|
|
+ mRecalibrationTextView = (TextView) root.findViewById(R.id.smt_check_recalibration_tv);
|
|
|
+
|
|
|
+ wrongColor = getResources().getColor(R.color.text_error);
|
|
|
+ rightColor = getResources().getColor(R.color.green);
|
|
|
+ //->录入信息
|
|
|
+ etFecode = (ClearableEditText) root.findViewById(R.id.et_fecode_smtchildcheck);
|
|
|
+ etLocation = (ClearableEditText) root.findViewById(R.id.et_location_smtchildcheck);
|
|
|
+ etOrder = (ClearableEditText) root.findViewById(R.id.et_order_smtchildcheck);
|
|
|
+ etFecode.setEnabled(false);
|
|
|
+ etLocation.setEnabled(false);
|
|
|
+ etOrder.setEnabled(false);
|
|
|
+
|
|
|
+ parentView = getActivity().getWindow().findViewById(Window.ID_ANDROID_CONTENT);
|
|
|
+ rlCollect = (RelativeLayout) root.findViewById(R.id.rl_collect_smtchildcheck);
|
|
|
+ llDouble = (LinearLayout) root.findViewById(R.id.ll_double_smtchildcheck);
|
|
|
+ llOrder = (LinearLayout) root.findViewById(R.id.ll_order_smtchildcheck);
|
|
|
+
|
|
|
+ mLinecodeTextView = (TextView) root.findViewById(R.id.smt_check_linecode_tv);
|
|
|
+ mTableTextView = (TextView) root.findViewById(R.id.smt_check_table_tv);
|
|
|
+ mMacodeTextView = (TextView) root.findViewById(R.id.smt_check_macode_tv);
|
|
|
+ mCollectEditText = (AutoCompleteTextView) root.findViewById(R.id.smt_check_prodcode_et);
|
|
|
+ mConfirmButton = (Button) root.findViewById(R.id.smt_check_confirm_btn);
|
|
|
+ mLocationTextView = (TextViewWithButton) root.findViewById(R.id.smt_check_location_tv);
|
|
|
+
|
|
|
+ mCollectEditText.requestFocus();
|
|
|
+
|
|
|
+
|
|
|
+ //接口回调
|
|
|
+ VolleyUtil.setVolleyHandler(handler);
|
|
|
+
|
|
|
+ mLineInfoBean = (LineInfoBean) PdaApplication.getDataCacheFromMap(Constants.FLAG.SMT_DEVICE_LINE_CACHE);
|
|
|
+
|
|
|
+
|
|
|
+ /*try {
|
|
|
+ makeCraft = new JSONObject(makeCraftStr);
|
|
|
+ mcId = makeCraft.getInt("mc_id");
|
|
|
+ Log.e(TAG, "makeCraft:" + makeCraft.toString());
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ JSONObject paramJson = new JSONObject();
|
|
|
+ try {
|
|
|
+ paramJson.put("id", mcId);
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ showLoadingView();
|
|
|
+ //获取网络数据
|
|
|
+ requestType = VolleyUtil.FRAGMENT_SCMAKE_SMTCHECK_LOCATION;
|
|
|
+ VolleyUtil.getVolleyUtil().requestSMTCheckLocation(getActivity(), GloableParams.ADDRESS_SMTCHECK_LOCATION_APPLY, VolleyUtil.METHOD_GET,
|
|
|
+ requestType, mcId);*/
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ mCleanIv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mCollectEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ String collect = mCollectEditText.getText().toString().trim();
|
|
|
+ if (!TextUtils.isEmpty(collect)) {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_DONE
|
|
|
+ || actionId == EditorInfo.IME_ACTION_SEND
|
|
|
+ || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ confirmEvent(collect);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mCollectEditText.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.length() == 0) {
|
|
|
+ mConfirmButton.setEnabled(false);
|
|
|
+ mCleanIv.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ mConfirmButton.setEnabled(true);
|
|
|
+ mCleanIv.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+
|
|
|
+// String collectHint = mCollectEditText.getHint().toString();
|
|
|
+//
|
|
|
+// if (COLLECT_PRODCODE.equals(collectHint) || COLLECT_OLD_PRODCODE.equals(collectHint)) {
|
|
|
+// if (s.length() >= 3) {
|
|
|
+// if (!s.toString().matches(Constants.REGEX.NO_SYMBOL)) {
|
|
|
+// CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.prodcode_cannot_contain_special));
|
|
|
+// mCollectEditText.setText(null);
|
|
|
+// mCollectEditText.requestFocus();
|
|
|
+// } else {
|
|
|
+// fuzzySearch();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mConfirmButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String collect = mCollectEditText.getText().toString().trim();
|
|
|
+ confirmEvent(collect);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ mLocationTextView.setOnTextClearListener(new TextViewWithButton.OnTextClearListener() {
|
|
|
+ @Override
|
|
|
+ public void onTextClear() {
|
|
|
+ mCollectEditText.setHint(COLLECT_LOCATION);
|
|
|
+ mCollectEditText.setText("");
|
|
|
+
|
|
|
+ mAutoStringAdapter = new MyArrayAdapter<String>(mActivity, android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
|
|
|
+ mCollectEditText.setAdapter(mAutoStringAdapter);
|
|
|
+
|
|
|
+// tvMsgNotice.setText("");
|
|
|
+// tvMsgProdcode.setText("");
|
|
|
+// tvMsgLocation.setText("");
|
|
|
+// tvMsgBarcode.setText("");
|
|
|
+// tvMsgQuantity.setText("");
|
|
|
+// tvMsgSpec.setText("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mModeRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
|
+ mLocationTextView.setText("");
|
|
|
+ tvMsgNotice.setText("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mSmtQueryImageView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ Fragment fragment = new SCSMTQueryFragment();
|
|
|
+ FragmentUtils.switchFragment(SCSMTInspectionFragment.this, fragment);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mRecalibrationTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ new AlertDialog.Builder(mActivity).setTitle("提示")
|
|
|
+ .setMessage("重新校验将会清空所有站位的校验记录,是否确定?")
|
|
|
+ .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ mLocationTextView.setText("");
|
|
|
+ startCheck();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton(R.string.cancel, null).create().show();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重新校验
|
|
|
+ */
|
|
|
+ private void startCheck() {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = GloableParams.ADDRESS_CHECK_LOCATIONDATAREPEATCHECK + "?linecode=" + (mLineInfoBean == null ? "" : mLineInfoBean.getDL_LINECODE());
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "startcheck");
|
|
|
+
|
|
|
+ mStringRequest = new StringRequest(Request.Method.GET, url,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ try {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ JSONObject resultObject = new JSONObject(s);
|
|
|
+ JSONObject dataObject = resultObject.optJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ double notCheckCount = JsonUtils.optDoubleNotNull(dataObject, "NotCheckCount");
|
|
|
+ String notice = "";
|
|
|
+ if (notCheckCount == 0) {
|
|
|
+ notice = notice + "校验已完成";
|
|
|
+ mNoticeStr = notice;
|
|
|
+ SoundUtil.play(SoundUtil.SOUND_CERES);
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tvMsgNotice.setText(notice);
|
|
|
+ } else {
|
|
|
+ notice = notice + "未校验站位"
|
|
|
+ + CommonUtil.doubleFormat(notCheckCount) + "条";
|
|
|
+
|
|
|
+ JSONArray notFeedArray = dataObject.optJSONArray("NotCheckLocation");
|
|
|
+ if (notFeedArray != null && notFeedArray.length() != 0) {
|
|
|
+ notice = notice + "\n站位:\n";
|
|
|
+ for (int i = 0; i < notFeedArray.length(); i++) {
|
|
|
+ JSONObject notCheckObject = notFeedArray.optJSONObject(i);
|
|
|
+ if (notCheckObject != null) {
|
|
|
+ String psl_location = JsonUtils.optStringNotNull(notCheckObject, "PSL_LOCATION");
|
|
|
+ if (i == 0 && mOrderSwitch) {
|
|
|
+ mCollectEditText.setText(psl_location);
|
|
|
+ confirmEvent(psl_location);
|
|
|
+ }
|
|
|
+ notice = notice + psl_location + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ notice = notice.substring(0, notice.length() - 1);
|
|
|
+ }
|
|
|
+ mNoticeStr = notice;
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, 5, 5 + CommonUtil.doubleFormat(notCheckCount).length(), R.color.blue_800);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String errorToast = CommonUtil.showErrorToast(volleyError, false);
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tvMsgNotice.setText(errorToast);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "startcheck");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fuzzySearch() {
|
|
|
+ String url = null;
|
|
|
+ try {
|
|
|
+ url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH_PRODUCT
|
|
|
+ + "?pr_code=" + URLEncoder.encode(mCollectEditText.getText().toString().toLowerCase(), "utf-8");
|
|
|
+
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH_PRODUCT
|
|
|
+ + "?pr_code=" + mCollectEditText.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 (mCollectEditText != null) {
|
|
|
+ mCollectEditText.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, "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);
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ mCollectEditText.requestFocus();
|
|
|
+ CommonUtil.openKeybord(mCollectEditText, 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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void confirmEvent(final String collect) {
|
|
|
+ final String location = mLocationTextView.getText().toString().trim();
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(location)) {
|
|
|
+ locationCheck(collect, location);
|
|
|
+ } else {
|
|
|
+ mSmtDslBean.setDsl_barcode(collect);
|
|
|
+ /*if (mUpRadioButton.isChecked() || (mJoinRadioButton.isChecked() && COLLECT_PRODCODE.equals(mCollectEditText.getHint().toString()))) {
|
|
|
+ smtCheck(collect, location);
|
|
|
+ } else {
|
|
|
+ joinDataCheck(collect, location);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ if (mMaterialSwitch) {
|
|
|
+ requestCheck(collect, location);
|
|
|
+ } else {
|
|
|
+ smtCheck(collect, location);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void requestCheck(String collect, String location) {
|
|
|
+ progressDialog.show();
|
|
|
+ Map<String, Object> dslMap = new HashMap<>();
|
|
|
+ dslMap.put("dsl_location", location);
|
|
|
+ dslMap.put("dsl_prodcode", collect);
|
|
|
+ dslMap.put("success", true);
|
|
|
+
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_SMT_FORECASTDATACHECK)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("dsl", JSON.toJSONString(dslMap))
|
|
|
+ .addParam("deviceLineMake", JSON.toJSONString(mLineInfoBean))
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ if (progressDialog.isShowing()) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ successCheckData(collect, location);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ if (progressDialog.isShowing()) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+
|
|
|
+ String notice = failStr + "\n" + mNoticeStr;
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, (failStr + "\n").length(), notice.length(), R.color.green);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ mCollectEditText.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mCollectEditText.requestFocus();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+
|
|
|
+ int smtCheckErr = SharedPreUtil.getInt(mActivity, Constants.FLAG.SMT_CHECK_ERROR, 0);
|
|
|
+ if (smtCheckErr == 1) {
|
|
|
+ failCheckData(collect, location);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void joinDataCheck(final String collect, final String location) {
|
|
|
+ progressDialog.show();
|
|
|
+
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "datacheck");
|
|
|
+
|
|
|
+ mStringRequest = new StringRequest(Request.Method.POST, GloableParams.ADDRESS_SMT_JOIN_FORECASTDATA_CHECK,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ joinDataCheck(collect, location, "原物料号校验正确", true);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String errorToast = CommonUtil.showErrorToast(volleyError, false);
|
|
|
+ joinDataCheck(collect, location, errorToast, false);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @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<>();
|
|
|
+ Map<String, Object> dslMap = new HashMap<>();
|
|
|
+ if (mUpRadioButton.isChecked()) {
|
|
|
+ dslMap.put("type", "loading");
|
|
|
+ } else if (mJoinRadioButton.isChecked()) {
|
|
|
+ dslMap.put("type", "join");
|
|
|
+ }
|
|
|
+ dslMap.put("dsl_location", location);
|
|
|
+ dslMap.put("dsl_prodcode", collect);
|
|
|
+ dslMap.put("success", true);
|
|
|
+
|
|
|
+ params.put("dsl", JSON.toJSONString(dslMap));
|
|
|
+ params.put("deviceLineMake", JSON.toJSONString(mLineInfoBean));
|
|
|
+ Log.d("paramjson", params.toString());
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "datacheck");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void joinDataCheck(String collect, String location, String dataCheckResult, boolean isSuccess) {
|
|
|
+ tvMsgProdcode.setText("");
|
|
|
+ tvMsgLocation.setText("");
|
|
|
+ tvMsgBarcode.setText("");
|
|
|
+ tvMsgQuantity.setText("");
|
|
|
+ tvMsgSpec.setText("");
|
|
|
+
|
|
|
+ collect = mLocationTextView.getText().toString().trim();
|
|
|
+
|
|
|
+ if (!TextUtils.isEmpty(mSmtLocationCache)) {
|
|
|
+ try {
|
|
|
+ JSONArray locationArray = new JSONArray(mSmtLocationCache);
|
|
|
+ boolean isExist = false;
|
|
|
+ for (int i = 0; i < locationArray.length(); i++) {
|
|
|
+ JSONObject locationObject = locationArray.getJSONObject(i);
|
|
|
+ if (collect.equals(JsonUtils.optStringNotNull(locationObject, "PSL_LOCATION"))) {
|
|
|
+ isExist = true;
|
|
|
+ mLocationTextView.setText(collect);
|
|
|
+ mCollectEditText.setText("");
|
|
|
+
|
|
|
+ String psl_prodcode = JsonUtils.optStringNotNull(locationObject, "PSL_PRODCODE");
|
|
|
+ String psl_repcode = JsonUtils.optStringNotNull(locationObject, "PSL_REPCODE");
|
|
|
+ mSmtDslBean = new SmtDslBean();
|
|
|
+ mSmtDslBean.setDsl_location(location);
|
|
|
+ mSmtDslBean.setDsl_prodcode(psl_prodcode);
|
|
|
+ mSmtDslBean.setDsl_repcode(psl_repcode);
|
|
|
+
|
|
|
+ mAutoStringAdapter = new MyArrayAdapter<String>(mActivity, android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
|
|
|
+ mCollectEditText.setAdapter(mAutoStringAdapter);
|
|
|
+
|
|
|
+ mCollectEditText.setHint(COLLECT_PRODCODE);
|
|
|
+ if (!TextUtils.isEmpty(psl_repcode)) {
|
|
|
+ String[] repcodes = psl_repcode.split(",");
|
|
|
+ String notice = dataCheckResult + "\n请采集接料的物料号";
|
|
|
+ for (int j = 0; j < repcodes.length; j++) {
|
|
|
+ String repcode = repcodes[j];
|
|
|
+ notice = notice + "\n" + repcode;
|
|
|
+ }
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ if (isSuccess) {
|
|
|
+ tvMsgNotice.setText(notice);
|
|
|
+ } else {
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, 0, dataCheckResult.length(), R.color.red);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ }
|
|
|
+ } else if (!TextUtils.isEmpty(psl_prodcode)) {
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ if (isSuccess) {
|
|
|
+ tvMsgNotice.setText(dataCheckResult + "\n请采集接料的物料号\n" + psl_prodcode);
|
|
|
+ } else {
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(dataCheckResult + "\n请采集接料的物料号\n" + psl_prodcode, mActivity, 0, dataCheckResult.length(), R.color.red);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ if (isSuccess) {
|
|
|
+ CommonUtil.spanString(dataCheckResult + "\n物料编号获取失败", mActivity, 0, dataCheckResult.length(), R.color.green);
|
|
|
+ tvMsgNotice.setText(dataCheckResult + "\n物料编号获取失败");
|
|
|
+ } else {
|
|
|
+ tvMsgNotice.setText(dataCheckResult + "\n物料编号获取失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isExist) {
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ String notice = "站位编号错误\n" + mNoticeStr;
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, "站位编号错误\n".length(), notice.length(), R.color.green);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ String notice = "站位编号错误\n" + mNoticeStr;
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, "站位编号错误\n".length(), notice.length(), R.color.green);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void locationCheck(String collect, String location) {
|
|
|
+ tvMsgProdcode.setText("");
|
|
|
+ tvMsgLocation.setText("");
|
|
|
+ tvMsgBarcode.setText("");
|
|
|
+ tvMsgQuantity.setText("");
|
|
|
+ tvMsgSpec.setText("");
|
|
|
+
|
|
|
+ if (!TextUtils.isEmpty(mSmtLocationCache)) {
|
|
|
+ try {
|
|
|
+ JSONArray locationArray = new JSONArray(mSmtLocationCache);
|
|
|
+ boolean isExist = false;
|
|
|
+ for (int i = 0; i < locationArray.length(); i++) {
|
|
|
+ JSONObject locationObject = locationArray.getJSONObject(i);
|
|
|
+ if (collect.equals(JsonUtils.optStringNotNull(locationObject, "PSL_LOCATION"))) {
|
|
|
+ isExist = true;
|
|
|
+ mLocationTextView.setText(collect);
|
|
|
+ mCollectEditText.setText("");
|
|
|
+
|
|
|
+ String psl_prodcode = JsonUtils.optStringNotNull(locationObject, "PSL_PRODCODE");
|
|
|
+ String psl_repcode = JsonUtils.optStringNotNull(locationObject, "PSL_REPCODE");
|
|
|
+ mSmtDslBean = new SmtDslBean();
|
|
|
+ mSmtDslBean.setDsl_location(location);
|
|
|
+ mSmtDslBean.setDsl_prodcode(psl_prodcode);
|
|
|
+ mSmtDslBean.setDsl_repcode(psl_repcode);
|
|
|
+
|
|
|
+ mAutoStringAdapter = new MyArrayAdapter<String>(mActivity, android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
|
|
|
+ mCollectEditText.setAdapter(mAutoStringAdapter);
|
|
|
+ //no use
|
|
|
+ if (mUpRadioButton.isChecked()) {
|
|
|
+ mCollectEditText.setHint(COLLECT_PRODCODE);
|
|
|
+ if (!TextUtils.isEmpty(psl_repcode)) {
|
|
|
+ String[] repcodes = psl_repcode.split(",");
|
|
|
+ String notice = "站位采集成功,请采集物料\n";
|
|
|
+ for (int j = 0; j < repcodes.length; j++) {
|
|
|
+ String repcode = repcodes[j];
|
|
|
+ notice = notice + repcode + "\n";
|
|
|
+ }
|
|
|
+ notice = notice + "的物料编号";
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tvMsgNotice.setText(notice);
|
|
|
+ } else if (!TextUtils.isEmpty(psl_prodcode)) {
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tvMsgNotice.setText("站位采集成功,请采集物料\n" + psl_prodcode + "\n的物料编号");
|
|
|
+ } else {
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tvMsgNotice.setText("站位采集成功,物料编号获取失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tvMsgNotice.setText("");
|
|
|
+ mCollectEditText.setHint(COLLECT_OLD_PRODCODE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isExist) {
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ String notice = "站位编号错误\n" + mNoticeStr;
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, "站位编号错误\n".length(), notice.length(), R.color.green);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ String notice = "站位编号错误\n" + mNoticeStr;
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, "站位编号错误\n".length(), notice.length(), R.color.green);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 物料号本地校验
|
|
|
+ *
|
|
|
+ * @param collect 采集的物料号
|
|
|
+ * @param location 站位编号
|
|
|
+ */
|
|
|
+ private void smtCheck(final String collect, final String location) {
|
|
|
+ boolean isExist = false;
|
|
|
+ String repcode = mSmtDslBean.getDsl_repcode();
|
|
|
+ if (collect.contains(mSmtDslBean.getDsl_prodcode())) {
|
|
|
+ isExist = true;
|
|
|
+ } else {
|
|
|
+ if (!TextUtils.isEmpty(repcode)) {
|
|
|
+ String[] repcodes = repcode.split(",");
|
|
|
+ if (repcodes != null && repcodes.length != 0) {
|
|
|
+ for (int i = 0; i < repcodes.length; i++) {
|
|
|
+ if (collect.contains(repcodes[i])) {
|
|
|
+ isExist = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isExist) {
|
|
|
+ successCheckData(collect, location);
|
|
|
+ } else {
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+
|
|
|
+ String notice = "校验失败,物料号错误!\n" + mNoticeStr;
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, "校验失败,物料号错误!\n".length(), notice.length(), R.color.green);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ mCollectEditText.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mCollectEditText.requestFocus();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+
|
|
|
+ int smtCheckErr = SharedPreUtil.getInt(mActivity, Constants.FLAG.SMT_CHECK_ERROR, 0);
|
|
|
+ if (smtCheckErr == 1) {
|
|
|
+ failCheckData(collect, location);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void failCheckData(final String collect, final String location) {
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "check");
|
|
|
+
|
|
|
+ mStringRequest = new StringRequest(Request.Method.POST, GloableParams.ADDRESS_SMT_REPEATCHECK_DATA,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @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<>();
|
|
|
+ Map<String, Object> dslMap = new HashMap<>();
|
|
|
+ if (mUpRadioButton.isChecked()) {
|
|
|
+ dslMap.put("type", "loading");
|
|
|
+ } else if (mJoinRadioButton.isChecked()) {
|
|
|
+ dslMap.put("type", "join");
|
|
|
+ }
|
|
|
+ dslMap.put("dsl_location", location);
|
|
|
+ dslMap.put("dsl_prodcode", collect);
|
|
|
+ dslMap.put("success", false);
|
|
|
+
|
|
|
+ params.put("dsl", JSON.toJSONString(dslMap));
|
|
|
+ params.put("deviceLineMake", JSON.toJSONString(mLineInfoBean));
|
|
|
+ Log.d("paramjson", params.toString());
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "check");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * SMT物料校验
|
|
|
+ *
|
|
|
+ * @param collect
|
|
|
+ * @param location
|
|
|
+ */
|
|
|
+ private void successCheckData(final String collect, final String location) {
|
|
|
+ progressDialog.show();
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "check");
|
|
|
+
|
|
|
+ mStringRequest = new StringRequest(Request.Method.POST, GloableParams.ADDRESS_SMT_REPEATCHECK_DATA,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ LogUtil.i("smtcheck", s);
|
|
|
+ JSONObject resultObject = new JSONObject(s);
|
|
|
+ JSONObject dataObject = resultObject.optJSONObject("data");
|
|
|
+ String notice = "站位[" + location + "]+物料[" + collect + "]匹配成功!";
|
|
|
+ if (dataObject != null) {
|
|
|
+ mSmtDslBean = new SmtDslBean();
|
|
|
+ mLocationTextView.setText("");
|
|
|
+ mCollectEditText.setText("");
|
|
|
+
|
|
|
+ double notCheckCount = JsonUtils.optDoubleNotNull(dataObject, "NotCheckCount");
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ if (notCheckCount == 0) {
|
|
|
+ notice = notice + "\n校验已完成";
|
|
|
+ mNoticeStr = "校验已完成";
|
|
|
+ SoundUtil.play(SoundUtil.SOUND_CERES);
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tvMsgNotice.setText(notice);
|
|
|
+ } else {
|
|
|
+ String buffer = notice;
|
|
|
+ notice = notice + "\n未校验站位"
|
|
|
+ + CommonUtil.doubleFormat(notCheckCount) + "条";
|
|
|
+ String noticeStr = "未校验站位" + CommonUtil.doubleFormat(notCheckCount) + "条";
|
|
|
+ JSONArray notCheckArray = dataObject.optJSONArray("NotCheckLocation");
|
|
|
+ if (notCheckArray != null && notCheckArray.length() != 0) {
|
|
|
+ notice = notice + "\n站位:";
|
|
|
+ noticeStr = noticeStr + "\n站位:";
|
|
|
+ for (int i = 0; i < notCheckArray.length(); i++) {
|
|
|
+ JSONObject notCheckObject = notCheckArray.optJSONObject(i);
|
|
|
+ if (notCheckObject != null) {
|
|
|
+ String psl_location = JsonUtils.optStringNotNull(notCheckObject, "PSL_LOCATION");
|
|
|
+ if (i == 0 && mOrderSwitch) {
|
|
|
+ mCollectEditText.setText(psl_location);
|
|
|
+ confirmEvent(psl_location);
|
|
|
+ }
|
|
|
+ notice = notice + psl_location + ",";
|
|
|
+ noticeStr = noticeStr + psl_location + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ notice = notice.substring(0, notice.length() - 1);
|
|
|
+ noticeStr = noticeStr.substring(0, noticeStr.length() - 1);
|
|
|
+ }
|
|
|
+ mNoticeStr = noticeStr;
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, (buffer + "\n未校验站位").length(), (buffer + "\n未校验站位").length() + CommonUtil.doubleFormat(notCheckCount).length(), R.color.blue_800);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ }
|
|
|
+
|
|
|
+ mCollectEditText.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mCollectEditText.requestFocus();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String errorToast = CommonUtil.showErrorToast(volleyError, true);
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+
|
|
|
+ String errorNotice = "校验失败," + errorToast + "\n" + mNoticeStr;
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(errorNotice, mActivity, ("校验失败," + errorToast + "\n").length(), errorNotice.length(), R.color.green);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+
|
|
|
+ mSmtDslBean = new SmtDslBean();
|
|
|
+ mLocationTextView.setText("");
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ mCollectEditText.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mCollectEditText.requestFocus();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @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<>();
|
|
|
+ Map<String, Object> dslMap = new HashMap<>();
|
|
|
+ if (mUpRadioButton.isChecked()) {
|
|
|
+ dslMap.put("type", "loading");
|
|
|
+ } else if (mJoinRadioButton.isChecked()) {
|
|
|
+ dslMap.put("type", "join");
|
|
|
+ }
|
|
|
+ dslMap.put("dsl_location", location);
|
|
|
+ dslMap.put("dsl_prodcode", collect);
|
|
|
+ dslMap.put("success", true);
|
|
|
+
|
|
|
+ params.put("dsl", JSON.toJSONString(dslMap));
|
|
|
+ params.put("deviceLineMake", JSON.toJSONString(mLineInfoBean));
|
|
|
+ Log.d("paramjson", params.toString());
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "check");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+// private void verificationLocation() {
|
|
|
+// String location = mLocationEditText.getText().toString().trim();
|
|
|
+// if (TextUtils.isEmpty(location)) {
|
|
|
+// CommonUtil.toastNoRepeat(mActivity, "请采集站位编号!");
|
|
|
+// } else {
|
|
|
+// if (!TextUtils.isEmpty(mSmtLocationCache)) {
|
|
|
+// try {
|
|
|
+// mIgnoreFocusChange = true;
|
|
|
+// JSONArray locationArray = new JSONArray(mSmtLocationCache);
|
|
|
+// boolean isExist = false;
|
|
|
+// for (int i = 0; i < locationArray.length(); i++) {
|
|
|
+// JSONObject locationObject = locationArray.getJSONObject(i);
|
|
|
+// if (location.equals(JsonUtils.optStringNotNull(locationObject, "PSL_LOCATION"))) {
|
|
|
+// isExist = true;
|
|
|
+// mCollectEditText.postDelayed(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// mCollectEditText.requestFocus();
|
|
|
+// }
|
|
|
+// }, 100);
|
|
|
+//
|
|
|
+// String psl_prodcode = JsonUtils.optStringNotNull(locationObject, "PSL_PRODCODE");
|
|
|
+// String psl_repcode = JsonUtils.optStringNotNull(locationObject, "PSL_REPCODE");
|
|
|
+// mSmtDslBean = new SmtDslBean();
|
|
|
+// mSmtDslBean.setDsl_location(location);
|
|
|
+// mSmtDslBean.setDsl_prodcode(psl_prodcode);
|
|
|
+// mSmtDslBean.setDsl_repcode(psl_repcode);
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (!isExist) {
|
|
|
+// CommonUtil.toastNoRepeat(mActivity, "站位编号错误");
|
|
|
+// mLocationEditText.setText("");
|
|
|
+// mLocationEditText.postDelayed(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// mLocationEditText.requestFocus();
|
|
|
+// }
|
|
|
+// }, 100);
|
|
|
+// }
|
|
|
+//
|
|
|
+// mIgnoreFocusChange = false;
|
|
|
+// } catch (JSONException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// CommonUtil.toastNoRepeat(mActivity, "站位编号错误");
|
|
|
+// mLocationEditText.setText("");
|
|
|
+// mLocationEditText.postDelayed(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// mLocationEditText.requestFocus();
|
|
|
+// }
|
|
|
+// }, 100);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.title_feedercheck_smt);
|
|
|
+
|
|
|
+ mSmtLocationCache = SharedPreUtil.getString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, null);
|
|
|
+ if (mLineInfoBean != null) {
|
|
|
+ mLinecodeTextView.setText(mLineInfoBean.getDL_LINECODE());
|
|
|
+ mTableTextView.setText(mLineInfoBean.getDL_TABLE() + "面");
|
|
|
+ mMacodeTextView.setText(mLineInfoBean.getDL_MACODE());
|
|
|
+ }
|
|
|
+
|
|
|
+ getUncheckLocation();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取未校验站位
|
|
|
+ */
|
|
|
+ private void getUncheckLocation() {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = GloableParams.ADDRESS_SMT_GET_UNCHECK_LOCATION + "?linecode=" + (mLineInfoBean == null ? "" : mLineInfoBean.getDL_LINECODE());
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "uncheck");
|
|
|
+
|
|
|
+ mStringRequest = new StringRequest(Request.Method.GET, url,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ try {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ JSONObject resultObject = new JSONObject(s);
|
|
|
+ JSONObject dataObject = resultObject.optJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ double notCheckCount = JsonUtils.optDoubleNotNull(dataObject, "NotCheckCount");
|
|
|
+ String notice = "";
|
|
|
+ if (notCheckCount == 0) {
|
|
|
+ notice = notice + "校验已完成";
|
|
|
+ mNoticeStr = notice;
|
|
|
+ SoundUtil.play(SoundUtil.SOUND_CERES);
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tvMsgNotice.setText(notice);
|
|
|
+ } else {
|
|
|
+ notice = notice + "未校验站位"
|
|
|
+ + CommonUtil.doubleFormat(notCheckCount) + "条";
|
|
|
+
|
|
|
+ JSONArray notFeedArray = dataObject.optJSONArray("NotCheckLocation");
|
|
|
+ if (notFeedArray != null && notFeedArray.length() != 0) {
|
|
|
+ notice = notice + "\n站位:";
|
|
|
+ for (int i = 0; i < notFeedArray.length(); i++) {
|
|
|
+ JSONObject notCheckObject = notFeedArray.optJSONObject(i);
|
|
|
+ if (notCheckObject != null) {
|
|
|
+ String psl_location = JsonUtils.optStringNotNull(notCheckObject, "PSL_LOCATION");
|
|
|
+ if (i == 0 && mOrderSwitch) {
|
|
|
+ mCollectEditText.setText(psl_location);
|
|
|
+ confirmEvent(psl_location);
|
|
|
+ }
|
|
|
+ notice = notice + psl_location + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ notice = notice.substring(0, notice.length() - 1);
|
|
|
+ }
|
|
|
+ mNoticeStr = notice;
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, 5, 5 + CommonUtil.doubleFormat(notCheckCount).length(), R.color.blue_800);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String errorToast = CommonUtil.showErrorToast(volleyError, false);
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tvMsgNotice.setText(errorToast);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "uncheck");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (!hidden) {
|
|
|
+ FunctionActivity.setTitle(getString(R.string.title_feedercheck_smt));
|
|
|
+ ((FunctionActivity) getActivity()).setSmtQueryIvVisible(true);
|
|
|
+ } else {
|
|
|
+ ((FunctionActivity) getActivity()).setSmtQueryIvVisible(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ hideKeyboard(etLocation);
|
|
|
+ VolleyUtil.distoryVolley();
|
|
|
+ super.onDestroy();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroyView() {
|
|
|
+ CommonUtil.closeKeybord(mCollectEditText, mActivity);
|
|
|
+ ((FunctionActivity) getActivity()).setSmtQueryIvVisible(false);
|
|
|
+ super.onDestroyView();
|
|
|
+ }
|
|
|
+
|
|
|
+ //改变当前校验方式
|
|
|
+ String mslKey = "msl_fecode";
|
|
|
+ String errorMsg, errorMsgNull;
|
|
|
+ String rightMsg, successMsg;
|
|
|
+ String serverParam = null;
|
|
|
+
|
|
|
+ private void changeCurCheckStyle(int style) {
|
|
|
+ String checkName = getString(R.string.notice_smtchild_feloa);
|
|
|
+ curCheckStyle = style;
|
|
|
+ febar = null;
|
|
|
+ isOrder = false;
|
|
|
+ //显示采集布局
|
|
|
+ showCollectLayout();
|
|
|
+ switch (style) {
|
|
|
+ case FEEDER_WITH_LOCATION:
|
|
|
+ Log.e(TAG, "check style:FEEDER_WITH_LOCATION");
|
|
|
+ //改变取值关键字
|
|
|
+ mslKey = "msl_fecode";
|
|
|
+ //修改界面信息
|
|
|
+ llOrder.setVisibility(View.GONE);
|
|
|
+ llDouble.setVisibility(View.VISIBLE);
|
|
|
+ etFecode.setText("");
|
|
|
+ etLocation.setText("");
|
|
|
+ etFecode.setHint(R.string.hint_smtchild_fecode);
|
|
|
+ errorMsg = getString(R.string.hint_feedererror_smtcheck);
|
|
|
+ errorMsgNull = getString(R.string.hint_collectfeeder_smtcheck);
|
|
|
+ rightMsg = getString(R.string.notice_smtchild_rightmsg);
|
|
|
+ successMsg = getString(R.string.notice_smtchild_successmsg);
|
|
|
+ //获得焦点
|
|
|
+ editTextGetFocus(etFecode);
|
|
|
+ break;
|
|
|
+ case FEEDER_ORDER:
|
|
|
+ //初始顺序置0
|
|
|
+ order = 0;
|
|
|
+ isOrder = true;
|
|
|
+ mslKey = "msl_fecode";
|
|
|
+ //上传给服务器的参数三
|
|
|
+ serverParam = "fecode";
|
|
|
+ Log.e(TAG, "check style:FEEDER_ORDER");
|
|
|
+ llOrder.setVisibility(View.VISIBLE);
|
|
|
+ llDouble.setVisibility(View.GONE);
|
|
|
+ etOrder.setText("");
|
|
|
+ etOrder.setHint(R.string.hint_smtchild_fecode);
|
|
|
+ //自动将变量makeSMTLocation[0].msl_fecode中的值赋值给变量fe_code
|
|
|
+ try {
|
|
|
+ febar = ((JSONObject) makeSMTLocation.get(order)).getString("msl_fecode");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //获得焦点
|
|
|
+ editTextGetFocus(etOrder);
|
|
|
+ //修改界面信息
|
|
|
+ rightMsg = getString(R.string.notice_smtchild_rightmsg);
|
|
|
+ successMsg = getString(R.string.notice_smtchild_successmsg);
|
|
|
+ errorMsg = getString(R.string.notice_smtchild_wrongfedmsg);
|
|
|
+ checkName = getString(R.string.notice_smtchild_feord);
|
|
|
+ break;
|
|
|
+ case BARCODE_WITH_LOCATION:
|
|
|
+ Log.e(TAG, "check style:BARCODE_WITH_LOCATION");
|
|
|
+ mslKey = "msl_barcode";
|
|
|
+ llOrder.setVisibility(View.GONE);
|
|
|
+ llDouble.setVisibility(View.VISIBLE);
|
|
|
+ etFecode.setText("");
|
|
|
+ etLocation.setText("");
|
|
|
+ etFecode.setHint(R.string.hint_smtchild_barcode);
|
|
|
+ errorMsg = getString(R.string.hint_barcoderror_smtcheck);
|
|
|
+ errorMsgNull = getString(R.string.hint_collectbarcode_smtcheck);
|
|
|
+ checkName = getString(R.string.notice_smtchild_barloa);
|
|
|
+ //获得焦点
|
|
|
+ editTextGetFocus(etFecode);
|
|
|
+ break;
|
|
|
+ case BARCODE_ORDER:
|
|
|
+ //初始顺序置0
|
|
|
+ order = 0;
|
|
|
+ isOrder = true;
|
|
|
+ mslKey = "msl_barcode";
|
|
|
+ //上传给服务器的参数三
|
|
|
+ serverParam = "barcode";
|
|
|
+ Log.e(TAG, "check style:FEEDER_ORDER");
|
|
|
+ llOrder.setVisibility(View.VISIBLE);
|
|
|
+ llDouble.setVisibility(View.GONE);
|
|
|
+ etOrder.setText("");
|
|
|
+ etOrder.setHint(R.string.hint_smtchild_barcode);
|
|
|
+ //自动将变量makeSMTLocation[0].msl_fecode中的值赋值给变量fe_code
|
|
|
+ try {
|
|
|
+ febar = ((JSONObject) makeSMTLocation.get(order)).getString("msl_barcode");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //获得焦点
|
|
|
+ editTextGetFocus(etOrder);
|
|
|
+ //修改界面信息
|
|
|
+ rightMsg = getString(R.string.notice_smtchild_rightbarmsg);
|
|
|
+ successMsg = getString(R.string.notice_smtchild_successbarmsg);
|
|
|
+ errorMsg = getString(R.string.notice_smtchild_wrongbarmsg);
|
|
|
+ checkName = getString(R.string.notice_smtchild_barord);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //修改校验方式显示文字
|
|
|
+ tvCheckStyle.setText(checkName);
|
|
|
+ //清空提示框文字
|
|
|
+ setNotice("", "", -1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //飞达/料卷输入框回车事件,febar = fecode、barcode、fe_code
|
|
|
+ String febar, location;
|
|
|
+
|
|
|
+ private boolean disposeFecodeEnter(String msl_key) {
|
|
|
+ setNotice("", "", -1);
|
|
|
+ String tmpFecode = null, tmpLocation = null;
|
|
|
+ //获得文字框输入
|
|
|
+ String msl_fecode = etFecode.getText().toString().trim();
|
|
|
+ Log.e(TAG + "tmpFecode", msl_fecode);
|
|
|
+ if (msl_fecode.equals("") || msl_fecode == null) {
|
|
|
+ etFecode.setWarnIconVisible();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //判断输入fecode与makeSMTLocation是否匹配
|
|
|
+ try {
|
|
|
+ JSONObject tmpJson;
|
|
|
+ for (int i = 0; i < makeSMTLocation.length(); i++) {
|
|
|
+ tmpJson = makeSMTLocation.getJSONObject(i);
|
|
|
+ tmpFecode = tmpJson.getString(msl_key);
|
|
|
+ //如果匹配
|
|
|
+ if (tmpFecode.equals(msl_fecode)) {
|
|
|
+ tmpLocation = tmpJson.getString("msl_location");
|
|
|
+ febar = msl_fecode;
|
|
|
+ location = tmpLocation;
|
|
|
+ Log.e(TAG + "FENTER:", "fecode:" + febar + "location:" + location);
|
|
|
+ etFecode.setOkIconVisible();
|
|
|
+ //站位获取焦点
|
|
|
+ editTextGetFocus(etLocation);
|
|
|
+ setNotice("", "", -1);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //如果不匹配
|
|
|
+ //提示飞达错误,清空输入值
|
|
|
+ String title = "错误";
|
|
|
+ setNotice(title, errorMsg, wrongColor);
|
|
|
+ etFecode.setText("");
|
|
|
+ febar = null;
|
|
|
+ location = null;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //站位输入框回车事件
|
|
|
+ private void disposeLocationEnter() {
|
|
|
+ setNotice("", "", -1);
|
|
|
+ Log.e(TAG, "disposeLocationEnter");
|
|
|
+ //获得输入框内容
|
|
|
+ String msl_fecode = etFecode.getText().toString().trim();
|
|
|
+ Log.e(TAG, msl_fecode);
|
|
|
+ //判断fecode内容是否为空
|
|
|
+ if (msl_fecode.equals("") || msl_fecode == null) {
|
|
|
+ String title = "错误";
|
|
|
+ setNotice(title, errorMsgNull, wrongColor);
|
|
|
+ editTextGetFocus(etFecode);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //获得location输入框内容
|
|
|
+ String msl_location = etLocation.getText().toString().trim();
|
|
|
+ //判断location内容是否为空
|
|
|
+ if (msl_location.equals("") || msl_location == null) {
|
|
|
+ String title = "错误";
|
|
|
+ setNotice(title,
|
|
|
+ getString(R.string.hint_collectfeeder_smtcheck),
|
|
|
+ wrongColor);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //判断msl_fecode 是否等于变量fecode
|
|
|
+ if (!msl_fecode.equals(febar)) {
|
|
|
+ //如果飞达输入框判断通过,fecode和mslfecode一致
|
|
|
+ if (!disposeFecodeEnter(mslKey)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ checkLocation(msl_location);
|
|
|
+ }
|
|
|
+ //如果msl_fecode等于变量fecode
|
|
|
+ else {
|
|
|
+ checkLocation(msl_location);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验站位是否正确
|
|
|
+ private void checkLocation(String msl_location) {
|
|
|
+ //校验正确
|
|
|
+ if (location.equals(msl_location)) {
|
|
|
+ String title = getString(R.string.notice_smtcheck_right);
|
|
|
+ String content = "站位:" + msl_location + "正确,请继续校验!";
|
|
|
+ setNotice(title, content, rightColor);
|
|
|
+ JSONObject paramJson = new JSONObject();
|
|
|
+ try {
|
|
|
+ String tmpId = makeCraft.getString("mc_id");
|
|
|
+ paramJson.put("id", tmpId);
|
|
|
+ paramJson.put("code", location);
|
|
|
+ paramJson.put("type", "location");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //更新数据msl_ifcheck值
|
|
|
+ requestType = VolleyUtil.FRAGMENT_SCMAKE_SMTCHECK_IFCHECK;
|
|
|
+ VolleyUtil.getVolleyUtil().requestJsonObject(getActivity(), GloableParams.ADDRESS_SMTCHECK_IFCHECK_APPLY, VolleyUtil.METHOD_POST,
|
|
|
+ requestType, paramJson);
|
|
|
+ } else {
|
|
|
+ //提示“站位msl_location错误”,同时清空msl_location
|
|
|
+ String title = getString(R.string.notice_smtcheck_wrong);
|
|
|
+ String content = "站位:" + msl_location + "错误!";
|
|
|
+ etLocation.setText("");
|
|
|
+ setNotice(title, content, wrongColor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //按钮点击事件:“飞达+站位”FeederLocation
|
|
|
+ private void disposeOnclickDouble() {
|
|
|
+ //获得输入框文字
|
|
|
+ String msl_fecode = null, msl_location = null;
|
|
|
+ msl_fecode = etFecode.getText().toString().trim();
|
|
|
+ msl_location = etLocation.getText().toString().trim();
|
|
|
+ setNotice("", "", -1);
|
|
|
+ if (msl_fecode.equals("") || msl_fecode == null) {
|
|
|
+ Log.e(TAG, "etFecode is null");
|
|
|
+ etFecode.setWarnIconVisible();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (msl_location.equals("") || msl_location == null) {
|
|
|
+ Log.e(TAG, "etLocation is null");
|
|
|
+ etLocation.setWarnIconVisible();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ disposeLocationEnter();
|
|
|
+ }
|
|
|
+
|
|
|
+ //顺序校验输入框enter事件(fecode和barcode共用)
|
|
|
+ int order = 0;
|
|
|
+
|
|
|
+ private void disposeOrderEnter() {
|
|
|
+ String title, content;
|
|
|
+ //获取输入框文字
|
|
|
+ String msl_febar = etOrder.getText().toString().trim();
|
|
|
+ if (msl_febar.equals("") || msl_febar == null) {
|
|
|
+ etOrder.setWarnIconVisible();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //如果输入的msl_fecode不等于变量fe_code
|
|
|
+ Log.e(TAG + "ordercheck", "msl_fecode:" + msl_febar + "fe_code:" + febar + msl_febar.equals(febar));
|
|
|
+ if (!msl_febar.equals(febar)) {
|
|
|
+ title = getString(R.string.notice_smtcheck_wrong);
|
|
|
+ content = errorMsg.replaceAll("replace", msl_febar);
|
|
|
+ etOrder.setText("");
|
|
|
+ setNotice(title, content, wrongColor);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ title = getString(R.string.notice_smtcheck_right);
|
|
|
+ rightMsg = rightMsg.replaceAll("replace", msl_febar);
|
|
|
+ setNotice(title, rightMsg, rightColor);
|
|
|
+ //发送请求至服务器更新msl_ifcheck=1
|
|
|
+ JSONObject paramJson = new JSONObject();
|
|
|
+ try {
|
|
|
+ String id = makeCraft.getString("mc_id");
|
|
|
+ String code = msl_febar;
|
|
|
+ paramJson.put("id", id);
|
|
|
+ paramJson.put("code", code);
|
|
|
+ paramJson.put("type", serverParam);
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ requestType = VolleyUtil.FRAGMENT_SCMAKE_SMTCHECK_IFCHECK;
|
|
|
+ VolleyUtil.getVolleyUtil().requestJsonObject(getActivity(), GloableParams.ADDRESS_SMTCHECK_IFCHECK_APPLY, VolleyUtil.METHOD_POST,
|
|
|
+ requestType, paramJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ //按钮点击事件:顺序校验
|
|
|
+ private void disposeOnclickOrder() {
|
|
|
+ String msl_febar = etOrder.getText().toString().trim();
|
|
|
+ if (msl_febar.equals("") || msl_febar == null) {
|
|
|
+ etOrder.setWarnIconVisible();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ disposeOrderEnter();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*============================选择校验方式下拉框==================================*/
|
|
|
+ List checkStyleList;
|
|
|
+ //显示选择校验方式下拉框
|
|
|
+ PopupWindow changePopWin;
|
|
|
+
|
|
|
+ //显示选择校验方式界面
|
|
|
+ private void showSelectPopWindow() {
|
|
|
+ ListView lvCheckStyle;
|
|
|
+ LayoutInflater inflater = getActivity().getLayoutInflater();
|
|
|
+ View view = inflater.inflate(R.layout.popupwin_inmake_select, null, false);
|
|
|
+ //获取组件
|
|
|
+ changePopWin = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
|
|
|
+ RelativeLayout rlPopwin = (RelativeLayout) view.findViewById(R.id.rl_popwin_inmake_select);
|
|
|
+ rlPopwin.setBackgroundColor(getResources().getColor(R.color.transparent));
|
|
|
+ lvCheckStyle = (ListView) view.findViewById(R.id.select_content_view);
|
|
|
+ TextView tvTitle = (TextView) view.findViewById(R.id.title_selectpop);
|
|
|
+ //获取数据源
|
|
|
+ checkStyleList = DataSourceManager.getDataSourceManager().getCheckStyleItemList();
|
|
|
+ Log.e(TAG, "checkStyleList" + checkStyleList.toString());
|
|
|
+ //Adapter
|
|
|
+ ArrayAdapter adapter = new ArrayAdapter(getActivity(), R.layout.item_list_popwin, checkStyleList);
|
|
|
+ lvCheckStyle.setAdapter(adapter);
|
|
|
+ //添加监听
|
|
|
+ lvCheckStyle.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ disposeOncheckStyleItemClice(position, id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //界面配置
|
|
|
+ tvTitle.setText(R.string.text_smtcheck_checkstyle);
|
|
|
+ //popwin捕获焦点
|
|
|
+ changePopWin.setFocusable(true);
|
|
|
+ changePopWin.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ changePopWin.showAtLocation(parentView, Gravity.CENTER, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验方式下拉框item点击事件
|
|
|
+ private void disposeOncheckStyleItemClice(int position, long id) {
|
|
|
+ String selectCheckStyleName = checkStyleList.get(position).toString().trim();
|
|
|
+ switch (selectCheckStyleName) {
|
|
|
+ //飞达+站位
|
|
|
+ case GloableParams.LISTNAME_SCMAKE_SMTCHECK_FELOA:
|
|
|
+ curCheckStyle = FEEDER_WITH_LOCATION;
|
|
|
+ break;
|
|
|
+ //飞达按序
|
|
|
+ case GloableParams.LISTNAME_SCMAKE_SMTCHECK_FEORD:
|
|
|
+ curCheckStyle = FEEDER_ORDER;
|
|
|
+ break;
|
|
|
+ //料卷+站位
|
|
|
+ case GloableParams.LISTNAME_SCMAKE_SMTCHECK_BARLOA:
|
|
|
+ curCheckStyle = BARCODE_WITH_LOCATION;
|
|
|
+ break;
|
|
|
+ //料卷按序
|
|
|
+ case GloableParams.LISTNAME_SCMAKE_SMTCHECK_BARORD:
|
|
|
+ curCheckStyle = BARCODE_ORDER;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ changeCurCheckStyle(curCheckStyle);
|
|
|
+ dismissPopwin();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*=============================Volley Handler===================================*/
|
|
|
+ int requestType = -1;
|
|
|
+ Handler handler = new Handler() {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ switch (msg.what) {
|
|
|
+ case VolleyUtil.SUCCESS_SUCCESS:
|
|
|
+ disposeVolleySuccess(msg);
|
|
|
+ break;
|
|
|
+ case VolleyUtil.FAILED_FAILED:
|
|
|
+ String title = "失败";
|
|
|
+ String content = "连接服务器失败";
|
|
|
+ setNotice(title, content, wrongColor);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ //Volley成功
|
|
|
+ private void disposeVolleySuccess(Message msg) {
|
|
|
+ Log.e(TAG, "" + requestType);
|
|
|
+ switch (requestType) {
|
|
|
+ //页面加载
|
|
|
+ case VolleyUtil.FRAGMENT_SCMAKE_SMTCHECK_LOCATION:
|
|
|
+ disposeLoadingSuccess(msg);
|
|
|
+ break;
|
|
|
+ //校验
|
|
|
+ case VolleyUtil.FRAGMENT_SCMAKE_SMTCHECK_IFCHECK:
|
|
|
+ disposeIfcheckSuccess(msg);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //页面加载Volley响应成功
|
|
|
+ private void disposeLoadingSuccess(Message msg) {
|
|
|
+ //获得makeSMTLocation
|
|
|
+ String makeSMTLocationStr = (String) msg.obj;
|
|
|
+ try {
|
|
|
+ JSONObject tmpJson = new JSONObject(makeSMTLocationStr);
|
|
|
+ boolean isNull = tmpJson.isNull("message");
|
|
|
+ Log.e(TAG + "makeSMTLocation0", "" + tmpJson.isNull("message"));
|
|
|
+ //如果makeSMTLocation是null
|
|
|
+ if (isNull) {
|
|
|
+ disposeMakeSMTLocationIsNull();
|
|
|
+ }
|
|
|
+ //如果有数据
|
|
|
+ else {
|
|
|
+ makeSMTLocation = tmpJson.getJSONArray("message");
|
|
|
+ //默认校验方式:飞达+站位
|
|
|
+ changeCurCheckStyle(FEEDER_WITH_LOCATION);
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //隐藏采集界面,提示无校验数据
|
|
|
+ private void disposeMakeSMTLocationIsNull() {
|
|
|
+ hideCollectLayout();
|
|
|
+ String title = "没有需要校验的数据";
|
|
|
+ setNotice(title, "", getResources().getColor(R.color.text_search));
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean isOrder = false;
|
|
|
+
|
|
|
+ //校验Volley响应成功
|
|
|
+ private void disposeIfcheckSuccess(Message msg) {
|
|
|
+ String title = getString(R.string.notice_smtcheck_success);
|
|
|
+ String content = successMsg.replaceAll("replace", febar);
|
|
|
+ Log.e(TAG, "febar:" + content);
|
|
|
+ setNotice(title, content, rightColor);
|
|
|
+ if (isOrder) {
|
|
|
+ //修改变量fe_code 的值
|
|
|
+ try {
|
|
|
+ //如果已经校验到该单最后一条
|
|
|
+ if (order == (makeSMTLocation.length() - 1)) {
|
|
|
+ title = getString(R.string.notice_smtcheck_allright);
|
|
|
+ content = getString(R.string.notice_smtcheck_allrightmsg);
|
|
|
+ content = content.replace("replace", febar);
|
|
|
+ setNotice(title, content, rightColor);
|
|
|
+ //隐藏采集界面
|
|
|
+ hideCollectLayout();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //febar等于下一条要校验的key值
|
|
|
+ febar = ((JSONObject) makeSMTLocation.get(++order)).getString(mslKey);
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ clearEditText();
|
|
|
+ }
|
|
|
+
|
|
|
+ //清除编辑框内容
|
|
|
+ private void clearEditText() {
|
|
|
+ if (etOrder != null) {
|
|
|
+ etOrder.setText("");
|
|
|
+ }
|
|
|
+ if (etLocation != null) {
|
|
|
+ etLocation.setText("");
|
|
|
+ }
|
|
|
+ if (etFecode != null) {
|
|
|
+ editTextGetFocus(etFecode);
|
|
|
+ etFecode.setText("");
|
|
|
+ }
|
|
|
+ if (isOrder) {
|
|
|
+ editTextGetFocus(etOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //隐藏采集界面
|
|
|
+ private void hideCollectLayout() {
|
|
|
+ rlChange.setVisibility(View.GONE);
|
|
|
+ rlCollect.setVisibility(View.GONE);
|
|
|
+ //llOrder.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ //显示采集界面
|
|
|
+ private void showCollectLayout() {
|
|
|
+ rlChange.setVisibility(View.VISIBLE);
|
|
|
+ rlCollect.setVisibility(View.VISIBLE);
|
|
|
+ // llOrder.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ /*=============================公用方法===================================*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 隐藏键盘
|
|
|
+ */
|
|
|
+ private void hideKeyboard(final EditText view) {
|
|
|
+ InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
+ //获取键盘管理对象
|
|
|
+ inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取输入框焦点
|
|
|
+ */
|
|
|
+ private void editTextGetFocus(EditText editText) {
|
|
|
+ editText.setFocusable(true);
|
|
|
+ editText.setFocusableInTouchMode(true);
|
|
|
+ editText.setEnabled(true);
|
|
|
+ editText.setClickable(true);
|
|
|
+ editText.requestFocus();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置提示信息
|
|
|
+ */
|
|
|
+ private void setNotice(String title, String content, int pid) {
|
|
|
+ tvMsgNotice.setText(title);
|
|
|
+ tvMsgNotice.setTextColor(pid);
|
|
|
+ tvMsgProdcode.setText(content);
|
|
|
+ //etCollect.setText("");
|
|
|
+ //清除其它信息
|
|
|
+ tvMsgSpec.setText("");
|
|
|
+ tvMsgBarcode.setText("");
|
|
|
+ tvMsgLocation.setText("");
|
|
|
+ tvMsgQuantity.setText("");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ switch (curCheckStyle) {
|
|
|
+ //飞达+站位
|
|
|
+ case FEEDER_WITH_LOCATION:
|
|
|
+ disposeOnclickDouble();
|
|
|
+ break;
|
|
|
+ //飞达按序
|
|
|
+ case FEEDER_ORDER:
|
|
|
+ disposeOnclickOrder();
|
|
|
+ break;
|
|
|
+ //料卷+站位
|
|
|
+ case BARCODE_WITH_LOCATION:
|
|
|
+ disposeOnclickDouble();
|
|
|
+ break;
|
|
|
+ //料卷按序
|
|
|
+ case BARCODE_ORDER:
|
|
|
+ disposeOnclickOrder();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示loadingView
|
|
|
+ */
|
|
|
+ private void showLoadingView() {
|
|
|
+ if (!progressDialog.isShowing()) {
|
|
|
+ progressDialog.show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭选择框
|
|
|
+ */
|
|
|
+ private void dismissPopwin() {
|
|
|
+ if (changePopWin.isShowing() && changePopWin != null) {
|
|
|
+ changePopWin.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
|
|
+ if (progressDialog != null && progressDialog.isShowing()) {
|
|
|
+// loadingView.dismiss();
|
|
|
+// VolleyUtil.distoryVolley();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (changePopWin != null && changePopWin.isShowing()) {
|
|
|
+ changePopWin.dismiss();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|