增加 盘点

idata
wangh 1 year ago
parent 38ee648bb1
commit 7aba9a7370

@ -13,6 +13,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Beijingdaxing" android:theme="@style/Theme.Beijingdaxing"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".StoreCheckActivity"
android:exported="false" />
<activity <activity
android:name=".CheckActivity" android:name=".CheckActivity"
android:exported="false" /> android:exported="false" />
@ -33,9 +36,7 @@
</activity> </activity>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"> android:exported="true"></activity>
</activity>
</application> </application>
</manifest> </manifest>

@ -27,7 +27,7 @@ public class HomePageActivity extends AppCompatActivity {
List<HomeIcon> list = new ArrayList<>(); List<HomeIcon> list = new ArrayList<>();
list.add(new HomeIcon(R.mipmap.home_in1, "轮挡入库", InActivity.class)); 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_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_check, "轮挡报废", CheckActivity.class)); list.add(new HomeIcon(R.mipmap.home_check, "轮挡报废", CheckActivity.class));
list.add(new HomeIcon(R.mipmap.home_in, "废品入库", CheckActivity.class)); list.add(new HomeIcon(R.mipmap.home_in, "废品入库", CheckActivity.class));

@ -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<Stock> 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<String> tagList;
@Override
protected void sanRfid(List<String> 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.<MyResult>post(url + "/storecheck/select").tag(this).execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
var body = response.body();
if (body.getCode() == 0) {
list = gson.fromJson(body.getData().toString(), new TypeToken<List<Stock>>() {
}.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.<MyResult>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<MyResult> 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;
}
}

@ -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<StoreCheckAdapter.MyViewHoder> {
private Context context;
private List<Stock> list;
private LayoutInflater inflater;
public StoreCheckAdapter(Context context) {
this.context = context;
inflater = LayoutInflater.from(context);
}
public void setList(List<Stock> 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;
}
}
}

@ -3,6 +3,7 @@ package com.example.beijing_daxing.base;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
@ -30,6 +31,9 @@ public abstract class BaseActivity extends AppCompatActivity {
public UHFLongerManager uhfLongerManager; public UHFLongerManager uhfLongerManager;
private MediaPlayer mediaPlayer; private MediaPlayer mediaPlayer;
private MyReceiver myReceiver; private MyReceiver myReceiver;
public Intent broadcastIntent;
@SuppressLint("UnspecifiedRegisterReceiverFlag") @SuppressLint("UnspecifiedRegisterReceiverFlag")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -37,7 +41,9 @@ public abstract class BaseActivity extends AppCompatActivity {
gson = new Gson(); gson = new Gson();
initDialog(); initDialog();
initSan(); initSan();
Intent intent = new Intent();
broadcastIntent = new Intent("android.rfid.FUN_KEY");
broadcastIntent.putExtra("keydown", false);
} }
public class MyReceiver extends BroadcastReceiver { public class MyReceiver extends BroadcastReceiver {

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

@ -34,7 +34,9 @@
android:layout_marginTop="30dp" android:layout_marginTop="30dp"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp" android:layout_marginBottom="20dp"
android:verticalSpacing="20dp"
android:numColumns="2" android:numColumns="2"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="checkState"
type="androidx.databinding.ObservableBoolean" />
<variable
name="adapter"
type="com.example.beijing_daxing.adapter.StoreCheckAdapter" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".StoreCheckActivity"
android:background="@color/bg1"
android:orientation="vertical">
<TextView
style="@style/title_text"
android:layout_width="match_parent"
android:layout_height="45dp"
android:text="仓库盘点" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:background="@color/white"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:adapter="@{adapter}"
android:padding="10dp"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@{checkState?@color/yellow:@color/black}"
android:layout_marginStart="20dp"
android:text='@{checkState?"停止读取":"开始盘点"}'
android:textSize="20sp"
android:onClick="check_read"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="store_check_submit"
style="@style/button_style"
android:text="提交"/>
</LinearLayout>
</LinearLayout>
</layout>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="item"
type="com.example.beijing_daxing.been.Stock" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="2dp"
android:background='@{item.state.equals("Y")?@color/green:@color/item_bg}'
android:orientation="horizontal">
<TextView
android:id="@+id/item_index"
style="@style/item_text_style"
android:layout_width="40dp"
android:layout_height="match_parent"
android:text='@{String.valueOf(item.index)}' />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
style="@style/item_text_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="left"
android:text="@{item.epcCode}" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:layout_weight="1"
android:text="@{item.locationCode}" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
android:id="@+id/item_buttom"
style="@style/item_text_style"
android:layout_width="63dp"
android:layout_height="match_parent"
android:text='@{item.state.equals("Y")?"已盘点":"未盘点"}'
android:textColor='@{item.state.equals("Y")?@color/black:@color/red}' />
</LinearLayout>
</layout>

@ -7,4 +7,7 @@
<color name="blue">#3073ff</color> <color name="blue">#3073ff</color>
<color name="red">#F44336</color> <color name="red">#F44336</color>
<color name="bg1">#F2F3F5</color> <color name="bg1">#F2F3F5</color>
<color name="yellow">#FFC107</color>
<color name="green">#ADDCA7</color>
<color name="item_bg">#DEE3E6</color>
</resources> </resources>
Loading…
Cancel
Save