加入生产日期等

This commit is contained in:
jjLv 2025-08-04 10:14:22 +08:00
parent 5c581e85ca
commit e8ce790f3b
5 changed files with 193 additions and 49 deletions

View File

@ -52,7 +52,9 @@ public class GoodsBean {
private String unqualifiedNum; private String unqualifiedNum;
private String totalQualifiedNum; private String totalQualifiedNum;
private String inventoryNum; private String inventoryNum;
private String warehouseId;
private String expireTime; private String expireTime;
private String productDate;
private String weight; private String weight;
private String takePhoto; private String takePhoto;
private String intoNum; private String intoNum;
@ -63,6 +65,22 @@ public class GoodsBean {
return StringHelper.isEmptyAndNull(totalQualifiedNum) ? "0" : totalQualifiedNum; return StringHelper.isEmptyAndNull(totalQualifiedNum) ? "0" : totalQualifiedNum;
} }
public String getWarehouseId() {
return warehouseId;
}
public void setWarehouseId(String warehouseId) {
this.warehouseId = warehouseId;
}
public String getProductDate() {
return productDate;
}
public void setProductDate(String productDate) {
this.productDate = productDate;
}
public String getFetchDetailId() { public String getFetchDetailId() {
return fetchDetailId; return fetchDetailId;
} }
@ -318,6 +336,7 @@ public class GoodsBean {
", unqualifiedNum='" + unqualifiedNum + '\'' + ", unqualifiedNum='" + unqualifiedNum + '\'' +
", inventoryNum='" + inventoryNum + '\'' + ", inventoryNum='" + inventoryNum + '\'' +
", expireTime='" + expireTime + '\'' + ", expireTime='" + expireTime + '\'' +
", productDate='" + productDate + '\'' +
", weight='" + weight + '\'' + ", weight='" + weight + '\'' +
", takePhoto='" + takePhoto + '\'' + ", takePhoto='" + takePhoto + '\'' +
", ifFillInventory='" + ifFillInventory + '\'' + ", ifFillInventory='" + ifFillInventory + '\'' +

View File

@ -148,7 +148,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
// 去皮命令 // 去皮命令
private static final String COMMAND_PEELED = "3C 54 41 52 E7 3E"; private static final String COMMAND_PEELED = "3C 54 41 52 E7 3E";
private final Handler mHandler = new Handler(Looper.getMainLooper()); private final Handler mHandler = new Handler(Looper.getMainLooper());
private TimePickerView mDatePicker; private TimePickerView mDatePicker, mDatePicker1;
private SurfaceView mSurfaceView; private SurfaceView mSurfaceView;
private static final int REQUEST_CAMERA_PERMISSION = 100; private static final int REQUEST_CAMERA_PERMISSION = 100;
// 相机相关变量 // 相机相关变量
@ -185,6 +185,17 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
.setType(true, true, true, false, false, false) .setType(true, true, true, false, false, false)
.build(); .build();
} }
private void showDatePickerDialog1(OnDateSelectedListener listener) {
mDatePicker1 = new TimePickerBuilder(requireContext(), (date, v) -> {
String dayTime = DateTimeHelper.format(date, "yyyy-MM-dd");
if (listener != null) {
listener.onDateSelected(dayTime);
}
}).setTimeSelectChangeListener(date -> Log.i("pvTime", "onTimeSelectChanged"))
.setTitleText("日期选择")
.setType(true, true, true, false, false, false)
.build();
}
List<GoodsBean> goodsList = new ArrayList<>(); List<GoodsBean> goodsList = new ArrayList<>();
List<SupplierBean> supplierList = new ArrayList<>(); List<SupplierBean> supplierList = new ArrayList<>();
String pageType; String pageType;
@ -204,6 +215,20 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
Log.e(TAG, "Current page is null."); Log.e(TAG, "Current page is null.");
} }
}); });
showDatePickerDialog1(date -> {
//针对当前选择的tab进行日期复制
if (mDestPage != null) {
View view = mPageMap.getOrDefault(mDestPage.getDisplayName(), null);
if (view != null) {
TextView dateTextView = view.findViewById(R.id.productionDate);
dateTextView.setText(date);
} else {
Log.e(TAG, "View for current page not found.");
}
} else {
Log.e(TAG, "Current page is null.");
}
});
//接收传入的参数 //接收传入的参数
Bundle args = getArguments(); Bundle args = getArguments();
String selectedGoods = null; String selectedGoods = null;
@ -284,10 +309,12 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
TextView weightView = view.findViewById(R.id.weight); TextView weightView = view.findViewById(R.id.weight);
TextView subtotal = view.findViewById(R.id.subtotal); TextView subtotal = view.findViewById(R.id.subtotal);
EditText dueDateEdit = view.findViewById(R.id.dueDate); EditText dueDateEdit = view.findViewById(R.id.dueDate);
EditText productionDate = view.findViewById(R.id.productionDate);
MaterialSpinner supplierSpinner = view.findViewById(R.id.supplier_spinner); MaterialSpinner supplierSpinner = view.findViewById(R.id.supplier_spinner);
weightView.setText("0"); weightView.setText("0");
subtotal.setText("0"); subtotal.setText("0");
dueDateEdit.setText(""); dueDateEdit.setText("");
productionDate.setText("");
supplierSpinner.setSelectedIndex(0); // 重置为第一个供应商 supplierSpinner.setSelectedIndex(0); // 重置为第一个供应商
GoodsBean goodsBean = goodsList.stream() GoodsBean goodsBean = goodsList.stream()
.filter(goods -> goods.getMaterialName().equals(pages[currentTabIndex])) .filter(goods -> goods.getMaterialName().equals(pages[currentTabIndex]))
@ -298,6 +325,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
goodsBean.setPurNum("0"); goodsBean.setPurNum("0");
goodsBean.setTotalPrice("0"); goodsBean.setTotalPrice("0");
goodsBean.setExpireTime(""); goodsBean.setExpireTime("");
goodsBean.setProductDate("");
goodsBean.setSupplierId(""); goodsBean.setSupplierId("");
goodsBean.setSupplierName(""); goodsBean.setSupplierName("");
goodsBean.setImgUrl(""); // 清空图片路径 goodsBean.setImgUrl(""); // 清空图片路径
@ -395,7 +423,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
// return false; // return false;
// } // }
// if (StringHelper.isEmptyAndNull(goods.getExpireTime())) { // if (StringHelper.isEmptyAndNull(goods.getExpireTime())) {
// XToastUtils.info("货品:" + goods.getMaterialName() + "必须选择期日期!"); // XToastUtils.info("货品:" + goods.getMaterialName() + "必须选择期日期!");
// return false; // return false;
// } // }
// } // }
@ -545,12 +573,19 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
view = LayoutInflater.from(getContext()).inflate(R.layout.item_inspection_warehousing, null); view = LayoutInflater.from(getContext()).inflate(R.layout.item_inspection_warehousing, null);
ImageView del_goods = view.findViewById(R.id.del_goods); ImageView del_goods = view.findViewById(R.id.del_goods);
EditText dueDateEdit = view.findViewById(R.id.dueDate); EditText dueDateEdit = view.findViewById(R.id.dueDate);
EditText productionDate = view.findViewById(R.id.productionDate);
dueDateEdit.setOnClickListener(new DebounceClickListener() { dueDateEdit.setOnClickListener(new DebounceClickListener() {
@Override @Override
public void onDebouncedClick(View v) { public void onDebouncedClick(View v) {
mDatePicker.show(); mDatePicker.show();
} }
}); });
productionDate.setOnClickListener(new DebounceClickListener() {
@Override
public void onDebouncedClick(View v) {
mDatePicker1.show();
}
});
TextView name = view.findViewById(R.id.name); TextView name = view.findViewById(R.id.name);
TextView code = view.findViewById(R.id.code); TextView code = view.findViewById(R.id.code);
TextView type = view.findViewById(R.id.type); TextView type = view.findViewById(R.id.type);
@ -785,27 +820,35 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
BigDecimal priceValue = new BigDecimal(goodsBean.getUnitPrice()); BigDecimal priceValue = new BigDecimal(goodsBean.getUnitPrice());
if (unit.getText().toString().equals("")) { if (unit.getText().toString().equals("")) {
weightView.setText(String.valueOf(weight * 2)); weightView.setText(String.valueOf(weight * 2));
BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100)); if ("enter".equals(pageType)){
BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getIntoNum()));
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
Log.e(TAG, "Weight: " + weight + ", Original number: " + originalNum.doubleValue() + ", Uninspected goods unInspectedGoodsNum: " + unInspectedGoodsNum);
if (weight * 2 >= originalNum.doubleValue()) {
enterWeight.setText(unInspectedGoodsNum + "");
} else {
enterWeight.setText(String.valueOf(weight * 2)); enterWeight.setText(String.valueOf(weight * 2));
}else{
BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100));
BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getIntoNum()));
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
Log.e(TAG, "Weight: " + weight + ", Original number: " + originalNum.doubleValue() + ", Uninspected goods unInspectedGoodsNum: " + unInspectedGoodsNum);
if (weight * 2 >= originalNum.doubleValue()) {
enterWeight.setText(unInspectedGoodsNum + "");
} else {
enterWeight.setText(String.valueOf(weight * 2));
}
} }
BigDecimal subtotalValue = new BigDecimal(enterWeight.getText().toString()).multiply(priceValue).divide(BigDecimal.valueOf(100)); BigDecimal subtotalValue = new BigDecimal(enterWeight.getText().toString()).multiply(priceValue).divide(BigDecimal.valueOf(100));
subtotal.setText(subtotalValue + ""); subtotal.setText(subtotalValue + "");
}else{ }else{
weightView.setText(String.valueOf(weight)); weightView.setText(String.valueOf(weight));
BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100)); if ("enter".equals(pageType)){
BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getIntoNum())); enterWeight.setText(String.valueOf(weight * 2));
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate); }else{
Log.e(TAG, "Weight: " + weight + ", Original number: " + originalNum.doubleValue() + ", Uninspected goods unInspectedGoodsNum: " + unInspectedGoodsNum); BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100));
if (weight >= originalNum.doubleValue()) { BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getIntoNum()));
enterWeight.setText(unInspectedGoodsNum + ""); BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
} else { Log.e(TAG, "Weight: " + weight + ", Original number: " + originalNum.doubleValue() + ", Uninspected goods unInspectedGoodsNum: " + unInspectedGoodsNum);
enterWeight.setText(String.valueOf(weight)); if (weight >= originalNum.doubleValue()) {
enterWeight.setText(unInspectedGoodsNum + "");
} else {
enterWeight.setText(String.valueOf(weight));
}
} }
BigDecimal subtotalValue = new BigDecimal(enterWeight.getText().toString()).multiply(priceValue).divide(BigDecimal.valueOf(100)); BigDecimal subtotalValue = new BigDecimal(enterWeight.getText().toString()).multiply(priceValue).divide(BigDecimal.valueOf(100));
subtotal.setText(subtotalValue + ""); subtotal.setText(subtotalValue + "");
@ -919,6 +962,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
View view = mPageMap.getOrDefault(mDestPage.getDisplayName(), null); View view = mPageMap.getOrDefault(mDestPage.getDisplayName(), null);
if (view != null) { if (view != null) {
TextView dateTextView = view.findViewById(R.id.dueDate); TextView dateTextView = view.findViewById(R.id.dueDate);
TextView productionDate = view.findViewById(R.id.productionDate);
TextView weightView = view.findViewById(R.id.weight); TextView weightView = view.findViewById(R.id.weight);
TextView enterWeight = view.findViewById(R.id.enter_weight); TextView enterWeight = view.findViewById(R.id.enter_weight);
TextView subtotal = view.findViewById(R.id.subtotal); TextView subtotal = view.findViewById(R.id.subtotal);
@ -936,9 +980,14 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
XToastUtils.warning("请先称重"); XToastUtils.warning("请先称重");
return; return;
} }
if (productionDate.getText().toString().isEmpty()) {
dialog.dismiss();
XToastUtils.warning("请选择生产日期");
return;
}
if (dateTextView.getText().toString().isEmpty()) { if (dateTextView.getText().toString().isEmpty()) {
dialog.dismiss(); dialog.dismiss();
XToastUtils.warning("请选择日期"); XToastUtils.warning("请选择到期日期");
return; return;
} }
if (subtotal.getText().toString().isEmpty()) { if (subtotal.getText().toString().isEmpty()) {
@ -957,6 +1006,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
goodsBean.setPurNum(enterWeight.getText().toString()); goodsBean.setPurNum(enterWeight.getText().toString());
goodsBean.setTotalPrice(String.valueOf(new BigDecimal(subtotal.getText().toString()).multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.DOWN).toPlainString())); goodsBean.setTotalPrice(String.valueOf(new BigDecimal(subtotal.getText().toString()).multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.DOWN).toPlainString()));
goodsBean.setExpireTime(dateTextView.getText().toString()); goodsBean.setExpireTime(dateTextView.getText().toString());
goodsBean.setProductDate(productionDate.getText().toString());
goodsBean.setImgUrl(goodsBean.getTakePhoto() != null ? goodsBean.getTakePhoto() : ""); goodsBean.setImgUrl(goodsBean.getTakePhoto() != null ? goodsBean.getTakePhoto() : "");
goodsBean.setSupplierId(supplierList.get(((MaterialSpinner) view.findViewById(R.id.supplier_spinner)).getSelectedIndex()).getSupplierId()); goodsBean.setSupplierId(supplierList.get(((MaterialSpinner) view.findViewById(R.id.supplier_spinner)).getSelectedIndex()).getSupplierId());
goodsBean.setSupplierName(supplierList.get(((MaterialSpinner) view.findViewById(R.id.supplier_spinner)).getSelectedIndex()).getSupplierName()); goodsBean.setSupplierName(supplierList.get(((MaterialSpinner) view.findViewById(R.id.supplier_spinner)).getSelectedIndex()).getSupplierName());

