修改 添加bug

master
wanghao 2 months ago
parent 4274ff4825
commit 2d3020ccfb

@ -10,8 +10,8 @@ android {
applicationId "com.example.as_trak"
minSdk 26
targetSdk 33
versionCode 1
versionName "1.0"
versionCode 3
versionName "1.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<litepal>
<dbname value="AS_TRAK" />
<version value="8" />
<version value="10" />
<list>
<mapping class="com.example.as_trak.entity.LoadOperation"/>
<mapping class="com.example.as_trak.entity.CargoInfo"/>

@ -9,7 +9,6 @@ import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListPopupWindow;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.annotation.Nullable;
@ -69,7 +68,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
binding.setQty1(cargoQty);
binding.setQty2(loadQty);
initAlertDialog();
initScan();
}
private void initAlertDialog() {
@ -102,6 +101,13 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
protected void onResume() {
super.onResume();
initInputCargo();
initScan();
}
@Override
protected void onStop() {
super.onStop();
unregisterReceiver(myReceiver);
}
// 初始化添加货箱
@ -145,19 +151,25 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
public void loadAddCargo1(View view) {
if (flightInfoTag == null) return;
String code0 = binding.loadMainCargoSanCode.getText().toString();
addCargo(code0,binding.loadMainSanTypeSpinner.getSelectedItem().toString() );
if (code0.isEmpty()) return;
addCargo(code0, binding.loadMainSanTypeSpinner.getSelectedItem().toString());
}
public void loadAddCargo(View view) {
if (flightInfoTag == null) return;
String cargoCode = binding.loadMainCargoCode.getText().toString();
if (cargoCode.isEmpty()) return;
if (cargoCode.length() != 7) {
Toast.makeText(this, "填写格式不规范", Toast.LENGTH_SHORT).show();
return;
}
String cargoCode0 = binding.loadMainCargoCode0.getSelectedItem().toString();
cargoCode = cargoCode0 + cargoCode;
addCargo(cargoCode, binding.loadMainCargoCode2.getSelectedItem().toString());
}
@SuppressLint("NotifyDataSetChanged")
private void addCargo(String cargoCode,String type){
private void addCargo(String cargoCode, String type) {
int id = flightInfoTag.getId();
int countTag = LitePal.where("cargoCode= ? and flightId=?", cargoCode, String.valueOf(id)).count(CargoInfo.class);
if (countTag > 0) {
@ -174,7 +186,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
cargoInfoList.add(cargoInfo);
int size = cargoInfoList.size();
cargoQty.set(size);
cargoInfoAdapter.notifyItemInserted(size-1);
cargoInfoAdapter.notifyItemInserted(size - 1);
binding.loadMainCargoCode.setText(null);
binding.loadMainCargoSanCode.setText(null);
Toast.makeText(this, "绑定成功", Toast.LENGTH_SHORT).show();
@ -213,6 +225,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
flightList.add(flightInfo);
adapter.notifyDataSetChanged();
}
// 删除装载单元
@SuppressLint("NotifyDataSetChanged")
@Override
@ -261,6 +274,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
Toast.makeText(this, "查询成功", Toast.LENGTH_SHORT).show();
lpw.dismiss();
}
// 返回时调
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
@ -268,11 +282,11 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
Log.e("TAG", "onActivityResult:重加载");
selectCargo();
}
// 查询装载单元 内 数量
@SuppressLint("NotifyDataSetChanged")
private void selectCargo() {
cargoInfoList = LitePal.where("flightId = ? ",
String.valueOf(flightInfoTag.getId())).find(CargoInfo.class);
cargoInfoList = LitePal.where("flightId = ? ", String.valueOf(flightInfoTag.getId())).find(CargoInfo.class);
AtomicInteger tag = new AtomicInteger();
if (!cargoInfoList.isEmpty()) {
cargoInfoList.forEach(cargoInfo -> {
@ -287,6 +301,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
cargoInfoAdapter.notifyDataSetChanged();
}
// 跳转装载页面
public void clickCargoInfo(View view) {
if (flightInfoTag == null) {
Toast.makeText(this, "没有选择航班", Toast.LENGTH_SHORT).show();
@ -296,19 +311,31 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
Toast.makeText(this, "没有添加装载单元", Toast.LENGTH_SHORT).show();
return;
}
ContainerType containerType = LitePal.where("typeName = ? and type =3 ",
flightInfoTag.getFlightCode().substring(0, 2)).findFirst(ContainerType.class);
boolean b = containerType != null;
intent.putExtra("checkState",b);
if (b){
intent.putExtra("checkCode",containerType.getCheckCode());
}
intent.putExtra("id", flightInfoTag.getId());
startActivityForResult(intent, 0);
}
// 扫描装载单元
@Override
public void sanCodeResult(String code) {
super.sanCodeResult(code);
if (code.length()<8) {
Toast.makeText(this, "扫描数据:"+code+" 异常", Toast.LENGTH_SHORT).show();
if (code.length() < 8) {
Toast.makeText(this, "扫描数据:" + code + " 异常", Toast.LENGTH_SHORT).show();
return;
}
String substring = code.substring(0, 8);
binding.loadMainCargoSanCode.setText(substring);
binding.loadMainCargoSanCode.setText(code);
}
}

@ -2,6 +2,7 @@ package com.example.as_trak;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@ -48,13 +49,18 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
private TipDialog tipDialog;
private AlertDialog.Builder alertDialog;
private Handler handler = new Handler(Looper.getMainLooper());
private String checkCode;
private boolean checkState;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_load_scan);
initScan();
int id = getIntent().getIntExtra("id", 0);
Intent intent = getIntent();
int id = intent.getIntExtra("id", 0);
checkCode = intent.getStringExtra("checkCode");
checkState = intent.getBooleanExtra("checkState", false);
// 航班显示
flightInfo = LitePal.where("id= ?", String.valueOf(id)).findFirst(FlightInfo.class);
binding.setData(flightInfo);
@ -63,7 +69,7 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
adapter = new CargoListAdapter(this, this);
adapter.setList(cargoInfoList);
binding.setAdapter1(adapter);
formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// loadToast = new LoadToast(this);
loadInfoAdapter = new LoadInfoAdapter(this, this);
loadInfoAdapter.setRecyclerView(binding.loadInfoRecyclerview);
@ -86,6 +92,7 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
updataDialog.dismiss();
});
tipDialog = new TipDialog(this);
tipDialog.setTipCall(this::loadLastFun);
alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("装载完成提示").setMessage("确认装载完成").setNegativeButton("取消", null).setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
@ -119,7 +126,7 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
super.sanCodeResult(code);
binding.loadSanInfoCode.setText(code);
// 先验证扫描情况
String regex = "^[A-Za-z]{3}\\d{5}";
String regex = "^[A-Za-z]{3}\\d{5}\\w{2}";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(code);
@ -128,14 +135,14 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
// Log.e("TAG", "sanCodeResult:" + matcher.group());
for (int i = 0; i < cargoInfoList.size(); i++) {
if (cargoInfoList.get(i).getCargoCode().equals(group)){
if (cargoInfoList.get(i).getCargoCode().equals(group)) {
RecyclerView.LayoutManager layoutManager = binding.scanR1.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
View itemView = layoutManager.findViewByPosition(i);
if (itemView != null) {
itemView.performClick(); //
Log.e("TAG", "触发点击事件:"+i );
Log.e("TAG", "触发点击事件:" + i);
}
}
return;
@ -158,16 +165,30 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
Toast.makeText(this, "没有选择装载单元", Toast.LENGTH_SHORT).show();
return;
}
if (checkState) {
String pattern = "^" + checkCode + "\\d+";
boolean isMatch = Pattern.matches(pattern, code);
if (!isMatch) {
tipDialog.showError("校验失败:" + code + ",不允许装机", code, true);
return;
}
}
loadLastFun(code);
// if (cargoInfoTag.getState().equals("装载完成")) {
// Toast.makeText(this, "装载单元已经装载完成", Toast.LENGTH_SHORT).show();
// return;
// }
}
private void loadLastFun(String code) {
int count = LitePal.where("flightId= ? and luggageCode=? and type ='装载' and (state IS NULL or state = '修改') ", String.valueOf(flightInfo.getId()), code).count(LoadOperation.class);
if (count > 0) {
tipDialog.showError("行李条码:" + code + "重复");
tipDialog.showError("行李条码:" + code + "重复", code, false);
return;
}
tipDialog.showSuccess(code + "\t装载成功");
tipDialog.showSuccess(code + "\n装载成功");
// 添加行李
LoadOperation loadOperation = new LoadOperation();
loadOperation.setFlightCode(flightInfo.getFlightCode());
@ -241,4 +262,11 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
alertDialog.show();
return true;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (myReceiver != null) unregisterReceiver(myReceiver);
}
}

