修改 导出和显示

master
wanghao 3 months ago
parent 6c60c1c85b
commit 28bbdc4d47

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

@ -133,9 +133,9 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
String cargoCode = binding.loadMainCargoCode.getText().toString();
if (cargoCode.isEmpty()) return;
String cargoCode0 = binding.loadMainCargoCode0.getSelectedItem().toString();
String cargoCode2 = binding.loadMainCargoCode2.getSelectedItem().toString();
int id = flightInfoTag.getId();
cargoCode = cargoCode0 + cargoCode + cargoCode2;
cargoCode = cargoCode0 + cargoCode ;
int countTag = LitePal.where("cargoCode= ? and flightId=?", cargoCode, String.valueOf(id)).count(CargoInfo.class);
if (countTag > 0) {
Toast.makeText(this, "装载单元已经绑定", Toast.LENGTH_SHORT).show();
@ -146,7 +146,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
cargoInfo.setCargoCode(cargoCode);
cargoInfo.setFlightId(id);
cargoInfo.setState("未装载");
// cargoInfo.setLoadState("C0");
cargoInfo.setCargoType(binding.loadMainCargoCode2.getSelectedItem().toString());
cargoInfo.save();
cargoInfoList.add(cargoInfo);
cargoInfoAdapter.notifyDataSetChanged();
@ -197,7 +197,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
@Override
public void longClickCargoInfo(int index) {
CargoInfo cargoInfo = cargoInfoList.get(index);
if (!cargoInfo.getState().equals("装载")) {
if (!cargoInfo.getState().equals("装载")) {
Toast.makeText(this, "已经装载行李,不能删除", Toast.LENGTH_SHORT).show();
return;
}

@ -35,7 +35,9 @@ public class AddFlightDialog extends Dialog {
dialogDatepicker.setSpinnersShown(true); // 显示数字选择器(true);
binding.dialogReturnTrue.setOnClickListener(v -> {
String date = dialogDatepicker.getYear() + "-" + (dialogDatepicker.getMonth()+1) + "-" + dialogDatepicker.getDayOfMonth();
int month = dialogDatepicker.getMonth() + 1;
String date = dialogDatepicker.getYear() + "-" + String.format("%02d", month) + "-" + dialogDatepicker.getDayOfMonth();
// Log.e("TAG", "AddFlightDialog:" + date);
String time= dialogTimepicker.getHour()+":"+dialogTimepicker.getMinute();
String flightCode = binding.dialogFlightCode.getText().toString();

@ -13,6 +13,9 @@ public class CargoInfo extends LitePalSupport {
*
*/
private String cargoCode;
// 类型
private String cargoType;
/**
*
*/
@ -22,6 +25,13 @@ public class CargoInfo extends LitePalSupport {
private int count;
public String getCargoType() {
return cargoType;
}
public void setCargoType(String cargoType) {
this.cargoType = cargoType;
}
public String getLoadState() {
return loadState;

@ -66,8 +66,6 @@ public class FlightInfoFragment extends Fragment implements AdapterView.OnItemCl
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = getContext();
progressDialog = new ProgressDialog(context);
progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
progressDialog.setCanceledOnTouchOutside(false);
@ -100,13 +98,14 @@ public class FlightInfoFragment extends Fragment implements AdapterView.OnItemCl
return binding.getRoot();
}
@SuppressLint("NotifyDataSetChanged")
@SuppressLint({"NotifyDataSetChanged", "SetTextI18n"})
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
FlightInfo flightInfo = flightList.get(position);
binding.loadMainFlightCode.setText(flightInfo.getFlightCode());
binding.loadMainFlightDate.setText(flightInfo.getTakeoffDate());
binding.loadMainFlightNumber.setText("" + flightInfo.getJieguiQty());
tagId = String.valueOf(flightInfo.getId());
int countCargo = LitePal.where("flightId= ?", tagId).count(CargoInfo.class);
binding.loadCountCargo.setText(String.valueOf(countCargo));
@ -127,7 +126,7 @@ public class FlightInfoFragment extends Fragment implements AdapterView.OnItemCl
progressDialog.show();
new Thread(() -> {
// 根据 flightId 查询 LoadOperation 数据
List<LoadOperation> loadOperations = LitePal.where("flightId = ?", flightId).find(LoadOperation.class);
List<LoadOperation> loadOperations = LitePal.where("flightId = ? and type='装载' and (state IS NULL or state = '修改') ", flightId).find(LoadOperation.class);
// 创建新的工作簿
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Load Operations");
@ -135,14 +134,15 @@ public class FlightInfoFragment extends Fragment implements AdapterView.OnItemCl
CellStyle headerCellStyle = workbook.createCellStyle();
headerCellStyle.setAlignment(HorizontalAlignment.CENTER); // 设置水平居中
headerCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中
// 创建表头
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]);
sheet.setDefaultColumnStyle(i,headerCellStyle);
sheet.setDefaultColumnStyle(i, headerCellStyle);
if (i == 4 || i == 5 || i == 6) {
sheet.setColumnWidth(i, 5000);
} else {
@ -150,8 +150,6 @@ public class FlightInfoFragment extends Fragment implements AdapterView.OnItemCl
}
}
// 填充数据
int rowNum = 1;
int index = 0;
@ -163,20 +161,15 @@ public class FlightInfoFragment extends Fragment implements AdapterView.OnItemCl
row.createCell(2).setCellValue(loadOperation.getDestination());
row.createCell(3).setCellValue(loadOperation.getTakeoffTime());
row.createCell(4).setCellValue(loadOperation.getCargoCode());
// row.createCell(5).setCellValue(loadOperation.getOrderNum());
row.createCell(5).setCellValue(loadOperation.getLuggageCode());
row.createCell(6).setCellValue(loadOperation.getOldLuggageCode());
row.createCell(7).setCellValue(loadOperation.getUser());
row.createCell(8).setCellValue(loadOperation.getLoadTime());
row.createCell(9).setCellValue(loadOperation.getType());
row.createCell(10).setCellValue(loadOperation.getUnLoadTime());
row.createCell(11).setCellValue(loadOperation.getState());
row.createCell(6).setCellValue(loadOperation.getLoadTime());
}
// 使用 MediaStore 存储文件
ContentResolver contentResolver = context.getContentResolver();
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, "行李装载操作信息" + LocalDateTime.now().format(formatter) + ".xlsx");
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, "行李装载信息" + binding.loadMainFlightCode.getText().toString() +" "+
binding.loadMainFlightDate.getText().toString() + ".xlsx");
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOCUMENTS);

@ -158,6 +158,89 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="51dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:paddingStart="5dp"
android:paddingEnd="5dp">
<TextView
android:id="@+id/item_cargo_c"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="装载单元编号"
android:textSize="15sp" />
<View
android:layout_width="1dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:background="#e1e1e1" />
<TextView
android:layout_width="45dp"
android:layout_height="match_parent"
android:gravity="center"
android:text='类型'
android:textSize="15sp" />
<View
android:layout_width="1dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:background="#e1e1e1" />
<TextView
android:layout_width="45dp"
android:layout_height="match_parent"
android:gravity="center"
android:text='数量'
android:textSize="15sp" />
<View
android:layout_width="1dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:background="#e1e1e1" />
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="状态"
android:textSize="15sp" />
<View
android:layout_width="1dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:background="#e1e1e1" />
<TextView
android:id="@+id/item_cargo_state"
android:layout_width="90dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="装载量"
android:textSize="15sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:background="#EEEEEE" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
@ -166,7 +249,7 @@
android:layout_weight="1"
android:adapter="@{adapter}"
android:background="@drawable/main_menu_bg"
android:padding="10dp"
android:padding="5dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout

@ -44,14 +44,14 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@{data.flightCode}"
android:text="@{data.takeoffTime}"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text='@{data.takeoffDate+" "+data.takeoffTime}'
android:text='@{data.flightCode+" "+data.takeoffDate}'
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"

@ -64,19 +64,34 @@
android:background="@drawable/main_menu_bg">
<TextView
android:layout_width="120dp"
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="装载单元数量"
android:text="航班日期"
android:textSize="18sp" />
<TextView
android:id="@+id/load_count_cargo"
android:id="@+id/load_main_flight_date"
style="@style/text_title"
android:layout_width="match_parent"
android:layout_height="38dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginEnd="10dp" />
android:layout_weight="1" />
<TextView
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="结柜数量"
android:textSize="18sp" />
<TextView
android:id="@+id/load_main_flight_number"
style="@style/text_title"
android:layout_width="85dp"
android:layout_height="match_parent"
android:layout_gravity="center" />
</LinearLayout>
@ -87,6 +102,21 @@
android:layout_marginTop="1dp"
android:background="@drawable/main_menu_bg">
<TextView
android:layout_width="120dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="装载单元数量"
android:textSize="18sp" />
<TextView
android:id="@+id/load_count_cargo"
style="@style/text_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1" />
<TextView
android:layout_width="120dp"
android:layout_height="match_parent"
@ -98,9 +128,9 @@
android:id="@+id/load_count_luggage"
style="@style/text_title"
android:layout_width="match_parent"
android:layout_height="38dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginEnd="10dp" />
android:layout_weight="1" />
</LinearLayout>

@ -31,6 +31,18 @@
android:layout_gravity="center"
android:background="#e1e1e1" />
<TextView
android:layout_width="45dp"
android:layout_height="match_parent"
android:gravity="center"
android:text='@{data.cargoType}'
android:textSize="15sp" />
<View
android:layout_width="1dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:background="#e1e1e1" />
<TextView
android:layout_width="45dp"
android:layout_height="match_parent"

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="loadState">
<item>C0</item>
<item>C1</item>
<item>C2</item>
<item>C3</item>
<item>C4</item>
<item>B0</item>
<item>B1</item>
<item>B2</item>
<item>B3</item>
<item>BX</item>
</string-array>
</resources>
Loading…
Cancel
Save