|
|
@@ -0,0 +1,167 @@
|
|
|
+package com.uas.pda_smart_com.fragment;
|
|
|
+
|
|
|
+import android.os.Bundle;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.widget.CheckBox;
|
|
|
+import android.widget.CompoundButton;
|
|
|
+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.bin.david.form.core.SmartTable;
|
|
|
+import com.bin.david.form.data.column.Column;
|
|
|
+import com.bin.david.form.data.format.IFormat;
|
|
|
+import com.bin.david.form.data.table.TableData;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.uas.pda_smart_com.R;
|
|
|
+import com.uas.pda_smart_com.bean.StockTaskMultipleBean;
|
|
|
+import com.uas.pda_smart_com.global.GloableParams;
|
|
|
+import com.uas.pda_smart_com.util.CommonUtil;
|
|
|
+import com.uas.pda_smart_com.util.FastjsonUtil;
|
|
|
+import com.uas.pda_smart_com.util.HttpCallback;
|
|
|
+import com.uas.pda_smart_com.util.HttpParams;
|
|
|
+import com.uas.pda_smart_com.util.VolleyRequest;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by RaoMeng on 2021/4/22
|
|
|
+ * Desc: 备料数据汇总
|
|
|
+ */
|
|
|
+public class StockDataSummaryFragment extends BaseFragment {
|
|
|
+ private SmartTable mSmartTable;
|
|
|
+ private Column<String> mProdcodeColumn, mOutqtyColumn;
|
|
|
+ private Column<Double> mPdaqtyColumn, mDetailColumn;
|
|
|
+ private TableData<StockTaskMultipleBean> mTableData;
|
|
|
+ private TextView mNumTextView;
|
|
|
+ private CheckBox mCheckBox;
|
|
|
+ private String mPiid, mWhcode, mInouno;
|
|
|
+ private List<StockTaskMultipleBean> mStockTaskMultipleBeans;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_stock_data_summary;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ setTitle("备料数据汇总");
|
|
|
+ Bundle bundle = getArguments();
|
|
|
+ if (bundle != null) {
|
|
|
+ mInouno = bundle.getString("pi_inoutno");
|
|
|
+ mWhcode = bundle.getString("pd_whcode");
|
|
|
+ mPiid = bundle.getString("pi_id");
|
|
|
+ }
|
|
|
+
|
|
|
+ mNumTextView = root.findViewById(R.id.stock_data_summary_num_tv);
|
|
|
+ mCheckBox = root.findViewById(R.id.stock_data_summary_cb);
|
|
|
+ mSmartTable = root.findViewById(R.id.stock_data_summary_st);
|
|
|
+
|
|
|
+ CommonUtil.getDefaultTable(mActivity, mSmartTable);
|
|
|
+ mProdcodeColumn = new Column<String>("物料编号", "PD_PRODCODE");
|
|
|
+ mOutqtyColumn = new Column<String>("名称", "PR_DETAIL");
|
|
|
+ mPdaqtyColumn = new Column<Double>("出库数量", "PD_OUTQTY", new IFormat<Double>() {
|
|
|
+ @Override
|
|
|
+ public String format(Double aDouble) {
|
|
|
+ return CommonUtil.doubleFormat(aDouble);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mDetailColumn = new Column<Double>("已采集数量", "PD_RESTQTY", new IFormat<Double>() {
|
|
|
+ @Override
|
|
|
+ public String format(Double aDouble) {
|
|
|
+ return CommonUtil.doubleFormat(aDouble);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ getDataList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ mNumTextView.setText("单号:" + mInouno);
|
|
|
+
|
|
|
+ mStockTaskMultipleBeans = new ArrayList<>();
|
|
|
+ setTableData(mStockTaskMultipleBeans);
|
|
|
+
|
|
|
+ getDataList();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setTableData(List<StockTaskMultipleBean> filterTableData) {
|
|
|
+ mTableData = new TableData<StockTaskMultipleBean>("出库单列表", filterTableData,
|
|
|
+ mOutqtyColumn, mProdcodeColumn, mPdaqtyColumn, mDetailColumn);
|
|
|
+ mSmartTable.setTableData(mTableData);
|
|
|
+ mSmartTable.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mSmartTable.postInvalidate();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getDataList() {
|
|
|
+ progressDialog.show();
|
|
|
+ mStockTaskMultipleBeans.clear();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_OUTMATERIAL_GETPREMATERIALLIST)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("ids", mPiid)
|
|
|
+ .addParam("showall", mCheckBox.isChecked() ? "-1" : "0")
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.getJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ StockTaskMultipleBean stockTaskMultipleBean = new StockTaskMultipleBean();
|
|
|
+ stockTaskMultipleBean.setPD_PRODCODE(FastjsonUtil.getText(dataObject, "PD_PRODCODE"));
|
|
|
+ stockTaskMultipleBean.setPR_DETAIL(FastjsonUtil.getText(dataObject, "PR_DETAIL"));
|
|
|
+ stockTaskMultipleBean.setPD_OUTQTY(FastjsonUtil.getDouble(dataObject, "PD_OUTQTY"));
|
|
|
+ stockTaskMultipleBean.setPD_RESTQTY(FastjsonUtil.getDouble(dataObject, "PD_PDAQTY"));
|
|
|
+
|
|
|
+ mStockTaskMultipleBeans.add(stockTaskMultipleBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setTableData(mStockTaskMultipleBeans);
|
|
|
+ } catch (Exception e) {
|
|
|
+ setTableData(mStockTaskMultipleBeans);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ setTableData(mStockTaskMultipleBeans);
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|