From deb54169e6dfe5b517074deb15612256467d28df Mon Sep 17 00:00:00 2001
From: wangh <123456>
Date: Wed, 17 Jan 2024 17:37:26 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E5=87=BA=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../example/beijing_daxing/InActivity.java    | 57 ++++++++++++------
 .../beijing_daxing/base/BaseActivity.java     |  4 +-
 .../example/beijing_daxing/vm/InStoreVM.java  | 29 ++++++++-
 .../example/beijing_daxing/vm/OutStoreVm.java | 59 +++++++++++++++++++
 app/src/main/res/layout/activity_out.xml      |  5 +-
 5 files changed, 129 insertions(+), 25 deletions(-)
 create mode 100644 app/src/main/java/com/example/beijing_daxing/vm/OutStoreVm.java

diff --git a/app/src/main/java/com/example/beijing_daxing/InActivity.java b/app/src/main/java/com/example/beijing_daxing/InActivity.java
index e74012e..1e73cea 100644
--- a/app/src/main/java/com/example/beijing_daxing/InActivity.java
+++ b/app/src/main/java/com/example/beijing_daxing/InActivity.java
@@ -6,6 +6,7 @@ import androidx.databinding.DataBindingUtil;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
+import android.widget.Toast;
 
 import com.example.beijing_daxing.adapter.InAdapter;
 import com.example.beijing_daxing.base.AdapterClickCall;
@@ -14,6 +15,7 @@ import com.example.beijing_daxing.base.MyRecultCall;
 import com.example.beijing_daxing.base.MyResult;
 import com.example.beijing_daxing.been.InStoreSelectBody;
 import com.example.beijing_daxing.databinding.ActivityInBinding;
+import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
 import com.example.beijing_daxing.vm.InStoreVM;
 import com.lzy.okgo.OkGo;
 import com.lzy.okgo.model.Response;
@@ -21,11 +23,14 @@ import com.lzy.okgo.model.Response;
 import java.util.ArrayList;
 import java.util.List;
 
