|
|
@@ -0,0 +1,358 @@
|
|
|
+package com.uas.uas_mes_standard.fragment;
|
|
|
+
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.v7.app.AlertDialog;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+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.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
+import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
|
+import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
|
|
|
+import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
|
|
+import com.uas.uas_mes_standard.R;
|
|
|
+import com.uas.uas_mes_standard.adapter.StorageInCollectAdapter;
|
|
|
+import com.uas.uas_mes_standard.bean.LongClickDeleteBean;
|
|
|
+import com.uas.uas_mes_standard.bean.StockAlreadyItemBean;
|
|
|
+import com.uas.uas_mes_standard.global.GloableParams;
|
|
|
+import com.uas.uas_mes_standard.listener.MyEditorActionListener;
|
|
|
+import com.uas.uas_mes_standard.tools.SharedPreUtil;
|
|
|
+import com.uas.uas_mes_standard.util.CommonUtil;
|
|
|
+import com.uas.uas_mes_standard.util.Constants;
|
|
|
+import com.uas.uas_mes_standard.util.FastjsonUtil;
|
|
|
+import com.uas.uas_mes_standard.util.HttpCallback;
|
|
|
+import com.uas.uas_mes_standard.util.HttpParams;
|
|
|
+import com.uas.uas_mes_standard.util.VolleyRequest;
|
|
|
+import com.uas.uas_mes_standard.view.ClearableEditText;
|
|
|
+import com.uas.uas_mes_standard.view.RecyclerItemDecoration;
|
|
|
+
|
|
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by RaoMeng on 2019/8/5
|
|
|
+ * Desc: 入库已采集列表
|
|
|
+ */
|
|
|
+public class StorageInBarDetailsCollectListFragment extends BaseFragment {
|
|
|
+ private ClearableEditText mDeleteEditText;
|
|
|
+ private TextView mDeleteTextView, mTypeTextView;
|
|
|
+ private LinearLayout mDeleteLayout;
|
|
|
+ private RefreshLayout mRefreshLayout;
|
|
|
+ private RecyclerView mRecyclerView;
|
|
|
+ private List<StockAlreadyItemBean> mCollectList;
|
|
|
+ private StorageInCollectAdapter mCollectAdapter;
|
|
|
+ private int mPageSize = 20, mPageIndex = 1;
|
|
|
+ private String mPiid, mWhcode, mPiClass;
|
|
|
+ private String mRevokeType;
|
|
|
+
|
|
|
+ public static StorageInBarDetailsCollectListFragment newInstance(String piid, String whcode,String mPiClass) {
|
|
|
+
|
|
|
+ Bundle args = new Bundle();
|
|
|
+ args.putString("id", piid);
|
|
|
+ args.putString("whcode", whcode);
|
|
|
+ args.putString("mPiClass",mPiClass);
|
|
|
+ StorageInBarDetailsCollectListFragment fragment = new StorageInBarDetailsCollectListFragment();
|
|
|
+ fragment.setArguments(args);
|
|
|
+ return fragment;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_storage_in_collect_list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ setTitle("已采集列表");
|
|
|
+
|
|
|
+ mDeleteEditText = root.findViewById(R.id.storage_in_colect_delete_et);
|
|
|
+ mDeleteTextView = root.findViewById(R.id.storage_in_colect_delete_btn);
|
|
|
+ mRefreshLayout = root.findViewById(R.id.storage_in_colect_list_srl);
|
|
|
+ mRefreshLayout.setEnableAutoLoadMore(false);
|
|
|
+ mDeleteLayout = root.findViewById(R.id.storage_in_colect_delete_ll);
|
|
|
+ if (CommonUtil.isGoldenMaster(mActivity)) {
|
|
|
+ mDeleteLayout.setVisibility(View.VISIBLE);
|
|
|
+ mDeleteEditText.requestFocus();
|
|
|
+ } else {
|
|
|
+ mDeleteLayout.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ mTypeTextView = root.findViewById(R.id.storage_in_colect_delete_type_tv);
|
|
|
+ mRecyclerView = root.findViewById(R.id.storage_in_colect_list_rv);
|
|
|
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
+ mRecyclerView.addItemDecoration(new RecyclerItemDecoration(1));
|
|
|
+ mCollectList = new ArrayList<>();
|
|
|
+ mCollectAdapter = new StorageInCollectAdapter(mCollectList);
|
|
|
+ mRecyclerView.setAdapter(mCollectAdapter);
|
|
|
+
|
|
|
+ mRevokeType = SharedPreUtil.getString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_IN_REVOKE_TYPE, "byBarcode");
|
|
|
+ if (mRevokeType != null) {
|
|
|
+ if (mRevokeType.equals("byBarcode")) {
|
|
|
+ mRevokeType = "byBarcode";
|
|
|
+ mDeleteEditText.setHint("请采集需要撤销的条码");
|
|
|
+ mTypeTextView.setText("条码");
|
|
|
+ } else if (mRevokeType.equals("byBox")) {
|
|
|
+ mDeleteEditText.setHint("请采集需要撤销的箱号");
|
|
|
+ mTypeTextView.setText("箱号");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
|
|
+ @Override
|
|
|
+ public void onRefresh(RefreshLayout refreshLayout) {
|
|
|
+ mPageIndex = 1;
|
|
|
+ getCollectList(mPageIndex, mPageSize);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mTypeTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String typeName = mTypeTextView.getText().toString().trim();
|
|
|
+ if ("条码".equals(typeName)) {
|
|
|
+ changeToTypeBox();
|
|
|
+ } else if ("箱号".equals(typeName)) {
|
|
|
+ changeToTypeBarcode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
|
|
+ @Override
|
|
|
+ public void onLoadMore(RefreshLayout refreshLayout) {
|
|
|
+ mPageIndex++;
|
|
|
+ getCollectList(mPageIndex, mPageSize);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ mCollectAdapter.setOnItemLongClickListener(new BaseQuickAdapter.OnItemLongClickListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ new AlertDialog.Builder(mActivity)
|
|
|
+ .setTitle("提示")
|
|
|
+ .setMessage("确定删除该条数据?")
|
|
|
+ .setNegativeButton(R.string.cancel, null)
|
|
|
+ .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ StockAlreadyItemBean itemBean = mCollectList.get(position);
|
|
|
+ Log.e("igetBI_ID()",itemBean.getBI_ID());
|
|
|
+ getLongDelete(itemBean.getBI_ID());
|
|
|
+ }
|
|
|
+ }).show();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ CommonUtil.setEditorActionListener(mDeleteEditText, new MyEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
+ deleteBarcode(text);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mDeleteTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String barcode = mDeleteEditText.getText().toString().trim();
|
|
|
+ deleteBarcode(barcode);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deleteBarcode(String text, boolean isBarcode) {
|
|
|
+ if (!TextUtils.isEmpty(text)) {
|
|
|
+ progressDialog.show();
|
|
|
+ String typeName = mTypeTextView.getText().toString().trim();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_INMATERIAL_DELETEGETDETAIL)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .tag(TAG + "deletedetail")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("bi_piid", mPiid)
|
|
|
+ .addParam("barcode", ("条码".equals(typeName) || isBarcode) ? text : "")
|
|
|
+ .addParam("outboxcode", ("箱号".equals(typeName) && !isBarcode) ? text : "")
|
|
|
+ .addParam("whcode", mWhcode)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "撤销成功");
|
|
|
+ if (!isBarcode) {
|
|
|
+ mDeleteEditText.setText("");
|
|
|
+ }
|
|
|
+ mDeleteEditText.requestFocus();
|
|
|
+ getCollectList(1, mPageIndex * mPageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ if (!isBarcode) {
|
|
|
+ mDeleteEditText.setText("");
|
|
|
+ mDeleteEditText.requestFocus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deleteBarcode(String text) {
|
|
|
+ deleteBarcode(text, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ Bundle arguments = getArguments();
|
|
|
+ if (arguments != null) {
|
|
|
+ mPiid = arguments.getString("id");
|
|
|
+ mWhcode = arguments.getString("whcode");
|
|
|
+ mPiClass = arguments.getString("mPiClass");
|
|
|
+ }
|
|
|
+ getCollectList(mPageIndex, mPageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void changeToTypeBarcode() {
|
|
|
+ mDeleteEditText.setHint("请采集需要撤销的条码");
|
|
|
+ mTypeTextView.setText("条码");
|
|
|
+ SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_IN_REVOKE_TYPE, "byBarcode");
|
|
|
+ mRevokeType = "byBarcode";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void changeToTypeBox() {
|
|
|
+ mDeleteEditText.setHint("请采集需要撤销的箱号");
|
|
|
+ mTypeTextView.setText("箱号");
|
|
|
+ SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_IN_REVOKE_TYPE, "byBox");
|
|
|
+ mRevokeType = "byBox";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getCollectList(int pageIndex, int pageSize) {
|
|
|
+ if (!mRefreshLayout.isRefreshing() && !mRefreshLayout.isLoading()) {
|
|
|
+ progressDialog.show();
|
|
|
+ }
|
|
|
+ if (pageIndex == 1) {
|
|
|
+ mCollectList.clear();
|
|
|
+ }
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_HAVE_SUBMIT_LIST_DEAL)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "submitlist")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("ids", mPiid)
|
|
|
+ .addParam("page", pageIndex + "")
|
|
|
+ .addParam("pagesize", pageSize + "")
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ try {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ mRefreshLayout.finishRefresh(0);
|
|
|
+ mRefreshLayout.finishLoadMore(0);
|
|
|
+
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if ((dataArray == null || dataArray.size() == 0) && pageIndex > 1) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "没有更多数据!");
|
|
|
+ }
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.getJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ StockAlreadyItemBean collectEntity = new StockAlreadyItemBean();
|
|
|
+ collectEntity.setBI_BARCODE(FastjsonUtil.getText(dataObject, "BI_BARCODE"));
|
|
|
+ collectEntity.setBI_OUTBOXCODE(FastjsonUtil.getText(dataObject, "BI_OUTBOXCODE"));
|
|
|
+ collectEntity.setBI_PRODCODE(FastjsonUtil.getText(dataObject, "BI_PRODCODE"));
|
|
|
+ collectEntity.setBI_INOUTNO(FastjsonUtil.getText(dataObject, "BI_INOUTNO"));
|
|
|
+ collectEntity.setBI_PIID(FastjsonUtil.getLong(dataObject, "BI_PIID"));
|
|
|
+ collectEntity.setBI_INQTY(FastjsonUtil.getDouble(dataObject, "BI_INQTY"));
|
|
|
+ collectEntity.setBI_OUTQTY(FastjsonUtil.getDouble(dataObject, "BI_OUTQTY"));
|
|
|
+ collectEntity.setPR_DETAIL(FastjsonUtil.getText(dataObject, "PR_DETAIL"));
|
|
|
+ collectEntity.setBI_WHCODE(FastjsonUtil.getText(dataObject, "BI_WHCODE"));
|
|
|
+ collectEntity.setPR_ID(FastjsonUtil.getLong(dataObject, "PR_ID"));
|
|
|
+ collectEntity.setPR_SPEC(FastjsonUtil.getText(dataObject, "PR_SPEC"));
|
|
|
+ collectEntity.setBI_LOCATION(FastjsonUtil.getText(dataObject, "BI_LOCATION"));
|
|
|
+ collectEntity.setBI_BATCHCODE(FastjsonUtil.getText(dataObject, "BI_BATCHCODE"));
|
|
|
+ collectEntity.setBI_PDAGET(FastjsonUtil.getInt(dataObject, "BI_PDAGET"));
|
|
|
+ collectEntity.setPR_ORISPECCODE(FastjsonUtil.getText(dataObject,"PR_ORISPECCODE"));
|
|
|
+ collectEntity.setBI_ID(FastjsonUtil.getText(dataObject,"BI_ID"));
|
|
|
+ mCollectList.add(collectEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (mPageIndex > 1) {
|
|
|
+ mPageIndex--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mCollectAdapter.notifyDataSetChanged();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ mRefreshLayout.finishRefresh(0);
|
|
|
+ mRefreshLayout.finishLoadMore(0);
|
|
|
+ if (mPageIndex > 1) {
|
|
|
+ mPageIndex--;
|
|
|
+ }
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ mCollectAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //长按删除
|
|
|
+ private void getLongDelete(String biids) {
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_PDAIO_GET_lOGINDELETE)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .tag(TAG + "submitlist")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("caller", mPiClass)
|
|
|
+ .addParam("ids", mPiid)
|
|
|
+ .addParam("biids", biids)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ getCollectList(mPageIndex, mPageSize);
|
|
|
+ EventBus.getDefault().post(new LongClickDeleteBean("刷新页面"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|