|
|
@@ -0,0 +1,1023 @@
|
|
|
+package com.uas.pda_wps.fragment;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.text.SpannableString;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
+import android.view.inputmethod.InputMethodManager;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.EditText;
|
|
|
+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.pda_wps.R;
|
|
|
+import com.uas.pda_wps.application.PdaApplication;
|
|
|
+import com.uas.pda_wps.bean.LineInfoBean;
|
|
|
+import com.uas.pda_wps.bean.SmtDslBean;
|
|
|
+import com.uas.pda_wps.global.GloableParams;
|
|
|
+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.FastjsonUtil;
|
|
|
+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.LogUtil;
|
|
|
+import com.uas.pda_wps.util.MyLog;
|
|
|
+import com.uas.pda_wps.util.SoundUtil;
|
|
|
+import com.uas.pda_wps.util.VolleyRequest;
|
|
|
+import com.uas.pda_wps.view.ClearableEditText;
|
|
|
+import com.uas.pda_wps.view.TextViewWithButton;
|
|
|
+
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * SMT备料上料:上料子页面
|
|
|
+ */
|
|
|
+public class SMTMaterialPreparationLoading extends BaseFragment implements View.OnClickListener, TextViewWithButton.TvHintHelper {
|
|
|
+ private TextViewWithButton tvLocation, tvBarcode, tvRemainqty, tvFecode, mLocationTextView;
|
|
|
+ private TextView tvMsgNotice, tvMsgLocation, tvMsgProdcode, tvMsgBarcode, tvMsgQuantity, tvMsgSpec,tv_collection_info;
|
|
|
+ private RelativeLayout rlCollect;
|
|
|
+ private JSONArray smtLocation;
|
|
|
+ private JSONObject makeCraft;
|
|
|
+ private TextView mLinecodeTextView, mTableTextView, mMacodeTextView;
|
|
|
+ private ClearableEditText mCollectEditText;
|
|
|
+ int requestType = -1;
|
|
|
+
|
|
|
+ private Button btnCollect;
|
|
|
+ private LineInfoBean mLineInfoBean; //线别enter数据
|
|
|
+
|
|
|
+ private SmtDslBean mSmtDslBean = new SmtDslBean();
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private String mNoticeStr = "";
|
|
|
+ private boolean mOrderSwitch = false;
|
|
|
+ private String mSmtLocationCache;
|
|
|
+ private boolean isCancelVerification; //设置-->备料上料--取消站位校验
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fra_smt_material_preparation_loading;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ mOrderSwitch = SharedPreUtil.getInt(mActivity, Constants.FLAG.CACHE_DEFAULT_ORDER_SWITCH + CommonUtil.getUserName(mActivity), 0) == 1;
|
|
|
+ //获取组件
|
|
|
+ //->采集信息
|
|
|
+ btnCollect = (Button) root.findViewById(R.id.btn_collect_smtchildin);
|
|
|
+ tvLocation = (TextViewWithButton) root.findViewById(R.id.tv_innernotice_location_smtchildin);
|
|
|
+ tvFecode = (TextViewWithButton) root.findViewById(R.id.tv_innernotice_fecode_smtchildin);
|
|
|
+ tvBarcode = (TextViewWithButton) root.findViewById(R.id.tv_innernotice_barcode_smtchildin);
|
|
|
+ tvRemainqty = (TextViewWithButton) root.findViewById(R.id.tv_innernotice_remainqty_smtchildin);
|
|
|
+ rlCollect = (RelativeLayout) root.findViewById(R.id.rl_innernotice_smtchildin);
|
|
|
+
|
|
|
+ mLocationTextView = (TextViewWithButton) root.findViewById(R.id.smt_feeding_in_location_tv);
|
|
|
+ mLinecodeTextView = (TextView) root.findViewById(R.id.smt_feeding_in_linecode_tv);
|
|
|
+ mTableTextView = (TextView) root.findViewById(R.id.smt_feeding_in_table_tv);
|
|
|
+ mMacodeTextView = (TextView) root.findViewById(R.id.smt_feeding_in_macode_tv);
|
|
|
+ mCollectEditText = (ClearableEditText) root.findViewById(R.id.smt_feeding_in_collect_et);
|
|
|
+
|
|
|
+ mCollectEditText.requestFocus();
|
|
|
+ //->提示信息
|
|
|
+ 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);
|
|
|
+
|
|
|
+ tv_collection_info = (TextView) root.findViewById(R.id.tv_collection_info);
|
|
|
+
|
|
|
+ //接口回调
|
|
|
+ VolleyUtil.setVolleyHandler(handler);
|
|
|
+
|
|
|
+ mLineInfoBean = (LineInfoBean) PdaApplication.getDataCacheFromMap(Constants.FLAG.SMT_DEVICE_LINE_CACHE);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ tvLocation.setTvHintHelper(this);
|
|
|
+ tvBarcode.setTvHintHelper(this);
|
|
|
+ tvRemainqty.setTvHintHelper(this);
|
|
|
+ tvFecode.setTvHintHelper(this);
|
|
|
+
|
|
|
+ mLocationTextView.setTvHintHelper(this);
|
|
|
+
|
|
|
+ btnCollect.setOnClickListener(this);
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mLocationTextView.setOnTextClearListener(new TextViewWithButton.OnTextClearListener() {
|
|
|
+ @Override
|
|
|
+ public void onTextClear() {
|
|
|
+ //mCollectEditText.setHint("请录入站位编号");
|
|
|
+ mCollectEditText.setHint("请录入条码号");
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void confirmEvent(String collect) {
|
|
|
+ String location = mLocationTextView.getText().toString().trim();
|
|
|
+ MyLog.e("aaa","站位数据为:" + location);
|
|
|
+ if (TextUtils.isEmpty(location)) {
|
|
|
+ //locationCheck(collect);
|
|
|
+ mLocationTextView.setText(collect);
|
|
|
+ mCollectEditText.setText("");
|
|
|
+
|
|
|
+ initLocation(collect);
|
|
|
+ setLocationCheck(collect); //接口站位校验
|
|
|
+ } else {
|
|
|
+ mSmtDslBean.setDsl_barcode(collect);
|
|
|
+ feedLoading();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initLocation(String collect) {
|
|
|
+ mSmtDslBean = new SmtDslBean();
|
|
|
+ mSmtDslBean.setDsl_location(collect);
|
|
|
+ mSmtDslBean.setDsl_prodcode("");
|
|
|
+ mCollectEditText.setHint("请录入条码号");
|
|
|
+
|
|
|
+ tvMsgNotice.setText("");
|
|
|
+ tvMsgProdcode.setText("");
|
|
|
+ tvMsgLocation.setText("");
|
|
|
+ tvMsgBarcode.setText("");
|
|
|
+ tvMsgQuantity.setText("");
|
|
|
+ tvMsgSpec.setText("");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 接口: 站位校验
|
|
|
+ */
|
|
|
+ private void setLocationCheck(String collect) {
|
|
|
+ // mLinecodeTextView.setText(mLineInfoBean.getDL_LINECODE()); //线别
|
|
|
+ // mTableTextView.setText(mLineInfoBean.getDL_TABLE() + "面"); //板面
|
|
|
+ // mMacodeTextView.setText(mLineInfoBean.getDL_MACODE()); //工单
|
|
|
+
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_LOADING_CHECKLOC)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("li_code", mLineInfoBean.getDL_LINECODE()) //线别
|
|
|
+ .addParam("ma_code", mLineInfoBean.getDL_MACODE()) //工单
|
|
|
+ .addParam("dl_table", mLineInfoBean.getDL_TABLE()) //板面
|
|
|
+ .addParam("location", collect) //站位
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ try {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = o.toString();
|
|
|
+
|
|
|
+ com.alibaba.fastjson.JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ com.alibaba.fastjson.JSONObject data = resultObject.getJSONObject("data");
|
|
|
+ if (data != null) {
|
|
|
+ String fecode = FastjsonUtil.getText(data, "fecode");
|
|
|
+ String prodcode = FastjsonUtil.getText(data, "prodcode");
|
|
|
+ String location = FastjsonUtil.getText(data, "location");
|
|
|
+
|
|
|
+ mLocationTextView.setText(location);
|
|
|
+ mCollectEditText.setText("");
|
|
|
+
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ String text = "校验成功" + "\n";
|
|
|
+ text += "站位: " + location + "\n"
|
|
|
+ + "飞达: " + fecode + "\n"
|
|
|
+ + "请采集物料: " + prodcode + "的料卷编号/物料编号";
|
|
|
+ tvMsgNotice.setText(text);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), failStr);
|
|
|
+ mLocationTextView.setText("");
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tvMsgNotice.setText(failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 站位本地校验
|
|
|
+ *
|
|
|
+ * @param collect 采集框采集内容
|
|
|
+ */
|
|
|
+ private void locationCheck(String collect) {
|
|
|
+ tvMsgProdcode.setText("");
|
|
|
+ tvMsgLocation.setText("");
|
|
|
+ tvMsgBarcode.setText("");
|
|
|
+ tvMsgQuantity.setText("");
|
|
|
+ tvMsgSpec.setText("");
|
|
|
+
|
|
|
+ mLocationTextView.setText(collect);
|
|
|
+ mCollectEditText.setText("");
|
|
|
+
|
|
|
+ mSmtDslBean = new SmtDslBean();
|
|
|
+ mSmtDslBean.setDsl_location(collect);
|
|
|
+ mSmtDslBean.setDsl_prodcode("");
|
|
|
+ mCollectEditText.setHint("请录入条码号");
|
|
|
+
|
|
|
+ // 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(collect);
|
|
|
+ // mSmtDslBean.setDsl_prodcode(psl_prodcode);
|
|
|
+ // mCollectEditText.setHint("请录入飞达编号");
|
|
|
+ //
|
|
|
+ // 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("站位采集成功,物料编号获取失败");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // 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 feedLoading() {
|
|
|
+ progressDialog.show();
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "loading");
|
|
|
+
|
|
|
+ final String smtDsl = JSON.toJSONString(mSmtDslBean);
|
|
|
+ String deviceLineMake = "";
|
|
|
+ if (mLineInfoBean != null) {
|
|
|
+ deviceLineMake = JSON.toJSONString(mLineInfoBean);
|
|
|
+ }
|
|
|
+ final String finalDeviceLineMake = deviceLineMake;
|
|
|
+ mStringRequest = new StringRequest(Request.Method.POST, GloableParams.ADDRESS_SMT_LOADING,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ try {
|
|
|
+ LogUtil.i("inloading", s);
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ JSONObject jsonObject = new JSONObject(s);
|
|
|
+ JSONObject dataObject = jsonObject.optJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ mLocationTextView.setText("");
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ //mCollectEditText.setHint("请录入站位编号");
|
|
|
+ mCollectEditText.setHint("请录入条码号");
|
|
|
+
|
|
|
+ mSmtDslBean = new SmtDslBean();
|
|
|
+
|
|
|
+ double notCheckCount = JsonUtils.optDoubleNotNull(dataObject, "NotFeedCount");
|
|
|
+ String notice = "飞达规格:" + JsonUtils.optStringNotNull(dataObject, "DSL_FESPEC");
|
|
|
+ if (notCheckCount == 0) {
|
|
|
+ notice = notice + "\n\n上料已完成";
|
|
|
+ mNoticeStr = "上料已完成";
|
|
|
+ SoundUtil.play(SoundUtil.SOUND_CERES);
|
|
|
+ tvMsgSpec.setText(notice);
|
|
|
+ } else {
|
|
|
+ String buffer = notice;
|
|
|
+ notice = notice + "\n\n未上料站位" + CommonUtil.doubleFormat(notCheckCount) + "条";
|
|
|
+ String noticeStr = "未上料站位" + CommonUtil.doubleFormat(notCheckCount) + "条";
|
|
|
+ JSONArray notFeedArray = dataObject.optJSONArray("NotFeedLocation");
|
|
|
+ if (notFeedArray != null && notFeedArray.length() != 0) {
|
|
|
+ //notice = notice + "\n站位:\n";
|
|
|
+ //noticeStr = noticeStr + "\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");
|
|
|
+ String psl_prodcode = JsonUtils.optStringNotNull(notCheckObject, "PSL_PRODCODE");
|
|
|
+ //notice = notice + psl_location + "\n";
|
|
|
+ //noticeStr = noticeStr + psl_location + "\n";
|
|
|
+ notice += "\n站位:" + psl_location + " 料号:" + psl_prodcode;
|
|
|
+ noticeStr += "\n站位:" + psl_location + " 料号:" + psl_prodcode;
|
|
|
+ if (i == 0 && mOrderSwitch) {
|
|
|
+ //过滤|,取前面的字段
|
|
|
+ if (!TextUtils.isEmpty(psl_location) && psl_location.contains("|")) {
|
|
|
+ String[] strLocation = psl_location.split("\\|");
|
|
|
+ psl_location = strLocation[0];
|
|
|
+ }
|
|
|
+ mCollectEditText.setText(psl_location);
|
|
|
+ confirmEvent(psl_location);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isCancelVerification) {
|
|
|
+ JSONObject notCheckObject = notFeedArray.optJSONObject(0);
|
|
|
+ if (notCheckObject != null) {
|
|
|
+ String psl_location = JsonUtils.optStringNotNull(notCheckObject, "PSL_LOCATION");
|
|
|
+ String psl_prodcode = JsonUtils.optStringNotNull(notCheckObject, "PSL_PRODCODE");
|
|
|
+ mLocationTextView.setText(psl_location);
|
|
|
+ initLocation(psl_location);
|
|
|
+ tv_collection_info.setVisibility(View.VISIBLE);
|
|
|
+ tv_collection_info.setText("请采集站位:" + psl_location + ",物料:" + psl_prodcode + "料卷编号/物料编号");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ tv_collection_info.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ //notice = notice.substring(0, notice.length() - 1);
|
|
|
+ //noticeStr = noticeStr.substring(0, noticeStr.length() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ mNoticeStr = noticeStr;
|
|
|
+ SpannableString spannableString = CommonUtil.spanString(notice, mActivity, (buffer + "\n\n未上料站位").length(),
|
|
|
+ (buffer + "\n\n未上料站位").length() + CommonUtil.doubleFormat(notCheckCount).length(), R.color.blue_800);
|
|
|
+ tvMsgSpec.setText(spannableString);
|
|
|
+
|
|
|
+ MyLog.e("aaa","已经扫完条码号");
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tvMsgNotice.setText("上料成功");
|
|
|
+ tvMsgProdcode.setText("料号:" + JsonUtils.optStringNotNull(dataObject, "DSL_PRODCODE"));
|
|
|
+ tvMsgLocation.setText("位号:" + JsonUtils.optStringNotNull(dataObject, "DSL_LOCATION"));
|
|
|
+ tvMsgBarcode.setText("料卷号:" + JsonUtils.optStringNotNull(dataObject, "DSL_BARCODE"));
|
|
|
+ tvMsgQuantity.setText("数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(dataObject, "DSL_REMAINQTY")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } 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);
|
|
|
+ if (errorToast != null) {
|
|
|
+ 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);
|
|
|
+ if (errorToast.contains("站位已经有在线料卷号")) {
|
|
|
+ mLocationTextView.setText("");
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ } else {
|
|
|
+ mCollectEditText.setText("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tv_collection_info.setText("");
|
|
|
+ tv_collection_info.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Map<String, String> getParams() throws AuthFailureError {
|
|
|
+ Map<String, String> params = new HashMap<String, String>();
|
|
|
+ params.put("dsl", smtDsl);
|
|
|
+ params.put("deviceLineMake", finalDeviceLineMake);
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "loading");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ //配置界面
|
|
|
+ ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.title_feederin_smt);
|
|
|
+
|
|
|
+ mSmtLocationCache = SharedPreUtil.getString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, null);
|
|
|
+ if (mSmtLocationCache != null) {
|
|
|
+ Log.d("smtLocation", mSmtLocationCache);
|
|
|
+ }
|
|
|
+ if (mLineInfoBean != null) {
|
|
|
+ mLinecodeTextView.setText(mLineInfoBean.getDL_LINECODE()); //线别
|
|
|
+ mTableTextView.setText(mLineInfoBean.getDL_TABLE() + "面"); //板面
|
|
|
+ mMacodeTextView.setText(mLineInfoBean.getDL_MACODE()); //工单
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否开启了不校验站位
|
|
|
+ isCancelVerification = SharedPreUtil.getInt(mActivity, Constants.FLAG.CANCEL_STATION_VERIFICATION + CommonUtil.getUserName(mActivity), 0) == 1;
|
|
|
+ MyLog.e("aaa","取消校验站位的值是:" + isCancelVerification + ",顺序上位的值是:" + mOrderSwitch);
|
|
|
+ getUnloadingLocation();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取未上料站位
|
|
|
+ */
|
|
|
+ private void getUnloadingLocation() {
|
|
|
+ MyLog.e("aaa", "获取为上料站位");
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_SMT_GET_UNLOADING_LOCATION)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "unloading")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("linecode", (mLineInfoBean == null ? "" : mLineInfoBean.getDL_LINECODE()))
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ try {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ JSONObject resultObject = new JSONObject(o.toString());
|
|
|
+ JSONObject dataObject = resultObject.optJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ double NotFeedCount = JsonUtils.optDoubleNotNull(dataObject, "NotFeedCount");
|
|
|
+ String notice = "";
|
|
|
+ if (NotFeedCount == 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(NotFeedCount) + "条";
|
|
|
+ JSONArray notFeedArray = dataObject.optJSONArray("NotFeedLocation");
|
|
|
+ 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");
|
|
|
+ String psl_prodcode = JsonUtils.optStringNotNull(notCheckObject, "PSL_PRODCODE");
|
|
|
+ //notice = notice + psl_location + "\n";
|
|
|
+ notice += "\n站位:" + psl_location + " 料号:" + psl_prodcode;
|
|
|
+ if (i == 0 && mOrderSwitch) {
|
|
|
+ //过滤|,取前面的字段
|
|
|
+ if (!TextUtils.isEmpty(psl_location) && psl_location.contains("|")) {
|
|
|
+ String[] strLocation = psl_location.split("\\|");
|
|
|
+ psl_location = strLocation[0];
|
|
|
+ }
|
|
|
+ mCollectEditText.setText(psl_location);
|
|
|
+ confirmEvent(psl_location);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isCancelVerification) {
|
|
|
+ JSONObject notCheckObject = notFeedArray.optJSONObject(0);
|
|
|
+ if (notCheckObject != null) {
|
|
|
+ String psl_location = JsonUtils.optStringNotNull(notCheckObject, "PSL_LOCATION");
|
|
|
+ String psl_prodcode = JsonUtils.optStringNotNull(notCheckObject, "PSL_PRODCODE");
|
|
|
+ mLocationTextView.setText(psl_location);
|
|
|
+ initLocation(psl_location);
|
|
|
+ tv_collection_info.setVisibility(View.VISIBLE);
|
|
|
+ tv_collection_info.setText("请采集站位:" + psl_location + ",物料:" + psl_prodcode + "料卷编号/物料编号");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ tv_collection_info.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ //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(NotFeedCount).length(), R.color.blue_800);
|
|
|
+ tvMsgNotice.setText(spannableString);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tvMsgNotice.setText(failStr);
|
|
|
+ tv_collection_info.setText("");
|
|
|
+ tv_collection_info.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ // String url = GloableParams.ADDRESS_SMT_GET_UNLOADING_LOCATION + "?linecode="
|
|
|
+ // + (mLineInfoBean == null ? "" : mLineInfoBean.getDL_LINECODE());
|
|
|
+ // PdaApplication.mRequestQueue.cancelAll(TAG + "unloading");
|
|
|
+ //
|
|
|
+ // 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 NotFeedCount = JsonUtils.optDoubleNotNull(dataObject, "NotFeedCount");
|
|
|
+ // String notice = "";
|
|
|
+ // if (NotFeedCount == 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(NotFeedCount) + "条";
|
|
|
+ // JSONArray notFeedArray = dataObject.optJSONArray("NotFeedLocation");
|
|
|
+ // 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");
|
|
|
+ // String psl_prodcode = JsonUtils.optStringNotNull(notCheckObject, "PSL_PRODCODE");
|
|
|
+ // //notice = notice + psl_location + "\n";
|
|
|
+ // notice += "\n站位:" + psl_location + " 料号:" + psl_prodcode;
|
|
|
+ // if (i == 0 && mOrderSwitch) {
|
|
|
+ // //过滤|,取前面的字段
|
|
|
+ // if(!TextUtils.isEmpty(psl_location)&&psl_location.contains("|")){
|
|
|
+ // String[] strLocation=psl_location.split("\\|");
|
|
|
+ // psl_location=strLocation[0];
|
|
|
+ // }
|
|
|
+ // mCollectEditText.setText(psl_location);
|
|
|
+ // confirmEvent(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(NotFeedCount).length(), R.color.blue_800);
|
|
|
+ // tvMsgNotice.setText(spannableString);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // 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 + "unloading");
|
|
|
+ // PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ VolleyUtil.distoryVolley();
|
|
|
+ super.onDestroy();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroyView() {
|
|
|
+ CommonUtil.closeKeybord(mCollectEditText, mActivity);
|
|
|
+ super.onDestroyView();
|
|
|
+ }
|
|
|
+
|
|
|
+ //按钮点击事件:当Location为空的时候
|
|
|
+ private void disposeOnClickLocation() {
|
|
|
+ Log.e("SMTChildInOnclick", "站位为空");
|
|
|
+ String tmpLocation = null;
|
|
|
+ String title = null;
|
|
|
+ String content = null;
|
|
|
+ int color = 0;
|
|
|
+ isAgain = false;
|
|
|
+
|
|
|
+ //信息框都清空
|
|
|
+ tvBarcode.setText("");
|
|
|
+ tvRemainqty.setText("");
|
|
|
+ tvFecode.setText("");
|
|
|
+
|
|
|
+ try {
|
|
|
+ //比对smtLocation
|
|
|
+ for (int i = 0; i < smtLocation.length(); i++) {
|
|
|
+ JSONObject tmpJson = smtLocation.getJSONObject(i);
|
|
|
+ tmpLocation = tmpJson.getString("psl_location").trim();
|
|
|
+ //如果匹配
|
|
|
+ if (tmpLocation.equals(code)) {
|
|
|
+ Log.e("SMTCHILD", "匹配");
|
|
|
+ //显示在站位输入框,添加数据项
|
|
|
+ tvLocation.setText(tmpLocation);
|
|
|
+ msl = new JSONObject();
|
|
|
+ msl.put("msl_location", code);
|
|
|
+ msl.put("msl_prodcode", tmpJson.getString("psl_prodcode").trim());
|
|
|
+ msl.put("msl_repcode", tmpJson.getString("psl_repcode").trim());
|
|
|
+ // msl.put("msl_repcode","无");
|
|
|
+ msl.put("psl_id", tmpJson.getString("psl_id").trim());
|
|
|
+ msl.put("msl_fespec", tmpJson.getString("psl_feeder").trim());
|
|
|
+ //msl = smtLocation.getJSONObject(i);
|
|
|
+ Log.e("SMTCHILD", msl.toString());
|
|
|
+ //更改etCollect的Hint
|
|
|
+ setEtHint();
|
|
|
+ //提示框中显示信息
|
|
|
+ title = "站位采集成功";
|
|
|
+ content = "站位采集成功,请采集物料" + msl.get("msl_prodcode") + "的条码";
|
|
|
+ color = getResources().getColor(R.color.green);
|
|
|
+ setNotice(title, content, color);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //如果不匹配
|
|
|
+ else {
|
|
|
+ Log.e("SMTCHILD", "不匹配");
|
|
|
+ title = "错误";
|
|
|
+ content = getString(R.string.notice_smtchild_barcode);
|
|
|
+ color = getResources().getColor(R.color.text_error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ setNotice(title, content, color);
|
|
|
+ }
|
|
|
+
|
|
|
+ //按钮点击事件:当料卷号为空的时候
|
|
|
+ private void disposeOnClickBarcode() {
|
|
|
+ Log.e("SMTChildInOnclick", "料卷为空");
|
|
|
+ //请求判断料卷编号是否正确,获取料卷数量
|
|
|
+ JSONObject paramJson = new JSONObject();
|
|
|
+ try {
|
|
|
+ paramJson.put("bar_code", code);
|
|
|
+ paramJson.put("prod_code", msl.getString("msl_prodcode"));
|
|
|
+ paramJson.put("rep_code", msl.getString("msl_repcode"));
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ showLoadingView();
|
|
|
+ requestType = VolleyUtil.FRAGMENT_SCMAKE_SMTIN_BARREMAIN;
|
|
|
+ VolleyUtil.getVolleyUtil().requestJsonObject(getActivity(), GloableParams.ADDRESS_SMT_BARREMAIN_APPLY, VolleyUtil.METHOD_POST,
|
|
|
+ VolleyUtil.FRAGMENT_SCMAKE_SMTIN_BARREMAIN, paramJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ //按钮点击事件:当飞达编号为空时
|
|
|
+ private void disposeOnClickFecode() {
|
|
|
+ //获取飞达编号
|
|
|
+ String fecodeStr = tvFecode.getText().toString().trim();
|
|
|
+ //->else if(msl_fecode为空),料卷号不为空,飞达编号为空时
|
|
|
+ if (fecodeStr.equals("") || fecodeStr == null) {
|
|
|
+ //tvFecode.setText(code);
|
|
|
+ try {
|
|
|
+ msl.put("msl_fecode", code);
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //上料操作
|
|
|
+ requestType = VolleyUtil.FRAGMENT_SCMAKE_SMTIN_UPLOAD;
|
|
|
+ showLoadingView();
|
|
|
+ VolleyUtil.getVolleyUtil().requestSMTInUpLoad(getActivity(), GloableParams.ADDRESS_SMTIN_UPLOAD_APPLY, VolleyUtil.METHOD_POST,
|
|
|
+ requestType, msl.toString(), makeCraft.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //扫描料卷编号成功
|
|
|
+ String mslBarcode = null, mslRemainQty = null;
|
|
|
+
|
|
|
+ private void disposeBarcodeSuccess(String result) {
|
|
|
+ String title, content;
|
|
|
+ int color;
|
|
|
+ JSONObject tmpJson, msgJson;
|
|
|
+ try {
|
|
|
+ tmpJson = new JSONObject(result);
|
|
|
+ msgJson = tmpJson.getJSONObject("message");
|
|
|
+ //将message中的值赋值给变量msl中的值
|
|
|
+ msl.put("msl_barcode", msgJson.getString("bar_code"));
|
|
|
+ msl.put("msl_prodcode", msgJson.get("bar_prodcode"));
|
|
|
+ msl.put("msl_remainqty", msgJson.get("bar_remain"));
|
|
|
+ mslBarcode = code;
|
|
|
+ mslRemainQty = msgJson.getString("bar_remain");
|
|
|
+ //料卷编号和数量输入框显示对应的值,清空采集栏中的值
|
|
|
+ tvBarcode.setText(mslBarcode);
|
|
|
+ tvRemainqty.setText(mslRemainQty);
|
|
|
+ //将采集栏中的提示文字修改为“请录入飞达编号”
|
|
|
+ setEtHint();
|
|
|
+ //清空提示栏信息
|
|
|
+ title = "料卷采集成功";
|
|
|
+ content = "请采集物料" + msl.get("msl_prodcode") + "的飞达编号";
|
|
|
+ color = getResources().getColor(R.color.green);
|
|
|
+ setNotice(title, content, color);
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //上料成功
|
|
|
+ private void disposeUpLoadSuccess(String result) {
|
|
|
+ JSONObject msgJson;
|
|
|
+ String productStr = "无", locationStr = "无", fecodeStr = "无", barcodeStr = "无", qtyStr = "无";
|
|
|
+ try {
|
|
|
+ JSONObject tmpJson = new JSONObject(result);
|
|
|
+ msgJson = tmpJson.getJSONObject("message");
|
|
|
+ productStr = msgJson.getString("msl_prodcode");
|
|
|
+ locationStr = msgJson.getString("msl_location");
|
|
|
+ fecodeStr = msgJson.getString("msl_fecode");
|
|
|
+ barcodeStr = msgJson.getString("msl_barcode");
|
|
|
+ qtyStr = msgJson.getString("msl_remainqty");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ tvFecode.setText(code);
|
|
|
+ //信息提示框
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tvMsgNotice.setText("上料成功");
|
|
|
+ tvMsgNotice.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tvMsgLocation.setText("物料号:" + productStr);
|
|
|
+ tvMsgProdcode.setText("站位:" + locationStr);
|
|
|
+ tvMsgBarcode.setText("飞达:" + fecodeStr);
|
|
|
+ tvMsgQuantity.setText("料卷号:" + barcodeStr);
|
|
|
+ tvMsgSpec.setText("数量:" + qtyStr);
|
|
|
+ //新一轮采集
|
|
|
+ msl = null;
|
|
|
+ isAgain = true;
|
|
|
+ setEtHint();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*========================Volley Handler=================================*/
|
|
|
+ Handler handler = new Handler() {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ switch (msg.what) {
|
|
|
+ case VolleyUtil.SUCCESS_SUCCESS:
|
|
|
+ disposeVolleySuccess(msg);
|
|
|
+ break;
|
|
|
+ case VolleyUtil.FAILED_FAILED:
|
|
|
+ disposeVolleyFaild(msg);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ //Volley响应失败
|
|
|
+ private void disposeVolleyFaild(Message msg) {
|
|
|
+ String noticeMsg = (String) msg.obj;
|
|
|
+ String title = "失败";
|
|
|
+ String content = noticeMsg;
|
|
|
+ setNotice(title, content, getResources().getColor(R.color.red));
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+ //Volley响应成功函数
|
|
|
+ private void disposeVolleySuccess(Message msg) {
|
|
|
+ Log.e("SCSMTFEEDER", "HandlerSuccess");
|
|
|
+ String result = (String) msg.obj;
|
|
|
+ switch (requestType) {
|
|
|
+ //请求详细数据
|
|
|
+ case VolleyUtil.FRAGMENT_SCMAKE_SMTINDETAIL:
|
|
|
+ Log.e("SCSMTFEEDER", "requestType:" + requestType);
|
|
|
+ String smtLocationStr = (String) msg.obj;
|
|
|
+ try {
|
|
|
+ //保存请求的变量
|
|
|
+ JSONObject tmpJson = new JSONObject(smtLocationStr);
|
|
|
+ //如果没有获取到网络数据
|
|
|
+ boolean isNull = tmpJson.isNull("message");
|
|
|
+ if (isNull) {
|
|
|
+ disposeNullServerData();
|
|
|
+ } else {
|
|
|
+ smtLocation = tmpJson.getJSONArray("message");
|
|
|
+ //这里获取了数据 没有填充上去
|
|
|
+ Log.e("SMTINChild", "smtLocation:" + smtLocation.toString());
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //物料
|
|
|
+ case VolleyUtil.FRAGMENT_SCMAKE_SMTIN_BARREMAIN:
|
|
|
+ Log.e("SMTWULIAO", "BARREMAIN");
|
|
|
+ disposeBarcodeSuccess(result);
|
|
|
+ // disposeFecodeCollect();
|
|
|
+ break;
|
|
|
+ //上料操作:上料成功以后,需要重新获取输入框文字
|
|
|
+ case VolleyUtil.FRAGMENT_SCMAKE_SMTIN_UPLOAD:
|
|
|
+ disposeUpLoadSuccess(result);
|
|
|
+ MyLog.e("aaa","旧的上料成功");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+ //隐藏采集界面
|
|
|
+ private void disposeNullServerData() {
|
|
|
+ rlCollect.setVisibility(View.GONE);
|
|
|
+ String title = getString(R.string.notice_smtin_nulldata);
|
|
|
+ setNotice(title, "", getResources().getColor(R.color.text_error));
|
|
|
+ }
|
|
|
+ /*========================公用方法=================================*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示loadingView
|
|
|
+ */
|
|
|
+ private void showLoadingView() {
|
|
|
+ if (!progressDialog.isShowing()) {
|
|
|
+ progressDialog.show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 键盘
|
|
|
+ */
|
|
|
+ InputMethodManager inputManager;
|
|
|
+
|
|
|
+ private void hideKeyboard(final EditText view) {
|
|
|
+ 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);
|
|
|
+ //清除其它信息
|
|
|
+ tvMsgSpec.setText("");
|
|
|
+ tvMsgBarcode.setText("");
|
|
|
+ tvMsgLocation.setText("");
|
|
|
+ tvMsgQuantity.setText("");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置采集框提示信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void setEtHint() {
|
|
|
+ //获取站位\料卷\飞达编号
|
|
|
+ String locationStr = tvLocation.getText().toString().trim();
|
|
|
+ String barcodeStr = tvBarcode.getText().toString().trim();
|
|
|
+ String remainQty = tvRemainqty.getText().toString().trim();
|
|
|
+ String fecodeStr = tvFecode.getText().toString().trim();
|
|
|
+ /*//->if(msl_location为空),如果站位为null
|
|
|
+ if (isAgain || locationStr.equals("") || locationStr == null) {
|
|
|
+ etCollect.setHint(R.string.hint_smtchild_location);
|
|
|
+ }
|
|
|
+ //->else if(msl_barcode为空) 如果站位不为空,料卷号为空
|
|
|
+ else if (barcodeStr.equals("") || barcodeStr == null) {
|
|
|
+ etCollect.setHint(R.string.hint_smtchild_barcode);
|
|
|
+ }
|
|
|
+ //->else if(msl_remainqty为空) 如果数量为空
|
|
|
+ else if (remainQty.equals("") || remainQty == null) {
|
|
|
+ etCollect.setHint(R.string.hint_smtchild_barcode);
|
|
|
+ }
|
|
|
+ //->else if(msl_fecode为空),料卷号不为空,飞达编号为空时
|
|
|
+ else if (fecodeStr.equals("") || barcodeStr == null) {
|
|
|
+ etCollect.setHint(R.string.hint_smtchild_fecode);
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按钮点击事件
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ disposeOnClick();
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject msl = new JSONObject();
|
|
|
+ String code = null;
|
|
|
+ boolean isAgain = false;
|
|
|
+
|
|
|
+ private void disposeOnClick() {
|
|
|
+ //->获取输入框文字内容
|
|
|
+ // code = etCollect.getText().toString().trim();
|
|
|
+ if (code.equals("") || code == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Log.e("SCSMT:code", "" + code);
|
|
|
+ //获取站位\料卷\飞达编号
|
|
|
+ String locationStr = tvLocation.getText().toString().trim();
|
|
|
+ String barcodeStr = tvBarcode.getText().toString().trim();
|
|
|
+ String fecodeStr = tvFecode.getText().toString().trim();
|
|
|
+ //->if(msl_location为空),如果站位为null,或者是新一轮采集
|
|
|
+ if (isAgain || locationStr.equals("") || locationStr == null) {
|
|
|
+ disposeOnClickLocation();
|
|
|
+ }
|
|
|
+ //->else if(msl_barcode为空) 如果站位不为空,料卷号为空
|
|
|
+ else if (barcodeStr.equals("") || barcodeStr == null) {
|
|
|
+ disposeOnClickBarcode();
|
|
|
+ }
|
|
|
+ //->else if(msl_fecode为空),料卷号不为空,飞达编号为空时
|
|
|
+ else if (fecodeStr.equals("") || barcodeStr == null) {
|
|
|
+ disposeOnClickFecode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
|
|
+ if (progressDialog != null && progressDialog.isShowing()) {
|
|
|
+ // loadingView.dismiss();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|