diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e37499d..4856608 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -13,6 +13,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.Beijingdaxing"
tools:targetApi="31">
+
@@ -33,9 +36,7 @@
-
-
+ android:exported="true">
\ No newline at end of file
diff --git a/app/src/main/java/com/example/beijing_daxing/HomePageActivity.java b/app/src/main/java/com/example/beijing_daxing/HomePageActivity.java
index 4c02bf1..75878d8 100644
--- a/app/src/main/java/com/example/beijing_daxing/HomePageActivity.java
+++ b/app/src/main/java/com/example/beijing_daxing/HomePageActivity.java
@@ -27,7 +27,7 @@ public class HomePageActivity extends AppCompatActivity {
List list = new ArrayList<>();
list.add(new HomeIcon(R.mipmap.home_in1, "轮挡入库", InActivity.class));
list.add(new HomeIcon(R.mipmap.home_out1, "轮挡领用出库", OutActivity.class));
- list.add(new HomeIcon(R.mipmap.home_store_check, "仓库盘点", OutActivity.class));
+ list.add(new HomeIcon(R.mipmap.home_store_check, "仓库盘点", StoreCheckActivity.class));
list.add(new HomeIcon(R.mipmap.home_check, "轮挡巡检", CheckActivity.class));
list.add(new HomeIcon(R.mipmap.home_check, "轮挡报废", CheckActivity.class));
list.add(new HomeIcon(R.mipmap.home_in, "废品入库", CheckActivity.class));
diff --git a/app/src/main/java/com/example/beijing_daxing/StoreCheckActivity.java b/app/src/main/java/com/example/beijing_daxing/StoreCheckActivity.java
new file mode 100644
index 0000000..5ae0b50
--- /dev/null
+++ b/app/src/main/java/com/example/beijing_daxing/StoreCheckActivity.java
@@ -0,0 +1,132 @@
+package com.example.beijing_daxing;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.databinding.Bindable;
+import androidx.databinding.DataBindingUtil;
+import androidx.databinding.ObservableBoolean;
+
+import android.annotation.SuppressLint;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.View;
+import android.widget.Toast;
+
+import com.example.beijing_daxing.adapter.StoreCheckAdapter;
+import com.example.beijing_daxing.base.BaseActivity;
+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.been.Stock;
+import com.example.beijing_daxing.databinding.ActivityStoreCheckBinding;
+import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
+import com.google.gson.reflect.TypeToken;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import okhttp3.RequestBody;
+
+public class StoreCheckActivity extends BaseActivity {
+
+
+ private ObservableBoolean checkState;
+ private List list;
+ private StoreCheckAdapter checkAdapter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ ActivityStoreCheckBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_store_check);
+ checkState = new ObservableBoolean();
+ binding.setCheckState(checkState);
+ checkAdapter = new StoreCheckAdapter(this);
+ binding.setAdapter(checkAdapter);
+ initRequest();
+ }
+ private List tagList;
+ @Override
+ protected void sanRfid(List epcs) {
+ epcs.forEach(t -> {
+ if (tagList.contains(t)){
+ tagList.add(t);
+ return;
+ }
+ var stock = new Stock();
+ stock.setEpcCode(t);
+ var index = list.indexOf(stock);
+ if (index != -1) {
+ list.get(index).setState("Y");
+ }
+ });
+ checkAdapter.notifyDataSetChanged();
+ }
+
+ private void initRequest() {
+ OkGo.post(url + "/storecheck/select").tag(this).execute(new MyRecultCall(dialog, this) {
+ @Override
+ public void onSuccess(Response response) {
+ super.onSuccess(response);
+ var body = response.body();
+ if (body.getCode() == 0) {
+ list = gson.fromJson(body.getData().toString(), new TypeToken>() {
+ }.getType());
+ tagList=new ArrayList<>();
+ checkAdapter.setList(list);
+ checkAdapter.notifyDataSetChanged();
+ } else {
+ Toast.makeText(StoreCheckActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+ }
+
+ public void check_read(View view) {
+ var b = checkState.get();
+ if (b) {
+ handler.removeCallbacks(runnable);
+ } else {
+ handler.postDelayed(runnable, 0);
+ }
+ checkState.set(!b);
+ }
+
+ public void store_check_submit(View view) {
+ handler.removeCallbacks(runnable);
+ OkGo.post(url+"/storecheck/submit")
+ .upRequestBody(RequestBody.create(JSON, gson.toJson(list)))
+ .params("user", SharedPreferencesUtils.getstring("user","test"))
+ .execute(new MyRecultCall(dialog,this){
+ @Override
+ public void onSuccess(Response response) {
+ super.onSuccess(response);
+ }
+ });
+ }
+
+ @SuppressLint("HandlerLeak")
+ private Handler handler = new Handler() {
+ @Override
+ public void handleMessage(@NonNull Message msg) {
+ super.handleMessage(msg);
+ }
+ };
+ private Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ sendBroadcast(broadcastIntent);
+ handler.postDelayed(runnable, 1000);
+ }
+ };
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ handler=null;
+ runnable=null;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/beijing_daxing/adapter/StoreCheckAdapter.java b/app/src/main/java/com/example/beijing_daxing/adapter/StoreCheckAdapter.java
new file mode 100644
index 0000000..666c312
--- /dev/null
+++ b/app/src/main/java/com/example/beijing_daxing/adapter/StoreCheckAdapter.java
@@ -0,0 +1,66 @@
+package com.example.beijing_daxing.adapter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.databinding.DataBindingUtil;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.example.beijing_daxing.R;
+import com.example.beijing_daxing.been.Stock;
+import com.example.beijing_daxing.databinding.ItemStoreCheckBinding;
+
+import java.util.List;
+
+/**
+ * @author wanghao
+ * @date 2024/1/19 14:32
+ */
+public class StoreCheckAdapter extends RecyclerView.Adapter {
+ private Context context;
+ private List list;
+ private LayoutInflater inflater;
+
+ public StoreCheckAdapter(Context context) {
+ this.context = context;
+ inflater = LayoutInflater.from(context);
+ }
+
+ public void setList(List list) {
+ this.list = list;
+ }
+
+ @Override
+ public MyViewHoder onCreateViewHolder(ViewGroup parent, int viewType) {
+ ItemStoreCheckBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_store_check, parent, false);
+ return new MyViewHoder(binding);
+ }
+
+ @Override
+ public void onBindViewHolder(MyViewHoder holder, int position) {
+ var binding = holder.getBinding();
+ binding.setItem(list.get(position));
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return list==null?0:list.size();
+ }
+
+ public class MyViewHoder extends RecyclerView.ViewHolder {
+ private ItemStoreCheckBinding binding;
+
+ public MyViewHoder( ItemStoreCheckBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ }
+
+ public ItemStoreCheckBinding getBinding() {
+ return binding;
+ }
+ }
+}
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 c4f8059..1f686ce 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
@@ -3,6 +3,7 @@ package com.example.beijing_daxing.base;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -30,6 +31,9 @@ public abstract class BaseActivity extends AppCompatActivity {
public UHFLongerManager uhfLongerManager;
private MediaPlayer mediaPlayer;
private MyReceiver myReceiver;
+
+ public Intent broadcastIntent;
+
@SuppressLint("UnspecifiedRegisterReceiverFlag")
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -37,7 +41,9 @@ public abstract class BaseActivity extends AppCompatActivity {
gson = new Gson();
initDialog();
initSan();
-
+ Intent intent = new Intent();
+ broadcastIntent = new Intent("android.rfid.FUN_KEY");
+ broadcastIntent.putExtra("keydown", false);
}
public class MyReceiver extends BroadcastReceiver {
diff --git a/app/src/main/java/com/example/beijing_daxing/been/Stock.java b/app/src/main/java/com/example/beijing_daxing/been/Stock.java
new file mode 100644
index 0000000..ff917c0
--- /dev/null
+++ b/app/src/main/java/com/example/beijing_daxing/been/Stock.java
@@ -0,0 +1,61 @@
+package com.example.beijing_daxing.been;
+
+import java.util.Objects;
+
+/**
+ * @author wanghao
+ * @date 2024/1/19 13:45
+ */
+public class Stock {
+ private int index;
+ private String epcCode;
+ private String locationCode;
+ private String state;
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public String getEpcCode() {
+ return epcCode;
+ }
+
+ public void setEpcCode(String epcCode) {
+ this.epcCode = epcCode;
+ }
+
+ public String getLocationCode() {
+ return locationCode;
+ }
+
+ public void setLocationCode(String locationCode) {
+ this.locationCode = locationCode;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Stock stock = (Stock) o;
+
+ return Objects.equals(epcCode, stock.epcCode);
+ }
+
+ @Override
+ public int hashCode() {
+ return epcCode != null ? epcCode.hashCode() : 0;
+ }
+}
diff --git a/app/src/main/res/layout/activity_home_page.xml b/app/src/main/res/layout/activity_home_page.xml
index 49ba505..0fb0763 100644
--- a/app/src/main/res/layout/activity_home_page.xml
+++ b/app/src/main/res/layout/activity_home_page.xml
@@ -34,7 +34,9 @@
android:layout_marginTop="30dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
+ android:verticalSpacing="20dp"
android:numColumns="2"
+
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
diff --git a/app/src/main/res/layout/activity_store_check.xml b/app/src/main/res/layout/activity_store_check.xml
new file mode 100644
index 0000000..e26bfc1
--- /dev/null
+++ b/app/src/main/res/layout/activity_store_check.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_store_check.xml b/app/src/main/res/layout/item_store_check.xml
new file mode 100644
index 0000000..3505049
--- /dev/null
+++ b/app/src/main/res/layout/item_store_check.xml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 940152f..129c38a 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -7,4 +7,7 @@
#3073ff
#F44336
#F2F3F5
+ #FFC107
+ #ADDCA7
+ #DEE3E6
\ No newline at end of file