View File

@ -557,6 +557,9 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
private void uploadOutWarehouseData(List<GoodsBean> selectedGoods, ResponseCallBack callback) { private void uploadOutWarehouseData(List<GoodsBean> selectedGoods, ResponseCallBack callback) {
ThreadPoolManager.getExecutor().execute(() -> { ThreadPoolManager.getExecutor().execute(() -> {
String url = WorkConfig.getBaseUrl() + "/ims_fetch_material/app/outInventory"; String url = WorkConfig.getBaseUrl() + "/ims_fetch_material/app/outInventory";
if ("out".equals(pageType)){
url = WorkConfig.getBaseUrl() + "/ims/out-inventory";
}
BigDecimal totalNum = BigDecimal.ZERO; BigDecimal totalNum = BigDecimal.ZERO;
BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal totalAmount = BigDecimal.ZERO;
for (GoodsBean goods : selectedGoods) { for (GoodsBean goods : selectedGoods) {
@ -718,39 +721,62 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
TextView tvWeightView = view.findViewById(R.id.tv_weight); TextView tvWeightView = view.findViewById(R.id.tv_weight);
TextView weightView = view.findViewById(R.id.weight); TextView weightView = view.findViewById(R.id.weight);
TextView enterWeight = view.findViewById(R.id.enter_weight); TextView enterWeight = view.findViewById(R.id.enter_weight);
TextView num = view.findViewById(R.id.num);
if (unit.getText().toString().equals("")) { if (unit.getText().toString().equals("")) {
tvWeightView.setText(String.valueOf(weight * 2)); tvWeightView.setText(String.valueOf(weight * 2));
BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getOutCount())); if ("out".equals(pageType)){
BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100)); if (new BigDecimal(weight * 2).compareTo(new BigDecimal(num.getText().toString())) > 0) {
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate); enterWeight.setText(num.getText().toString());
Log.e(TAG,"unInspectedGoodsNum=" + unInspectedGoodsNum); weightView.setText(String.valueOf(weight * 2));
Log.e(TAG,"weight=" + weight); }else{
Log.e(TAG,"originalNum=" + originalNum); enterWeight.setText(String.valueOf(weight * 2));
if (weight * 2 >= originalNum.doubleValue()) { weightView.setText(String.valueOf(weight * 2));
enterWeight.setText(unInspectedGoodsNum + ""); }
weightView.setText(unInspectedGoodsNum + ""); } else{
} else { BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getOutCount()));
enterWeight.setText(String.valueOf(weight * 2)); BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100));
weightView.setText(String.valueOf(weight * 2)); BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
Log.e(TAG,"unInspectedGoodsNum=" + unInspectedGoodsNum);
Log.e(TAG,"weight=" + weight);
Log.e(TAG,"originalNum=" + originalNum);
if (weight * 2 >= originalNum.doubleValue()) {
enterWeight.setText(unInspectedGoodsNum + "");
weightView.setText(unInspectedGoodsNum + "");
} else {
enterWeight.setText(String.valueOf(weight * 2));
weightView.setText(String.valueOf(weight * 2));
}
} }
}else{ }else{
tvWeightView.setText(String.valueOf(weight)); tvWeightView.setText(String.valueOf(weight));
BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getMaterialTotalNum()).subtract(new BigDecimal(goodsBean.getOutCount())); if ("out".equals(pageType)){
BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100)); if (new BigDecimal(weight * 2).compareTo(new BigDecimal(num.getText().toString())) > 0) {
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate); enterWeight.setText(num.getText().toString());
Log.e(TAG,"goodsBean=" + goodsBean); weightView.setText(String.valueOf(weight));
Log.e(TAG,"getTotalQualifiedNum=" + goodsBean.getTotalQualifiedNum()); }else{
Log.e(TAG,"getOutCount=" + goodsBean.getOutCount()); enterWeight.setText(String.valueOf(weight));
Log.e(TAG,"unInspectedGoodsNum=" + unInspectedGoodsNum); weightView.setText(String.valueOf(weight));
Log.e(TAG,"weight=" + weight); }
Log.e(TAG,"originalNum=" + originalNum); }else{
if (weight >= originalNum.doubleValue()) { BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getMaterialTotalNum()).subtract(new BigDecimal(goodsBean.getOutCount()));
enterWeight.setText(unInspectedGoodsNum + ""); BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100));
weightView.setText(unInspectedGoodsNum + ""); BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
} else { Log.e(TAG,"goodsBean=" + goodsBean);
enterWeight.setText(String.valueOf(weight)); Log.e(TAG,"getTotalQualifiedNum=" + goodsBean.getTotalQualifiedNum());
weightView.setText(String.valueOf(weight)); Log.e(TAG,"getOutCount=" + goodsBean.getOutCount());
Log.e(TAG,"unInspectedGoodsNum=" + unInspectedGoodsNum);
Log.e(TAG,"weight=" + weight);
Log.e(TAG,"originalNum=" + originalNum);
if (weight >= originalNum.doubleValue()) {
enterWeight.setText(unInspectedGoodsNum + "");
weightView.setText(unInspectedGoodsNum + "");
} else {
enterWeight.setText(String.valueOf(weight));
weightView.setText(String.valueOf(weight));
}
} }
} }
}); });

