|
|
@ -1,9 +1,8 @@
|
|
|
|
package com.example.beijing_daxing;
|
|
|
|
package com.example.beijing_daxing;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
|
|
import androidx.databinding.DataBindingUtil;
|
|
|
|
import androidx.databinding.DataBindingUtil;
|
|
|
|
import androidx.databinding.ViewDataBinding;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
@ -13,46 +12,61 @@ import com.example.beijing_daxing.base.MyRecultCall;
|
|
|
|
import com.example.beijing_daxing.base.MyResult;
|
|
|
|
import com.example.beijing_daxing.base.MyResult;
|
|
|
|
import com.example.beijing_daxing.been.LedgerRfid;
|
|
|
|
import com.example.beijing_daxing.been.LedgerRfid;
|
|
|
|
import com.example.beijing_daxing.databinding.ActivityBfactivityBinding;
|
|
|
|
import com.example.beijing_daxing.databinding.ActivityBfactivityBinding;
|
|
|
|
|
|
|
|
import com.example.beijing_daxing.dialog.TakePictureDialog;
|
|
|
|
|
|
|
|
import com.example.beijing_daxing.uitls.HexAscii;
|
|
|
|
import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
|
|
|
|
import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
|
|
|
|
import com.example.beijing_daxing.vm.BFWm;
|
|
|
|
import com.example.beijing_daxing.vm.BFWm;
|
|
|
|
import com.lzy.okgo.OkGo;
|
|
|
|
import com.lzy.okgo.OkGo;
|
|
|
|
import com.lzy.okgo.model.Response;
|
|
|
|
import com.lzy.okgo.model.Response;
|
|
|
|
import com.uhf.api.cls.Reader;
|
|
|
|
import com.uhf.api.cls.Reader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.pda.serialport.Tools;
|
|
|
|
import cn.pda.serialport.Tools;
|
|
|
|
|
|
|
|
|
|
|
|
public class BFActivity extends BaseActivity {
|
|
|
|
public class BFActivity extends BaseActivity implements TakePictureDialog.dialogReturnListSizeCall {
|
|
|
|
private BFWm wm;
|
|
|
|
private BFWm wm;
|
|
|
|
|
|
|
|
private TakePictureDialog takeDialog;
|
|
|
|
|
|
|
|
private List<File> files;
|
|
|
|
|
|
|
|
private List<Bitmap> bitmaps;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ActivityBfactivityBinding dataBinding;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
ActivityBfactivityBinding dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_bfactivity);
|
|
|
|
dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_bfactivity);
|
|
|
|
wm=new BFWm();
|
|
|
|
wm = new BFWm();
|
|
|
|
|
|
|
|
wm.setList(List.of(getResources().getStringArray(R.array.bfyy)));
|
|
|
|
dataBinding.setVm(wm);
|
|
|
|
dataBinding.setVm(wm);
|
|
|
|
setPower(17);
|
|
|
|
takeDialog = new TakePictureDialog(this);
|
|
|
|
|
|
|
|
takeDialog.setCall(this);
|
|
|
|
|
|
|
|
setPower(SharedPreferencesUtils.getInt("powerScrap", 17));
|
|
|
|
|
|
|
|
bitmaps = new ArrayList<>();
|
|
|
|
|
|
|
|
files = new ArrayList<>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void sanRfid(List<Reader.TAGINFO> epcs) {
|
|
|
|
protected void sanRfid(List<Reader.TAGINFO> epcs) {
|
|
|
|
var epc = epcs.get(0);
|
|
|
|
var epc = epcs.get(0);
|
|
|
|
byte[] epcId = epc.EpcId;
|
|
|
|
byte[] epcId = epc.EpcId;
|
|
|
|
String epc1 = Tools.Bytes2HexString(epcId, epcId.length);
|
|
|
|
String epc1 = HexAscii.hex2Str(Tools.Bytes2HexString(epcId, epcId.length));
|
|
|
|
wm.setEpc(epc1);
|
|
|
|
wm.setEpc(epc1);
|
|
|
|
OkGo.<MyResult>post(url+"/bf/select")
|
|
|
|
OkGo.<MyResult>post(url + "/bf/select")
|
|
|
|
.tag(this)
|
|
|
|
.tag(this)
|
|
|
|
.params("epc",epc1)
|
|
|
|
.params("epc", epc1)
|
|
|
|
.execute(new MyRecultCall(dialog,this){
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
super.onSuccess(response);
|
|
|
|
super.onSuccess(response);
|
|
|
|
var body = response.body();
|
|
|
|
var body = response.body();
|
|
|
|
if (body.getCode()==0){
|
|
|
|
if (body.getCode() == 0) {
|
|
|
|
LedgerRfid ledgerRfid=gson.fromJson(body.getData().toString(),LedgerRfid.class);
|
|
|
|
LedgerRfid ledgerRfid = gson.fromJson(body.getData().toString(), LedgerRfid.class);
|
|
|
|
wm.setPcode(ledgerRfid.getBatchCode());
|
|
|
|
wm.setPcode(ledgerRfid.getBatchCode());
|
|
|
|
wm.setState(ledgerRfid.getDictLabel());
|
|
|
|
wm.setState(ledgerRfid.getDictLabel());
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
wm.clearText();
|
|
|
|
wm.clearText();
|
|
|
|
Toast.makeText(BFActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(BFActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -61,28 +75,57 @@ public class BFActivity extends BaseActivity {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void bf_submit(View view){
|
|
|
|
public void bfTackPhoto(View view) {
|
|
|
|
if (wm.getState().equals("正常")){
|
|
|
|
takePhoto();
|
|
|
|
OkGo.<MyResult>post(url+"/bf/submit")
|
|
|
|
}
|
|
|
|
.params("epc",wm.getEpc())
|
|
|
|
|
|
|
|
.params("remark",wm.getRemark())
|
|
|
|
public void bfShowPhoto(View view) {
|
|
|
|
.params("user", SharedPreferencesUtils.getstring("user","test-user"))
|
|
|
|
takeDialog.setBitmaps(bitmaps, files);
|
|
|
|
.execute(new MyRecultCall(dialog,this){
|
|
|
|
takeDialog.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void bf_submit(View view) {
|
|
|
|
|
|
|
|
String state = wm.getState();
|
|
|
|
|
|
|
|
if (state==null ) return;
|
|
|
|
|
|
|
|
if ( state.equals("正常")) {
|
|
|
|
|
|
|
|
String reason = wm.getReason();
|
|
|
|
|
|
|
|
String remark = wm.getRemark();
|
|
|
|
|
|
|
|
if (reason.equals("其他") && remark ==null ) return;
|
|
|
|
|
|
|
|
OkGo.<MyResult>post(url + "/bf/submit")
|
|
|
|
|
|
|
|
.params("epc", wm.getEpc())
|
|
|
|
|
|
|
|
.params("reason", reason)
|
|
|
|
|
|
|
|
.params("remark", remark)
|
|
|
|
|
|
|
|
.params("user", SharedPreferencesUtils.getstring("user", ""))
|
|
|
|
|
|
|
|
.addFileParams("files",files)
|
|
|
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
super.onSuccess(response);
|
|
|
|
super.onSuccess(response);
|
|
|
|
var body = response.body();
|
|
|
|
var body = response.body();
|
|
|
|
if (body.getCode()==0){
|
|
|
|
if (body.getCode() == 0) {
|
|
|
|
Toast.makeText(BFActivity.this, "提交成功", Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(BFActivity.this, "提交成功", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
files.forEach(File::delete);
|
|
|
|
finish();
|
|
|
|
finish();
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
Toast.makeText(BFActivity.this,body.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(BFActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
Toast.makeText(this, "轮挡已报废,无需操作", Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(this, "轮挡已报废,无需操作", Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void returnListSize(int size) {
|
|
|
|
|
|
|
|
dataBinding.bfPictureNumber.setText(bitmaps.size() + "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void takePhotoCall(File outputImage, Bitmap bitmap) {
|
|
|
|
|
|
|
|
files.add(outputImage);
|
|
|
|
|
|
|
|
bitmaps.add(bitmap);
|
|
|
|
|
|
|
|
dataBinding.bfPictureNumber.setText(bitmaps.size() + "");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|