增加 - PDA mac 验证

master
wangh 12 months ago
parent 4e43b5d048
commit 48c3b9619d

@ -57,7 +57,7 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte
listPopupWindow.setAnchorView(binding.selectDefect);
listPopupWindow.setOnItemClickListener(this);
String stationCode = getIntent().getStringExtra("stationCode");
/* OkGo.<Result>get(url + "/base/qualityInspectionItem/getQualityDefects/" + stationCode).tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).execute(new MyRecultCall(dialog, this) {
OkGo.<Result>get(url + "/base/qualityInspectionItem/getQualityDefects/" + stationCode).tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<Result> response) {
super.onSuccess(response);
@ -77,7 +77,7 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte
}
});
*/ OkGo.<Result>get(url + "/system/dict/data/type/treatment_measures").tag(this)
OkGo.<Result>get(url + "/system/dict/data/type/treatment_measures").tag(this)
.headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
.execute(new MyRecultCall(dialog, this) {
@Override
@ -85,7 +85,8 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte
super.onSuccess(response);
Result body = response.body();
List<DictBeen> dictBeenList = gson.fromJson(gson.toJson(body.getData()),
new TypeToken<List<DictBeen>>() {}.getType());
new TypeToken<List<DictBeen>>() {
}.getType());
checkViewModel.setDictBeenList(dictBeenList);
}
@ -112,11 +113,22 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte
checkViewModel.setOffline(s1);
checkViewModel.setList(submitList);
checkViewModel.setUserName(SharedPreferencesUtils.getstring("userName", "pda01"));
OkGo.<Result>post(url + "/api/checkSubmit").tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).upRequestBody(RequestBody.create(JSON, gson.toJson(checkViewModel))).execute(new MyRecultCall(dialog, this) {
OkGo.<Result>post(url + "/api/checkSubmit").tag(this)
.headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
.upRequestBody(RequestBody.create(JSON, gson.toJson(checkViewModel)))
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<Result> response) {
super.onSuccess(response);
Result result = response.body();
if (result.getCode() == 200) {
Toast.makeText(CheckActivity.this, "提交成功", Toast.LENGTH_SHORT).show();
checkViewModel.setCode(null);
submitList.clear();
checkAdapter.notifyDataSetChanged();
} else {
Toast.makeText(CheckActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
}
}
});
}

@ -17,9 +17,13 @@ import android.widget.Toast;
import com.example.aucma_mes.base.BaseActivity;
import com.example.aucma_mes.databinding.ActivityMainBinding;
import com.example.aucma_mes.entity.LoginBack;
import com.example.aucma_mes.entity.RegisterPda;
import com.example.aucma_mes.entity.Result;
import com.example.aucma_mes.utils.MyRecultCall;
import com.example.aucma_mes.utils.SharedPreferencesUtils;
import com.example.aucma_mes.vm.User;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
@ -34,7 +38,7 @@ import okhttp3.RequestBody;
public class MainActivity extends BaseActivity {
private User user;
private boolean loginState=false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -45,6 +49,31 @@ public class MainActivity extends BaseActivity {
getSupportActionBar().hide(); // 隐藏原生标题栏
binding.setUser(user);
Toast.makeText(this, getMacAddress()+"可以使用", Toast.LENGTH_SHORT).show();
OkGo.<Result>get(url + "/system/dict/data/type/treatment_measures").tag(this)
.headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<Result> response) {
super.onSuccess(response);
Result result = response.body();
if (result.getCode()==200){
List<RegisterPda> pdaList=gson.fromJson(gson.toJson( result.getData()),new TypeToken< List<RegisterPda>>(){}.getType());
RegisterPda registerPda=new RegisterPda();
registerPda.setSerialCode(getMacAddress());
int index = pdaList.indexOf(registerPda);
loginState= index >-1;
if (loginState){
SharedPreferencesUtils.putstring("pdaName",pdaList.get(index).getPdaName());
}
}else {
Toast.makeText(MainActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
@ -76,6 +105,11 @@ public class MainActivity extends BaseActivity {
return "02:00:00:00:00:00"; // 如果无法获取到有效的MAC地址返回一个默认值
}
public void login(View view) {
if (!loginState) {
Toast.makeText(this, "设备未注册,不允许登录", Toast.LENGTH_SHORT).show();
return;
}
dialog.show();
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON,gson.toJson(user) );

@ -0,0 +1,45 @@
package com.example.aucma_mes.entity;
import java.util.Objects;
/**
* @author wanghao
* @date 2023/11/22 17:36
*/
public class RegisterPda {
/* "pdaName": "质检PDA02",
"serialCode": "4c:11:54:36:b7:91",*/
private String pdaName;
private String serialCode;
public String getPdaName() {
return pdaName;
}
public void setPdaName(String pdaName) {
this.pdaName = pdaName;
}
public String getSerialCode() {
return serialCode;
}
public void setSerialCode(String serialCode) {
this.serialCode = serialCode;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RegisterPda that = (RegisterPda) o;
return Objects.equals(serialCode, that.serialCode);
}
@Override
public int hashCode() {
return serialCode != null ? serialCode.hashCode() : 0;
}
}
Loading…
Cancel
Save