修改 货箱添加

master
wanghao 3 months ago
parent 2d3020ccfb
commit 6aaeae2f3d

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

@ -118,20 +118,24 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
int size = list.size();
List<String> list1 = new ArrayList<>(size);
List<String> list2 = new ArrayList<>(size);
List<String> list3 = new ArrayList<>(size);
list.forEach(t -> {
if (t.getType().equals("1")) {
list1.add(t.getTypeName());
} else {
}else if (t.getType().equals("2")) {
list2.add(t.getTypeName());
} else {
list3.add(t.getTypeName());
}
});
if (list1.isEmpty() || list2.isEmpty()) {
if (list1.isEmpty() || list2.isEmpty()|| list3.isEmpty()) {
Toast.makeText(this, "基础信息未维护", Toast.LENGTH_SHORT).show();
Intent intent1 = new Intent(this, SettingActivity.class);
startActivity(intent1);
}
binding.setList1(list1);
binding.setList2(list2);
binding.setList3(list3);
}
}
@ -146,28 +150,31 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
visibState.set(false);
}
// 添加货箱
// 手动添加货箱
public void loadAddCargo(View view) {
if (flightInfoTag == null) return;
String cargoCode = binding.loadMainCargoCode.getText().toString();
// if (cargoCode.length() != 5) {
// Toast.makeText(this, "填写格式不规范", Toast.LENGTH_SHORT).show();
// return;
// }
String cargoCode0 = binding.loadMainCargoCode0.getSelectedItem().toString();
String cargoCode3=binding.loadMainCargoCode3.getSelectedItem().toString();
cargoCode = cargoCode0 + cargoCode+cargoCode3;
addCargo(cargoCode, binding.loadMainCargoCode2.getSelectedItem().toString());
}
// 扫描添加货箱
@SuppressLint("NotifyDataSetChanged")
public void loadAddCargo1(View view) {
if (flightInfoTag == null) return;
String code0 = binding.loadMainCargoSanCode.getText().toString();
if (code0.isEmpty()) return;
addCargo(code0, binding.loadMainSanTypeSpinner.getSelectedItem().toString());
}
public void loadAddCargo(View view) {
if (flightInfoTag == null) return;
String cargoCode = binding.loadMainCargoCode.getText().toString();
if (cargoCode.length() != 7) {
Toast.makeText(this, "填写格式不规范", Toast.LENGTH_SHORT).show();
return;
}
String cargoCode0 = binding.loadMainCargoCode0.getSelectedItem().toString();
cargoCode = cargoCode0 + cargoCode;
addCargo(cargoCode, binding.loadMainCargoCode2.getSelectedItem().toString());
}
@SuppressLint("NotifyDataSetChanged")
private void addCargo(String cargoCode, String type) {
int id = flightInfoTag.getId();

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

@ -65,7 +65,6 @@ public class CargoListAdapter extends RecyclerView.Adapter<CargoListAdapter.MyVi
} else {
if (cargoInfo.getState().equals("装载完成")) {
itemCargoCode.setBackgroundResource(R.drawable.item_over);
// return;
}else {
itemCargoCode.setBackgroundResource(R.drawable.select_bg);
}
@ -83,6 +82,11 @@ public class CargoListAdapter extends RecyclerView.Adapter<CargoListAdapter.MyVi
Log.e("TAG", "本次点击:" + position);
});
binding.itemCargoLinear.setOnLongClickListener(v -> {
call.longClickCargoInfo(position);
return true;
});
}
@Override
@ -104,5 +108,6 @@ public class CargoListAdapter extends RecyclerView.Adapter<CargoListAdapter.MyVi
public interface CargoInfoCall {
void clickCargoInfo(int index);
void longClickCargoInfo(int index);
}
}

