|
|
|
|
@ -1,11 +1,15 @@
|
|
|
|
|
package com.example.writeepc;
|
|
|
|
|
|
|
|
|
|
import static androidx.constraintlayout.helper.widget.MotionEffect.TAG;
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
|
|
|
|
|
import androidx.databinding.DataBindingUtil;
|
|
|
|
|
|
|
|
|
|
@ -34,23 +38,64 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
private ActivityShuangqian2Binding binding;
|
|
|
|
|
private MyMesInfoAdapter adapter;
|
|
|
|
|
private MyMesInfoAdapter adapter;
|
|
|
|
|
private Button traceSanButton;
|
|
|
|
|
private boolean sanState = true;
|
|
|
|
|
private Handler handler = new Handler();
|
|
|
|
|
private Runnable runnable;
|
|
|
|
|
private MyKeyReceiver keyReceiver;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
binding = DataBindingUtil.setContentView(this, R.layout.activity_shuangqian2);
|
|
|
|
|
initUHFRManager1();
|
|
|
|
|
|
|
|
|
|
int powerTrace = Integer.parseInt(SharedPreferencesUtils.getstring("powerTrace", "22"));
|
|
|
|
|
// 设置功率
|
|
|
|
|
String powerTrace1 = SharedPreferencesUtils.getstring("powerTrace", "22");
|
|
|
|
|
int powerTrace = Integer.parseInt(powerTrace1);
|
|
|
|
|
Reader.READER_ERR readerErr = uhfrManager.setPower(powerTrace, powerTrace);
|
|
|
|
|
Log.e("TAG", "追溯设置功率:" + readerErr.name());
|
|
|
|
|
Log.e("TAG", "追溯设置功率" + powerTrace1 + ":" + readerErr.name());
|
|
|
|
|
initDialog();
|
|
|
|
|
adapter=new MyMesInfoAdapter(this);
|
|
|
|
|
adapter = new MyMesInfoAdapter(this);
|
|
|
|
|
binding.setAdapter(adapter);
|
|
|
|
|
traceSanButton = binding.traceSanButton;
|
|
|
|
|
runnable = new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
if (sanState) {
|
|
|
|
|
handler.removeCallbacks(runnable);
|
|
|
|
|
} else {
|
|
|
|
|
readEPC(12);
|
|
|
|
|
handler.postDelayed(runnable, 1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
keyReceiver = new MyKeyReceiver();
|
|
|
|
|
IntentFilter intentFilter = new IntentFilter();
|
|
|
|
|
intentFilter.addAction("android.rfid.FUN_KEY");
|
|
|
|
|
registerReceiver(keyReceiver, intentFilter);
|
|
|
|
|
|
|
|
|
|
String ACTION_CLOSE_SCAN = "com.rfid.CLOSE_SCAN";
|
|
|
|
|
Intent toKillService = new Intent();
|
|
|
|
|
toKillService.setAction(ACTION_CLOSE_SCAN);
|
|
|
|
|
sendBroadcast(toKillService);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void dataReadRFID(View view) {
|
|
|
|
|
readEPC(12);
|
|
|
|
|
if (sanState) {
|
|
|
|
|
handler.postDelayed(runnable, 0);
|
|
|
|
|
sanState = false;
|
|
|
|
|
traceSanButton.setBackgroundResource(R.drawable.button_bg2);
|
|
|
|
|
traceSanButton.setText("停止扫描");
|
|
|
|
|
} else {
|
|
|
|
|
sanState = true;
|
|
|
|
|
handler.removeCallbacks(runnable);
|
|
|
|
|
traceSanButton.setBackgroundResource(R.drawable.button_bg1);
|
|
|
|
|
traceSanButton.setText("开始扫描");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String msg="<Entity><ID>37f82ad8-6a16-4b9b-880c-78ebf644970a</ID><FAC>02</FAC><BARCODE>2408418883</BARCODE><STATE>1</STATE><CUSQTY>0</CUSQTY><CUDQTY>0</CUDQTY><CUBQTY>0</CUBQTY><CUIQTY>0</CUIQTY><BUITNBR>000000000080435113</BUITNBR><BUITDSC>2045</BUITDSC><BUDAT xsi:type=\"xsd:dateTime\">2025-08-04T00:00:00</BUDAT><BUTIM xsi:type=\"xsd:dateTime\">2025-08-04T10:55:31.517</BUTIM><BUSHT>1</BUSHT><BUBAN /><BUMCH>L403</BUMCH><BUNAM>张磊</BUNAM><BUNAMCOD>HL4969</BUNAMCOD><BUSQTY>1</BUSQTY><BUDQTY>0</BUDQTY><BUBQTY>0</BUBQTY><BUIQTY>0</BUIQTY><BUPLANCOD>YC250804L403204511</BUPLANCOD><BUCOTCOD /><NORMALSTA>P</NORMALSTA><TYRENO>2408418883</TYRENO><BUVERSION /><CRTIM xsi:type=\"xsd:dateTime\">2025-08-04T10:55:31.517</CRTIM><IS_DELETE>0</IS_DELETE><BUHELPER1 /><BUHELPER2 /><BUQCSTATE>1</BUQCSTATE><CUWARNING xsi:nil=\"true\" /><CULTIM>0</CULTIM><CUKTIM>0</CUKTIM><SPEC>S2045-05</SPEC><DOT>0</DOT><BUHELPER3 /><BUASS1 /><BUASS2 /><BUASS3 /><BUASS4 /><BUASS5 /><WMS_FLAG>0</WMS_FLAG><BUCARNO /></Entity>";
|
|
|
|
|
// jiexi(msg);
|
|
|
|
|
|
|
|
|
|
@ -63,17 +108,18 @@ private MyMesInfoAdapter adapter;
|
|
|
|
|
binding.dataEpc.setText(result);
|
|
|
|
|
|
|
|
|
|
if (readState) {
|
|
|
|
|
dataReadRFID(null);
|
|
|
|
|
// callWebService(buildSelectRequest(result));
|
|
|
|
|
haohuaMesSelect(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void haohuaMesSelect(String result) {
|
|
|
|
|
OkGo.<MyResult>post("http://192.168.26.26:5050/UMInterface/RFID/tyreTracingBack")
|
|
|
|
|
.params("rfid",result)
|
|
|
|
|
.execute(new MyRecultCall(dialog,this) {
|
|
|
|
|
.params("rfid", result)
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
@ -81,16 +127,18 @@ private MyMesInfoAdapter adapter;
|
|
|
|
|
MyResult body = response.body();
|
|
|
|
|
try {
|
|
|
|
|
if (body.getCode() == 200) {
|
|
|
|
|
List<String> list=gson.fromJson(body.getDataJson(),new TypeToken<List<String>>(){}.getType());
|
|
|
|
|
if (list.isEmpty()){
|
|
|
|
|
List<String> list =
|
|
|
|
|
gson.fromJson(body.getDataJson(), new TypeToken<List<String>>() {
|
|
|
|
|
}.getType());
|
|
|
|
|
if (list.isEmpty()) {
|
|
|
|
|
tipsDialog.setTip(false, "未返回信息");
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
List<MESInfo> mesInfos=new ArrayList<>(list.size());
|
|
|
|
|
list.forEach(item->{
|
|
|
|
|
List<MESInfo> mesInfos = new ArrayList<>(list.size());
|
|
|
|
|
list.forEach(item -> {
|
|
|
|
|
String[] split = item.split(":");
|
|
|
|
|
MESInfo mesInfo=new MESInfo();
|
|
|
|
|
MESInfo mesInfo = new MESInfo();
|
|
|
|
|
mesInfo.setTitle(split[0]);
|
|
|
|
|
mesInfo.setInfo(split[1]);
|
|
|
|
|
mesInfos.add(mesInfo);
|
|
|
|
|
@ -133,21 +181,25 @@ private MyMesInfoAdapter adapter;
|
|
|
|
|
String str = "<faultstring>";
|
|
|
|
|
int faultstringIndex = result.indexOf(str);
|
|
|
|
|
if (faultstringIndex > -1) {
|
|
|
|
|
String faultstring = result.substring(faultstringIndex + str.length(), result.indexOf("</faultstring>"));
|
|
|
|
|
String faultstring =
|
|
|
|
|
result.substring(faultstringIndex + str.length(), result.indexOf("</faultstring>"));
|
|
|
|
|
tipsDialog.setTip(false, faultstring);
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int codeIndex = result.indexOf("<Code>");
|
|
|
|
|
if (codeIndex > -1) {
|
|
|
|
|
String resultCode = result.substring(codeIndex + 6, result.indexOf("</Code>"));
|
|
|
|
|
String resultCode =
|
|
|
|
|
result.substring(codeIndex + 6, result.indexOf("</Code>"));
|
|
|
|
|
if (resultCode.equals("200")) {
|
|
|
|
|
String resultMsg = result.substring(result.indexOf("<Entity>") + 8, result.indexOf("</Entity>"));
|
|
|
|
|
String resultMsg =
|
|
|
|
|
result.substring(result.indexOf("<Entity>") + 8, result.indexOf("</Entity>"));
|
|
|
|
|
|
|
|
|
|
jiexi(resultMsg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String resultMsg = result.substring(result.indexOf("<Msg>") + 5, result.indexOf("</Msg>"));
|
|
|
|
|
String resultMsg =
|
|
|
|
|
result.substring(result.indexOf("<Msg>") + 5, result.indexOf("</Msg>"));
|
|
|
|
|
tipsDialog.setTip(false, resultMsg);
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
}
|
|
|
|
|
@ -166,7 +218,6 @@ private MyMesInfoAdapter adapter;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建验证信息
|
|
|
|
|
private String buildSelectRequest(String epcid) {
|
|
|
|
|
StringBuilder soapRequest = new StringBuilder();
|
|
|
|
|
@ -256,4 +307,21 @@ private MyMesInfoAdapter adapter;
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class MyKeyReceiver extends BroadcastReceiver {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
|
var keydown = intent.getBooleanExtra("keydown", false);
|
|
|
|
|
if (!keydown) {
|
|
|
|
|
dataReadRFID(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
unregisterReceiver(keyReceiver);
|
|
|
|
|
}
|
|
|
|
|
}
|