bug修改
This commit is contained in:
parent
ef6fcf9df6
commit
c338ca4314
|
|
@ -19,6 +19,7 @@ package com.bonus.canteen.fragment.EnterFragment;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
|
@ -67,6 +68,7 @@ import androidx.viewpager.widget.ViewPager;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.bonus.canteen.activity.LoginActivity;
|
import com.bonus.canteen.activity.LoginActivity;
|
||||||
|
import com.bonus.canteen.activity.MainActivity;
|
||||||
import com.bonus.canteen.constants.AppConstants;
|
import com.bonus.canteen.constants.AppConstants;
|
||||||
import com.bonus.canteen.core.BaseFragment;
|
import com.bonus.canteen.core.BaseFragment;
|
||||||
import com.bonus.canteen.db.AppDatabase;
|
import com.bonus.canteen.db.AppDatabase;
|
||||||
|
|
@ -168,6 +170,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
List<MaterialRequesterBean> userList = new ArrayList<>();
|
List<MaterialRequesterBean> userList = new ArrayList<>();
|
||||||
List<WarehouseBean> warehouseList = new ArrayList<>();
|
List<WarehouseBean> warehouseList = new ArrayList<>();
|
||||||
String relateOrderGoodsId;
|
String relateOrderGoodsId;
|
||||||
|
boolean isUpload = false;
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected ActivityInspectionWarehouseBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
|
protected ActivityInspectionWarehouseBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
|
||||||
|
|
@ -185,6 +188,7 @@ 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) {
|
private void showDatePickerDialog1(OnDateSelectedListener listener) {
|
||||||
mDatePicker1 = new TimePickerBuilder(requireContext(), (date, v) -> {
|
mDatePicker1 = new TimePickerBuilder(requireContext(), (date, v) -> {
|
||||||
String dayTime = DateTimeHelper.format(date, "yyyy-MM-dd");
|
String dayTime = DateTimeHelper.format(date, "yyyy-MM-dd");
|
||||||
|
|
@ -196,9 +200,11 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
.setType(true, true, true, false, false, false)
|
.setType(true, true, true, false, false, false)
|
||||||
.build();
|
.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;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initViews() {
|
protected void initViews() {
|
||||||
showDatePickerDialog(date -> {
|
showDatePickerDialog(date -> {
|
||||||
|
|
@ -236,7 +242,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
selectedGoods = args.getString("selectedGoods");
|
selectedGoods = args.getString("selectedGoods");
|
||||||
pageType = args.getString("pageType");
|
pageType = args.getString("pageType");
|
||||||
relateOrderGoodsId = args.getString("relateOrderGoodsId");
|
relateOrderGoodsId = args.getString("relateOrderGoodsId");
|
||||||
if (StringHelper.isEmptyAndNull(pageType)){
|
if (StringHelper.isEmptyAndNull(pageType)) {
|
||||||
pageType = ENTER; // 默认值为"enter"
|
pageType = ENTER; // 默认值为"enter"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -248,13 +254,18 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
// 解析selectedGoods为GoodsBean列表
|
// 解析selectedGoods为GoodsBean列表
|
||||||
goodsList = JSON.parseArray(selectedGoods, GoodsBean.class);
|
goodsList = JSON.parseArray(selectedGoods, GoodsBean.class);
|
||||||
|
goodsList = goodsList.stream().filter(name -> name.getMaterialName() != null && !name.getMaterialName().isEmpty())
|
||||||
|
.collect(Collectors.toList());
|
||||||
pages = goodsList.stream()
|
pages = goodsList.stream()
|
||||||
.map(GoodsBean::getMaterialName).toArray(String[]::new);
|
.map(GoodsBean::getMaterialName)
|
||||||
|
.filter(name -> name != null && !name.isEmpty())
|
||||||
|
.toArray(String[]::new);
|
||||||
pagesList = List.of(pages);
|
pagesList = List.of(pages);
|
||||||
MultiPage[] multiPages = MultiPage.fromList(pagesList);
|
MultiPage[] multiPages = MultiPage.fromList(pagesList);
|
||||||
mDestPage = multiPages[0];
|
mDestPage = multiPages[0];
|
||||||
TAB_COUNT = pagesList.size();
|
TAB_COUNT = pagesList.size();
|
||||||
|
|
||||||
|
|
||||||
mCurrentItemCount = TAB_COUNT;
|
mCurrentItemCount = TAB_COUNT;
|
||||||
mTabSegment = findViewById(R.id.tabSegment);
|
mTabSegment = findViewById(R.id.tabSegment);
|
||||||
mContentViewPager = findViewById(R.id.contentViewPager);
|
mContentViewPager = findViewById(R.id.contentViewPager);
|
||||||
|
|
@ -287,7 +298,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
Log.e(TAG, "SurfaceView is null for page: " + mDestPage.getDisplayName());
|
Log.e(TAG, "SurfaceView is null for page: " + mDestPage.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Error in onLayoutChange: ", e);
|
Log.e(TAG, "Error in onLayoutChange: ", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -296,6 +307,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
initMaterialRequesterSpinner();
|
initMaterialRequesterSpinner();
|
||||||
mHandler.postDelayed(this::initScale, 2000);
|
mHandler.postDelayed(this::initScale, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initListeners() {
|
protected void initListeners() {
|
||||||
binding.clear.setOnClickListener(new DebounceClickListener() {
|
binding.clear.setOnClickListener(new DebounceClickListener() {
|
||||||
|
|
@ -384,25 +396,60 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
binding.confirmEnterWarehouse.setOnClickListener(new DebounceClickListener() {
|
binding.confirmEnterWarehouse.setOnClickListener(new DebounceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDebouncedClick(View v) {
|
public void onDebouncedClick(View v) {
|
||||||
boolean isPass = handlerResultParameters(goodsList);
|
if (isUpload){
|
||||||
if (!isPass) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uploadEnterWarehouseData(goodsList, new ResponseCallBack() {
|
isUpload = true;
|
||||||
|
List<GoodsBean> emptyGoods = goodsList.stream()
|
||||||
|
.filter(goods -> StringHelper.isEmptyAndNull(goods.getWeight()) || Double.parseDouble(goods.getWeight()) <= 0)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<GoodsBean> filteredGoods = goodsList.stream()
|
||||||
|
.filter(goods -> !StringHelper.isEmptyAndNull(goods.getWeight()) && Double.parseDouble(goods.getWeight()) > 0)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
Log.e(TAG, "Empty Goods: " + emptyGoods);
|
||||||
|
boolean isPass = handlerResultParameters(filteredGoods);
|
||||||
|
if (!isPass) {
|
||||||
|
isUpload = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!emptyGoods.isEmpty()) {
|
||||||
|
new MaterialDialog.Builder(requireContext())
|
||||||
|
.iconRes(R.drawable.icon_tip)
|
||||||
|
.limitIconToDefaultSize()
|
||||||
|
.title("提示")
|
||||||
|
.content("当前有部分货品信息未填写完整,是否继续入库?")
|
||||||
|
.positiveText("继续")
|
||||||
|
.onPositive((poDialog,s) -> uploadEnterWarehouseData(new ArrayList<>(filteredGoods), new ResponseCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
isUpload = false;
|
||||||
XToastUtils.success("入库成功!");
|
XToastUtils.success("入库成功!");
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("pageType", pageType);
|
bundle.putString("pageType", pageType);
|
||||||
CompleteWarehouseEntryFragment completeWarehouseEntryFragment = new CompleteWarehouseEntryFragment();
|
CompleteWarehouseEntryFragment completeWarehouseEntryFragment = new CompleteWarehouseEntryFragment();
|
||||||
completeWarehouseEntryFragment.setArguments(bundle);
|
completeWarehouseEntryFragment.setArguments(bundle);
|
||||||
switchPage(completeWarehouseEntryFragment, CompleteWarehouseEntryFragment.class);
|
switchPage(completeWarehouseEntryFragment, CompleteWarehouseEntryFragment.class);
|
||||||
|
poDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFail(String msg) {
|
public void onFail(String msg) {
|
||||||
|
isUpload = false;
|
||||||
requireActivity().runOnUiThread(() -> XToastUtils.error(msg));
|
requireActivity().runOnUiThread(() -> XToastUtils.error(msg));
|
||||||
}
|
}
|
||||||
});
|
}))
|
||||||
|
.negativeText("取消")
|
||||||
|
.onNegative((dialog, which) -> {
|
||||||
|
isUpload = false;
|
||||||
|
dialog.dismiss();
|
||||||
|
})
|
||||||
|
.progress(true, 0)
|
||||||
|
.progressIndeterminateStyle(false)
|
||||||
|
.cancelable(false)
|
||||||
|
.show();
|
||||||
|
}else {
|
||||||
|
isUpload = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
binding.saveData.setOnClickListener(new DebounceClickListener() {
|
binding.saveData.setOnClickListener(new DebounceClickListener() {
|
||||||
|
|
@ -412,10 +459,9 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private boolean handlerResultParameters(List<GoodsBean> selectedGoods) {
|
|
||||||
List<GoodsBean> filteredGoods = selectedGoods.stream()
|
private boolean handlerResultParameters(List<GoodsBean> filteredGoods) {
|
||||||
.filter(goods -> !StringHelper.isEmptyAndNull(goods.getWeight()) && Double.parseDouble(goods.getWeight()) > 0)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
// for (GoodsBean goods : selectedGoods) {
|
// for (GoodsBean goods : selectedGoods) {
|
||||||
// Log.e(TAG, "Selected Goods: " + goods);
|
// Log.e(TAG, "Selected Goods: " + goods);
|
||||||
// if (StringHelper.isEmptyAndNull(goods.getWeight()) || Double.parseDouble(goods.getWeight()) <= 0) {
|
// if (StringHelper.isEmptyAndNull(goods.getWeight()) || Double.parseDouble(goods.getWeight()) <= 0) {
|
||||||
|
|
@ -427,11 +473,10 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if (filteredGoods.isEmpty()){
|
if (filteredGoods.isEmpty()) {
|
||||||
XToastUtils.info("请至少选择一个货品并进行重量!");
|
XToastUtils.info("请先保存相关货品入库信息!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
goodsList = new ArrayList<>(filteredGoods);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -473,8 +518,9 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSupplierList(MaterialSpinner supplierSpinner) {
|
private void initSupplierList(MaterialSpinner supplierSpinner) {
|
||||||
ThreadPoolManager.getExecutor().execute(() ->{
|
ThreadPoolManager.getExecutor().execute(() -> {
|
||||||
String url = WorkConfig.getBaseUrl() + "/ims_supplier/list?pageSize=" + 1000 + "&pageNum=" + 1;
|
String url = WorkConfig.getBaseUrl() + "/ims_supplier/list?pageSize=" + 1000 + "&pageNum=" + 1;
|
||||||
String result = service.httpGet(url, requireContext());
|
String result = service.httpGet(url, requireContext());
|
||||||
Log.i(TAG, "result==" + result);
|
Log.i(TAG, "result==" + result);
|
||||||
|
|
@ -487,7 +533,8 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void initWarehouseSpinner(){
|
|
||||||
|
private void initWarehouseSpinner() {
|
||||||
ThreadPoolManager.getExecutor().execute(() -> {
|
ThreadPoolManager.getExecutor().execute(() -> {
|
||||||
String url = WorkConfig.getBaseUrl() + "/ims_warehouse_info/list?pageSize=" + 1000 + "&pageNum=" + 1;
|
String url = WorkConfig.getBaseUrl() + "/ims_warehouse_info/list?pageSize=" + 1000 + "&pageNum=" + 1;
|
||||||
String result = service.httpGet(url, requireContext());
|
String result = service.httpGet(url, requireContext());
|
||||||
|
|
@ -507,6 +554,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initInboundSpinners() {
|
private void initInboundSpinners() {
|
||||||
//设置入库类型选择器
|
//设置入库类型选择器
|
||||||
List<SpinnerBean> inboundTypes = new ArrayList<>();
|
List<SpinnerBean> inboundTypes = new ArrayList<>();
|
||||||
|
|
@ -523,8 +571,9 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void initMaterialRequesterSpinner(){
|
|
||||||
ThreadPoolManager.getExecutor().execute(() ->{
|
private void initMaterialRequesterSpinner() {
|
||||||
|
ThreadPoolManager.getExecutor().execute(() -> {
|
||||||
String url = WorkConfig.getPrefixesUrl() + "/system/user/list?pageSize=" + 1000 + "&pageNum=" + 1 + "&roleIds=125";
|
String url = WorkConfig.getPrefixesUrl() + "/system/user/list?pageSize=" + 1000 + "&pageNum=" + 1 + "&roleIds=125";
|
||||||
String result = service.httpGet(url, requireContext());
|
String result = service.httpGet(url, requireContext());
|
||||||
Log.i(TAG, "result==" + result);
|
Log.i(TAG, "result==" + result);
|
||||||
|
|
@ -535,7 +584,8 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
String json = JSONObject.parseObject(result).getString("rows");
|
String json = JSONObject.parseObject(result).getString("rows");
|
||||||
if (json != null && !json.isEmpty()) {
|
if (json != null && !json.isEmpty()) {
|
||||||
userList = new Gson().fromJson(json, new TypeToken<List<MaterialRequesterBean>>() {}.getType());
|
userList = new Gson().fromJson(json, new TypeToken<List<MaterialRequesterBean>>() {
|
||||||
|
}.getType());
|
||||||
Log.e(TAG, "User List: " + userList);
|
Log.e(TAG, "User List: " + userList);
|
||||||
if (!userList.isEmpty()) {
|
if (!userList.isEmpty()) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
|
@ -546,6 +596,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private PagerAdapter mPagerAdapter = new PagerAdapter() {
|
private PagerAdapter mPagerAdapter = new PagerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
|
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
|
||||||
|
|
@ -623,14 +674,14 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
price.setText(StringHelper.isEmptyAndNull(goodsBean.getUnitPrice()) ? "0" : new BigDecimal(goodsBean.getUnitPrice()).divide(BigDecimal.valueOf(100)).toString());
|
price.setText(StringHelper.isEmptyAndNull(goodsBean.getUnitPrice()) ? "0" : new BigDecimal(goodsBean.getUnitPrice()).divide(BigDecimal.valueOf(100)).toString());
|
||||||
weight.setText("0");
|
weight.setText("0");
|
||||||
enterWeight.setText("0");
|
enterWeight.setText("0");
|
||||||
if (!StringHelper.isEmptyAndNull(goodsBean.getSupplierName())){
|
if (!StringHelper.isEmptyAndNull(goodsBean.getSupplierName())) {
|
||||||
int index = supplierList.stream()
|
int index = supplierList.stream()
|
||||||
.map(SupplierBean::getSupplierName)
|
.map(SupplierBean::getSupplierName)
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
.indexOf(goodsBean.getSupplierName());
|
.indexOf(goodsBean.getSupplierName());
|
||||||
// 设置供应商下拉框
|
// 设置供应商下拉框
|
||||||
supplierSpinner.setSelectedIndex(index);
|
supplierSpinner.setSelectedIndex(index);
|
||||||
}else{
|
} else {
|
||||||
supplierSpinner.setSelectedIndex(0); // 默认选择第一个供应商
|
supplierSpinner.setSelectedIndex(0); // 默认选择第一个供应商
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -820,9 +871,9 @@ 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));
|
||||||
if ("enter".equals(pageType)){
|
if ("enter".equals(pageType)) {
|
||||||
enterWeight.setText(String.valueOf(weight * 2));
|
enterWeight.setText(String.valueOf(weight * 2));
|
||||||
}else{
|
} else {
|
||||||
BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100));
|
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 unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getIntoNum()));
|
||||||
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
|
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
|
||||||
|
|
@ -835,11 +886,11 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
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));
|
||||||
if ("enter".equals(pageType)){
|
if ("enter".equals(pageType)) {
|
||||||
enterWeight.setText(String.valueOf(weight * 2));
|
enterWeight.setText(String.valueOf(weight));
|
||||||
}else{
|
} else {
|
||||||
BigDecimal rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100));
|
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 unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getIntoNum()));
|
||||||
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
|
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
|
||||||
|
|
@ -917,7 +968,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
public void roundOffWeight(){
|
public void roundOffWeight() {
|
||||||
if (mDestPage != null) {
|
if (mDestPage != null) {
|
||||||
View view = mPageMap.getOrDefault(mDestPage.getDisplayName(), null);
|
View view = mPageMap.getOrDefault(mDestPage.getDisplayName(), null);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
|
|
@ -947,6 +998,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
Log.e(TAG, "Current page is null.");
|
Log.e(TAG, "Current page is null.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GoodsBean> getResult() {
|
public List<GoodsBean> getResult() {
|
||||||
if (goodsList.isEmpty()) {
|
if (goodsList.isEmpty()) {
|
||||||
XToastUtils.error("没有可用的货品数据");
|
XToastUtils.error("没有可用的货品数据");
|
||||||
|
|
@ -990,6 +1042,12 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
XToastUtils.warning("请选择到期日期");
|
XToastUtils.warning("请选择到期日期");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//日期比对
|
||||||
|
if (DateTimeHelper.compareDate(productionDate.getText().toString(), dateTextView.getText().toString()) > 0) {
|
||||||
|
dialog.dismiss();
|
||||||
|
XToastUtils.warning("生产日期不能大于到期日期");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (subtotal.getText().toString().isEmpty()) {
|
if (subtotal.getText().toString().isEmpty()) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
XToastUtils.warning("小计不能为空");
|
XToastUtils.warning("小计不能为空");
|
||||||
|
|
@ -1236,6 +1294,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
Log.e(TAG, "保存图片失败: " + e.getMessage());
|
Log.e(TAG, "保存图片失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传照片
|
* 上传照片
|
||||||
* 使用OkHttpService上传图片到服务器
|
* 使用OkHttpService上传图片到服务器
|
||||||
|
|
@ -1253,7 +1312,7 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
if (!ObjectUtil.isEmpty(res)) {
|
if (!ObjectUtil.isEmpty(res)) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(res);
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
||||||
if (!jsonObject.containsKey("data")) {
|
if (!jsonObject.containsKey("data")) {
|
||||||
if (jsonObject.getInteger("code") == 401){
|
if (jsonObject.getInteger("code") == 401) {
|
||||||
Intent intent = new Intent(requireActivity(), LoginActivity.class);
|
Intent intent = new Intent(requireActivity(), LoginActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
@ -1349,7 +1408,6 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 尺寸比较器
|
// 尺寸比较器
|
||||||
class CompareSizesByArea implements Comparator<Size> {
|
class CompareSizesByArea implements Comparator<Size> {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1446,7 +1504,9 @@ public class InspectionWarehousingFragment extends BaseFragment<ActivityInspecti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaterialDialog dialog;
|
private MaterialDialog dialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 带圆形Loading的Dialog
|
* 带圆形Loading的Dialog
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -67,12 +67,14 @@ import androidx.viewpager.widget.ViewPager;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.bonus.canteen.activity.LoginActivity;
|
import com.bonus.canteen.activity.LoginActivity;
|
||||||
|
import com.bonus.canteen.activity.MainActivity;
|
||||||
import com.bonus.canteen.constants.AppConstants;
|
import com.bonus.canteen.constants.AppConstants;
|
||||||
import com.bonus.canteen.core.BaseFragment;
|
import com.bonus.canteen.core.BaseFragment;
|
||||||
import com.bonus.canteen.db.AppDatabase;
|
import com.bonus.canteen.db.AppDatabase;
|
||||||
import com.bonus.canteen.db.entity.base.LoginInfo;
|
import com.bonus.canteen.db.entity.base.LoginInfo;
|
||||||
import com.bonus.canteen.db.entity.base.ParamSettingInfo;
|
import com.bonus.canteen.db.entity.base.ParamSettingInfo;
|
||||||
import com.bonus.canteen.entity.GoodsBean;
|
import com.bonus.canteen.entity.GoodsBean;
|
||||||
|
import com.bonus.canteen.entity.GoodsUploadBean;
|
||||||
import com.bonus.canteen.entity.MaterialRequesterBean;
|
import com.bonus.canteen.entity.MaterialRequesterBean;
|
||||||
import com.bonus.canteen.entity.PhotoResponse;
|
import com.bonus.canteen.entity.PhotoResponse;
|
||||||
import com.bonus.canteen.entity.SpinnerBean;
|
import com.bonus.canteen.entity.SpinnerBean;
|
||||||
|
|
@ -165,13 +167,15 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
List<MaterialRequesterBean> userList = new ArrayList<>();
|
List<MaterialRequesterBean> userList = new ArrayList<>();
|
||||||
List<WarehouseBean> warehouseList = new ArrayList<>();
|
List<WarehouseBean> warehouseList = new ArrayList<>();
|
||||||
String pageType;
|
String pageType;
|
||||||
String fetchMaterialCode,fetchId;
|
String fetchMaterialCode, fetchId;
|
||||||
String fetchDetailId;
|
String fetchDetailId;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected ActivityInspectionWarehouseBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
|
protected ActivityInspectionWarehouseBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
|
||||||
return ActivityInspectionWarehouseBinding.inflate(inflater, container, attachToRoot);
|
return ActivityInspectionWarehouseBinding.inflate(inflater, container, attachToRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<GoodsBean> goodsList = new ArrayList<>();
|
List<GoodsBean> goodsList = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -185,7 +189,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
fetchMaterialCode = args.getString("fetchMaterialCode");
|
fetchMaterialCode = args.getString("fetchMaterialCode");
|
||||||
fetchId = args.getString("fetchMaterialId");
|
fetchId = args.getString("fetchMaterialId");
|
||||||
fetchDetailId = args.getString("fetchDetailId");
|
fetchDetailId = args.getString("fetchDetailId");
|
||||||
if (StringHelper.isEmptyAndNull(pageType)){
|
if (StringHelper.isEmptyAndNull(pageType)) {
|
||||||
pageType = OUT;
|
pageType = OUT;
|
||||||
}
|
}
|
||||||
binding.cancelEnterWarehouse.setText("取消出库");
|
binding.cancelEnterWarehouse.setText("取消出库");
|
||||||
|
|
@ -196,8 +200,12 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goodsList = JSON.parseArray(selectedGoods, GoodsBean.class);
|
goodsList = JSON.parseArray(selectedGoods, GoodsBean.class);
|
||||||
|
goodsList = goodsList.stream().filter(name -> name.getMaterialName() != null && !name.getMaterialName().isEmpty())
|
||||||
|
.collect(Collectors.toList());
|
||||||
pages = goodsList.stream()
|
pages = goodsList.stream()
|
||||||
.map(GoodsBean::getMaterialName).toArray(String[]::new);
|
.map(GoodsBean::getMaterialName)
|
||||||
|
.filter(name -> name != null && !name.isEmpty())
|
||||||
|
.toArray(String[]::new);
|
||||||
pagesList = List.of(pages);
|
pagesList = List.of(pages);
|
||||||
MultiPage[] multiPages = MultiPage.fromList(pagesList);
|
MultiPage[] multiPages = MultiPage.fromList(pagesList);
|
||||||
mDestPage = multiPages[0];
|
mDestPage = multiPages[0];
|
||||||
|
|
@ -235,7 +243,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
Log.e(TAG, "SurfaceView is null for page: " + mDestPage.getDisplayName());
|
Log.e(TAG, "SurfaceView is null for page: " + mDestPage.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Error in onLayoutChange: ", e);
|
Log.e(TAG, "Error in onLayoutChange: ", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -244,7 +252,8 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
initMaterialRequesterSpinner();
|
initMaterialRequesterSpinner();
|
||||||
mHandler.postDelayed(this::initScale, 2000);
|
mHandler.postDelayed(this::initScale, 2000);
|
||||||
}
|
}
|
||||||
private void initWarehouseSpinner(){
|
|
||||||
|
private void initWarehouseSpinner() {
|
||||||
ThreadPoolManager.getExecutor().execute(() -> {
|
ThreadPoolManager.getExecutor().execute(() -> {
|
||||||
String url = WorkConfig.getBaseUrl() + "/ims_warehouse_info/list?pageSize=" + 1000 + "&pageNum=" + 1;
|
String url = WorkConfig.getBaseUrl() + "/ims_warehouse_info/list?pageSize=" + 1000 + "&pageNum=" + 1;
|
||||||
String result = service.httpGet(url, requireContext());
|
String result = service.httpGet(url, requireContext());
|
||||||
|
|
@ -264,6 +273,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initOutboundSpinners() {
|
private void initOutboundSpinners() {
|
||||||
//设置入库类型选择器
|
//设置入库类型选择器
|
||||||
List<SpinnerBean> inboundTypes = new ArrayList<>();
|
List<SpinnerBean> inboundTypes = new ArrayList<>();
|
||||||
|
|
@ -281,8 +291,9 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void initMaterialRequesterSpinner(){
|
|
||||||
ThreadPoolManager.getExecutor().execute(() ->{
|
private void initMaterialRequesterSpinner() {
|
||||||
|
ThreadPoolManager.getExecutor().execute(() -> {
|
||||||
String url = WorkConfig.getPrefixesUrl() + "/system/user/list?pageSize=" + 1000 + "&pageNum=" + 1 + "&roleIds=124";
|
String url = WorkConfig.getPrefixesUrl() + "/system/user/list?pageSize=" + 1000 + "&pageNum=" + 1 + "&roleIds=124";
|
||||||
String result = service.httpGet(url, requireContext());
|
String result = service.httpGet(url, requireContext());
|
||||||
Log.i(TAG, "result==" + result);
|
Log.i(TAG, "result==" + result);
|
||||||
|
|
@ -293,11 +304,12 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
}
|
}
|
||||||
String json = JSONObject.parseObject(result).getString("rows");
|
String json = JSONObject.parseObject(result).getString("rows");
|
||||||
if (json != null && !json.isEmpty()) {
|
if (json != null && !json.isEmpty()) {
|
||||||
userList = new Gson().fromJson(json, new TypeToken<List<MaterialRequesterBean>>() {}.getType());
|
userList = new Gson().fromJson(json, new TypeToken<List<MaterialRequesterBean>>() {
|
||||||
|
}.getType());
|
||||||
Log.e(TAG, "User List: " + userList);
|
Log.e(TAG, "User List: " + userList);
|
||||||
if (!userList.isEmpty()) {
|
if (!userList.isEmpty()) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
if (isAdded()){
|
if (isAdded()) {
|
||||||
binding.enterPersonSpinner.setItems(userList);
|
binding.enterPersonSpinner.setItems(userList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -306,6 +318,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private PagerAdapter mPagerAdapter = new PagerAdapter() {
|
private PagerAdapter mPagerAdapter = new PagerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
|
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
|
||||||
|
|
@ -433,13 +446,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
View view = mPageMap.get(pages[currentTabIndex]);
|
View view = mPageMap.get(pages[currentTabIndex]);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
TextView weightView = view.findViewById(R.id.weight);
|
TextView weightView = view.findViewById(R.id.weight);
|
||||||
TextView subtotal = view.findViewById(R.id.subtotal);
|
|
||||||
EditText dueDateEdit = view.findViewById(R.id.dueDate);
|
|
||||||
MaterialSpinner supplierSpinner = view.findViewById(R.id.supplier_spinner);
|
|
||||||
weightView.setText("0");
|
weightView.setText("0");
|
||||||
subtotal.setText("0");
|
|
||||||
dueDateEdit.setText("");
|
|
||||||
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]))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
|
@ -521,6 +528,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
completeWarehouseEntryFragment.setArguments(bundle);
|
completeWarehouseEntryFragment.setArguments(bundle);
|
||||||
switchPage(completeWarehouseEntryFragment, CompleteWarehouseEntryFragment.class);
|
switchPage(completeWarehouseEntryFragment, CompleteWarehouseEntryFragment.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFail(String msg) {
|
public void onFail(String msg) {
|
||||||
requireActivity().runOnUiThread(() -> XToastUtils.error(msg));
|
requireActivity().runOnUiThread(() -> XToastUtils.error(msg));
|
||||||
|
|
@ -535,12 +543,13 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handlerResultParameters(List<GoodsBean> selectedGoods) {
|
private boolean handlerResultParameters(List<GoodsBean> selectedGoods) {
|
||||||
List<GoodsBean> filteredGoods = new ArrayList<>(selectedGoods.stream()
|
List<GoodsBean> filteredGoods = new ArrayList<>(selectedGoods.stream()
|
||||||
.filter(goods -> !StringHelper.isEmptyAndNull(goods.getFetchNum()) && Double.parseDouble(goods.getFetchNum()) > 0)
|
.filter(goods -> !StringHelper.isEmptyAndNull(goods.getFetchNum()) && Double.parseDouble(goods.getFetchNum()) > 0)
|
||||||
.collect(Collectors.toMap(GoodsBean::getMaterialCode, goods -> goods, (g1, g2) -> g1))
|
.collect(Collectors.toMap(GoodsBean::getMaterialCode, goods -> goods, (g1, g2) -> g1))
|
||||||
.values());
|
.values());
|
||||||
if (filteredGoods.isEmpty()){
|
if (filteredGoods.isEmpty()) {
|
||||||
XToastUtils.info("请至少选择一个货品并进行重量!");
|
XToastUtils.info("请至少选择一个货品并进行重量!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -554,19 +563,31 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
// }
|
// }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void uploadOutWarehouseData(List<GoodsBean> selectedGoods, ResponseCallBack callback) {
|
|
||||||
|
private void uploadOutWarehouseData(List<GoodsBean> list, ResponseCallBack callback) {
|
||||||
|
Log.e(TAG, "Uploading Out Warehouse Data: " + list);
|
||||||
|
List<GoodsUploadBean> selectedGoods = list.stream()
|
||||||
|
.map(goods -> {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
GoodsUploadBean goodsUploadBean = gson.fromJson(gson.toJson(goods), GoodsUploadBean.class);
|
||||||
|
goodsUploadBean.setTotalPrice(new BigDecimal(goodsUploadBean.getTotalPrice()).setScale(0, RoundingMode.DOWN).toPlainString());
|
||||||
|
return goodsUploadBean;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
Log.e(TAG, "Uploading Out Warehouse Data: " + selectedGoods);
|
||||||
ThreadPoolManager.getExecutor().execute(() -> {
|
ThreadPoolManager.getExecutor().execute(() -> {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
String url = WorkConfig.getBaseUrl() + "/ims_fetch_material/app/outInventory";
|
String url = WorkConfig.getBaseUrl() + "/ims_fetch_material/app/outInventory";
|
||||||
if ("out".equals(pageType)){
|
if ("out".equals(pageType)) {
|
||||||
url = WorkConfig.getBaseUrl() + "/ims/out-inventory";
|
url = WorkConfig.getBaseUrl() + "/ims/out-inventory";
|
||||||
}
|
}
|
||||||
|
Log.e(TAG, "uploadOutWarehouseData url: " + url);
|
||||||
BigDecimal totalNum = BigDecimal.ZERO;
|
BigDecimal totalNum = BigDecimal.ZERO;
|
||||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
for (GoodsBean goods : selectedGoods) {
|
for (GoodsUploadBean goods : selectedGoods) {
|
||||||
totalNum = totalNum.add(new BigDecimal(goods.getWeight()));
|
totalNum = totalNum.add(new BigDecimal(goods.getWeight()));
|
||||||
totalAmount = totalAmount.add(new BigDecimal(goods.getTotalPrice()));
|
totalAmount = totalAmount.add(new BigDecimal(goods.getTotalPrice()));
|
||||||
}
|
}
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
json.put("warehouseId", ((WarehouseBean) binding.warehouseSpinner.getSelectedItem()).getWarehouseId());
|
json.put("warehouseId", ((WarehouseBean) binding.warehouseSpinner.getSelectedItem()).getWarehouseId());
|
||||||
json.put("fetchUserId", ((MaterialRequesterBean) binding.enterPersonSpinner.getSelectedItem()).getUserId());
|
json.put("fetchUserId", ((MaterialRequesterBean) binding.enterPersonSpinner.getSelectedItem()).getUserId());
|
||||||
json.put("outDate", DateTimeHelper.getTime());
|
json.put("outDate", DateTimeHelper.getTime());
|
||||||
|
|
@ -597,6 +618,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initScale() {
|
private void initScale() {
|
||||||
if (serialPort != null) {
|
if (serialPort != null) {
|
||||||
serialPort.close();
|
serialPort.close();
|
||||||
|
|
@ -707,7 +729,13 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
if (mDestPage != null) {
|
if (mDestPage != null) {
|
||||||
View view = mPageMap.getOrDefault(mDestPage.getDisplayName(), null);
|
View view = mPageMap.getOrDefault(mDestPage.getDisplayName(), null);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
ParamSettingInfo paramSettingInfo = AppDatabase.getDatabase(requireContext()).parameterInfoDao().getOneInfo();
|
ParamSettingInfo paramSettingInfo;
|
||||||
|
try {
|
||||||
|
paramSettingInfo = AppDatabase.getDatabase(requireContext()).parameterInfoDao().getOneInfo();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Error fetching parameter settings", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
GoodsBean goodsBean = goodsList.stream()
|
GoodsBean goodsBean = goodsList.stream()
|
||||||
.filter(goods -> goods.getMaterialName().equals(mDestPage.getDisplayName()))
|
.filter(goods -> goods.getMaterialName().equals(mDestPage.getDisplayName()))
|
||||||
|
|
@ -724,21 +752,21 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
TextView num = view.findViewById(R.id.num);
|
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));
|
||||||
if ("out".equals(pageType)){
|
if ("out".equals(pageType)) {
|
||||||
if (new BigDecimal(weight * 2).compareTo(new BigDecimal(num.getText().toString())) > 0) {
|
if (new BigDecimal(weight * 2).compareTo(new BigDecimal(num.getText().toString())) > 0) {
|
||||||
enterWeight.setText(num.getText().toString());
|
enterWeight.setText(num.getText().toString());
|
||||||
weightView.setText(String.valueOf(weight * 2));
|
weightView.setText(String.valueOf(weight * 2));
|
||||||
}else{
|
} else {
|
||||||
enterWeight.setText(String.valueOf(weight * 2));
|
enterWeight.setText(String.valueOf(weight * 2));
|
||||||
weightView.setText(String.valueOf(weight * 2));
|
weightView.setText(String.valueOf(weight * 2));
|
||||||
}
|
}
|
||||||
} else{
|
} else {
|
||||||
BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getTotalQualifiedNum()).subtract(new BigDecimal(goodsBean.getOutCount()));
|
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 rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100));
|
||||||
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
|
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
|
||||||
Log.e(TAG,"unInspectedGoodsNum=" + unInspectedGoodsNum);
|
Log.e(TAG, "unInspectedGoodsNum=" + unInspectedGoodsNum);
|
||||||
Log.e(TAG,"weight=" + weight);
|
Log.e(TAG, "weight=" + weight);
|
||||||
Log.e(TAG,"originalNum=" + originalNum);
|
Log.e(TAG, "originalNum=" + originalNum);
|
||||||
if (weight * 2 >= originalNum.doubleValue()) {
|
if (weight * 2 >= originalNum.doubleValue()) {
|
||||||
enterWeight.setText(unInspectedGoodsNum + "");
|
enterWeight.setText(unInspectedGoodsNum + "");
|
||||||
weightView.setText(unInspectedGoodsNum + "");
|
weightView.setText(unInspectedGoodsNum + "");
|
||||||
|
|
@ -748,26 +776,26 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
tvWeightView.setText(String.valueOf(weight));
|
tvWeightView.setText(String.valueOf(weight));
|
||||||
if ("out".equals(pageType)){
|
if ("out".equals(pageType)) {
|
||||||
if (new BigDecimal(weight * 2).compareTo(new BigDecimal(num.getText().toString())) > 0) {
|
if (new BigDecimal(weight * 2).compareTo(new BigDecimal(num.getText().toString())) > 0) {
|
||||||
enterWeight.setText(num.getText().toString());
|
enterWeight.setText(num.getText().toString());
|
||||||
weightView.setText(String.valueOf(weight));
|
weightView.setText(String.valueOf(weight));
|
||||||
}else{
|
} else {
|
||||||
enterWeight.setText(String.valueOf(weight));
|
enterWeight.setText(String.valueOf(weight));
|
||||||
weightView.setText(String.valueOf(weight));
|
weightView.setText(String.valueOf(weight));
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
BigDecimal unInspectedGoodsNum = new BigDecimal(goodsBean.getMaterialTotalNum()).subtract(new BigDecimal(goodsBean.getOutCount()));
|
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 rate = BigDecimal.valueOf(100).subtract(new BigDecimal(paramSettingInfo.getWeighDownwardRatio())).divide(BigDecimal.valueOf(100));
|
||||||
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
|
BigDecimal originalNum = unInspectedGoodsNum.multiply(rate);
|
||||||
Log.e(TAG,"goodsBean=" + goodsBean);
|
Log.e(TAG, "goodsBean=" + goodsBean);
|
||||||
Log.e(TAG,"getTotalQualifiedNum=" + goodsBean.getTotalQualifiedNum());
|
Log.e(TAG, "getTotalQualifiedNum=" + goodsBean.getTotalQualifiedNum());
|
||||||
Log.e(TAG,"getOutCount=" + goodsBean.getOutCount());
|
Log.e(TAG, "getOutCount=" + goodsBean.getOutCount());
|
||||||
Log.e(TAG,"unInspectedGoodsNum=" + unInspectedGoodsNum);
|
Log.e(TAG, "unInspectedGoodsNum=" + unInspectedGoodsNum);
|
||||||
Log.e(TAG,"weight=" + weight);
|
Log.e(TAG, "weight=" + weight);
|
||||||
Log.e(TAG,"originalNum=" + originalNum);
|
Log.e(TAG, "originalNum=" + originalNum);
|
||||||
if (weight >= originalNum.doubleValue()) {
|
if (weight >= originalNum.doubleValue()) {
|
||||||
enterWeight.setText(unInspectedGoodsNum + "");
|
enterWeight.setText(unInspectedGoodsNum + "");
|
||||||
weightView.setText(unInspectedGoodsNum + "");
|
weightView.setText(unInspectedGoodsNum + "");
|
||||||
|
|
@ -815,26 +843,19 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
XToastUtils.error("输出流未初始化");
|
XToastUtils.error("输出流未初始化");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void roundOffWeight(){
|
|
||||||
|
public void roundOffWeight() {
|
||||||
if (mDestPage != null) {
|
if (mDestPage != null) {
|
||||||
View view = mPageMap.getOrDefault(mDestPage.getDisplayName(), null);
|
View view = mPageMap.getOrDefault(mDestPage.getDisplayName(), null);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
TextView weightView = view.findViewById(R.id.weight);
|
TextView weightView = view.findViewById(R.id.weight);
|
||||||
TextView subtotal = view.findViewById(R.id.subtotal);
|
TextView tvWeightView = view.findViewById(R.id.tv_weight);
|
||||||
if (!weightView.getText().toString().isEmpty()) {
|
if (!weightView.getText().toString().isEmpty()) {
|
||||||
double weight = Double.parseDouble(weightView.getText().toString());
|
double weight = Double.parseDouble(weightView.getText().toString());
|
||||||
BigDecimal roundedWeight = BigDecimal.valueOf(weight).setScale(0, RoundingMode.HALF_UP);
|
BigDecimal roundedWeight = BigDecimal.valueOf(weight).setScale(0, RoundingMode.HALF_UP);
|
||||||
Log.e(TAG, "Rounded weight: " + roundedWeight);
|
Log.e(TAG, "Rounded weight: " + roundedWeight);
|
||||||
weightView.setText(roundedWeight.toString());
|
weightView.setText(roundedWeight.toString());
|
||||||
GoodsBean goodsBean = goodsList.stream()
|
tvWeightView.setText(roundedWeight.toString());
|
||||||
.filter(goods -> goods.getMaterialName().equals(mDestPage.getDisplayName()))
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
if (goodsBean != null) {
|
|
||||||
BigDecimal priceValue = new BigDecimal(goodsBean.getUnitPrice());
|
|
||||||
BigDecimal subtotalValue = roundedWeight.multiply(priceValue).divide(BigDecimal.valueOf(100));
|
|
||||||
subtotal.setText(subtotalValue.toString());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
XToastUtils.warning("请先称重");
|
XToastUtils.warning("请先称重");
|
||||||
}
|
}
|
||||||
|
|
@ -845,6 +866,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
Log.e(TAG, "Current page is null.");
|
Log.e(TAG, "Current page is null.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GoodsBean> getResult() {
|
public List<GoodsBean> getResult() {
|
||||||
if (goodsList.isEmpty()) {
|
if (goodsList.isEmpty()) {
|
||||||
XToastUtils.error("没有可用的货品数据");
|
XToastUtils.error("没有可用的货品数据");
|
||||||
|
|
@ -861,6 +883,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
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);
|
||||||
GoodsBean goodsBean = goodsList.stream()
|
GoodsBean goodsBean = goodsList.stream()
|
||||||
.filter(goods -> goods.getMaterialName().equals(mDestPage.getDisplayName()))
|
.filter(goods -> goods.getMaterialName().equals(mDestPage.getDisplayName()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
|
@ -880,7 +903,15 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
XToastUtils.warning("称重结果必须大于0");
|
XToastUtils.warning("称重结果必须大于0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Log.e(TAG, "WeightView: " + weightView.getText().toString());
|
||||||
|
Log.e(TAG, "EnterWeight: " + enterWeight.getText().toString());
|
||||||
|
Log.e(TAG, "Num: " + num.getText().toString());
|
||||||
|
|
||||||
|
if (new BigDecimal(weightView.getText().toString()).compareTo(new BigDecimal(enterWeight.getText().toString())) > 0) {
|
||||||
|
dialog.dismiss();
|
||||||
|
XToastUtils.warning("出库重量不能大于库存数量");
|
||||||
|
return;
|
||||||
|
}
|
||||||
//对list进行数据更新
|
//对list进行数据更新
|
||||||
goodsBean.setWeight(weightView.getText().toString());
|
goodsBean.setWeight(weightView.getText().toString());
|
||||||
goodsBean.setDeliveryNum(weightView.getText().toString());
|
goodsBean.setDeliveryNum(weightView.getText().toString());
|
||||||
|
|
@ -979,12 +1010,17 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
private void openCamera() {
|
private void openCamera() {
|
||||||
if (isCameraOpen) return; // 防止重复打开
|
if (isCameraOpen) return; // 防止重复打开
|
||||||
|
|
||||||
|
try {
|
||||||
if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.CAMERA)
|
if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.CAMERA)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
ActivityCompat.requestPermissions(requireActivity(),
|
ActivityCompat.requestPermissions(requireActivity(),
|
||||||
new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSION);
|
new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "请求相机权限失败: " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CameraManager manager = (CameraManager) requireActivity().getSystemService(Context.CAMERA_SERVICE);
|
CameraManager manager = (CameraManager) requireActivity().getSystemService(Context.CAMERA_SERVICE);
|
||||||
try {
|
try {
|
||||||
|
|
@ -1115,6 +1151,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
Log.e(TAG, "保存图片失败: " + e.getMessage());
|
Log.e(TAG, "保存图片失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传照片
|
* 上传照片
|
||||||
* 使用OkHttpService上传图片到服务器
|
* 使用OkHttpService上传图片到服务器
|
||||||
|
|
@ -1132,7 +1169,7 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
if (!ObjectUtil.isEmpty(res)) {
|
if (!ObjectUtil.isEmpty(res)) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(res);
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
||||||
if (!jsonObject.containsKey("data")) {
|
if (!jsonObject.containsKey("data")) {
|
||||||
if (jsonObject.getInteger("code") == 401){
|
if (jsonObject.getInteger("code") == 401) {
|
||||||
Intent intent = new Intent(requireActivity(), LoginActivity.class);
|
Intent intent = new Intent(requireActivity(), LoginActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
@ -1228,7 +1265,6 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 尺寸比较器
|
// 尺寸比较器
|
||||||
class CompareSizesByArea implements Comparator<Size> {
|
class CompareSizesByArea implements Comparator<Size> {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1325,7 +1361,9 @@ public class InspectionWarehousingOutFragment extends BaseFragment<ActivityInspe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaterialDialog dialog;
|
private MaterialDialog dialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 带圆形Loading的Dialog
|
* 带圆形Loading的Dialog
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -258,8 +258,8 @@ public class DocumentSelectionFragment extends BaseFragment<ActivityDocumentStro
|
||||||
jsonObject.put("pageNum", 1);
|
jsonObject.put("pageNum", 1);
|
||||||
jsonObject.put("pageSize", 10);
|
jsonObject.put("pageSize", 10);
|
||||||
jsonObject.put("ifAllInspect", 2);
|
jsonObject.put("ifAllInspect", 2);
|
||||||
jsonObject.put("endDateTime", DateTimeHelper.getNowDate() + " 00:00:00");
|
jsonObject.put("endDateTime", DateTimeHelper.getNowDate() + " 23:59:59");
|
||||||
jsonObject.put("startDateTime", DateTimeHelper.getLastDate(-29) + " 23:59:59");
|
jsonObject.put("startDateTime", DateTimeHelper.getLastDate(-29) + " 00:00:00");
|
||||||
String jsonString = jsonObject.toString();
|
String jsonString = jsonObject.toString();
|
||||||
Log.e(TAG, "jsonString==" + jsonString);
|
Log.e(TAG, "jsonString==" + jsonString);
|
||||||
RequestBody body = RequestBody.create(mediaType, jsonString);
|
RequestBody body = RequestBody.create(mediaType, jsonString);
|
||||||
|
|
@ -418,17 +418,18 @@ public class DocumentSelectionFragment extends BaseFragment<ActivityDocumentStro
|
||||||
public void changeOutFragment(List<GoodsBean> goodsBeanList, DocumentOutBean bean) {
|
public void changeOutFragment(List<GoodsBean> goodsBeanList, DocumentOutBean bean) {
|
||||||
BigDecimal outNum = new BigDecimal(bean.getOutNum());
|
BigDecimal outNum = new BigDecimal(bean.getOutNum());
|
||||||
BigDecimal totalNum = new BigDecimal(bean.getTotalNum());
|
BigDecimal totalNum = new BigDecimal(bean.getTotalNum());
|
||||||
|
Log.e(TAG, "outNum==" + outNum);
|
||||||
|
Log.e(TAG, "totalNum==" + totalNum);
|
||||||
if (totalNum.compareTo(outNum) == 0) {
|
if (totalNum.compareTo(outNum) == 0) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
if (isDestroyed || !isAdded()) return;
|
if (isDestroyed || !isAdded()) return;
|
||||||
XToastUtils.success("当前领料单暂无可出库货品!");
|
XToastUtils.success("当前领料单暂无可出库货品!");
|
||||||
});
|
});
|
||||||
}
|
}else{
|
||||||
Log.e(TAG, "outNum==" + outNum);
|
|
||||||
Log.e(TAG, "totalNum==" + totalNum);
|
|
||||||
//展示出入库单据信息
|
//展示出入库单据信息
|
||||||
showOutDetail(bean, goodsBeanList);
|
showOutDetail(bean, goodsBeanList);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showOutDetail(DocumentOutBean bean, List<GoodsBean> goodsList) {
|
private void showOutDetail(DocumentOutBean bean, List<GoodsBean> goodsList) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
|
|
||||||
|
|
@ -412,4 +412,12 @@ public class ProductSelectionFragment extends BaseFragment<ActivityProductSelect
|
||||||
binding = null;
|
binding = null;
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showToast(String text) {
|
||||||
|
if (isAdded()) {
|
||||||
|
XToastUtils.info(text);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "showToast: Fragment is not added to the activity");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,4 +80,18 @@ public class DateTimeHelper {
|
||||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
|
@SuppressLint("SimpleDateFormat") SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
|
||||||
return sdf.format(calendar.getTime());
|
return sdf.format(calendar.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int compareDate(String start, String end) {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
try {
|
||||||
|
Date startDate = sdf.parse(start);
|
||||||
|
Date endDate = sdf.parse(end);
|
||||||
|
if (startDate != null && endDate != null) {
|
||||||
|
return startDate.compareTo(endDate);
|
||||||
|
}
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import android.util.Base64;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -44,6 +45,15 @@ public class StringHelper {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
public static boolean isEmptyAndNullOrZero(String str) {
|
||||||
|
if (str == null || str.trim().equals("") || str.trim().equals("null")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (new BigDecimal(str).compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证手机格式
|
* 验证手机格式
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue