Compare commits

..

1 Commits

Author SHA1 Message Date
wanghao 2f48e3f31d 增加 风神接口 7 months ago

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="com.codeverse.userSettings.MarscodeWorkspaceAppSettingsState">
<option name="ckgOperationStatus" value="SUCCESS" />
<option name="progress" value="0.90625" />
</component>
</project>

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidTestResultsUserPreferences">
<option name="androidTestResultsTableState">
<map>
<entry key="-941396539">
<value>
<AndroidTestResultsTableState>
<option name="preferredColumnWidths">
<map>
<entry key="Duration" value="90" />
<entry key="Tests" value="360" />
<entry key="alps k62v1_3h" value="120" />
</map>
</option>
</AndroidTestResultsTableState>
</value>
</entry>
<entry key="-531529726">
<value>
<AndroidTestResultsTableState>
<option name="preferredColumnWidths">
<map>
<entry key="Duration" value="90" />
<entry key="Pixel_2_API_33" value="120" />
<entry key="Tests" value="360" />
<entry key="alps k62v1_3h" value="120" />
</map>
</option>
</AndroidTestResultsTableState>
</value>
</entry>
<entry key="1094103868">
<value>
<AndroidTestResultsTableState>
<option name="preferredColumnWidths">
<map>
<entry key="Duration" value="90" />
<entry key="Tests" value="360" />
<entry key="alps k62v1_3h" value="120" />
</map>
</option>
</AndroidTestResultsTableState>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -31,8 +31,8 @@ android {
dataBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_15
targetCompatibility JavaVersion.VERSION_15
}
}
@ -48,12 +48,10 @@ dependencies {
implementation files('libs\\reader(1).jar')
implementation files('libs\\UHF67_v3.6.jar')
implementation 'androidx.preference:preference:1.2.0'
implementation files('libs\\jxl-2.6.12.jar')
// implementation files('libs\\uhfr_v1.8.jar')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'org.litepal.android:java:3.0.0'
implementation 'com.tonystark.android:socket:4.1.0'
//使 OkSocketServer Java,Server.
implementation 'com.tonystark.android:socket-server:4.1.0'

Binary file not shown.

Binary file not shown.

@ -0,0 +1,140 @@
package com.example.writeepc;
import android.util.Log;
import com.example.writeepc.been.MESInfo;
import junit.framework.TestCase;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ShuangqianActivity2Test extends TestCase {
public void test() {
String result = """
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetRFIDBindingInfoResponse xmlns="http://tempuri.org/">
<GetRFIDBindingInfoResult>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="品牌" type="xs:string" minOccurs="0"/>
<xs:element name="规格" type="xs:string" minOccurs="0"/>
<xs:element name="花纹类型" type="xs:string" minOccurs="0"/>
<xs:element name="胎号" type="xs:string" minOccurs="0"/>
<xs:element name="DOT" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<>123</>
<>1234</>
<>1235</>
<>1236</>
<DOT>1236</DOT>
</Table>
</NewDataSet>
</diffgr:diffgram>
</GetRFIDBindingInfoResult>
</GetRFIDBindingInfoResponse>
</soap:Body>
</soap:Envelope>
""";
String regex = "<Table .*\">";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(result);
if (!matcher.find()) {
System.out.println("未找到匹配的内容");
return;
}
String matched = matcher.group();// 匹配内容
int beginIndex = matcher.start() + matched.length();
int endIndex = result.indexOf("</Table>");
Log.e("TAG", "test1:" + beginIndex);
Log.e("TAG", "test2:" + endIndex);
if (beginIndex >= endIndex) {
System.out.println("未找到匹配的内容");
return;
}
result = result.substring(beginIndex, endIndex);
System.out.println("截取内容:" + result);
// <品牌>风神</品牌><规格>10.00R20</规格><花纹类型>AGC08</花纹类型)<胎号>ZB250901399</胎号><DOT>3625</DOT>
String[] str=new String[]{"品牌","规格","花纹类型","胎号","DOT"};
for (String s : str) {
String tag = "<" + s + ">";
System.out.println("-"+result.substring(result.indexOf(tag) + tag.length(), result.indexOf("</"+s+">"))+"-");
}
/* InputStream inputStream = new StringBufferInputStream(result);
XmlPullParser parser = Xml.newPullParser();
parser.setInput(inputStream, "utf-8"); // 设置输入流和编码
int eventType = parser.getEventType();
boolean isInTable = false; // 是否进入<Table>节点
while (eventType != XmlPullParser.END_DOCUMENT) {
String tagName = parser.getName();
System.out.println("tab name :"+tagName);
switch (eventType) {
case XmlPullParser.START_TAG:
// 找到<Table>节点,初始化数据对象
if ("Table".equals(tagName)) {
isInTable = true;
} else if (isInTable) {
switch (tagName) {
case "品牌":
String trim = parser.nextText().trim();
System.out.println(trim);
break;
case "规格":
String trim2 = parser.nextText().trim();
System.out.println(trim2);
break;
case "花纹类型":
String trim3 = parser.nextText().trim();
System.out.println(trim3);
break;
case "胎号":
String trim4 = parser.nextText().trim();
System.out.println(trim4);
break;
case "DOT":
String trim5 = parser.nextText().trim();
System.out.println(trim5);
break;
}
}
break;
case XmlPullParser.END_TAG:
// 退出<Table>节点
if ("Table".equals(tagName)) {
isInTable = false;
}
break;
}
eventType = parser.next(); // 解析下一个事件
}*/
}
}

@ -1,12 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<application
android:name=".base.MyApplication"
@ -19,53 +16,28 @@
android:supportsRtl="true"
android:theme="@style/Theme.WriteEpc"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".UserXuanchuanActivity"
android:exported="true"
android:label="宣传">
</activity>
<activity
android:name=".WriteUserActivity"
android:exported="true"
android:label="读写EPC区">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
tools:targetApi="31" >
<activity
android:name=".SettingsActivity"
android:exported="false"
android:label="@string/title_activity_settings" />
<activity
android:name=".SettingsActivity2"
android:name=".ShuangqianActivity2"
android:theme="@style/traceActivityStyle"
android:exported="false" />
<activity
android:name=".IntentSelectActivity"
android:exported="false"
android:theme="@style/traceActivityStyle" />
<activity
android:name=".ShuangqianActivity2"
android:exported="false"
android:theme="@style/traceActivityStyle" />
<activity
android:name=".HomeActivity"
android:exported="true">
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HomeActivity2"
android:exported="true"
android:label="轮胎信息追溯"></activity>
<activity
android:name=".ShuangqianActivity"
android:exported="true" />
android:exported="true" >
</activity>
<receiver
android:name=".broadcast.MyScannerReceiver"
@ -80,7 +52,7 @@
android:theme="@style/socketActivityStyle" />
<activity
android:name=".KillActivity"
android:exported="true">
android:exported="true" >
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
@ -89,22 +61,22 @@
</activity>
<activity
android:name=".MoreActivity"
android:exported="true"
android:label="扫描EPC">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
android:exported="true" >
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
<activity
android:name=".MainActivity"
android:exported="true" >
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
</application>
</manifest>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<litepal>
<dbname value="write_tag_info" />
<version value="1" />
<list>
<mapping class="com.example.writeepc.been.WriteInfo"></mapping>
</list>
</litepal>

@ -1,6 +1,4 @@
package com.example.writeepc.utils;
import android.util.Log;
package com.example.writeepc;
/**
* @author: wangh
@ -33,15 +31,12 @@ public class ASCIIUtil {
return sb.toString();
}
public static String hexTo4ZN(String hex) {
public static String hexTo4ZN(String hex) throws Exception {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hex.length() - 1; i += 4) {
String h = hex.substring(i, (i + 4));
Log.e("TAG", "hexTo4ZN:" + h);
if (!h.equals("0000")) {
sb.append((char) Integer.parseInt(h, 16));
}
sb.append((char) Integer.parseInt(h, 16));
}
return sb.toString();

@ -24,7 +24,6 @@ public class HomeActivity extends BaseActivity {
RadioButton button2 = this.findViewById(R.id.home_2);
RadioButton button1_1 = this.findViewById(R.id.home_1_1);
RadioButton button4 = this.findViewById(R.id.home_4);
Intent intent = new Intent(this, ShuangqianActivity.class);
button1.setOnClickListener(v -> {
intent.putExtra("type",true);
@ -41,10 +40,6 @@ public class HomeActivity extends BaseActivity {
button4.setOnClickListener(v -> {
startActivity(new Intent(this, SettingsActivity.class));
});
}
@Override

@ -1,59 +0,0 @@
package com.example.writeepc;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.RadioButton;
import android.widget.Toast;
import com.example.writeepc.base.BaseActivity;
import com.example.writeepc.base.MyApplication;
import com.handheld.uhfr.UHFRManager;
public class HomeActivity2 extends BaseActivity {
private UHFRManager uhfrManager;
private long exitTime = 0L;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home2);
uhfrManager = UHFRManager.getInstance();
MyApplication.getApplication().setUhfrManager(uhfrManager);
RadioButton button4 = this.findViewById(R.id.home2_4);
RadioButton button3 = this.findViewById(R.id.home2_3);
button4.setOnClickListener(v -> {
startActivity(new Intent(this, SettingsActivity2.class));
});
button3.setOnClickListener(v -> {
startActivity(new Intent(this, IntentSelectActivity.class));
});
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == 4) {
if ((System.currentTimeMillis() - exitTime) > 2000) {
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
return true;
} else {
finish();
}
}
return false;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (uhfrManager != null) {
uhfrManager.close();
uhfrManager = null;
}
}
}

@ -1,9 +1,7 @@
package com.example.writeepc.been;
package com.example.writeepc;
import androidx.databinding.BaseObservable;
import java.util.Arrays;
public class InfoData extends BaseObservable {
private int power;
private String epc;
@ -14,36 +12,6 @@ public class InfoData extends BaseObservable {
private String readTId;
private byte[] tidBytes;
private String writeUser;
private String readUser;
private int readLenth=4;
public int getReadLenth() {
return readLenth;
}
public void setReadLenth(int readLenth) {
this.readLenth = readLenth;
}
public String getWriteUser() {
return writeUser;
}
public void setWriteUser(String writeUser) {
this.writeUser = writeUser;
notifyChange();
}
public String getReadUser() {
return readUser;
}
public void setReadUser(String readUser) {
this.readUser = readUser;
notifyChange();
}
public byte[] getTidBytes() {
return tidBytes;
}
@ -115,18 +83,4 @@ public class InfoData extends BaseObservable {
this.state = state;
notifyChange();
}
public void clear() {
epc = null;
writeEpc = null;
readEpc = null;
readAscii = null;
readTId = null;
tidBytes = null;
writeUser = null;
readUser = null;
notifyChange();
}
}

@ -1,238 +0,0 @@
package com.example.writeepc;
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.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import androidx.databinding.DataBindingUtil;
import com.example.writeepc.adapter.MyMesInfoAdapter;
import com.example.writeepc.base.BaseActivity;
import com.example.writeepc.base.okgo.MyRecultCall;
import com.example.writeepc.base.okgo.MyResult;
import com.example.writeepc.been.MESInfo;
import com.example.writeepc.databinding.ActivityIntentSelectBinding;
import com.example.writeepc.utils.SharedPreferencesUtils;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class IntentSelectActivity extends BaseActivity {
private final Handler handler = new Handler();
public MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private ActivityIntentSelectBinding binding;
private MyMesInfoAdapter adapter;
private Button traceSanButton;
private boolean sanState = true;
private Runnable runnable;
private Runnable tokenRunnable;
private MyKeyReceiver keyReceiver;
private String ip;
private String token;
@SuppressLint("UnspecifiedRegisterReceiverFlag")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_intent_select);
initUHFRManager1();
// 设置功率
String powerTrace1 = SharedPreferencesUtils.getstring("powerTrace2", "22");
int powerTrace = Integer.parseInt(powerTrace1);
Reader.READER_ERR readerErr = uhfrManager.setPower(powerTrace, powerTrace);
Log.e("TAG", "追溯设置功率" + powerTrace1 + ":" + readerErr.name());
initDialog();
adapter = new MyMesInfoAdapter(this);
binding.setAdapter(adapter);
traceSanButton = binding.traceSanButton;
runnable = () -> {
if (sanState) {
handler.removeCallbacks(runnable);
} else {
readEPC(12);
handler.postDelayed(runnable, 1000);
}
};
// tokenRunnable = () -> {
// requestToken();
// };
handler.postDelayed(tokenRunnable, 0);
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);
binding.dataEpc.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (s.length() == 24) {
requestToken(s.toString());
}
}
});
ip = SharedPreferencesUtils.getstring("ip", "https://rfidpub.haohuatire.com:7443");
}
private void requestToken(String epc) {
Map<String, String> map = new HashMap<>();
map.put("AppId", "app-20250704032545-nmmhn8jw");
map.put("AppSecret", "dXJZQKubbqhSPCugtA49rsDGACmN5CMD4ItTfP11+DA=");
OkGo.<MyResult>post(ip + "/UMInterface/Auth/AccessToken").upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
MyResult body = response.body();
if (body.getCode() == 200) {
String dataJson = body.getDataJson();
JsonObject jsonObject = JsonParser.parseString(dataJson).getAsJsonObject();
token = jsonObject.get("Token").getAsString();
Log.e("TAG", "onSuccess:token=" + token);
binding.traceSanButton1.setVisibility(View.GONE);
// handler.postDelayed(tokenRunnable, 60 * 1000 * 90);
haohuaMesSelect(epc);
} else {
tipsDialog.setTip(false, body.getInfo());
tipsDialog.show();
binding.traceSanButton1.setVisibility(View.VISIBLE);
}
}
});
}
public void intentRequestToken(View view) {
requestToken(binding.dataEpc.getText().toString());
}
public void dataReadRFID(View view) {
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("开始扫描");
}
}
@Override
protected void readTidReault(boolean readState, String result, byte[] rdata) {
super.readTidReault(readState, result, rdata);
binding.dataEpc.setText(result);
if (readState) {
dataReadRFID(null);
}
}
private void haohuaMesSelect(String result) {
OkGo.<MyResult>post(ip + "/UMInterface/RFID/sellTyreTracingBack")
.headers("Token", token)
.params("rfid", result).execute(new MyRecultCall(dialog, this) {
@SuppressLint("NotifyDataSetChanged")
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
MyResult body = response.body();
try {
if (body.getCode() == 200) {
String dataJson = body.getDataJson();
if (dataJson == null || dataJson.equals("[]")) {
tipsDialog.setTip(false, "未查询到相关信息");
tipsDialog.show();
adapter.setList(null);
return;
}
dataJson = dataJson.replace("[{", "").replace("\"", "").trim();
String[] split = dataJson.split(",");
List<MESInfo> mesInfos = new ArrayList<>();
for (String item : split) {
String[] split1 = item.split(":");
MESInfo mesInfo = new MESInfo();
mesInfo.setTitle(split1[0]);
mesInfo.setInfo(split1[1]);
mesInfos.add(mesInfo);
}
;
adapter.setList(mesInfos);
} else {
tipsDialog.setTip(false, body.getInfo());
tipsDialog.show();
adapter.setList(null);
}
} catch (Exception e) {
tipsDialog.setTip(false, "接口返回信息异常,解析失败");
tipsDialog.show();
}
adapter.notifyDataSetChanged();
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(keyReceiver);
}
private class MyKeyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
var keydown = intent.getBooleanExtra("keydown", false);
if (!keydown) {
dataReadRFID(null);
}
}
}
}

@ -10,12 +10,12 @@ import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.example.writeepc.been.InfoData;
import com.example.writeepc.databinding.ActivityMainBinding;
import com.example.writeepc.utils.ASCIIUtil;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
import java.util.List;
import cn.pda.serialport.Tools;
public class MainActivity extends AppCompatActivity {
@ -67,13 +67,6 @@ public class MainActivity extends AppCompatActivity {
public void readTid(View view) {
byte[] rdata = new byte[12];
Reader.READER_ERR readerErr = uhfrManager.getTagData(2, 0, 6, rdata, accesspwd, timeOut);
uhfrManager.setGen2session(0);
//taget
uhfrManager.setTarget(0);
//q value
uhfrManager.setQvaule(0);
//FastId
uhfrManager.setFastID(false);
Log.e("TAG", "readTid:" + readerErr.name());
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
infoData.setReadTId(Tools.Bytes2HexString(rdata, 12));
@ -149,6 +142,5 @@ public class MainActivity extends AppCompatActivity {
// uhfrManager.asyncStopReading();
uhfrManager.close();
uhfrManager = null;
}
}

@ -4,7 +4,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
@ -12,7 +11,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import com.example.writeepc.databinding.ActivityMoreBinding;
import com.example.writeepc.utils.ASCIIUtil;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
@ -28,7 +26,6 @@ public class MoreActivity extends AppCompatActivity {
private boolean aBoolean;
private ActivityMoreBinding binding;
private MyAdapter adapter;
public MediaPlayer music;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -38,7 +35,6 @@ public class MoreActivity extends AppCompatActivity {
adapter = new MyAdapter(this);
binding.setAdapter(adapter);
uhfrManager = UHFRManager.getInstance();
music = MediaPlayer.create(this, com.example.writeepc.R.raw.msg);
registerReceiver();
}
@ -92,7 +88,7 @@ public class MoreActivity extends AppCompatActivity {
if (strings == null || strings.isEmpty()) {
return;
}
music.start();
List<String> list = new ArrayList<>(strings.size());
strings.forEach(taginfo -> {

@ -17,7 +17,7 @@ import java.util.List;
public class SettingsActivity extends AppCompatActivity {
private Spinner powerBinding;
private Spinner powerTrace;
// private EditText settingIp;
private EditText settingIp;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -26,19 +26,19 @@ public class SettingsActivity extends AppCompatActivity {
DataBindingUtil.setContentView(this, R.layout.settings_activity);
powerBinding = binding.selectPowerBinding;
powerTrace = binding.selectPowerTrace;
// settingIp = binding.settingIp;
settingIp = binding.settingIp;
String bindingPower = SharedPreferencesUtils.getstring("powerBinding", "22");
String tracePower = SharedPreferencesUtils.getstring("powerTrace", "22");
List<String> powerList = Arrays.asList(getResources().getStringArray(R.array.power));
powerBinding.setSelection(powerList.indexOf(bindingPower));
powerTrace.setSelection(powerList.indexOf(tracePower));
// settingIp.setText(SharedPreferencesUtils.getstring("ip", "https://rfidpub.haohuatire.com:7443"));
settingIp.setText(SharedPreferencesUtils.getstring("ip", "http://10.72.36.3:8090/FSRFID.asmx"));
}
public void saveInfo(View view) {
SharedPreferencesUtils.putstring("powerBinding", powerBinding.getSelectedItem().toString());
SharedPreferencesUtils.putstring("powerTrace", powerTrace.getSelectedItem().toString());
// SharedPreferencesUtils.putstring("ip", settingIp.getText().toString());
SharedPreferencesUtils.putstring("ip", settingIp.getText().toString());
finish();
}
}

@ -1,45 +0,0 @@
package com.example.writeepc;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Spinner;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import com.example.writeepc.databinding.SettingsActivity2Binding;
import com.example.writeepc.databinding.SettingsActivityBinding;
import com.example.writeepc.utils.SharedPreferencesUtils;
import java.util.Arrays;
import java.util.List;
public class SettingsActivity2 extends AppCompatActivity {
private Spinner powerTrace;
private EditText settingIp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SettingsActivity2Binding binding =
DataBindingUtil.setContentView(this, R.layout.settings_activity2);
powerTrace = binding.selectPowerTrace;
settingIp = binding.settingIp;
String tracePower = SharedPreferencesUtils.getstring("powerTrace2", "22");
List<String> powerList = Arrays.asList(getResources().getStringArray(R.array.power));
powerTrace.setSelection(powerList.indexOf(tracePower));
settingIp.setText(SharedPreferencesUtils.getstring("ip", "https://rfidpub.haohuatire.com:7443"));
}
public void saveInfo(View view) {
SharedPreferencesUtils.putstring("powerTrace2", powerTrace.getSelectedItem().toString());
SharedPreferencesUtils.putstring("ip", settingIp.getText().toString());
finish();
}
}

@ -2,6 +2,7 @@ package com.example.writeepc;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
@ -20,6 +21,8 @@ import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.uhf.api.cls.Reader;
import java.time.Year;
public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
private ActivityShuangqianBinding binding;
@ -29,19 +32,15 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_shuangqian);
String ACTION_SCAN_INIT = "com.rfid.SCAN_INIT";
Intent intent = new Intent();
intent.setAction(ACTION_SCAN_INIT);
sendBroadcast(intent);
initUHFRManager1();
initDialog();
int powerBinding = Integer.parseInt(SharedPreferencesUtils.getstring("powerBinding", "22"));
Reader.READER_ERR readerErr = uhfrManager.setPower(powerBinding, powerBinding);
// Reader.READER_ERR readerErr = uhfrManager.setPower(powerBinding, powerBinding);
myReceiver = new MyScannerReceiver(this);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.rfid.SCAN");
@ -50,6 +49,10 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
binding.setTitle(type ? "MES轮胎绑定" : "解绑");
binding.setType(type);
// uriLastStr = type ? "barcodeAndRFIDBinding" : "unBinding";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
binding.socketYear.setText(String.valueOf(Year.now().getValue()));
}
}
// 读取
@ -73,50 +76,53 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
public void submit(View view) {
String epc = binding.socketEpc.getText().toString();
String code = binding.socketBarcode.getText().toString();
if (epc.isEmpty() || code.isEmpty()) return;
haohuaSubmit(epc, code);
// callWebService(buildSoapRequest(epc, code));//双钱
String year = binding.socketYear.getText().toString();
if (epc.isEmpty() || code.isEmpty() || year.isEmpty()) return;
// haohuaSubmit(epc, code);
callWebService(buildSoapRequest(epc, code, year));// 双钱
}
// 解绑
public void unBindingSubmit(View view) {
String epc = binding.socketEpc.getText().toString();
String code = binding.socketBarcode.getText().toString();
haohuaSubmit(epc, code);
}
private void haohuaSubmit(String epc, String code) {
OkGo.<MyResult>post("http://192.168.26.26:5050/UMInterface/RFID/" + uriLastStr)
.params("rfid", epc).params("barCode", code).execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
MyResult body = response.body();
try {
if (body.getCode() == 200) {
tipsDialog.setTip(true, body.getInfo());
tipsDialog.show();
binding.socketBarcode.setText(null);
binding.socketEpc.setText(null);
} else {
tipsDialog.setTip(false, body.getInfo());
tipsDialog.show();
}
} catch (Exception e) {
tipsDialog.setTip(false, "接口返回信息异常");
tipsDialog.show();
}
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
MyResult body = response.body();
try {
if (body.getCode() == 200) {
tipsDialog.setTip(true, body.getInfo());
tipsDialog.show();
binding.socketBarcode.setText(null);
binding.socketEpc.setText(null);
} else {
tipsDialog.setTip(false, body.getInfo());
tipsDialog.show();
}
});
} catch (Exception e) {
tipsDialog.setTip(false, "接口返回信息异常");
tipsDialog.show();
}
}
});
}
private void callWebService(String soapRequest) {
// 发送 POST 请求
OkGo.<String>post("http://10.135.55.206:99/WebService.asmx").headers("Content-Type", "text/xml; charset=utf-8").upString(soapRequest, mediaType).execute(new StringCallback() {
OkGo.<String>post(SharedPreferencesUtils.getstring("ip", "http://10.72.36.3:8090/FSRFID.asmx"))
.headers("Content-Type", "text/xml; charset=utf-8")
.upString(soapRequest, mediaType)
.execute(new StringCallback() {
@Override
public void onStart(Request<String, ? extends Request> request) {
super.onStart(request);
@ -128,40 +134,20 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
// 处理响应结果
String result = response.body();
try {
String str = "<faultstring>";
int faultstringIndex = result.indexOf(str);
if (faultstringIndex > -1) {
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 resultMsg =
result.substring(result.indexOf("<Msg>") + 5, result.indexOf("</Msg>"));
if (resultCode.equals("200")) {
tipsDialog.setTip(true, resultMsg);
tipsDialog.show();
binding.socketBarcode.setText(null);
binding.socketEpc.setText(null);
} else {
tipsDialog.setTip(false, resultMsg);
tipsDialog.show();
}
// clearView(null);
}
String str = "<SubmitRFIDBindingInfoResult>";
String subStringResult =
result.substring(result.indexOf(str) + str.length(), result.indexOf("</SubmitRFIDBindingInfoResult>")).trim();
boolean equals = subStringResult.equals("OK");
tipsDialog.setTip(equals, subStringResult);
tipsDialog.show();
} catch (Exception e) {
tipsDialog.setTip(false, "接口返回信息异常");
tipsDialog.show();
}
}
@Override
public void onFinish() {
super.onFinish();
@ -171,20 +157,26 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
}
// 创建提交信息
private String buildSoapRequest(String epcid, String barcode) {
String soapRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<RFID_BarcodBind xmlns=\"http://tempuri.org/\">" +
"<epcid>" + epcid + "</epcid>" +
"<barcode>" + barcode + "</barcode>" +
"</RFID_BarcodBind>" +
"</soap:Body>" +
"</soap:Envelope>";
return soapRequest;
private String buildSoapRequest(String epcid, String barcode, String year) {
return String.format("""
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header>
<tem:MySoapHeader>
<tem:UserName>RFID-MES</tem:UserName>
<tem:PassWord>Yh#14ulh!6hk9ue4ml</tem:PassWord>
</tem:MySoapHeader>
</soap:Header>
<soap:Body>
<tem:SubmitRFIDBindingInfo>
<tem:RFIDCode>%s</tem:RFIDCode>
<tem:GreenTyreNo>%s</tem:GreenTyreNo>
<tem:YearNo>%s</tem:YearNo>
</tem:SubmitRFIDBindingInfo>
</soap:Body>
</soap:Envelope>
""", epcid, barcode, year);
}
@Override
public void getScannerData(String data) {
binding.socketBarcode.setText(data);

@ -37,6 +37,8 @@ import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ShuangqianActivity2 extends BaseActivity {
private ActivityShuangqian2Binding binding;
@ -46,6 +48,7 @@ public class ShuangqianActivity2 extends BaseActivity {
private Handler handler = new Handler();
private Runnable runnable;
private MyKeyReceiver keyReceiver;
private List<MESInfo> mesInfos;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -59,7 +62,10 @@ public class ShuangqianActivity2 extends BaseActivity {
Log.e("TAG", "追溯设置功率" + powerTrace1 + ":" + readerErr.name());
initDialog();
adapter = new MyMesInfoAdapter(this);
mesInfos = new ArrayList<>();
adapter.setList(mesInfos);
binding.setAdapter(adapter);
traceSanButton = binding.traceSanButton;
runnable = new Runnable() {
@Override
@ -81,7 +87,7 @@ public class ShuangqianActivity2 extends BaseActivity {
Intent toKillService = new Intent();
toKillService.setAction(ACTION_CLOSE_SCAN);
sendBroadcast(toKillService);
binding.dataEpc.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -95,7 +101,7 @@ public class ShuangqianActivity2 extends BaseActivity {
@Override
public void afterTextChanged(Editable s) {
if (s.length()==24){
if (s.length() == 24) {
haohuaMesSelect(s.toString());
}
@ -131,7 +137,7 @@ public class ShuangqianActivity2 extends BaseActivity {
if (readState) {
dataReadRFID(null);
// callWebService(buildSelectRequest(result));
callWebService(buildSelectRequest(result));
// haohuaMesSelect(result);
@ -185,7 +191,7 @@ public class ShuangqianActivity2 extends BaseActivity {
private void callWebService(String soapRequest) {
// 发送 POST 请求
OkGo.<String>post("http://10.135.55.206:99/WebService.asmx")
OkGo.<String>post(SharedPreferencesUtils.getstring("ip", "http://10.72.36.3:8090/FSRFID.asmx"))
.headers("Content-Type", "text/xml; charset=utf-8")
.upString(soapRequest, mediaType)
.execute(new StringCallback() {
@ -198,39 +204,42 @@ public class ShuangqianActivity2 extends BaseActivity {
@Override
public void onSuccess(Response<String> response) {
// 处理响应结果
String result = response.body();
try {
String str = "<faultstring>";
int faultstringIndex = result.indexOf(str);
if (faultstringIndex > -1) {
String faultstring =
result.substring(faultstringIndex + str.length(), result.indexOf("</faultstring>"));
tipsDialog.setTip(false, faultstring);
mesInfos.clear();
String result = response.body();
String regex = "<Table .*\">";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(result);
if (!matcher.find()) {
tipsDialog.setTip(false, "未找到匹配的内容");
tipsDialog.show();
return;
}
int codeIndex = result.indexOf("<Code>");
if (codeIndex > -1) {
String resultCode =
result.substring(codeIndex + 6, result.indexOf("</Code>"));
if (resultCode.equals("200")) {
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>"));
tipsDialog.setTip(false, resultMsg);
String matched = matcher.group();// 匹配内容
int beginIndex = matcher.start() + matched.length();
int endIndex = result.indexOf("</Table>");
Log.e("TAG", "test1:" + beginIndex);
Log.e("TAG", "test2:" + endIndex);
if (beginIndex >= endIndex) {
tipsDialog.setTip(false, "未找到匹配的内容");
tipsDialog.show();
return;
}
String[] str = new String[]{"品牌", "规格", "花纹类型", "胎号", "DOT"};
for (String s : str) {
String tag = "<" + s + ">";
MESInfo mesInfo = new MESInfo();
mesInfo.setTitle(s);
mesInfo.setInfo(result.substring(result.indexOf(tag) + tag.length(), result.indexOf("</" + s + ">")));
mesInfos.add(mesInfo);
}
} catch (Exception e) {
tipsDialog.setTip(false, "接口返回信息异常");
tipsDialog.show();
}
}
adapter.notifyDataSetChanged();
}
@Override
public void onFinish() {
@ -242,16 +251,22 @@ public class ShuangqianActivity2 extends BaseActivity {
// 创建验证信息
private String buildSelectRequest(String epcid) {
StringBuilder soapRequest = new StringBuilder();
soapRequest.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
soapRequest.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
soapRequest.append("<soap:Body>");
soapRequest.append("<TyreTracingBack xmlns=\"http://tempuri.org/\">");
soapRequest.append("<epcid>").append(epcid).append("</epcid>");
soapRequest.append("</TyreTracingBack>");
soapRequest.append("</soap:Body>");
soapRequest.append("</soap:Envelope>");
return soapRequest.toString();
String soapRequest = String.format("""
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header>
<tem:MySoapHeader>
<tem:UserName>RFID-MES</tem:UserName>
<tem:PassWord>Yh#14ulh!6hk9ue4ml</tem:PassWord>
</tem:MySoapHeader>
</soap:Header>
<soap:Body>
<tem:GetRFIDBindingInfo>
<tem:RFIDCode>%s</tem:RFIDCode>
</tem:GetRFIDBindingInfo>
</soap:Body>
</soap:Envelope>
""", epcid);
return soapRequest;
}
private void jiexi(String msg) {
@ -330,6 +345,12 @@ public class ShuangqianActivity2 extends BaseActivity {
}
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(keyReceiver);
}
private class MyKeyReceiver extends BroadcastReceiver {
@Override
@ -340,10 +361,4 @@ public class ShuangqianActivity2 extends BaseActivity {
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(keyReceiver);
}
}

@ -1,108 +0,0 @@
package com.example.writeepc;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
import com.example.writeepc.base.BaseActivity;
import com.example.writeepc.databinding.ActivityUserXuanchuanBinding;
import com.example.writeepc.utils.ASCIIUtil;
import java.util.Locale;
public class UserXuanchuanActivity extends BaseActivity {
private ActivityUserXuanchuanBinding binding;
private int flag = 0;
private byte[] rdata;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_user_xuanchuan);
Locale locale = new Locale("es");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
initReceiver();
initUHFRManager(33);
}
public void readTid(View view) {
flag = 1;
readTid();
}
public void writeUser(View view) {
String trim = binding.writeInfo.getText().toString().trim();
if (rdata == null) {
Toast.makeText(this, "请先读取TID", Toast.LENGTH_SHORT).show();
return;
}
if (trim.isEmpty()) {
Toast.makeText(this, "请输入要写入的用户信息", Toast.LENGTH_SHORT).show();
return;
}
int length = trim.length();
// 32,128
if (length > 32 ) {
Toast.makeText(this, "长度不能超过32个字符", Toast.LENGTH_SHORT).show();
return;
}
String writeData = ASCIIUtil.str4Hex(trim);
int writeLenth = writeData.length();
Log.e("TAG", "数据长度:" + length + " ," + writeLenth);
if (writeLenth < 128) {
writeData = writeData+String.format("%0"+(128-writeLenth)+"d", 0);
}
Log.e("TAG", "写入数据:" + writeData+" ,长度:" + writeData.length());
writeUserDataByTid(writeData, rdata);
}
public void readUser(View view) {
flag = 2;
readUser(64);
}
@Override
public void receiverSan() {
super.receiverSan();
readUser(null);
}
@Override
protected void readTidReault(boolean readState, String result, byte[] rdata) {
super.readTidReault(readState, result, rdata);
if (readState) {
if (flag == 1) {
binding.tidCode.setText(result);
this.rdata = rdata;
} else {
Log.e("TAG", "readTidReault:" + result);
String text = ASCIIUtil.hexTo4ZN(result);
binding.readInfo.setText(text);
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (uhfrManager != null) {
uhfrManager.close();
uhfrManager = null;
}
if (myReceiver != null) {
unregisterReceiver(myReceiver);
myReceiver = null;
}
}
}

@ -1,182 +0,0 @@
package com.example.writeepc;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
import com.example.writeepc.base.BaseActivity;
import com.example.writeepc.been.InfoData;
import com.example.writeepc.been.WriteInfo;
import com.example.writeepc.databinding.ActivityWriteUserBinding;
import com.example.writeepc.utils.SharedPreferencesUtils;
import com.example.writeepc.utils.WriteExportExcelUtil;
import com.uhf.api.cls.Reader;
import org.litepal.LitePal;
import java.io.File;
import java.util.Date;
public class WriteUserActivity extends BaseActivity {
private ActivityWriteUserBinding binding;
private InfoData infoData;
private boolean isReadUser = false;
private WriteExportExcelUtil writeExportExcelUtil;
private MyKeyReceiver keyReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_write_user);
infoData = new InfoData();
binding.setData(infoData);
int power = SharedPreferencesUtils.getInt("power", 30);
binding.selectPower.setSelection(power-5);
initUHFRManager(power);
writeExportExcelUtil = new WriteExportExcelUtil(this);
keyReceiver = new MyKeyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.rfid.FUN_KEY");
registerReceiver(keyReceiver, intentFilter);
}
@Override
protected void readTidReault(boolean readState, String result, byte[] rdata) {
Log.e("TAG", "readTidReault:" + result);
if (isReadUser) {
infoData.setTidBytes(rdata);
infoData.setReadTId(result);
return;
}
infoData.setReadUser(result);
}
public void writeUser(View view) {
String readTId = infoData.getReadTId();
if (readTId == null || readTId.isEmpty()) {
Toast.makeText(this, "请先读取TID", Toast.LENGTH_SHORT).show();
return;
}
String writeData = infoData.getWriteUser();
if (writeData == null || writeData.isEmpty()) {
Toast.makeText(this, "请输入要写入的数据", Toast.LENGTH_SHORT).show();
return;
}
try {
WriteInfo writeInfo = new WriteInfo(readTId, writeData, sdf.format(new Date()));
// boolean b = writeUserDataByTid(writeData + "0000000000", infoData.getTidBytes());
boolean b = writeEPCDataByTid("00"+writeData , infoData.getTidBytes());
if (b) {
writeInfo.save();
}
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this, "写入用户数据失败,请检查胎号是否正确", Toast.LENGTH_SHORT).show();
}
}
public void readUser(View view) {
isReadUser = false;
// readUser(6);
readEPC(6);
}
public void userClearView(View view) {
// infoData.setWriteUser(null);
// infoData.setReadUser(null);
infoData.clear();
}
public void writeUserReadTid(View view) {
isReadUser = true;
readTid();
}
@Override
public void receiverSan() {
this.readUser(null);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (uhfrManager != null) {
uhfrManager.close();
uhfrManager = null;
}
// if (myReceiver != null) {
// unregisterReceiver(myReceiver);
// }
if (keyReceiver != null) {
unregisterReceiver(keyReceiver);
}
}
@Override
protected void onResume() {
super.onResume();
exportExcel(null);
}
public void exportExcel(View view) {
// File file= writeExportExcelUtil.getFilePath("RFID写入记录.xls");
// if (file.exists()) {
// file.delete();
// }
// writeExportExcelUtil.export(LitePal.findAll(WriteInfo.class), "RFID写入记录.xls");
}
// 点击两次返回结束程序
private long exitTime = 0;
@Override
public void onBackPressed() {
if (System.currentTimeMillis() - exitTime > 2000) {
Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
} else {
finish();
}
}
public class MyKeyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
var keydown = intent.getBooleanExtra("keydown", false);
var keyCode = intent.getIntExtra("keyCode", 0);
Log.e("TAG", "onReceive:" + keyCode);
if (!keydown) {
if (keyCode == 135) {
writeUserReadTid(null);
}else if (keyCode ==136){
writeUser(null);
}
}
}
}
public void setPower(View view) {
String powerString = binding.selectPower.getSelectedItem().toString();
int power = Integer.parseInt(powerString);
SharedPreferencesUtils.putInt("power", power);
Reader.READER_ERR readerErr = uhfrManager.setPower(power, power);
Log.e("TAG", "setPower:" + readerErr.toString());
}
}

@ -1,10 +1,6 @@
package com.example.writeepc.base;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
@ -19,8 +15,6 @@ import com.google.gson.Gson;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
import java.text.SimpleDateFormat;
import cn.pda.serialport.Tools;
import okhttp3.MediaType;
@ -33,24 +27,15 @@ public class BaseActivity extends AppCompatActivity {
public TipsDialog tipsDialog;
public MediaType mediaType = MediaType.parse("text/xml; charset=utf-8");
public Gson gson;
public MyReceiver myReceiver;
public SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 格式化时间
public SimpleDateFormat fileNameDate = new SimpleDateFormat("yyyy-MM-dd HH_mm_ss");// 格式化时间
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// tipsDialog = new TipsDialog(this);
// gson = new Gson();
tipsDialog = new TipsDialog(this);
gson = new Gson();
}
public void initReceiver() {
myReceiver = new MyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.rfid.FUN_KEY");
registerReceiver(myReceiver, intentFilter);
}
public void initDialog() {
dialog = new ProgressDialog(this);
@ -66,14 +51,7 @@ public class BaseActivity extends AppCompatActivity {
uhfrManager.setPower(30, 30);
accesspwd = Tools.HexString2Bytes("00000000");
music = MediaPlayer.create(this, com.example.writeepc.R.raw.msg);
}
public void initUHFRManager(int power) {
uhfrManager = UHFRManager.getInstance();
uhfrManager.setGen2session(false);
uhfrManager.setPower(power, power);
accesspwd = Tools.HexString2Bytes("00000000");
music = MediaPlayer.create(this, com.example.writeepc.R.raw.msg);
}
public void initUHFRManager1() {
@ -85,6 +63,7 @@ public class BaseActivity extends AppCompatActivity {
}
// 1- 读取TID
public void readTid() {
byte[] rdata = new byte[12];
@ -103,8 +82,7 @@ public class BaseActivity extends AppCompatActivity {
// 1- 读取EPC
public void readEPC(int lenth) {
byte[] rdata = new byte[lenth];
Reader.READER_ERR readerErr =
uhfrManager.getTagData(1, 5, lenth / 2, rdata, accesspwd, timeOut);
Reader.READER_ERR readerErr = uhfrManager.getTagData(1, 2, lenth / 2, rdata, accesspwd, timeOut);
Log.e("TAG", "readTid:" + readerErr.name());
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
music.start();
@ -116,121 +94,10 @@ public class BaseActivity extends AppCompatActivity {
}
// 3- 读取User
public void readUser(int lenth) {
byte[] rdata = new byte[lenth];
Reader.READER_ERR readerErr =
uhfrManager.getTagData(3, 0, lenth / 2, rdata, accesspwd, timeOut);
Log.e("TAG", "readTid:" + readerErr.name());
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
music.start();
readTidReault(true, Tools.Bytes2HexString(rdata, lenth), rdata);
} else {
Toast.makeText(this, "读取失败", Toast.LENGTH_SHORT).show();
readTidReault(false, null, null);
}
}
public void writeUserData(String writeData) {
byte[] bytes = Tools.HexString2Bytes(writeData);
Reader.READER_ERR readerErr = uhfrManager.writeTagData((char) 3, 0,
bytes, bytes.length, accesspwd, timeOut);
Log.e("TAG", "写入状态:" + readerErr.name());
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
music.start();
Toast.makeText(this, "写入成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "写入失败", Toast.LENGTH_SHORT).show();
}
}
public boolean writeUserDataByTid(String writeData, byte[] rdata) {
byte[] bytes = Tools.HexString2Bytes(writeData);
Reader.READER_ERR readerErr = uhfrManager.writeTagDataByFilter
((char) 3, 0,
bytes, bytes.length, accesspwd, timeOut,
rdata, 2, 0, true);
Log.e("TAG", "写入状态:" + readerErr.name());
boolean b = readerErr == Reader.READER_ERR.MT_OK_ERR;
if (b) {
music.start();
Toast.makeText(this, "写入成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "写入失败", Toast.LENGTH_SHORT).show();
}
return b;
}
public boolean writeEPCDataByTid(String writeData, byte[] rdata) {
byte[] bytes = Tools.HexString2Bytes(writeData);
Reader.READER_ERR readerErr = uhfrManager.writeTagDataByFilter
((char) 1, 5,
bytes, bytes.length, accesspwd, timeOut,
rdata, 2, 0, true);
Log.e("TAG", "写入状态:" + readerErr.name());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Log.e("TAG", "Sleep interrupted", e);
}
Reader.READER_ERR readerErr2 = Reader.READER_ERR.MT_CMD_FAILED_ERR;
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
// 写入成功
byte[] suessTagEpc = new byte[12];
Reader.READER_ERR readerErrReed =
uhfrManager.getTagData(1, 2, 6, suessTagEpc, accesspwd, timeOut);
Log.e("TAG", "read读取全部EPC:" + readerErrReed.name());
if ( readerErrReed == Reader.READER_ERR.MT_OK_ERR) {
readerErr2 = uhfrManager.lockTagByFilter(
Reader.Lock_Obj.LOCK_OBJECT_BANK1,
Reader.Lock_Type.BANK1_PERM_LOCK,
// Reader.Lock_Type.BANK1_LOCK,
accesspwd,
timeOut,
suessTagEpc, 1, 2, true);
}
}
Log.e("TAG", "锁定状态:" + readerErr2.name());
boolean b = readerErr2 == Reader.READER_ERR.MT_OK_ERR;
if (b) {
music.start();
Toast.makeText(this, "写入成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "写入失败", Toast.LENGTH_SHORT).show();
}
return b;
}
protected void readTidReault(boolean readState, String result, byte[] rdata) {
}
public void receiverSan() {
}
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
var keydown = intent.getBooleanExtra("keydown", false);
if (!keydown) {
receiverSan();
}
}
}
// @Override
// protected void onDestroy() {
// super.onDestroy();

@ -13,8 +13,6 @@ import com.lzy.okgo.https.HttpsUtils;
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
import com.lzy.okgo.model.HttpHeaders;
import org.litepal.LitePal;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
@ -50,7 +48,6 @@ public class MyApplication extends Application {
application = this;
SharedPreferencesUtils.init(getApplicationContext(), "myapp");
okGoBase();
LitePal.initialize(this);
}
// OKGO 初始化
@ -65,9 +62,9 @@ public class MyApplication extends Application {
HttpsUtils.SSLParams sslParams1 = HttpsUtils.getSslSocketFactory(); // 方法一:信任所有证书,不安全有风险
builder.sslSocketFactory(sslParams1.sSLSocketFactory, sslParams1.trustManager);
builder.addInterceptor(loggingInterceptor);
builder.readTimeout(10000, TimeUnit.MILLISECONDS); // 全局的读取超时时间
builder.writeTimeout(10000, TimeUnit.MILLISECONDS); // 全局的写入超时时间
builder.connectTimeout(10000, TimeUnit.MILLISECONDS); // 全局的连接超时时间
builder.readTimeout(6000, TimeUnit.MILLISECONDS); // 全局的读取超时时间
builder.writeTimeout(6000, TimeUnit.MILLISECONDS); // 全局的写入超时时间
builder.connectTimeout(6000, TimeUnit.MILLISECONDS); // 全局的连接超时时间
builder.cookieJar(new CookieJarImpl(new MemoryCookieStore())); // 使用内存保持cookieapp退出后cookie消失
OkGo.getInstance().init(this).setOkHttpClient(builder.build()) // 建议设置OkHttpClient不设置将使用默认的
.setCacheMode(CacheMode.NO_CACHE) // 全局统一缓存模式,默认不使用缓存,可以不传

@ -1,51 +0,0 @@
package com.example.writeepc.been;
import org.litepal.crud.LitePalSupport;
public class WriteInfo extends LitePalSupport {
private int id;
private String tid;
private String writeInfo;
private String dateTime;
public WriteInfo() {
}
public WriteInfo(String tid, String writeInfo, String dateTime) {
this.tid = tid;
this.writeInfo = writeInfo;
this.dateTime = dateTime;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTid() {
return tid;
}
public void setTid(String tid) {
this.tid = tid;
}
public String getWriteInfo() {
return writeInfo;
}
public void setWriteInfo(String writeInfo) {
this.writeInfo = writeInfo;
}
public String getDateTime() {
return dateTime;
}
public void setDateTime(String dateTime) {
this.dateTime = dateTime;
}
}

@ -1,98 +0,0 @@
package com.example.writeepc.utils;
import android.content.Context;
import android.os.Environment;
import android.widget.Toast;
import com.example.writeepc.been.WriteInfo;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
/**
* 使 jxl-2.6.12 Excel Android 5.1
*/
public class WriteExportExcelUtil {
private Context mContext;
public WriteExportExcelUtil(Context context) {
this.mContext = context;
}
/**
* RFID .xls
*/
public void export(List<WriteInfo> dataList, String fileName) {
// 确保文件名以 .xls 结尾
if (!fileName.endsWith(".xls")) {
fileName += ".xls";
}
WritableWorkbook workbook = null;
try {
File file = getFilePath(fileName);
FileOutputStream fos = new FileOutputStream(file);
workbook = Workbook.createWorkbook(fos);
WritableSheet sheet = workbook.createSheet("RFID写入记录", 0); // 索引0表示第一个表
sheet.setColumnView(0, 10);
sheet.setColumnView(1, 20);
sheet.setColumnView(2, 20);
sheet.setColumnView(3, 20);
// 4. 写入表头(第一行)
String[] headers = {"序号", "TID", "写入胎号", "写入时间"};
for (int i = 0; i < headers.length; i++) {
// Label(列索引, 行索引, 内容)
Label headerLabel = new Label(i, 0, headers[i]);
sheet.addCell(headerLabel);
}
// 5. 写入数据从第二行开始行索引1
for (int i = 0; i < dataList.size(); i++) {
WriteInfo data = dataList.get(i);
int rowIndex = i + 1;
// 序号id
sheet.addCell(new Label(0, rowIndex, String.valueOf(data.getId())));
sheet.addCell(new Label(1, rowIndex, data.getTid() == null ? "" : data.getTid()));
sheet.addCell(new Label(2, rowIndex, data.getWriteInfo() == null ? "" : data.getWriteInfo()));
sheet.addCell(new Label(3, rowIndex, data.getDateTime() == null ? "" : data.getDateTime()));
}
// 6. 写入文件并关闭工作簿
workbook.write();
// Toast.makeText(mContext, "导出成功:" + file.getAbsolutePath(), Toast.LENGTH_LONG).show();
} catch (IOException | WriteException e) {
e.printStackTrace();
// Toast.makeText(mContext, "导出失败:" + e.getMessage(), Toast.LENGTH_SHORT).show();
} finally {
// 7. 释放资源
if (workbook != null) {
try {
workbook.close();
} catch (IOException | WriteException e) {
e.printStackTrace();
}
}
}
}
/**
* Android 5.1
*/
public File getFilePath(String fileName) {
File downloadDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
if (!downloadDir.exists()) {
downloadDir.mkdirs();
}
return new File(downloadDir, fileName);
}
}

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="6dp"/>
<solid android:color="@color/white"/>
</shape>

@ -23,8 +23,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
>
android:orientation="horizontal">
<RadioButton
android:id="@+id/home_1"
@ -68,7 +67,8 @@
android:drawablePadding="10dp"
android:gravity="center"
android:text="解绑"
android:textSize="20sp"/>
android:textSize="20sp"
android:visibility="gone" />
<RadioButton
android:id="@+id/home_4"
@ -82,8 +82,37 @@
android:text="设置"
android:textSize="20sp" />
<RadioButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawablePadding="10dp"
android:gravity="center"
android:textSize="20sp" />
</RadioGroup>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:visibility="gone">
<RadioButton
android:id="@+id/home_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/ic_info"
android:drawablePadding="10dp"
android:gravity="center"
android:text="轮胎信息查询"
android:textSize="20sp" />
</RadioGroup>
</LinearLayout>

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".HomeActivity2">
<TextView
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="#6750A4"
android:letterSpacing="0.2"
android:text="主页"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<RadioButton
android:id="@+id/home2_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/ic_info"
android:drawablePadding="10dp"
android:gravity="center"
android:text="轮胎信息查询"
android:textSize="20sp" />
<RadioButton
android:id="@+id/home2_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/home_setting"
android:drawablePadding="10dp"
android:gravity="center"
android:text="设置"
android:textSize="20sp" />
</RadioGroup>
</LinearLayout>

@ -1,105 +0,0 @@
<?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="adapter"
type="com.example.writeepc.adapter.MyMesInfoAdapter" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".IntentSelectActivity">
<TextView
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="#6750A4"
android:letterSpacing="0.2"
android:text="轮胎追溯"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="扫描RFID:" />
<EditText
android:id="@+id/data_epc"
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
</LinearLayout>
<TextView
android:id="@+id/data_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="left|center"
android:padding="20dp"
android:textSize="18sp"
android:visibility="gone" />
<TextView
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="查询信息"
android:textColor="@color/blue" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:adapter="@{adapter}"
android:padding="10dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp">
<Button
android:id="@+id/trace_san_button1"
style="@style/button_style"
android:layout_width="150dp"
android:layout_height="55dp"
android:background="@drawable/button_bg2"
android:onClick="intentRequestToken"
android:visibility="gone"
android:text="重新连接" />
<Button
android:id="@+id/trace_san_button"
style="@style/button_style"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="55dp"
android:onClick="dataReadRFID"
android:background="@drawable/button_bg1"
android:text="开始扫描" />
</LinearLayout>
</LinearLayout>
</layout>

@ -7,7 +7,7 @@
<variable
name="data"
type="com.example.writeepc.been.InfoData" />
type="com.example.writeepc.InfoData" />
</data>
<LinearLayout

@ -58,27 +58,27 @@
</LinearLayout>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="55dp"-->
<!-- android:layout_marginTop="20dp"-->
<!-- android:orientation="horizontal">-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<!-- <TextView-->
<!-- style="@style/info_text"-->
<!-- android:layout_width="110dp"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_gravity="center"-->
<!-- android:text="胎胚年份:" />-->
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="胎胚年份:" />
<!-- <EditText-->
<!-- android:id="@+id/socket_year"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_gravity="center"-->
<!-- android:gravity="center"-->
<!-- />-->
<!-- </LinearLayout>-->
<EditText
android:id="@+id/socket_year"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"

@ -1,108 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@mipmap/test1"
tools:context=".UserXuanchuanActivity">
<TextView
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_gravity="center"
android:background="@color/blue2"
android:letterSpacing="0.2"
android:text="RFID Tag writing"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="San TID:" />
<TextView
android:id="@+id/tid_code"
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="readTid"
android:backgroundTint="@color/blue2"
android:text="Query TID" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Input data:" />
<EditText
android:id="@+id/write_info"
style="@style/info_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:minHeight="45dp" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/blue2"
android:onClick="writeUser"
android:text="Write data" />
<TextView
android:id="@+id/read_info"
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="8dp"
android:layout_weight="1" />
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/blue2"
android:onClick="readUser"
android:text="Scan RFID" />
</LinearLayout>
</layout>

@ -1,201 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="data"
type="com.example.writeepc.been.InfoData" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".WriteUserActivity">
<TextView
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_gravity="center"
android:background="#6750A4"
android:letterSpacing="0.2"
android:text="EPC区读写"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:visibility="gone">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="读取长度:" />
<Spinner
android:id="@+id/user_read_lenth"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/read_lenth"
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="设置功率:" />
<Spinner
android:id="@+id/select_power"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:entries="@array/power"
android:textAlignment="center"
/>
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="setPower"
android:text="设置功率" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="扫描TID:" />
<TextView
android:id="@+id/tid_code"
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="@{data.readTId}" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:backgroundTint="@color/blue2"
android:onClick="writeUserReadTid"
android:text="1-查询TID" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="30dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="写入数据:" />
<EditText
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@={data.writeUser}" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="12dp"
android:onClick="writeUser"
android:text="写入数据" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="EPC:" />
<TextView
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:minHeight="55dp"
android:padding="5dp"
android:text="@={data.readUser}" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="12dp"
android:onClick="readUser"
android:text="扫描验证" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp">
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_weight="1"
android:backgroundTint="#FFD600"
android:onClick="userClearView"
android:text="清空操作" />
<!-- <Button-->
<!-- style="@style/button_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="55dp"-->
<!-- android:backgroundTint="@color/blue"-->
<!-- android:onClick="exportExcel"-->
<!-- android:text="设置功率" />-->
</LinearLayout>
</LinearLayout>
</layout>

@ -29,6 +29,7 @@
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
@ -70,24 +71,29 @@
android:textAlignment="center" />
</LinearLayout>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="45dp"-->
<!-- android:layout_marginTop="20dp"-->
<!-- android:orientation="horizontal"-->
<!-- >-->
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:text="请求地址:" />
<!-- <TextView-->
<!-- style="@style/info_text"-->
<!-- android:layout_width="110dp"-->
<!-- android:layout_height="45dp"-->
<!-- android:layout_gravity="center|left"-->
<!-- android:text="请求地址:" />-->
<!-- <EditText-->
<!-- android:id="@+id/setting_ip"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="45dp"-->
<!-- android:layout_gravity="center"-->
<!-- android:entries="@array/power"-->
<!-- android:lines="1"-->
<!-- android:textAlignment="center" />-->
<EditText
android:id="@+id/setting_ip"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_gravity="center"
android:entries="@array/power"
android:layout_marginLeft="10dp"
android:lines="1"
android:textAlignment="center" />
<!-- </LinearLayout>-->
<View
android:layout_width="match_parent"

@ -1,85 +0,0 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".SettingsActivity2">
<TextView
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_gravity="center"
android:background="#6750A4"
android:letterSpacing="1"
android:text="设置"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="追溯功率:" />
<Spinner
android:id="@+id/select_power_trace"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:entries="@array/power"
android:textAlignment="center" />
</LinearLayout>
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center|left"
android:text="请求地址:" />
<EditText
android:id="@+id/setting_ip"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:entries="@array/power"
android:lines="1"
android:textAlignment="center" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:onClick="saveInfo"
android:text="保存并退出" />
</LinearLayout>
</layout>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 KiB

@ -32,23 +32,6 @@
<item>33</item>
</string-array>
<string-array name="read_lenth">
<item>4</item>
<item>8</item>
<item>12</item>
<item>16</item>
<item>20</item>
<item>24</item>
<item>28</item>
<item>32</item>
<item>36</item>
<item>40</item>
<item>44</item>
<item>48</item>
<item>52</item>
<item>56</item>
<item>60</item>
</string-array>
<!-- Reply Preference -->
<string-array name="reply_entries">
<item>Reply</item>

@ -3,5 +3,4 @@
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="blue">#304FFE</color>
<color name="blue2">#034580</color>
</resources>

@ -44,16 +44,6 @@
<item name="android:background">@drawable/san_text_bg</item>
<item name="android:layout_marginEnd">8dp</item>
</style>
<style name="info_text2">
<item name="android:textColor">@color/black</item>
<item name="android:textSize">18sp</item>
<item name="android:gravity">center</item>
<item name="android:background">@drawable/info_text_bg</item>
<item name="android:layout_marginEnd">8dp</item>
</style>
<style name="button_style">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">20sp</item>
@ -63,7 +53,6 @@
<item name="android:layout_marginEnd">20dp</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:layout_marginBottom">5dp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="button_style1">
<item name="android:textColor">@color/white</item>

Loading…
Cancel
Save