@ -38,8 +38,15 @@ public class SettingActivity extends BaseActivity implements EditDialog.EditDial
@SuppressLint("NotifyDataSetChanged")
@Override
public void onTabSelected(TabLayout.Tab tab) {
String string = tab.getText().toString();
type = string.equals("种类维护") ? "1" : "2";
if (string.equals("种类维护")) {
type = "1";
}else if (string.equals("类型代码")){
type = "2";
}else {
type = "3";
}
adapterSetList(type);
}
@ -70,9 +77,10 @@ public class SettingActivity extends BaseActivity implements EditDialog.EditDial
@SuppressLint("NotifyDataSetChanged")
@Override
public void saveInfo(String info) {
public void saveInfo(String info,String checkCode) {
ContainerType containerType = new ContainerType();
containerType.setTypeName(info);
containerType.setCheckCode(checkCode);
containerType.setType(type);
containerType.save();
list.add(containerType);
@ -89,6 +97,7 @@ public class SettingActivity extends BaseActivity implements EditDialog.EditDial
adapter.notifyDataSetChanged();
}
public void settingAdd(View view){
editDialog.setType(type);
editDialog.show();
}
}

@ -34,6 +34,11 @@ public class UnLoadActivity extends BaseActivity {
Log.e("TAG", "传值:" + code);
luggageFragment.sanCode(code);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (myReceiver!=null) unregisterReceiver(myReceiver);
}
}

