diff --git a/app/src/main/java/com/bonus/canteen/entity/GoodsBean.java b/app/src/main/java/com/bonus/canteen/entity/GoodsBean.java index eaca91c..8d1e53e 100644 --- a/app/src/main/java/com/bonus/canteen/entity/GoodsBean.java +++ b/app/src/main/java/com/bonus/canteen/entity/GoodsBean.java @@ -52,7 +52,9 @@ public class GoodsBean { private String unqualifiedNum; private String totalQualifiedNum; private String inventoryNum; + private String warehouseId; private String expireTime; + private String productDate; private String weight; private String takePhoto; private String intoNum; @@ -63,6 +65,22 @@ public class GoodsBean { 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() { return fetchDetailId; } @@ -318,6 +336,7 @@ public class GoodsBean { ", unqualifiedNum='" + unqualifiedNum + '\'' + ", inventoryNum='" + inventoryNum + '\'' + ", expireTime='" + expireTime + '\'' + + ", productDate='" + productDate + '\'' + ", weight='" + weight + '\'' + ", takePhoto='" + takePhoto + '\'' + ", ifFillInventory='" + ifFillInventory + '\'' + diff --git a/app/src/main/java/com/bonus/canteen/fragment/EnterFragment/InspectionWarehousingFragment.java b/app/src/main/java/com/bonus/canteen/fragment/EnterFragment/InspectionWarehousingFragment.java index a4275e2..d01822d 100644 --- a/app/src/main/java/com/bonus/canteen/fragment/EnterFragment/InspectionWarehousingFragment.java +++ b/app/src/main/java/com/bonus/canteen/fragment/EnterFragment/InspectionWarehousingFragment.java @@ -148,7 +148,7 @@ public class InspectionWarehousingFragment extends BaseFragment { + 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 goodsList = new ArrayList<>(); List supplierList = new ArrayList<>(); String pageType; @@ -204,6 +215,20 @@ public class InspectionWarehousingFragment extends BaseFragment { + //针对当前选择的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(); String selectedGoods = null; @@ -284,10 +309,12 @@ public class InspectionWarehousingFragment extends BaseFragment goods.getMaterialName().equals(pages[currentTabIndex])) @@ -298,6 +325,7 @@ public class InspectionWarehousingFragment extends BaseFragment= originalNum.doubleValue()) { - enterWeight.setText(unInspectedGoodsNum + ""); - } else { + if ("enter".equals(pageType)){ 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)); subtotal.setText(subtotalValue + ""); }else{ weightView.setText(String.valueOf(weight)); - 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 >= originalNum.doubleValue()) { - enterWeight.setText(unInspectedGoodsNum + ""); - } else { - enterWeight.setText(String.valueOf(weight)); + if ("enter".equals(pageType)){ + 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 >= originalNum.doubleValue()) { + enterWeight.setText(unInspectedGoodsNum + ""); + } else { + enterWeight.setText(String.valueOf(weight)); + } } BigDecimal subtotalValue = new BigDecimal(enterWeight.getText().toString()).multiply(priceValue).divide(BigDecimal.valueOf(100)); subtotal.setText(subtotalValue + ""); @@ -919,6 +962,7 @@ public class InspectionWarehousingFragment extends BaseFragment selectedGoods, ResponseCallBack callback) { ThreadPoolManager.getExecutor().execute(() -> { String url = WorkConfig.getBaseUrl() + "/ims_fetch_material/app/outInventory"; + if ("out".equals(pageType)){ + url = WorkConfig.getBaseUrl() + "/ims/out-inventory"; + } BigDecimal totalNum = BigDecimal.ZERO; BigDecimal totalAmount = BigDecimal.ZERO; for (GoodsBean goods : selectedGoods) { @@ -718,39 +721,62 @@ public class InspectionWarehousingOutFragment extends BaseFragment 0) { + enterWeight.setText(num.getText().toString()); + weightView.setText(String.valueOf(weight * 2)); + }else{ + enterWeight.setText(String.valueOf(weight * 2)); + weightView.setText(String.valueOf(weight * 2)); + } + } else{ + BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getOutCount())); + BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100)); + 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{ tvWeightView.setText(String.valueOf(weight)); - BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getMaterialTotalNum()).subtract(new BigDecimal(goodsBean.getOutCount())); - BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100)); - BigDecimal originalNum = unInspectedGoodsNum.multiply(rate); - Log.e(TAG,"goodsBean=" + goodsBean); - Log.e(TAG,"getTotalQualifiedNum=" + goodsBean.getTotalQualifiedNum()); - 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)); + if ("out".equals(pageType)){ + if (new BigDecimal(weight * 2).compareTo(new BigDecimal(num.getText().toString())) > 0) { + enterWeight.setText(num.getText().toString()); + weightView.setText(String.valueOf(weight)); + }else{ + enterWeight.setText(String.valueOf(weight)); + weightView.setText(String.valueOf(weight)); + } + }else{ + BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getMaterialTotalNum()).subtract(new BigDecimal(goodsBean.getOutCount())); + BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100)); + BigDecimal originalNum = unInspectedGoodsNum.multiply(rate); + Log.e(TAG,"goodsBean=" + goodsBean); + Log.e(TAG,"getTotalQualifiedNum=" + goodsBean.getTotalQualifiedNum()); + 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)); + } } + } }); diff --git a/app/src/main/java/com/bonus/canteen/fragment/commonFragment/ProductSelectionFragment.java b/app/src/main/java/com/bonus/canteen/fragment/commonFragment/ProductSelectionFragment.java index 20efead..415a711 100644 --- a/app/src/main/java/com/bonus/canteen/fragment/commonFragment/ProductSelectionFragment.java +++ b/app/src/main/java/com/bonus/canteen/fragment/commonFragment/ProductSelectionFragment.java @@ -100,10 +100,13 @@ public class ProductSelectionFragment extends BaseFragment filteredList = goodsList.stream() .filter(goods -> goods.getMaterialName().contains(searchText) || goods.getMaterialCode().contains(searchText)) .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 finalFilteredList = filteredList; requireActivity().runOnUiThread(() -> { closeDialog(); if (isDestroyed || !isAdded()) return; - goodsAdapter.updateGoodsList(filteredList); - if (filteredList.isEmpty()) { + goodsAdapter.updateGoodsList(finalFilteredList); + if (finalFilteredList.isEmpty()) { binding.linearGoodsList.setVisibility(View.GONE); binding.noData.setVisibility(View.VISIBLE); } @@ -179,7 +195,21 @@ public class ProductSelectionFragment extends BaseFragment { closeDialog(); 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 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); if (goodsList.isEmpty()) { binding.linearGoodsList.setVisibility(View.GONE); @@ -216,6 +246,7 @@ public class ProductSelectionFragment extends BaseFragment(); binding.keyword.setText(""); + binding.warehouseSpinner.setSelectedIndex(0); binding.alreadySelectedNum.setText("已选择:0"); initData(); } diff --git a/app/src/main/res/layout/item_inspection_warehousing.xml b/app/src/main/res/layout/item_inspection_warehousing.xml index 923920a..044b208 100644 --- a/app/src/main/res/layout/item_inspection_warehousing.xml +++ b/app/src/main/res/layout/item_inspection_warehousing.xml @@ -147,7 +147,25 @@ android:layout_width="match_parent" android:layout_height="320dp" android:orientation="vertical"> + + + + +