增加 入库自动扫描

idata
wanghao 6 months ago
parent 685451d5c9
commit f896ff9d90

@ -1,9 +1,14 @@
package com.example.beijing_daxing; package com.example.beijing_daxing;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableBoolean;
import android.annotation.SuppressLint;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
@ -32,7 +37,7 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
private InAdapter adapter; private InAdapter adapter;
private List<String> epcList; private List<String> epcList;
private ActivityInBinding binding; private ActivityInBinding binding;
private ObservableBoolean checkState;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -46,6 +51,8 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
adapter.setAdapterClickCall(this); adapter.setAdapterClickCall(this);
binding.setAdapter(adapter); binding.setAdapter(adapter);
setPower(33); setPower(33);
checkState=new ObservableBoolean();
binding.setCheckState(checkState);
} }
@Override @Override
@ -56,7 +63,8 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length); var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
if (!epcList.contains(epc)) { if (!epcList.contains(epc)) {
if (epc.substring(0,8).equals("42574C44")){ Log.e("TAG", "sanRfid:" + epc);
if (epc.substring(0,8).equals("53574C44")){
epcList.add(epc); epcList.add(epc);
} }
} }
@ -105,4 +113,39 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
} }
}); });
} }
@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() {
// Log.e("TAG", "发送广播读取RFID");
// sendBroadcast(broadcastIntent);
sanEpc();
handler.postDelayed(runnable, 0);
}
};
public void instore_check(View view) {
var b = checkState.get();
if (b) {
handler.removeCallbacks(runnable);
} else {
handler.postDelayed(runnable, 100);
}
checkState.set(!b);
}
@Override
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacks(runnable);
handler = null;
runnable = null;
}
} }

@ -48,7 +48,7 @@ public class OutActivity extends BaseActivity implements AdapterClickCall {
epcs.stream().forEach(t -> { epcs.stream().forEach(t -> {
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length); var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
if (!epcList.contains(epc)) { if (!epcList.contains(epc)) {
if (epc.substring(0,8).equals("42574C44")) { if (epc.substring(0,8).equals("53574C44")) {
epcList.add(epc); epcList.add(epc);
} }
} }

@ -96,9 +96,14 @@ public abstract class BaseActivity extends AppCompatActivity {
} }
public void setPower(int power){ public void setPower(int power){
Reader.READER_ERR readerErr = uhfLongerManager.setPower(power, power); try {
Log.e("TAG", "setPower:" + readerErr.name()); Reader.READER_ERR readerErr = uhfLongerManager.setPower(power, power);
Log.e("TAG", "readPower:" + uhfLongerManager.getPower()[0]); Log.e("TAG", "setPower:" + readerErr.name());
// Log.e("TAG", "readPower:" + uhfLongerManager.getPower()[0]);
}catch (Exception e){
}
} }
@Override @Override

@ -5,37 +5,44 @@
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<data> <data>
<variable <variable
name="vm" name="vm"
type="com.example.beijing_daxing.vm.InStoreVM" /> type="com.example.beijing_daxing.vm.InStoreVM" />
<variable <variable
name="adapter" name="adapter"
type="com.example.beijing_daxing.adapter.InAdapter" /> type="com.example.beijing_daxing.adapter.InAdapter" />
<variable
name="checkState"
type="androidx.databinding.ObservableBoolean" />
<import type="android.view.View"/>
</data> </data>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/bg1" android:background="@color/bg1"
android:orientation="vertical"
tools:context=".InActivity"> tools:context=".InActivity">
<TextView <TextView
style="@style/title_text" style="@style/title_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="45dp" android:layout_height="45dp"
android:text="轮挡入库"/> android:text="轮挡入库" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView2" android:id="@+id/recyclerView2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:background="@color/white"
android:layout_weight="1" android:layout_weight="1"
android:adapter="@{adapter}"
android:background="@color/white"
android:padding="10dp" android:padding="10dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
android:adapter="@{adapter}" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -71,7 +78,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="45dp" android:layout_height="45dp"
android:layout_gravity="center" android:layout_gravity="center"
android:text="@={vm.binchCode}"/> android:text="@={vm.binchCode}" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -89,7 +96,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:entries="@{vm.manus}" android:entries="@{vm.manus}"
android:onItemSelected="@{vm.selectManus}"/> android:onItemSelected="@{vm.selectManus}" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -106,19 +113,36 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:entries="@{vm.locations}" android:entries="@{vm.locations}"
android:onItemSelected="@{vm.selectLocation}"/> android:onItemSelected="@{vm.selectLocation}" />
</LinearLayout> </LinearLayout>
<LinearLayout
<Button
style="@style/button_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp" android:layout_height="55dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginBottom="12dp" android:layout_marginBottom="12dp"
android:text="提交" android:orientation="horizontal">
android:onClick="in_submit"
app:layout_constraintTop_toBottomOf="@+id/linearLayout4" <Button
tools:layout_editor_absoluteX="16dp" /> android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:backgroundTint="@{checkState?@color/yellow:@color/black}"
android:onClick="instore_check"
android:text='@{checkState?"停止读取":"开始盘点"}'
android:textSize="20sp" />
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginBottom="12dp"
android:layout_weight="1"
android:onClick="in_submit"
android:text="提交"
app:layout_constraintTop_toBottomOf="@+id/linearLayout4"
tools:layout_editor_absoluteX="16dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</layout> </layout>
Loading…
Cancel
Save