+import okhttp3.RequestBody;
+
 public class InActivity extends BaseActivity implements AdapterClickCall {
     private InStoreVM vm;
     private InAdapter adapter;
     private List<String> epcList;
-    private      ActivityInBinding binding;
+    private ActivityInBinding binding;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -34,8 +39,8 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
         vm = new InStoreVM();
         binding.setVm(vm);
         initRequest();
-        adapter=new InAdapter(this);
-        epcList=new ArrayList<>();
+        adapter = new InAdapter(this);
+        epcList = new ArrayList<>();
         adapter.setList(epcList);
         adapter.setAdapterClickCall(this);
         binding.setAdapter(adapter);
@@ -45,8 +50,8 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
     protected void sanRfid(List<String> epcs) {
         // Log.e("TAG", "sanRfid:" + epcs);
 
-        epcs.stream().forEach(t->{
-            if (!epcList.contains(t)){
+        epcs.stream().forEach(t -> {
+            if (!epcList.contains(t)) {
                 epcList.add(t);
             }
         });
@@ -56,17 +61,15 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
     }
 
     private void initRequest() {
-        OkGo.<MyResult>post(url + "/instore/select")
-                .tag(this)
-                .execute(new MyRecultCall(dialog, this) {
-                    @Override
-                    public void onSuccess(Response<MyResult> response) {
-                        super.onSuccess(response);
-                        // Log.e("TAG", "onSuccess:" + );response.body()
-                        InStoreSelectBody inStoreSelectBody = gson.fromJson(response.body().getData().toString(), InStoreSelectBody.class);
-                        vm.initSelect(inStoreSelectBody.getBaseLocationList(), inStoreSelectBody.getBaseManufacturerList());
-                    }
-                });
+        OkGo.<MyResult>post(url + "/instore/select").tag(this).execute(new MyRecultCall(dialog, this) {
+            @Override
+            public void onSuccess(Response<MyResult> response) {
+                super.onSuccess(response);
+                // Log.e("TAG", "onSuccess:" + );response.body()
+                InStoreSelectBody inStoreSelectBody = gson.fromJson(response.body().getData().toString(), InStoreSelectBody.class);
+                vm.initSelect(inStoreSelectBody.getBaseLocationList(), inStoreSelectBody.getBaseManufacturerList());
+            }
+        });
     }
 
     @Override
@@ -75,9 +78,25 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
         adapter.notifyDataSetChanged();
         vm.setSanLength(epcList.size());
     }
-    public void in_submit(View view){
+
+    public void in_submit(View view) {
         String binchCode = vm.getBinchCode();
-        if (binchCode==null||epcList.isEmpty()) return;
-        OkGo.<MyResult>post(url+"/")
+        if (binchCode == null || epcList.isEmpty()) return;
+        vm.setEpcList(epcList);
+        vm.setSubmitUser(SharedPreferencesUtils.getstring("user","test"));
+        OkGo.<MyResult>post(url + "/instore/submit")
+                .upRequestBody(RequestBody.create(JSON, gson.toJson(vm)))
+                .execute(new MyRecultCall(dialog,this){
+                    @Override
+                    public void onSuccess(Response<MyResult> response) {
+                        super.onSuccess(response);
+                        if (response.body().getCode()==0){
+                            Toast.makeText(InActivity.this, "提亀成功", Toast.LENGTH_SHORT).show();
+                            finish();
+                        }else {
+                            Toast.makeText(InActivity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show();
+                        }
+                    }
+                });
     }
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/example/beijing_daxing/base/BaseActivity.java b/app/src/main/java/com/example/beijing_daxing/base/BaseActivity.java
index bdfa608..c4f8059 100644
--- a/app/src/main/java/com/example/beijing_daxing/base/BaseActivity.java
+++ b/app/src/main/java/com/example/beijing_daxing/base/BaseActivity.java
@@ -22,8 +22,8 @@ import java.util.List;
 import okhttp3.MediaType;
 
 public abstract class BaseActivity extends AppCompatActivity {
-    // public static String url = "http://192.168.0.102:90/api";
-    public static String url = "http://172.20.10.2:90/api";
+    public static String url = "http://192.168.0.102:90/api";
+    // public static String url = "http://172.20.10.2:90/api";
     public ProgressDialog dialog;
     public Gson gson;
     public MediaType JSON = MediaType.parse("application/json; charset=utf-8");
diff --git a/app/src/main/java/com/example/beijing_daxing/vm/InStoreVM.java b/app/src/main/java/com/example/beijing_daxing/vm/InStoreVM.java
index d6839c6..177eec1 100644
--- a/app/src/main/java/com/example/beijing_daxing/vm/InStoreVM.java
+++ b/app/src/main/java/com/example/beijing_daxing/vm/InStoreVM.java
@@ -19,13 +19,34 @@ import java.util.List;
 public class InStoreVM extends BaseObservable {
     private List<String> manus;
     private List<String> locations;
-    private String binchCode;
     private int sanLength;
+    private List<BaseManufacturer> baseManufacturerList;
+    private String binchCode;
     private String selectManuText;
     private String selectLocationText;
+    private List<String> epcList;
+    private String submitUser;
+    private Long manufacturerId;
+
+    public String getSubmitUser() {
+        return submitUser;
+    }
+
+    public void setSubmitUser(String submitUser) {
+        this.submitUser = submitUser;
+    }
+
+    public List<String> getEpcList() {
+        return epcList;
+    }
+
+    public void setEpcList(List<String> epcList) {
+        this.epcList = epcList;
+    }
 
     public void selectManus(AdapterView<?> parent, View view, int position, long id) {
         selectManuText = manus.get(position);
+        this.manufacturerId = baseManufacturerList.get(position).getManufacturerId();
     }
 
     public void selectLocation(AdapterView<?> parent, View view, int position, long id) {
@@ -50,8 +71,9 @@ public class InStoreVM extends BaseObservable {
     }
 
     public void initSelect(List<BaseLocation> baseLocationList, List<BaseManufacturer> baseManufacturerList) {
-        manus=new ArrayList<>();
-        locations=new ArrayList<>();
+        manus = new ArrayList<>();
+        locations = new ArrayList<>();
+        this.baseManufacturerList = baseManufacturerList;
         baseLocationList.forEach(t -> this.locations.add(t.getLocationCode()));
         baseManufacturerList.forEach(t -> this.manus.add(t.getManufacturerName()));
         notifyChange();
@@ -73,4 +95,5 @@ public class InStoreVM extends BaseObservable {
         this.sanLength = sanLength;
         notifyChange();
     }
+
 }
diff --git a/app/src/main/java/com/example/beijing_daxing/vm/OutStoreVm.java b/app/src/main/java/com/example/beijing_daxing/vm/OutStoreVm.java
new file mode 100644
index 0000000..d590efc
--- /dev/null
+++ b/app/src/main/java/com/example/beijing_daxing/vm/OutStoreVm.java
@@ -0,0 +1,59 @@
+package com.example.beijing_daxing.vm;
+
+import androidx.databinding.BaseObservable;
+
+import java.util.List;
+
+/**
+ * @author wanghao
+ * @date 2024/1/17  16:17
+ */
+public class OutStoreVm  extends BaseObservable {
+    private List<String> epcList;
+    private String areaCode;
+    private String submitUser;
+    private String useUser;
+
+    private List<String> areaList;
+
+
+    public List<String> getEpcList() {
+        return epcList;
+    }
+
+    public void setEpcList(List<String> epcList) {
+        this.epcList = epcList;
+    }
+
+    public String getAreaCode() {
+        return areaCode;
+    }
+
+    public void setAreaCode(String areaCode) {
+        this.areaCode = areaCode;
+    }
+
+    public String getSubmitUser() {
+        return submitUser;
+    }
+
+    public void setSubmitUser(String submitUser) {
+        this.submitUser = submitUser;
+    }
+
+    public String getUseUser() {
+        return useUser;
+    }
+
+    public void setUseUser(String useUser) {
+        this.useUser = useUser;
+    }
+
+    public List<String> getAreaList() {
+        return areaList;
+    }
+
+    public void setAreaList(List<String> areaList) {
+        this.areaList = areaList;
+    }
+}
diff --git a/app/src/main/res/layout/activity_out.xml b/app/src/main/res/layout/activity_out.xml
index 4348d47..66c7554 100644
--- a/app/src/main/res/layout/activity_out.xml
+++ b/app/src/main/res/layout/activity_out.xml
@@ -4,7 +4,9 @@
     xmlns:tools="http://schemas.android.com/tools">
 
     <data>
-
+        <variable
+            name="vm"
+            type="com.example.beijing_daxing.vm.OutStoreVm" />
     </data>
 
     <LinearLayout
@@ -25,6 +27,7 @@
             android:layout_height="300dp"
             android:layout_marginTop="10dp"
             android:background="@color/white"
+
             android:padding="10dp" />
         <LinearLayout
             android:layout_width="match_parent"