View File

@ -100,10 +100,13 @@ public class ProductSelectionFragment extends BaseFragment<ActivityProductSelect
binding.nextStep.setVisibility(View.GONE); binding.nextStep.setVisibility(View.GONE);
initData(); initData();
} else { } else {
binding.areaSpinner.setVisibility(View.VISIBLE); binding.areaSpinner.setVisibility(View.GONE);
if (AppConstants.ENTER.equals(pageType)) { if (AppConstants.ENTER.equals(pageType)) {
binding.nextStep.setText("验货入库"); binding.nextStep.setText("验货入库");
binding.warehouseSpinner.setVisibility(View.GONE);
} else { } else {
binding.warehouseSpinner.setVisibility(View.VISIBLE);
initWarehouseSpinner("");
binding.nextStep.setText("验货出库"); binding.nextStep.setText("验货出库");
} }
initAreaSpinner(); initAreaSpinner();
@ -165,11 +168,24 @@ public class ProductSelectionFragment extends BaseFragment<ActivityProductSelect
List<GoodsBean> filteredList = goodsList.stream() List<GoodsBean> filteredList = goodsList.stream()
.filter(goods -> goods.getMaterialName().contains(searchText) || goods.getMaterialCode().contains(searchText)) .filter(goods -> goods.getMaterialName().contains(searchText) || goods.getMaterialCode().contains(searchText))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (pageType.equals("out")) {
String warehouseId = binding.warehouseSpinner.getSelectedItem() != null ? ((WarehouseBean) binding.warehouseSpinner.getSelectedItem()).getWarehouseId() : null;
Log.e(TAG, "Selected warehouseId: " + warehouseId);
filteredList = filteredList.stream()
.filter(goods -> {
if (StringHelper.isEmptyAndNull(goods.getWarehouseId()))
return false;
assert warehouseId != null;
return warehouseId.equals(goods.getWarehouseId());
})
.collect(Collectors.toList());
}
List<GoodsBean> finalFilteredList = filteredList;
requireActivity().runOnUiThread(() -> { requireActivity().runOnUiThread(() -> {
closeDialog(); closeDialog();
if (isDestroyed || !isAdded()) return; if (isDestroyed || !isAdded()) return;
goodsAdapter.updateGoodsList(filteredList); goodsAdapter.updateGoodsList(finalFilteredList);
if (filteredList.isEmpty()) { if (finalFilteredList.isEmpty()) {
binding.linearGoodsList.setVisibility(View.GONE); binding.linearGoodsList.setVisibility(View.GONE);
binding.noData.setVisibility(View.VISIBLE); binding.noData.setVisibility(View.VISIBLE);
} }
@ -179,7 +195,21 @@ public class ProductSelectionFragment extends BaseFragment<ActivityProductSelect
requireActivity().runOnUiThread(() -> { requireActivity().runOnUiThread(() -> {
closeDialog(); closeDialog();
if (isDestroyed || !isAdded()) return; if (isDestroyed || !isAdded()) return;
goodsAdapter = new GoodsAdapter(getContext(), goodsList, this, selectedGoodsIdList, pageType); String warehouseId = binding.warehouseSpinner.getSelectedItem() != null ? ((WarehouseBean) binding.warehouseSpinner.getSelectedItem()).getWarehouseId() : null;
if (pageType.equals("out") && !StringHelper.isEmptyAndNull(warehouseId)) {
Log.e(TAG, "Selected warehouseId: " + warehouseId);
List<GoodsBean> filteredList = goodsList.stream()
.filter(goods -> {
if (StringHelper.isEmptyAndNull(goods.getWarehouseId()))
return false;
assert warehouseId != null;
return warehouseId.equals(goods.getWarehouseId());
})
.collect(Collectors.toList());
goodsAdapter = new GoodsAdapter(getContext(), filteredList, this, selectedGoodsIdList, pageType);
}else{
goodsAdapter = new GoodsAdapter(getContext(), goodsList, this, selectedGoodsIdList, pageType);
}
gridView.setAdapter(goodsAdapter); gridView.setAdapter(goodsAdapter);
if (goodsList.isEmpty()) { if (goodsList.isEmpty()) {
binding.linearGoodsList.setVisibility(View.GONE); binding.linearGoodsList.setVisibility(View.GONE);
@ -216,6 +246,7 @@ public class ProductSelectionFragment extends BaseFragment<ActivityProductSelect
public void onDebouncedClick(View v) { public void onDebouncedClick(View v) {
selectedGoodsIdList = new ArrayList<>(); selectedGoodsIdList = new ArrayList<>();
binding.keyword.setText(""); binding.keyword.setText("");
binding.warehouseSpinner.setSelectedIndex(0);
binding.alreadySelectedNum.setText("已选择0"); binding.alreadySelectedNum.setText("已选择0");
initData(); initData();
} }

View File

@ -147,7 +147,25 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="320dp" android:layout_height="320dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp">
<TextView
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="生产日期" />
<EditText
android:id="@+id/productionDate"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/edittext_border"
android:editable="false"
android:hint="请选择日期" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp"> android:layout_height="80dp">