完成 交货

master
wangh 6 months ago
parent 464bcfa2bf
commit 5620639649

@ -46,4 +46,8 @@ dependencies {
implementation 'com.lzy.net:okgo:3.0.4'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.google.zxing:core:3.3.3'
// https://mvnrepository.com/artifact/com.google.zxing/javase
// implementation 'com.google.zxing:javase:3.5.3'
}

@ -22,12 +22,15 @@
android:theme="@style/Theme.BGSRFIDTrack"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".JionActivity"
android:exported="false" />
<activity
android:name=".BindingDBActivity"
android:exported="false" />
<activity
android:name=".RflyActivity"
android:exported="true"></activity>
android:exported="true" />
<activity
android:name=".UnBindingActivity"
android:exported="false" />
@ -48,7 +51,6 @@
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

@ -20,7 +20,7 @@ public class HomePageActivity extends BaseActivity {
Intent intent = new Intent(this, BindingActivity.class);
Intent intent2 = new Intent(this, UnBindingActivity.class);
Intent intent3 = new Intent(this, BindingDBActivity.class);
Intent intent4 = new Intent(this, UnBindingActivity.class);
Intent jionIntent = new Intent(this, JionActivity.class);
binding.homeIn.setOnClickListener(v -> {
startActivity(intent);
});
@ -30,8 +30,13 @@ public class HomePageActivity extends BaseActivity {
binding.binding.setOnClickListener(v -> {
startActivity(intent3);
});
binding.homeJiaojie.setOnClickListener(v -> {
startActivity(intent4);
binding.homeJiao.setOnClickListener(v -> {
jionIntent.putExtra("type", true);
startActivity(jionIntent);
});
binding.homeJie.setOnClickListener(v -> {
jionIntent.putExtra("type", false);
startActivity(jionIntent);
});
}

@ -0,0 +1,117 @@
package com.example.bgsrfidtrack;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import android.graphics.Bitmap;
import com.example.bgsrfidtrack.dialog.DialogClickCall;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.example.bgsrfidtrack.adapter.JionAdapter;
import com.example.bgsrfidtrack.base.BaseActivity;
import com.example.bgsrfidtrack.base.MyRecultCall;
import com.example.bgsrfidtrack.base.MyResult;
import com.example.bgsrfidtrack.base.SharedPreferencesUtils;
import com.example.bgsrfidtrack.databinding.ActivityJionBinding;
import com.example.bgsrfidtrack.dialog.ImgDialog;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import java.util.Hashtable;
import java.util.List;
public class JionActivity extends BaseActivity implements DialogClickCall {
private String ip;
private JionAdapter adapter;
private ImgDialog imgDialog;
private List<String> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityJionBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_jion);
var type = getIntent().getBooleanExtra("type", true);
binding.setState(type);
ip = SharedPreferencesUtils.getstring("ip", "");
adapter = new JionAdapter(this);
imgDialog = new ImgDialog(this, this);
binding.setAdapter(adapter);
if (type) {
binding.setTitle("交货");
initJionRequest();
} else {
binding.setTitle("接货");
}
}
// 查询交货列表
private void initJionRequest() {
OkGo.<MyResult>post("http://" + ip + "/api/jion/select")
.params("user", SharedPreferencesUtils.getstring("user", ""))
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
var body = response.body();
if (body.getCode() == 0) {
list = gson.fromJson(body.getJson(), new TypeToken<List<String>>() {
}.getType());
adapter.setList(list);
adapter.notifyDataSetChanged();
}
Toast.makeText(context, body.getMsg(), Toast.LENGTH_SHORT).show();
}
});
}
public void jionDialogShow(View view) {
String s = list.toString().replace("[","").replace("]","");
Log.e("TAG", "jionDialogShow:" + s);
try {
imgDialog.dialogShow(Create2DCode(s, 600, 600));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public Bitmap Create2DCode(String str, int w, int h) throws Exception {
BitMatrix matrix = new MultiFormatWriter().encode(str, BarcodeFormat.QR_CODE, w, h);
int width = matrix.getWidth();
int height = matrix.getHeight();
// 二维矩阵转为一维像素数组
int[] pixels = new int[width * height];
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
if (matrix.get(i, j)) {
pixels[j * width + i] = Color.BLACK;
}
}
}
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
// 通过像素数组生成bitmap,具体参考api
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
}
@Override
public void dialogClick() {
}
}