@ -12,7 +12,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class BaseActivity extends AppCompatActivity {
private MyScanCodeBroad myReceiver;
public MyScanCodeBroad myReceiver;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@ -29,11 +29,6 @@ public class BaseActivity extends AppCompatActivity {
registerReceiver(myReceiver, intentFilter);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (myReceiver!=null) unregisterReceiver(myReceiver);
}
private class MyScanCodeBroad extends BroadcastReceiver {
@Override

@ -20,20 +20,27 @@ public class EditDialog extends Dialog {
this.call = call;
}
private String type;
public void setType(String type) {
this.type = type;
}
public EditDialog(@NonNull Context context) {
super(context, R.style.dialog_style);
binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.dialog_edit, null, false);
setContentView(binding.getRoot());
binding.editFalse.setOnClickListener(v -> dismiss());
binding.editTrue.setOnClickListener(v -> call.saveInfo(binding.editInfo.getText().toString()));
binding.editTrue.setOnClickListener(v -> call.saveInfo(binding.editInfo.getText().toString(),binding.editInfo2.getText().toString()));
}
public interface EditDialogCall{
void saveInfo(String info);
void saveInfo(String info,String checkCode);
}
@Override
public void show() {
super.show();
binding.setType(type);
binding.editInfo.setText(null);
}
}

