@ -34,21 +34,18 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern ;
import java.util.regex.Pattern ;
public class LoadScanActivity extends BaseActivity implements CargoListAdapter . CargoInfoCall , LoadInfoAdapter . LoadInfoCall , View . OnLongClickListener {
public class LoadScanActivity extends BaseActivity implements CargoListAdapter . CargoInfoCall , LoadInfoAdapter . LoadInfoCall , View . OnLongClickListener {
private final Handler handler = new Handler ( Looper . getMainLooper ( ) ) ;
private List < CargoInfo > cargoInfoList ;
private List < CargoInfo > cargoInfoList ;
private CargoListAdapter adapter ;
private CargoListAdapter adapter ;
private List < LoadOperation > loadOperations ;
private List < LoadOperation > loadOperations ;
private CargoInfo cargoInfoTag ;
private CargoInfo cargoInfoTag ;
private FlightInfo flightInfo ;
private FlightInfo flightInfo ;
// private LoadToast loadToast;
private LoadInfoAdapter loadInfoAdapter ;
private LoadInfoAdapter loadInfoAdapter ;
// 定义时间格式
private DateTimeFormatter formatter ; // 定义时间格式
private DateTimeFormatter formatter ;
private UpdataDialog updataDialog ;
private UpdataDialog updataDialog ;
// 装载完成对话框
private ActivityLoadScanBinding binding ; // 装载完成对话框
private ActivityLoadScanBinding binding ;
private TipDialog tipDialog ;
private TipDialog tipDialog ;
private AlertDialog . Builder alertDialog ;
private AlertDialog . Builder alertDialog ;
private Handler handler = new Handler ( Looper . getMainLooper ( ) ) ;
private String checkCode ;
private String checkCode ;
private boolean checkState ;
private boolean checkState ;
@ -70,7 +67,6 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
adapter . setList ( cargoInfoList ) ;
adapter . setList ( cargoInfoList ) ;
binding . setAdapter1 ( adapter ) ;
binding . setAdapter1 ( adapter ) ;
formatter = DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:mm:ss" ) ;
formatter = DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:mm:ss" ) ;
// loadToast = new LoadToast(this);
loadInfoAdapter = new LoadInfoAdapter ( this , this ) ;
loadInfoAdapter = new LoadInfoAdapter ( this , this ) ;
loadInfoAdapter . setRecyclerView ( binding . loadInfoRecyclerview ) ;
loadInfoAdapter . setRecyclerView ( binding . loadInfoRecyclerview ) ;
binding . setAdapter2 ( loadInfoAdapter ) ;
binding . setAdapter2 ( loadInfoAdapter ) ;
@ -82,12 +78,26 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
@SuppressLint ( "NotifyDataSetChanged" )
@SuppressLint ( "NotifyDataSetChanged" )
private void initDialog ( ) {
private void initDialog ( ) {
updataDialog = new UpdataDialog ( this ) ;
updataDialog = new UpdataDialog ( this ) ;
updataDialog . setUpdataDialogCall ( ( code , index ) - > {
updataDialog . setUpdataDialogCall ( ( tag , code , index ) - > {
if ( tag . equals ( "行李" ) ) {
LoadOperation loadOperation = loadOperations . get ( index ) ;
LoadOperation loadOperation = loadOperations . get ( index ) ;
loadOperation . setOldLuggageCode ( loadOperation . getLuggageCode ( ) ) ;
loadOperation . setOldLuggageCode ( loadOperation . getLuggageCode ( ) ) ;
loadOperation . setLuggageCode ( code ) ;
loadOperation . setLuggageCode ( code ) ;
loadOperation . setState ( "修改" ) ;
loadOperation . setState ( "修改" ) ;
loadOperation . update ( loadOperation . getId ( ) ) ;
loadOperation . update ( loadOperation . getId ( ) ) ;
} else if ( tag . equals ( "装载单元" ) ) {
// 128
CargoInfo cargoInfo = cargoInfoList . get ( index ) ;
int id = cargoInfo . getId ( ) ;
LoadOperation updateBeen = new LoadOperation ( ) ;
updateBeen . setUpdateCargoTag ( 1 ) ;
String formattedTime = LocalDateTime . now ( ) . format ( formatter ) ;
updateBeen . setLoadTime ( formattedTime ) ;
updateBeen . updateAll ( "cargoId =?" , String . valueOf ( id ) ) ;
cargoInfo . setCargoCode ( code ) ;
cargoInfo . update ( id ) ;
adapter . notifyDataSetChanged ( ) ;
}
loadInfoAdapter . notifyDataSetChanged ( ) ;
loadInfoAdapter . notifyDataSetChanged ( ) ;
updataDialog . dismiss ( ) ;
updataDialog . dismiss ( ) ;
} ) ;
} ) ;
@ -110,16 +120,27 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
}
}
// 点击装载单元
// 点击装载单元
@SuppressLint ( "NotifyDataSetChanged" )
@Override
@Override
public void clickCargoInfo ( int index ) {
public void clickCargoInfo ( int index ) {
cargoInfoTag = cargoInfoList . get ( index ) ;
cargoInfoTag = cargoInfoList . get ( index ) ;
// Log.e("TAG", "clickCargoInfo:" + cargoInfoTag.toString());
loadOperations = LitePal . where ( "cargoId =? and type = ? and (state IS NULL or state = '修改') " , String . valueOf ( cargoInfoTag . getId ( ) ) , "装载" ) . order ( "id desc" ) . find ( LoadOperation . class ) ;
loadOperations = LitePal . where ( "cargoId =? and type = ? and (state IS NULL or state = '修改') " , String . valueOf ( cargoInfoTag . getId ( ) ) , "装载" ) . order ( "id desc" ) . find ( LoadOperation . class ) ;
Log . e ( "TAG" , "clickCargoInfo:" + loadOperations ) ;
Log . e ( "TAG" , "clickCargoInfo:" + loadOperations ) ;
loadInfoAdapter . setList ( loadOperations ) ;
loadInfoAdapter . setList ( loadOperations ) ;
loadInfoAdapter . notifyDataSetChanged ( ) ;
loadInfoAdapter . notifyDataSetChanged ( ) ;
}
}
// 长按货箱
@Override
public void longClickCargoInfo ( int index ) {
// 93
CargoInfo cargoInfo = cargoInfoList . get ( index ) ;
updataDialog . setIndex ( index ) ;
updataDialog . setCode ( cargoInfo . getCargoCode ( ) ) ;
updataDialog . setTag ( "装载单元" ) ;
updataDialog . show ( ) ;
}
// 扫码结果
// 扫码结果
@Override
@Override
public void sanCodeResult ( String code ) {
public void sanCodeResult ( String code ) {
@ -134,9 +155,7 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
String group = matcher . group ( ) ;
String group = matcher . group ( ) ;
// Log.e("TAG", "sanCodeResult:" + matcher.group());
// Log.e("TAG", "sanCodeResult:" + matcher.group());
for ( int i = 0 ; i < cargoInfoList . size ( ) ; i + + ) {
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 ( ) ;
RecyclerView . LayoutManager layoutManager = binding . scanR1 . getLayoutManager ( ) ;
if ( layoutManager instanceof LinearLayoutManager ) {
if ( layoutManager instanceof LinearLayoutManager ) {
View itemView = layoutManager . findViewByPosition ( i ) ;
View itemView = layoutManager . findViewByPosition ( i ) ;
@ -182,6 +201,7 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
}
}
// 插入数据库
private void loadLastFun ( String code ) {
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 ) ;
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 ) {
if ( count > 0 ) {
@ -233,6 +253,7 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
// }
// }
LoadOperation loadOperation = loadOperations . get ( index ) ;
LoadOperation loadOperation = loadOperations . get ( index ) ;
updataDialog . setIndex ( index ) ;
updataDialog . setIndex ( index ) ;
updataDialog . setTag ( "行李" ) ;
updataDialog . setCode ( loadOperation . getLuggageCode ( ) ) ;
updataDialog . setCode ( loadOperation . getLuggageCode ( ) ) ;
updataDialog . show ( ) ;
updataDialog . show ( ) ;
}
}