修改 导出和显示

master
wanghao 2 months ago
parent 28bbdc4d47
commit 008dade658

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

@ -10,6 +10,8 @@ import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.PixelCopy;
import android.view.View;
@ -28,6 +30,7 @@ import com.example.as_trak.toast.LoadToast;
import org.litepal.LitePal;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@ -44,7 +47,7 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
private DateTimeFormatter formatter;
private UpdataDialog updataDialog;
// 装载完成对话框
private ActivityLoadScanBinding binding;
private TipDialog tipDialog;
private AlertDialog.Builder alertDialog;
@ -52,18 +55,22 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityLoadScanBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_load_scan);
binding = DataBindingUtil.setContentView(this, R.layout.activity_load_scan);
initScan();
int id = getIntent().getIntExtra("id", 0);
// 航班显示
flightInfo = LitePal.where("id= ?", String.valueOf(id)).findFirst(FlightInfo.class);
binding.setData(flightInfo);
// 货箱显示
cargoInfoList = LitePal.where("flightId = ?", String.valueOf(id)).find(CargoInfo.class);
adapter = new CargoListAdapter(this, this);
adapter.setList(cargoInfoList);
binding.setAdapter1(adapter);
formatter = DateTimeFormatter.ofPattern("HH:mm");
formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
// loadToast = new LoadToast(this);
loadInfoAdapter = new LoadInfoAdapter(this, this);
loadInfoAdapter.setRecyclerView(binding.loadInfoRecyclerview);
binding.setAdapter2(loadInfoAdapter);
binding.loadScanSubmit.setOnLongClickListener(this);
initDialog();
@ -84,43 +91,69 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
updataDialog.dismiss();
});
tipDialog = new TipDialog(this);
alertDialog=new AlertDialog.Builder(this);
alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("装载完成提示")
.setMessage("是否全部修改状态为装载完成")
.setNegativeButton("取消",null)
.setPositiveButton("确", new DialogInterface.OnClickListener() {
.setMessage("确认装载完成")
.setNegativeButton("取消", null)
.setPositiveButton("确", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
cargoInfoList.forEach(t -> {
t.setState("装载完成");
t.update(t.getId());
});
Toast.makeText(LoadScanActivity.this, "成功", Toast.LENGTH_SHORT).show();
finish();
if (cargoInfoTag == null) {
Toast.makeText(LoadScanActivity.this, "没有选择装载单元", Toast.LENGTH_SHORT).show();
return;
}
cargoInfoTag.setState("装载完成");
cargoInfoTag.update(cargoInfoTag.getId());
adapter.notifyDataSetChanged();
Toast.makeText(LoadScanActivity.this, "装载完成", Toast.LENGTH_SHORT).show();
}
}).create();
}
// 点击装载单元
@Override
public void clickCargoInfo(int 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);
Log.e("TAG", "clickCargoInfo:" + loadOperations);
loadInfoAdapter.setList(loadOperations);
loadInfoAdapter.notifyDataSetChanged();
}
// 扫码结果
@SuppressLint("NotifyDataSetChanged")
@Override
public void sanCodeResult(String code) {
super.sanCodeResult(code);
addInfo(code);
}
// 手动添加扫描结果
public void addSanResult(View view) {
String code = binding.loadSanInfoCode.getText().toString();
addInfo(code);
}
// 添加
private void addInfo(String code) {
if (cargoInfoTag == null) {
Toast.makeText(this, "没有选择装载单元", Toast.LENGTH_SHORT).show();
return;
}
if (cargoInfoTag.getState().equals("装载完成")) {
Toast.makeText(this, "装载单元已经装载完成", Toast.LENGTH_SHORT).show();
return;
}
int count = LitePal.where("flightId= ? and luggageCode=? and (state IS NULL or state = '修改') ", String.valueOf(flightInfo.getId()), code).count(LoadOperation.class);
// if (cargoInfoTag.getState().equals("装载完成")) {
// Toast.makeText(this, "装载单元已经装载完成", Toast.LENGTH_SHORT).show();
// return;
// }
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 + "重复");
return;
}
tipDialog.showSuccess("绑定成功");
tipDialog.showSuccess(code + "\t装载成功");
// 添加行李
LoadOperation loadOperation = new LoadOperation();
loadOperation.setFlightCode(flightInfo.getFlightCode());
loadOperation.setFlightId(flightInfo.getId());
@ -130,39 +163,37 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
loadOperation.setCargoId(cargoInfoTag.getId());
loadOperation.setLuggageCode(code);
// loadOperation.setUser();
String formattedTime = LocalTime.now().format(formatter); // 格式化当前时间
String formattedTime = LocalDateTime.now().format(formatter); // 格式化当前时间
loadOperation.setLoadTime(formattedTime);
loadOperation.setType("装载");
loadOperation.save();
loadOperations.add(0, loadOperation);
Log.e("TAG", "sanCodeResult:" + loadOperations.toString());
loadInfoAdapter.notifyDataSetChanged();
loadOperations.add(0, loadOperation);//列表
loadInfoAdapter.notifyItemInserted(0);
binding.loadInfoRecyclerview.scrollToPosition(0);
loadOperation.setBg(true);
changeBackgroundColorAfterDelay(loadOperation);
// 更新货箱状态
int size = loadOperations.size();
Log.e("TAG", "更新的id:" + cargoInfoTag.getId() + "数量:" + size);
cargoInfoTag.setCount(size);
cargoInfoTag.setState("装载中");
cargoInfoTag.update(cargoInfoTag.getId());
}
// 点击装载单元
@Override
public void clickCargoInfo(int 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()), "装载").find(LoadOperation.class);
loadInfoAdapter.setList(loadOperations);
loadInfoAdapter.notifyDataSetChanged();
private Handler handler = new Handler(Looper.getMainLooper());
private void changeBackgroundColorAfterDelay(LoadOperation loadOperation) {
handler.postDelayed(() -> {
loadOperation.setBg(false);
loadInfoAdapter.notifyDataSetChanged();
}, 3000);
}
// 修改行李号
@SuppressLint("NotifyDataSetChanged")
@Override
public void updateCargoInfo(int index) {
if (cargoInfoTag.getState().equals("装载完成")) {
Toast.makeText(this, "装载单元已经装载完成", Toast.LENGTH_SHORT).show();
return;
}
// if (cargoInfoTag.getState().equals("装载完成")) {
// Toast.makeText(this, "装载单元已经装载完成", Toast.LENGTH_SHORT).show();
// return;
// }
LoadOperation loadOperation = loadOperations.get(index);
updataDialog.setIndex(index);
updataDialog.setCode(loadOperation.getLuggageCode());
@ -173,10 +204,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;
}
// if (cargoInfoTag.getState().equals("装载完成")) {
// Toast.makeText(this, "装载单元已经装载完成", Toast.LENGTH_SHORT).show();
// return;
// }
LoadOperation loadOperation = loadOperations.get(index);
loadOperation.setState("删除");
loadOperation.update(loadOperation.getId());