@ -24,6 +24,7 @@ public class TipDialog extends Dialog {
private MediaPlayer musicSuccess;
private Vibrator vibrator;
private ObservableBoolean state;
private ObservableBoolean buttonVisState;
private DialogTipBinding binding;
public TipDialog(@NonNull Context context) {
@ -37,23 +38,38 @@ public class TipDialog extends Dialog {
state = new ObservableBoolean();
setCanceledOnTouchOutside(false);
binding.setState(state);
buttonVisState=new ObservableBoolean();
binding.setButtonVisState(buttonVisState);
binding.tipDialogOver.setOnClickListener(v -> dismiss());
binding.tipDialogAllwey.setOnClickListener(v -> tipCall.noAutoSub(code));
}
public void showError(String msg) {
private String code;
public void showError(String msg,String code,boolean buttonState) {
super.show();
music.start();
vibrator.vibrate(500); // 震动1/2秒
state.set(false);
buttonVisState.set(buttonState);
binding.toastMsg.setText(msg);
this.code=code;
}
public void showSuccess(String msg) {
super.show();
musicSuccess.start();
state.set(true);
buttonVisState.set(false);
binding.toastMsg.setText(msg);
}
public interface TipCall{
void noAutoSub(String code);
}
private TipCall tipCall;
public void setTipCall(TipCall tipCall) {
this.tipCall = tipCall;
}
}

@ -6,8 +6,16 @@ public class ContainerType extends LitePalSupport {
private int id;
private int tag;
private String typeName;
private String checkCode;
private String type;
public String getCheckCode() {
return checkCode;
}
public void setCheckCode(String checkCode) {
this.checkCode = checkCode;
}
public String getType() {
return type;

@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="title"
type="String" />
@ -27,10 +28,10 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="20dp"
android:background="@drawable/tablayout_bg"
app:tabBackground="@drawable/tab_background_selector"
app:tabGravity="fill"
app:tabTextColor="@color/blue"
app:tabSelectedTextColor="@color/white"
app:tabBackground="@drawable/tab_background_selector">
app:tabTextColor="@color/blue">
<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
@ -46,6 +47,7 @@
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager2.widget.ViewPager2

@ -174,7 +174,7 @@
style="@style/text_title"/>
<TextView
<EditText
android:id="@+id/load_main_cargo_san_code"
android:layout_width="0dp"
android:layout_height="45dp"
@ -386,11 +386,12 @@
<Button
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="12dp"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_margin="8dp"
android:letterSpacing="0.5"
android:onClick="clickCargoInfo"
android:layout_gravity="center"
android:text="装载行李"
android:textSize="18sp"
android:textStyle="bold" />

@ -4,9 +4,11 @@
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="title"
type="String" />
<variable
name="adapter"
type="com.example.as_trak.adapter.ContainerTypesAdapter" />
@ -47,6 +49,11 @@
android:layout_height="match_parent"
android:text="类型代码" />
<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="校验维护" />
</com.google.android.material.tabs.TabLayout>
@ -54,21 +61,21 @@
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_weight="1"
android:adapter="@{adapter}"
android:background="@color/white" />
android:background="@color/white"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<ImageView
android:layout_width="62dp"
android:layout_height="62dp"
android:src="@mipmap/info_add"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="16dp"
android:onClick="settingAdd"
android:layout_gravity="center" />
android:src="@mipmap/info_add" />
</LinearLayout>
</layout>

@ -3,6 +3,11 @@
<data>
<variable
name="type"
type="String" />
<import type="android.view.View"/>
</data>
<LinearLayout
@ -17,19 +22,55 @@
android:layout_gravity="center"
android:drawableStart="@mipmap/icon_tip"
android:gravity="center"
android:textSize="22dp"
android:text="填写信息" />
android:text="填写信息"
android:textSize="22dp" />
<EditText
android:id="@+id/edit_info"
<LinearLayout
android:layout_width="350dp"
android:layout_height="55dp"
android:layout_margin="10dp"
android:gravity="center"
android:layout_gravity="center"
android:lines="1"
android:inputType="textCapWords"
android:maxLines="1" />
android:layout_margin="10dp">
<TextView
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="航司代码:"
android:visibility='@{type.equals("3")?View.VISIBLE:View.GONE}'
style="@style/text_title"/>
<EditText
android:id="@+id/edit_info"
android:layout_width="match_parent"
android:layout_height="55dp"
android:gravity="center"
android:inputType="textCapWords"
android:lines="1"
android:maxLines="1" />
</LinearLayout>
<LinearLayout
android:layout_width="350dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:visibility='@{type.equals("3")?View.VISIBLE:View.GONE}'
android:layout_margin="5dp">
<TextView
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="前缀代码:"
style="@style/text_title"/>
<EditText
android:id="@+id/edit_info2"
android:layout_width="match_parent"
android:layout_height="55dp"
android:gravity="center"
android:inputType="textCapWords"
android:lines="1"
android:maxLines="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"

@ -6,6 +6,9 @@
<variable
name="state"
type="androidx.databinding.ObservableBoolean" />
<variable
name="buttonVisState"
type="androidx.databinding.ObservableBoolean" />
<import type="android.view.View" />
</data>
@ -36,12 +39,26 @@
<TextView
android:id="@+id/toast_msg"
android:layout_width="400dp"
android:layout_width="420dp"
android:layout_height="215dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="28sp" />
<Button
android:id="@+id/tip_dialog_allwey"
android:layout_width="250dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:backgroundTint="@color/green"
android:text="转机人工通过校验"
android:visibility="@{buttonVisState?View.VISIBLE:View.GONE}"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold" />
<Button
android:id="@+id/tip_dialog_over"
android:layout_width="250dp"
@ -49,10 +66,12 @@
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:backgroundTint="@color/white"
android:letterSpacing="0.5"
android:text="关闭"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="20sp"
android:letterSpacing="0.5"/>
android:textStyle="bold" />
</LinearLayout>
</layout>

@ -2,9 +2,11 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="data"
type="com.example.as_trak.entity.ContainerType" />
<import type="android.view.View"/>
</data>
<LinearLayout
@ -31,8 +33,6 @@
android:background="#e1e1e1" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -41,6 +41,16 @@
android:text="@{data.typeName}"
android:textSize="15sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@{data.checkCode}"
android:visibility='@{data.type.equals("3")?View.VISIBLE:View.GONE}'
android:textSize="15sp" />
<TextView
android:id="@+id/item_cargo_d"
android:layout_width="50dp"

Loading…
Cancel
Save