@ -9,7 +9,6 @@ import android.util.Log;
import android.view.View ;
import android.view.View ;
import android.widget.AdapterView ;
import android.widget.AdapterView ;
import android.widget.ListPopupWindow ;
import android.widget.ListPopupWindow ;
import android.widget.Spinner ;
import android.widget.Toast ;
import android.widget.Toast ;
import androidx.annotation.Nullable ;
import androidx.annotation.Nullable ;
@ -69,7 +68,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
binding . setQty1 ( cargoQty ) ;
binding . setQty1 ( cargoQty ) ;
binding . setQty2 ( loadQty ) ;
binding . setQty2 ( loadQty ) ;
initAlertDialog ( ) ;
initAlertDialog ( ) ;
initScan ( ) ;
}
}
private void initAlertDialog ( ) {
private void initAlertDialog ( ) {
@ -102,6 +101,13 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
protected void onResume ( ) {
protected void onResume ( ) {
super . onResume ( ) ;
super . onResume ( ) ;
initInputCargo ( ) ;
initInputCargo ( ) ;
initScan ( ) ;
}
@Override
protected void onStop ( ) {
super . onStop ( ) ;
unregisterReceiver ( myReceiver ) ;
}
}
// 初始化添加货箱
// 初始化添加货箱
@ -145,12 +151,18 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
public void loadAddCargo1 ( View view ) {
public void loadAddCargo1 ( View view ) {
if ( flightInfoTag = = null ) return ;
if ( flightInfoTag = = null ) return ;
String code0 = binding . loadMainCargoSanCode . getText ( ) . toString ( ) ;
String code0 = binding . loadMainCargoSanCode . getText ( ) . toString ( ) ;
if ( code0 . isEmpty ( ) ) return ;
addCargo ( code0 , binding . loadMainSanTypeSpinner . getSelectedItem ( ) . toString ( ) ) ;
addCargo ( code0 , binding . loadMainSanTypeSpinner . getSelectedItem ( ) . toString ( ) ) ;
}
}
public void loadAddCargo ( View view ) {
public void loadAddCargo ( View view ) {
if ( flightInfoTag = = null ) return ;
if ( flightInfoTag = = null ) return ;
String cargoCode = binding . loadMainCargoCode . getText ( ) . toString ( ) ;
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 ( ) ;
String cargoCode0 = binding . loadMainCargoCode0 . getSelectedItem ( ) . toString ( ) ;
cargoCode = cargoCode0 + cargoCode ;
cargoCode = cargoCode0 + cargoCode ;
addCargo ( cargoCode , binding . loadMainCargoCode2 . getSelectedItem ( ) . toString ( ) ) ;
addCargo ( cargoCode , binding . loadMainCargoCode2 . getSelectedItem ( ) . toString ( ) ) ;
@ -213,6 +225,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
flightList . add ( flightInfo ) ;
flightList . add ( flightInfo ) ;
adapter . notifyDataSetChanged ( ) ;
adapter . notifyDataSetChanged ( ) ;
}
}
// 删除装载单元
// 删除装载单元
@SuppressLint ( "NotifyDataSetChanged" )
@SuppressLint ( "NotifyDataSetChanged" )
@Override
@Override
@ -261,6 +274,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
Toast . makeText ( this , "查询成功" , Toast . LENGTH_SHORT ) . show ( ) ;
Toast . makeText ( this , "查询成功" , Toast . LENGTH_SHORT ) . show ( ) ;
lpw . dismiss ( ) ;
lpw . dismiss ( ) ;
}
}
// 返回时调
// 返回时调
@Override
@Override
protected void onActivityResult ( int requestCode , int resultCode , @Nullable Intent data ) {
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:重加载" ) ;
Log . e ( "TAG" , "onActivityResult:重加载" ) ;
selectCargo ( ) ;
selectCargo ( ) ;
}
}
// 查询装载单元 内 数量
// 查询装载单元 内 数量
@SuppressLint ( "NotifyDataSetChanged" )
@SuppressLint ( "NotifyDataSetChanged" )
private void selectCargo ( ) {
private void selectCargo ( ) {
cargoInfoList = LitePal . where ( "flightId = ? " ,
cargoInfoList = LitePal . where ( "flightId = ? " , String . valueOf ( flightInfoTag . getId ( ) ) ) . find ( CargoInfo . class ) ;
String . valueOf ( flightInfoTag . getId ( ) ) ) . find ( CargoInfo . class ) ;
AtomicInteger tag = new AtomicInteger ( ) ;
AtomicInteger tag = new AtomicInteger ( ) ;
if ( ! cargoInfoList . isEmpty ( ) ) {
if ( ! cargoInfoList . isEmpty ( ) ) {
cargoInfoList . forEach ( cargoInfo - > {
cargoInfoList . forEach ( cargoInfo - > {
@ -287,6 +301,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
cargoInfoAdapter . notifyDataSetChanged ( ) ;
cargoInfoAdapter . notifyDataSetChanged ( ) ;
}
}
// 跳转装载页面
public void clickCargoInfo ( View view ) {
public void clickCargoInfo ( View view ) {
if ( flightInfoTag = = null ) {
if ( flightInfoTag = = null ) {
Toast . makeText ( this , "没有选择航班" , Toast . LENGTH_SHORT ) . show ( ) ;
Toast . makeText ( this , "没有选择航班" , Toast . LENGTH_SHORT ) . show ( ) ;
@ -296,9 +311,19 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
Toast . makeText ( this , "没有添加装载单元" , Toast . LENGTH_SHORT ) . show ( ) ;
Toast . makeText ( this , "没有添加装载单元" , Toast . LENGTH_SHORT ) . show ( ) ;
return ;
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 ( ) ) ;
intent . putExtra ( "id" , flightInfoTag . getId ( ) ) ;
startActivityForResult ( intent , 0 ) ;
startActivityForResult ( intent , 0 ) ;
}
}
// 扫描装载单元
// 扫描装载单元
@Override
@Override
public void sanCodeResult ( String code ) {
public void sanCodeResult ( String code ) {
@ -307,8 +332,10 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
Toast . makeText ( this , "扫描数据:" + code + " 异常" , Toast . LENGTH_SHORT ) . show ( ) ;
Toast . makeText ( this , "扫描数据:" + code + " 异常" , Toast . LENGTH_SHORT ) . show ( ) ;
return ;
return ;
}
}
String substring = code . substring ( 0 , 8 ) ;
binding . loadMainCargoSanCode . setText ( code ) ;
binding . loadMainCargoSanCode . setText ( substring ) ;
}
}
}
}