完成 报废

idata
wanghao 4 months ago
parent cd03058083
commit 6d2031f1a4

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

@ -11,7 +11,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import com.example.beijing_daxing.adapter.CheckAdapter;
@ -32,9 +31,7 @@ import com.uhf.api.cls.Reader;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import cn.pda.serialport.Tools;
@ -223,7 +220,7 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
// 拍照
public void check_tackPhoto(View view) {
teke_photo();
takePhoto();
}
// 显示拍的照片

@ -13,6 +13,7 @@ import com.example.beijing_daxing.base.MyRecultCall;
import com.example.beijing_daxing.base.MyResult;
import com.example.beijing_daxing.been.LedgerRfid;
import com.example.beijing_daxing.databinding.ActivityFpInBinding;
import com.example.beijing_daxing.uitls.HexAscii;
import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.example.beijing_daxing.vm.FpInVm;
import com.lzy.okgo.OkGo;
@ -32,13 +33,13 @@ public class FpInActivity extends BaseActivity {
ActivityFpInBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_fp_in);
vm = new FpInVm();
binding.setVm(vm);
setPower(17);
setPower(SharedPreferencesUtils.getInt("powerScrapIn",17));
}
@Override
protected void sanRfid(List<Reader.TAGINFO> epcs) {
Reader.TAGINFO taginfo = epcs.get(0);
var epc = Tools.Bytes2HexString(taginfo.EpcId,taginfo.EpcId.length);
var epc = HexAscii.hex2Str(Tools.Bytes2HexString(taginfo.EpcId,taginfo.EpcId.length));
vm.setEpc(epc);
OkGo.<MyResult>post(url+"/fpin/select")
.tag(this).params("epc",epc)

@ -19,6 +19,7 @@ import com.example.beijing_daxing.base.MyRecultCall;
import com.example.beijing_daxing.base.MyResult;
import com.example.beijing_daxing.been.Stock;
import com.example.beijing_daxing.databinding.ActivityFpOutBinding;
import com.example.beijing_daxing.uitls.HexAscii;
import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
@ -42,8 +43,9 @@ public class FpOutActivity extends BaseActivity {
binding.setCheckState(checkState);
adapter = new OutAdapter(this);
binding.setAdapter(adapter);
tagList=new ArrayList<>();
initRequest();
setPower(17);
setPower(SharedPreferencesUtils.getInt("powerScrapOut",17));
}
private List<String> tagList;
@ -53,11 +55,11 @@ public class FpOutActivity extends BaseActivity {
epcs.forEach(t -> {
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
if (tagList.contains(epc)){
tagList.add(epc);
return;
}
tagList.add(epc);
var stock = new Stock();
stock.setEpcCode(epc);
stock.setEpcCode(HexAscii.hex2Str(epc));
var index = list.indexOf(stock);
if (index != -1) {
list.get(index).setState("Y");
@ -74,7 +76,6 @@ public class FpOutActivity extends BaseActivity {
if (body.getCode() == 0) {
list = gson.fromJson(body.getData().toString(), new TypeToken<List<Stock>>() {
}.getType());
tagList=new ArrayList<>();
adapter.setList(list);
adapter.notifyDataSetChanged();
} else {

@ -4,7 +4,6 @@ import android.Manifest;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@ -17,9 +16,7 @@ import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Window;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
@ -36,7 +33,6 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@ -44,7 +40,7 @@ import java.util.List;
import okhttp3.MediaType;
public abstract class BaseActivity extends AppCompatActivity {
public static String url = "http://192.168.0.102:8090/api";
public static String url = "http://192.168.137.1:8090/api";
// public static String url = "http://119.45.202.115:8090/api";
public ProgressDialog dialog;
public Gson gson;
@ -140,7 +136,7 @@ public abstract class BaseActivity extends AppCompatActivity {
public SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
// 拍照
public void teke_photo() {
public void takePhoto() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
}
@ -182,7 +178,7 @@ public abstract class BaseActivity extends AppCompatActivity {
Log.e("TAG", "onActivityResult:" + img_uri.getPath());
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(img_uri));
FileOutputStream outputStream = new FileOutputStream(outputImage);
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, outputStream);
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, outputStream);
takePhotoCall(outputImage, bitmap);
outputStream.close();
} catch (FileNotFoundException e) {

@ -1,7 +1,12 @@
package com.example.beijing_daxing.vm;
import android.view.View;
import android.widget.AdapterView;
import androidx.databinding.BaseObservable;
import java.util.List;
/**
* @author wanghao
* @date 2024/1/25 16:59
@ -10,8 +15,38 @@ public class BFWm extends BaseObservable {
private String epc;
private String pcode;
private String state;
private String reason;
private String remark;
private List<String> list;
private boolean editState;
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public List<String> getList() {
return list;
}
public void setList(List<String> list) {
this.list = list;
}
public boolean isEditState() {
return editState;
}
public void setEditState(boolean editState) {
this.editState = editState;
notifyChange();
}
public String getRemark() {
return remark;
}
@ -51,4 +86,11 @@ public class BFWm extends BaseObservable {
state = remark = pcode = null;
notifyChange();
}
public void itemSelect(AdapterView<?> parent, View view, int position, long id){
String s = list.get(position);
setEditState(s.equals("其他"));
setReason(s);
}
}

@ -7,6 +7,7 @@
<variable
name="vm"
type="com.example.beijing_daxing.vm.BFWm" />
<import type="android.view.View"/>
</data>
<LinearLayout
@ -96,7 +97,31 @@
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="报废原因:" />
android:text="选择原因:" />
<Spinner
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:textAlignment="center"
android:onItemSelected="@{vm.itemSelect}"
android:entries="@array/bfyy"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:visibility="@{vm.editState?View.VISIBLE:View.GONE}"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="输入其他:" />
<EditText
style="@style/info_text"
@ -105,12 +130,51 @@
android:layout_gravity="center"
android:text="@={vm.remark}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="horizontal">
<ImageButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:src="@mipmap/icon_cromer"
android:onClick="bfTackPhoto"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:onClick="bfShowPhoto"
android:text="查看照片"/>
<TextView
android:id="@+id/bf_picture_number"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:background="@drawable/bg_number"
android:gravity="center"
android:text="0"
android:textColor="@color/white"
android:textSize="18sp"
/>
</FrameLayout>
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_margin="20dp"
android:layout_marginTop="10dp"
android:onClick="bf_submit"
android:text="标记报废" />

@ -6,4 +6,12 @@
<item>跳过</item>
<item>报废</item>
</string-array>
<string-array name="bfyy">
<item>轮挡绳子损坏</item>
<item>反光损坏</item>
<item>橡胶损坏</item>
<item>其他</item>
</string-array>
</resources>
Loading…
Cancel
Save