|
@@ -0,0 +1,800 @@
|
|
|
+package com.uas.pda_smart_com.fragment;
|
|
|
+
|
|
|
+import android.app.Activity;
|
|
|
+import android.app.Dialog;
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
+import android.support.v7.app.AlertDialog;
|
|
|
+import android.text.SpannableStringBuilder;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.Button;
|
|
|
+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.ScrollView;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.android.volley.toolbox.StringRequest;
|
|
|
+import com.uas.pda_smart_com.R;
|
|
|
+import com.uas.pda_smart_com.activity.FunctionActivity;
|
|
|
+import com.uas.pda_smart_com.adapter.CaptionValueItemAdapter;
|
|
|
+import com.uas.pda_smart_com.adapter.WarehouseCacheAdapter;
|
|
|
+import com.uas.pda_smart_com.bean.CaptionValueBean;
|
|
|
+import com.uas.pda_smart_com.bean.WarehouseCacheBean;
|
|
|
+import com.uas.pda_smart_com.global.GloableParams;
|
|
|
+import com.uas.pda_smart_com.tools.SharedPreUtil;
|
|
|
+import com.uas.pda_smart_com.util.CameraUtil;
|
|
|
+import com.uas.pda_smart_com.util.CommonUtil;
|
|
|
+import com.uas.pda_smart_com.util.Constants;
|
|
|
+import com.uas.pda_smart_com.util.FastjsonUtil;
|
|
|
+import com.uas.pda_smart_com.util.FragmentUtils;
|
|
|
+import com.uas.pda_smart_com.util.HttpCallback;
|
|
|
+import com.uas.pda_smart_com.util.HttpParams;
|
|
|
+import com.uas.pda_smart_com.util.SpanUtils;
|
|
|
+import com.uas.pda_smart_com.util.VolleyRequest;
|
|
|
+import com.uas.pda_smart_com.view.ClearableEditText;
|
|
|
+import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
+import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author RaoMeng
|
|
|
+ * @describe 入库管理-IQC检验页面
|
|
|
+ * @date 2018/4/22 17:14
|
|
|
+ */
|
|
|
+
|
|
|
+public class StorageTwoIQCInFragment extends BaseFragment implements View.OnClickListener, HttpCallback {
|
|
|
+ private static final int SCAN_BARCODE_CODE = 113;
|
|
|
+ private static final int FLAG_GET_BARCODE = 0x06;
|
|
|
+ private static final int FLAG_IQC_IN = 0x07;
|
|
|
+
|
|
|
+ private int mFocusId;
|
|
|
+ private ClearableEditText mBarcodeEditText;
|
|
|
+ private Button mMenuButton, mCommitButton;
|
|
|
+ private ImageView mScanImageView, mGoodImageView, mBadImageView;
|
|
|
+ private ListView mDataListView, mWarehouseListView;
|
|
|
+ private TextView mErrorTextView, mGoodEditText, mBadEditText;
|
|
|
+ private ScrollView mErrorScrollView;
|
|
|
+ private LinearLayout mDataLinearLayout;
|
|
|
+ private List<CaptionValueBean> mCaptionValueBeans;
|
|
|
+ private CaptionValueItemAdapter mCaptionValueItemAdapter;
|
|
|
+ private String mGoodWarehouse = "", mBadWarehouse = "";
|
|
|
+ private Dialog mWarehouseDialog;
|
|
|
+ private List<WarehouseCacheBean> mWarehouseCacheBeans;
|
|
|
+ private WarehouseCacheAdapter mWarehouseCacheAdapter;
|
|
|
+ private View mPopView;
|
|
|
+ private int mVeId = 0;
|
|
|
+ private String text_rb= "合格";
|
|
|
+
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private PopupWindow mMenuPopupWindow;
|
|
|
+ private Fragment mFragment;
|
|
|
+ private SpanUtils mSpanUtils;
|
|
|
+ private double mOkQty;
|
|
|
+ private TextView tv_barcode;
|
|
|
+ private TextView tv_veCode;
|
|
|
+ private TextView tv_vadCode;
|
|
|
+ private TextView tv_prodcode;
|
|
|
+ private TextView tv_prDetail;
|
|
|
+ private TextView tv_prSpec;
|
|
|
+ private TextView tv_veOrderCode;
|
|
|
+ private TextView tv_veOrderNo;
|
|
|
+ private TextView tv_veVendName;
|
|
|
+ private TextView tv_testMethod;
|
|
|
+ private TextView tv_testResult;
|
|
|
+ private TextView tv_vadQty;
|
|
|
+ private TextView tv_checkQty;
|
|
|
+ private TextView tv_mOkQty;
|
|
|
+ private TextView tv_ngQty;
|
|
|
+ private TextView tv_status;
|
|
|
+ private RadioGroup rg_yesorno;
|
|
|
+ private RadioButton rb_yse;
|
|
|
+ private RadioButton rb_no;
|
|
|
+ private Button btn_shen;
|
|
|
+ private String datastring;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroyView() {
|
|
|
+ super.onDestroyView();
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ CommonUtil.closeKeybord(mBarcodeEditText, mActivity);
|
|
|
+ ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(getString(R.string.title_storage_in));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_two_storage_iqc_in;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ FunctionActivity.setTitle(getString(R.string.title_storage_iqc));
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
|
|
|
+
|
|
|
+ mMenuButton = (Button) mActivity.findViewById(R.id.btn_actionbar_more);
|
|
|
+ mBarcodeEditText = (ClearableEditText) root.findViewById(R.id.storage_iqc_collect_et);
|
|
|
+ mBarcodeEditText.requestFocus();
|
|
|
+ mScanImageView = (ImageView) root.findViewById(R.id.storage_iqc_scan_iv);
|
|
|
+
|
|
|
+ mCommitButton = (Button) root.findViewById(R.id.storage_iqc_in_commit_btn);
|
|
|
+ mDataLinearLayout = (LinearLayout) root.findViewById(R.id.storage_iqc_in_data_ll);
|
|
|
+ mDataListView = (ListView) root.findViewById(R.id.storage_iqc_in_data_lv);
|
|
|
+ mGoodEditText = (TextView) root.findViewById(R.id.storage_iqc_good_warehouse_et);
|
|
|
+ mBadEditText = (TextView) root.findViewById(R.id.storage_iqc_bad_warehouse_et);
|
|
|
+ mGoodImageView = (ImageView) root.findViewById(R.id.storage_iqc_good_warehouse_iv);
|
|
|
+ mBadImageView = (ImageView) root.findViewById(R.id.storage_iqc_bad_warehouse_iv);
|
|
|
+ mErrorTextView = (TextView) root.findViewById(R.id.storage_iqc_in_error_tv);
|
|
|
+ mErrorScrollView = (ScrollView) root.findViewById(R.id.storage_iqc_in_error_sv);
|
|
|
+
|
|
|
+ tv_barcode = root.findViewById(R.id.tv_barcode);
|
|
|
+ tv_veCode = root.findViewById(R.id.tv_veCode);
|
|
|
+ tv_vadCode = root.findViewById(R.id.tv_vadCode);
|
|
|
+ tv_prodcode = root.findViewById(R.id.tv_prodcode);
|
|
|
+ tv_prDetail = root.findViewById(R.id.tv_prDetail);
|
|
|
+ tv_prSpec = root.findViewById(R.id.tv_prSpec);
|
|
|
+ tv_veOrderCode = root.findViewById(R.id.tv_veOrderCode);
|
|
|
+ tv_veOrderNo = root.findViewById(R.id.tv_veOrderNo);
|
|
|
+ tv_veVendName = root.findViewById(R.id.tv_veVendName);
|
|
|
+ tv_testMethod = root.findViewById(R.id.tv_testMethod);
|
|
|
+ tv_testResult = root.findViewById(R.id.tv_testResult);
|
|
|
+ tv_vadQty = root.findViewById(R.id.tv_vadQty);
|
|
|
+ tv_checkQty = root.findViewById(R.id.tv_checkQty);
|
|
|
+ tv_mOkQty = root.findViewById(R.id.tv_mOkQty);
|
|
|
+ tv_ngQty = root.findViewById(R.id.tv_ngQty);
|
|
|
+ tv_status = root.findViewById(R.id.tv_status);
|
|
|
+ rg_yesorno = root.findViewById(R.id.rg_yesorno);
|
|
|
+ rb_yse = root.findViewById(R.id.rb_yse);
|
|
|
+ rb_no = root.findViewById(R.id.rb_no);
|
|
|
+ btn_shen = root.findViewById(R.id.btn_shen);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ mCaptionValueBeans = new ArrayList<>();
|
|
|
+ mCaptionValueItemAdapter = new CaptionValueItemAdapter(mActivity, mCaptionValueBeans);
|
|
|
+ mDataListView.setAdapter(mCaptionValueItemAdapter);
|
|
|
+
|
|
|
+ mPopView = View.inflate(mActivity, R.layout.pop_ip_history, null);
|
|
|
+ mWarehouseListView = (ListView) mPopView.findViewById(R.id.pop_ip_history_lv);
|
|
|
+ mWarehouseCacheBeans = new ArrayList<>();
|
|
|
+ mWarehouseCacheAdapter = new WarehouseCacheAdapter(mActivity, mWarehouseCacheBeans);
|
|
|
+ mWarehouseListView.setAdapter(mWarehouseCacheAdapter);
|
|
|
+ mWarehouseDialog = new AlertDialog.Builder(mActivity).setView(mPopView).create();
|
|
|
+
|
|
|
+ initPopupWindow();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ mMenuButton.setOnClickListener(this);
|
|
|
+ mScanImageView.setOnClickListener(this);
|
|
|
+// mBadImageView.setOnClickListener(this);
|
|
|
+// mBadEditText.setOnClickListener(this);
|
|
|
+ mGoodImageView.setOnClickListener(this);
|
|
|
+ mGoodEditText.setOnClickListener(this);
|
|
|
+ mCommitButton.setOnClickListener(this);
|
|
|
+
|
|
|
+ mBarcodeEditText.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 barcode = mBarcodeEditText.getText().toString().trim();
|
|
|
+ getDataByBarcode(barcode);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ rg_yesorno.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
|
+ if (checkedId == R.id.rb_yse) {
|
|
|
+ text_rb="合格";
|
|
|
+ } else if (checkedId == R.id.rb_no) {
|
|
|
+ text_rb="不合格";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ btn_shen.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ new AlertDialog.Builder(mActivity)
|
|
|
+ .setMessage("确定是否是要审核")
|
|
|
+ .setPositiveButton("是", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ Yessehn();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton("否", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ dialog.dismiss();
|
|
|
+ }
|
|
|
+ }).create().show();
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ private static final int FLAG_UPDATEANDINQTY = 0x05;
|
|
|
+ public void Yessehn(){
|
|
|
+ if (mVeId == 0) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "单据id获取失败,请重新获取条码信息");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(mGoodWarehouse) && mOkQty > 0) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "该检验单存在合格数,良品仓必填\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_DOCUMENTLIBRARY_AUTIQC)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .tag(TAG + "updateandinqty")
|
|
|
+ .flag(FLAG_UPDATEANDINQTY)
|
|
|
+ .addParam("ve_id", mVeId+"")
|
|
|
+ .addParam("ve_result", text_rb)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ datastring = FastjsonUtil.getText(resultObject, "data");
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, datastring);
|
|
|
+// mDataLinearLayout.setVisibility(View.GONE);
|
|
|
+// mErrorScrollView.setVisibility(View.VISIBLE);
|
|
|
+ if (!CommonUtil.isNetWorkConnected(mActivity)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, mActivity.getString(R.string.net_not_connect));
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (!CommonUtil.isRepeatClick()) {
|
|
|
+
|
|
|
+ hideAllViews();
|
|
|
+ YessehnSTORAGE();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public void YessehnSTORAGE(){
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_TURNPURCBARCODE)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .flag(FLAG_IQC_IN)
|
|
|
+ .tag(TAG + "turnQc")
|
|
|
+ .addParam("ve_id", mVeId + "")
|
|
|
+ .addParam("okwh", mGoodWarehouse)
|
|
|
+ .addParam("ngwh", mBadWarehouse)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ try {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ Log.e("dataObject===",dataObject.toString());
|
|
|
+ if (dataObject != null) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "入库单"+FastjsonUtil.getText(dataObject, "okNO")+"生成成功");
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ // mBadWarehouse = SharedPreUtil.getString(mActivity
|
|
|
+// , Constants.FLAG.CACHE_DEFAULT_REJECTS_WAREHOUSE + CommonUtil.getUserName(mActivity), null);
|
|
|
+
|
|
|
+ mSpanUtils = new SpanUtils();
|
|
|
+ SpannableStringBuilder badWareHouse = mSpanUtils.append("IQC").setForegroundColor(Color.BLACK)
|
|
|
+ .append("(IQC判退仓)").setForegroundColor(Color.GRAY).create();
|
|
|
+ mBadWarehouse = "IQC";
|
|
|
+ mGoodEditText.setText(mGoodWarehouse);
|
|
|
+ mBadEditText.setText(badWareHouse);
|
|
|
+
|
|
|
+ String allWarehouse = SharedPreUtil.getString(mActivity, Constants.FLAG.ALL_WAREHOUSE_CACHE, null);
|
|
|
+ try {
|
|
|
+ JSONArray warehouseArray = JSON.parseArray(allWarehouse);
|
|
|
+ if (warehouseArray != null) {
|
|
|
+ for (int i = 0; i < warehouseArray.size(); i++) {
|
|
|
+ JSONObject warehouseObject = warehouseArray.getJSONObject(i);
|
|
|
+ if (warehouseObject != null) {
|
|
|
+ WarehouseCacheBean warehouseCacheBean = new WarehouseCacheBean();
|
|
|
+ warehouseCacheBean.setWhcode(FastjsonUtil.getText(warehouseObject, "WH_CODE"));
|
|
|
+ warehouseCacheBean.setDescription(FastjsonUtil.getText(warehouseObject, "WH_DESCRIPTION"));
|
|
|
+
|
|
|
+ mWarehouseCacheBeans.add(warehouseCacheBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mWarehouseCacheAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private CaptionValueBean createItem(String caption, String value, int color) {
|
|
|
+ CaptionValueBean captionValueBean = new CaptionValueBean();
|
|
|
+ captionValueBean.setCaption(caption);
|
|
|
+ captionValueBean.setValue(value);
|
|
|
+ captionValueBean.setColor(color);
|
|
|
+
|
|
|
+ return captionValueBean;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initPopupWindow() {
|
|
|
+ View view = View.inflate(getActivity(), R.layout.pop_storage_iqc_in_menu, null);
|
|
|
+
|
|
|
+ Button doneButton = (Button) view.findViewById(R.id.pop_storage_iqc_in_menu_1);
|
|
|
+ Button todoButton = (Button) view.findViewById(R.id.pop_storage_iqc_in_menu_2);
|
|
|
+
|
|
|
+ mFragment = new StorageIQCInListFragment();
|
|
|
+
|
|
|
+ doneButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeMenuPopupWindow();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.FLAG.FLAG_IQC_IN_CALLER, "VerifyApplyDetail!Have");
|
|
|
+ mFragment.setArguments(bundle);
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ FragmentUtils.switchFragment(StorageTwoIQCInFragment.this, mFragment);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ todoButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeMenuPopupWindow();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.FLAG.FLAG_IQC_IN_CALLER, "VerifyApplyDetail!Need");
|
|
|
+ mFragment.setArguments(bundle);
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ FragmentUtils.switchFragment(StorageTwoIQCInFragment.this, mFragment);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mMenuPopupWindow = new PopupWindow(view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ mMenuPopupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ mMenuPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeMenuPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closeMenuPopupWindow() {
|
|
|
+ if (mMenuPopupWindow != null) {
|
|
|
+ mMenuPopupWindow.dismiss();
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (!hidden) {
|
|
|
+ FunctionActivity.setTitle(getString(R.string.title_storage_iqc));
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ switch (v.getId()) {
|
|
|
+ case R.id.storage_iqc_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, "请选择您要操作的输入框");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case R.id.btn_actionbar_more:
|
|
|
+ CommonUtil.setBackgroundAlpha(getActivity(), 0.5f);
|
|
|
+ mMenuPopupWindow.showAsDropDown(mMenuButton);
|
|
|
+ break;
|
|
|
+ case R.id.storage_iqc_good_warehouse_iv:
|
|
|
+ case R.id.storage_iqc_good_warehouse_et:
|
|
|
+ if (mWarehouseCacheBeans.size() == 0) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "仓库列表获取失败,请重新登录获取数据");
|
|
|
+ } else {
|
|
|
+ mWarehouseListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ WarehouseCacheBean warehouseCacheBean = mWarehouseCacheBeans.get(position);
|
|
|
+ String whcode = warehouseCacheBean.getWhcode();
|
|
|
+ String description = warehouseCacheBean.getDescription();
|
|
|
+
|
|
|
+ mGoodWarehouse = whcode;
|
|
|
+ SharedPreUtil.saveString(mActivity
|
|
|
+ , Constants.FLAG.IQC_GOOD_WAREHOUSE_CACHE + CommonUtil.getUserName(mActivity), mGoodWarehouse);
|
|
|
+
|
|
|
+ mSpanUtils = new SpanUtils();
|
|
|
+ SpannableStringBuilder result = mSpanUtils.append(whcode).setForegroundColor(Color.BLACK).append("(" + description + ")").setForegroundColor(Color.GRAY).create();
|
|
|
+
|
|
|
+ mGoodEditText.setText(result);
|
|
|
+
|
|
|
+ if (mWarehouseDialog != null) {
|
|
|
+ mWarehouseDialog.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mWarehouseDialog.show();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case R.id.storage_iqc_bad_warehouse_iv:
|
|
|
+ case R.id.storage_iqc_bad_warehouse_et:
|
|
|
+ if (mWarehouseCacheBeans.size() == 0) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "仓库列表获取失败,请重新登录获取数据");
|
|
|
+ } else {
|
|
|
+ mWarehouseListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ WarehouseCacheBean warehouseCacheBean = mWarehouseCacheBeans.get(position);
|
|
|
+ mBadEditText.setText(warehouseCacheBean.getWhcode());
|
|
|
+
|
|
|
+ if (mWarehouseDialog != null) {
|
|
|
+ mWarehouseDialog.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mWarehouseDialog.show();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case R.id.storage_iqc_in_commit_btn:
|
|
|
+ if (!CommonUtil.isNetWorkConnected(mActivity)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, mActivity.getString(R.string.net_not_connect));
|
|
|
+ } else {
|
|
|
+ if (mVeId == 0) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "单据id获取失败,请重新获取条码信息");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!CommonUtil.isRepeatClick()) {
|
|
|
+ String good = mGoodEditText.getText().toString().trim();
|
|
|
+ String bad = mBadEditText.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(mGoodWarehouse) && mOkQty > 0) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "该检验单存在合格数,良品仓必填\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ hideAllViews();
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_IQC_TURN_PURC_STORAGE)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .flag(FLAG_IQC_IN)
|
|
|
+ .tag(TAG + "turnQc")
|
|
|
+ .addParam("ve_id", mVeId + "")
|
|
|
+ .addParam("okwh", mGoodWarehouse)
|
|
|
+ .addParam("ngwh", mBadWarehouse)
|
|
|
+ .build(), this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSuccess(final int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ switch (flag) {
|
|
|
+ case FLAG_GET_BARCODE:
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ try {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ mVeId = FastjsonUtil.getInt(dataObject, "VE_ID");
|
|
|
+ String barcode = FastjsonUtil.getText(dataObject, "barcode");
|
|
|
+ String veCode = FastjsonUtil.getText(dataObject, "VE_CODE");
|
|
|
+ String vadCode = FastjsonUtil.getText(dataObject, "VAD_CODE");
|
|
|
+ String prodcode = FastjsonUtil.getText(dataObject, "VAD_PRODCODE");
|
|
|
+ String prDetail = FastjsonUtil.getText(dataObject, "PR_DETAIL");
|
|
|
+ String prSpec = FastjsonUtil.getText(dataObject, "PR_SPEC");
|
|
|
+ String veOrderCode = FastjsonUtil.getText(dataObject, "VE_ORDERCODE");
|
|
|
+ String veOrderNo = FastjsonUtil.getText(dataObject, "VE_ORDERDETNO");
|
|
|
+ String veVendName = FastjsonUtil.getText(dataObject, "VAD_VENDNAME");
|
|
|
+ String testMethod = FastjsonUtil.getText(dataObject, "VE_METHOD");
|
|
|
+ String testResult = FastjsonUtil.getText(dataObject, "VE_RESULT");
|
|
|
+ String vadQty = FastjsonUtil.getText(dataObject, "VAD_QTY");
|
|
|
+ String checkQty = FastjsonUtil.getText(dataObject, "CHECKQTY");
|
|
|
+ mOkQty = FastjsonUtil.getDouble(dataObject, "OKQTY");
|
|
|
+ String ngQty = FastjsonUtil.getText(dataObject, "NGQTY");
|
|
|
+ String status = FastjsonUtil.getText(dataObject, "VE_STATUS");
|
|
|
+ String goodWhcode = FastjsonUtil.getText(dataObject, "DEFAULTWHCODE");
|
|
|
+ String goodWhname = FastjsonUtil.getText(dataObject, "DEFAULTWHNAME");
|
|
|
+ String vad_whcode = FastjsonUtil.getText(dataObject, "vad_whcode");
|
|
|
+ mGoodWarehouse = vad_whcode;
|
|
|
+ mGoodEditText.setText(mGoodWarehouse);
|
|
|
+ tv_barcode.setText(barcode);
|
|
|
+ tv_veCode.setText(veCode);
|
|
|
+ tv_vadCode.setText(vadCode);
|
|
|
+ tv_prodcode.setText(prodcode);
|
|
|
+ tv_prDetail.setText(prDetail);
|
|
|
+ tv_prSpec.setText(prSpec);
|
|
|
+ tv_veOrderCode.setText(veOrderCode);
|
|
|
+ tv_veOrderNo.setText(veOrderNo);
|
|
|
+ tv_veVendName.setText(veVendName);
|
|
|
+ tv_testMethod.setText(testMethod);
|
|
|
+ tv_vadQty.setText(vadQty);
|
|
|
+ tv_checkQty.setText(checkQty);
|
|
|
+ tv_mOkQty.setText(mOkQty+"");
|
|
|
+ tv_ngQty.setText(ngQty);
|
|
|
+ tv_status.setText(status);
|
|
|
+ }
|
|
|
+ mErrorScrollView.setVisibility(View.GONE);
|
|
|
+ mDataLinearLayout.setVisibility(View.VISIBLE);
|
|
|
+// analysisGetBarcode(result);
|
|
|
+ } catch (Exception e) {
|
|
|
+ mDataLinearLayout.setVisibility(View.GONE);
|
|
|
+ mErrorTextView.setText("条码数据获取异常,请重新获取");
|
|
|
+ mErrorScrollView.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case FLAG_IQC_IN:
|
|
|
+ try {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ Log.e("dataObject===",dataObject.toString());
|
|
|
+ if (dataObject != null) {
|
|
|
+ final JSONObject okNoObject = dataObject.getJSONObject("okNO");
|
|
|
+ if (okNoObject == null) {
|
|
|
+ mErrorScrollView.setVisibility(View.VISIBLE);
|
|
|
+ mErrorTextView.setText("不良品入库成功\n单号:" + FastjsonUtil.getText(dataObject, "ngNO"));
|
|
|
+ } else {
|
|
|
+ mErrorScrollView.setVisibility(View.GONE);
|
|
|
+ mDataLinearLayout.setVisibility(View.GONE);
|
|
|
+ String ngNO = FastjsonUtil.getText(dataObject, "ngNO");
|
|
|
+ String message = "验收成功\n"
|
|
|
+ + "单号:" + FastjsonUtil.getText(okNoObject, "PI_INOUTNO");
|
|
|
+ if (!TextUtils.isEmpty(ngNO)) {
|
|
|
+ message += "\n不良品入库成功\n单号:" + ngNO;
|
|
|
+ }
|
|
|
+ message += "\n是否进行条码入库采集?";
|
|
|
+ new AlertDialog.Builder(mActivity)
|
|
|
+ .setMessage(message)
|
|
|
+ .setPositiveButton("是", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ if (!CommonUtil.isRepeatClick()) {
|
|
|
+ dialog.dismiss();
|
|
|
+ Fragment fragment = new MaterialInCollectFragment();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.FLAG.FLAG_IQC_IN_JSON, okNoObject.toJSONString());
|
|
|
+
|
|
|
+ fragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(StorageTwoIQCInFragment.this, fragment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton("否", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ dialog.dismiss();
|
|
|
+ }
|
|
|
+ }).create().show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+
|
|
|
+ switch (flag) {
|
|
|
+ case FLAG_GET_BARCODE:
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ progressDialog.dismiss();
|
|
|
+ mDataLinearLayout.setVisibility(View.GONE);
|
|
|
+ mErrorTextView.setText(failStr);
|
|
|
+ mErrorScrollView.setVisibility(View.VISIBLE);
|
|
|
+ break;
|
|
|
+ case FLAG_IQC_IN:
|
|
|
+ progressDialog.dismiss();
|
|
|
+ mErrorTextView.setText(failStr);
|
|
|
+ mErrorScrollView.setVisibility(View.VISIBLE);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void analysisGetBarcode(String result) {
|
|
|
+ Log.d("iqcBarcode", result);
|
|
|
+ try {
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ String barcode;
|
|
|
+ String veCode;
|
|
|
+ String vadCode;
|
|
|
+ String prodcode;
|
|
|
+ String prDetail;
|
|
|
+ String prSpec;
|
|
|
+ String veOrderCode;
|
|
|
+ String veOrderNo;
|
|
|
+ String veVendName;
|
|
|
+ String testMethod;
|
|
|
+ String testResult;
|
|
|
+ String vadQty;
|
|
|
+ String checkQty;
|
|
|
+ String ngQty;
|
|
|
+ String status;
|
|
|
+ String goodWhcode;
|
|
|
+ String goodWhname;
|
|
|
+
|
|
|
+ mVeId = FastjsonUtil.getInt(dataObject, "VE_ID");
|
|
|
+ barcode = FastjsonUtil.getText(dataObject, "barcode");
|
|
|
+ veCode = FastjsonUtil.getText(dataObject, "VE_CODE");
|
|
|
+ vadCode = FastjsonUtil.getText(dataObject, "VAD_CODE");
|
|
|
+ prodcode = FastjsonUtil.getText(dataObject, "VAD_PRODCODE");
|
|
|
+ prDetail = FastjsonUtil.getText(dataObject, "PR_DETAIL");
|
|
|
+ prSpec = FastjsonUtil.getText(dataObject, "PR_SPEC");
|
|
|
+ veOrderCode = FastjsonUtil.getText(dataObject, "VE_ORDERCODE");
|
|
|
+ veOrderNo = FastjsonUtil.getText(dataObject, "VE_ORDERDETNO");
|
|
|
+ veVendName = FastjsonUtil.getText(dataObject, "VAD_VENDNAME");
|
|
|
+ testMethod = FastjsonUtil.getText(dataObject, "VE_METHOD");
|
|
|
+ testResult = FastjsonUtil.getText(dataObject, "VE_RESULT");
|
|
|
+ vadQty = FastjsonUtil.getText(dataObject, "VAD_QTY");
|
|
|
+ checkQty = FastjsonUtil.getText(dataObject, "CHECKQTY");
|
|
|
+ mOkQty = FastjsonUtil.getDouble(dataObject, "OKQTY");
|
|
|
+ ngQty = FastjsonUtil.getText(dataObject, "NGQTY");
|
|
|
+ status = FastjsonUtil.getText(dataObject, "VE_STATUS");
|
|
|
+ goodWhcode = FastjsonUtil.getText(dataObject, "DEFAULTWHCODE");
|
|
|
+ goodWhname = FastjsonUtil.getText(dataObject, "DEFAULTWHNAME");
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(goodWhcode)) {
|
|
|
+ mGoodWarehouse = SharedPreUtil.getString(mActivity
|
|
|
+ , Constants.FLAG.IQC_GOOD_WAREHOUSE_CACHE + CommonUtil.getUserName(mActivity), null);
|
|
|
+ } else {
|
|
|
+ mGoodWarehouse = goodWhcode;
|
|
|
+ }
|
|
|
+ mSpanUtils = new SpanUtils();
|
|
|
+ SpannableStringBuilder goodWareHouse = mSpanUtils.append(goodWhcode).setForegroundColor(Color.BLACK)
|
|
|
+ .append(TextUtils.isEmpty(goodWhname) ? "" : ("(" + goodWhname + ")")).setForegroundColor(Color.GRAY).create();
|
|
|
+ mGoodEditText.setText(goodWareHouse);
|
|
|
+
|
|
|
+ mCaptionValueBeans.add(createItem("条码号", barcode, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("检验单号", veCode, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("收料单号", vadCode, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("物料编号", prodcode, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("物料名称", prDetail, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("物料规格", prSpec, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("采购单", veOrderCode, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("序号", veOrderNo, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("供应商", veVendName, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("检验方式", testMethod, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("检验结果", testResult, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("收料数", vadQty, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("送检数", checkQty, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("合格数", mOkQty + "", 0));
|
|
|
+ mCaptionValueBeans.add(createItem("不合格数", ngQty, 0));
|
|
|
+ mCaptionValueBeans.add(createItem("状态", status, 0));
|
|
|
+
|
|
|
+ mCaptionValueItemAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ mErrorScrollView.setVisibility(View.GONE);
|
|
|
+ mDataLinearLayout.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getDataByBarcode(String barcode) {
|
|
|
+ if (TextUtils.isEmpty(barcode)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ hideAllViews();
|
|
|
+ progressDialog.show();
|
|
|
+
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_IQC_GETDATA_BARCODE + "?bar_code=" + barcode)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .flag(FLAG_GET_BARCODE)
|
|
|
+ .tag(TAG + "barcode")
|
|
|
+ .build(), this);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void hideAllViews() {
|
|
|
+ mDataLinearLayout.setVisibility(View.GONE);
|
|
|
+ mErrorTextView.setText("");
|
|
|
+ mErrorScrollView.setVisibility(View.GONE);
|
|
|
+ mCaptionValueBeans.clear();
|
|
|
+// mCaptionValueItemAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
+ @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.storage_iqc_collect_et) {
|
|
|
+ mBarcodeEditText.setText(result);
|
|
|
+ mBarcodeEditText.setSelection(result.length());
|
|
|
+
|
|
|
+ getDataByBarcode(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|