diff --git a/app/src/main/assets/litepal.xml b/app/src/main/assets/litepal.xml index d6f181e..f3da561 100644 --- a/app/src/main/assets/litepal.xml +++ b/app/src/main/assets/litepal.xml @@ -1,7 +1,7 @@ - + diff --git a/app/src/main/java/com/example/as_trak/LoadMainActivity.java b/app/src/main/java/com/example/as_trak/LoadMainActivity.java index dd49d45..dd59956 100644 --- a/app/src/main/java/com/example/as_trak/LoadMainActivity.java +++ b/app/src/main/java/com/example/as_trak/LoadMainActivity.java @@ -47,6 +47,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad private ObservableInt loadQty; private androidx.appcompat.app.AlertDialog.Builder alertDialog; private String[] loadStateList; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -64,25 +65,17 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad loadQty = new ObservableInt(); binding.setQty1(cargoQty); binding.setQty2(loadQty); - builder = new AlertDialog.Builder(this); - builder.setTitle("删除确认").setMessage("是否确定删除装载单元").setNegativeButton("取消", null); - initAlertDialog(); } private void initAlertDialog() { + builder = new AlertDialog.Builder(this); + builder.setTitle("删除确认").setMessage("是否确定删除装载单元").setNegativeButton("取消", null); loadStateList = getResources().getStringArray(R.array.loadState); alertDialog = new androidx.appcompat.app.AlertDialog.Builder(this); alertDialog.setTitle("选择装载量") - .setItems(loadStateList, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Toast.makeText(LoadMainActivity.this, "装载完成", Toast.LENGTH_SHORT).show(); - - - } - }).setNegativeButton("取消", null).create(); + .setNegativeButton("取消", null).create(); } // 初始化航班添加 @@ -161,11 +154,13 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad binding.loadMainCargoCode.setText(null); Toast.makeText(this, "绑定成功", Toast.LENGTH_SHORT).show(); } + public void saveNumber(View view) { flightInfoTag.setJieguiQty(binding.loadMainJieguiQty.getText().toString()); flightInfoTag.update(flightInfoTag.getId()); Toast.makeText(this, "保存成功", Toast.LENGTH_SHORT).show(); } + // 关闭货箱添加 public void loadCloseEdit(View view) { visibState.set(true); @@ -217,9 +212,23 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad } }).show(); + } + // 修改装载量 + @Override + public void updateState(int index) { + CargoInfo cargoInfo = cargoInfoList.get(index); + alertDialog.setItems(loadStateList, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + cargoInfo.setLoadState(loadStateList[which]); + cargoInfo.update(cargoInfo.getId()); + cargoInfoAdapter.notifyItemChanged(index); + } + }).show(); } + // 选中航班 @Override public void onItemClick(AdapterView parent, View view, int position, long id) { @@ -247,7 +256,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad AtomicInteger tag = new AtomicInteger(); if (!cargoInfoList.isEmpty()) { cargoInfoList.forEach(cargoInfo -> { - int countNum = LitePal.where("cargoId = ? and type ='正常' and (state IS NULL or state = '修改')", String.valueOf(cargoInfo.getId())).count(LoadOperation.class); + int countNum = LitePal.where("cargoId = ? and type ='装载' and (state IS NULL or state = '修改')", String.valueOf(cargoInfo.getId())).count(LoadOperation.class); cargoInfo.setCount(countNum); tag.addAndGet(countNum); }); diff --git a/app/src/main/java/com/example/as_trak/LoadScanActivity.java b/app/src/main/java/com/example/as_trak/LoadScanActivity.java index b08e818..c0cc9a7 100644 --- a/app/src/main/java/com/example/as_trak/LoadScanActivity.java +++ b/app/src/main/java/com/example/as_trak/LoadScanActivity.java @@ -81,6 +81,7 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C loadOperation.setState("修改"); loadOperation.update(loadOperation.getId()); loadInfoAdapter.notifyDataSetChanged(); + updataDialog.dismiss(); }); tipDialog = new TipDialog(this); alertDialog=new AlertDialog.Builder(this); @@ -158,6 +159,10 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C @SuppressLint("NotifyDataSetChanged") @Override public void updateCargoInfo(int index) { + if (cargoInfoTag.getState().equals("装载完成")) { + Toast.makeText(this, "装载单元已经装载完成", Toast.LENGTH_SHORT).show(); + return; + } LoadOperation loadOperation = loadOperations.get(index); updataDialog.setIndex(index); updataDialog.setCode(loadOperation.getLuggageCode()); @@ -168,6 +173,10 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C @SuppressLint("NotifyDataSetChanged") @Override public void deleteCargoInfo(int index) { + if (cargoInfoTag.getState().equals("装载完成")) { + Toast.makeText(this, "装载单元已经装载完成", Toast.LENGTH_SHORT).show(); + return; + } LoadOperation loadOperation = loadOperations.get(index); loadOperation.setState("删除"); loadOperation.update(loadOperation.getId()); diff --git a/app/src/main/java/com/example/as_trak/SettingActivity.java b/app/src/main/java/com/example/as_trak/SettingActivity.java index c32a4c2..46f118c 100644 --- a/app/src/main/java/com/example/as_trak/SettingActivity.java +++ b/app/src/main/java/com/example/as_trak/SettingActivity.java @@ -33,7 +33,7 @@ public class SettingActivity extends BaseActivity implements EditDialog.EditDial adapter = new ContainerTypesAdapter(this, this); adapterSetList("1"); binding.setAdapter(adapter); - + type="1"; binding.infoTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @SuppressLint("NotifyDataSetChanged") @Override diff --git a/app/src/main/java/com/example/as_trak/adapter/CargoInfoAdapter.java b/app/src/main/java/com/example/as_trak/adapter/CargoInfoAdapter.java index e0a1bdb..105cbc2 100644 --- a/app/src/main/java/com/example/as_trak/adapter/CargoInfoAdapter.java +++ b/app/src/main/java/com/example/as_trak/adapter/CargoInfoAdapter.java @@ -43,7 +43,7 @@ public class CargoInfoAdapter extends RecyclerView.Adapter call.deleteCargoInfo(position)); - // binding.itemCargoU.setOnClickListener(v -> call.updateCargoInfo(position)); + binding.itemCargoState.setOnClickListener(v -> call.updateState(position)); binding.itemCargoC.setOnLongClickListener(v -> { call.longClickCargoInfo(position); return true; @@ -69,6 +69,7 @@ public class CargoInfoAdapter extends RecyclerView.Adapter list = LitePal.where("flightId= ? and (state IS NULL or state = '修改')" @@ -139,7 +138,7 @@ public class FlightInfoFragment extends Fragment implements AdapterView.OnItemCl // 创建表头 Row headerRow = sheet.createRow(0); - String[] headers = {"序号", "航班号", "目的地代码", "起飞时间", "货箱号", "行李编码", "旧的行李编码", "操作人", "装载时间", "操作类型", "状态"}; + String[] headers = {"序号", "航班号", "目的地代码", "起飞时间", "货箱号", "行李编码", "旧的行李编码", "操作人", "装载时间", "操作","拉下时间", "状态"}; for (int i = 0; i < headers.length; i++) { Cell cell = headerRow.createCell(i); cell.setCellValue(headers[i]); @@ -170,7 +169,8 @@ public class FlightInfoFragment extends Fragment implements AdapterView.OnItemCl row.createCell(7).setCellValue(loadOperation.getUser()); row.createCell(8).setCellValue(loadOperation.getLoadTime()); row.createCell(9).setCellValue(loadOperation.getType()); - row.createCell(10).setCellValue(loadOperation.getState()); + row.createCell(10).setCellValue(loadOperation.getUnLoadTime()); + row.createCell(11).setCellValue(loadOperation.getState()); } // 使用 MediaStore 存储文件 diff --git a/app/src/main/java/com/example/as_trak/fragment/LuggageFragment.java b/app/src/main/java/com/example/as_trak/fragment/LuggageFragment.java index 081e67d..f541ce4 100644 --- a/app/src/main/java/com/example/as_trak/fragment/LuggageFragment.java +++ b/app/src/main/java/com/example/as_trak/fragment/LuggageFragment.java @@ -27,6 +27,10 @@ import com.example.as_trak.fragment.been.LuggageBeen; import org.litepal.LitePal; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; import java.util.List; import java.util.stream.IntStream; @@ -91,30 +95,26 @@ public class LuggageFragment extends Fragment implements View.OnLongClickListene luggageBeen.setCargoCode(loadOperationFrist.getCargoCode()); luggageBeen.setState(loadOperationFrist.getType()); luggageBeen.setLoadTime(loadOperationFrist.getLoadTime()); - luggageBeen.setLuggageCode(loadOperationFrist.getLuggageCode()); - List loadOperationList = - LitePal.where("flightId = ? and cargoId = ? and (state IS NULL or state = '修改') ", - String.valueOf(loadOperationFrist.getFlightId()), String.valueOf(loadOperationFrist.getCargoId())) - .order("id asc").find(LoadOperation.class); - FlightInfo flightInfo = - LitePal.where("id=?", String.valueOf(loadOperationFrist.getFlightId())).findFirst(FlightInfo.class); + String luggageCode = loadOperationFrist.getLuggageCode(); + luggageBeen.setLuggageCode(luggageCode); + List loadOperationList = LitePal.where("flightId = ? and cargoId = ? and (state IS NULL or state = '修改') ", String.valueOf(loadOperationFrist.getFlightId()), String.valueOf(loadOperationFrist.getCargoId())).order("id asc").find(LoadOperation.class); + FlightInfo flightInfo = LitePal.where("id=?", String.valueOf(loadOperationFrist.getFlightId())).findFirst(FlightInfo.class); luggageBeen.setTakeoffDate(flightInfo.getTakeoffDate()); - IntStream.range(0, loadOperationList.size()) - .filter(i -> loadOperationList.get(i).getLuggageCode().equals(code)) - .findFirst() - .ifPresent(i -> luggageBeen.setOrderNum(String.valueOf(i + 1))); + IntStream.range(0, loadOperationList.size()).filter(i -> loadOperationList.get(i).getLuggageCode().equals(luggageCode)).findFirst().ifPresent(i -> luggageBeen.setOrderNum(String.valueOf(i + 1))); } + // 长按按钮弹窗 @Override public boolean onLongClick(View v) { - if (loadOperationFrist == null) { + if (loadOperationFrist == null || loadOperationFrist.getType().equals("拉下")) { return false; } builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { loadOperationFrist.setType("拉下"); + loadOperationFrist.setUnLoadTime(LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"))); loadOperationFrist.update(loadOperationFrist.getId()); Toast.makeText(getContext(), "拉下成功", Toast.LENGTH_SHORT).show(); luggageBeen.setState("拉下"); diff --git a/app/src/main/res/layout/activity_load_main.xml b/app/src/main/res/layout/activity_load_main.xml index 8cebe15..7e91734 100644 --- a/app/src/main/res/layout/activity_load_main.xml +++ b/app/src/main/res/layout/activity_load_main.xml @@ -114,7 +114,7 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + @@ -34,12 +35,13 @@ android:layout_height="40dp" android:layout_gravity="center" android:layout_marginEnd="10dp" + android:layout_weight="1" android:background="@drawable/select_bg" android:drawableRight="@mipmap/ic_select" - android:layout_weight="1" android:gravity="center" android:paddingEnd="10dp" android:textSize="18sp" /> + + android:text="" + android:textSize="18sp" /> - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/item_cargo.xml b/app/src/main/res/layout/item_cargo.xml index f2b1c30..3c7c2b6 100644 --- a/app/src/main/res/layout/item_cargo.xml +++ b/app/src/main/res/layout/item_cargo.xml @@ -58,6 +58,7 @@ android:layout_gravity="center" android:background="#e1e1e1" /> - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file