@ -212,6 +212,7 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
.params("locationCode", list2.get(0))
.params("hkCode", list1.get(0))
.execute(new MyRecultCall(dialog, this) {
@SuppressLint("NotifyDataSetChanged")
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);

@ -80,7 +80,7 @@ public class UnBindingActivity extends BaseActivity implements MyKeyInfoCall, Ad
var body = response.body();
if (body.getCode() == 0) {
list = gson.fromJson(body.getData().toString(), new TypeToken<List<String>>() {
list = gson.fromJson(body.getJson(), new TypeToken<List<String>>() {
}.getType());
adapter.setList(list);
adapter.notifyDataSetChanged();

@ -0,0 +1,67 @@
package com.example.bgsrfidtrack.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.example.bgsrfidtrack.R;
import com.example.bgsrfidtrack.databinding.ItemGoodsInfoBinding;
import com.example.bgsrfidtrack.databinding.ItemJionBinding;
import java.util.List;
/**
* @author wanghao
* @date 2024/7/10 15:30
*/
public class JionAdapter extends RecyclerView.Adapter<JionAdapter.MyViewHolder> {
private Context context;
private List<String> list;
private LayoutInflater inflater;
public JionAdapter(Context context) {
this.context = context;
inflater = LayoutInflater.from(context);
}
public void setList(List<String> list) {
this.list = list;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ItemJionBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_jion, parent, false);
return new MyViewHolder(binding);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
var binding = holder.binding;
binding.itemCode.setText(list.get(position));
binding.itemIndex.setText(position+1+"");
}
@Override
public int getItemCount() {
return list==null ? 0 : list.size();
}
static class MyViewHolder extends RecyclerView.ViewHolder {
private ItemJionBinding binding;
public MyViewHolder(ItemJionBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
}
}

@ -31,7 +31,7 @@ public class MyRecultCall extends AbsCallback<MyResult> {
if (body == null) return null;
Gson gson = new Gson();
MyResult resust = gson.fromJson(body.string(), MyResult.class);
resust.setData(gson.toJson(resust.getData()));
resust.setJson(gson.toJson(resust.getData()));
return resust;
}

@ -7,10 +7,19 @@ package com.example.bgsrfidtrack.base;
public class MyResult {
private int code;
private String msg;
private String json;
private Object data;
private Object rows;
private int total;
public String getJson() {
return json;
}
public void setJson(String json) {
this.json = json;
}
public int getTotal() {
return total;
}

@ -0,0 +1,9 @@
package com.example.bgsrfidtrack.dialog;
/**
* @author wanghao
* @date 2024/7/26 16:22
*/
public interface DialogClickCall {
void dialogClick();
}

@ -0,0 +1,39 @@
package com.example.bgsrfidtrack.dialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import com.example.bgsrfidtrack.R;
import com.example.bgsrfidtrack.databinding.DialogImgBinding;
import com.example.bgsrfidtrack.databinding.ItemJionBinding;
/**
* @author wanghao
* @date 2024/7/26 13:23
*/
public class ImgDialog extends Dialog {
private DialogImgBinding binding;
private DialogClickCall call;
public ImgDialog(@NonNull Context context,DialogClickCall call) {
super(context, R.style.dialogStyle);
LayoutInflater inflater=LayoutInflater.from(context);
this.call=call;
binding = DataBindingUtil.inflate(inflater,R.layout.dialog_img,null,false);
setContentView(binding.getRoot());
binding.dialogDis.setOnClickListener(v -> dismiss());
binding.dialogSubmit.setOnClickListener(v -> call.dialogClick());
}
public void dialogShow(Bitmap bitmap) {
binding.dialogImg.setImageBitmap(bitmap);
super.show();
}
}

@ -72,15 +72,47 @@
android:textSize="20sp" />
<RadioButton
android:id="@+id/home_jiaojie"
android:id="@+id/home_cha"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/icon_jiaojie"
android:drawableTop="@mipmap/home_cha"
android:drawablePadding="8dp"
android:gravity="center"
android:text="交接"
android:text="查询"
android:textSize="20sp" />
</RadioGroup>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<RadioButton
android:id="@+id/home_jiao"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/home_jiao"
android:drawablePadding="8dp"
android:gravity="center"
android:text="交货"
android:textSize="20sp" />
<RadioButton
android:id="@+id/home_jie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/home_jie"
android:drawablePadding="8dp"
android:gravity="center"
android:text="接货"
android:textSize="20sp" />
</RadioGroup>

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="title"
type="String" />
<variable
name="state"
type="Boolean" />
<import type="android.view.View" />
<variable
name="adapter"
type="com.example.bgsrfidtrack.adapter.JionAdapter" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".JionActivity">
<include
layout="@layout/title_bar"
app:title="@{title}" />
<LinearLayout
style="@style/layoutbg"
android:layout_width="match_parent"
android:layout_height="45dp"
android:visibility="@{state?View.GONE:View.VISIBLE}">
<TextView
style="@style/textbg"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="交货码" />
<TextView
android:id="@+id/unbinding_epc"
style="@style/santextbg"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
style="@style/layoutbg"
android:layout_width="match_parent"
android:layout_height="35dp">
<TextView
style="@style/textbg"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="序号" />
<TextView
style="@style/textbg"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:text="货框" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/white"
android:adapter="@{adapter}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:padding="4dp" />
<Button
style="@style/buttonbg"
android:layout_width="match_parent"
android:layout_height="50dp"
android:onClick="jionDialogShow"
android:text='@{state?"交货":"确认"}'/>
</LinearLayout>
</layout>

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
</data>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
<ImageView
android:id="@+id/dialog_dis"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@mipmap/icon_cha"
android:layout_gravity="right"
android:padding="22dp" />
<ImageView
android:id="@+id/dialog_img"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="对方扫描交货码"
android:gravity="center"
android:textColor="@color/blue"
android:textSize="16sp" />
<Button
android:id="@+id/dialog_submit"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="完成"
style="@style/buttonbg" />
</LinearLayout>
</layout>

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
</data>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="@+id/item_index"
style="@style/textbg"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="序号" />
<TextView
android:id="@+id/item_code"
style="@style/textbg"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:text="货物条码" />
</LinearLayout>
</layout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -44,4 +44,18 @@
</style>
<style name="dialogStyle">
<!--背景颜色及和透明程度-->
<item name="android:windowBackground">@android:color/transparent</item>
<!--是否去除标题 -->
<item name="android:windowNoTitle">true</item>
<!--是否去除边框-->
<item name="android:windowFrame">@null</item>
<!--是否浮现在activity之上-->
<item name="android:windowIsFloating">true</item>
<!--是否模糊-->
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowMinWidthMinor">95%</item><!--宽度铺满全屏-->
</style>
</resources>
Loading…
Cancel
Save