|
|
@@ -0,0 +1,3097 @@
|
|
|
+package com.uas.jc_wms.fragment;
|
|
|
+
|
|
|
+
|
|
|
+import android.app.Activity;
|
|
|
+import android.content.ComponentName;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+import android.net.Uri;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
+import android.support.v7.app.AlertDialog;
|
|
|
+import android.support.v7.widget.DividerItemDecoration;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+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.view.ViewGroup;
|
|
|
+import android.view.Window;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.ArrayAdapter;
|
|
|
+import android.widget.BaseAdapter;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.EditText;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.ListView;
|
|
|
+import android.widget.PopupWindow;
|
|
|
+import android.widget.RadioButton;
|
|
|
+import android.widget.RadioGroup;
|
|
|
+import android.widget.Spinner;
|
|
|
+import android.widget.TableLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.android.volley.AuthFailureError;
|
|
|
+import com.android.volley.DefaultRetryPolicy;
|
|
|
+import com.android.volley.NetworkResponse;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.android.volley.Response;
|
|
|
+import com.android.volley.VolleyError;
|
|
|
+import com.android.volley.toolbox.HttpHeaderParser;
|
|
|
+import com.android.volley.toolbox.JsonObjectRequest;
|
|
|
+import com.android.volley.toolbox.StringRequest;
|
|
|
+import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
+import com.chad.library.adapter.base.BaseViewHolder;
|
|
|
+import com.uas.jc_wms.R;
|
|
|
+import com.uas.jc_wms.activity.FunctionActivity;
|
|
|
+import com.uas.jc_wms.application.PdaApplication;
|
|
|
+import com.uas.jc_wms.bean.ErrorMsg;
|
|
|
+import com.uas.jc_wms.bean.IOCOutMakeMaterialOperMsd;
|
|
|
+import com.uas.jc_wms.bean.IOCOutmakeMaterialSplitBean;
|
|
|
+import com.uas.jc_wms.bean.MaterialInformationBean;
|
|
|
+import com.uas.jc_wms.bean.SubmitNotParam;
|
|
|
+import com.uas.jc_wms.bean.WHBreakingBatchBreakingBtnClickEventNew;
|
|
|
+import com.uas.jc_wms.database.DBManager;
|
|
|
+import com.uas.jc_wms.global.GloableParams;
|
|
|
+import com.uas.jc_wms.table.TableLBARCODEIO;
|
|
|
+import com.uas.jc_wms.table.TableLPRODIONEEDGET;
|
|
|
+import com.uas.jc_wms.tools.SharedPreUtil;
|
|
|
+import com.uas.jc_wms.tools.VolleyUtil;
|
|
|
+import com.uas.jc_wms.util.CameraUtil;
|
|
|
+import com.uas.jc_wms.util.CommonUtil;
|
|
|
+import com.uas.jc_wms.util.Constants;
|
|
|
+import com.uas.jc_wms.util.FastjsonUtil;
|
|
|
+import com.uas.jc_wms.util.FileUtils;
|
|
|
+import com.uas.jc_wms.util.FragmentUtils;
|
|
|
+import com.uas.jc_wms.util.HttpCallback;
|
|
|
+import com.uas.jc_wms.util.HttpParams;
|
|
|
+import com.uas.jc_wms.util.JsonTools;
|
|
|
+import com.uas.jc_wms.util.JsonUtils;
|
|
|
+import com.uas.jc_wms.util.LogUtil;
|
|
|
+import com.uas.jc_wms.util.PrintUtils;
|
|
|
+import com.uas.jc_wms.util.StringUtil;
|
|
|
+import com.uas.jc_wms.util.VolleyRequest;
|
|
|
+import com.uas.jc_wms.util.VollyRequest;
|
|
|
+import com.uas.jc_wms.view.ClearableEditText;
|
|
|
+import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
+import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
+
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
+import razerdp.basepopup.BasePopupWindow;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by RaoMeng on 2016/7/27.
|
|
|
+ * 材料出库采集页面
|
|
|
+ */
|
|
|
+public class IOCOutMakeMaterialOperNew extends BaseFragment implements View.OnClickListener, RadioGroup.OnCheckedChangeListener, HttpCallback {
|
|
|
+ private static final int SCAN_BARCODE_CODE = 103;
|
|
|
+ private static final int SPLIT_BARCODE_SUCCESS = 104;
|
|
|
+ private static final int SPLIT_BARCODE_FAIL = 105;
|
|
|
+ private static final int FLAG_CONFIRM_POST = 0x05;
|
|
|
+ private static final int BarcodeSplitting = 0x06; //按条码拆分
|
|
|
+
|
|
|
+ private ImageView mScanImageView;
|
|
|
+
|
|
|
+ private JsonObjectRequest jsonRequest;
|
|
|
+ private static final String TAG = "IOCOutMakeMaterialOper";
|
|
|
+ private Button btnActionbarWithback, btnActionbarRight;
|
|
|
+ private String pi_inoutno;
|
|
|
+ private String pd_whcode;
|
|
|
+ private String pi_id;
|
|
|
+ private boolean isMultiple;
|
|
|
+ private Fragment mFragment;
|
|
|
+ private String mCollectType;
|
|
|
+
|
|
|
+ private PopupWindow listPopupWindow;
|
|
|
+ private StringRequest stringRequestPost;
|
|
|
+ private String mProdOutType;
|
|
|
+ private List<WHBreakingBatchBreakingBtnClickEventNew.DataBean> messages = new ArrayList<>();
|
|
|
+
|
|
|
+ private int mCollectModel = 1;//采集模式:1代表在线,0代表离线
|
|
|
+ private String mBarRemain, mRestqty;
|
|
|
+ private String mResult1, mResult2, mResult3, mResult4;
|
|
|
+ private List<String> mResults;
|
|
|
+
|
|
|
+ private TextWatcher watcher = new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable editable) {
|
|
|
+ if (editable.length() == 0) {
|
|
|
+ btnConfirm.setEnabled(false);
|
|
|
+ } else {
|
|
|
+ btnConfirm.setEnabled(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ private StringRequest stringRequest;
|
|
|
+ private PopupWindow splitPop;
|
|
|
+ private String strPrintDataList;
|
|
|
+ private StringRequest stringRequestSplit;
|
|
|
+ private DBManager mDbManager;
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private ArrayAdapter mTypeSpAdapter;
|
|
|
+ private ArrayList<String> mCollectTypes;
|
|
|
+ private String mPrintUrl = "";
|
|
|
+ private Handler mHandler = new Handler() {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ super.handleMessage(msg);
|
|
|
+ switch (msg.what) {
|
|
|
+ case Constants.CONSTANT.PRINT_SUCCESS:
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ Toast.makeText(mActivity, R.string.obtain_print_file_success, Toast.LENGTH_LONG).show();
|
|
|
+ try {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ ComponentName comp = new ComponentName("com.dynamixsoftware.printershare", "com.dynamixsoftware.printershare.ActivityPrintPDF");
|
|
|
+ intent = new Intent();
|
|
|
+ intent.setComponent(comp);
|
|
|
+ intent.setAction("android.intent.action.VIEW");
|
|
|
+ intent.setType("application/pdf");
|
|
|
+ intent.setData(Uri.fromFile(new File(Constants.CONSTANT.PRINT_FILE_PATH, Constants.CONSTANT.PRINT_FILE_NAME)));
|
|
|
+ startActivity(intent);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Toast.makeText(mActivity, "打印失败", Toast.LENGTH_LONG).show();
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Constants.CONSTANT.PRINT_FAILED:
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Toast.makeText(mActivity, R.string.obtain_print_file_failed, Toast.LENGTH_LONG).show();
|
|
|
+ break;
|
|
|
+ case Constants.CONSTANT.PRINT_OVERLOAD:
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Toast.makeText(mActivity, R.string.obtain_print_file_overload, Toast.LENGTH_LONG).show();
|
|
|
+ break;
|
|
|
+ case SPLIT_BARCODE_SUCCESS:
|
|
|
+ String s = (String) msg.obj;
|
|
|
+ if (popupWindow != null && popupWindow.isShowing())
|
|
|
+ closePopupWindow();
|
|
|
+ mResults = new ArrayList<>();
|
|
|
+ mCollectTypeRadioGroup.setEnabled(true);
|
|
|
+ LogUtil.e("breaking", s);
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = new JSONObject(s);
|
|
|
+ JSONObject dataObject = jsonObject.optJSONObject("data");
|
|
|
+ if (dataObject == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject messageObject = dataObject.optJSONObject("barcode");
|
|
|
+ if (messageObject == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (messageObject.has("ISMSD")) {
|
|
|
+ if (messageObject.optBoolean("ISMSD")) {
|
|
|
+ //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
|
|
|
+ iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
|
|
|
+ // Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
|
|
|
+ mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
|
|
|
+ mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
|
|
|
+ showDewPopupWindow();
|
|
|
+ } else {
|
|
|
+ mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
|
|
|
+ mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
|
|
|
+ mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
|
|
|
+ if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
|
|
|
+ spliteBarcode(currentBarcode, mBarRemain, mRestqty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mCollectResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ mCollectResultTextView.setText(null);
|
|
|
+ JSONArray listArray = dataObject.optJSONArray("nolist");
|
|
|
+ if (mCollectType.equals("byBarcode") || mCollectType.equals("byBatchcode")) {
|
|
|
+ String barcodeResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
|
|
|
+ + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
|
|
|
+ + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
|
|
|
+ + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
|
|
|
+ + ";名称规格:" + messageObject.optString("PR_DETAIL")
|
|
|
+ + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
|
|
|
+ + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
|
|
|
+
|
|
|
+ if (listArray != null && listArray.length() > 0) {
|
|
|
+ for (int i = 0; i < listArray.length(); i++) {
|
|
|
+ JSONObject listObject = listArray.optJSONObject(i);
|
|
|
+ barcodeResult = barcodeResult
|
|
|
+ + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
|
|
|
+ + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
|
|
|
+ }
|
|
|
+
|
|
|
+ //弹出拆分结果弹框
|
|
|
+ // initBreakPopupWindow(listArray);
|
|
|
+ }
|
|
|
+
|
|
|
+ mCollectResultTextView.setText(barcodeResult);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBarcodeCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mResult1 = messageObject.optString("BAR_CODE");
|
|
|
+ mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
|
|
|
+ mResult3 = messageObject.optString("BAR_PRODCODE");
|
|
|
+
|
|
|
+ mResults.add(mResult1);
|
|
|
+ mResults.add(mResult2);
|
|
|
+ mResults.add(mResult3);
|
|
|
+
|
|
|
+ mCollectBarcodeTv.setText(mResult1);
|
|
|
+ mCollectBarRemainTv.setText(mResult2);
|
|
|
+ mCollectBarProdcodeTv.setText(mResult3);
|
|
|
+
|
|
|
+ PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
|
|
|
+ } else if (false) {
|
|
|
+ String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
|
|
|
+ + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
|
|
|
+ + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
|
|
|
+ + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
|
|
|
+ + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
|
|
|
+ + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
|
|
|
+
|
|
|
+
|
|
|
+ if (listArray != null && listArray.length() > 0) {
|
|
|
+ for (int i = 0; i < listArray.length(); i++) {
|
|
|
+ JSONObject listObject = listArray.optJSONObject(i);
|
|
|
+ boxResult = boxResult
|
|
|
+ + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
|
|
|
+ + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mCollectResultTextView.setText(boxResult);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBoxCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mResult1 = messageObject.optString("PA_OUTBOXCODE");
|
|
|
+ mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
|
|
|
+ mResult3 = messageObject.optString("PA_PRODCODE");
|
|
|
+ mResult4 = messageObject.optString("PA_WHCODE");
|
|
|
+
|
|
|
+ mResults.add(mResult1);
|
|
|
+ mResults.add(mResult2);
|
|
|
+ mResults.add(mResult3);
|
|
|
+ mResults.add(mResult4);
|
|
|
+
|
|
|
+ mCollectBoxTv.setText(mResult1);
|
|
|
+ mCollectBoxNumTv.setText(mResult2);
|
|
|
+ mCollectBoxrProdcodeTv.setText(mResult3);
|
|
|
+ mCollectBoxWhcodeTv.setText(mResult4);
|
|
|
+
|
|
|
+ PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
|
|
|
+ }
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "采集成功");
|
|
|
+
|
|
|
+ Object next = jsonObject.getJSONObject("data").get("next");
|
|
|
+ if (next != null && !"null".equals(next.toString())) {
|
|
|
+ JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
|
|
|
+ MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
|
|
|
+ if (materialInformationBean != null) {
|
|
|
+ String materialInfo =
|
|
|
+ "型号:" + (materialInformationBean.getPR_ORISPECCODE() == null ? "" : materialInformationBean.getPR_ORISPECCODE())
|
|
|
+ + "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
|
|
|
+ + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
|
|
|
+ + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
|
|
|
+ + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
|
|
|
+ + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
|
|
|
+ + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
|
|
|
+ if (materialInformationBean.getPD_BATCHCODE() != null) {
|
|
|
+ materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
|
|
|
+ }
|
|
|
+ mMaterialInforTextView.setText(materialInfo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mMaterialInforTextView.setText("该出库单已经完成备料");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SPLIT_BARCODE_FAIL:
|
|
|
+ s = (String) msg.obj;
|
|
|
+ String errorStr = "请求失败";
|
|
|
+ if (JsonUtils.validate(s)) {
|
|
|
+ try {
|
|
|
+ JSONObject errorObject = new JSONObject(s);
|
|
|
+ String exceptionInfo = JsonUtils.optStringNotNull(errorObject, "exceptionInfo");
|
|
|
+ if (TextUtils.isEmpty(exceptionInfo)) {
|
|
|
+ errorStr = "系统错误";
|
|
|
+ } else {
|
|
|
+ errorStr = exceptionInfo;
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (getActivity() != null) {
|
|
|
+ try {
|
|
|
+ etBarCode.setText(null);
|
|
|
+ CommonUtil.editTextGetFocus(etBarCode);
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), errorStr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ private okhttp3.Request mRequest;
|
|
|
+ private OkHttpClient mOkHttpClient;
|
|
|
+ private int mFocusId;
|
|
|
+ private String currentBarcode;
|
|
|
+ private boolean isConnected = false;
|
|
|
+ private String mOldAddress = "";
|
|
|
+ private int mPrintDpi = 203;
|
|
|
+ private boolean isPrinting = false;
|
|
|
+ private TextView tvPiInoutno;
|
|
|
+ private TextView tvPdWhcode;
|
|
|
+ private ClearableEditText etBarCode;
|
|
|
+ private Button btnConfirm;
|
|
|
+ private RadioGroup mCollectTypeRadioGroup;
|
|
|
+ private RadioButton mBarcodeRadioButton;
|
|
|
+ private RadioButton mBoxRadioButton;
|
|
|
+ private TableLayout mBarcodeTableLayout;
|
|
|
+ private TableLayout mBoxTableLayout;
|
|
|
+ private TextView tvBarcodeCollectionSuccess;
|
|
|
+ private TextView mCollectBarcodeTv;
|
|
|
+ private TextView mCollectBarRemainTv;
|
|
|
+ private TextView mCollectBarProdcodeTv;
|
|
|
+ private TextView tvBoxCollectionSuccess;
|
|
|
+ private TextView mCollectBoxTv;
|
|
|
+ private TextView mCollectBoxNumTv;
|
|
|
+ private TextView mCollectBoxrProdcodeTv;
|
|
|
+ private TextView mCollectBoxWhcodeTv;
|
|
|
+ private Button mCollectModelBtn;
|
|
|
+ private TextView mtypeNameTv;
|
|
|
+ private Spinner mTypeSpinner;
|
|
|
+ private TextView mMaterialInforTextView;
|
|
|
+ private TextView mCollectResultTextView;
|
|
|
+ private Button btn_oneprint;
|
|
|
+ private com.alibaba.fastjson.JSONArray listArray;
|
|
|
+
|
|
|
+ private RecyclerView rv_line_ip_port_data;
|
|
|
+ private IpAndResourcesPortAdapter ipAndResourcesPortAdapter;
|
|
|
+ private ArrayList<ComDataBean> ComDataBeanList;
|
|
|
+ private PopupWindow editPW;
|
|
|
+ private ClearableEditText edit_et;
|
|
|
+ private String sc_name, sc_code;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_iocout_make_material_oper;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(getString(R.string.out_material_collect));
|
|
|
+ // ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterialOper();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
|
|
|
+ ((FunctionActivity) getActivity()).setScanIvVisible(true);
|
|
|
+
|
|
|
+ ComDataBeanList = new ArrayList<>();
|
|
|
+
|
|
|
+ mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
|
|
|
+ tvPiInoutno = mActivity.findViewById(R.id.tv_pi_inoutno);
|
|
|
+ tvPdWhcode = mActivity.findViewById(R.id.tv_pd_whcode);
|
|
|
+ etBarCode = mActivity.findViewById(R.id.et_bar_code);
|
|
|
+ btnConfirm = mActivity.findViewById(R.id.btn_confirm);
|
|
|
+
|
|
|
+ mCollectTypeRadioGroup = mActivity.findViewById(R.id.iocout_collect_rg);
|
|
|
+ mBarcodeRadioButton = mActivity.findViewById(R.id.iocout_collect_barcode_rb);
|
|
|
+ mBoxRadioButton = mActivity.findViewById(R.id.iocout_collect_box_rb);
|
|
|
+ mBarcodeTableLayout = mActivity.findViewById(R.id.iocout_collect_barcode_tl);
|
|
|
+ mBoxTableLayout = mActivity.findViewById(R.id.iocout_collect_box_tl);
|
|
|
+
|
|
|
+ tvBarcodeCollectionSuccess = mActivity.findViewById(R.id.tv_barcode_collection_success);
|
|
|
+ mCollectBarcodeTv = mActivity.findViewById(R.id.iocout_bar_code_tv);
|
|
|
+ mCollectBarRemainTv = mActivity.findViewById(R.id.iocout_bar_remain_tv);
|
|
|
+ mCollectBarProdcodeTv = mActivity.findViewById(R.id.iocout_bar_prodcode_tv);
|
|
|
+ tvBoxCollectionSuccess = mActivity.findViewById(R.id.tv_box_collection_success);
|
|
|
+ mCollectBoxTv = mActivity.findViewById(R.id.iocout_box_tv);
|
|
|
+ mCollectBoxNumTv = mActivity.findViewById(R.id.iocout_box_num_tv);
|
|
|
+ mCollectBoxrProdcodeTv = mActivity.findViewById(R.id.iocout_box_prodcode_tv);
|
|
|
+ mCollectBoxWhcodeTv = mActivity.findViewById(R.id.iocout_box_whcode_tv);
|
|
|
+ mCollectModelBtn = mActivity.findViewById(R.id.iocout_collect_model_btn);
|
|
|
+ mtypeNameTv = mActivity.findViewById(R.id.iocout_material_type_tv);
|
|
|
+ mTypeSpinner = mActivity.findViewById(R.id.iocout_material_type_sp);
|
|
|
+ mMaterialInforTextView = mActivity.findViewById(R.id.iocout_next_material_information);
|
|
|
+ mCollectResultTextView = mActivity.findViewById(R.id.iocout_collect_result);
|
|
|
+ btn_oneprint = root.findViewById(R.id.btn_oneprint);
|
|
|
+
|
|
|
+ mDbManager = new DBManager(getActivity().getApplicationContext());
|
|
|
+ mOkHttpClient = new OkHttpClient.Builder()
|
|
|
+ .sslSocketFactory(FileUtils.createSSLSocketFactory(), new FileUtils.TrustAllCerts())
|
|
|
+ .hostnameVerifier(new FileUtils.TrustAllHostnameVerifier())
|
|
|
+ .connectTimeout(30, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(30, TimeUnit.SECONDS).build();
|
|
|
+
|
|
|
+ mProdOutType = SharedPreUtil.getString(getActivity().getApplicationContext(), Constants.FLAG.PRODOUT_TYPE_CACHE, "byBatch");
|
|
|
+ //获取上一个Fragment(即IOCOutMakeMaterial里面的数据)
|
|
|
+ Bundle bundle = getArguments();
|
|
|
+ if (bundle != null) {
|
|
|
+ pi_inoutno = bundle.getString("pi_inoutno");
|
|
|
+ pd_whcode = bundle.getString("pd_whcode") == null ? "" : bundle.getString("pd_whcode");
|
|
|
+ pi_id = bundle.getString("pi_id");
|
|
|
+ isMultiple = bundle.getBoolean("isMultiple");
|
|
|
+ }
|
|
|
+
|
|
|
+ mResults = new ArrayList<>();
|
|
|
+ if (mCollectModel == 1) {
|
|
|
+ mCollectModelBtn.setText("在线");
|
|
|
+ } else if (mCollectModel == 0) {
|
|
|
+ mCollectModelBtn.setText("离线");
|
|
|
+ }
|
|
|
+
|
|
|
+ //条码输入框获取焦点
|
|
|
+ etBarCode.requestFocus();
|
|
|
+
|
|
|
+ tvPiInoutno.setText(pi_inoutno);
|
|
|
+ tvPdWhcode.setText(pd_whcode);
|
|
|
+
|
|
|
+ mCollectTypes = new ArrayList<>();
|
|
|
+ mCollectTypes.add("条码号");
|
|
|
+ mCollectTypes.add("外箱号");
|
|
|
+
|
|
|
+ mTypeSpAdapter = new ArrayAdapter<>(getActivity(), R.layout.layout_myspinner, mCollectTypes);
|
|
|
+ mTypeSpAdapter.setDropDownViewResource(R.layout.layout_myspinner_dropdown);
|
|
|
+ mTypeSpinner.setAdapter(mTypeSpAdapter);
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+ mCollectType = SharedPreUtil.getString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBarcode");
|
|
|
+
|
|
|
+ if (mCollectType != null) {
|
|
|
+ //取消箱号采集
|
|
|
+ if (mCollectType.equals("byBarcode")) {
|
|
|
+ mCollectType = "byBarcode";
|
|
|
+ CommonUtil.setSpinnerItemSelectedByValue(mTypeSpinner, "条码号");
|
|
|
+ etBarCode.setHint(R.string.please_collect_barcode);
|
|
|
+ mtypeNameTv.setText("条码");
|
|
|
+ } else if (mCollectType.equals("byBatchcode")) {
|
|
|
+ CommonUtil.setSpinnerItemSelectedByValue(mTypeSpinner, "箱号");
|
|
|
+ etBarCode.setHint("请采集箱号");
|
|
|
+ mtypeNameTv.setText("箱号");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ btnActionbarRight = (Button) getActivity().findViewById(R.id.btn_actionbar_more);
|
|
|
+
|
|
|
+ isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
|
|
|
+ mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
|
|
|
+ mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ btnActionbarRight.setOnClickListener(this);
|
|
|
+ etBarCode.addTextChangedListener(watcher);
|
|
|
+ mCollectTypeRadioGroup.setOnCheckedChangeListener(this);
|
|
|
+ mCollectModelBtn.setOnClickListener(this);
|
|
|
+ mScanImageView.setOnClickListener(this);
|
|
|
+
|
|
|
+ etBarCode.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_SEND
|
|
|
+ || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ confirmEvent();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mtypeNameTv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String typeName = mtypeNameTv.getText().toString().trim();
|
|
|
+ if ("条码".equals(typeName)) {
|
|
|
+ changeToTypeBatch();
|
|
|
+ } else if ("箱号".equals(typeName)) {
|
|
|
+ changeToTypeBarcode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ if (mCollectTypes != null) {
|
|
|
+ if (mCollectTypes.get(position).equals("条码号")) {
|
|
|
+ changeToTypeBarcode();
|
|
|
+ } else if (mCollectTypes.get(position).equals("外箱号")) {
|
|
|
+ changeToTypeBatch();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNothingSelected(AdapterView<?> parent) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ btn_oneprint.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (listArray != null && listArray.size() > 0) {
|
|
|
+ printEvent(listArray);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "数据为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 采集方式切换成箱号
|
|
|
+ */
|
|
|
+ private void changeToTypeBatch() {
|
|
|
+ etBarCode.setHint("请采集箱号");
|
|
|
+ mtypeNameTv.setText("箱号");
|
|
|
+ SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBatchcode");
|
|
|
+ mCollectType = "byBatchcode";
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno);
|
|
|
+
|
|
|
+ if (mResults != null && mResults.size() == 4) {
|
|
|
+ tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBoxCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mCollectBoxTv.setText(mResults.get(0));
|
|
|
+ mCollectBoxNumTv.setText(mResults.get(1));
|
|
|
+ mCollectBoxrProdcodeTv.setText(mResults.get(2));
|
|
|
+ mCollectBoxWhcodeTv.setText(mResults.get(3));
|
|
|
+ } else {
|
|
|
+ tvBoxCollectionSuccess.setVisibility(View.GONE);
|
|
|
+ mCollectBoxTv.setText(null);
|
|
|
+ mCollectBoxNumTv.setText(null);
|
|
|
+ mCollectBoxrProdcodeTv.setText(null);
|
|
|
+ mCollectBoxWhcodeTv.setText(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 采集方式切换成条码号
|
|
|
+ */
|
|
|
+ private void changeToTypeBarcode() {
|
|
|
+ etBarCode.setHint(R.string.please_collect_barcode);
|
|
|
+ mtypeNameTv.setText("条码");
|
|
|
+ SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBarcode");
|
|
|
+ mCollectType = "byBarcode";
|
|
|
+
|
|
|
+ // mBarcodeTableLayout.setVisibility(View.VISIBLE);
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno);
|
|
|
+
|
|
|
+ if (mResults != null && mResults.size() == 3) {
|
|
|
+ tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBarcodeCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mCollectBarcodeTv.setText(mResults.get(0));
|
|
|
+ mCollectBarRemainTv.setText(mResults.get(1));
|
|
|
+ mCollectBarProdcodeTv.setText(mResults.get(2));
|
|
|
+ } else {
|
|
|
+ tvBarcodeCollectionSuccess.setVisibility(View.GONE);
|
|
|
+ mCollectBarcodeTv.setText(null);
|
|
|
+ mCollectBarRemainTv.setText(null);
|
|
|
+ mCollectBarProdcodeTv.setText(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ if (CommonUtil.isNetWorkConnected(mActivity)) {
|
|
|
+ getNextMaterialInfo();
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.net_not_connect));
|
|
|
+ mMaterialInforTextView.setText(getString(R.string.net_not_connect));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取下一采集货品信息
|
|
|
+ */
|
|
|
+ private void getNextMaterialInfo() {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH + "?pi_id=" + pi_id + "&pd_whcode=" + pd_whcode;
|
|
|
+ // if (!isMultiple) {
|
|
|
+ if (false) {
|
|
|
+ if (mProdOutType.equals("byProdcode")) {
|
|
|
+ url = GloableParams.ADDRESS_OUT_GET_NEXT_PRODCODE + "?pi_id=" + pi_id + "&pd_whcode=" + pd_whcode;
|
|
|
+ } else if (mProdOutType.equals("byBatch")) {
|
|
|
+ url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH + "?pi_id=" + pi_id + "&pd_whcode=" + pd_whcode;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH_DEAL + "?ids=" + pi_id;
|
|
|
+ if (mProdOutType.equals("byProdcode")) {
|
|
|
+ url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH_DEAL + "?ids=" + pi_id;
|
|
|
+ } else if (mProdOutType.equals("byBatch")) {
|
|
|
+ url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH_DEAL + "?ids=" + pi_id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "getnext");
|
|
|
+ mStringRequest = new StringRequest(Request.Method.GET, url,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Log.i("materialinfo", s);
|
|
|
+ MaterialInformationBean materialInformationBean = JsonTools.parseJsonToBean(s, MaterialInformationBean.class);
|
|
|
+ if (materialInformationBean != null && materialInformationBean.getData() != null) {
|
|
|
+ String materialInfo =
|
|
|
+ "型号:" + (materialInformationBean.getData().getPR_ORISPECCODE() == null ? "" : materialInformationBean.getData().getPR_ORISPECCODE())
|
|
|
+ + "物料:" + (materialInformationBean.getData().getPD_PRODCODE() == null ? "" : materialInformationBean.getData().getPD_PRODCODE())
|
|
|
+ + "; 名称规格:" + (materialInformationBean.getData().getPR_DETAIL() == null ? "" : materialInformationBean.getData().getPR_DETAIL())
|
|
|
+ + " " + (materialInformationBean.getData().getPR_SPEC() == null ? "" : materialInformationBean.getData().getPR_SPEC())
|
|
|
+ + "; 未备料数:" + (materialInformationBean.getData().getPD_RESTQTY() == null ? "" : materialInformationBean.getData().getPD_RESTQTY())
|
|
|
+ + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getData().getBAR_REMAIN()))
|
|
|
+ + "; 仓位:" + (materialInformationBean.getData().getBAR_LOCATION() == null ? "" : materialInformationBean.getData().getBAR_LOCATION())
|
|
|
+ + "; DC:" + (materialInformationBean.getData().getDC() == null ? "" : materialInformationBean.getData().getDC())
|
|
|
+ + "; 线别仓可用库存:" + (materialInformationBean.getData().getV_RESTQTY() == null ? "" : materialInformationBean.getData().getV_RESTQTY());
|
|
|
+ if (materialInformationBean.getData().getPD_BATCHCODE() != null) {
|
|
|
+ materialInfo = materialInfo + "; 批号:" + materialInformationBean.getData().getPD_BATCHCODE();
|
|
|
+ }
|
|
|
+ if (mMaterialInforTextView != null)
|
|
|
+ mMaterialInforTextView.setText(materialInfo);
|
|
|
+ } else {
|
|
|
+ if (mMaterialInforTextView != null)
|
|
|
+ mMaterialInforTextView.setText("该出库单当前的仓库已经完成备料");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String errorMsg = CommonUtil.showErrorToast(volleyError);
|
|
|
+ if (mMaterialInforTextView != null)
|
|
|
+ mMaterialInforTextView.setText(errorMsg);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "getnext");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 材料出库确认
|
|
|
+ private IOCOutMakeMaterialOperMsd iocOutMakeMaterialOperMsd;
|
|
|
+ // 需要拆分材料
|
|
|
+ private IOCOutmakeMaterialSplitBean mIocoutMaterialSplitBean;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 在线模式确认按钮提交事件
|
|
|
+ */
|
|
|
+ private void barcodeEnterEvent(boolean msdcheck, boolean datecheck) {
|
|
|
+ progressDialog.show();
|
|
|
+ // currentBarcode = etBarCode.getText().toString().trim();
|
|
|
+ String url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
|
|
|
+ + "?barcode=" + currentBarcode
|
|
|
+ + (isMultiple ? "&ids=" : "&ids=")
|
|
|
+ + pi_id + "&whcode=" + pd_whcode
|
|
|
+ + "&type=barcode&msdcheck=" + msdcheck
|
|
|
+ + "&datecheck=" + datecheck;
|
|
|
+ try {
|
|
|
+ if (mProdOutType != null && mCollectType != null) {
|
|
|
+ if (mProdOutType.equals("byProdcode")) {
|
|
|
+ if (mCollectType.equals("byBarcode")) {
|
|
|
+ url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
|
|
|
+ + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
|
|
|
+ + (isMultiple ? "&ids=" : "&ids=")
|
|
|
+ + pi_id + "&whcode=" + pd_whcode
|
|
|
+ + "&type=barcode&msdcheck=" + msdcheck
|
|
|
+ + "&datecheck=" + datecheck;
|
|
|
+
|
|
|
+ } else if (mCollectType.equals("byBatchcode")) {
|
|
|
+ url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
|
|
|
+ + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
|
|
|
+ + (isMultiple ? "&ids=" : "&ids=")
|
|
|
+ + pi_id + "&whcode=" + pd_whcode
|
|
|
+ + "&type=boxcode&msdcheck=" + msdcheck
|
|
|
+ + "&datecheck=" + datecheck;
|
|
|
+ }
|
|
|
+ } else if (mProdOutType.equals("byBatch")) {
|
|
|
+ if (mCollectType.equals("byBarcode")) {
|
|
|
+ url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
|
|
|
+ + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
|
|
|
+ + (isMultiple ? "&ids=" : "&ids=")
|
|
|
+ + pi_id + "&whcode=" + pd_whcode
|
|
|
+ + "&type=barcode&msdcheck=" + msdcheck
|
|
|
+ + "&datecheck=" + datecheck;
|
|
|
+ } else if (mCollectType.equals("byBatchcode")) {
|
|
|
+ url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
|
|
|
+ + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
|
|
|
+ + (isMultiple ? "&ids=" : "&ids=")
|
|
|
+ + pi_id + "&whcode=" + pd_whcode
|
|
|
+ + "&type=boxcode&msdcheck=" + msdcheck
|
|
|
+ + "&datecheck=" + datecheck;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ LogUtil.i("iocouturl", url);
|
|
|
+ etBarCode.setText(null);
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG);
|
|
|
+ mCollectTypeRadioGroup.setEnabled(false);
|
|
|
+ jsonRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(JSONObject jsonObject) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ mResults = new ArrayList<>();
|
|
|
+ mCollectTypeRadioGroup.setEnabled(true);
|
|
|
+ LogUtil.e("!!!ok", jsonObject.toString());
|
|
|
+ try {
|
|
|
+ JSONObject dataObject = jsonObject.optJSONObject("data");
|
|
|
+ if (dataObject == null) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "采集结果获取失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject messageObject = dataObject.getJSONObject("barcode");
|
|
|
+
|
|
|
+ if (messageObject.has("IFOVER") && messageObject.optBoolean("IFOVER")) {
|
|
|
+ new AlertDialog.Builder(mActivity)
|
|
|
+ .setMessage("采集条码[" + messageObject.optString("BAR_CODE") + "]有效期已过,是否继续采集?")
|
|
|
+ .setNegativeButton(R.string.cancel, null)
|
|
|
+ .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
+ dialogInterface.dismiss();
|
|
|
+ barcodeEnterEvent(false, false);
|
|
|
+ }
|
|
|
+ }).create().show();
|
|
|
+ } else if (messageObject.has("ISMSD")) {
|
|
|
+ if (messageObject.optBoolean("ISMSD")) {
|
|
|
+ //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
|
|
|
+ iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
|
|
|
+ if (iocOutMakeMaterialOperMsd != null) {
|
|
|
+ Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
|
|
|
+ mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
|
|
|
+ mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
|
|
|
+ showDewPopupWindow();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
|
|
|
+ mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
|
|
|
+ mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
|
|
|
+ if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
|
|
|
+ spliteBarcode(currentBarcode, mBarRemain, mRestqty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mCollectResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ mCollectResultTextView.setText(null);
|
|
|
+ JSONArray listArray = dataObject.optJSONArray("nolist");
|
|
|
+ if (mCollectType.equals("byBarcode") || mCollectType.equals("byBatchcode")) {
|
|
|
+ String barcodeResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
|
|
|
+ + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
|
|
|
+ + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
|
|
|
+ + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
|
|
|
+ + ";名称规格:" + messageObject.optString("PR_DETAIL")
|
|
|
+ + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
|
|
|
+ + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
|
|
|
+
|
|
|
+ if (listArray != null && listArray.length() > 0) {
|
|
|
+ for (int i = 0; i < listArray.length(); i++) {
|
|
|
+ JSONObject listObject = listArray.optJSONObject(i);
|
|
|
+ barcodeResult = barcodeResult
|
|
|
+ + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
|
|
|
+ + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mCollectResultTextView.setText(barcodeResult);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBarcodeCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mResult1 = messageObject.optString("BAR_CODE");
|
|
|
+ mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
|
|
|
+ mResult3 = messageObject.optString("BAR_PRODCODE");
|
|
|
+
|
|
|
+ mResults.add(mResult1);
|
|
|
+ mResults.add(mResult2);
|
|
|
+ mResults.add(mResult3);
|
|
|
+
|
|
|
+ mCollectBarcodeTv.setText(mResult1);
|
|
|
+ mCollectBarRemainTv.setText(mResult2);
|
|
|
+ mCollectBarProdcodeTv.setText(mResult3);
|
|
|
+
|
|
|
+ PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
|
|
|
+ } else if (false) {
|
|
|
+ String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
|
|
|
+ + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
|
|
|
+ + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
|
|
|
+ + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
|
|
|
+ + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
|
|
|
+ + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
|
|
|
+
|
|
|
+ if (listArray != null && listArray.length() > 0) {
|
|
|
+ for (int i = 0; i < listArray.length(); i++) {
|
|
|
+ JSONObject listObject = listArray.optJSONObject(i);
|
|
|
+ boxResult = boxResult
|
|
|
+ + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
|
|
|
+ + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mCollectResultTextView.setText(boxResult);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
|
|
|
+
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBoxCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mResult1 = messageObject.optString("PA_OUTBOXCODE");
|
|
|
+ mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
|
|
|
+ mResult3 = messageObject.optString("PA_PRODCODE");
|
|
|
+ mResult4 = messageObject.optString("PA_WHCODE");
|
|
|
+
|
|
|
+ mResults.add(mResult1);
|
|
|
+ mResults.add(mResult2);
|
|
|
+ mResults.add(mResult3);
|
|
|
+ mResults.add(mResult4);
|
|
|
+
|
|
|
+ mCollectBoxTv.setText(mResult1);
|
|
|
+ mCollectBoxNumTv.setText(mResult2);
|
|
|
+ mCollectBoxrProdcodeTv.setText(mResult3);
|
|
|
+ mCollectBoxWhcodeTv.setText(mResult4);
|
|
|
+
|
|
|
+ PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
|
|
|
+ }
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "采集成功");
|
|
|
+
|
|
|
+ Object next = jsonObject.getJSONObject("data").get("next");
|
|
|
+ if (next != null && !"null".equals(next.toString())) {
|
|
|
+ JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
|
|
|
+ MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
|
|
|
+ if (materialInformationBean != null) {
|
|
|
+ String materialInfo =
|
|
|
+ "型号:" + (materialInformationBean.getPR_ORISPECCODE() == null ? "" : materialInformationBean.getPR_ORISPECCODE())
|
|
|
+ + "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
|
|
|
+ + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
|
|
|
+ + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
|
|
|
+ + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
|
|
|
+ + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
|
|
|
+ + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
|
|
|
+ if (materialInformationBean.getPD_BATCHCODE() != null) {
|
|
|
+ materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
|
|
|
+ }
|
|
|
+ mMaterialInforTextView.setText(materialInfo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mMaterialInforTextView.setText("该出库单已经完成备料");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (getActivity() != null) {
|
|
|
+ mCollectTypeRadioGroup.setEnabled(true);
|
|
|
+ CommonUtil.editTextGetFocus(etBarCode);
|
|
|
+ String errorToast = CommonUtil.showErrorToast(volleyError, true);
|
|
|
+ mCollectResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ mCollectResultTextView.setText(errorToast);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ jsonRequest.setTag(TAG);
|
|
|
+ PdaApplication.mRequestQueue.add(jsonRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建PopupWindow
|
|
|
+ */
|
|
|
+ private PopupWindow popupWindow;
|
|
|
+ private AdapterPopupWindow adapterPopupWindow;
|
|
|
+ private Button dewOperConfirmBtn, btnDewCancel;
|
|
|
+
|
|
|
+ protected void showDewPopupWindow() {
|
|
|
+ try {
|
|
|
+ LayoutInflater inflater = LayoutInflater.from(getActivity());
|
|
|
+ View contentView = inflater.inflate(R.layout.popupwindow_ioc_out_make_material_oper, null);
|
|
|
+
|
|
|
+ ListView dewOperLv = (ListView) contentView.findViewById(R.id.dew_oper_lv);
|
|
|
+ ((TextView) contentView.findViewById(R.id.tv_ms_level)).setText(iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getMS_LEVEL());
|
|
|
+ ((TextView) contentView.findViewById(R.id.tv_status)).setText(iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getSTATUS());
|
|
|
+ if (iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getMS_RESTTIME() == -1) {
|
|
|
+ ((TextView) contentView.findViewById(R.id.tv_ms_resttime)).setText("999");
|
|
|
+ } else {
|
|
|
+ ((TextView) contentView.findViewById(R.id.tv_ms_resttime)).setText(iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getMS_RESTTIME() + "");
|
|
|
+ }
|
|
|
+
|
|
|
+ dewOperConfirmBtn = (Button) contentView.findViewById(R.id.dew_oper_confirm_btn);
|
|
|
+ btnDewCancel = (Button) contentView.findViewById(R.id.btn_dew_cancel);
|
|
|
+
|
|
|
+ dewOperConfirmBtn.setOnClickListener(this);
|
|
|
+ btnDewCancel.setOnClickListener(this);
|
|
|
+ adapterPopupWindow = new AdapterPopupWindow(getActivity(), R.layout.item_list_ioc_out_make_material_oper, iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getLog());
|
|
|
+ dewOperLv.setAdapter(adapterPopupWindow);
|
|
|
+ //item 的点击事件
|
|
|
+ dewOperLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
+ /* IOCOutMakeMaterialSubmit.Data data = dataListPopupWindow.get(i);
|
|
|
+ dataList.add(data);
|
|
|
+ adapterListView.notifyDataSetChanged();
|
|
|
+ closePopupWindow();
|
|
|
+ reset();*/
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // PopupWindow实例化
|
|
|
+ popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
|
+ LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ popupWindow.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
+ // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
|
|
|
+ popupWindow.showAtLocation(btnConfirm, Gravity.CENTER, 0, 0);
|
|
|
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closePopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //获取最底层窗口的参数,背景变灰色效果
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
|
+ switch (checkedId) {
|
|
|
+ case R.id.iocout_collect_barcode_rb:
|
|
|
+ etBarCode.setHint(R.string.please_collect_barcode);
|
|
|
+ mtypeNameTv.setText("条码号");
|
|
|
+ SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBarcode");
|
|
|
+ mCollectType = "byBarcode";
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.VISIBLE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno);
|
|
|
+
|
|
|
+ if (mResults != null && mResults.size() == 3) {
|
|
|
+ tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBarcodeCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mCollectBarcodeTv.setText(mResults.get(0));
|
|
|
+ mCollectBarRemainTv.setText(mResults.get(1));
|
|
|
+ mCollectBarProdcodeTv.setText(mResults.get(2));
|
|
|
+ } else {
|
|
|
+ tvBarcodeCollectionSuccess.setVisibility(View.GONE);
|
|
|
+ mCollectBarcodeTv.setText(null);
|
|
|
+ mCollectBarRemainTv.setText(null);
|
|
|
+ mCollectBarProdcodeTv.setText(null);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case R.id.iocout_collect_box_rb:
|
|
|
+ etBarCode.setHint(R.string.please_collect_box);
|
|
|
+ mtypeNameTv.setText("外箱号");
|
|
|
+ SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBatchcode");
|
|
|
+ mCollectType = "byBatchcode";
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.VISIBLE);
|
|
|
+
|
|
|
+ mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno);
|
|
|
+
|
|
|
+ if (mResults != null && mResults.size() == 4) {
|
|
|
+ tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBoxCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mCollectBoxTv.setText(mResults.get(0));
|
|
|
+ mCollectBoxNumTv.setText(mResults.get(1));
|
|
|
+ mCollectBoxrProdcodeTv.setText(mResults.get(2));
|
|
|
+ mCollectBoxWhcodeTv.setText(mResults.get(3));
|
|
|
+ } else {
|
|
|
+ mCollectBoxTv.setText(null);
|
|
|
+ mCollectBoxNumTv.setText(null);
|
|
|
+ mCollectBoxrProdcodeTv.setText(null);
|
|
|
+ mCollectBoxWhcodeTv.setText(null);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ if (flag == FLAG_CONFIRM_POST) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "过账成功");
|
|
|
+ } else if (flag == BarcodeSplitting) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ if (FastjsonUtil.validate(result)) {
|
|
|
+ com.alibaba.fastjson.JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ if (resultObject != null) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, FastjsonUtil.getText(resultObject, "data"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ if (flag == FLAG_CONFIRM_POST) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ } else if (flag == BarcodeSplitting) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * popupWindow 设置适配器
|
|
|
+ */
|
|
|
+ private class AdapterPopupWindow extends BaseAdapter {
|
|
|
+ private int resourceId;
|
|
|
+ private List<IOCOutMakeMaterialOperMsd.DataBean.BarcodeBean.MsdBean.LogBean> objects;
|
|
|
+ private Context mContext;
|
|
|
+
|
|
|
+ public AdapterPopupWindow(Context context, int resource, List<IOCOutMakeMaterialOperMsd.DataBean.BarcodeBean.MsdBean.LogBean> objects) {
|
|
|
+ resourceId = resource;
|
|
|
+ this.objects = objects;
|
|
|
+ mContext = context;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getCount() {
|
|
|
+ return objects == null ? 0 : objects.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getItem(int position) {
|
|
|
+ return objects == null ? null : objects.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getItemId(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ ViewHolder viewHolder = null;
|
|
|
+ if (convertView == null) {
|
|
|
+ convertView = View.inflate(mContext, resourceId, null);
|
|
|
+ viewHolder = new ViewHolder();
|
|
|
+
|
|
|
+ viewHolder.dateTextView = (TextView) convertView.findViewById(R.id.tv_date);
|
|
|
+ viewHolder.lifeTimeTextView = (TextView) convertView.findViewById(R.id.tv_lifetime);
|
|
|
+ viewHolder.actionTextView = (TextView) convertView.findViewById(R.id.tv_action);
|
|
|
+ viewHolder.manTextView = (TextView) convertView.findViewById(R.id.tv_man);
|
|
|
+ convertView.setTag(viewHolder);
|
|
|
+ } else {
|
|
|
+ viewHolder = (ViewHolder) convertView.getTag();
|
|
|
+ }
|
|
|
+
|
|
|
+ viewHolder.actionTextView.setText(objects.get(position).getMS_ACTION());
|
|
|
+ viewHolder.dateTextView.setText(objects.get(position).getMS_DATE() + "");
|
|
|
+ viewHolder.lifeTimeTextView.setText(objects.get(position).getMS_LIFETIME() + "");
|
|
|
+ viewHolder.manTextView.setText(objects.get(position).getMS_MAN());
|
|
|
+ return convertView;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ class ViewHolder {
|
|
|
+ TextView dateTextView;
|
|
|
+ TextView lifeTimeTextView;
|
|
|
+ TextView actionTextView;
|
|
|
+ TextView manTextView;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ switch (view.getId()) {
|
|
|
+ case R.id.btn_actionbar_more:
|
|
|
+ View materialOutMoreView = View.inflate(getActivity(), R.layout.pop_material_out_menu, null);
|
|
|
+ Button stockTaskBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_1);
|
|
|
+ Button stockAlreadyBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_2);
|
|
|
+ Button stockRevokeBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_3);
|
|
|
+ Button stockModifyBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_4);
|
|
|
+ Button stockSpecialBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_5);
|
|
|
+ Button passBillBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_6);
|
|
|
+ Button stockDataSummary = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_7);
|
|
|
+ Button barcodeSplitting = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_8);
|
|
|
+
|
|
|
+ stockTaskBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ ((FunctionActivity) getActivity()).setScanIvVisible(false);
|
|
|
+ if (isMultiple) {
|
|
|
+ clickToFragment(new MaterialOutStockTaskMultipleFragment());
|
|
|
+ } else {
|
|
|
+ clickToFragment(new MaterialOutStockTaskMultipleFragment());
|
|
|
+ // clickToFragment(new MaterialOutStockTaskFragment());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ stockDataSummary.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ ((FunctionActivity) getActivity()).setScanIvVisible(false);
|
|
|
+ clickToFragment(new StockDataSummaryFragment());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ stockAlreadyBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ ((FunctionActivity) getActivity()).setScanIvVisible(false);
|
|
|
+ clickToFragment(new MaterialOutStockAlreadyFragment());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ stockRevokeBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ // ((FunctionActivity) getActivity()).setScanIvVisible(false);
|
|
|
+ clickToFragment(new MaterialOutRevocationStockFragment());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ stockModifyBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ // ((FunctionActivity) getActivity()).setScanIvVisible(false);
|
|
|
+ clickToFragment(new ModifyQuantityOutFragment());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ stockSpecialBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ // ((FunctionActivity) getActivity()).setScanIvVisible(false);
|
|
|
+ clickToFragment(new SpecialMaterialOutFragment());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ passBillBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ new AlertDialog.Builder(mActivity)
|
|
|
+ .setMessage("确认将单据过账?")
|
|
|
+ .setNegativeButton(R.string.cancel, null)
|
|
|
+ .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
+ dialogInterface.dismiss();
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_INMATERIAL_CONFIRMPOST)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("piid", pi_id)
|
|
|
+ .tag(TAG + "confirmpost")
|
|
|
+ .flag(FLAG_CONFIRM_POST).build(),
|
|
|
+ 30 * 1000, IOCOutMakeMaterialOperNew.this);
|
|
|
+ }
|
|
|
+ }).create().show();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ barcodeSplitting.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ //弹出拨入仓
|
|
|
+ getRepairStep("");
|
|
|
+ //getWhcode(0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ listPopupWindow = new PopupWindow(materialOutMoreView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ listPopupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CommonUtil.setBackgroundAlpha(getActivity(), 0.5f);
|
|
|
+ listPopupWindow.showAsDropDown(btnActionbarRight);
|
|
|
+
|
|
|
+
|
|
|
+ /*View materialOutMoreView = View.inflate(getActivity(), R.layout.popupwindow_material_out_listview, null);
|
|
|
+ Button hadCollectBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_1);
|
|
|
+ Button noCollectBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_2);
|
|
|
+ Button reCollectBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_3);
|
|
|
+ Button noSubmitBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_4);
|
|
|
+
|
|
|
+ if (mCollectModel == 1) {
|
|
|
+ noSubmitBtn.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ noSubmitBtn.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+
|
|
|
+ hadCollectBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ clickToFragment(new CollectAlreadyFragment());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ noCollectBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ clickToFragment(new CollectNotFragment());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ reCollectBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ progressDialog.show();
|
|
|
+ mDbManager.deleteFromBarcodeIo(new String[]{pi_id, pd_whcode}, "LBI_PIID=? and LBI_WHCODE=?");
|
|
|
+ getAgainEvent();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ noSubmitBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ clickToFragment(new SubmitNotFragment());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ listPopupWindow = new PopupWindow(materialOutMoreView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+// popupWindow.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
+ listPopupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CommonUtil.setBackgroundAlpha(getActivity(), 0.5f);
|
|
|
+ listPopupWindow.showAsDropDown(btnActionbarRight);*/
|
|
|
+
|
|
|
+ break;
|
|
|
+ case R.id.dew_oper_confirm_btn:
|
|
|
+ if (iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getSTATUS().equals("在烘烤")) {
|
|
|
+ new AlertDialog.Builder(getActivity()).setTitle("提示")
|
|
|
+ .setMessage("是否出烤箱?")
|
|
|
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ dialog.dismiss();
|
|
|
+ popupWindow.dismiss();
|
|
|
+ progressDialog.show();
|
|
|
+ outOvenEvent();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ dialog.dismiss();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ } else {
|
|
|
+ double bar_remain = iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN();
|
|
|
+ double restqty = iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY();
|
|
|
+ if (CommonUtil.doubleCompare(bar_remain, restqty) == 1) {
|
|
|
+ spliteBarcode(currentBarcode, bar_remain + "", restqty + "");
|
|
|
+ } else {
|
|
|
+ closePopupWindow();
|
|
|
+ barcodeEnterEvent(true, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case R.id.btn_dew_cancel:
|
|
|
+ //点击取消按钮,关闭窗口
|
|
|
+ closePopupWindow();
|
|
|
+ // clearAll();
|
|
|
+ break;
|
|
|
+ case R.id.iocout_collect_model_btn:
|
|
|
+ if (mCollectModelBtn.getText().toString().trim().equals("在线")) {
|
|
|
+ mCollectModelBtn.setText("离线");
|
|
|
+ mCollectModel = 0;
|
|
|
+ } else if (mCollectModelBtn.getText().toString().trim().equals("离线")) {
|
|
|
+ List<TableLBARCODEIO> allBarcodeIo = new ArrayList<>();
|
|
|
+ if (mDbManager.getDb().isOpen()) {
|
|
|
+ allBarcodeIo = mDbManager.queryFromBarcodeIo(new String[]{"out", pi_id, pd_whcode}, "inOrOut=? and LBI_PIID=? and LBI_WHCODE=?");
|
|
|
+ }
|
|
|
+ if (CommonUtil.isNetWorkConnected(getActivity())) {
|
|
|
+ if (allBarcodeIo.size() != 0) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.auto_upload_offline_data));
|
|
|
+ submitOfflineData(allBarcodeIo, false);
|
|
|
+ } else {
|
|
|
+ mCollectModelBtn.setText("在线");
|
|
|
+ mCollectModel = 1;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mCollectModelBtn.setText("离线");
|
|
|
+ mCollectModel = 0;
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case R.id.btn_actionbar_scan_iv:
|
|
|
+ if (CameraUtil.hasCamera()) {
|
|
|
+ if (root.findFocus() != null) {
|
|
|
+ mFocusId = root.findFocus().getId();
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(mActivity, CaptureActivity.class);
|
|
|
+ startActivityForResult(intent, SCAN_BARCODE_CODE);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // private void getWhcode() {
|
|
|
+ // View mPopView = View.inflate(mActivity, R.layout.pop_whcode_dlert_dialog, null);
|
|
|
+ // ClearableEditText cet_whcode = (ClearableEditText) mPopView.findViewById(R.id.cet_whcode);
|
|
|
+ // Button bt_ok = (Button) mPopView.findViewById(R.id.bt_ok);
|
|
|
+ // AlertDialog mWarehouseDialog = new AlertDialog.Builder(mActivity)
|
|
|
+ // .setView(mPopView)
|
|
|
+ // .create();
|
|
|
+ // mWarehouseDialog.show();
|
|
|
+ //
|
|
|
+ // bt_ok.setOnClickListener(new View.OnClickListener() {
|
|
|
+ // @Override
|
|
|
+ // public void onClick(View v) {
|
|
|
+ // mWarehouseDialog.cancel();
|
|
|
+ // VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ // new HttpParams.Builder()
|
|
|
+ // .url(GloableParams.ADDRESS_BARCODE_SPLITTING)
|
|
|
+ // .method(Request.Method.GET)
|
|
|
+ // .addParam("id", pi_id)
|
|
|
+ // .addParam("whcode", cet_whcode.getText().toString().trim())
|
|
|
+ // .tag(TAG + "_barcodeSplitting")
|
|
|
+ // .flag(BarcodeSplitting).build(),
|
|
|
+ // 30 * 1000, IOCOutMakeMaterialOperNew.this);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ private void getRepairStep(String trim) {
|
|
|
+// String pi_class = "完工入库单";
|
|
|
+// String pi_type = "良品";
|
|
|
+ String pi_class = "";
|
|
|
+ String pi_type = "";
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_PDAIO_IN_GETWHCODE)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "getMaCode")
|
|
|
+ .addParam("condition", trim)
|
|
|
+ .addParam("piclass", pi_class)
|
|
|
+ .addParam("pi_type", pi_type)
|
|
|
+ .flag(0)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
|
|
|
+ com.alibaba.fastjson.JSONObject data = FastjsonUtil.getJSONObject(o.toString(), "data");
|
|
|
+ com.alibaba.fastjson.JSONArray dataArray = FastjsonUtil.getJSONArray(data.toString(), "whcode");
|
|
|
+ // JSONArray dataArray = FastjsonUtil.getJSONArray(data.toString(), "data");
|
|
|
+ if (isSuccess) {
|
|
|
+ if (dataArray == null) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "未搜索到匹配数据");
|
|
|
+ } else {
|
|
|
+ handleFeededlineData(dataArray, trim);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleFeededlineData(com.alibaba.fastjson.JSONArray dataArray, String trim) {
|
|
|
+ ComDataBean bean;
|
|
|
+ ComDataBeanList.clear();
|
|
|
+ for (Object index : dataArray) {
|
|
|
+ com.alibaba.fastjson.JSONObject data = (com.alibaba.fastjson.JSONObject) index;
|
|
|
+ bean = new ComDataBean();
|
|
|
+ bean.setItemName(data.getString("WH_DESCRIPTION"));
|
|
|
+ bean.setItemremark(data.getString("WH_CODE"));
|
|
|
+ ComDataBeanList.add(bean);
|
|
|
+ }
|
|
|
+ if (trim.isEmpty()) {
|
|
|
+ initresourcesPopupWindow();
|
|
|
+ } else {
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(ComDataBeanList);
|
|
|
+ ipAndResourcesPortAdapter.setmList(ComDataBeanList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initresourcesPopupWindow() {
|
|
|
+ View contView = LayoutInflater.from(mActivity).inflate(R.layout.index_recycle_item, null);
|
|
|
+ edit_et = (ClearableEditText) contView.findViewById(R.id.edit_et);
|
|
|
+ TextView sure_tv = (TextView) contView.findViewById(R.id.sure_tv);
|
|
|
+ TextView cancle_tv = (TextView) contView.findViewById(R.id.cancle_tv);
|
|
|
+ ImageView search_im = contView.findViewById(R.id.search_im);
|
|
|
+ LinearLayout line_top = contView.findViewById(R.id.line_top);
|
|
|
+ rv_line_ip_port_data = contView.findViewById(R.id.rv_ip_port_data);
|
|
|
+ rv_line_ip_port_data.addItemDecoration(new DividerItemDecoration(mActivity, LinearLayout.VERTICAL));
|
|
|
+ rv_line_ip_port_data.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(ComDataBeanList);
|
|
|
+ ipAndResourcesPortAdapter.setmList(ComDataBeanList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ setlineAdapter(ComDataBeanList);
|
|
|
+ // edit_et.setText(ct_qty.getText().toString().trim());
|
|
|
+
|
|
|
+ edit_et.requestFocus();
|
|
|
+ editPW = new PopupWindow(contView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ editPW.setTouchable(true);
|
|
|
+ editPW.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ editPW.setOnDismissListener(new BasePopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closePopListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ View parentView = mActivity.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
|
|
|
+ editPW.showAtLocation(parentView, Gravity.CENTER, 0, 0);
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
+ edit_et.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_DONE
|
|
|
+ || actionId == EditorInfo.IME_ACTION_SEND
|
|
|
+ || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ String mSearchStr = edit_et.getText().toString().trim();
|
|
|
+ if (!mSearchStr.isEmpty()) {
|
|
|
+ List<ComDataBean> thisList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < ComDataBeanList.size(); i++) {
|
|
|
+ if (ComDataBeanList.get(i).getItemremark().contains(mSearchStr) || ComDataBeanList.get(i).getItemName().contains(mSearchStr)) {
|
|
|
+ thisList.add(ComDataBeanList.get(i));
|
|
|
+ }
|
|
|
+ if (i == ComDataBeanList.size() - 1) {
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(thisList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ LogUtil.i("mSearchStr", JSON.toJSONString(thisList));
|
|
|
+
|
|
|
+ }
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int j = 0; j < lineCodeEntities.size(); j++) {
|
|
|
+ lineCodeEntities.get(j).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(ComDataBeanList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ List<ComDataBean> ipAndPortBeans = ipAndResourcesPortAdapter.getmList();
|
|
|
+ sc_name = ipAndPortBeans.get(position).getItemName();
|
|
|
+ sc_code = ipAndPortBeans.get(position).getItemremark();
|
|
|
+ for (int i = 0; i < ipAndPortBeans.size(); i++) {
|
|
|
+ ipAndPortBeans.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndPortBeans.get(position).setChecked(true);
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ search_im.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String mSearchStr = edit_et.getText().toString().trim();
|
|
|
+ if (!mSearchStr.isEmpty()) {
|
|
|
+ List<ComDataBean> thisList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < ComDataBeanList.size(); i++) {
|
|
|
+ if (ComDataBeanList.get(i).getItemremark().contains(mSearchStr) || ComDataBeanList.get(i).getItemName().contains(mSearchStr)) {
|
|
|
+ thisList.add(ComDataBeanList.get(i));
|
|
|
+ }
|
|
|
+ if (i == ComDataBeanList.size() - 1) {
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(thisList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ LogUtil.i("mSearchStr", JSON.toJSONString(thisList));
|
|
|
+
|
|
|
+ }
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int j = 0; j < lineCodeEntities.size(); j++) {
|
|
|
+ lineCodeEntities.get(j).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(ComDataBeanList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ }
|
|
|
+ // getRepairStep(mSearchStr);
|
|
|
+ ipAndResourcesPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ List<ComDataBean> ipAndPortBeans = ipAndResourcesPortAdapter.getmList();
|
|
|
+ sc_name = ipAndPortBeans.get(position).getItemName();
|
|
|
+ sc_code = ipAndPortBeans.get(position).getItemremark();
|
|
|
+ for (int i = 0; i < ipAndPortBeans.size(); i++) {
|
|
|
+ ipAndPortBeans.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndPortBeans.get(position).setChecked(true);
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ //确定
|
|
|
+ sure_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ list.clear();
|
|
|
+ if (StringUtil.isEmpty(sc_code)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请选择仓库编号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_BARCODE_SPLITTING)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("id", pi_id)
|
|
|
+ .addParam("whcode", sc_code)
|
|
|
+ .tag(TAG + "_barcodeSplitting")
|
|
|
+ .flag(BarcodeSplitting).build(),
|
|
|
+ 30 * 1000, IOCOutMakeMaterialOperNew.this);
|
|
|
+
|
|
|
+ closePopListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //取消
|
|
|
+ cancle_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closePopListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ String mSearchStr = edit_et.getText().toString().trim();
|
|
|
+ if (mSearchStr.isEmpty()) {
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(ComDataBeanList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ ipAndResourcesPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ List<ComDataBean> ipAndPortBeans = ipAndResourcesPortAdapter.getmList();
|
|
|
+ sc_name = ipAndPortBeans.get(position).getItemName();
|
|
|
+ sc_code = ipAndPortBeans.get(position).getItemremark();
|
|
|
+ for (int i = 0; i < ipAndPortBeans.size(); i++) {
|
|
|
+ ipAndPortBeans.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndPortBeans.get(position).setChecked(true);
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setlineAdapter(ArrayList<ComDataBean> mList) {
|
|
|
+ LogUtil.i("mList", JSON.toJSONString(mList));
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(mList);
|
|
|
+ ipAndResourcesPortAdapter.setmList(ComDataBeanList);
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closePopListPopupWindow() {
|
|
|
+ if (editPW != null) {
|
|
|
+ editPW.dismiss();
|
|
|
+ editPW = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (resultCode != Activity.RESULT_OK) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (requestCode == SCAN_BARCODE_CODE && data != null) {
|
|
|
+ if (data.getExtras() != null) {
|
|
|
+ String result = data.getExtras().getString(CodeUtils.RESULT_STRING);
|
|
|
+ if (mFocusId == R.id.et_bar_code) {
|
|
|
+ etBarCode.setText(result);
|
|
|
+ etBarCode.setSelection(result.length());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (!hidden) {
|
|
|
+ FunctionActivity.setTitle(getResources().getString(R.string.out_material_collect));
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
|
|
|
+ ((FunctionActivity) getActivity()).setScanIvVisible(true);
|
|
|
+ mScanImageView.setOnClickListener(this);
|
|
|
+ etBarCode.requestFocus();
|
|
|
+
|
|
|
+ isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
|
|
|
+ mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
|
|
|
+ mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
|
|
|
+ } else {
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ ((FunctionActivity) getActivity()).setScanIvVisible(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 出烘烤
|
|
|
+ */
|
|
|
+ private void outOvenEvent() {
|
|
|
+ String url = GloableParams.ADDRESS_MSDOUTOVEN + "?code=" + currentBarcode;
|
|
|
+ stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Toast.makeText(getActivity().getApplicationContext(), "出烘烤成功", Toast.LENGTH_SHORT).show();
|
|
|
+ double bar_remain = iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN();
|
|
|
+ double restqty = iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY();
|
|
|
+ if (CommonUtil.doubleCompare(bar_remain, restqty) == 1) {
|
|
|
+ spliteBarcode(currentBarcode, bar_remain + "", restqty + "");
|
|
|
+ } else {
|
|
|
+ closePopupWindow();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ //显示处理后的错误信息
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (volleyError != null && volleyError.networkResponse != null && volleyError.networkResponse.data != null) {
|
|
|
+ ErrorMsg errorMsg = JsonTools.parseJsonToBean(new String(volleyError.networkResponse.data), ErrorMsg.class);
|
|
|
+ if (errorMsg == null) {
|
|
|
+ Toast.makeText(mActivity, "系统错误", Toast.LENGTH_LONG).show();
|
|
|
+ } else {
|
|
|
+ String exceptionInfo = errorMsg.exceptionInfo;
|
|
|
+ if (exceptionInfo.contains("无需出")) {
|
|
|
+ Toast.makeText(mActivity, "已出烘烤", Toast.LENGTH_LONG).show();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Toast.makeText(mActivity, "出烘烤失败", Toast.LENGTH_LONG).show();
|
|
|
+ // etBarCode.setText("");
|
|
|
+ // CommonUtil.editTextGetFocus(etBarCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ String cookie = SharedPreUtil.getString(getActivity().getApplicationContext(), "cookie", null);
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Cookie", cookie);
|
|
|
+ return headers;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ stringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ stringRequest.setTag(TAG);
|
|
|
+ PdaApplication.mRequestQueue.add(stringRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void spliteBarcode(final String currentBarcode, String barRemain, String restqty) {
|
|
|
+ new AlertDialog.Builder(getActivity()).setTitle("提示")
|
|
|
+ .setMessage("条码数量(" + barRemain + ")大于剩余需要采集数量(" + restqty + "),确认拆分?")
|
|
|
+ .setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ if (!CommonUtil.isRepeatClick())
|
|
|
+ breakingBtnClickEvent(currentBarcode);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ dialog.dismiss();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分拆批次
|
|
|
+ *
|
|
|
+ * @param currentBarcode
|
|
|
+ */
|
|
|
+ private void breakingBtnClickEvent(final String currentBarcode) {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_BREAK_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_BREAK_DEAL;
|
|
|
+ Log.d("breakDeal", url);
|
|
|
+
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(url)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("ids", pi_id)
|
|
|
+ .addParam("barcode", currentBarcode)
|
|
|
+ .addParam("or_remain", mBarRemain)
|
|
|
+ .addParam("bar_remain", mRestqty)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+
|
|
|
+ String s = o.toString();
|
|
|
+ if (popupWindow != null && popupWindow.isShowing())
|
|
|
+ closePopupWindow();
|
|
|
+ mResults = new ArrayList<>();
|
|
|
+ mCollectTypeRadioGroup.setEnabled(true);
|
|
|
+ LogUtil.e("breaking", s);
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = new JSONObject(s);
|
|
|
+ JSONObject dataObject = jsonObject.optJSONObject("data");
|
|
|
+ if (dataObject == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject messageObject = dataObject.optJSONObject("barcode");
|
|
|
+ if (messageObject == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (messageObject.has("ISMSD")) {
|
|
|
+ if (messageObject.optBoolean("ISMSD")) {
|
|
|
+ //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
|
|
|
+ iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
|
|
|
+ // Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
|
|
|
+ mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
|
|
|
+ mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
|
|
|
+ showDewPopupWindow();
|
|
|
+ } else {
|
|
|
+ mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
|
|
|
+ mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
|
|
|
+ mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
|
|
|
+ if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
|
|
|
+ spliteBarcode(currentBarcode, mBarRemain, mRestqty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mCollectResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ mCollectResultTextView.setText(null);
|
|
|
+ // listArray = dataObject.optJSONArray("nolist");
|
|
|
+ listArray = FastjsonUtil.getJSONArray(dataObject.toString(), "nolist");
|
|
|
+ Log.e("listArraydata", listArray.toString());
|
|
|
+ if (mCollectType.equals("byBarcode") || mCollectType.equals("byBatchcode")) {
|
|
|
+ String barcodeResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
|
|
|
+ + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
|
|
|
+ + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
|
|
|
+ + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
|
|
|
+ + ";名称规格:" + messageObject.optString("PR_DETAIL")
|
|
|
+ + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
|
|
|
+ + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
|
|
|
+
|
|
|
+ if (listArray != null && listArray.size() > 0) {
|
|
|
+ for (int i = 0; i < listArray.size(); i++) {
|
|
|
+ com.alibaba.fastjson.JSONObject listObject = listArray.getJSONObject(i);
|
|
|
+ //JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
|
|
|
+ //JsonUtils.optStringNotNull(listObject, "BAR_CODE")
|
|
|
+ //CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "RESTQTY"));
|
|
|
+ barcodeResult = barcodeResult
|
|
|
+ + "\n单号:" + listObject.getString("PI_INOUTNO")
|
|
|
+ + ";条码号:" + listObject.getString("BAR_CODE")
|
|
|
+ + ";数量:" + listObject.getString("RESTQTY");
|
|
|
+ }
|
|
|
+
|
|
|
+ //弹出拆分结果弹框
|
|
|
+ initBreakPopupWindow(listArray);
|
|
|
+ }
|
|
|
+
|
|
|
+ mCollectResultTextView.setText(barcodeResult);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
|
|
|
+
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBarcodeCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mResult1 = messageObject.optString("BAR_CODE");
|
|
|
+ mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
|
|
|
+ mResult3 = messageObject.optString("BAR_PRODCODE");
|
|
|
+
|
|
|
+ mResults.add(mResult1);
|
|
|
+ mResults.add(mResult2);
|
|
|
+ mResults.add(mResult3);
|
|
|
+
|
|
|
+ mCollectBarcodeTv.setText(mResult1);
|
|
|
+ mCollectBarRemainTv.setText(mResult2);
|
|
|
+ mCollectBarProdcodeTv.setText(mResult3);
|
|
|
+
|
|
|
+ PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
|
|
|
+ } else if (false) {
|
|
|
+ String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
|
|
|
+ + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
|
|
|
+ + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
|
|
|
+ + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
|
|
|
+ + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
|
|
|
+ + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
|
|
|
+
|
|
|
+
|
|
|
+ if (listArray != null && listArray.size() > 0) {
|
|
|
+ for (int i = 0; i < listArray.size(); i++) {
|
|
|
+ com.alibaba.fastjson.JSONObject listObject = listArray.getJSONObject(i);
|
|
|
+ // + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
|
|
|
+ // + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
|
|
|
+ // + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
|
|
|
+ boxResult = boxResult
|
|
|
+ + "\n单号:" + listObject.getString("PI_INOUTNO")
|
|
|
+ + ";条码号:" + listObject.getString("BAR_CODE")
|
|
|
+ + ";数量:" + listObject.getDouble("BAR_REMAIN");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mCollectResultTextView.setText(boxResult);
|
|
|
+ mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
|
|
|
+
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBoxCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mResult1 = messageObject.optString("PA_OUTBOXCODE");
|
|
|
+ mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
|
|
|
+ mResult3 = messageObject.optString("PA_PRODCODE");
|
|
|
+ mResult4 = messageObject.optString("PA_WHCODE");
|
|
|
+
|
|
|
+ mResults.add(mResult1);
|
|
|
+ mResults.add(mResult2);
|
|
|
+ mResults.add(mResult3);
|
|
|
+ mResults.add(mResult4);
|
|
|
+
|
|
|
+ mCollectBoxTv.setText(mResult1);
|
|
|
+ mCollectBoxNumTv.setText(mResult2);
|
|
|
+ mCollectBoxrProdcodeTv.setText(mResult3);
|
|
|
+ mCollectBoxWhcodeTv.setText(mResult4);
|
|
|
+
|
|
|
+ PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
|
|
|
+ }
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "采集成功");
|
|
|
+
|
|
|
+ Object next = jsonObject.getJSONObject("data").get("next");
|
|
|
+ if (next != null && !"null".equals(next.toString())) {
|
|
|
+ JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
|
|
|
+ MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
|
|
|
+ if (materialInformationBean != null) {
|
|
|
+ String materialInfo =
|
|
|
+ "型号:" + (materialInformationBean.getPR_ORISPECCODE() == null ? "" : materialInformationBean.getPR_ORISPECCODE())
|
|
|
+ + "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
|
|
|
+ + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
|
|
|
+ + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
|
|
|
+ + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
|
|
|
+ + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
|
|
|
+ + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
|
|
|
+ if (materialInformationBean.getPD_BATCHCODE() != null) {
|
|
|
+ materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
|
|
|
+ }
|
|
|
+ mMaterialInforTextView.setText(materialInfo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mMaterialInforTextView.setText("该出库单已经完成备料");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (getActivity() != null) {
|
|
|
+ try {
|
|
|
+ etBarCode.setText(null);
|
|
|
+ CommonUtil.editTextGetFocus(etBarCode);
|
|
|
+ CommonUtil.makeNotice();
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), failStr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ /*RequestBody requestBody = new FormBody.Builder()
|
|
|
+ .add("ids", pi_id)
|
|
|
+ .add("barcode", currentBarcode)
|
|
|
+ .add("or_remain", mBarRemain)
|
|
|
+ .add("bar_remain", mRestqty)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ okhttp3.Request.Builder builder = new okhttp3.Request.Builder().url(url).post(requestBody);
|
|
|
+
|
|
|
+ Map<String, String> cookiesMap = VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ if (cookiesMap != null) {
|
|
|
+ Set<String> keys = cookiesMap.keySet();
|
|
|
+ Iterator<String> iterator = keys.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ String key = iterator.next();
|
|
|
+ String value = cookiesMap.get(key);
|
|
|
+ builder.addHeader(key, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mRequest = builder.build();
|
|
|
+ mOkHttpClient.newCall(mRequest).enqueue(new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onFailure(Call call, IOException e) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Message message = Message.obtain();
|
|
|
+ message.what = SPLIT_BARCODE_FAIL;
|
|
|
+ message.obj = "{\"exceptionInfo\":\"条码拆分异常\"}";
|
|
|
+ mHandler.sendMessage(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(Call call, okhttp3.Response response) throws IOException {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String s = response.body().string();
|
|
|
+ if (response.code() == 200) {
|
|
|
+ Message message = Message.obtain();
|
|
|
+ message.what = SPLIT_BARCODE_SUCCESS;
|
|
|
+ message.obj = s;
|
|
|
+ mHandler.sendMessage(message);
|
|
|
+ } else {
|
|
|
+ Message message = Message.obtain();
|
|
|
+ message.what = SPLIT_BARCODE_FAIL;
|
|
|
+ message.obj = s;
|
|
|
+ mHandler.sendMessage(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+*/
|
|
|
+ /*stringRequest = new StringRequest(Request.Method.POST, url,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+
|
|
|
+ if (popupWindow != null && popupWindow.isShowing())
|
|
|
+ closePopupWindow();
|
|
|
+ mResults = new ArrayList<>();
|
|
|
+ mCollectTypeRadioGroup.setEnabled(true);
|
|
|
+ LogUtil.e("breaking", s);
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = new JSONObject(s);
|
|
|
+ JSONObject dataObject = jsonObject.optJSONObject("data");
|
|
|
+ if (dataObject == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject messageObject = dataObject.optJSONObject("barcode");
|
|
|
+ if (messageObject == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (messageObject.has("ISMSD")) {
|
|
|
+ if (messageObject.optBoolean("ISMSD")) {
|
|
|
+ //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
|
|
|
+ iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
|
|
|
+// Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
|
|
|
+ mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
|
|
|
+ mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
|
|
|
+ showDewPopupWindow();
|
|
|
+ } else {
|
|
|
+ mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
|
|
|
+ mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
|
|
|
+ mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
|
|
|
+ if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
|
|
|
+ spliteBarcode(currentBarcode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mCollectResultTextView.setVisibility(View.VISIBLE);
|
|
|
+ mCollectResultTextView.setText(null);
|
|
|
+ JSONArray listArray = dataObject.optJSONArray("nolist");
|
|
|
+ if (mCollectType.equals("byBarcode")) {
|
|
|
+ String barcodeResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
|
|
|
+ + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
|
|
|
+ + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
|
|
|
+ + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
|
|
|
+ + ";名称规格:" + messageObject.optString("PR_DETAIL")
|
|
|
+ + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
|
|
|
+ + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
|
|
|
+
|
|
|
+ if (listArray != null && listArray.length() > 0) {
|
|
|
+ for (int i = 0; i < listArray.length(); i++) {
|
|
|
+ JSONObject listObject = listArray.optJSONObject(i);
|
|
|
+ barcodeResult = barcodeResult
|
|
|
+ + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
|
|
|
+ + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mCollectResultTextView.setText(barcodeResult);
|
|
|
+
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBarcodeCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mResult1 = messageObject.optString("BAR_CODE");
|
|
|
+ mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
|
|
|
+ mResult3 = messageObject.optString("BAR_PRODCODE");
|
|
|
+
|
|
|
+ mResults.add(mResult1);
|
|
|
+ mResults.add(mResult2);
|
|
|
+ mResults.add(mResult3);
|
|
|
+
|
|
|
+ mCollectBarcodeTv.setText(mResult1);
|
|
|
+ mCollectBarRemainTv.setText(mResult2);
|
|
|
+ mCollectBarProdcodeTv.setText(mResult3);
|
|
|
+
|
|
|
+ PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
|
|
|
+ } else if (mCollectType.equals("byBatchcode")) {
|
|
|
+ String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
|
|
|
+ + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
|
|
|
+ + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
|
|
|
+ + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
|
|
|
+ + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
|
|
|
+ + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
|
|
|
+
|
|
|
+
|
|
|
+ if (listArray != null && listArray.length() > 0) {
|
|
|
+ for (int i = 0; i < listArray.length(); i++) {
|
|
|
+ JSONObject listObject = listArray.optJSONObject(i);
|
|
|
+ boxResult = boxResult
|
|
|
+ + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
|
|
|
+ + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
|
|
|
+ + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mCollectResultTextView.setText(boxResult);
|
|
|
+
|
|
|
+
|
|
|
+ mBarcodeTableLayout.setVisibility(View.GONE);
|
|
|
+ mBoxTableLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
|
|
|
+ tvBoxCollectionSuccess.setText("采集成功");
|
|
|
+
|
|
|
+ mResult1 = messageObject.optString("PA_OUTBOXCODE");
|
|
|
+ mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
|
|
|
+ mResult3 = messageObject.optString("PA_PRODCODE");
|
|
|
+ mResult4 = messageObject.optString("PA_WHCODE");
|
|
|
+
|
|
|
+ mResults.add(mResult1);
|
|
|
+ mResults.add(mResult2);
|
|
|
+ mResults.add(mResult3);
|
|
|
+ mResults.add(mResult4);
|
|
|
+
|
|
|
+ mCollectBoxTv.setText(mResult1);
|
|
|
+ mCollectBoxNumTv.setText(mResult2);
|
|
|
+ mCollectBoxrProdcodeTv.setText(mResult3);
|
|
|
+ mCollectBoxWhcodeTv.setText(mResult4);
|
|
|
+
|
|
|
+ PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
|
|
|
+ }
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "采集成功");
|
|
|
+
|
|
|
+ Object next = jsonObject.getJSONObject("data").get("next");
|
|
|
+ if (next != null && !"null".equals(next.toString())) {
|
|
|
+ JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
|
|
|
+ MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
|
|
|
+ if (materialInformationBean != null) {
|
|
|
+ String materialInfo =
|
|
|
+ "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
|
|
|
+ + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
|
|
|
+ + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
|
|
|
+ + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
|
|
|
+ + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
|
|
|
+ + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
|
|
|
+ if (materialInformationBean.getPD_BATCHCODE() != null) {
|
|
|
+ materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
|
|
|
+ }
|
|
|
+ mMaterialInforTextView.setText(materialInfo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mMaterialInforTextView.setText("该出库单已经完成备料");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+// Toast.makeText(getActivity().getApplicationContext(), "拆分失败", Toast.LENGTH_LONG).show();
|
|
|
+ if (getActivity() != null) {
|
|
|
+ etBarCode.setText(null);
|
|
|
+ CommonUtil.editTextGetFocus(etBarCode);
|
|
|
+ CommonUtil.showErrorToast(volleyError);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Map<String, String> getParams() throws AuthFailureError {
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+// if (isMultiple) {
|
|
|
+ params.put("ids", pi_id);
|
|
|
+// } else {
|
|
|
+// params.put("id", pi_id);
|
|
|
+// params.put("whcode", pd_whcode);
|
|
|
+// }
|
|
|
+ params.put("barcode", currentBarcode);
|
|
|
+ params.put("or_remain", mBarRemain);
|
|
|
+ params.put("bar_remain", mRestqty);
|
|
|
+ Log.e(TAG, params.toString());
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+ stringRequest.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
|
|
|
+ int timeoutMs = stringRequest.getTimeoutMs();
|
|
|
+ stringRequest.setTag(TAG);
|
|
|
+ PdaApplication.mRequestQueue.add(stringRequest);*/
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void initBreakPopupWindow(com.alibaba.fastjson.JSONArray listArray) {
|
|
|
+ messages.clear();
|
|
|
+ for (int i = 0; i < listArray.size(); i++) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson.JSONObject barcodeObject = listArray.getJSONObject(i);
|
|
|
+
|
|
|
+ if (barcodeObject != null) {
|
|
|
+ WHBreakingBatchBreakingBtnClickEventNew.DataBean dataBean = new WHBreakingBatchBreakingBtnClickEventNew.DataBean();
|
|
|
+
|
|
|
+ // dataBean.setBAR_CODE(JsonUtils.optStringNotNull(barcodeObject, "BAR_CODE"));
|
|
|
+ // dataBean.setBAR_REMAIN(JsonUtils.optStringNotNull(barcodeObject, "BAR_REMAIN"));//RESTQTY
|
|
|
+ dataBean.setBAR_CODE(barcodeObject.getString("BAR_CODE"));
|
|
|
+ dataBean.setBAR_REMAIN(barcodeObject.getString("BAR_REMAIN"));//RESTQTY
|
|
|
+
|
|
|
+ messages.add(dataBean);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ View popView = LayoutInflater.from(getActivity()).inflate(R.layout.popupwindow_whbreaking_batch, null);
|
|
|
+ ListView listView = (ListView) popView.findViewById(R.id.list_view);
|
|
|
+ Button btnPrintf = (Button) popView.findViewById(R.id.btn_print);
|
|
|
+ Button btnPrintfSet = (Button) popView.findViewById(R.id.btn_print_setting);
|
|
|
+ Button btnClose = (Button) popView.findViewById(R.id.btn_close);
|
|
|
+ Button btnBack = (Button) popView.findViewById(R.id.btn_back);
|
|
|
+
|
|
|
+ btnBack.setVisibility(View.GONE);
|
|
|
+ btnClose.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ btnPrintf.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (isConnected) {
|
|
|
+ progressDialog.show();
|
|
|
+ printEvent(listArray);
|
|
|
+ } else {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
|
|
|
+
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
|
|
|
+ blueToothPrintFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(IOCOutMakeMaterialOperNew.this, blueToothPrintFragment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ btnPrintfSet.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
|
|
|
+
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
|
|
|
+ blueToothPrintFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(IOCOutMakeMaterialOperNew.this, blueToothPrintFragment);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ MyAdapter adapter = new MyAdapter(getActivity(), R.layout.item_list_whbreakingbatchfragment, messages);
|
|
|
+ listView.setAdapter(adapter);
|
|
|
+ //当只有一条数据的时候可以加上
|
|
|
+ /*
|
|
|
+ if (messages.size()>1){
|
|
|
+ btnBack.setVisibility(View.GONE);
|
|
|
+ }*/
|
|
|
+ // PopupWindow实例化,参数的意思是 view,长(不包括状态栏),高(不包括状态栏),是否聚焦
|
|
|
+ splitPop = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
|
+ LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ splitPop.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
+ splitPop.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
|
|
|
+ splitPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
+ splitPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ // confirmEvent();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void printEvent(com.alibaba.fastjson.JSONArray printArray) {
|
|
|
+ if (isPrinting) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "正在打印中,请勿重复操作");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isPrinting = true;
|
|
|
+ if (printArray != null && printArray.size() > 0) {
|
|
|
+ boolean isFail = false;
|
|
|
+ for (int i = 0; i < printArray.size(); i++) {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson.JSONObject printObject = printArray.getJSONObject(i);
|
|
|
+ int printResult = PrintUtils.printBar(mActivity, printObject.toString(), mPrintDpi, null);
|
|
|
+ if (printResult <= 0) {
|
|
|
+ isFail = true;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (isFail) {
|
|
|
+ isConnected = false;
|
|
|
+ SharedPreUtil.saveInt(mActivity, "printConnect", 0);
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印失败,请重新连接打印机");
|
|
|
+
|
|
|
+ BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
|
|
|
+
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, printArray.toString());
|
|
|
+ blueToothPrintFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(IOCOutMakeMaterialOperNew.this, blueToothPrintFragment);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印成功");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印失败,条码数据为空");
|
|
|
+ }
|
|
|
+ isPrinting = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static final String GETPRINTDATA = "getPrintData";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取打印文件
|
|
|
+ */
|
|
|
+ private void getPrintData() {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = GloableParams.ADDRESS_LABELPRINT + "?data=" + strPrintDataList;
|
|
|
+ stringRequestSplit = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ try {
|
|
|
+ JSONObject resultObject = new JSONObject(s);
|
|
|
+ if (resultObject.optBoolean("success")) {
|
|
|
+ mPrintUrl = resultObject.optString("data");
|
|
|
+ FileUtils.printBarcode(mPrintUrl, mHandler);
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.showErrorToast(volleyError);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ Map map = VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ //不用改动
|
|
|
+ map.put("Content-Type", "text/html; charset=UTF-8");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+ stringRequestSplit.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ stringRequestSplit.setTag(GETPRINTDATA);
|
|
|
+ PdaApplication.mRequestQueue.add(stringRequestSplit);
|
|
|
+ }
|
|
|
+
|
|
|
+ private class MyAdapter extends ArrayAdapter<WHBreakingBatchBreakingBtnClickEventNew.DataBean> {
|
|
|
+ private int resourceId;
|
|
|
+
|
|
|
+ public MyAdapter(Context context, int resource, List<WHBreakingBatchBreakingBtnClickEventNew.DataBean> objects) {
|
|
|
+ super(context, resource, objects);
|
|
|
+ resourceId = resource;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ //WHBreakingBatchBreakingBtnClickEventNew.Message target = getItem(position);
|
|
|
+ WHBreakingBatchBreakingBtnClickEventNew.DataBean person = getItem(position);
|
|
|
+ convertView = LayoutInflater.from(getContext()).inflate(resourceId,
|
|
|
+ null);
|
|
|
+ TextView tv_bar_code = (TextView) convertView.findViewById(R.id.tv_bar_code);
|
|
|
+ TextView tv_bar_remain = (TextView) convertView.findViewById(R.id.tv_bar_remain);
|
|
|
+ // tv_bar_code.setText(target.bar_code);
|
|
|
+ // tv_bar_remain.setText(target.bar_remain);
|
|
|
+ tv_bar_code.setText(person.getBAR_CODE());
|
|
|
+ tv_bar_remain.setText(person.getBAR_REMAIN());
|
|
|
+ return convertView;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 条码输入框的enter事件以及确认按钮点击事件
|
|
|
+ */
|
|
|
+ private void confirmEvent() {
|
|
|
+ currentBarcode = etBarCode.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(currentBarcode)) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "请输入号码");
|
|
|
+ } else if (!currentBarcode.matches(Constants.REGEX.NO_CN_SYMBOL)) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
|
|
|
+ } else {
|
|
|
+ if (mCollectModel == 1) {
|
|
|
+ if (CommonUtil.isNetWorkConnected(getActivity())) {
|
|
|
+ barcodeEnterEvent(false, true);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
|
|
|
+ }
|
|
|
+ } else if (mCollectModel == 0) {
|
|
|
+ //离线模式
|
|
|
+ saveToDatabase(currentBarcode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveToDatabase(String currentText) {
|
|
|
+ progressDialog.show();
|
|
|
+ List<TableLBARCODEIO> allBarcodeIo = new ArrayList<>();
|
|
|
+ if (mDbManager.getDb().isOpen()) {
|
|
|
+ allBarcodeIo = mDbManager.queryFromBarcodeIo(new String[]{"out", pi_id, pd_whcode}, "inOrOut=? and LBI_PIID=? and LBI_WHCODE=? ");
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果用户采集的离线数据超过30条,提示用户请先将采集的数据上传,限制用户必须先将数据上传
|
|
|
+ if (allBarcodeIo.size() >= 30) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ final List<TableLBARCODEIO> finalAllBarcodeIo = allBarcodeIo;
|
|
|
+ new android.app.AlertDialog.Builder(getActivity())
|
|
|
+ .setTitle("提示")
|
|
|
+ .setMessage("您采集的离线数据已经达到30条,请先将离线数据上传再继续采集。是否上传数据?")
|
|
|
+ .setPositiveButton("上传", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ if (CommonUtil.isNetWorkConnected(getActivity())) {
|
|
|
+ submitOfflineData(finalAllBarcodeIo, false);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ dialog.dismiss();
|
|
|
+ }
|
|
|
+ }).show();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ boolean isExist = false;
|
|
|
+ for (int i = 0; i < allBarcodeIo.size(); i++) {
|
|
|
+ if (pi_id.equals(allBarcodeIo.get(i).getLBI_PIID() + "") && pd_whcode.equals(allBarcodeIo.get(i).getLBI_WHCODE())
|
|
|
+ && "out".equals(allBarcodeIo.get(i).getInOrOut())
|
|
|
+ && ((currentText.equals(allBarcodeIo.get(i).getLBI_BARCODE()) && mCollectType.equals("byBarcode"))
|
|
|
+ || (currentText.equals(allBarcodeIo.get(i).getLBI_OUTBOXCODE()) && mCollectType.equals("byBatchcode")))) {
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isExist) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (mCollectType.equals("byBarcode"))
|
|
|
+ Toast.makeText(getActivity(), "条码 " + currentText + " 已经在已采集待提交数据中", Toast.LENGTH_SHORT).show();
|
|
|
+ else if (mCollectType.equals("byBatchcode"))
|
|
|
+ Toast.makeText(getActivity(), "外箱 " + currentText + " 已经在已采集待提交数据中", Toast.LENGTH_SHORT).show();
|
|
|
+ etBarCode.setText(null);
|
|
|
+ etBarCode.requestFocus();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ TableLBARCODEIO newBarcodeIo = new TableLBARCODEIO();
|
|
|
+ newBarcodeIo.setLBI_PIID(Long.parseLong(pi_id));
|
|
|
+ if (mCollectType.equals("byBarcode")) {
|
|
|
+ newBarcodeIo.setLBI_BARCODE(etBarCode.getText().toString().trim());
|
|
|
+ newBarcodeIo.setLBI_OUTBOXCODE("");
|
|
|
+ newBarcodeIo.setLBI_BOXTYPE("byBarcode");
|
|
|
+ } else if (mCollectType.equals("byBatchcode")) {
|
|
|
+ newBarcodeIo.setLBI_BARCODE("");
|
|
|
+ newBarcodeIo.setLBI_OUTBOXCODE(etBarCode.getText().toString().trim());
|
|
|
+ newBarcodeIo.setLBI_BOXTYPE("byBatchcode");
|
|
|
+ }
|
|
|
+ newBarcodeIo.setLBI_WHCODE(pd_whcode);
|
|
|
+ newBarcodeIo.setLBI_INOUTNO(pi_inoutno);
|
|
|
+ newBarcodeIo.setLBI_PRODCODE("");
|
|
|
+ newBarcodeIo.setLBI_INQTY(0);
|
|
|
+ newBarcodeIo.setLBI_LOCATION("");
|
|
|
+ newBarcodeIo.setLBI_PRDETAIL("");
|
|
|
+ newBarcodeIo.setLBI_OUTQTY(0);
|
|
|
+ newBarcodeIo.setLBI_PRID(0);
|
|
|
+ newBarcodeIo.setInOrOut("out");
|
|
|
+ try {
|
|
|
+ mDbManager.saveToBarcodeIo(newBarcodeIo);
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Toast.makeText(getActivity(), "成功保存至未提交列表", Toast.LENGTH_SHORT).show();
|
|
|
+ }
|
|
|
+ }, 400);
|
|
|
+ etBarCode.setText(null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Toast.makeText(getActivity(), "数据保存失败", Toast.LENGTH_SHORT).show();
|
|
|
+ etBarCode.setText(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void submitOfflineData(final List<TableLBARCODEIO> mNotSubmitList, final boolean isPop) {
|
|
|
+ progressDialog.show();
|
|
|
+ final List<SubmitNotParam> submitNotParams = new ArrayList<SubmitNotParam>();
|
|
|
+ for (int i = 0; i < mNotSubmitList.size(); i++) {
|
|
|
+ SubmitNotParam submitNotParam = new SubmitNotParam();
|
|
|
+ TableLBARCODEIO lbarcodeio = mNotSubmitList.get(i);
|
|
|
+
|
|
|
+ submitNotParam.setBi_barcode(lbarcodeio.getLBI_BARCODE());
|
|
|
+ submitNotParam.setBi_inoutno(lbarcodeio.getLBI_INOUTNO());
|
|
|
+ submitNotParam.setBi_inqty(lbarcodeio.getLBI_INQTY() + "");
|
|
|
+ submitNotParam.setBi_location(lbarcodeio.getLBI_LOCATION());
|
|
|
+ submitNotParam.setBi_piid(lbarcodeio.getLBI_PIID() + "");
|
|
|
+ submitNotParam.setBi_prodcode(lbarcodeio.getLBI_PRODCODE());
|
|
|
+ submitNotParam.setBi_prodid(lbarcodeio.getLBI_PRID() + "");
|
|
|
+ submitNotParam.setBi_whcode(lbarcodeio.getLBI_WHCODE());
|
|
|
+ submitNotParam.setBi_outboxcode(lbarcodeio.getLBI_OUTBOXCODE());
|
|
|
+ submitNotParam.setBi_boxtype(lbarcodeio.getLBI_BOXTYPE());
|
|
|
+
|
|
|
+ submitNotParams.add(submitNotParam);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = GloableParams.ADDRESS_OUT_SAVE_BARCODE;
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "submit");
|
|
|
+
|
|
|
+ mStringRequest = new StringRequest(Request.Method.POST, url,
|
|
|
+ new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ JSONObject resultJsonObject = new JSONObject(s);
|
|
|
+ JSONObject dataJsonObject = resultJsonObject.getJSONObject("data");
|
|
|
+
|
|
|
+ Iterator<String> resultKeys = dataJsonObject.keys();
|
|
|
+
|
|
|
+ if (resultKeys.hasNext()) {
|
|
|
+ int successCount = 0;
|
|
|
+ int failCount = 0;
|
|
|
+ while (resultKeys.hasNext()) {
|
|
|
+ String barcodeKey = resultKeys.next().toString();
|
|
|
+ String barcodeResult = JsonUtils.optStringNotNull(dataJsonObject, barcodeKey);
|
|
|
+
|
|
|
+ if (barcodeKey.contains("byBarcode:")) {
|
|
|
+ barcodeKey = barcodeKey.substring(10);
|
|
|
+ } else if (barcodeKey.contains("byBatchcode:")) {
|
|
|
+ barcodeKey = barcodeKey.substring(6);
|
|
|
+ }
|
|
|
+ if ("success".equals(barcodeResult)) {
|
|
|
+ successCount++;
|
|
|
+ for (int i = 0; i < mNotSubmitList.size(); i++) {
|
|
|
+ TableLBARCODEIO lbarcodeio = mNotSubmitList.get(i);
|
|
|
+ if (barcodeKey.equals(lbarcodeio.getLBI_BARCODE())) {
|
|
|
+ mDbManager.deleteFromBarcodeIo(lbarcodeio);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ failCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (failCount == 0) {
|
|
|
+ mCollectModelBtn.setText("在线");
|
|
|
+ mCollectModel = 1;
|
|
|
+ Toast.makeText(getActivity(), getResources().getString(R.string.submit_success), Toast.LENGTH_SHORT).show();
|
|
|
+ if (isPop)
|
|
|
+ getActivity().getSupportFragmentManager().popBackStack();
|
|
|
+ } else {
|
|
|
+ mCollectModelBtn.setText("离线");
|
|
|
+ mCollectModel = 0;
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), successCount + "条数据提交成功\n" + failCount + "条数据提交失败");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (getActivity() != null) {
|
|
|
+ mCollectModelBtn.setText("离线");
|
|
|
+ mCollectModel = 0;
|
|
|
+ CommonUtil.showErrorToast(volleyError);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Map<String, String> getParams() throws AuthFailureError {
|
|
|
+ Map<String, String> param = new HashMap<>();
|
|
|
+ param.put("data", JSON.toJSONString(submitNotParams));
|
|
|
+ param.put("type", mProdOutType);
|
|
|
+ return param;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ mStringRequest.setTag(TAG + "submit");
|
|
|
+ PdaApplication.mRequestQueue.add(mStringRequest);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void getAgainEvent() {
|
|
|
+ String url = GloableParams.ADDRESS_CLEARGET;
|
|
|
+
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG);
|
|
|
+ stringRequestPost = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(String s) {
|
|
|
+ LogUtil.e("已空", s + "");
|
|
|
+ // progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "已清空采集数据");
|
|
|
+ getCollectNotListOnline(pi_id, pd_whcode);
|
|
|
+ }
|
|
|
+ }, new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (getActivity() != null) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ // getCollectNotListOnline(pi_id, pd_whcode);
|
|
|
+ CommonUtil.showErrorToast(volleyError);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Map<String, String> getParams() throws AuthFailureError {
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ params.put("id", pi_id);
|
|
|
+ params.put("whcode", pd_whcode);
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ stringRequestPost.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ stringRequestPost.setTag(TAG);
|
|
|
+ PdaApplication.mRequestQueue.add(stringRequestPost);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取材料未采集列表
|
|
|
+ *
|
|
|
+ * @param pi_id
|
|
|
+ * @param pd_whcode
|
|
|
+ */
|
|
|
+ private void getCollectNotListOnline(String pi_id, String pd_whcode) {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = GloableParams.ADDRESS_OUT_NEED_GET_LIST + "?id=" + pi_id + "&whcode=" + pd_whcode + "&type=" + mProdOutType;
|
|
|
+
|
|
|
+ PdaApplication.mRequestQueue.cancelAll(TAG + "online");
|
|
|
+
|
|
|
+ jsonRequest = new JsonObjectRequest(Request.Method.GET, url, null,
|
|
|
+ new Response.Listener<JSONObject>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(JSONObject jsonObject) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ if (!"success".equals(jsonObject.getJSONObject("data").optString("message"))) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), jsonObject.getJSONObject("data").optString("message"));
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("data");
|
|
|
+ LogUtil.i("jsonArray", jsonArray.toString());
|
|
|
+ if (jsonArray != null) {
|
|
|
+ List<TableLPRODIONEEDGET> lprodioneedgetList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
+ LogUtil.i("jsonObject", jsonArray.get(i).toString());
|
|
|
+
|
|
|
+ JSONObject notCollectObject = jsonArray.getJSONObject(i);
|
|
|
+ TableLPRODIONEEDGET lprodioneedget = new TableLPRODIONEEDGET();
|
|
|
+ lprodioneedget.setLPN_PRODCODE(notCollectObject.optString("PD_PRODCODE"));
|
|
|
+ lprodioneedget.setLPN_RESTQTY(notCollectObject.optDouble("PD_RESTQTY"));
|
|
|
+ lprodioneedget.setLPN_PRDETAIL(notCollectObject.optString("PR_DETAIL"));
|
|
|
+ lprodioneedget.setLPN_PRSPEC(JsonUtils.optStringNotNull(notCollectObject, "PR_SPEC"));
|
|
|
+ lprodioneedget.setLPN_ZXBZS(notCollectObject.optDouble("PR_ZXBZS"));
|
|
|
+
|
|
|
+ lprodioneedget.setLPN_IFBARCODECHECK("");
|
|
|
+
|
|
|
+ lprodioneedget.setLPN_PIID(notCollectObject.optInt("PD_PIID"));
|
|
|
+ lprodioneedget.setLPN_INOUTNO(notCollectObject.optString("PD_INOUTNO"));
|
|
|
+ lprodioneedget.setLPN_WHCODE(notCollectObject.optString("PD_WHCODE"));
|
|
|
+ lprodioneedget.setLPN_PRID(notCollectObject.optInt("PR_ID"));
|
|
|
+ lprodioneedget.setLPN_BATCHCODE(notCollectObject.optString("PD_BATCHCODE"));
|
|
|
+
|
|
|
+ lprodioneedget.setInOrOut("out");
|
|
|
+ lprodioneedget.setLPN_ORDERCODE("");
|
|
|
+ lprodioneedget.setLPN_TRACEKIND(-1);
|
|
|
+
|
|
|
+ lprodioneedgetList.add(lprodioneedget);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (mDbManager.getDb().isOpen()) {
|
|
|
+ mDbManager.deleteInOrOutProductWaitCollect("out");
|
|
|
+ mDbManager.saveListToProductWaitCollect(lprodioneedgetList);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new Response.ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError volleyError) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.showErrorToast(volleyError);
|
|
|
+ }
|
|
|
+ }) {
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
+ return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
|
|
|
+ if (response.data == null || response.data.length == 0) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ try {
|
|
|
+ jsonObject.put("msg", "成功:服务器无返回");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return Response.success(jsonObject, HttpHeaderParser.parseCacheHeaders(response));
|
|
|
+ } else {
|
|
|
+ return super.parseNetworkResponse(response);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
|
|
|
+ jsonRequest.setTag(TAG + "online");
|
|
|
+ PdaApplication.mRequestQueue.add(jsonRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void clickToFragment(BaseFragment baseFragment) {
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString("pi_id", pi_id);
|
|
|
+ bundle.putString("pi_inoutno", pi_inoutno);
|
|
|
+ bundle.putString("pd_whcode", pd_whcode);
|
|
|
+ bundle.putString("whichpage", "materialout");
|
|
|
+ bundle.putBoolean("isMultiple", isMultiple);
|
|
|
+ if (mCollectModel == 1) {
|
|
|
+ bundle.putInt("modeType", 3);
|
|
|
+ } else if (mCollectModel == 0) {
|
|
|
+ bundle.putInt("modeType", 2);
|
|
|
+ }
|
|
|
+ mFragment = baseFragment;
|
|
|
+ mFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(this, mFragment);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closeListPopupWindow() {
|
|
|
+ if (listPopupWindow != null) {
|
|
|
+ listPopupWindow.dismiss();
|
|
|
+ listPopupWindow = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closeSplitPopupWindow() {
|
|
|
+ if (splitPop != null) {
|
|
|
+ splitPop.dismiss();
|
|
|
+ splitPop = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closePopupWindow() {
|
|
|
+ if (popupWindow != null) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ popupWindow = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清除所有信息
|
|
|
+ */
|
|
|
+ private void clearAll() {
|
|
|
+ //清空输入框
|
|
|
+ etBarCode.setText("");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroyView() {
|
|
|
+ super.onDestroyView();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ ((FunctionActivity) getActivity()).setScanIvVisible(false);
|
|
|
+ ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(getString(R.string.out_management));
|
|
|
+ mDbManager.closeDB();
|
|
|
+ CommonUtil.closeKeybord(((EditText) etBarCode), mActivity);
|
|
|
+ ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterial();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 其返回一个布尔值;意思是,如果对返回事件进行了处理就返回TRUE,如果不做处理就返回FALSE,让上层进行处理。
|
|
|
+ *
|
|
|
+ * @return 是否交与activity处理返回事件
|
|
|
+ */
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ List<TableLBARCODEIO> allBarcodeIo = new ArrayList<>();
|
|
|
+ if (mDbManager == null || !mDbManager.getDb().isOpen()) {
|
|
|
+ mDbManager = new DBManager(PdaApplication.getmContext());
|
|
|
+ }
|
|
|
+ allBarcodeIo = mDbManager.queryFromBarcodeIo(new String[]{"out", pi_inoutno, pd_whcode}, "inOrOut=? and LBI_INOUTNO=? and LBI_WHCODE=?");
|
|
|
+ if (allBarcodeIo != null && allBarcodeIo.size() != 0) {
|
|
|
+ final List<TableLBARCODEIO> finalAllBarcodeIo = allBarcodeIo;
|
|
|
+ new android.app.AlertDialog.Builder(getActivity())
|
|
|
+ .setTitle("提示")
|
|
|
+ .setMessage("存在未提交的离线采集数据,点击上传将把未提交数据上传,点击取消将清空未采集数据")
|
|
|
+ .setPositiveButton("上传", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ if (CommonUtil.isNetWorkConnected(getActivity())) {
|
|
|
+ submitOfflineData(finalAllBarcodeIo, true);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ dialog.dismiss();
|
|
|
+ try {
|
|
|
+ mDbManager.deleteListFromBarcodeIo(finalAllBarcodeIo);
|
|
|
+ List<TableLPRODIONEEDGET> allLprodioneedgets = mDbManager.queryFromProductWaitCollect(new String[]{"out"}, "inOrOut=? ");
|
|
|
+ if (allLprodioneedgets != null) {
|
|
|
+ for (int j = 0; j < finalAllBarcodeIo.size(); j++) {
|
|
|
+ TableLBARCODEIO deleteLbarcodeio = finalAllBarcodeIo.get(j);
|
|
|
+ for (int i = 0; i < allLprodioneedgets.size(); i++) {
|
|
|
+ TableLPRODIONEEDGET tableLPRODIONEEDGET = allLprodioneedgets.get(i);
|
|
|
+ if (tableLPRODIONEEDGET.getLPN_PIID() == deleteLbarcodeio.getLBI_PIID()
|
|
|
+ && tableLPRODIONEEDGET.getLPN_WHCODE().equals(deleteLbarcodeio.getLBI_WHCODE())
|
|
|
+ // && tableLPRODIONEEDGET.getLPN_PRODCODE().equals(deleteLbarcodeio.getLBI_PRODCODE())
|
|
|
+ ) {
|
|
|
+ tableLPRODIONEEDGET.setLPN_RESTQTY(CommonUtil.doubleAddition(tableLPRODIONEEDGET.getLPN_RESTQTY(), deleteLbarcodeio.getLBI_INQTY()));
|
|
|
+ mDbManager.updateProductWaitCollect(tableLPRODIONEEDGET);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "清除数据成功");
|
|
|
+ getActivity().getSupportFragmentManager().popBackStack();
|
|
|
+ } catch (Exception e) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "清除失败");
|
|
|
+ getActivity().getSupportFragmentManager().popBackStack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).show();
|
|
|
+ // ((FunctionActivity) getActivity()).fragment = new MaterialStorageFragment();
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class IpAndResourcesPortAdapter extends BaseQuickAdapter<ComDataBean, BaseViewHolder> {
|
|
|
+ private List<ComDataBean> mmmmList;
|
|
|
+
|
|
|
+ public List<ComDataBean> getmList() {
|
|
|
+ return mmmmList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setmList(List<ComDataBean> mList) {
|
|
|
+ this.mmmmList = mList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ComDataBean getBeanByPositon(int position) {
|
|
|
+ return mmmmList.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ private IpAndResourcesPortAdapter(@Nullable List<ComDataBean> data) {
|
|
|
+ super(R.layout.fuzzy_ipandport_item, data);
|
|
|
+ this.mmmmList = data;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void convert(BaseViewHolder helper, ComDataBean item) {
|
|
|
+ helper.setText(R.id.macode_ip__Tv, item.getItemremark() + "-(" + item.getItemName() + ")");
|
|
|
+ LinearLayout line_true = helper.itemView.findViewById(R.id.line_true);
|
|
|
+ if (item.getChecked()) {
|
|
|
+ line_true.setSelected(true);
|
|
|
+ } else {
|
|
|
+ line_true.setSelected(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class ComDataBean {
|
|
|
+ String itemName = null;
|
|
|
+ String itemremark = null;
|
|
|
+ boolean Checked;
|
|
|
+
|
|
|
+ public boolean getChecked() {
|
|
|
+ return Checked;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setChecked(boolean checked) {
|
|
|
+ Checked = checked;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getItemName() {
|
|
|
+ return itemName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setItemName(String itemName) {
|
|
|
+ this.itemName = itemName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getItemremark() {
|
|
|
+ return itemremark;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setItemremark(String itemremark) {
|
|
|
+ this.itemremark = itemremark;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|