@ -2,6 +2,8 @@ package com.example.as_trak.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
@ -106,4 +108,15 @@ public class LoadInfoAdapter extends RecyclerView.Adapter<LoadInfoAdapter.MyView
popupMenu.show();
}
private Handler handler = new Handler(Looper.getMainLooper());
private RecyclerView recyclerView;
public void setRecyclerView(RecyclerView recyclerView) {
this.recyclerView = recyclerView;
}
}

@ -24,7 +24,8 @@ public class BaseActivity extends AppCompatActivity {
public void initScan() {
myReceiver = new MyScanCodeBroad();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.ACTION_DECODE_DATA");
// intentFilter.addAction("android.intent.ACTION_DECODE_DATA");
intentFilter.addAction("com.rfid.SCAN");
registerReceiver(myReceiver, intentFilter);
}
@ -38,8 +39,9 @@ public class BaseActivity extends AppCompatActivity {
@Override
public void onReceive(Context context, Intent intent) {
String value = intent.getStringExtra("barcode_string");
String scannerdata = intent.getStringExtra("scannerdata");
Log.e("TAG", "onReceive:" + value);
sanCodeResult(value);
sanCodeResult(scannerdata);
}
}
public void sanCodeResult(String code){}

@ -6,7 +6,10 @@ import android.content.Context;
import android.database.Observable;
import android.media.MediaPlayer;
import android.os.Vibrator;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.Window;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
@ -25,6 +28,7 @@ public class TipDialog extends Dialog {
public TipDialog(@NonNull Context context) {
super(context, R.style.dialog_style);
getWindow().setGravity(Gravity.BOTTOM);
music = MediaPlayer.create(context, R.raw.error);
musicSuccess = MediaPlayer.create(context, R.raw.success);
vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
@ -34,6 +38,7 @@ public class TipDialog extends Dialog {
setCanceledOnTouchOutside(false);
binding.setState(state);
binding.tipDialogOver.setOnClickListener(v -> dismiss());
}

@ -52,6 +52,15 @@ public class LoadOperation extends LitePalSupport {
*/
private String state;
private boolean bg =false;
public boolean isBg() {
return bg;
}
public void setBg(boolean bg) {
this.bg = bg;
}
public String getUnLoadTime() {
return unLoadTime;
@ -176,6 +185,7 @@ public class LoadOperation extends LitePalSupport {
@Override
public String toString() {
return "LoadOperation{" +
"order="+orderNum+
"id=" + id +
", flightCode='" + flightCode + '\'' +
", flightId=" + flightId +

@ -46,6 +46,7 @@
android:gravity="center"
android:text="@{data.takeoffTime}"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -53,6 +54,7 @@
android:gravity="center"
android:text='@{data.flightCode+" "+data.takeoffDate}'
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -64,10 +66,41 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="5dp"
android:background="@drawable/main_menu_bg">
<TextView
style="@style/text_title"
android:layout_width="110dp"
android:layout_height="match_parent"
android:text="扫描或输入:" />
<EditText
android:id="@+id/load_san_info_code"
android:layout_width="0dp"
android:layout_height="38dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/select_bg"
android:gravity="center"
android:textSize="18sp" />
<ImageButton
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_marginEnd="0dp"
android:background="@color/white"
android:onClick="addSanResult"
android:src="@mipmap/icon_add" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/main_menu_bg">
@ -118,15 +151,13 @@
android:background="#e1e1e1" />
<TextView
android:layout_width="60dp"
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="装载时间"
android:textSize="14sp" />
</LinearLayout>
<View
@ -154,6 +185,7 @@
android:background="#e1e1e1" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/load_info_recyclerview"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignTop="@+id/scan_r1"
@ -167,9 +199,6 @@
</RelativeLayout>
<Button
android:id="@+id/load_scan_submit"
android:layout_width="150dp"

@ -37,7 +37,7 @@
<TextView
android:id="@+id/toast_msg"
android:layout_width="400dp"
android:layout_height="315dp"
android:layout_height="215dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="28sp" />

@ -182,7 +182,7 @@ android:id="@+id/load_main_flight_number"
android:background="#e1e1e1" />
<TextView
android:layout_width="60dp"
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="时间"

@ -11,7 +11,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="51dp"
android:orientation="vertical">
android:orientation="vertical"
android:background='@{data.bg?@color/green:@color/white}'
>
<LinearLayout
android:layout_width="match_parent"
@ -37,7 +39,7 @@
android:gravity="center"
android:layout_weight="1"
android:text='@{data.luggageCode}'
android:textSize="15sp" />
android:textSize="17sp" />
<View
android:layout_width="1dp"
@ -47,7 +49,7 @@
<TextView
android:layout_width="60dp"
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:text='@{data.loadTime}'

@ -66,7 +66,7 @@
<TextView
android:layout_width="60dp"
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="@{data.loadTime}"
@ -122,7 +122,7 @@
android:background="#e1e1e1" />
<TextView
android:layout_width="60dp"
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="@{data.unLoadTime}"

@ -3,5 +3,6 @@
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="blue">#387BE7</color>
<color name="green">#00FF00</color>
<color name="empty_color">#F2F3F5</color>
</resources>

@ -46,6 +46,7 @@
<item name="android:backgroundDimEnabled">true</item>
<!-- 遮罩层 -->
<item name="android:backgroundDimAmount">0.5</item>
<!-- <item name="android:gravity"></item>-->
<!--对话框动画-->

Loading…
Cancel
Save