Bläddra i källkod

出库采集添加【备料数据汇总】功能

RaoMeng 4 år sedan
förälder
incheckning
2e4b9e92c3

+ 1 - 0
app/build.gradle

@@ -79,6 +79,7 @@ dependencies {
     implementation deps.recyclerview
     implementation deps.permisson
     implementation deps.basePopup
+    implementation deps.smartTable
 }
 
 def getVersionName() {

+ 3 - 0
app/src/main/java/com/uas/pda_smart_com/fragment/BomCheckFragment.java

@@ -109,6 +109,9 @@ public class BomCheckFragment extends BaseFragment {
             @Override
             public void onFail(int flag, String failStr) throws Exception {
                 progressDialog.dismiss();
+                mBarcodeEditText.setText("");
+                mBarcodeEditText.requestFocus();
+
                 CommonUtil.makeNotice();
                 CommonUtil.toastNoRepeat(mActivity, failStr);
             }

+ 11 - 0
app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutMakeMaterialOper.java

@@ -1186,6 +1186,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
                 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);
 
                 stockTaskBtn.setOnClickListener(new View.OnClickListener() {
                     @Override
@@ -1202,6 +1203,16 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
                     }
                 });
 
+                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) {

+ 167 - 0
app/src/main/java/com/uas/pda_smart_com/fragment/StockDataSummaryFragment.java

@@ -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;
+    }
+}

+ 3 - 0
app/src/main/java/com/uas/pda_smart_com/global/GloableParams.java

