wuhb 1 год назад
Родитель
Сommit
0df71c3add

+ 42 - 30
app/src/main/java/com/ygtx/emcs/activity/StockOutBindActivity.java

@@ -11,12 +11,14 @@ import android.graphics.drawable.ColorDrawable;
 import android.os.Bundle;
 import android.os.Handler;
 import android.util.DisplayMetrics;
+import android.util.SparseBooleanArray;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.WindowManager;
 import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.ImageView;
@@ -217,11 +219,10 @@ public class StockOutBindActivity extends BaseActivity {
 
     private void setNewItemAreaValue(List<MaterialStockModel> materialStockModelList){
         for (MaterialStockModel lineAreaModel:materialStockModelList){
-            if(lineAreaModel.getAreaCode().startsWith("A")){
-                continue;
+            if(lineAreaModel.getAreaCode().startsWith("B")){
+                View areaView = addAreaItem();
+                setStockItemValue(lineAreaModel, areaView);
             }
-            View areaView = addAreaItem();
-            setStockItemValue(lineAreaModel, areaView);
         }
     }
 
@@ -335,7 +336,7 @@ public class StockOutBindActivity extends BaseActivity {
         params.addBodyParameter("outstockId", lineModel.getOutstockId().toString());
         params.addBodyParameter("lineId", lineModel.getLineId().toString());
         params.addBodyParameter("erpOutstockCode", erpOutstockCode);
-        if("-1".equals(batchCode)){
+        if("随机".equals(batchCode)){
             params.addBodyParameter("outMode", "0");
         }else{
             params.addBodyParameter("outMode", "1");
@@ -895,51 +896,62 @@ public class StockOutBindActivity extends BaseActivity {
                 ||"1".equals(lineModel.getStatus())){
             return;
         }
-        List<Map<String,String>> params = new ArrayList<>();
-        Map<String,String> defaultParam = new HashMap<>();
-        defaultParam.put("name", "随机");
-        defaultParam.put("value", "-1");
-        params.add(defaultParam);
+        List<String> params1 = new ArrayList<>();
+        params1.add("随机");
         if(!batchModelList.isEmpty()){
             batchModelList.forEach(item->{
-                Map<String,String> param = new HashMap<>();
-                param.put("name", item.getBatchCode());
-                param.put("value", item.getBatchCode());
-                params.add(param);
+                params1.add(item.getBatchCode());
             });
         }
         View popup_list_view= LayoutInflater.from(context).inflate(R.layout.popupwindow_list_view,null);
         ListView mListView = popup_list_view.findViewById(R.id.lv_data);
-        mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
         Button itemCancel = popup_list_view.findViewById(R.id.bt_item_cancel);
+        Button itemOk = popup_list_view.findViewById(R.id.bt_item_ok);
+        itemOk.setVisibility(View.VISIBLE);
         itemCancel.setOnClickListener(v -> {
             if(popupWindow1!=null){
                 popupWindow1.dismiss();
                 setBackgroundAlpha(1.0f);
             }
         });
-        mListView.setBackgroundResource(R.color.white);
-        SimpleAdapter simplead = new SimpleAdapter(this, params,
-                R.layout.popupwindow_list_item, new String[] { "name"},
-                new int[] {R.id.tv_msg});
-        mListView.setAdapter(simplead);
-        mListView.setOnItemClickListener((parent, view1, position, id) -> {
+        itemOk.setOnClickListener(v->{
             try {
-                String value = params.get(position).get("value");
-                String name = params.get(position).get("name");
-                if(name!=null) {
-                    if (name.contains(".")) {
-                        name = name.split("\\.")[0];
+                batchCode = "";
+                SparseBooleanArray checked = mListView.getCheckedItemPositions();
+                for (int i = 0; i < checked.size(); i++) {
+                    if (checked.valueAt(i)) {
+                        int position = checked.keyAt(i);
+                        String selectedItem = params1.get(position);
+                        batchCode +=  "," + selectedItem;
                     }
-                    binding.tvBatchCode.setText(name);
                 }
-                batchCode = value;
+                if(!StringUtils.isEmpty(batchCode)){
+                    batchCode = batchCode.substring(1);
+                }
+                binding.tvBatchCode.setText(batchCode);
                 updateStockOutLine();
-                popupWindow1.dismiss();
-                setBackgroundAlpha(1.0f);
             }catch (Throwable ex){
                 mylog.error("选择批号异常", ex);
             }
+            popupWindow1.dismiss();
+            setBackgroundAlpha(1.0f);
+        });
+        mListView.setBackgroundResource(R.color.white);
+        mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
+        ArrayAdapter<String> adapter = new ArrayAdapter<>(
+                this,
+                android.R.layout.simple_list_item_multiple_choice,
+                params1);
+        mListView.setAdapter(adapter);
+        mListView.setOnItemClickListener((parent, v, position, id) -> {
+            if(position == 0) {
+                for (int i = 0; i < mListView.getCount(); i++) {
+                    mListView.setItemChecked(i, false);
+                }
+                mListView.setItemChecked(position, true);
+            }else{
+                mListView.setItemChecked(0, false);
+            }
         });
         WindowManager manager = this.getWindowManager();
         DisplayMetrics outMetrics = new DisplayMetrics();

+ 22 - 15
app/src/main/java/com/ygtx/emcs/activity/StockOutNewActivity.java

@@ -71,11 +71,21 @@ public class StockOutNewActivity extends BaseActivity {
         initData();
     }
 
+    private void reloadData(){
+        new Handler().postDelayed(()->{
+            if(Constant.user != null) {
+                loadErpTask(0);
+            }
+            reloadData();
+        }, 3000);
+    }
+
+
     private void initData(){
         erpOutstockCode = getParamString("erpOutstockCode");
         if(!StringUtils.isEmpty(erpOutstockCode)){
             binding.tvOutCode.setText(erpOutstockCode);
-            loadErpTask();
+            loadErpTask(1);
         }
         stockLineListViewAdapter = new StockOutListViewAdapter(stockLineList, context);
         binding.lvProduct.setAdapter(stockLineListViewAdapter);
@@ -85,12 +95,7 @@ public class StockOutNewActivity extends BaseActivity {
             if("1".equals(from) && !"2".equals(stockLineModel.getStatus())){
                 return;
             }
-            if("1".equals(from) && "2".equals(stockLineModel.getStatus())){
-                stockOut(stockLineModel);
-            }else{
-                ToastUtils.showToast(context, "请扫物料编码出库");
-//                stockOut(stockLineModel);
-            }
+            stockOut(stockLineModel);
         });
         binding.lvProduct.setOnItemLongClickListener((parent, view, position, id) -> {
             StockLineModel stockLineModel = stockLineList.get(position);
@@ -117,10 +122,10 @@ public class StockOutNewActivity extends BaseActivity {
             ToastUtils.showToast(context, "请设置料框码的标识");
             finish();
         }
-
+        reloadData();
 // ========================test========================
 //        binding.tvScanTips.setOnClickListener(view->{
-//            receiverTask("CK_20250401010");
+//            receiverTask("CK_20250409001");
 //        });
 //        binding.tvOutCode.setOnClickListener(view->{
 //            receiverTask("BOX000028");
@@ -194,7 +199,7 @@ public class StockOutNewActivity extends BaseActivity {
             try {
                 binding.tvOutCode.setText(barcode);
                 erpOutstockCode = barcode;
-                loadErpTask();
+                loadErpTask(1);
             }catch (Throwable ex){
                 mylog.error("任务发送异常:", ex);
                 ToastUtils.showToast(context, "发送异常");
@@ -253,7 +258,7 @@ public class StockOutNewActivity extends BaseActivity {
         ToastUtils.showToast(context, "出库单不存在" + barcode + "物品");
     }
 
-    private void loadErpTask() {
+    private void loadErpTask(int show) {
         if(StringUtils.isEmpty(erpOutstockCode)){
             erpOutstockCode = binding.tvOutCode.getText().toString();
         }
@@ -270,7 +275,9 @@ public class StockOutNewActivity extends BaseActivity {
         }
         isSubmit = false;
         MyProgress myProgress = MyProgress.getInstance();
-        myProgress.show(context, "提示", "正在加载");
+        if(show == 1) {
+            myProgress.show(context, "提示", "正在加载");
+        }
         RequestParams params = httParams(Constant.ERP_OUT_STOCK);
         params.addBodyParameter("erpOutstockCode", erpOutstockCode);
 //        params.addBodyParameter("isAutomatic", "0");
@@ -388,7 +395,7 @@ public class StockOutNewActivity extends BaseActivity {
                 try {
                     if (rs.getInt("code") == 200) {
                         ToastUtils.showToast(context, rs.getString("msg"));
-                        loadErpTask();
+                        loadErpTask(1);
                     }else if(rs.getInt("code") == 401){
                         ToastUtils.showToast(context, "会话过期");
                         logoutAuth(rs.getInt("code"));
@@ -445,7 +452,7 @@ public class StockOutNewActivity extends BaseActivity {
                     ToastUtils.showToast(context, rs.getString("msg"));
                     if (rs.getInt("code") == 200) {
                         ToastUtils.showToast(context, "核对成功");
-                        loadErpTask();
+                        loadErpTask(1);
                     }else if(rs.getInt("code") == 401){
                         ToastUtils.showToast(context, "会话过期");
                         logoutAuth(rs.getInt("code"));
@@ -479,7 +486,7 @@ public class StockOutNewActivity extends BaseActivity {
     @Subscribe(threadMode = ThreadMode.MAIN, sticky = true, priority = 1)
     public void onReceiveMsg(EventMessage message){
         if(message.getType() == 3){
-            loadErpTask();
+            loadErpTask(1);
         }
     }
 

+ 10 - 0
app/src/main/java/com/ygtx/emcs/activity/model/MaterialStockModel.java

@@ -49,6 +49,8 @@ public class MaterialStockModel {
 
     private String attr1;
 
+    private String sel;
+
     public Long getMaterialStockId() {
         return materialStockId;
     }
@@ -232,4 +234,12 @@ public class MaterialStockModel {
     public void setAttr1(String attr1) {
         this.attr1 = attr1;
     }
+
+    public String getSel() {
+        return sel;
+    }
+
+    public void setSel(String sel) {
+        this.sel = sel;
+    }
 }

+ 1 - 0
app/src/main/res/layout/popupwindow_list_item.xml

@@ -3,6 +3,7 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:padding="15dp" >
+
     <TextView
         android:id="@+id/tv_msg"
         android:layout_width="match_parent"

+ 22 - 6
app/src/main/res/layout/popupwindow_list_view.xml

@@ -17,12 +17,28 @@
             android:background="@color/gray"
             android:layout_weight="1"
             android:listSelector="@drawable/blu" />
-        <Button
-            android:id="@+id/bt_item_cancel"
+        <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="50dp"
-            android:layout_marginTop="1dp"
-            android:background="@drawable/shape_white_all"
-            android:text="@string/cancel"/>
+            android:layout_height="wrap_content"
+            android:background="@drawable/gray"
+            android:orientation="horizontal">
+            <Button
+                android:id="@+id/bt_item_cancel"
+                android:layout_width="match_parent"
+                android:layout_height="50dp"
+                android:layout_margin="1dp"
+                android:layout_weight="1"
+                android:background="@color/white"
+                android:text="@string/cancel"/>
+            <Button
+                android:id="@+id/bt_item_ok"
+                android:layout_width="match_parent"
+                android:layout_height="50dp"
+                android:layout_margin="1dp"
+                android:visibility="gone"
+                android:layout_weight="1"
+                android:background="@color/white"
+                android:text="@string/sure"/>
+        </LinearLayout>
     </LinearLayout>
 </RelativeLayout>

+ 11 - 10
app/src/main/res/layout/ygtx_bind_out_item.xml

@@ -20,7 +20,7 @@
             android:padding="5dp"
             android:orientation="horizontal">
             <TextView
-                android:layout_width="80dp"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:gravity="start"
                 android:textSize="18sp"
@@ -48,7 +48,7 @@
             android:padding="5dp"
             android:orientation="horizontal">
             <TextView
-                android:layout_width="80dp"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:gravity="start"
                 android:textSize="18sp"
@@ -76,7 +76,7 @@
             android:id="@+id/ll_batch_code"
             android:orientation="horizontal">
             <TextView
-                android:layout_width="80dp"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:gravity="start"
                 android:textSize="18sp"
@@ -111,14 +111,14 @@
             android:id="@+id/ll_box_code"
             android:orientation="horizontal">
             <TextView
-                android:layout_width="80dp"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:gravity="start"
                 android:textSize="18sp"
                 android:text="料框:"/>
             <TextView
                 android:id="@+id/tv_box_code"
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:textSize="18sp"
                 android:layout_height="wrap_content"
                 android:padding="5dp"
@@ -138,7 +138,7 @@
             android:padding="5dp"
             android:orientation="horizontal">
             <TextView
-                android:layout_width="80dp"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:gravity="start"
                 android:textSize="18sp"
@@ -152,17 +152,18 @@
                 android:layout_weight="1"
                 android:textSize="18sp"/>
             <TextView
-                android:layout_width="90dp"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:gravity="center"
                 android:textSize="18sp"
                 android:text="总量:"/>
             <TextView
                 android:id="@+id/tv_qty"
-                android:layout_width="80dp"
+                android:layout_width="match_parent"
                 android:textSize="18sp"
                 android:layout_height="wrap_content"
                 android:gravity="center"
+                android:layout_weight="1.5"
                 android:text="0"/>
         </LinearLayout>
         <TextView
@@ -180,10 +181,10 @@
             android:padding="5dp"
             android:gravity="end">
             <TextView
-                android:layout_width="80dp"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:textSize="18sp"
-                android:text="每袋:"/>
+                android:text="每袋"/>
             <EditText
                 android:layout_width="100dp"
                 android:layout_height="wrap_content"

+ 5 - 5
app/src/main/res/layout/ygtx_stock_product_item.xml

@@ -17,7 +17,7 @@
         android:background="@color/white"
         android:orientation="horizontal">
         <TextView
-            android:layout_width="80dp"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:paddingTop="5dp"
             android:paddingStart="5dp"
@@ -55,7 +55,7 @@
         android:background="@color/white"
         android:orientation="horizontal">
         <TextView
-            android:layout_width="80dp"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:paddingTop="5dp"
             android:paddingStart="5dp"
@@ -80,7 +80,7 @@
         android:background="@color/white"
         android:orientation="horizontal">
         <TextView
-            android:layout_width="80dp"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:paddingTop="5dp"
             android:paddingStart="5dp"
@@ -96,7 +96,7 @@
             android:textSize="18dp"
             />
         <TextView
-            android:layout_width="80dp"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:paddingTop="5dp"
             android:paddingStart="5dp"
@@ -123,7 +123,7 @@
         android:background="@color/white"
         android:orientation="horizontal">
         <TextView
-            android:layout_width="80dp"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:paddingTop="5dp"
             android:paddingStart="5dp"