| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312 |
- package com.uas.uaspda.fragment;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.graphics.drawable.BitmapDrawable;
- import android.os.AsyncTask;
- import android.os.Handler;
- import android.os.Message;
- import android.support.v4.app.Fragment;
- import android.support.v7.app.AlertDialog;
- import android.text.Editable;
- import android.text.TextUtils;
- import android.text.TextWatcher;
- import android.util.Log;
- import android.view.Gravity;
- import android.view.KeyEvent;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.AutoCompleteTextView;
- import android.widget.Button;
- import android.widget.CheckBox;
- import android.widget.CompoundButton;
- import android.widget.GridView;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.PopupWindow;
- import android.widget.RadioButton;
- import android.widget.RadioGroup;
- import android.widget.SimpleAdapter;
- import android.widget.TextView;
- import com.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.application.PdaApplication;
- import com.uas.uaspda.bean.ErrorMsg;
- import com.uas.uaspda.bean.LineInfoBean;
- 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.JsonTools;
- import com.uas.uaspda.util.JsonUtils;
- import com.uas.uaspda.util.MyArrayAdapter;
- import com.uas.uaspda.view.ClearableEditText;
- import com.uas.uaspda.view.ConfirmDialog;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.io.UnsupportedEncodingException;
- import java.net.URLEncoder;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * SMT作业页面
- */
- public class SCSMTIndexFragment extends BaseFragment implements AdapterView.OnItemClickListener {
- private static final String TAG = "SCSMTIndexFragment";
- private static final int MACODE_FUZZY = 0;
- private static final int PRODCODE_FUZZY = 1;
- GridView lvIndex;
- List<Map<String, Object>> operationIndexList;
- private LineInfoBean mLineInfoBean;
- private PopupWindow mPasswordPopupWindow, mSwitchPopupWindow, mMachinePopupWindow, mDownAllPopupWindow;
- private ClearableEditText mPasswordEditText;
- private TextView mConfirmTextView, mCancelTextView;
- private TextView mDecodeTextView, mStatusTextView, mLinecodeTextView, mTableTextView, mMacodeTextView, mProdcodeTextView;
- private StringRequest mStringRequest;
- private int dl_madeqty, ma_qty;//产出数,工单数
- private MyArrayAdapter mAutoStringAdapter;
- View downAllView;
- AlertDialog switchDialog;
- @Override
- protected int getLayout() {
- return R.layout.fragment_scmake_smtcontent;
- }
- @Override
- protected void initViews() {
- ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.title_operation_smt);
- ((Button) (getActivity().findViewById(R.id.btn_actionbar_right))).setVisibility(View.GONE);
- downAllView = View.inflate(getActivity(), R.layout.pop_smt_down_all, null);
- switchDialog = new AlertDialog.Builder(getActivity()).setView(downAllView).create();
- lvIndex = (GridView) root.findViewById(R.id.lv_index_smt);
- mDecodeTextView = (TextView) root.findViewById(R.id.smt_content_decode_tv);
- mStatusTextView = (TextView) root.findViewById(R.id.smt_content_status_tv);
- mLinecodeTextView = (TextView) root.findViewById(R.id.smt_content_linecode_tv);
- mTableTextView = (TextView) root.findViewById(R.id.smt_content_table_tv);
- mMacodeTextView = (TextView) root.findViewById(R.id.smt_content_macode_tv);
- mProdcodeTextView = (TextView) root.findViewById(R.id.smt_content_prodcode_tv);
- //接口回调
- VolleyUtil.setVolleyHandler(volleyHandler);
- //获取数据
- operationIndexList = DataSourceManager.getDataSourceManager().getFeederOperationIndex();
- mLineInfoBean = (LineInfoBean) PdaApplication.getDataCacheFromMap(Constants.FLAG.SMT_DEVICE_LINE_CACHE);
- }
- @Override
- protected void initEvents() {
- //配置监听
- lvIndex.setOnItemClickListener(this);
- }
- @Override
- protected void initDatas() {
- SimpleAdapter adapter = new SimpleAdapter(mActivity, operationIndexList, R.layout.item_grid_first,
- new String[]{DataSourceManager.KEY_GRID_ITEMIMG, DataSourceManager.KEY_GRID_ITEMNAME},
- new int[]{R.id.first_griditem_img, R.id.first_griditem_name});
- lvIndex.setAdapter(adapter);
- if (mLineInfoBean != null) {
- mDecodeTextView.setText(mLineInfoBean.getDL_DECODE());
- mStatusTextView.setText(mLineInfoBean.getDL_STATUS());
- mLinecodeTextView.setText(mLineInfoBean.getDL_LINECODE());
- mTableTextView.setText(mLineInfoBean.getDL_TABLE() + "面");
- mMacodeTextView.setText(mLineInfoBean.getDL_MACODE());
- mProdcodeTextView.setText(mLineInfoBean.getDL_PRODCODE());
- if (CommonUtil.isNetWorkConnected(mActivity)) {
- getSmtLocation();
- } else {
- CommonUtil.toastNoRepeat(mActivity, getString(R.string.net_not_connect));
- SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, "");
- }
- }
- }
- @Override
- public void onHiddenChanged(boolean hidden) {
- super.onHiddenChanged(hidden);
- if (!hidden) {
- VolleyUtil.setVolleyHandler(volleyHandler);
- ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.title_operation_smt);
- ((Button) (getActivity().findViewById(R.id.btn_actionbar_right))).setVisibility(View.GONE);
- }
- }
- /**
- * 获取当前工单站位信息
- */
- private void getSmtLocation() {
- progressDialog.show();
- String url = GloableParams.ADDRESS_SMT_GET_SMT_LOCATION
- + "?ps_id=" + mLineInfoBean.getPS_ID()
- + "&dl_table=" + mLineInfoBean.getDL_TABLE();
- PdaApplication.mRequestQueue.cancelAll(TAG + "location");
- mStringRequest = new StringRequest(Request.Method.GET, url,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- try {
- JSONObject resultObject = new JSONObject(s);
- if (resultObject.optBoolean("success")) {
- String smtLocation = resultObject.optString("data");
- Log.d("smtLocation", smtLocation);
- SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, smtLocation);
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- CommonUtil.showErrorToast(volleyError, true);
- SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, "");
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- };
- mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- mStringRequest.setTag(TAG + "location");
- PdaApplication.mRequestQueue.add(mStringRequest);
- }
- @Override
- public void onDestroy() {
- VolleyUtil.distoryVolley();
- PdaApplication.removeDataCacheFromMap(Constants.FLAG.SMT_REQUEST_CACHE);
- super.onDestroy();
- }
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- if (!CommonUtil.isRepeatClick()) {
- String mSmtLocationCache = SharedPreUtil.getString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, null);
- if (TextUtils.isEmpty(mSmtLocationCache)) {
- new AlertDialog.Builder(mActivity).setTitle("提示")
- .setMessage("获取站位表失败,无法进行后续操作。点击确定重新获取站位表!")
- .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (CommonUtil.isNetWorkConnected(mActivity)) {
- getSmtLocation();
- } else {
- CommonUtil.toastNoRepeat(mActivity, getString(R.string.net_not_connect));
- SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, "");
- }
- }
- })
- .setNegativeButton(R.string.cancel, null).create().show();
- } else {
- //获取选择的列表Name
- String selectedName = operationIndexList.get(position).get(DataSourceManager.KEY_GRID_ITEMNAME).toString();
- Fragment fragment;
- switch (selectedName) {
- //上料
- case GloableParams.LISTNAME_FEEDER_IN:
- fragment = new SCSMTInFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //接料
- case GloableParams.LISTNAME_FEEDER_JOIN:
- fragment = new SCSMTJointFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //换料
- case GloableParams.LISTNAME_FEEDER_CHANGE:
- fragment = new SCSMTChangeFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //下料
- case GloableParams.LISTNAME_FEEDER_DOWN:
- fragment = new SCSMTDownFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //全部下料
- case GloableParams.LISTNAME_FEEDER_DOWNALL:
- queryMakeqty(1);
- break;
- //料卷查询
- case GloableParams.LISTNAME_FEEDER_QUERY:
- fragment = new SCSMTQueryFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //工单切换
- case GloableParams.LISTNAME_FEEDER_SWITCH:
- queryMakeqty(2);
- break;
- //校验
- case GloableParams.LISTNAME_FEEDER_CHECK:
- fragment = new SCSMTCheckFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //机台操作
- case GloableParams.LISTNAME_FEEDER_MACHINE:
- operationMachine();
- break;
- //叫料
- case GloableParams.LISTNAME_REQUEST_MACHINE:
- fragment = new SCSMTRequestFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //站位反查
- case GloableParams.LISTNAME_LOCATION_QUERY:
- fragment = new SMTLocationQueryFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //备料查询
- case GloableParams.LISTNAME_PREMATERIAL_QUERY:
- fragment = new SMTPreMaterialQueryFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //飞达料盘绑定
- case GloableParams.LISTNAME_FEEDER_BIND:
- fragment = new SCSMTBindFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //飞达料盘解绑
- case GloableParams.LISTNAME_FEEDER_UNBIND:
- fragment = new SCSMTUnBindFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- //复检效验
- case GloableParams.LISTNAME_FEEDER_CHECKINSPECTION:
- fragment = new SCSMTInspectionFragment();
- FragmentUtils.switchFragment(this, fragment);
- break;
- }
- }
- }
- }
- private void operationMachine() {
- View machineView = View.inflate(mActivity, R.layout.popupwindow_machine_operation, null);
- TextView mMsgTextView = (TextView) machineView.findViewById(R.id.pop_machine_operation_msg_tv);
- TextView mCancelTextView = (TextView) machineView.findViewById(R.id.pop_machine_operation_cancel_tv);
- TextView mConfirmTextView = (TextView) machineView.findViewById(R.id.pop_machine_operation_confirm_tv);
- mCancelTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeMachinePopupWindow();
- }
- });
- if ("UNUSED".equals(mLineInfoBean.getDL_STATUSCODE().trim())
- || "STOP".equals(mLineInfoBean.getDL_STATUSCODE().trim())) {
- mMsgTextView.setText("机台正处于停止状态,是否启动机台?");
- mConfirmTextView.setText("启动机台");
- mConfirmTextView.setTextColor(getResources().getColor(R.color.text_blue));
- mConfirmTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- startMachine(false);
- }
- });
- }
- if ("STARTED".equals(mLineInfoBean.getDL_STATUSCODE().trim())) {
- mMsgTextView.setText("机台正处于启动状态,是否暂停机台?");
- mConfirmTextView.setText("暂停机台");
- mConfirmTextView.setTextColor(getResources().getColor(R.color.color_red));
- mConfirmTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- stopMachine();
- }
- });
- }
- mMachinePopupWindow = new PopupWindow(machineView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
- mMachinePopupWindow.setBackgroundDrawable(new BitmapDrawable());
- mMachinePopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- @Override
- public void onDismiss() {
- closeMachinePopupWindow();
- }
- });
- CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
- mMachinePopupWindow.showAtLocation(mActivity.getWindow().getDecorView(), Gravity.CENTER, 0, -100);
- }
- /**
- * 获取对应工单产出数
- *
- * @param i
- */
- private void queryMakeqty(final int i) {
- progressDialog.show();
- String url = GloableParams.ADDRESS_SMT_QUERY_MADEQTY + "?dl_macode=" + mLineInfoBean.getDL_MACODE()
- + "&dl_linecode=" + mLineInfoBean.getDL_LINECODE();
- PdaApplication.mRequestQueue.cancelAll(TAG + "downall");
- mStringRequest = new StringRequest(Request.Method.GET, url,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- if (s != null) {
- try {
- Log.d("madeqty", s);
- JSONObject resultObject = new JSONObject(s);
- if (!resultObject.isNull("data")) {
- JSONObject dataObject = resultObject.optJSONObject("data");
- if (dataObject != null) {
- dl_madeqty = (int) JsonUtils.optLongNotNull(dataObject, "DL_MADEQTY");
- ma_qty = (int) JsonUtils.optLongNotNull(dataObject, "MA_QTY");
- showVerificationPop(i);
- } else {
- CommonUtil.toastNoRepeat(mActivity, "产出数获取失败,请重新获取");
- }
- } else {
- dl_madeqty = 0;
- ma_qty = 0;
- showVerificationPop(i);
- }
- } catch (JSONException e) {
- e.printStackTrace();
- CommonUtil.toastNoRepeat(mActivity, "产出数获取异常,请重新获取");
- }
- } else {
- CommonUtil.toastNoRepeat(mActivity, "产出数获取失败,请重新获取");
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- CommonUtil.showErrorToast(volleyError, true);
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- };
- mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- mStringRequest.setTag(TAG + "downall");
- PdaApplication.mRequestQueue.add(mStringRequest);
- }
- /**
- * 开启机台
- *
- * @param force
- */
- private void startMachine(final boolean force) {
- progressDialog.show();
- PdaApplication.mRequestQueue.cancelAll(TAG + "start");
- mStringRequest = new StringRequest(Request.Method.POST, GloableParams.ADDRESS_SMT_START_SMT,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- closeMachinePopupWindow();
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- try {
- Log.d("result", s);
- JSONObject resultObject = new JSONObject(s);
- if (resultObject.optBoolean("success")) {
- JSONObject dataObject = resultObject.optJSONObject("data");
- if (dataObject != null) {
- JSONObject devicelineObject = dataObject.optJSONObject("deviceline");
- if (devicelineObject != null) {
- mLineInfoBean = new LineInfoBean();
- mLineInfoBean.setDL_ID(JsonUtils.optLongNotNull(devicelineObject, "DL_ID"));
- mLineInfoBean.setDL_DECODE(JsonUtils.optStringNull(devicelineObject, "DL_DECODE"));
- mLineInfoBean.setDL_LINECODE(JsonUtils.optStringNull(devicelineObject, "DL_LINECODE"));
- mLineInfoBean.setDL_MACODE(JsonUtils.optStringNull(devicelineObject, "DL_MACODE"));
- mLineInfoBean.setDL_TABLE(JsonUtils.optStringNull(devicelineObject, "DL_TABLE"));
- mLineInfoBean.setDL_STATUSCODE(JsonUtils.optStringNull(devicelineObject, "DL_STATUSCODE"));
- mLineInfoBean.setDL_STATUS(JsonUtils.optStringNull(devicelineObject, "DL_STATUS"));
- mLineInfoBean.setPS_ID(JsonUtils.optLongNotNull(devicelineObject, "PS_ID"));
- mLineInfoBean.setMA_ID(JsonUtils.optLongNotNull(devicelineObject, "MA_ID"));
- mLineInfoBean.setDL_PRODCODE(JsonUtils.optStringNotNull(devicelineObject, "DL_PRODCODE"));
- PdaApplication.putDataCache2Map(Constants.FLAG.SMT_DEVICE_LINE_CACHE, mLineInfoBean);
- mDecodeTextView.setText(mLineInfoBean.getDL_DECODE());
- mStatusTextView.setText(mLineInfoBean.getDL_STATUS());
- mLinecodeTextView.setText(mLineInfoBean.getDL_LINECODE());
- mTableTextView.setText(mLineInfoBean.getDL_TABLE() + "面");
- mMacodeTextView.setText(mLineInfoBean.getDL_MACODE());
- mProdcodeTextView.setText(mLineInfoBean.getDL_PRODCODE());
- }
- String smtLocation = dataObject.optString("smtlocation");
- Log.d("smtLocation", smtLocation);
- if (!TextUtils.isEmpty(smtLocation))
- SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, smtLocation);
- CommonUtil.toastNoRepeat(mActivity, "机台启动成功");
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- closeMachinePopupWindow();
- int exceptionCode = 0;
- if (volleyError != null && volleyError.networkResponse != null && volleyError.networkResponse.data != null) {
- ErrorMsg errorMsg = JsonTools.parseJsonToBean(new String(volleyError.networkResponse.data), ErrorMsg.class);
- if (errorMsg != null) {
- exceptionCode = errorMsg.exceptionCode;
- }
- if (exceptionCode == 3001) {
- new AlertDialog.Builder(mActivity).setTitle("提示")
- .setMessage(errorMsg.exceptionInfo + ",是否强制启动?")
- .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- startMachine(true);
- }
- }).setNegativeButton(R.string.cancel, null).create().show();
- } else {
- CommonUtil.showErrorToast(volleyError, true);
- }
- }
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- Map<String, String> params = new HashMap<String, String>();
- String deviceLineMake = JSON.toJSONString(mLineInfoBean);
- params.put("deviceLineMake", deviceLineMake);
- params.put("force", force + "");
- return params;
- }
- };
- mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- mStringRequest.setTag(TAG + "start");
- PdaApplication.mRequestQueue.add(mStringRequest);
- }
- /**
- * 暂停机台
- */
- private void stopMachine() {
- progressDialog.show();
- PdaApplication.mRequestQueue.cancelAll(TAG + "stop");
- mStringRequest = new StringRequest(Request.Method.POST, GloableParams.ADDRESS_SMT_STOP_SMT,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- closeMachinePopupWindow();
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- try {
- JSONObject resultObject = new JSONObject(s);
- if (resultObject.optBoolean("success")) {
- JSONObject dataObject = resultObject.optJSONObject("data");
- if (dataObject != null) {
- JSONObject devicelineObject = dataObject.optJSONObject("deviceline");
- if (devicelineObject != null) {
- mLineInfoBean = new LineInfoBean();
- mLineInfoBean.setDL_ID(JsonUtils.optLongNotNull(devicelineObject, "DL_ID"));
- mLineInfoBean.setDL_DECODE(JsonUtils.optStringNull(devicelineObject, "DL_DECODE"));
- mLineInfoBean.setDL_LINECODE(JsonUtils.optStringNull(devicelineObject, "DL_LINECODE"));
- mLineInfoBean.setDL_MACODE(JsonUtils.optStringNull(devicelineObject, "DL_MACODE"));
- mLineInfoBean.setDL_TABLE(JsonUtils.optStringNull(devicelineObject, "DL_TABLE"));
- mLineInfoBean.setDL_STATUSCODE(JsonUtils.optStringNull(devicelineObject, "DL_STATUSCODE"));
- mLineInfoBean.setDL_STATUS(JsonUtils.optStringNull(devicelineObject, "DL_STATUS"));
- mLineInfoBean.setPS_ID(JsonUtils.optLongNotNull(devicelineObject, "PS_ID"));
- mLineInfoBean.setMA_ID(JsonUtils.optLongNotNull(devicelineObject, "MA_ID"));
- mLineInfoBean.setDL_PRODCODE(JsonUtils.optStringNotNull(devicelineObject, "DL_PRODCODE"));
- PdaApplication.putDataCache2Map(Constants.FLAG.SMT_DEVICE_LINE_CACHE, mLineInfoBean);
- mDecodeTextView.setText(mLineInfoBean.getDL_DECODE());
- mStatusTextView.setText(mLineInfoBean.getDL_STATUS());
- mLinecodeTextView.setText(mLineInfoBean.getDL_LINECODE());
- mTableTextView.setText(mLineInfoBean.getDL_TABLE() + "面");
- mMacodeTextView.setText(mLineInfoBean.getDL_MACODE());
- mProdcodeTextView.setText(mLineInfoBean.getDL_PRODCODE());
- }
- String smtLocation = dataObject.optString("smtlocation");
- if (!TextUtils.isEmpty(smtLocation))
- SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, smtLocation);
- CommonUtil.toastNoRepeat(mActivity, "机台暂停成功");
- }
- }
- } catch (Exception e) {
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- CommonUtil.showErrorToast(volleyError, true);
- closeMachinePopupWindow();
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- Map<String, String> params = new HashMap<String, String>();
- String deviceLineMake = JSON.toJSONString(mLineInfoBean);
- params.put("deviceLineMake", deviceLineMake);
- return params;
- }
- };
- mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- mStringRequest.setTag(TAG + "stop");
- PdaApplication.mRequestQueue.add(mStringRequest);
- }
- /**
- * 验证登录密码
- *
- * @param whichFunc 1:全部下料;2:工单切换
- */
- private void showVerificationPop(final int whichFunc) {
- LayoutInflater layoutInflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View popView = layoutInflater.inflate(R.layout.pop_password_verification, null);
- mCancelTextView = (TextView) popView.findViewById(R.id.pop_password_verification_cancel_tv);
- mConfirmTextView = (TextView) popView.findViewById(R.id.pop_password_verification_confirm_tv);
- mPasswordEditText = (ClearableEditText) popView.findViewById(R.id.pop_password_verification_et);
- mConfirmTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- verificationPassword(whichFunc);
- }
- });
- mCancelTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closePasswordPopupWindow();
- }
- });
- mPasswordPopupWindow = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
- mPasswordPopupWindow.setBackgroundDrawable(new BitmapDrawable());
- mPasswordPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- @Override
- public void onDismiss() {
- closePasswordPopupWindow();
- }
- });
- CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
- mPasswordPopupWindow.showAtLocation(mActivity.getWindow().getDecorView(), Gravity.CENTER, 0, -100);
- CommonUtil.openKeybord(mPasswordEditText, mActivity);
- }
- /**
- * 验证登录密码
- *
- * @param whichFunc
- */
- private void verificationPassword(int whichFunc) {
- String input = mPasswordEditText.getText().toString().trim();
- if (TextUtils.isEmpty(input)) {
- CommonUtil.toastNoRepeat(mActivity, "请输入密码!");
- } else {
- /*String str = SharedPreUtil.getString(mActivity, SharedPreUtil.KEY_URI, null);
- if (str != null) {
- try {
- IPPORT ip = JsonTools.parseJsonToBean(str, IPPORT.class);
- String ipStr = ip.uriArray.get(0).ip;
- String portStr = ip.uriArray.get(0).port;
- String mUserCache = SharedPreUtil.getString(mActivity, ipStr + ":" + portStr, null);
- if (mUserCache != null) {
- JSONObject userCacheJsonObject = null;
- userCacheJsonObject = new JSONObject(mUserCache);
- JSONArray userCacheArray = userCacheJsonObject.getJSONArray(DataSourceManager.KEY_INFOARRAY);
- JSONObject userCacheObject = (JSONObject) userCacheArray.get(0);
- String password = userCacheObject.getString(DataSourceManager.KEY_PASSWORD);
- if (password != null) {
- if (password.equals(input)) {
- // CommonUtil.toastNoRepeat(mActivity, "验证通过!");
- closePasswordPopupWindow();
- if (whichFunc == 1)
- showConfirmAllDownDialog();
- else if (whichFunc == 2) {
- showWitchPopupWindow();
- }
- } else {
- CommonUtil.toastNoRepeat(mActivity, "密码错误,请重新输入!");
- mPasswordEditText.setText("");
- mPasswordEditText.requestFocus();
- }
- } else {
- CommonUtil.toastNoRepeat(mActivity, "密码丢失,请重新登录!");
- closePasswordPopupWindow();
- }
- } else {
- CommonUtil.toastNoRepeat(mActivity, "密码丢失,请重新登录!");
- closePasswordPopupWindow();
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- } else {
- CommonUtil.toastNoRepeat(mActivity, "密码丢失,请重新登录!");
- closePasswordPopupWindow();
- }*/
- String verificationPwd = SharedPreUtil.getString(mActivity, Constants.FLAG.VERIFICATION_PASSWORD, null);
- if (TextUtils.isEmpty(verificationPwd)) {
- CommonUtil.toastNoRepeat(mActivity, "密码丢失,请重新登录!");
- CommonUtil.makeNotice();
- closePasswordPopupWindow();
- } else {
- if (verificationPwd.equals(input)) {
- // CommonUtil.toastNoRepeat(mActivity, "验证通过!");
- closePasswordPopupWindow();
- if (whichFunc == 1)
- showConfirmAllDownDialog();
- else if (whichFunc == 2) {
- showWitchPopupWindow();
- }
- } else {
- CommonUtil.toastNoRepeat(mActivity, "密码错误,请重新输入!");
- CommonUtil.makeNotice();
- mPasswordEditText.setText("");
- mPasswordEditText.requestFocus();
- }
- }
- }
- }
- /**
- * 切换工单
- */
- private void showWitchPopupWindow() {
- View switchView = View.inflate(mActivity, R.layout.popupwindom_switch_jobs, null);
- final AlertDialog switchDialog = new AlertDialog.Builder(mActivity).setView(switchView).create();
- final AutoCompleteTextView jobsEditText = (AutoCompleteTextView) switchView.findViewById(R.id.pop_switch_jobs_number_et);
- jobsEditText.setThreshold(1);
- final ClearableEditText outputEditText = (ClearableEditText) switchView.findViewById(R.id.pop_switch_jobs_output_et);
- final ImageView cleanIv = (ImageView) switchView.findViewById(R.id.pop_switch_jobs_clean_iv);
- RadioGroup mTableRadioGroup = (RadioGroup) switchView.findViewById(R.id.pop_switch_jobs_table_rg);
- final RadioButton mARadioButton = (RadioButton) switchView.findViewById(R.id.pop_switch_jobs_a_rb);
- final RadioButton mBRadioButton = (RadioButton) switchView.findViewById(R.id.pop_switch_jobs_b_rb);
- final TextView mConfirmTextView = (TextView) switchView.findViewById(R.id.pop_switch_jobs_confirm_tv);
- TextView mCancelTextView = (TextView) switchView.findViewById(R.id.pop_switch_jobs_cancel_tv);
- final CheckBox orderCheckBox = (CheckBox) switchView.findViewById(R.id.pop_switch_jobs_order_cb);
- LinearLayout mOperationLinearLayout = (LinearLayout) switchView.findViewById(R.id.pop_switch_jobs_operation_ll);
- final LinearLayout mExceptionLinearLayout = (LinearLayout) switchView.findViewById(R.id.pop_switch_jobs_exception_ll);
- final TextView mExceptionTextView = (TextView) switchView.findViewById(R.id.pop_switch_jobs_exception_msg_tv);
- final TextView mKnownTextView = (TextView) switchView.findViewById(R.id.pop_switch_jobs_exception_confirm_tv);
- mOperationLinearLayout.setVisibility(View.VISIBLE);
- mExceptionLinearLayout.setVisibility(View.GONE);
- outputEditText.requestFocus();
- outputEditText.setText(dl_madeqty + "");
- outputEditText.setSelection(outputEditText.getText().toString().trim().length());
- cleanIv.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- jobsEditText.setText("");
- }
- });
- mKnownTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mExceptionLinearLayout.setVisibility(View.GONE);
- mExceptionTextView.setText("");
- }
- });
- jobsEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- if (!orderCheckBox.isChecked()) {
- if (s.length() >= 3) {
- if (!s.toString().matches(Constants.REGEX.NO_SYMBOL)) {
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.note_number_cannot_contain_special));
- jobsEditText.setText(null);
- jobsEditText.requestFocus();
- } else {
- fuzzySearch(jobsEditText, MACODE_FUZZY);
- }
- }
- } else {
- if (s.length() >= 3) {
- if (!s.toString().matches(Constants.REGEX.NO_SYMBOL)) {
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.product_code_cannot_contain_special));
- jobsEditText.setText(null);
- jobsEditText.requestFocus();
- } else {
- fuzzySearch(jobsEditText, PRODCODE_FUZZY);
- }
- }
- }
- }
- @Override
- public void afterTextChanged(Editable s) {
- if (s == null || s.length() == 0) {
- mConfirmTextView.setEnabled(false);
- cleanIv.setVisibility(View.GONE);
- } else {
- mConfirmTextView.setEnabled(true);
- cleanIv.setVisibility(View.VISIBLE);
- }
- }
- });
- orderCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (!isChecked) {
- jobsEditText.setHint("请输入新工单号");
- mAutoStringAdapter = new MyArrayAdapter<String>(mActivity, android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
- jobsEditText.setAdapter(mAutoStringAdapter);
- } else {
- jobsEditText.setHint("请输入产品代码");
- mAutoStringAdapter = new MyArrayAdapter<String>(mActivity, android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
- jobsEditText.setAdapter(mAutoStringAdapter);
- }
- }
- });
- mConfirmTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- final String linecode = mLineInfoBean.getDL_LINECODE();
- final String jobs = jobsEditText.getText().toString().trim();
- String outputStr = outputEditText.getText().toString().trim();
- String table = "A";
- if (!TextUtils.isEmpty(jobs)) {
- if (mARadioButton.isChecked()) {
- table = "A";
- } else if (mBRadioButton.isChecked()) {
- table = "B";
- }
- if (jobs.equals(mLineInfoBean.getDL_MACODE()) && table.equals(mLineInfoBean.getDL_TABLE())) {
- if (!orderCheckBox.isChecked()) {
- CommonUtil.toastNoRepeat(mActivity, "无法切换至相同的工单号+板面!");
- } else {
- CommonUtil.toastNoRepeat(mActivity, "无法切换至相同的产品代码+板面!");
- }
- CommonUtil.makeNotice();
- } else {
- try {
- if (TextUtils.isEmpty(outputStr)) {
- CommonUtil.toastNoRepeat(mActivity, "请输入原工单产出数");
- } else {
- int quantity = (int) Long.parseLong(outputStr);
- if (quantity >= dl_madeqty && quantity <= ma_qty) {
- switchJobs(linecode, jobs, table, jobsEditText, outputEditText, switchDialog, orderCheckBox.isChecked(), mExceptionLinearLayout, mExceptionTextView);
- } else {
- CommonUtil.toastNoRepeat(mActivity, "数量必须介于产出数和工单数之间");
- CommonUtil.makeNotice();
- }
- }
- } catch (Exception e) {
- outputEditText.setText(dl_madeqty + "");
- outputEditText.setSelection(outputEditText.getText().toString().trim().length());
- CommonUtil.toastNoRepeat(mActivity, "产出数应为正整数");
- CommonUtil.makeNotice();
- }
- }
- }
- }
- });
- mCancelTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // closeSwitchPopupWindow();
- switchDialog.dismiss();
- }
- });
- switchDialog.show();
- // mSwitchPopupWindow = new PopupWindow(switchView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
- // mSwitchPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- // @Override
- // public void onDismiss() {
- // closeSwitchPopupWindow();
- // }
- // });
- // CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
- // mSwitchPopupWindow.showAtLocation(mActivity.getWindow().getDecorView(), Gravity.CENTER, 0, -100);
- CommonUtil.openKeybord(outputEditText, mActivity);
- }
- /**
- * 模糊查询
- *
- * @param jobsEditText
- * @param fuzzy
- */
- private void fuzzySearch(final AutoCompleteTextView jobsEditText, final int fuzzy) {
- String url = null;
- try {
- if (fuzzy == MACODE_FUZZY)
- url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH
- + "?inoutNo=" + URLEncoder.encode(jobsEditText.getText().toString().toLowerCase(), "utf-8");
- else if (fuzzy == PRODCODE_FUZZY)
- url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH_PRODUCT
- + "?pr_code=" + URLEncoder.encode(jobsEditText.getText().toString().toLowerCase(), "utf-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- if (fuzzy == MACODE_FUZZY)
- url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH
- + "?inoutNo=" + jobsEditText.getText().toString().toLowerCase();
- else
- url = GloableParams.ADDRESS_SMT_FUZZY_SEARCH_PRODUCT
- + "?pr_code=" + jobsEditText.getText().toString().toLowerCase();
- }
- PdaApplication.mRequestQueue.cancelAll(TAG + "fuzzysearch");
- mStringRequest = new StringRequest(Request.Method.GET, url,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- Log.e("autoStrings", s);
- List<String> mAutoStrings = new ArrayList<String>();
- try {
- mAutoStrings.clear();
- mAutoStringAdapter = new MyArrayAdapter<String>(mActivity, android.R.layout.simple_dropdown_item_1line, mAutoStrings);
- if (jobsEditText != null) {
- jobsEditText.setAdapter(mAutoStringAdapter);
- }
- JSONObject resultObject = new JSONObject(s);
- JSONArray dataArray = resultObject.optJSONArray("data");
- if (dataArray != null) {
- for (int i = 0; i < dataArray.length(); i++) {
- JSONObject dataObject = dataArray.optJSONObject(i);
- if (dataObject != null) {
- String pi_inoutno = JsonUtils.optStringNotNull(dataObject, fuzzy == MACODE_FUZZY ? "MA_CODE" : "PR_CODE");
- if (!TextUtils.isEmpty(pi_inoutno))
- mAutoStringAdapter.add(pi_inoutno);
- }
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- CommonUtil.showErrorToast(volleyError);
- jobsEditText.setText("");
- jobsEditText.requestFocus();
- CommonUtil.openKeybord(jobsEditText, mActivity);
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- };
- mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- mStringRequest.setTag(TAG + "fuzzysearch");
- PdaApplication.mRequestQueue.add(mStringRequest);
- }
- /**
- * 切换工单
- *
- * @param linecode 线别
- * @param jobs 工单
- * @param table 板面
- * @param jobsEditText 工单输入框
- * @param outputEditText
- * @param switchDialog 弹出框
- * @param checked 是否被选中
- * @param mExceptionLinearLayout
- * @param mExceptionTextView
- */
- private void switchJobs(final String linecode, final String jobs, String table, final AutoCompleteTextView jobsEditText, final ClearableEditText outputEditText, final AlertDialog switchDialog, final boolean checked, final LinearLayout mExceptionLinearLayout, final TextView mExceptionTextView) {
- progressDialog.show();
- PdaApplication.mRequestQueue.cancelAll(TAG + "change");
- final String finalTable = table;
- mStringRequest = new StringRequest(Request.Method.POST, GloableParams.ADDRESS_SMT_CHANGE_MAKE,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- switchDialog.dismiss();
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- try {
- Log.d("result", s);
- JSONObject resultObject = new JSONObject(s);
- if (resultObject.optBoolean("success")) {
- JSONObject dataObject = resultObject.optJSONObject("data");
- if (dataObject != null) {
- JSONObject devicelineObject = dataObject.optJSONObject("deviceline");
- if (devicelineObject != null) {
- mLineInfoBean = new LineInfoBean();
- mLineInfoBean.setDL_ID(JsonUtils.optLongNotNull(devicelineObject, "DL_ID"));
- mLineInfoBean.setDL_DECODE(JsonUtils.optStringNull(devicelineObject, "DL_DECODE"));
- mLineInfoBean.setDL_LINECODE(JsonUtils.optStringNull(devicelineObject, "DL_LINECODE"));
- mLineInfoBean.setDL_MACODE(JsonUtils.optStringNull(devicelineObject, "DL_MACODE"));
- mLineInfoBean.setDL_TABLE(JsonUtils.optStringNull(devicelineObject, "DL_TABLE"));
- mLineInfoBean.setDL_STATUSCODE(JsonUtils.optStringNull(devicelineObject, "DL_STATUSCODE"));
- mLineInfoBean.setDL_STATUS(JsonUtils.optStringNull(devicelineObject, "DL_STATUS"));
- mLineInfoBean.setPS_ID(JsonUtils.optLongNotNull(devicelineObject, "PS_ID"));
- mLineInfoBean.setMA_ID(JsonUtils.optLongNotNull(devicelineObject, "MA_ID"));
- mLineInfoBean.setDL_PRODCODE(JsonUtils.optStringNotNull(devicelineObject, "DL_PRODCODE"));
- PdaApplication.putDataCache2Map(Constants.FLAG.SMT_DEVICE_LINE_CACHE, mLineInfoBean);
- CommonUtil.toastNoRepeat(mActivity, "工单切换成功!");
- mDecodeTextView.setText(mLineInfoBean.getDL_DECODE());
- mStatusTextView.setText(mLineInfoBean.getDL_STATUS());
- mLinecodeTextView.setText(mLineInfoBean.getDL_LINECODE());
- mTableTextView.setText(mLineInfoBean.getDL_TABLE() + "面");
- mMacodeTextView.setText(mLineInfoBean.getDL_MACODE());
- mProdcodeTextView.setText(mLineInfoBean.getDL_PRODCODE());
- }
- String smtLocation = dataObject.optString("smtlocation");
- Log.d("smtLocation", smtLocation);
- if (!TextUtils.isEmpty(smtLocation))
- SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, smtLocation);
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- String errorToast = CommonUtil.showErrorToast(volleyError, false);
- mExceptionLinearLayout.setVisibility(View.VISIBLE);
- mExceptionTextView.setText(errorToast);
- jobsEditText.setText("");
- outputEditText.setText(dl_madeqty + "");
- outputEditText.setSelection(outputEditText.getText().toString().trim().length());
- outputEditText.requestFocus();
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- Map<String, String> params = new HashMap<String, String>();
- params.put("dl_linecode", linecode);
- params.put("ma_code", jobs);
- params.put("table", finalTable);
- params.put("dl_actmadeqty", outputEditText.getText().toString().trim());
- params.put("has_noma", checked + "");
- return params;
- }
- };
- mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- mStringRequest.setTag(TAG + "change");
- PdaApplication.mRequestQueue.add(mStringRequest);
- }
- private void closeMachinePopupWindow() {
- if (mMachinePopupWindow != null) {
- mMachinePopupWindow.dismiss();
- CommonUtil.setBackgroundAlpha(mActivity, 1f);
- }
- }
- private void closeSwitchPopupWindow() {
- if (mSwitchPopupWindow != null) {
- mSwitchPopupWindow.dismiss();
- CommonUtil.setBackgroundAlpha(mActivity, 1f);
- }
- }
- private void closeDownAllPopupWindow() {
- if (mDownAllPopupWindow != null) {
- mDownAllPopupWindow.dismiss();
- CommonUtil.setBackgroundAlpha(mActivity, 1f);
- }
- }
- private void closePasswordPopupWindow() {
- if (mPasswordPopupWindow != null) {
- mPasswordPopupWindow.dismiss();
- CommonUtil.setBackgroundAlpha(mActivity, 1f);
- }
- }
- /*=============================全部下料=========================================*/
- //全部下料对话框
- /**
- * 弹出全部下料对话框
- */
- private void showConfirmAllDownDialog() {
- final ClearableEditText quantityEditText = (ClearableEditText) downAllView.findViewById(R.id.pop_smt_down_all_et);
- CheckBox unbindCheckBox = downAllView.findViewById(R.id.pop_smt_down_unbind_cb);
- unbindCheckBox.setChecked(true);
- final TextView mConfirmTextView = (TextView) downAllView.findViewById(R.id.pop_smt_down_all_confirm_tv);
- TextView mCancelTextView = (TextView) downAllView.findViewById(R.id.pop_smt_down_all_cancel_tv);
- quantityEditText.setText(dl_madeqty + "");
- quantityEditText.setSelection(quantityEditText.getText().toString().trim().length());
- mConfirmTextView.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
- @Override
- public void afterTextChanged(Editable s) {
- if (s == null || s.length() == 0) {
- mConfirmTextView.setEnabled(false);
- } else {
- mConfirmTextView.setEnabled(true);
- }
- }
- });
- mConfirmTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String quantityStr = quantityEditText.getText().toString().trim();
- try {
- int quantity = (int) Long.parseLong(quantityStr);
- if (quantity >= dl_madeqty && quantity <= ma_qty) {
- disposeAllDown(quantity, unbindCheckBox.isChecked());
- } else {
- CommonUtil.toastNoRepeat(mActivity, "数量必须介于产出数和工单数之间");
- CommonUtil.makeNotice();
- }
- } catch (Exception e) {
- quantityEditText.setText(dl_madeqty + "");
- quantityEditText.setSelection(quantityEditText.getText().toString().trim().length());
- CommonUtil.toastNoRepeat(mActivity, "产出数应为正整数");
- CommonUtil.makeNotice();
- }
- }
- });
- mCancelTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // closeDownAllPopupWindow();
- switchDialog.dismiss();
- }
- });
- switchDialog.show();
- //
- // mDownAllPopupWindow = new PopupWindow(downAllView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
- //
- // mDownAllPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- // @Override
- // public void onDismiss() {
- // closeDownAllPopupWindow();
- // }
- // });
- // CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
- // mDownAllPopupWindow.showAtLocation(mActivity.getWindow().getDecorView(), Gravity.CENTER, 0, -100);
- CommonUtil.openKeybord(quantityEditText, mActivity);
- }
- //全部下料
- private void disposeAllDown(int quantity, boolean unbind) {
- showLoadingView();
- VolleyUtil.getVolleyUtil().requestSMTAllDown(getActivity(),
- GloableParams.ADDRESS_SMT_CUTTING_ALLSTOCK,
- VolleyUtil.METHOD_POST,
- VolleyUtil.FRAGMENT_SCMAKE_SMTALLDOWN,
- mLineInfoBean.getDL_MACODE(),
- mLineInfoBean.getDL_LINECODE(),
- quantity,
- unbind);
- }
- /*======================ConfirmDialog==========================================*/
- ConfirmDialog confirmDialog;
- boolean isOk = false;
- //关闭确认对话框
- public void closeConfirmDialog() {
- confirmDialog.dismiss();
- }
- /*============================Volley Handler=========================================*/
- Handler volleyHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- // closeDownAllPopupWindow();
- switchDialog.dismiss();
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- String noticeMsg = (String) msg.obj;
- CommonUtil.toastNoRepeat(mActivity, noticeMsg);
- if (msg.what == VolleyUtil.SUCCESS_SUCCESS) {
- SharedPreUtil.saveString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, "");
- getActivity().getSupportFragmentManager().popBackStack();
- }
- }
- };
- /*============================公用方法=========================================*/
- /**
- * @注释:显示错误提示
- */
- ConfirmDialog noticeDialog;
- private void showNotice(String noticeMsg) {
- noticeDialog = new ConfirmDialog(getActivity());
- noticeDialog.show(noticeMsg, ConfirmDialog.NOTICE);
- new AsyncTask<String, Void, Float>() {
- @Override
- protected Float doInBackground(String... params) {
- try {
- //notice显示1.5s
- Thread.sleep(1500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return null;
- }
- @Override
- protected void onPostExecute(Float aFloat) {
- //notice退出
- //noticeTextView.startAnimation(noticeOut);
- // noticeTextView.setVisibility(View.GONE);
- noticeDialog.dismiss();
- }
- }.execute();
- }
- /**
- * 显示loadingView
- */
- private void showLoadingView() {
- if (!progressDialog.isShowing()) {
- progressDialog.show();
- }
- }
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- Log.e("SMTINDEX", "onKeyDown");
- if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
- if (progressDialog != null && progressDialog.isShowing()) {
- // loadingView.dismiss();
- // VolleyUtil.distoryVolley();
- return true;
- }
- if (confirmDialog != null && confirmDialog.isShowing()) {
- Log.e("SMTINDEX", "confirmDialog");
- closeConfirmDialog();
- return true;
- }
- if (noticeDialog != null && noticeDialog.isShowing()) {
- noticeDialog.dismiss();
- return true;
- }
- }
- return false;
- }
- @Override
- public boolean onFragmentBackPressed() {
- return false;
- }
- }
|