修改 地标绑定识别前缀

master
wanghao 5 months ago
parent 1dcadcd121
commit 7550cc741b

@ -4,7 +4,6 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="delegatedBuild" value="true" />
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />

@ -67,10 +67,14 @@ public class BindingDBActivity extends BaseActivity implements MyKeyInfoCall {
@Override
public void sanEpcCall(String epc) {
super.sanEpcCall(epc);
if (binding.hkEpc.getText().toString().isEmpty()) {
if (epc==null|| epc.isEmpty()) return;
if (epc.contains("HK")) {
binding.hkEpc.setText(epc);
} else {
}else if (epc.contains("DB")) {
binding.dbEpc.setText(epc);
}else {
Toast.makeText(context, "RFID识别失败格式有误"+epc, Toast.LENGTH_SHORT).show();
}
}
}

@ -84,7 +84,6 @@ public class JionActivity extends BaseActivity implements DialogClickCall {
super.onSuccess(response);
var body = response.body();
if (body.getCode() == 0) {
list = gson.fromJson(body.getJson(), new TypeToken<List<String>>() {
}.getType());
adapter.setList(list);

@ -68,7 +68,6 @@ public class MainActivity extends BaseActivity {
SharedPreferencesUtils.putstring("pass", pass);
SharedPreferencesUtils.putstring("ip", ip);
}
Intent intent = new Intent(MainActivity.this, HomePageActivity.class);
// Intent intent = new Intent(MainActivity.this, RflyActivity.class);
// Intent intent = new Intent(MainActivity.this, WebViewActivity.class);

@ -44,6 +44,8 @@ import java.util.Set;
public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback, Rfly.ReadTagDataCallback {
private Rfly hbtReader;
private ObservableBoolean state;
private ObservableBoolean readstate1;
private ObservableBoolean readstate2;
private ActivityRflyBinding binding;
private List<String> tagList;
private GoodsInfoAdapter adapter1;
@ -126,12 +128,21 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
list2 = new ArrayList<>();
adapter2.setList(list2);
binding.setAdapter2(adapter2);
readstate1=new ObservableBoolean();
readstate1.set(false);
binding.setReadstate1(readstate1);
readstate2=new ObservableBoolean();
readstate2.set(false);
binding.setReadstate2(readstate2);
}
// 返回RFID
@Override
public void ReadTagDataCallback(EpcBean epcBean) {
var strepc = epcBean.strepc;
Log.e("TAG", "ReadTagDataCallback:" +strepc );
Message message = new Message();
strepc = ASCIIUtil.hex2Str(strepc);
message.what=0;
@ -148,10 +159,17 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
int what = msg.what;
if (what==100){
readstate1.set(false);
readstate2.set(false);
return;
}
var str = msg.obj.toString();
if (str.contains("DB")) {
if (what==0){
binding.ledgerDb.setText(str);
readstate2.set(true);
}else {
// 地标
list2.add(0, str);
@ -161,6 +179,7 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
} else if (str.contains("HK")) {
if (what==0){
binding.ledgerHk.setText(str);
readstate1.set(true);
}else {
list1.add(str);
var length = str.length();
@ -178,9 +197,11 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
if (state.get()) {
hbtReader.ScanTags();
state.set(false);
startTask();//开始定时清理
} else {
hbtReader.StopScan();
state.set(true);
stopTask();//停止-在停止读取的时候
}
} catch (ReaderException e) {
e.printStackTrace();
@ -263,8 +284,8 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
// 提交
public void blueToothSubmit(View view) {
if (!state.get()) {
Toast.makeText(context, "先停止读取RFID", Toast.LENGTH_SHORT).show();
return;
Toast.makeText(context, "已停止读取", Toast.LENGTH_SHORT).show();
blueToothSanRFID(null);
}
if (list1.isEmpty() || list2.isEmpty()) return;
OkGo.<MyResult>post("http://" + SharedPreferencesUtils.getstring("ip", "") + "/api/blueToothSubmit")
@ -288,4 +309,32 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
});
}
private Runnable task;
// 开启定时任务
private void startTask() {
stopTask();
handler.postDelayed(task = new Runnable() {
@Override
public void run() {
// 在这里执行具体的任务
Log.d("HandlerTask", "run");
Message message = new Message();
message.what=100;
handler.sendMessage(message);
// 任务执行完后再次调用postDelayed开启下一次任务
handler.postDelayed(this, 500);
}
}, 0);
}
// 停止定时任务
private void stopTask() {
if (task != null) {
handler.removeCallbacks(task);
task = null;
}
readstate1.set(false);
readstate2.set(false);
}}

@ -0,0 +1,44 @@
package com.example.bgsrfidtrack.been;
/**
* @author wanghao
* @date 2024/8/2 17:28
*/
public class JionBeen {
private int index;
private String epc;
private boolean checkState;
private boolean visbState;
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getEpc() {
return epc;
}
public void setEpc(String epc) {
this.epc = epc;
}
public boolean isCheckState() {
return checkState;
}
public void setCheckState(boolean checkState) {
this.checkState = checkState;
}
public boolean isVisbState() {
return visbState;
}
public void setVisbState(boolean visbState) {
this.visbState = visbState;
}
}

@ -13,6 +13,13 @@
name="state"
type="androidx.databinding.ObservableBoolean" />
<variable
name="readstate1"
type="androidx.databinding.ObservableBoolean" />
<variable
name="readstate2"
type="androidx.databinding.ObservableBoolean" />
<variable
name="adapter1"
type="com.example.bgsrfidtrack.adapter.GoodsInfoAdapter" />
@ -20,6 +27,7 @@
<variable
name="adapter2"
type="com.example.bgsrfidtrack.adapter.GoodsInfoAdapter" />
<import type="android.view.View"/>
</data>
@ -90,9 +98,15 @@
<TextView
android:id="@+id/ledger_hk"
style="@style/santextbg"
android:layout_width="match_parent"
android:layout_width="265dp"
android:layout_height="match_parent" />
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:src="@mipmap/icon_read_state"
android:visibility="@{readstate1?View.VISIBLE:View.GONE}" />
</LinearLayout>
@ -111,8 +125,13 @@
<TextView
android:id="@+id/ledger_db"
style="@style/santextbg"
android:layout_width="match_parent"
android:layout_width="265dp"
android:layout_height="match_parent" />
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:src="@mipmap/icon_read_state"
android:visibility="@{readstate2?View.VISIBLE:View.GONE}" />
</LinearLayout>

@ -9,6 +9,9 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp">
<!-- <CheckBox-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="match_parent"/>-->
<TextView
android:id="@+id/item_index"

Loading…
Cancel
Save