|
|
@@ -0,0 +1,239 @@
|
|
|
+package com.uas.pda_wps.fragment;
|
|
|
+
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.uas.pda_wps.R;
|
|
|
+import com.uas.pda_wps.activity.FunctionActivity;
|
|
|
+import com.uas.pda_wps.adapter.FeidaCalibrationAdapter;
|
|
|
+import com.uas.pda_wps.application.PdaApplication;
|
|
|
+import com.uas.pda_wps.bean.FeidaCalibrationBean;
|
|
|
+import com.uas.pda_wps.bean.LineInfoBean;
|
|
|
+import com.uas.pda_wps.global.GloableParams;
|
|
|
+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.VolleyRequest;
|
|
|
+import com.uas.pda_wps.view.ClearableEditText;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 飞达校验
|
|
|
+ */
|
|
|
+public class FeidaCalibrationFra extends BaseFragment {
|
|
|
+
|
|
|
+ private TextView tv_xianbie, tv_banmian, tv_gongdanbianhao, tv_not_jiaoyan;
|
|
|
+ private LineInfoBean mLineInfoBean;
|
|
|
+ String deviceLineMake = "";
|
|
|
+ private ClearableEditText cet_feida_bianhao;
|
|
|
+ private RecyclerView rv_not_cailibration;
|
|
|
+ private List<FeidaCalibrationBean> fidaCailibrationBeans;
|
|
|
+ private FeidaCalibrationAdapter feidaCalibrationAdapter;
|
|
|
+// private FeidaCalibrationAda feidaCalibrationAdapter;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.frag_fada_calibration;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ tv_xianbie = (TextView) root.findViewById(R.id.tv_xianbie);
|
|
|
+ tv_banmian = (TextView) root.findViewById(R.id.tv_banmian);
|
|
|
+ tv_gongdanbianhao = (TextView) root.findViewById(R.id.tv_gongdanbianhao);
|
|
|
+ tv_not_jiaoyan = (TextView) root.findViewById(R.id.tv_not_jiaoyan);
|
|
|
+ rv_not_cailibration = (RecyclerView) root.findViewById(R.id.rv_not_cailibration);
|
|
|
+
|
|
|
+ cet_feida_bianhao = (ClearableEditText) root.findViewById(R.id.cet_feida_bianhao);
|
|
|
+ cet_feida_bianhao.requestFocus();
|
|
|
+
|
|
|
+ mLineInfoBean = (LineInfoBean) PdaApplication.getDataCacheFromMap(Constants.FLAG.SMT_DEVICE_LINE_CACHE);
|
|
|
+ if (mLineInfoBean != null) {
|
|
|
+ deviceLineMake = JSON.toJSONString(mLineInfoBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ cet_feida_bianhao.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ String collect = v.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;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText("飞达校验");
|
|
|
+
|
|
|
+ if (mLineInfoBean != null) {
|
|
|
+ tv_xianbie.setText(mLineInfoBean.getDL_LINECODE());
|
|
|
+ tv_banmian.setText(mLineInfoBean.getDL_TABLE() + "面");
|
|
|
+ tv_gongdanbianhao.setText(mLineInfoBean.getDL_MACODE());
|
|
|
+ }
|
|
|
+
|
|
|
+ rv_not_cailibration.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
+ fidaCailibrationBeans = new ArrayList<>();
|
|
|
+ feidaCalibrationAdapter = new FeidaCalibrationAdapter(fidaCailibrationBeans);
|
|
|
+// feidaCalibrationAdapter = new FeidaCalibrationAda(getActivity(), fidaCailibrationBeans);
|
|
|
+ rv_not_cailibration.setAdapter(feidaCalibrationAdapter);
|
|
|
+
|
|
|
+ getUncheckLocation();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取未校验站位
|
|
|
+ */
|
|
|
+ private void getUncheckLocation() {
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_SMT_QUAGETUNCHECKFEEDER)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("linecode", (mLineInfoBean == null ? "" : mLineInfoBean.getDL_LINECODE()))
|
|
|
+ .addParam("table", (mLineInfoBean == null ? "" : mLineInfoBean.getDL_TABLE()))
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ if (FastjsonUtil.validate(result)) {
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+
|
|
|
+ String NotCheckCount = dataObject.getString("NotCheckCount");
|
|
|
+ JSONArray dataArray = dataObject.getJSONArray("NotCheckFeeder");
|
|
|
+ fidaCailibrationBeans.clear();
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
+ tv_not_jiaoyan.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tv_not_jiaoyan.setText("未校验飞达 " + NotCheckCount + "条");
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject jb = dataArray.getJSONObject(i);
|
|
|
+ FeidaCalibrationBean feidaCalibrationBean = new FeidaCalibrationBean();
|
|
|
+ String dsl_location = jb.getString("DSL_LOCATION");
|
|
|
+ String dsl_fecode = jb.getString("DSL_FECODE");
|
|
|
+ feidaCalibrationBean.setDSL_LOCATION(dsl_location);
|
|
|
+ feidaCalibrationBean.setDSL_FECODE(dsl_fecode);
|
|
|
+ fidaCailibrationBeans.add(feidaCalibrationBean);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ tv_not_jiaoyan.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tv_not_jiaoyan.setText("无未校验数据");
|
|
|
+ }
|
|
|
+ feidaCalibrationAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ cet_feida_bianhao.setText("");
|
|
|
+ cet_feida_bianhao.requestFocus();
|
|
|
+ tv_not_jiaoyan.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tv_not_jiaoyan.setText(failStr);
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void confirmEvent(final String collect) {
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_SMT_QUACHECKFEEDERDATA)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("deviceLineMake", deviceLineMake)
|
|
|
+ .addParam("fe_code", collect)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ cet_feida_bianhao.setText("");
|
|
|
+ cet_feida_bianhao.requestFocus();
|
|
|
+ if (FastjsonUtil.validate(result)) {
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+
|
|
|
+ String NotCheckCount = dataObject.getString("NotCheckCount");
|
|
|
+ JSONArray dataArray = dataObject.getJSONArray("NotCheckFeeder");
|
|
|
+ fidaCailibrationBeans.clear();
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
+ tv_not_jiaoyan.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tv_not_jiaoyan.setText("未校验飞达 " + NotCheckCount + "条");
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject jb = dataArray.getJSONObject(i);
|
|
|
+ FeidaCalibrationBean feidaCalibrationBean = new FeidaCalibrationBean();
|
|
|
+ String dsl_location = jb.getString("DSL_LOCATION");
|
|
|
+ String dsl_fecode = jb.getString("DSL_FECODE");
|
|
|
+ feidaCalibrationBean.setDSL_LOCATION(dsl_location);
|
|
|
+ feidaCalibrationBean.setDSL_FECODE(dsl_fecode);
|
|
|
+ fidaCailibrationBeans.add(feidaCalibrationBean);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ tv_not_jiaoyan.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ tv_not_jiaoyan.setText("无未校验数据");
|
|
|
+ }
|
|
|
+ feidaCalibrationAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ cet_feida_bianhao.setText("");
|
|
|
+ cet_feida_bianhao.requestFocus();
|
|
|
+ tv_not_jiaoyan.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tv_not_jiaoyan.setText(failStr);
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (!hidden) {
|
|
|
+ FunctionActivity.setTitle("飞达校验");
|
|
|
+ } else { }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|