|
|
|
@ -25,10 +25,12 @@ import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
|
|
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
|
import com.lzy.okgo.OkGo;
|
|
|
|
|
import com.lzy.okgo.model.Response;
|
|
|
|
|
import com.uhf.api.cls.Reader;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import cn.pda.serialport.Tools;
|
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
|
|
|
|
|
|
public class StoreCheckActivity extends BaseActivity {
|
|
|
|
@ -48,16 +50,20 @@ public class StoreCheckActivity extends BaseActivity {
|
|
|
|
|
binding.setAdapter(checkAdapter);
|
|
|
|
|
initRequest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<String> tagList;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void sanRfid(List<String> epcs) {
|
|
|
|
|
protected void sanRfid(List<Reader.TAGINFO> epcs) {
|
|
|
|
|
if (tagList == null) return;
|
|
|
|
|
epcs.forEach(t -> {
|
|
|
|
|
if (tagList.contains(t)){
|
|
|
|
|
tagList.add(t);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var epc = Tools.Bytes2HexString(t.EpcId, t.EpcId.length);
|
|
|
|
|
if (tagList.contains(epc)) {
|
|
|
|
|
tagList.add(epc);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var stock = new Stock();
|
|
|
|
|
stock.setEpcCode(t);
|
|
|
|
|
stock.setEpcCode(epc);
|
|
|
|
|
var index = list.indexOf(stock);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
list.get(index).setState("Y");
|
|
|
|
@ -75,7 +81,7 @@ public class StoreCheckActivity extends BaseActivity {
|
|
|
|
|
if (body.getCode() == 0) {
|
|
|
|
|
list = gson.fromJson(body.getData().toString(), new TypeToken<List<Stock>>() {
|
|
|
|
|
}.getType());
|
|
|
|
|
tagList=new ArrayList<>();
|
|
|
|
|
tagList = new ArrayList<>();
|
|
|
|
|
checkAdapter.setList(list);
|
|
|
|
|
checkAdapter.notifyDataSetChanged();
|
|
|
|
|
} else {
|
|
|
|
@ -97,20 +103,20 @@ public class StoreCheckActivity extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
public void store_check_submit(View view) {
|
|
|
|
|
handler.removeCallbacks(runnable);
|
|
|
|
|
OkGo.<MyResult>post(url+"/storecheck/submit")
|
|
|
|
|
OkGo.<MyResult>post(url + "/storecheck/submit")
|
|
|
|
|
.tag(this)
|
|
|
|
|
.params("user", SharedPreferencesUtils.getstring("user","test"))
|
|
|
|
|
.params("json",gson.toJson(list))
|
|
|
|
|
.params("user", SharedPreferencesUtils.getstring("user", "test"))
|
|
|
|
|
.params("json", gson.toJson(list))
|
|
|
|
|
// .upRequestBody(RequestBody.create(JSON, gson.toJson(list)))
|
|
|
|
|
.execute(new MyRecultCall(dialog,this){
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
var body = response.body();
|
|
|
|
|
if (body.getCode()==0){
|
|
|
|
|
if (body.getCode() == 0) {
|
|
|
|
|
finish();
|
|
|
|
|
Toast.makeText(StoreCheckActivity.this, "提交成功", Toast.LENGTH_SHORT).show();
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
Toast.makeText(StoreCheckActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -127,7 +133,9 @@ public class StoreCheckActivity extends BaseActivity {
|
|
|
|
|
private Runnable runnable = new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
sendBroadcast(broadcastIntent);
|
|
|
|
|
Log.e("TAG", "发送广播,读取RFID");
|
|
|
|
|
// sendBroadcast(broadcastIntent);
|
|
|
|
|
sanEpc();
|
|
|
|
|
handler.postDelayed(runnable, 1000);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -136,7 +144,7 @@ public class StoreCheckActivity extends BaseActivity {
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
handler.removeCallbacks(runnable);
|
|
|
|
|
handler=null;
|
|
|
|
|
runnable=null;
|
|
|
|
|
handler = null;
|
|
|
|
|
runnable = null;
|
|
|
|
|
}
|
|
|
|
|
}
|