@ -51,7 +51,12 @@ public class LoadInfoAdapter extends RecyclerView.Adapter<LoadInfoAdapter.MyView
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
ItemLoadInfoBinding binding = holder.binding;
LoadOperation data = list.get(position);
data.setOrderNum(list.size()-position);
if (data.getUpdateCargoTag()==0){
data.setOrderNum(list.size()-position);
}else {
data.setOrderNum(0);
}
binding.setData(data);
// binding.itemLoadD.setOnClickListener(v -> call.deleteCargoInfo(position));
binding.itemLoadU.setOnLongClickListener(v -> {

@ -36,7 +36,6 @@ public class AddFlightDialog extends Dialog {
binding.dialogReturnTrue.setOnClickListener(v -> {
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();

@ -10,12 +10,15 @@ import androidx.databinding.DataBindingUtil;
import com.example.as_trak.R;
import com.example.as_trak.databinding.DialogUpdateBinding;
import java.nio.charset.CoderResult;
public class UpdataDialog extends Dialog {
private DialogUpdateBinding binding;
private String code;
private int index;
private String tag;
public void setTag(String tag) {
this.tag = tag;
}
public void setIndex(int index) {
this.index = index;
@ -41,17 +44,18 @@ public class UpdataDialog extends Dialog {
if (code.isEmpty()) {
return;
}
updataDialogCall.codeResult(code,index);
updataDialogCall.codeResult(tag, code, index);
});
}
@Override
public void show() {
super.show();
binding.setTag(tag);
binding.updateOldCode.setText(code);
binding.updataNewCode.setText(null);
}
public interface UpdataDialogCall{
public void codeResult(String code,int index);
public void codeResult(String tag,String code,int index);
}
}

@ -52,6 +52,16 @@ public class LoadOperation extends LitePalSupport {
*/
private String state;
private int updateCargoTag=0;
public int getUpdateCargoTag() {
return updateCargoTag;
}
public void setUpdateCargoTag(int updateCargoTag) {
this.updateCargoTag = updateCargoTag;
}
private boolean bg =false;
public boolean isBg() {

@ -27,6 +27,10 @@
name="list2"
type="java.util.List" />
<variable
name="list3"
type="java.util.List" />
<variable
name="qty1"
@ -85,94 +89,111 @@
</LinearLayout>
<LinearLayout
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="51dp"
android:layout_marginTop="8dp"
android:minHeight="51dp"
android:background="@drawable/main_menu_bg">
android:orientation="horizontal">
<Spinner
android:id="@+id/load_main_cargo_code0"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:entries="@{list1}"
android:textAlignment="center"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<EditText
android:id="@+id/load_main_cargo_code"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:background="@drawable/select_bg"
android:gravity="center"
android:inputType="text"
android:maxLines="1"
android:textSize="17sp"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/main_menu_bg"
android:minHeight="51dp">
<Spinner
android:id="@+id/load_main_cargo_code2"
android:layout_width="90dp"
android:layout_height="match_parent"
android:entries="@{list2}"
android:textAlignment="center"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<Spinner
android:id="@+id/load_main_cargo_code0"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:entries="@{list1}"
android:textAlignment="center"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<TextView
android:layout_width="55dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:background="@drawable/button_add"
android:gravity="center"
android:onClick="loadAddCargo"
android:text="添加"
android:textColor="@color/white"
android:textSize="15sp"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<EditText
android:id="@+id/load_main_cargo_code"
android:layout_width="100dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:background="@drawable/select_bg"
android:gravity="center"
android:inputType="number"
android:maxLines="1"
android:singleLine="true"
android:textSize="17sp"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<ImageButton
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginEnd="5dp"
android:background="@color/white"
android:onClick="loadCloseEdit"
android:src="@mipmap/icon_left"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<Spinner
android:id="@+id/load_main_cargo_code3"
android:layout_width="90dp"
android:layout_height="match_parent"
android:entries="@{list3}"
android:textAlignment="center"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<TextView
android:layout_width="wrap_content"
android:layout_height="51dp"
android:layout_marginStart="10dp"
android:gravity="center"
android:onClick="loadAddEdit"
android:text="装载单元信息"
android:textSize="18sp"
android:visibility="@{visibState?View.VISIBLE:View.GONE}"
app:drawableEndCompat="@mipmap/icon_right" />
<Spinner
android:id="@+id/load_main_cargo_code2"
android:layout_width="90dp"
android:layout_height="match_parent"
android:entries="@{list2}"
android:textAlignment="center"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
</LinearLayout>
<TextView
android:layout_width="55dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:background="@drawable/button_add"
android:gravity="center"
android:onClick="loadAddCargo"
android:text="添加"
android:textColor="@color/white"
android:textSize="15sp"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginEnd="5dp"
android:drawableLeft="@mipmap/icon_left"
android:gravity="center"
android:onClick="loadCloseEdit"
android:text="关闭"
android:textSize="18dp"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<TextView
android:layout_width="wrap_content"
android:layout_height="51dp"
android:layout_marginStart="10dp"
android:gravity="center"
android:onClick="loadAddEdit"
android:text="装载单元信息"
android:textSize="18sp"
android:visibility="@{visibState?View.VISIBLE:View.GONE}"
app:drawableEndCompat="@mipmap/icon_right" />
</LinearLayout>
</HorizontalScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/main_menu_bg"
android:minHeight="51dp"
android:visibility="@{visibState?View.GONE:View.VISIBLE}"
android:background="@drawable/main_menu_bg">
android:visibility="@{visibState?View.GONE:View.VISIBLE}">
<TextView
style="@style/text_title"
android:layout_width="90dp"
android:layout_height="match_parent"
android:text="扫描添加:"
style="@style/text_title"/>
android:text="扫描添加:" />
<EditText
android:id="@+id/load_main_cargo_san_code"
@ -183,31 +204,30 @@
android:layout_weight="1"
android:background="@drawable/select_bg"
android:gravity="center"
android:textSize="17sp"
android:maxLines="1" />
android:maxLines="1"
android:textSize="17sp" />
<Spinner
android:id="@+id/load_main_san_type_spinner"
android:layout_width="90dp"
android:layout_height="match_parent"
android:entries="@{list2}"
android:textAlignment="center"/>
android:textAlignment="center" />
<TextView
android:layout_width="55dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:layout_marginEnd="55dp"
android:background="@drawable/button_add"
android:gravity="center"
android:onClick="loadAddCargo1"
android:layout_marginEnd="55dp"
android:text="添加"
android:textColor="@color/white"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
@ -388,10 +408,10 @@
<Button
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_margin="8dp"
android:letterSpacing="0.5"
android:onClick="clickCargoInfo"
android:layout_gravity="center"
android:text="装载行李"
android:textSize="18sp"
android:textStyle="bold" />

@ -45,7 +45,9 @@
android:id="@+id/dialog_flight_code"
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:inputType="textCapCharacters"
android:singleLine="true" />
</LinearLayout>
<LinearLayout
@ -65,7 +67,9 @@
android:id="@+id/dialog_flight_num"
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:inputType="textCapCharacters"
android:singleLine="true"/>
</LinearLayout>
@ -86,7 +90,6 @@
android:id="@+id/dialog_datepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:datePickerMode="spinner" />
</LinearLayout>

@ -43,8 +43,9 @@
android:layout_width="match_parent"
android:layout_height="55dp"
android:gravity="center"
android:inputType="textCapWords"
android:inputType="textCapCharacters"
android:lines="1"
android:maxLines="1" />
</LinearLayout>

@ -2,7 +2,9 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="tag"
type="String" />
</data>
<LinearLayout
@ -18,7 +20,7 @@
android:drawableRight="@mipmap/ic_cha"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="修改行李号" />
android:text='@{"修改"+tag}' />
<LinearLayout
android:layout_width="350dp"
android:layout_height="48dp"
@ -30,7 +32,7 @@
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="行李号(旧):" />
android:text='@{tag+"(原):"}' />
<TextView
android:id="@+id/update_old_code"
@ -49,13 +51,16 @@
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="输入行李号:" />
android:text="输入新编码:" />
<EditText
android:id="@+id/updata_new_code"
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:lines="1"
android:maxLines="1"
android:inputType="textCapCharacters"/>
</LinearLayout>

Loading…
Cancel
Save