Commit 299c86a6 by jason

菜品选食材代码同步

parent 83c9d9a7
...@@ -22,4 +22,20 @@ public class DishDetailBean { ...@@ -22,4 +22,20 @@ public class DishDetailBean {
private String foodBasicUnit;// string 非必须 食材基本单位 private String foodBasicUnit;// string 非必须 食材基本单位
private List<DeputyUnitBean> foodUnits; private List<DeputyUnitBean> foodUnits;
public DishDetailBean( PurchaseFoodBean foodBean) {
// this.id = foodBean.get;
// this.biFoodId = foodBean.getId();
// this.dishesName = dishesName;
// this.brandId = brandId;
// this.restaurantId = restaurantId;
// this.deletes = deletes;
this.purchaseFoodId = foodBean.getId();;
this.foodName = foodBean.getName();
this.consumeQuantity = foodBean.getFoodQuantity();
this.basicUnitName = foodBean.getBasicUnitName();
this.foodNo = foodBean.getFoodNo();
this.type = 0;
this.foodUnits = foodBean.getFoodUnits();
// this.foodBasicUnit = foodBean.getShowUnit().; ????
}
} }
...@@ -5,7 +5,6 @@ import android.app.Application; ...@@ -5,7 +5,6 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.common.constans.AppConstant; import com.gingersoft.gsa.cloud.common.constans.AppConstant;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil; import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.DishDetailBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean; import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean;
import com.gingersoft.supply_chain.mvp.bean.DishesResultBean; import com.gingersoft.supply_chain.mvp.bean.DishesResultBean;
import com.gingersoft.supply_chain.mvp.contract.DishesContract; import com.gingersoft.supply_chain.mvp.contract.DishesContract;
......
...@@ -541,6 +541,10 @@ public class OtherFunctionPresenter extends BasePresenter<OtherFunctionContract. ...@@ -541,6 +541,10 @@ public class OtherFunctionPresenter extends BasePresenter<OtherFunctionContract.
return DishesFoodList.getInstance().getCartFoods(); return DishesFoodList.getInstance().getCartFoods();
} }
public void clearPurchaseFood(){
DishesFoodList.getInstance().clear();
}
/** /**
* 添加食品到採購map中 * 添加食品到採購map中
* *
......
...@@ -27,12 +27,13 @@ public class DishDetailAdapter extends BaseQuickAdapter<DishDetailBean, BaseView ...@@ -27,12 +27,13 @@ public class DishDetailAdapter extends BaseQuickAdapter<DishDetailBean, BaseView
private int[] colors = new int[]{R.color.color_f9, R.color.white}; private int[] colors = new int[]{R.color.color_f9, R.color.white};
public DishDetailAdapter(Context context, List<DishDetailBean> foods) { public DishDetailAdapter(Context context, List<DishDetailBean> foods) {
super(R.layout.item_dishes_foods, foods); super(R.layout.item_dishes_foods,foods);
this.context = context; this.context = context;
addChildClickViewIds(R.id.tv_dishes_unit,R.id.tv_dishes_del); addChildClickViewIds(R.id.tv_dishes_unit,R.id.tv_dishes_del);
// TODO: 2021/7/25 扶單位處理 // TODO: 2021/7/25 扶單位處理
} }
@Override @Override
protected void convert(@NotNull BaseViewHolder viewHolder, DishDetailBean item) { protected void convert(@NotNull BaseViewHolder viewHolder, DishDetailBean item) {
viewHolder.setText(R.id.tv_dishes_name, item.getFoodName());//食材名字 viewHolder.setText(R.id.tv_dishes_name, item.getFoodName());//食材名字
...@@ -43,7 +44,7 @@ public class DishDetailAdapter extends BaseQuickAdapter<DishDetailBean, BaseView ...@@ -43,7 +44,7 @@ public class DishDetailAdapter extends BaseQuickAdapter<DishDetailBean, BaseView
if (CollectionUtils.isNullOrEmpty(deputyUnitBeans)) { if (CollectionUtils.isNullOrEmpty(deputyUnitBeans)) {
// addChildClickViewIds(R.id.tv_dishes_unit); consumeQuantity // addChildClickViewIds(R.id.tv_dishes_unit); consumeQuantity
} }
viewHolder.setText(R.id.tv_dishes_count, item.getConsumeQuantity());//消耗數量 viewHolder.setText(R.id.tv_dishes_count, String.valueOf(item.getConsumeQuantity()));//消耗數量
} }
} }
...@@ -99,7 +99,11 @@ public class DishesGroupProvider extends BaseNodeProvider { ...@@ -99,7 +99,11 @@ public class DishesGroupProvider extends BaseNodeProvider {
if (CollectionUtils.isNotNullOrEmpty(dishNodes)) { if (CollectionUtils.isNotNullOrEmpty(dishNodes)) {
if (groupNode.getPos()==0) { if (groupNode.getPos()==0) {
groupNode.setPos(1); groupNode.setPos(1);
dishNodes.get(0).setSelect(true); DishNode dishNode = dishNodes.get(0);
dishNode.setSelect(true);
if (defaultClick != null) {
defaultClick.onChildClick(dishNode);
}
} }
} }
...@@ -110,4 +114,14 @@ public class DishesGroupProvider extends BaseNodeProvider { ...@@ -110,4 +114,14 @@ public class DishesGroupProvider extends BaseNodeProvider {
} }
} }
private defaultClick defaultClick;
public void setDefaultClick(DishesGroupProvider.defaultClick defaultClick) {
this.defaultClick = defaultClick;
}
public interface defaultClick {
void onChildClick(DishNode dishNode);
}
} }
...@@ -11,9 +11,11 @@ import java.util.List; ...@@ -11,9 +11,11 @@ import java.util.List;
public class DishesTreeAdapter extends BaseNodeAdapter { public class DishesTreeAdapter extends BaseNodeAdapter {
public static final int DISHESGROUP=1; public static final int DISHESGROUP=1;
public static final int DISHESSINGLE=2; public static final int DISHESSINGLE=2;
public DishesTreeAdapter() { public DishesTreeAdapter(DishesGroupProvider.defaultClick defaultClick) {
super(); super();
addNodeProvider(new DishesGroupProvider()); DishesGroupProvider groupProvider= new DishesGroupProvider();
groupProvider.setDefaultClick(defaultClick);
addNodeProvider(groupProvider);
addNodeProvider(new DishProvider()); addNodeProvider(new DishProvider());
addChildClickViewIds(R.id.tv_dish_title); addChildClickViewIds(R.id.tv_dish_title);
} }
......
...@@ -20,14 +20,19 @@ import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean; ...@@ -20,14 +20,19 @@ import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailBean; import com.gingersoft.supply_chain.mvp.bean.DishDetailBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean; import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean;
import com.gingersoft.supply_chain.mvp.bean.DishesResultBean; import com.gingersoft.supply_chain.mvp.bean.DishesResultBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.contract.DishesContract; import com.gingersoft.supply_chain.mvp.contract.DishesContract;
import com.gingersoft.supply_chain.mvp.presenter.DishesPresenter; import com.gingersoft.supply_chain.mvp.presenter.DishesPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishDetailAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishNode; import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishNode;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode; import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupProvider;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesTreeAdapter; import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesTreeAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.food.OtherFunctionFragment;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import butterknife.BindView; import butterknife.BindView;
...@@ -48,6 +53,10 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp ...@@ -48,6 +53,10 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
@BindView(R2.id.rv_dishes_food) @BindView(R2.id.rv_dishes_food)
RecyclerView rvDishes; RecyclerView rvDishes;
private DishesTreeAdapter dishesTreeAdapter; private DishesTreeAdapter dishesTreeAdapter;
private DishDetailAdapter dishDetailAdapter;
public static final int DISHES_ADD=123;
public static DishesFragment newInstance() { public static DishesFragment newInstance() {
DishesFragment fragment = new DishesFragment(); DishesFragment fragment = new DishesFragment();
return fragment; return fragment;
...@@ -74,9 +83,30 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp ...@@ -74,9 +83,30 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
initTopBar(topbarFoodIngredients, getString(R.string.str_dishes)); initTopBar(topbarFoodIngredients, getString(R.string.str_dishes));
mPresenter.getDishGroupData(); mPresenter.getDishGroupData();
} }
private void initDishDetail(DishDetailResultBean dishesResultBean){
List<DishDetailBean> foods=dishesResultBean.getData();
if (CollectionUtils.isNullOrEmpty(foods)) {
dishDetailAdapter=new DishDetailAdapter(requireContext(),foods);
}else {
dishDetailAdapter=new DishDetailAdapter(requireContext(),new ArrayList<>());
}
dishDetailAdapter.addFooterView(getFooter());
rvDishes.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false));
rvDishes.setAdapter(dishDetailAdapter);
}
private void initDishes( List<DishesGroupNode> dishesGroupNodes){ private View getFooter() {
dishesTreeAdapter = new DishesTreeAdapter(); View view = getLayoutInflater().inflate(R.layout.item_dishes_foot, rvDishes, false);
view.findViewById(R.id.tv_dish_add).setOnClickListener(v -> {
startForResult(OtherFunctionFragment.newInstance(),DISHES_ADD);
});
view.findViewById(R.id.tv_dish_done).setOnClickListener(v -> {
LogUtil.e("zjs"," 完成 tv_dish_done");
});
return view;
}
private void initDishGroup(List<DishesGroupNode> dishesGroupNodes){
dishesTreeAdapter = new DishesTreeAdapter(dishNode -> mPresenter.getDishesDetailData(dishNode));
dishesTreeAdapter.setOnItemChildClickListener((adapter, view, position) -> { dishesTreeAdapter.setOnItemChildClickListener((adapter, view, position) -> {
BaseNode baseNode= dishesTreeAdapter.getItem(position); BaseNode baseNode= dishesTreeAdapter.getItem(position);
if (baseNode instanceof DishNode) { if (baseNode instanceof DishNode) {
...@@ -112,17 +142,12 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp ...@@ -112,17 +142,12 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
@Override @Override
public void loadDishGroupInfo( List<DishesGroupNode> dishGroup) { public void loadDishGroupInfo( List<DishesGroupNode> dishGroup) {
initDishes(dishGroup); initDishGroup(dishGroup);
} }
@Override @Override
public void loadDishesInfo(DishNode dishNode,DishDetailResultBean dishesDetail) { public void loadDishesInfo(DishNode dishNode,DishDetailResultBean dishesDetail) {
List<DishDetailBean> foods= dishesDetail.getData(); initDishDetail(dishesDetail);
if (CollectionUtils.isNullOrEmpty(foods)) { //沒有加過食材 那麼只有add
}else {
}
} }
@Override @Override
...@@ -144,4 +169,57 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp ...@@ -144,4 +169,57 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
public void selectDishGroupByIndex(int position) { public void selectDishGroupByIndex(int position) {
} }
@Override
public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
super.onFragmentResult(requestCode, resultCode, data);
LogUtil.e("zjs"," onFragmentResult ="+requestCode + " resultCode="+resultCode);
if (requestCode == DISHES_ADD) {
if (data != null) {
if (dishDetailAdapter != null) {
List<DishDetailBean> foodsOld = dishDetailAdapter.getData();
ArrayList<PurchaseFoodBean> purchaseFood = (ArrayList<PurchaseFoodBean>) data.getSerializable("zjs");
if (purchaseFood != null) {
List<DishDetailBean> foodsNew = new ArrayList<>();
int len=purchaseFood.size();
LogUtil.e("zjs", " purchaseFood =" + purchaseFood.size()+" foodsOld="+foodsOld.size());
if (CollectionUtils.isNotNullOrEmpty(foodsOld)) {
int old=foodsOld.size();
boolean isNew=true;
for (int i = 0; i < len; i++) {
PurchaseFoodBean newBean= purchaseFood.get(i);
for (int j = 0; j < old; j++) {
DishDetailBean oldBean=foodsOld.get(j);
LogUtil.e("zjs"," oldBean="+oldBean.toString()+" newBean="+newBean.toString());
if (newBean.getId()==oldBean.getPurchaseFoodId()) {
oldBean.setConsumeQuantity(oldBean.getConsumeQuantity()+newBean.getFoodQuantity());
isNew=false;
dishDetailAdapter.notifyItemChanged(j);
continue;
}
}
if (isNew) {
DishDetailBean addNewBean=new DishDetailBean(newBean);
foodsNew.add(addNewBean);
}
}
}else { //全新
for (int i = 0; i < len; i++) {
PurchaseFoodBean newBean= purchaseFood.get(i);
LogUtil.e("zjs"," 全新 newBean="+newBean.toString());
DishDetailBean addNewBean=new DishDetailBean(newBean);
foodsNew.add(addNewBean);
}
}
// TODO: 2021/7/26 完成按钮显示 菜品数据绑定
dishDetailAdapter.addData(foodsNew);
}
}
}
}
}
} }
\ No newline at end of file
...@@ -160,7 +160,6 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr ...@@ -160,7 +160,6 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
break; break;
case "菜品Boom": case "菜品Boom":
start(DishesFragment.newInstance()); start(DishesFragment.newInstance());
// startForResult(OtherFunctionFragment.newInstance(),12345);
break; break;
default: default:
...@@ -175,13 +174,4 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr ...@@ -175,13 +174,4 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
mTopBar.addLeftBackImageButton().setOnClickListener(v -> killMyself()); mTopBar.addLeftBackImageButton().setOnClickListener(v -> killMyself());
} }
@Override
public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
super.onFragmentResult(requestCode, resultCode, data);
LogUtil.e("zjs"," onFragmentResult ="+requestCode + " resultCode="+resultCode);
if (data != null) {
ArrayList<PurchaseFoodBean> purchaseFood = (ArrayList<PurchaseFoodBean>) data.getSerializable("zjs");
LogUtil.e("zjs"," purchaseFood ="+ purchaseFood.size());
}
}
} }
...@@ -246,6 +246,7 @@ public class OtherFunctionFragment extends BaseSupplyChainFragment<OtherFunction ...@@ -246,6 +246,7 @@ public class OtherFunctionFragment extends BaseSupplyChainFragment<OtherFunction
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
view.setLayoutParams(layoutParams); view.setLayoutParams(layoutParams);
view.setOnClickListener(this); view.setOnClickListener(this);
view.setVisibility(View.GONE);
topbarFoodIngredients.addRightView(view, R.id.qmui_shopping_cart); topbarFoodIngredients.addRightView(view, R.id.qmui_shopping_cart);
} }
...@@ -453,8 +454,9 @@ public class OtherFunctionFragment extends BaseSupplyChainFragment<OtherFunction ...@@ -453,8 +454,9 @@ public class OtherFunctionFragment extends BaseSupplyChainFragment<OtherFunction
if (CollectionUtils.isNotNullOrEmpty(purchaseFood)) { if (CollectionUtils.isNotNullOrEmpty(purchaseFood)) {
LogUtil.e("zjs"," purchaseFood "+purchaseFood.size()); LogUtil.e("zjs"," purchaseFood "+purchaseFood.size());
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable("zjs", (Serializable) purchaseFood); bundle.putSerializable("zjs", purchaseFood);
setFragmentResult(RESULT_OK, bundle); setFragmentResult(RESULT_OK, bundle);
mPresenter.clearPurchaseFood();
killMyself(); killMyself();
} else { } else {
showMessage("請選擇食材"); showMessage("請選擇食材");
......
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 连框颜色值 -->
<item>
<shape>
<solid android:color="@color/supply_function_color" />
</shape>
</item>
<!--设置只有底部有边框-->
<!-- 主体背景颜色值 -->
<item android:bottom="1px">
<shape>
<solid android:color="@color/white" />
</shape>
</item>
</layer-list>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="3"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
android:id="@+id/tv_head_layout_res_id" android:id="@+id/tv_head_layout_res_id"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/white" android:background="@drawable/shape_dish_bottom"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
android:id="@+id/layout_dishes_foot" android:id="@+id/layout_dishes_foot"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/white" android:background="@color/white"
android:gravity="center" android:gravity="center"
android:padding="@dimen/dp_6" android:padding="@dimen/dp_6"
...@@ -20,7 +19,7 @@ ...@@ -20,7 +19,7 @@
android:padding="@dimen/dp_6" android:padding="@dimen/dp_6"
android:text="+ 選擇食材" android:text="+ 選擇食材"
android:textColor="@color/theme_color" android:textColor="@color/theme_color"
android:textSize="@dimen/sp_18" android:textSize="@dimen/sp_16"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
...@@ -33,7 +32,7 @@ ...@@ -33,7 +32,7 @@
android:padding="@dimen/dp_6" android:padding="@dimen/dp_6"
android:text="完成" android:text="完成"
android:textColor="@color/theme_color" android:textColor="@color/theme_color"
android:textSize="@dimen/sp_18" android:textSize="@dimen/sp_16"
android:textStyle="bold" android:textStyle="bold"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" /> tools:visibility="visible" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment