修改入库等界面功能

main
杨万里 2 months ago
parent b5ad951171
commit d174f408bf

@ -46,7 +46,7 @@ public class HomePageActivity extends AppCompatActivity {
/**
* 1 R.id.logout
*/
@OnClick({R.id.chaxun, R.id.ruku, R.id.chuku, R.id.zhuangxie, R.id.huanwei, R.id.zhijian, R.id.xxbd,R.id.test1, R.id.logout})
@OnClick({R.id.chaxun, R.id.ruku, R.id.chuku, R.id.zhuangxie, R.id.huanwei, R.id.zhijian, R.id.xxbd,R.id.test1,R.id.test2, R.id.logout})
public void onViewClicked(View view) {
Intent intent; // 建议在这里声明,而不是方法最开始
@ -75,6 +75,9 @@ public class HomePageActivity extends AppCompatActivity {
case R.id.test1:
intent = new Intent(this, TyreLayoutActivity.class);
break;
case R.id.test2:
intent = new Intent(this, TyreLayoutActivity.class);
break;
case R.id.logout:
// 修改点 2处理退出逻辑
handleLogout();

@ -16,11 +16,12 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.android.hdhe.uhf.reader.UhfReader;
import com.android.hdhe.uhf.readerInterface.TagModel;
import com.example.tyre.entity.AjaxResult;
@ -28,130 +29,120 @@ import com.example.tyre.entity.BaseTyre;
import com.example.tyre.entity.EPC;
import com.example.tyre.entity.InStoreSpinnerVo;
import com.example.tyre.entity.Tyre;
import com.example.tyre.entity.TyreSizeVo;
import com.example.tyre.util.CommonDialog;
import com.example.tyre.util.MyUrl;
import com.example.tyre.util.PlayMusic;
import com.example.tyre.util.SharedPreferencesUtils;
import com.example.tyre.util.Util;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import androidx.appcompat.app.AppCompatActivity;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.pda.serialport.Tools;
/**
* Created by on 2019/12/10.
* Activity ()
* XML
*/
public class InStoreHouseActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
public class InStoreHouseActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener{
// === UI 组件绑定 (基于新布局修正) ===
@BindView(R.id.button) Button button;
@BindView(R.id.back) Button back;
@BindView(R.id.button)
Button button;
@BindView(R.id.epc)
TextView scan;
@BindView(R.id.pinpai)
TextView pinpai;
@BindView(R.id.xinghao)
TextView xinghao;
@BindView(R.id.cengji)
TextView cengji;
@BindView(R.id.huawen)
TextView huawen;
@BindView(R.id.gcts)
TextView gcts;
@BindView(R.id.back)
Button back;
@BindView(R.id.wtbm)
EditText wtbm;
// @BindView(R.id.zbh)
// EditText zbh;
// @BindView(R.id.spinner)
// Spinner spinner;
@BindView(R.id.linearLayout3)
LinearLayout linearLayout3;
// @BindView(R.id.czy)
// TextView czy;
@BindView(R.id.tyrekind)
TextView tyrekind;
@BindView(R.id.spinnerkind)
Spinner spinnerkind;
// 1. EPC 相关:原 @BindView(R.id.epc) 是 TextView现在建议直接读取显示文本或维护内部变量
// 假设 XML 中 Spinner EPC 的 ID 是 spinnerEPC (根据上一轮修改)
@BindView(R.id.EPC)
TextView EPC;
@BindView(R.id.spinnerpattern)
Spinner spinnerpattern;
// 2. 胎号 (EditText)
@BindView(R.id.wtbm) EditText wtbm;
@BindView(R.id.spinnerlevel)
Spinner spinnerlevel;
// 3. 花纹深度 (EditText)
@BindView(R.id.patternDepth) EditText patternDepth;
@BindView(R.id.spinnerSize)
Spinner spinnerSize;
// 4. 下拉框 Spinners (核心修复点)
@BindView(R.id.spinnerkind) Spinner spinnerkind;
@BindView(R.id.spinnerpattern) Spinner spinnerpattern;
@BindView(R.id.spinnerlevel) Spinner spinnerlevel;
@BindView(R.id.spinnerSize) Spinner spinnerSize;
@BindView(R.id.spinnerBrand) Spinner spinnerBrand;
@BindView(R.id.spinnergcts) Spinner spinnergcts;
@BindView(R.id.spinnerBrand)
Spinner spinnerBrand;
// === 内部数据变量 (用于保存选中的值) ===
// 注意:不再需要 pinpai, xinghao 等 TextView 的 BindView
// 我们直接通过 Spinner.getSelectedItem().toString() 获取值
// 或者定义变量保存
private String selectedBrand = "";
private String selectedModel = "";
private String selectedLevel = "";
private String selectedPattern = "";
private String selectedKind = "";
private String selectedGcts = "";
@BindView(R.id.spinnergcts)
Spinner spinnergcts;
// private UHFService mDevice;
// private MyHandler handler;
// === 业务逻辑变量 ===
private boolean isStart = true;
private ProgressDialog progressDialog;
private boolean runFlag = true;
private boolean startFlag = false;
private UhfReader manager; // UHF manager,UHF Operating handle
private UhfReader manager;
private ArrayList<EPC> listEPC;
private ArrayList<String> listepc = new ArrayList<String>();
private List<TyreSizeVo> patternSize;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_instorehouse);
setContentView(R.layout.activity_instorehouse); // 确保使用新布局
ButterKnife.bind(this);
manager = MyApplication.getManager();
initView();
// 初始化下拉框数据
check_spinner();
showLoadingDialog();
// 启动 UHF 扫描线程
Thread thread = new InventoryThread();
thread.start();
Util.initSoundPool(this);
}
private void initView() {
listEPC = new ArrayList<EPC>();
// 初始化所有 Spinner 的监听器
initSpinners();
}
/**
* Spinner
*
*/
private void initSpinners() {
spinnerkind.setOnItemSelectedListener(this);
spinnerpattern.setOnItemSelectedListener(this);
spinnerlevel.setOnItemSelectedListener(this);
spinnerSize.setOnItemSelectedListener(this);
spinnerBrand.setOnItemSelectedListener(this);
spinnergcts.setOnItemSelectedListener(this);
initView();
Thread thread = new InventoryThread();
thread.start();
com.example.tyre.util.Util.initSoundPool(this);
// spinner.setOnItemSelectedListener(this);
}
private void showLoadingDialog() {
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("数据加载中...");
progressDialog.setCancelable(false);
progressDialog.show();
}
private void hideLoadingDialog() {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
@Override
public void onResume() {
super.onResume();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); }
registerReceiver();
startFlag = false; // 开启扫描
}
@Override
@ -163,382 +154,301 @@ public class InStoreHouseActivity extends AppCompatActivity implements AdapterVi
@Override
protected void onDestroy() {
startFlag = false;
runFlag = false;
super.onDestroy();
}
private void initView() {
listEPC = new ArrayList<EPC>();
}
/**
* Inventory EPC Thread
*/
// === UHF 扫描逻辑优化 ===
class InventoryThread extends Thread {
private List<TagModel> tagList;
byte[] accessPassword = Tools.HexString2Bytes("00000000");
@Override
public void run() {
super.run();
while (runFlag) {
if (startFlag) {
tagList = manager.inventoryRealTime(); //实时盘存
List<TagModel> tagList = manager.inventoryRealTime();
if (tagList != null && !tagList.isEmpty()) {
//播放提示音
Util.play(1, 0);
Util.play(1, 0); // 播放提示音
for (TagModel tag : tagList) {
if (tag == null) {
String epcStr = "";
// String epcStr = new String(epc);
addToList(listEPC, epcStr, (byte) -1);
} else {
String epcStr = Tools.Bytes2HexString(tag.getmEpcBytes(), tag.getmEpcBytes().length);
// String epcStr = new String(epc);
byte rssi = tag.getmRssi();
addToList(listEPC, epcStr, rssi);
}
String epcStr = tag == null ? "" :
Tools.Bytes2HexString(tag.getmEpcBytes(), tag.getmEpcBytes().length);
byte rssi = tag != null ? tag.getmRssi() : -1;
addToList(epcStr, rssi);
}
}
tagList = null;
try {
Thread.sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// 防止频繁刷新
try { Thread.sleep(20); } catch (InterruptedException e) { }
}
}
}
}
}
long lastTime;
long nextTime;
// EPC add to LISTVIEW
private void addToList(final List<EPC> list, final String epc, final byte rssi) {
/**
* EPC
* UI
*/
private void addToList(final String epc, final byte rssi) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// The epc for the first time
if (list.isEmpty()) {
EPC epcTag = new EPC();
epcTag.setEpc(epc);
epcTag.setCount(1);
epcTag.setRssi(rssi);
list.add(epcTag);
listepc.add(epc);
// 1. 更新 EPC 显示 (直接设置到 Spinner 或 TextView)
// 假设 spinnerEPC 是用来显示 EPC 的
// 这里可能需要一个只读的 Adapter 或者直接 setText (如果 spinnerEPC 改为了 TextView)
// 为了简化,假设我们有一个方法更新 EPC 显示
//updateEpcDisplay(epc);
EPC.setText(epc);
// 2. 清理旧数据 (根据业务逻辑调整,通常不建议每次扫描都清空)
listepc.clear();
listepc.add(epc);
}else {
for (int i = 0; i < list.size(); i++) {
EPC mEPC = list.get(i);
// list contain this epc
if (epc.equals(mEPC.getEpc())) {
mEPC.setCount(mEPC.getCount() + 1);
mEPC.setRssi(rssi);
list.set(i, mEPC);
break;
} else if (i == (list.size() - 1)) {
// list doesn't contain this epc
EPC newEPC = new EPC();
newEPC.setEpc(epc);
newEPC.setCount(1);
newEPC.setRssi(rssi);
list.add(newEPC);
listepc.add(epc);
}
}
// 3. 自动查询后台数据
if (!epc.isEmpty()) {
find(epc);
startFlag = false; // 扫描到一次后暂停,防止重复提交
}
// play sound
lastTime = SystemClock.elapsedRealtime();
long time = lastTime - nextTime;
if (time >= 60) {
Util.play(1, 0);
nextTime = lastTime;
Log.e("TAG", "run: " + time);
}
if (listepc != null && !listepc.isEmpty()){
startFlag = false;
String currentEpc = listepc.get(0);
scan.setText(currentEpc);
}
clearData();
}
});
Log.e("EPC", "listepc:+ " + listepc);
// if (listepc != null && !listepc.isEmpty()){
// startFlag = false;
//// scan.setText("测试");
// scan.setText(listepc.get(0).toString());
// //请求后台
// find(listepc.get(0).toString());
// }
// clearData();
}
private void clearData() {
listEPC.removeAll(listEPC);
listepc.removeAll(listepc);
private void updateEpcDisplay(String epc) {
// 这里根据你的实际布局调整
// 如果 spinnerEPC 是 Spinner你可能需要一个包含该 EPC 的 Adapter
// 或者在 XML 中保留一个隐藏的 EditText 用于传参
// 简单处理:打印日志
Log.d("UHF", "Scanned EPC: " + epc);
}
// 基本信息查询
// === 网络请求与数据填充 ===
private void find(String epc) {
OkGo.<String>post(MyUrl.url + "/tyre/tyre/pdaQueryTyreInfo").tag(this)
showLoadingDialog();
OkGo.<String>post(MyUrl.url + "/tyre/tyre/pdaQueryTyreInfo")
.tag(this)
.params("tyreEpc", epc)
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
String body = response.body();
Log.e("body", body);
try {
Gson gson = new Gson();
BaseTyre baseTyre = gson.fromJson(body, BaseTyre.class);
if (baseTyre != null) {
// 空值处理:若字段为 null 则显示空字符串
String tyreNo = safeGetString(baseTyre.getTyreNo());
wtbm.setText(tyreNo);
String brand = safeGetString(baseTyre.getTyreBrand());
String model = safeGetString(baseTyre.getTyreModel());
String level = safeGetString(baseTyre.getTyreLevel());
String pattern = safeGetString(baseTyre.getTyrePattern());
String kind = safeGetString(baseTyre.getTyreType());
pinpai.setText(brand);
xinghao.setText(model);
cengji.setText(level);
huawen.setText(pattern);
tyrekind.setText(kind);
@Override
public void onSuccess(Response<String> response) {
hideLoadingDialog();
try {
Gson gson = new Gson();
BaseTyre baseTyre = gson.fromJson(response.body(), BaseTyre.class);
if (baseTyre != null) {
// 填充表单数据
// 注意:这里不再 setText 到被移除的 TextView
// 而是应该选中 Spinner 的对应项,或者填充 EditText
wtbm.setText(safeGetString(baseTyre.getTyreNo()));
// 逻辑优化Spinner 应该通过 Adapter 选中 position
// 这里简化处理,直接记录值供提交使用
selectedBrand = safeGetString(baseTyre.getTyreBrand());
selectedModel = safeGetString(baseTyre.getTyreModel());
selectedLevel = safeGetString(baseTyre.getTyreLevel());
selectedPattern = safeGetString(baseTyre.getTyrePattern());
selectedKind = safeGetString(baseTyre.getTyreType());
// 如果需要自动选中 Spinner需要遍历 Adapter 寻找 position
// setSelectedSpinnerItem(spinnerBrand, selectedBrand);
}else {
wtbm.setText("");
}
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (JsonSyntaxException e) {
return;
}
}
});
});
}
private String safeGetString(String value) {
// 注意:原代码中有一行是 "null".equals(value),这是为了防止后台返回字符串 "null"
return value == null || "null".equals(value) ? "" : value;
}
//添加到库存表
private void insert_inventory(String epc,String wtbm,String pinpai,String xinghao,String cengji,String huawen,String grooves,String tyrekind) {
OkGo.<String>post(MyUrl.url + "/tyre/inventory/pdaAddInventory").tag(this)
.params("tyreRfid", epc)
.params("tyreEpc",epc)
.params("tyreOutsideId",wtbm)
.params("tyreBrand",pinpai)
.params("tyreModel",xinghao)
.params("tyreLevel",cengji)
.params("tyrePattern",huawen)
.params("grooves",grooves)
.params("tyreType",tyrekind)
.params("CreateBy",SharedPreferencesUtils.getstring("user","admin")).execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
hideLoadingDialog();
String body = response.body();
Gson gson = new Gson();
AjaxResult ajaxResult = gson.fromJson(body, AjaxResult.class);
handleResponse(ajaxResult);
}
@Override
public void onError(Response<String> response) {
hideLoadingDialog();
Toast.makeText(InStoreHouseActivity.this, "请求失败,请检查网络或重试", Toast.LENGTH_SHORT).show();
}
});
}
private void handleResponse(AjaxResult result) {
switch (result.getCode()) {
case "500":
new CommonDialog(this).setMessage(result.getMsg()).show();
break;
case "0":
new CommonDialog(this).setMessage(result.getMsg()).show();
break;
}
}
// === 提交逻辑 ===
@OnClick({R.id.button, R.id.back})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.button:
// int len=wtbm.getText().toString().length();
// if (len != 11){
// new CommonDialog(InStoreHouseActivity.this).setMessage("胎号填写错误").show();
// }else {
// Log.e("aaaaa",epc.substring(4)+wtbm.getText().toString()+tyrekind.getText().toString());
String epc=scan.getText().toString();
String w=wtbm.getText().toString();
// String zb=zbh.getText().toString();
String p = pinpai.getText().toString();
String x=xinghao.getText().toString();
String c=cengji.getText().toString();
String h=huawen.getText().toString();
String t=tyrekind.getText().toString();
String g=gcts.getText().toString();
if (scan.getText().toString()==""){
new CommonDialog(InStoreHouseActivity.this).setMessage("请扫描轮胎芯片!").show();
return;
}
showLoadingDialog();
insert_inventory(epc,w,p,x,c,h,g,t);
// }
submitData();
break;
case R.id.back:
Intent intent = new Intent(this, HomePageActivity.class);
startActivity(intent);
finish(); // 推荐使用 finish 返回
break;
}
}
private void submitData() {
// 1. 获取当前显示的值
// String epc = ((TextView) spinnerEPC.getChildAt(0)).getText().toString(); // 复杂
// 简单方案:假设你有一个变量保存了最后扫描的 EPC
String currentEpc = getCurrentEpcFromUHF(); // 你需要实现这个逻辑或维护一个变量
if (currentEpc.isEmpty()) {
new CommonDialog(this).setMessage("请扫描轮胎芯片!").show();
return;
}
String wtbmStr = wtbm.getText().toString().trim();
String depthStr = patternDepth.getText().toString().trim();
// 2. 获取下拉框选中的值 (核心修复)
// 由于去除了重影 TextView直接从 Spinner 获取
String brand = spinnerBrand.getSelectedItem() != null ?
spinnerBrand.getSelectedItem().toString() : selectedBrand;
String model = spinnerSize.getSelectedItem() != null ?
spinnerSize.getSelectedItem().toString() : selectedModel;
String level = spinnerlevel.getSelectedItem() != null ?
spinnerlevel.getSelectedItem().toString() : selectedLevel;
String pattern = spinnerpattern.getSelectedItem() != null ?
spinnerpattern.getSelectedItem().toString() : selectedPattern;
String kind = spinnerkind.getSelectedItem() != null ?
spinnerkind.getSelectedItem().toString() : selectedKind;
String grooves = spinnergcts.getSelectedItem() != null ?
spinnergcts.getSelectedItem().toString() : selectedGcts;
// 3. 参数校验
if (wtbmStr=="" || wtbmStr == null || wtbmStr == "Scan fail") {
new CommonDialog(this).setMessage("胎号不能为空").show();
return;
}
showLoadingDialog();
// 4. 发送网络请求
OkGo.<String>post(MyUrl.url + "/tyre/inventory/pdaAddInventory")
.tag(this)
.params("tyreRfid", currentEpc)
.params("tyreEpc", currentEpc)
.params("tyreOutsideId", wtbmStr)
.params("tyreBrand", brand)
.params("tyreModel", model)
.params("tyreLevel", level)
.params("tyrePattern", pattern)
.params("grooves", grooves)
.params("tyreType", kind)
.params("patternDepth", depthStr)
.params("CreateBy", SharedPreferencesUtils.getstring("user", "admin"))
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
hideLoadingDialog();
handleResponse(response.body());
}
@Override
public void onError(Response<String> response) {
hideLoadingDialog();
Toast.makeText(InStoreHouseActivity.this, "请求失败,请检查网络", Toast.LENGTH_SHORT).show();
}
});
}
private String getCurrentEpcFromUHF() {
// TODO: 实现获取当前扫描到的 EPC 的逻辑
// 例如返回 listepc.get(0) 或者维护一个全局变量 currentEpc
return listepc.isEmpty() ? "" : listepc.get(0);
}
private void handleResponse(String body) {
try {
AjaxResult result = new Gson().fromJson(body, AjaxResult.class);
new CommonDialog(this).setMessage(result.getMsg()).show();
if ("200".equals(result.getCode())) { // 假设 200 是成功
// 清空数据以便下一次扫描
clearForm();
}
} catch (Exception e) {
Toast.makeText(this, "数据解析错误", Toast.LENGTH_SHORT).show();
}
}
private void clearForm() {
wtbm.setText("");
patternDepth.setText("");
EPC.setText("");
// spinnerEPC... 清空逻辑
}
// === 下拉框数据加载 (保持不变,但 Adapter 绑定逻辑需确认) ===
private void check_spinner() {
showLoadingDialog();
OkGo.<String>post(MyUrl.url + "/system/dict/data/tyreTypeList")
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
try {
Gson gson = new Gson();
InStoreSpinnerVo vo = gson.fromJson(response.body(), InStoreSpinnerVo.class);
// 设置 Adapter (逻辑保持不变)
setAdapter(spinnerkind, vo.getKindList());
setAdapter(spinnerpattern, vo.getPatternList());
setAdapter(spinnerlevel, vo.getLevelList());
setAdapter(spinnergcts, vo.getGctsList());
setAdapter(spinnerBrand, vo.getTyreBrandList());
// 特殊处理:型号 (需要处理 Label/Value)
List<String> sizeLabels = new ArrayList<>();
if (vo.getTyreSizeList() != null) {
patternSize = vo.getTyreSizeList();
for (TyreSizeVo size : patternSize) {
sizeLabels.add(size.getLabel());
}
}
setAdapter(spinnerSize, sizeLabels);
hideLoadingDialog();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
private void setAdapter(Spinner spinner, List<String> data) {
if (data != null && !data.isEmpty()) {
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, data);
spinner.setAdapter(adapter);
}
}
// === Spinner 选择监听 (优化版) ===
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch (parent.getId()){
// case R.id.spinner:
// czy.setText(parent.getItemAtPosition(position).toString());
// break;
case R.id.spinnerkind:
tyrekind.setText(parent.getItemAtPosition(position).toString());
break;
case R.id.spinnerpattern:
huawen.setText(parent.getItemAtPosition(position).toString());
break;
case R.id.spinnerlevel:
cengji.setText(parent.getItemAtPosition(position).toString());
// 仅保存选中的值,不再 setText 到任何 TextView (解决重影的根本原因)
String selectedItem = parent.getItemAtPosition(position).toString();
switch (parent.getId()) {
case R.id.spinnerBrand:
selectedBrand = selectedItem;
break;
case R.id.spinnerSize:
xinghao.setText(parent.getItemAtPosition(position).toString());
selectedModel = selectedItem;
// 如果需要根据型号联动花纹深度
if (patternSize != null && position < patternSize.size()) {
patternDepth.setText(patternSize.get(position).getValue());
}
break;
case R.id.spinnerBrand:
pinpai.setText(parent.getItemAtPosition(position).toString());
case R.id.spinnerlevel:
selectedLevel = selectedItem;
break;
case R.id.spinnerpattern:
selectedPattern = selectedItem;
break;
case R.id.spinnerkind:
selectedKind = selectedItem;
break;
case R.id.spinnergcts:
gcts.setText(parent.getItemAtPosition(position).toString());
selectedGcts = selectedItem;
break;
}
}
private Toast mToast;
private Toast toast;
@Override
public void onNothingSelected(AdapterView<?> parent) {
// 可选:设置默认值
}
private class KeyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
int keyCode = intent.getIntExtra("keyCode", 0);
if (keyCode == 0) {
keyCode = intent.getIntExtra("keycode", 0);
}
boolean keyDown = intent.getBooleanExtra("keydown", false);
if (keyDown) {
if (toast == null) {
// toast = Toast.makeText(InStoreHouseActivity.this, "KeyReceiver:keyCode = down" + keyCode, Toast.LENGTH_SHORT);
} else {
// toast.setText("KeyReceiver:keyCode = down" + keyCode);
}
// toast.show();
switch (keyCode) {
case KeyEvent.KEYCODE_F1:
case KeyEvent.KEYCODE_F2:
case KeyEvent.KEYCODE_F3:
case KeyEvent.KEYCODE_F4:
case KeyEvent.KEYCODE_F5:
//扫描
startFlag = true;
break;
}
}
}
}
private void check_spinner() {
OkGo.<String>post(MyUrl.url + "/system/dict/data/tyreTypeList").execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
hideLoadingDialog();
String body = response.body();
Gson gson = new Gson();
InStoreSpinnerVo inStoreSpinnerVo=new InStoreSpinnerVo();
inStoreSpinnerVo = gson.fromJson(body,InStoreSpinnerVo.class);
List<String> stringList=inStoreSpinnerVo.getKindList();
List<String> patternList=inStoreSpinnerVo.getPatternList();
List<String> patternLevel=inStoreSpinnerVo.getLevelList();
List<String> patternSize=inStoreSpinnerVo.getTyreSizeList();
List<String> patternBrand=inStoreSpinnerVo.getTyreBrandList();
List<String> patternGcts=inStoreSpinnerVo.getGctsList();
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(InStoreHouseActivity.this, android.R.layout.simple_list_item_1, stringList);
ArrayAdapter<String> arrayAdapterPattern = new ArrayAdapter<>(InStoreHouseActivity.this, android.R.layout.simple_list_item_1, patternList);
ArrayAdapter<String> arrayAdapterLevel = new ArrayAdapter<>(InStoreHouseActivity.this, android.R.layout.simple_list_item_1, patternLevel);
ArrayAdapter<String> arrayAdapterSize = new ArrayAdapter<>(InStoreHouseActivity.this, android.R.layout.simple_list_item_1, patternSize);
ArrayAdapter<String> arrayAdapterBrand = new ArrayAdapter<>(InStoreHouseActivity.this, android.R.layout.simple_list_item_1, patternBrand);
ArrayAdapter<String> arrayAdapterGcts = new ArrayAdapter<>(InStoreHouseActivity.this, android.R.layout.simple_list_item_1, patternGcts);
spinnerkind.setAdapter(arrayAdapter);
spinnerpattern.setAdapter(arrayAdapterPattern);
spinnerlevel.setAdapter(arrayAdapterLevel);
spinnerSize.setAdapter(arrayAdapterSize);
spinnerBrand.setAdapter(arrayAdapterBrand);
spinnergcts.setAdapter(arrayAdapterGcts);
}
});
spinnerkind.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
tyrekind.setText(parent.getItemAtPosition(position).toString());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinnerpattern.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
huawen.setText(parent.getItemAtPosition(position).toString());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinnerlevel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
cengji.setText(parent.getItemAtPosition(position).toString());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinnerSize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
xinghao.setText(parent.getItemAtPosition(position).toString());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinnerBrand.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
pinpai.setText(parent.getItemAtPosition(position).toString());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinnergcts.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
gcts.setText(parent.getItemAtPosition(position).toString());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
// === 广播接收器 (保持不变) ===
private KeyReceiver keyReceiver;
private void registerReceiver() {
keyReceiver = new KeyReceiver();
@ -547,7 +457,51 @@ public class InStoreHouseActivity extends AppCompatActivity implements AdapterVi
filter.addAction("android.intent.action.FUN_KEY");
registerReceiver(keyReceiver, filter);
}
private void unregisterReceiver() {
unregisterReceiver(keyReceiver);
if (keyReceiver != null) {
unregisterReceiver(keyReceiver);
keyReceiver = null;
}
}
}
private class KeyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
int keyCode = intent.getIntExtra("keyCode", 0);
if (keyCode == 0) keyCode = intent.getIntExtra("keycode", 0);
boolean keyDown = intent.getBooleanExtra("keydown", false);
switch (keyCode) {
case KeyEvent.KEYCODE_F1:
case KeyEvent.KEYCODE_F2:
case KeyEvent.KEYCODE_F3:
case KeyEvent.KEYCODE_F4:
case KeyEvent.KEYCODE_F5:
//扫描
startFlag = true;
break;
}
}
}
private void showLoadingDialog() {
if (progressDialog == null) {
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("数据加载中...");
progressDialog.setCancelable(false); // 禁止用户通过返回键取消
}
if (!progressDialog.isShowing()) {
progressDialog.show();
}
}
/**
*
*/
private void hideLoadingDialog() {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
}

@ -162,30 +162,106 @@ public class TyreLayoutActivity extends AppCompatActivity {
public void onSuccess(Response<String> response) {
hideLoadingDialog();
String body = response.body();
Gson gson=new Gson();
List<BaseCar> baseCarList = gson.fromJson(body, new TypeToken<List<BaseCar>>(){}.getType());
Log.e("EPC", "listepc:+ " + baseCarList.size());
if (baseCarList!=null && baseCarList.size()>0){
List<String> carNoList = new ArrayList<>();
for (BaseCar car : baseCarList) {
carNoList.add(car.getCarNo());
Log.d("CarQuery", "Response: " + body);
Gson gson = new Gson();
try {
// 1. 将响应体解析为 JsonObject (通用 JSON 对象)
// 这样可以绕过 AjaxResult 类对 data 字段的 String 类型限制
com.google.gson.JsonObject jsonObject = gson.fromJson(body, com.google.gson.JsonObject.class);
// 2. 获取 code 字段 (注意:你的日志显示 code 是数字 0但 AjaxResult 定义是 String这里做兼容处理)
String code = "";
if (jsonObject.has("code")) {
// 尝试获取 code无论是 "0" 还是 0 都能处理
code = jsonObject.get("code").getAsString();
}
// 显示自定义弹窗
showCarSelectionDialog(carNoList);
// 3. 判断成功状态 (根据你的日志0 代表成功)
if ("0".equals(code) || "200".equals(code)) {
// 4. 获取 data 元素
if (jsonObject.has("data")) {
com.google.gson.JsonElement dataElement = jsonObject.get("data");
// 5. 将 data 元素转换为 List<BaseCar>
// 使用 TypeToken 指定泛型类型
java.lang.reflect.Type type = new com.google.gson.reflect.TypeToken<List<BaseCar>>() {}.getType();
List<BaseCar> carList = gson.fromJson(dataElement, type);
if (carList != null && !carList.isEmpty()) {
// 6. 展示弹窗列表
showCarSelectionDialog(carList);
} else {
// 7. 无数据处理
new CommonDialog(TyreLayoutActivity.this).setMessage("未查询到相关车辆信息").show();
}
}
} else {
// 业务错误处理
String msg = jsonObject.has("msg") ? jsonObject.get("msg").getAsString() : "未知错误";
new CommonDialog(TyreLayoutActivity.this).setMessage(msg).show();
}
} catch (Exception e) {
e.printStackTrace();
new CommonDialog(TyreLayoutActivity.this).setMessage("数据解析异常").show();
}
}
});
}
private void showCarSelectionDialog(List<String> carNoList) {
CarSelectionDialog dialog = new CarSelectionDialog(this, carNoList);
dialog.setOnCarSelectedListener(new CarSelectionDialog.OnCarSelectedListener() {
@Override
public void onCarSelected(String carNo) {
// 处理选中的车辆
etPlateNumber.setText(carNo);
/**
*
* @param carList
*/
private void showCarSelectionDialog(List<BaseCar> carList) {
if (carList.size() == 1) {
// 如果只有一辆车,直接填充,无需弹窗
BaseCar car = carList.get(0);
fillCarInfoToUI(car);
//Util.play(1, 0); // 提示音
Toast.makeText(this, "自动匹配车辆:" + car.getCarNo(), Toast.LENGTH_SHORT).show();
} else {
// 如果有多辆车,展示弹窗供用户选择
// 提取车牌号列表用于显示
List<String> licensePlates = new ArrayList<>();
for (BaseCar car : carList) {
licensePlates.add(car.getCarNo() != null ? car.getCarNo() : "未知车牌");
}
});
dialog.show();
// 创建并显示弹窗
CarSelectionDialog dialog = new CarSelectionDialog(this, licensePlates);
dialog.setOnCarSelectedListener((selectedItem) -> {
// selectedItem 是 Object转成 String
String selectedPlate = selectedItem.toString().trim();
// 遍历列表找到对应的对象
for (BaseCar car : carList) {
if (selectedPlate.equals(car.getCarNo())) {
fillCarInfoToUI(car);
break;
}
}
});
dialog.show();
}
}
/**
*
* @param car
*/
private void fillCarInfoToUI(BaseCar car) {
// 填充车牌号
etPlateNumber.setText(safeGetString(car.getCarNo()));
// 如果有其他字段,例如:
// startEdit.setText(safeGetString(car.getDefaultMileage())); // 默认里程
// 视觉反馈
etPlateNumber.setTextColor(getColor(R.color.green500));
// Util.play(1, 0);
}
@OnClick({R.id.btn_retrieve})
public void onViewClicked(View view) {

File diff suppressed because it is too large Load Diff

@ -4,7 +4,7 @@ import java.util.List;
public class InStoreSpinnerVo {
private List<String> tyreBrandList;
private List<String> tyreSizeList;
private List<TyreSizeVo> tyreSizeList;
private List<String> levelList;
private List<String> patternList;
private List<String> kindList;
@ -26,11 +26,11 @@ public class InStoreSpinnerVo {
this.tyreBrandList = tyreBrandList;
}
public List<String> getTyreSizeList() {
public List<TyreSizeVo> getTyreSizeList() {
return tyreSizeList;
}
public void setTyreSizeList(List<String> tyreSizeList) {
public void setTyreSizeList(List<TyreSizeVo> tyreSizeList) {
this.tyreSizeList = tyreSizeList;
}

@ -0,0 +1,22 @@
package com.example.tyre.entity;
public class TyreSizeVo {
private String label;
private String value;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

@ -7,6 +7,6 @@ package com.example.tyre.util;
*/
public class MyUrl {
// public static String url="http://192.168.31.26:8020";
public static String url="http://www.qdhys.xyz:8020";
// public static String url="http://10.11.187.77:8020";
// public static String url="http://www.qdhys.xyz:8020";
public static String url="http://10.11.187.77:8020";
}

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<stroke android:width="1dp" android:color="#BBDEFB" />
<corners android:radius="8dp" />
</shape>

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#1565C0" /> <!-- 按下时的颜色 -->
<corners android:radius="12dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#1976D2" /> <!-- 正常颜色 -->
<corners android:radius="12dp" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#E0E0E0" />
<corners android:radius="12dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#FAFAFA" />
<corners android:radius="12dp" />
</shape>
</item>
</selector>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="1dp" android:color="#DDDDDD"/>
<corners android:radius="8dp"/>
</shape>

@ -1,313 +1,323 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/xuebai">
<TextView
android:id="@+id/textView2"
style="@style/tablebarStyleTwo"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="轮胎入库"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="EPC:" />
android:background="#F5F7FA"
android:padding="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- 标题栏 -->
<TextView
android:id="@+id/epc"
style="@style/infotext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_santex_coppy"
android:textSize="15sp"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout8"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="胎号:" />
android:layout_height="56dp"
android:background="#FFFFFF"
android:gravity="center"
android:elevation="4dp"
android:text="轮胎入库管理"
android:textColor="#333333"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginBottom="16dp"
android:padding="8dp"/>
<EditText
android:id="@+id/wtbm"
style="@style/infotext"
<!-- 表单卡片 -->
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_santex_coppy"
/>
</LinearLayout>
android:layout_height="wrap_content"
app:cardCornerRadius="12dp"
app:cardElevation="8dp"
android:layout_marginBottom="16dp">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="品牌:" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/pinpai"
style="@style/infotext"
android:layout_width="200dp"
android:layout_height="match_parent"
android:background="@drawable/bg_santex_coppy"
/>
<Spinner
android:id="@+id/spinnerBrand"
android:layout_width="30dp"
android:layout_height="match_parent"></Spinner>
</LinearLayout>
<!-- 第一行EPC + 胎号 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="12dp">
<!-- EPC -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginEnd="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EPC"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<!-- 修复:移除了原来的 TextView直接使用 Spinner -->
<TextView
android:id="@+id/EPC"
style="@style/infotext"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:textSize="16sp"
android:hint="请扫描RFID"/>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="型号:" />
</LinearLayout>
<TextView
android:id="@+id/xinghao"
style="@style/infotext"
android:layout_width="200dp"
android:layout_height="match_parent"
android:background="@drawable/bg_santex_coppy"
/>
<Spinner
android:id="@+id/spinnerSize"
android:layout_width="30dp"
android:layout_height="match_parent"></Spinner>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="层级:" />
<!-- 胎号 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="胎号"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<EditText
android:id="@+id/wtbm"
style="@style/infotext"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:textSize="16sp"
android:hint="请输入胎号"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/cengji"
style="@style/infotext"
android:layout_width="200dp"
android:layout_height="match_parent"
android:background="@drawable/bg_santex_coppy"
/>
<Spinner
android:id="@+id/spinnerlevel"
android:layout_width="30dp"
android:layout_height="match_parent"></Spinner>
<!-- 第二行:品牌 + 型号 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="12dp">
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="花纹:" />
<TextView
android:id="@+id/huawen"
style="@style/infotext"
android:layout_width="200dp"
android:layout_height="match_parent"
android:background="@drawable/bg_santex_coppy"
/>
<Spinner
android:id="@+id/spinnerpattern"
android:layout_width="30dp"
android:layout_height="match_parent"></Spinner>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout10"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="沟槽条数:" />
<TextView
android:id="@+id/gcts"
style="@style/infotext"
android:layout_width="200dp"
android:layout_height="match_parent"
android:background="@drawable/bg_santex_coppy"
/>
<Spinner
android:id="@+id/spinnergcts"
android:layout_width="30dp"
android:layout_height="match_parent"></Spinner>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="轮胎类别:" />
<!-- 品牌 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginEnd="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="品牌"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<!-- 修复:直接使用 Spinner不再叠加 TextView -->
<Spinner
android:id="@+id/spinnerBrand"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:spinnerMode="dropdown"/>
</LinearLayout>
<TextView
android:id="@+id/tyrekind"
style="@style/infotext"
android:layout_width="200dp"
android:layout_height="match_parent"
android:background="@drawable/bg_santex_coppy"
/>
<Spinner
android:id="@+id/spinnerkind"
android:layout_width="30dp"
android:layout_height="match_parent"></Spinner>
</LinearLayout>
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="40dp"-->
<!--android:layout_marginStart="8dp"-->
<!--android:layout_marginTop="10dp"-->
<!--android:layout_marginEnd="8dp"-->
<!--android:orientation="horizontal"-->
<!--app:layout_constraintEnd_toEndOf="parent"-->
<!--app:layout_constraintStart_toStartOf="parent"-->
<!--app:layout_constraintTop_toBottomOf="@+id/linearLayout3">-->
<!--<TextView-->
<!--style="@style/alltext"-->
<!--android:layout_width="90dp"-->
<!--android:layout_height="match_parent"-->
<!--android:background="@color/blue2"-->
<!--android:text="操作员:" />-->
<!-- 型号 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="型号"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<Spinner
android:id="@+id/spinnerSize"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:spinnerMode="dropdown"/>
</LinearLayout>
</LinearLayout>
<!--<TextView-->
<!--android:id="@+id/czy"-->
<!--style="@style/infotext"-->
<!--android:layout_width="100dp"-->
<!--android:layout_height="match_parent"-->
<!--android:background="@drawable/bg_santex_coppy"-->
<!--/>-->
<!--<Spinner-->
<!--android:entries="@array/user"-->
<!--android:id="@+id/spinner"-->
<!--android:layout_width="30dp"-->
<!--android:layout_height="match_parent"></Spinner>-->
<!--</LinearLayout>-->
<!-- 第三行:层级 + 花纹 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="12dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_marginTop="10dp"
>
<Button
android:id="@+id/button"
<!-- 层级 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginEnd="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="层级"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<Spinner
android:id="@+id/spinnerlevel"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:spinnerMode="dropdown"/>
</LinearLayout>
<!-- 花纹 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="花纹"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<Spinner
android:id="@+id/spinnerpattern"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:spinnerMode="dropdown"/>
</LinearLayout>
</LinearLayout>
<!-- 第四行:沟槽条数 + 轮胎类别 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="12dp">
<!-- 沟槽条数 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginEnd="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="沟槽条数"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<Spinner
android:id="@+id/spinnergcts"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:spinnerMode="dropdown"/>
</LinearLayout>
<!-- 轮胎类别 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="轮胎类别"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<Spinner
android:id="@+id/spinnerkind"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:spinnerMode="dropdown"/>
</LinearLayout>
</LinearLayout>
<!-- 花纹深度(独立一行) -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="12dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="花纹深度"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<EditText
android:id="@+id/patternDepth"
style="@style/infotext"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:textSize="16sp"
android:hint="请输入花纹深度" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<!-- 操作按钮 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginStart="18dp"
android:layout_marginEnd="18dp"
style="@style/buttonStyle"
android:text="轮 胎 入 库"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_weight="1"
/>
<Button
android:id="@+id/back"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginStart="18dp"
android:layout_marginEnd="18dp"
style="@style/buttonStyle"
android:text="返 回"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_weight="1"
/>
</LinearLayout>
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="24dp">
</LinearLayout>
<Button
android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="1"
android:layout_marginEnd="8dp"
android:backgroundTint="#007AFF"
android:text="轮 胎 入 库"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:elevation="4dp"
style="@style/Widget.MaterialComponents.Button"/>
<Button
android:id="@+id/back"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:backgroundTint="#FF3B30"
android:text="返 回"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:elevation="4dp"
style="@style/Widget.MaterialComponents.Button"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

@ -1,274 +1,297 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.tyre.UpActivity">
<TextView
android:id="@+id/textView2"
style="@style/tablebarStyleTwo"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="轮胎装车"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="EPC:" />
<TextView
android:id="@+id/epc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:textSize="15sp"
android:textColor="@color/black"
android:background="@drawable/bg_santex_coppy"
android:gravity="center" />
</LinearLayout>
android:background="#F5F7FA"
android:padding="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="胎号:" />
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- 页面标题 -->
<TextView
android:id="@+id/th"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:textSize="15sp"
android:textColor="@color/black"
android:background="@drawable/bg_santex_coppy"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="自编号:" />
<EditText
android:id="@+id/zbh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:textSize="15sp"
android:textColor="@color/black"
android:background="@drawable/bg_santex_coppy"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="车牌号:" />
<EditText
android:id="@+id/car"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:background="@drawable/bg_santex_coppy"
android:layout_height="56dp"
android:background="#FFFFFF"
android:elevation="4dp"
android:gravity="center"
android:textColor="@color/black"
android:textSize="22sp" />
<Button
android:id="@+id/searchButton"
android:layout_width="50dp"
android:layout_height="match_parent"
android:background="@mipmap/search_icon"
android:contentDescription="搜索" />
android:layout_marginBottom="16dp"
android:padding="8dp"
android:text="轮胎装车管理"
android:textColor="#1976D2"
android:textSize="20sp"
android:textStyle="bold" />
<!-- <Spinner-->
<!-- android:id="@+id/carAdapter"-->
<!-- android:layout_width="50dp"-->
<!-- android:layout_height="match_parent"></Spinner>-->
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="起始里程:" />
<EditText
android:id="@+id/start"
<!-- 主表单卡片 -->
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:textSize="22sp"
android:textColor="@color/black"
android:background="@drawable/bg_santex_coppy"
android:gravity="center" />
</LinearLayout>
android:layout_height="wrap_content"
app:cardCornerRadius="12dp"
app:cardElevation="8dp"
android:layout_marginBottom="16dp">
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<TextView
style="@style/alltext"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="@color/blue2"
android:text="安装轮位:" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/azlw"
<!-- 第一行EPC芯片 (独立一行) -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="12dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EPC芯片"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<!-- 使用TextView显示EPC背景使用圆角 -->
<TextView
android:id="@+id/epc"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="4dp"
android:background="@drawable/rounded_input_bg"
android:gravity="center_vertical"
android:paddingStart="12dp"
android:text="请扫描EPC"
android:textColor="#555"
android:textSize="16sp" />
</LinearLayout>
<!-- 第二行:胎号 + 自编号 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="12dp">
<!-- 胎号 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginEnd="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="胎号"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<EditText
android:id="@+id/th"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="4dp"
android:background="@drawable/rounded_input_bg"
android:gravity="center_vertical"
android:paddingStart="12dp"
android:text="未读取"
android:textColor="#555"
android:textSize="16sp" />
</LinearLayout>
<!-- 自编号 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="自编号"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<EditText
android:id="@+id/zbh"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="4dp"
android:background="@drawable/rounded_input_bg"
android:gravity="center_vertical"
android:paddingStart="12dp"
android:textColor="#555"
android:textSize="16sp"
android:hint="请输入自编号" />
</LinearLayout>
</LinearLayout>
<!-- 第三行:车牌号 (带搜索图标) -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="12dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginEnd="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="车牌号"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<EditText
android:id="@+id/car"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="4dp"
android:background="@drawable/rounded_input_bg"
android:gravity="center_vertical"
android:paddingStart="12dp"
android:textColor="#555"
android:textSize="16sp"
android:hint="请输入或扫描" />
</LinearLayout>
<!-- 搜索按钮 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="操作"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<Button
android:id="@+id/searchButton"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="4dp"
android:backgroundTint="#007AFF"
android:text="🔍 搜索"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
<!-- 第四行:起始里程 + 安装轮位 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="12dp">
<!-- 起始里程 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginEnd="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="起始里程"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<EditText
android:id="@+id/start"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="4dp"
android:background="@drawable/rounded_input_bg"
android:gravity="center_vertical"
android:paddingStart="12dp"
android:textColor="#555"
android:textSize="16sp"
android:hint="0"
android:inputType="number" />
</LinearLayout>
<!-- 安装轮位 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="安装轮位"
android:textColor="#666666"
android:textSize="12sp"
android:layout_marginStart="4dp"/>
<Spinner
android:id="@+id/condition"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="4dp"
android:background="@drawable/rounded_input_bg"
android:paddingStart="12dp"
android:spinnerMode="dropdown" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<!-- 底部操作按钮 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:textSize="22sp"
android:textColor="@color/black"
android:background="@drawable/bg_santex_coppy"
android:gravity="center" />
<Spinner
android:id="@+id/condition"
android:layout_width="30dp"
android:layout_height="match_parent"></Spinner>
</LinearLayout>
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="40dp"-->
<!--android:layout_marginStart="8dp"-->
<!--android:layout_marginTop="20dp"-->
<!--android:layout_marginEnd="8dp"-->
<!--android:orientation="horizontal"-->
<!--app:layout_constraintEnd_toEndOf="parent"-->
<!--app:layout_constraintStart_toStartOf="parent"-->
<!--app:layout_constraintTop_toBottomOf="@+id/linearLayout3">-->
<!--<TextView-->
<!--style="@style/alltext"-->
<!--android:layout_width="80dp"-->
<!--android:layout_height="match_parent"-->
<!--android:background="@color/blue2"-->
<!--android:text="操作人:" />-->
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="24dp">
<!--<TextView-->
<!--android:id="@+id/czr"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_marginStart="8dp"-->
<!--android:layout_weight="1"-->
<!--android:textSize="22sp"-->
<!--android:textColor="@color/black"-->
<!--android:background="@drawable/bg_santex_coppy"-->
<!--android:gravity="center" />-->
<!--<Spinner-->
<!--android:id="@+id/spinner2"-->
<!--android:entries="@array/user"-->
<!--android:layout_width="30dp"-->
<!--android:layout_height="match_parent"></Spinner>-->
<!--</LinearLayout>-->
<Button
android:id="@+id/confirmButton"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="1"
android:layout_marginEnd="8dp"
android:backgroundTint="#4CAF50"
android:text="确 认 装 车"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:elevation="4dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="50dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:orientation="horizontal">
<Button
android:id="@+id/ok"
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="完成"
style="@style/buttonStyle"
android:textColor="@color/black"/>
<View
android:layout_width="50dp"
android:layout_height="match_parent"
/>
<Button
android:id="@+id/back"
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="返回"
style="@style/buttonStyle"
android:textColor="@color/black"/>
<Button
android:id="@+id/back"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:backgroundTint="#9E9E9E"
android:text="取 消"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:elevation="4dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

@ -9,6 +9,7 @@
<color name="black">#232323</color>
<color name="blue2">#F0F5FD</color>
<color name="green">#E6E8F6FC</color>
<color name="green500">#E610FA4A</color>
<color name="title">#3b4753</color>
<!-- <color name="xuebai">#f0fcff</color>

Loading…
Cancel
Save