@@ -224,6 +224,7 @@ public class GloableParams {
     public static String ADDRESS_BARSTOCK_DELETEBARCODEIO;
     public static String ADDRESS_BARSTOCK_GETPRODINOUTQTYSUM;
     public static String ADDRESS_OUTMATERIAL_CHECKBOMBARCODE;
+    public static String ADDRESS_OUTMATERIAL_GETPREMATERIALLIST;
 
 
     //连接服务器请求地址
@@ -524,6 +525,7 @@ public class GloableParams {
     private static String ADDRESSTAIL_OUT_NEED_GET_LIST = "/api/pda/outMaterial/getNeedGetList.action";
     private static String ADDRESSTAIL_OUT_SAVE_BARCODE = "/api/pda/outMaterial/saveAll.action";
     private static String ADDRESSTAIL_OUT_NEED_GET_LIST_DEAL = "/api/pda/outMaterial/getNeedGetListDeal.action";
+    private static String ADDRESSTAIL_OUTMATERIAL_GETPREMATERIALLIST = "/api/pda/outMaterial/getPreMaterialList.action";
     //材料出库获取下一采集货品信息
     private static String ADDRESSTAIL_OUT_GET_NEXT_PRODCODE = "/api/pda/outMaterial/getNextByProdcode.action";
     private static String ADDRESSTAIL_OUT_GET_NEXT_BATCH = "/api/pda/outMaterial/getNextByBatch.action";
@@ -993,5 +995,6 @@ public class GloableParams {
         GloableParams.ADDRESS_BARSTOCK_DELETEBARCODEIO = uriHead + GloableParams.ADDRESSTAIL_BARSTOCK_DELETEBARCODEIO;
         GloableParams.ADDRESS_BARSTOCK_GETPRODINOUTQTYSUM = uriHead + GloableParams.ADDRESSTAIL_BARSTOCK_GETPRODINOUTQTYSUM;
         GloableParams.ADDRESS_OUTMATERIAL_CHECKBOMBARCODE = uriHead + GloableParams.ADDRESSTAIL_OUTMATERIAL_CHECKBOMBARCODE;
+        GloableParams.ADDRESS_OUTMATERIAL_GETPREMATERIALLIST = uriHead + GloableParams.ADDRESSTAIL_OUTMATERIAL_GETPREMATERIALLIST;
     }
 }

+ 60 - 0
app/src/main/java/com/uas/pda_smart_com/util/CommonUtil.java

@@ -5,6 +5,7 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
+import android.graphics.Color;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.os.AsyncTask;
@@ -12,6 +13,7 @@ import android.os.Build;
 import android.os.Handler;
 import android.os.Vibrator;
 import android.support.v4.app.Fragment;
+import android.support.v4.content.ContextCompat;
 import android.text.Editable;
 import android.text.SpannableString;
 import android.text.Spanned;
@@ -20,6 +22,7 @@ import android.text.TextWatcher;
 import android.text.style.AbsoluteSizeSpan;
 import android.text.style.ForegroundColorSpan;
 import android.util.DisplayMetrics;
+import android.util.TypedValue;
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.ViewGroup;
@@ -36,6 +39,11 @@ import android.widget.Toast;
 
 import com.alibaba.fastjson.JSON;
 import com.android.volley.VolleyError;
+import com.bin.david.form.core.SmartTable;
+import com.bin.david.form.data.CellInfo;
+import com.bin.david.form.core.TableConfig;
+import com.bin.david.form.data.format.bg.BaseCellBackgroundFormat;
+import com.bin.david.form.data.style.FontStyle;
 import com.uas.pda_smart_com.R;
 import com.uas.pda_smart_com.application.PdaApplication;
 import com.uas.pda_smart_com.bean.ErrorMsg;
@@ -305,6 +313,32 @@ public class CommonUtil {
         return (int) (pxValue / scale + 0.5f);
     }
 
+
+    /**
+     * sp转px
+     *
+     * @param context
+     * @return
+     */
+
+    public static int sp2px(Context context, float spVal) {
+        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
+
+                spVal, context.getResources().getDisplayMetrics());
+
+    }
+
+    /**
+     * px转sp
+     *
+     * @param pxVal
+     * @return
+     */
+
+    public static float px2sp(Context context, float pxVal) {
+        return (pxVal / context.getResources().getDisplayMetrics().scaledDensity);
+    }
+
     /**
      * 检测网络是否可用
      *
@@ -932,4 +966,30 @@ public class CommonUtil {
         return result;
     }
 
+
+    public static void getDefaultTable(Activity mActivity, SmartTable mSmartTable) {
+        WindowManager wm = mActivity.getWindowManager();
+        int screenWith = wm.getDefaultDisplay().getWidth();
+        mSmartTable.getConfig().setMinTableWidth(screenWith)
+                .setShowXSequence(false)
+                .setShowYSequence(false)
+                .setShowTableTitle(false)
+                .setFixedTitle(true)
+                .setVerticalPadding(CommonUtil.dip2px(mActivity, 10))
+                .setColumnTitleVerticalPadding(CommonUtil.dip2px(mActivity, 10))
+                .setHorizontalPadding(CommonUtil.dip2px(mActivity, 10))
+                .setSequenceHorizontalPadding(CommonUtil.dip2px(mActivity, 10))
+                .setColumnTitleHorizontalPadding(CommonUtil.dip2px(mActivity, 10))
+                .setContentStyle(new FontStyle(CommonUtil.sp2px(mActivity, 12), Color.parseColor("#333333")))
+                .setColumnTitleStyle(new FontStyle(CommonUtil.sp2px(mActivity, 14), Color.parseColor("#000000")))
+                .setContentCellBackgroundFormat(new BaseCellBackgroundFormat<CellInfo>() {
+                    @Override
+                    public int getBackGroundColor(CellInfo cellInfo) {
+                        if (cellInfo.row % 2 == 0) {
+                            return ContextCompat.getColor(mActivity, R.color.blue_50);
+                        }
+                        return TableConfig.INVALID_COLOR;
+                    }
+                });
+    }
 }

+ 2 - 2
app/src/main/res/layout/fragment_bom_check.xml

@@ -21,7 +21,7 @@
                 android:layout_height="match_parent"
                 android:gravity="center"
                 android:padding="10dp"
-                android:text="BOM  ID"
+                android:text="校验"
                 android:textColor="@color/body_text_1"
                 android:textSize="16sp" />
 
@@ -32,7 +32,7 @@
                 android:layout_weight="1"
                 android:focusable="true"
                 android:focusableInTouchMode="true"
-                android:hint="请采集BOM  ID"
+                android:hint="请输入BOM ID或者工单号"
                 android:imeOptions="actionSend"
                 android:textColor="@color/black" />
         </TableRow>

+ 35 - 0
app/src/main/res/layout/fragment_stock_data_summary.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        android:padding="10dp">
+
+        <TextView
+            android:id="@+id/stock_data_summary_num_tv"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:text="单号:"
+            android:textColor="#333333"
+            android:textSize="14sp" />
+
+        <CheckBox
+            android:id="@+id/stock_data_summary_cb"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:checked="true"
+            android:text="未完成" />
+    </LinearLayout>
+
+
+    <com.bin.david.form.core.SmartTable
+        android:id="@+id/stock_data_summary_st"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+</LinearLayout>

+ 24 - 11
app/src/main/res/layout/pop_material_out_menu.xml

@@ -10,56 +10,69 @@
         android:id="@+id/pop_material_out_menu_1"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:layout_marginLeft="10dp"
+        android:layout_marginRight="10dp"
         android:background="@color/transparent"
-        android:text="备料任务 "
+        android:text="备料任务"
+        android:textSize="@dimen/app_text_size_body_2" />
+
+    <Button
+        android:id="@+id/pop_material_out_menu_7"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
         android:layout_marginLeft="10dp"
         android:layout_marginRight="10dp"
+        android:background="@color/transparent"
+        android:text="备料数据汇总"
         android:textSize="@dimen/app_text_size_body_2" />
 
     <Button
         android:id="@+id/pop_material_out_menu_2"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@color/transparent"
-        android:text="已备料列表"
         android:layout_marginLeft="10dp"
         android:layout_marginRight="10dp"
+        android:background="@color/transparent"
+        android:text="已备料列表"
         android:textSize="@dimen/app_text_size_body_2" />
 
     <Button
         android:id="@+id/pop_material_out_menu_3"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@color/transparent"
-        android:text="撤销备料"
         android:layout_marginLeft="10dp"
         android:layout_marginRight="10dp"
+        android:background="@color/transparent"
+        android:text="撤销备料"
         android:textSize="@dimen/app_text_size_body_2" />
+
     <Button
         android:id="@+id/pop_material_out_menu_4"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@color/transparent"
-        android:text="修改数量"
         android:layout_marginLeft="10dp"
         android:layout_marginRight="10dp"
+        android:background="@color/transparent"
+        android:text="修改数量"
         android:textSize="@dimen/app_text_size_body_2" />
+
     <Button
         android:id="@+id/pop_material_out_menu_5"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@color/transparent"
-        android:text="特殊出库"
         android:layout_marginLeft="10dp"
         android:layout_marginRight="10dp"
+        android:background="@color/transparent"
+        android:text="特殊出库"
         android:textSize="@dimen/app_text_size_body_2" />
+
     <Button
         android:id="@+id/pop_material_out_menu_6"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@color/transparent"
-        android:text="单据过账"
         android:layout_marginLeft="10dp"
         android:layout_marginRight="10dp"
+        android:background="@color/transparent"
+        android:text="单据过账"
         android:textSize="@dimen/app_text_size_body_2" />
 </LinearLayout>

+ 2 - 2
build.gradle

@@ -61,7 +61,7 @@ ext {
             BaseRecyclerViewAdapterHelperVersion: '2.9.30',
             permissonVersion                    : '2.0.0-rc12',
             basePopupVersion                    : '2.1.5',
-            basePopupVersion                    : '2.1.5'
+            smartTableVersion                   : '2.2.0'
     ]
 
     deps = [
@@ -78,6 +78,6 @@ ext {
             recyclerview                 : 'com.android.support:recyclerview-v7:' + depsVersion.appcompatV7Version,
             permisson                    : 'com.yanzhenjie:permission:' + depsVersion.permissonVersion,
             basePopup                    : 'com.github.razerdp:BasePopup:' + depsVersion.basePopupVersion,
-            basePopup                    : 'com.github.razerdp:BasePopup:' + depsVersion.basePopupVersion
+            smartTable                   : 'com.github.huangyanbin:SmartTable:' + depsVersion.smartTableVersion
     ]
 }