增加 写入成功接口

master
wanghao 3 months ago
parent 935808a98e
commit 5568cb2fa0

@ -4,12 +4,11 @@
<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$" />
<option name="gradleHome" value="$PROJECT_DIR$/../../../android gradle version/gradle-8.0.2" />
<option name="gradleJvm" value="17" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

@ -1,5 +1,5 @@
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

@ -61,8 +61,8 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
popupMenu = new PopupMenu(this, binding.writeMenu);
popupMenu.setOnMenuItemClickListener(this);
getMenuInflater().inflate(R.menu.activity_menu, popupMenu.getMenu());
rfidModel = new C5106Device(this, this);
// rfidModel = new AutoID9UDevice(this, this);
// rfidModel = new C5106Device(this, this);
rfidModel = new AutoID9UDevice(this, this);
if (rfidModel instanceof C5106Device) {
intent1 = new Intent(this, ReadActivity.class);
} else {
@ -118,11 +118,12 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
tagUserStr.append("~");
}
String user = ASCIIUtil.str2Hex(tagUserStr.toString());
String tyreNo = list.get(0).getPropertyContent();
if (!writeUserState) {
Log.e("TAG", "请求");
Map<String, String> map = new HashMap<>();
map.put("EpcCode", epcStr);
map.put("TyreNo", list.get(0).getPropertyContent());
map.put("TyreNo", tyreNo);
map.put("token", "123456");
map.put("Language", SharedPreferencesUtils.getstring("languageIndex", "0"));
Log.e("TAG", "writeUser:" + 2);
@ -136,10 +137,10 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
if (body.getSaveFlag().equals("1")) {
// Toast.makeText(WriteUserActivity.this, getString(R.string.binding_success), Toast.LENGTH_SHORT).show();
writeUserState = true;
writeUser(user, epcStr);
writeUser(user, epcStr,tyreNo);
} else if (body.getSaveFlagCF().equals("0")) {// 等于0的情况属于绑定后写入失败可重新写入
writeUserState = true;
writeUser(user, epcStr);
writeUser(user, epcStr,tyreNo);
} else {
tipDialog.shouDialog(false, body.getSaveMessage());
}
@ -148,16 +149,17 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
});
} else {
writeUser(user, epcStr);
writeUser(user, epcStr, tyreNo);
}
}
private void writeUser(String user, String epcStr) {
private void writeUser(String user, String epcStr,String tyreNo) {
Log.e("TAG", "写入");
var writeState = rfidModel.writeUser(validateDataLength(user), epcStr);
tipDialog.shouDialog(writeState, getString(writeState ? R.string.write_success : R.string.write_failed));
// 成功还是失败
if (writeState) {
list.clear();
adapter.notifyDataSetChanged();
@ -165,6 +167,20 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
binding.writeTire.setText(null);
writeUserState = false;
}
Map backMap = new HashMap();
backMap.put("TyreNo",tyreNo);
backMap.put("Flag",writeState?1:2);
backMap.put("token","123456");
OkGo.<MyResult>post("http://" + url + "/rfid/Back")
.upRequestBody(RequestBody.create(JSON, gson.toJson(backMap)))
.execute(new MyRecultCall(dialog, this) {
@SuppressLint("NotifyDataSetChanged")
@Override
public void onSuccess(Response<MyResult> response) {
}
});
}

Loading…
Cancel
Save