From 5531e190bdb211a746e1017c1d96d9e9403e1a4f Mon Sep 17 00:00:00 2001 From: liup <1454939542@qq.com> Date: Thu, 6 Jun 2024 18:11:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=BB=BA=E9=85=8D?= =?UTF-8?q?=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/ExecuteTheRecipe.java | 2 +- .../bnframework/common/constant/DataBus.java | 1 - .../bonait/bnframework/common/db/QueryDB.java | 10 +- .../common/db/mode/BPA_GOODPROPERTY.java | 11 + .../common/db/mode/BPA_GOODSRECIPENAME.java | 9 + .../common/db/res/ResGoodProperty.java | 13 +- .../common/db/util/GoodsRecipeUtil.java | 70 ++++ .../common/db/{ => util}/ListAddUtil.java | 3 +- .../common/linktab/good/GoodLeftAdapter.java | 4 +- .../common/view/NewScrollView.java | 43 ++ .../modules/home/adapter/BaseAdapter.java | 177 +++++++++ .../home/adapter/GoodGroupNameAdapter.java | 43 ++ .../adapter/newpropertyselect_adapter.java | 78 +++- .../modules/home/adapter/pfsx_adapter.java | 40 +- .../from/fragment/Jcsjgl_sxgl_fragment.java | 2 +- .../home/fragment/mode/GoodsEditView.java | 371 ++++++++++++++++++ .../fragment/mode/add_makegood_control.java | 127 ++++-- .../main/res/drawable/bg_btn_red_selected.xml | 27 ++ app/src/main/res/drawable/button4.xml | 29 ++ app/src/main/res/layout/activity_jcsjgl.xml | 40 +- .../main/res/layout/fragment_jcsjgl_sxgl.xml | 291 +++++++------- .../item/layout/dialog_add_makegood.xml | 16 +- .../layout/item/layout/goods_edit_layout.xml | 351 +++++++++++++++++ .../layout/item/layout/item_group_detail.xml | 121 ++++++ .../layout/item/layout/item_group_name.xml | 93 +++++ .../main/res/mipmap-xxxhdpi/ic_arrow_down.png | Bin 0 -> 6186 bytes .../res/mipmap-xxxhdpi/ic_arrow_down2.png | Bin 0 -> 2922 bytes .../main/res/mipmap-xxxhdpi/ic_arrow_left.png | Bin 0 -> 5623 bytes .../res/mipmap-xxxhdpi/ic_arrow_left2.png | Bin 0 -> 2888 bytes 29 files changed, 1754 insertions(+), 218 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/common/db/util/GoodsRecipeUtil.java rename app/src/main/java/com/bonait/bnframework/common/db/{ => util}/ListAddUtil.java (99%) create mode 100644 app/src/main/java/com/bonait/bnframework/common/view/NewScrollView.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/adapter/BaseAdapter.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/adapter/GoodGroupNameAdapter.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/GoodsEditView.java create mode 100644 app/src/main/res/drawable/bg_btn_red_selected.xml create mode 100644 app/src/main/res/drawable/button4.xml create mode 100644 app/src/main/res/layout/item/layout/goods_edit_layout.xml create mode 100644 app/src/main/res/layout/item/layout/item_group_detail.xml create mode 100644 app/src/main/res/layout/item/layout/item_group_name.xml create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_arrow_down.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_arrow_down2.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_arrow_left.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_arrow_left2.png diff --git a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java index c0a260a3..ac8ee72d 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -472,7 +472,7 @@ public class ExecuteTheRecipe { public void Run() { IsComplete[0] = true; if(GoodMake!=null&& GoodMake.good!=null){ - MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】配料完成!"); +// MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】配料完成!"); } } }; diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java index 523f6cc5..c6540b08 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java @@ -385,7 +385,6 @@ public class DataBus { * 属性数据 */ public ArrayList bpa_goodproperties = new ArrayList<>(); - public pfsx_adapter sxadapter=null; /** * 加载商品配方 */ diff --git a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java index 6a093836..116dc33c 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java @@ -5,6 +5,7 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.util.Log; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.file.DBHelper; import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA; @@ -12,14 +13,12 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODPROPERTY; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME; import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; -import com.bonait.bnframework.common.db.file.DBHelper; import com.bonait.bnframework.common.db.mode.BPA_ALERTLOG; import com.bonait.bnframework.common.db.mode.BPA_CRAFT; import com.bonait.bnframework.common.db.mode.BPA_CRAFTPROCESS; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; import com.bonait.bnframework.common.db.mode.BPA_LOG; -import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.db.mode.BPA_MENU; import com.bonait.bnframework.common.db.mode.BPA_MENUANDUSER; import com.bonait.bnframework.common.db.mode.BPA_ORDER; @@ -39,15 +38,13 @@ import com.bonait.bnframework.common.db.mode.ModeBase; import com.bonait.bnframework.common.db.res.ResAlertLog; import com.bonait.bnframework.common.db.res.ResGoodsRecipe; import com.bonait.bnframework.common.db.res.ResLog; -import com.bonait.bnframework.common.db.res.ResSilosMode; import com.bonait.bnframework.common.db.res.ResSubOrder; +import com.bonait.bnframework.common.db.util.ListAddUtil; import com.bonait.bnframework.common.helper.Tools; -import com.bonait.bnframework.common.utils.PreferenceUtils; import java.lang.reflect.Field; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; @@ -1351,6 +1348,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_GOODSRECIPENAME) k); } + LogUtils.d("GetGoodsRecipeNameGoodId data="+data.toString()); return data; } catch (Exception e) { Log.d("商品ID查询配方信息", "商品ID查询配方信息异常: " + e.getMessage()); @@ -3520,7 +3518,7 @@ public class QueryDB { * @param orderby "date("+COLUMN_DATE+") desc" "TYPE desc"; desc 倒序 * @return */ - private static ArrayList Get(Class c, String whereClause, String[] Args, String orderby) { + public static ArrayList Get(Class c, String whereClause, String[] Args, String orderby) { lock.lock(); ArrayList rlts = new ArrayList(); SQLiteDatabase db = helper.getReadableDatabase(); diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODPROPERTY.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODPROPERTY.java index 3c86e6de..cd0dfa38 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODPROPERTY.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODPROPERTY.java @@ -19,4 +19,15 @@ public class BPA_GOODPROPERTY extends ModeBase { * 商品类型id */ public String GoodsTypeId; + + @Override + public String toString() { + return "BPA_GOODPROPERTY{" + + "name='" + name + '\'' + + ", foreignKeyRe='" + foreignKeyRe + '\'' + + ", parentid='" + parentid + '\'' + + ", sort=" + sort + + ", GoodsTypeId='" + GoodsTypeId + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPENAME.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPENAME.java index 829cafa6..5cbf4677 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPENAME.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPENAME.java @@ -12,4 +12,13 @@ public class BPA_GOODSRECIPENAME extends ModeBase { public String name; //规格集合 ids public String design;//商品规格 + + @Override + public String toString() { + return "BPA_GOODSRECIPENAME{" + + "goodsID='" + goodsID + '\'' + + ", name='" + name + '\'' + + ", design='" + design + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/res/ResGoodProperty.java b/app/src/main/java/com/bonait/bnframework/common/db/res/ResGoodProperty.java index 836a656b..4a133194 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/res/ResGoodProperty.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/res/ResGoodProperty.java @@ -10,6 +10,17 @@ import java.util.List; * 查询 */ public class ResGoodProperty extends BPA_GOODPROPERTY { - public Boolean isSelect; + public Boolean isSelect = false; public ArrayList child; + + @Override + public String toString() { + return "ResGoodProperty==>{" + + "isSelect=" + isSelect + + ", child=" + child + + ", id='" + id + '\'' + + ", parentid='" + parentid + '\'' + + ", name='" + name + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsRecipeUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsRecipeUtil.java new file mode 100644 index 00000000..5a3e9a30 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsRecipeUtil.java @@ -0,0 +1,70 @@ +package com.bonait.bnframework.common.db.util; + +import android.util.Log; + +import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author: liup + * @description: + * @date: 2024/6/5 17:37. + */ +public class GoodsRecipeUtil { + /** + * 商品ID查询配方关联表 + * + * @param id + * @return + */ + public static ArrayList GetGoodsRecipeNameGoodId(String id) { + try { + LogUtils.d("GetGoodsRecipeNameGoodId id="+id); + String orderby = QueryDB.Desc_Time_Up;//出料顺序 + String where = "isDelete=? and goodsID=?"; + String[] args = new String[]{"0", id}; + ArrayList data = new ArrayList<>(); + ArrayList obj = QueryDB.Get(BPA_GOODSRECIPENAME.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_GOODSRECIPENAME) k); + } + LogUtils.d("GetGoodsRecipeNameGoodId data="+data.toString()); + return data; + } catch (Exception e) { + Log.d("商品ID查询配方信息", "商品ID查询配方信息异常: " + e.getMessage()); + return null; + } + } + + public static ArrayList GetGoodsRecipeNameLikes(String id, List list) { + try { + String orderby = QueryDB.Desc_Time_Up;//出料顺序 + String where = "isDelete=? and goodsID=?"; + if(!list.isEmpty()){ + StringBuilder likes = new StringBuilder(); + for (int i=0;i data = new ArrayList<>(); + ArrayList obj = QueryDB.Get(BPA_GOODSRECIPENAME.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_GOODSRECIPENAME) k); + } + LogUtils.d("GetGoodsRecipeNameLikes data="+data.toString()); + return data; + } catch (Exception e) { + Log.d("商品ID查询配方信息", "商品ID查询配方信息异常: " + e.getMessage()); + return null; + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/common/db/ListAddUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/ListAddUtil.java similarity index 99% rename from app/src/main/java/com/bonait/bnframework/common/db/ListAddUtil.java rename to app/src/main/java/com/bonait/bnframework/common/db/util/ListAddUtil.java index e20b10d1..d1abcd67 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/ListAddUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/ListAddUtil.java @@ -1,8 +1,9 @@ -package com.bonait.bnframework.common.db; +package com.bonait.bnframework.common.db.util; import android.content.ContentValues; import android.database.sqlite.SQLiteDatabase; +import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODPROPERTY; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; diff --git a/app/src/main/java/com/bonait/bnframework/common/linktab/good/GoodLeftAdapter.java b/app/src/main/java/com/bonait/bnframework/common/linktab/good/GoodLeftAdapter.java index f0fccff7..cb996572 100644 --- a/app/src/main/java/com/bonait/bnframework/common/linktab/good/GoodLeftAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/common/linktab/good/GoodLeftAdapter.java @@ -44,8 +44,8 @@ public class GoodLeftAdapter extends BaseQuickAdapter holder.setText(R.id.tv_type, type.name); int index_d = Fdata.indexOf(item); if (item.isChoose) { - holder.setBackgroundColor(R.id.tv_linearlayout, resources.getColor(R.color.main_background)); - holder.setTextColor(R.id.tv_type, resources.getColor(R.color.app_color_blue)); + holder.setBackgroundColor(R.id.tv_linearlayout, resources.getColor(R.color.app_color_blue7f)); + holder.setTextColor(R.id.tv_type, resources.getColor(R.color.white)); holder.setVisible(R.id.tv_image, true); holder.setVisible(R.id.tv_update, true); holder.setVisible(R.id.tv_delete, true); diff --git a/app/src/main/java/com/bonait/bnframework/common/view/NewScrollView.java b/app/src/main/java/com/bonait/bnframework/common/view/NewScrollView.java new file mode 100644 index 00000000..413231d5 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/view/NewScrollView.java @@ -0,0 +1,43 @@ +package com.bonait.bnframework.common.view; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.ScrollView; + +/** + * @author liupeng + * @description: 因OnScrollChangeListener()API23低版本报错,必须重写 + * @date :2022/2/17 11:29 + */ +public class NewScrollView extends ScrollView { + + private OnScrollChange listener; + + public void setOnScrollListener(OnScrollChange listener){ + this.listener = listener; + } + + public NewScrollView(Context context) { + super(context); + } + + public NewScrollView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public NewScrollView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onScrollChanged(int l, int t, int oldl, int oldt) { + super.onScrollChanged(l, t, oldl, oldt); + if(listener!=null){ + listener.onScroll(l,t,oldl,oldt); + } + } + + public interface OnScrollChange{ + void onScroll(int l,int t,int oldl,int oldt); + } +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/BaseAdapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/BaseAdapter.java new file mode 100644 index 00000000..09e3741a --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/BaseAdapter.java @@ -0,0 +1,177 @@ +package com.bonait.bnframework.modules.home.adapter; + +import android.view.View; + +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author: liup + * @description: adapter基类 + * @date: 2024/6/6 9:02. + */ +public abstract class BaseAdapter + extends RecyclerView.Adapter { + /** + * 数据 + */ + protected List mData; + /** + * 当前位置 + */ + protected int mCurrentPosition = -1; + + /** + * 不初始化数据 + */ + public BaseAdapter() { + this(null); + } + + /** + * 初始化数据 + * + * @param data 数据 + */ + public BaseAdapter(List data) { + super(); + mData = data; + } + + /** + * 获取当前位置 + * + * @return 当前位置 + */ + public int getCurrentPosition() { + return mCurrentPosition; + } + + /** + * 设置当前位置 + * + * @param currentPosition 当前位置 + */ + public void setCurrentPosition(int currentPosition) { + mCurrentPosition = currentPosition; + } + + /** + * 获取数据 + * + * @return 数据 + */ + public List getData() { + if (mData == null) { + mData = new ArrayList<>(); + } + return mData; + } + + /** + * 设置数据 + * + * @param data 数据 + */ + public void setNewData(List data) { + mData = data == null ? new ArrayList<>() : data; + notifyDataSetChanged(); + } + + /** + * 添加数据 + * + * @param newData 新数据 + */ + public void addData(List newData) { + mData.addAll(newData); + notifyItemRangeInserted(mData.size() - newData.size(), newData.size()); + } + + /** + * 更新数据 + * + * @param data 数据 + */ + public void updateData(List data) { + if (data != null) { + int size = data.size(); + int mSize = mData.size(); + if (mSize >= size) { + if (size > 0) { + for (int i = 0; i < size; i++) { + mData.set(i, data.get(i)); + } + notifyItemRangeChanged(0, size); + } + if (mSize > size) { + for (int i = 0; i < mSize - size; i++) { + mData.remove(mData.size() - 1); + } + notifyItemRangeRemoved(size, mSize - size); + } + } else { + for (int i = 0; i < mSize; i++) { + mData.set(i, data.get(i)); + } + notifyItemRangeChanged(0, mSize); + for (int i = mSize; i < size; i++) { + mData.add(data.get(i)); + } + notifyItemRangeInserted(mSize, size - mSize); + } + } + } + + /** + * 替换数据 + * + * @param data 数据 + */ + public void replaceData(List data) { + if (data != mData) { + mCurrentPosition = 0; + if(mData==null){ + mData=data; + }else { + mData.clear(); + mData.addAll(data); + notifyDataSetChanged(); + } + } + } + + /** + * 清空数据 + */ + public void clearData() { + if(mData!=null) { + mCurrentPosition = 0; + mData.clear(); + notifyDataSetChanged(); + } + } + + @Override + public int getItemViewType(int position) { + return position; + } + + @Override + public int getItemCount() { + if (mData == null || mData.isEmpty()) { + return 0; + } + return mData.size(); + } + + /** + * 当项被点击 + * + * @param v 视图 + * @param position 位置 + */ + protected abstract void onItemClick(View v, int position); +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/GoodGroupNameAdapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/GoodGroupNameAdapter.java new file mode 100644 index 00000000..22755ca2 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/GoodGroupNameAdapter.java @@ -0,0 +1,43 @@ +//package com.bonait.bnframework.modules.home.adapter; +// +// +//import android.view.LayoutInflater; +//import android.view.View; +//import android.view.ViewGroup; +// +//import androidx.annotation.NonNull; +//import androidx.recyclerview.widget.RecyclerView; +// +//import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME; +// +///** +// * @author: liup +// * @description: +// * @date: 2024/6/6 17:30. +// */ +//public class GoodGroupNameAdapter extends BaseAdapter { +// @Override +// protected void onItemClick(View v, int position) { +// +// } +// +// @NonNull +// @Override +// public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { +// return new ViewHolder(ItemStepBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)); +// } +// +// @Override +// public void onBindViewHolder(@NonNull ViewHolder holder, int position) { +// +// } +// +// public static class ViewHolder extends RecyclerView.ViewHolder { +// +// +// public ViewHolder(ItemStepBinding view) { +// super(view.getRoot()); +// binding = view; +// } +// } +//} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/newpropertyselect_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/newpropertyselect_adapter.java index 9782dfb8..f75d46c8 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/newpropertyselect_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/newpropertyselect_adapter.java @@ -1,5 +1,6 @@ package com.bonait.bnframework.modules.home.adapter; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.content.ContextWrapper; @@ -13,9 +14,12 @@ import androidx.recyclerview.widget.RecyclerView; import com.bonait.bnframework.R; import com.bonait.bnframework.common.constant.MessageName; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME; import com.bonait.bnframework.common.db.res.ResGoodProperty; import com.bonait.bnframework.common.db.res.ResMaterilas; +import com.bonait.bnframework.common.db.util.GoodsRecipeUtil; import com.bonait.bnframework.common.message.MessageManager; +import com.bonait.bnframework.common.utils.ToastUtils; import java.util.ArrayList; import java.util.List; @@ -27,6 +31,21 @@ public class newpropertyselect_adapter extends RecyclerView.Adapter Data = new ArrayList<>(); +// private List idList = new ArrayList<>(); +// private String goodId=""; +// private int parentPosition = 0; +// +// public void setParentPosition(int parentPosition) { +// this.parentPosition = parentPosition; +// } +// +// public void setGoodId(String goodId) { +// this.goodId = goodId; +// } +// +// public void setIdList(List idList) { +// this.idList = idList; +// } public newpropertyselect_adapter(Context context, ArrayList data) { this.context = context; @@ -43,19 +62,49 @@ public class newpropertyselect_adapter extends RecyclerView.Adapter goodsrecipenames = new ArrayList<>(); +// if(goodId!=null && !goodId.isEmpty()&&idList!=null && !idList.isEmpty()){ +// List list = new ArrayList<>(); +// for (int i=0;i int resource1; public Context contextA; private final LayoutInflater mLayoutInflater; +// private List idList = new ArrayList<>(); +// private String goodId=""; +// public void setGoodId(String goodId) { +// this.goodId = goodId; +// } +// +// public void setIdList(List idList) { +// this.idList = idList; +// } - public pfsx_adapter(Context context,ArrayList ac) { + public pfsx_adapter(Context context, ArrayList ac) { this.contextA = context; datas=ac; mLayoutInflater = LayoutInflater.from(context); @@ -48,7 +58,7 @@ public class pfsx_adapter extends RecyclerView.Adapter } @Override - public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + public void onBindViewHolder(RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) { if (holder instanceof MyViewHolder) { MyViewHolder myViewHolder = (MyViewHolder) holder; ResGoodProperty bpa_goodproperty =datas.get(position); @@ -59,6 +69,16 @@ public class pfsx_adapter extends RecyclerView.Adapter layout.setAutoMeasureEnabled(true); myViewHolder.recyclerView.setLayoutManager(layout); newpropertyselect_adapter zsxadapter = new newpropertyselect_adapter(contextA,bpa_goodproperty.child); + zsxadapter.setClickCallBack(new newpropertyselect_adapter.ItemClickCallBack() { + @Override + public void onClickItem(View view, int pos, String attributeId) { + if(clickCallBack!=null){ + clickCallBack.onClickItem(view,position,attributeId); + } + } + }); +// zsxadapter.setIdList(idList); +// zsxadapter.setGoodId(goodId); myViewHolder.recyclerView.setAdapter(zsxadapter); // 设置要显示的图片和文字 @@ -80,4 +100,20 @@ public class pfsx_adapter extends RecyclerView.Adapter } } + private ItemClickCallBack clickCallBack; + + public void setClickCallBack(ItemClickCallBack clickCallBack) { + this.clickCallBack = clickCallBack; + } + + public interface ItemClickCallBack{ + /** + * + * @param view + * @param position 父属性位置 + * @param attributeId 子属性id + */ + void onClickItem(View view,int position,String attributeId); + } + } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java index 2d6f4130..df726eb4 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java @@ -52,7 +52,7 @@ public class Jcsjgl_sxgl_fragment extends BaseFragment {// implements MyClickLis @BindView(R.id.datatab_sx) RecyclerView datatab_sx; @BindView(R.id.root) - LinearLayout root; + QMUIWindowInsetLayout root; @BindView(R.id.recyclerView) RecyclerView recyclerView; @BindView(R.id.ll_content) diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/GoodsEditView.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/GoodsEditView.java new file mode 100644 index 00000000..d3d633ad --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/GoodsEditView.java @@ -0,0 +1,371 @@ +package com.bonait.bnframework.modules.home.fragment.mode; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; + +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; + +import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.constant.MessageName; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_GOODPROPERTY; +import com.bonait.bnframework.common.db.mode.BPA_GOODS; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME; +import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; +import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.db.res.ResGoodProperty; +import com.bonait.bnframework.common.db.res.ResMaterilas; +import com.bonait.bnframework.common.glide.GlideUtil; +import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.helper.WrapContentLinearLayoutManager; +import com.bonait.bnframework.common.image.MyBitmapUtils; +import com.bonait.bnframework.common.message.MessageLooper; +import com.bonait.bnframework.common.message.MessageManager; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.common.view.MyLayoutManager; +import com.bonait.bnframework.databinding.GoodsEditLayoutBinding; +import com.bonait.bnframework.modules.home.adapter.newmeatrilselect_adapter; +import com.bonait.bnframework.modules.home.adapter.pfsx_adapter; +import com.bonait.bnframework.modules.home.fragment.from.ImageChooseActivity; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @author: liup + * @description: + * @date: 2024/6/6 15:38. + */ +public class GoodsEditView extends LinearLayout { + + private GoodsEditLayoutBinding viewBinding; + private Activity activity; + private String url;//图片地址 + /** + * 点击事件 + */ + public MyClickListener mListener=null; + /** + * 商品 + */ + public BPA_GOODS goodsData=null; + /** + * 当前物料数据 + */ + public ArrayList resMaterilas=new ArrayList<>(); + + public GoodsEditView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + View root = LayoutInflater.from(context).inflate(R.layout.goods_edit_layout, this); + viewBinding = GoodsEditLayoutBinding.bind(root); + initView(); + } + + private void initView(){ + initListener(); + } + + /** + * 设置数据 + * + * @param data + */ + public void setData(BPA_GOODS data, Activity activity) { + if(data==null){ + ToastUtils.info("数据为空"); + return; + } + setVisibility(VISIBLE); + goodsData = data; + this.activity=activity; + initData(); + } + + /** + * 初始化界面控件的显示数据 + */ + private void initData() { + //数据不为空 那么就是修改 + viewBinding.edittextName.setText(goodsData.name); + viewBinding.edittextFk.setText(goodsData.foreignKeyRe); + new MyBitmapUtils().disPlay(viewBinding.imgGoods,goodsData.url); + url=goodsData.url; + //初始化属性信息 + initPropertyData(); + } + + public void setListener(MyClickListener mListener){ + this.mListener = mListener; + } + + /** + * 按键监听 + */ + private void initListener(){ + viewBinding.titleGoods.setOnClickListener(v->{ + if(viewBinding.contentGoods.getVisibility() == VISIBLE){ + viewBinding.contentGoods.setVisibility(GONE); + viewBinding.icArrowGoods.setBackgroundResource(R.mipmap.ic_arrow_left); + viewBinding.tvGoods.setText("收起"); + }else { + viewBinding.contentGoods.setVisibility(VISIBLE); + viewBinding.icArrowGoods.setBackgroundResource(R.mipmap.ic_arrow_down); + viewBinding.tvGoods.setText("展开"); + } + }); + viewBinding.titleAttribute.setOnClickListener(v->{ + if(viewBinding.contentAttribut.getVisibility() == VISIBLE){ + viewBinding.contentAttribut.setVisibility(GONE); + viewBinding.icArrowAttribute.setBackgroundResource(R.mipmap.ic_arrow_left); + viewBinding.tvArrowAttribute.setText("收起"); + }else { + viewBinding.contentAttribut.setVisibility(VISIBLE); + viewBinding.icArrowAttribute.setBackgroundResource(R.mipmap.ic_arrow_down); + viewBinding.tvArrowAttribute.setText("展开"); + } + }); + viewBinding.titleDetail.setOnClickListener(v->{ + if(viewBinding.contentDetail.getVisibility() == VISIBLE){ + viewBinding.contentDetail.setVisibility(GONE); + viewBinding.icArrowDetail.setBackgroundResource(R.mipmap.ic_arrow_left); + viewBinding.tvArrowDetail.setText("收起"); + }else { + viewBinding.contentDetail.setVisibility(VISIBLE); + viewBinding.icArrowDetail.setBackgroundResource(R.mipmap.ic_arrow_down); + viewBinding.tvArrowDetail.setText("展开"); + } + }); + + viewBinding.llImg.setOnClickListener(v->{ + Intent intent = new Intent(getContext(), ImageChooseActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); + getContext().startActivity(intent); + }); + //图标选择 + MessageManager.getInstance().registerMessageReceiver(activity, MessageName.ClickImage, new MessageLooper.OnMessageListener() { + @Override + public void onMessage(Object msg) { + if (msg != null) { + url=(String) msg; + new MyBitmapUtils().disPlay(viewBinding.imgGoods,url); + GlideUtil.showImage(viewBinding.imgGoods.getContext(),url,viewBinding.imgGoods,R.mipmap.loading3); + goodsData.url = url; + QueryDB.UpdateGoods(goodsData); + } + } + }); + + //商品 + viewBinding.updateGoods.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(viewBinding.edittextName.getText().toString().isEmpty()) + { + ToastUtils.info("名称不能为空!"); + return; + } + boolean isSucess = QueryDB.GetGoodsIs(viewBinding.edittextName.getText().toString()); + if(isSucess) + { + ToastUtils.info("菜谱名称已存在!"); + return; + } + goodsData.name = viewBinding.edittextGroup.getText().toString(); + goodsData.url = url; + goodsData.foreignKeyRe=viewBinding.edittextFk.getText().toString(); + QueryDB.UpdateGoods(goodsData); + if (mListener != null) { + mListener.clickListenerNew(v,1,goodsData); + } + ToastUtils.info("修改成功"); + } + }); + viewBinding.closeFrom.setOnClickListener(v->{ + setVisibility(GONE); + }); + + //属性 + viewBinding.addGroup.setOnClickListener(v->{ + if(viewBinding.edittextGroup.getText().toString().isEmpty()) + { + ToastUtils.info("名称不能为空!"); + return; + } + viewBinding.addGroup.setText("修改名称"); + + BPA_GOODSRECIPENAME goodsrecipename = QueryDB.GetGoodsRecipeNameDesignId(ggids,goodsData.id); + if(goodsrecipename!=null) + { + goodsrecipename.name = viewBinding.edittextGroup.getText().toString(); + goodsrecipename.design=ggids; + goodsrecipename.goodsID=goodsData.id; + QueryDB.AddGoodsRecipeName(goodsrecipename); + ToastUtils.info("添加【"+goodsrecipename.name+"】配方成功"); + }else { + goodsrecipename = new BPA_GOODSRECIPENAME(); + goodsrecipename.name = viewBinding.edittextGroup.getText().toString(); + goodsrecipename.design=ggids; + goodsrecipename.goodsID=goodsData.id; + QueryDB.UpdateGoodsRecipeName(goodsrecipename); + ToastUtils.info("修改【"+goodsrecipename.name+"】配方成功"); + } + }); + } + + BPA_GOODSRECIPENAME goodsrecipename = null; + String ggids = "";//规格id集合 + String groupName =""; + /** + * 查询是否有配方 + */ + public boolean hasGroup() { + //1.数据名称不能为空 + ggids = ""; + groupName =""; + for (ResGoodProperty item : bpa_goodproperties) { + for (ResGoodProperty k : item.child) { + if (k.isSelect) { + ggids += k.id + ","; + groupName +="/"+k.name; + } + } + } + + if (!ggids.isEmpty()) { + ggids = ggids.substring(0, ggids.length() - 1); + } + + goodsrecipename = QueryDB.GetGoodsRecipeNameDesignId(ggids,goodsData.id); + if (goodsrecipename == null) { + return false; + } + return true; + } + + /** + * 属性信息 + */ + ArrayList bpa_goodproperties = new ArrayList<>(); + private pfsx_adapter sxadapter; + private void initPropertyData() { + //2.填充规则数据,查询所有属性大类 + viewBinding.recyclerProperty.setLayoutManager(new WrapContentLinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL,false)); + + ArrayList goodsrecipenames = QueryDB.GetGoodsRecipeNameGoodId(goodsData.id); + assert goodsrecipenames != null; + LogUtils.d("add_makegood_control goodsrecipenames = "+goodsrecipenames.size()); + List attributeNameList = new ArrayList<>(); + for(BPA_GOODSRECIPENAME goodsrecipename1 : goodsrecipenames){ + if(goodsrecipename1.design.contains(",")){ + String[] res = goodsrecipename1.design.split(","); + attributeNameList.addAll(Arrays.asList(res)); + }else { + attributeNameList.add(goodsrecipename1.design); + } + } + + bpa_goodproperties.clear(); + ArrayList parentAttributes = QueryDB.GetGoodsPropertyByTypeId(goodsData.goodtype); + for(BPA_GOODPROPERTY bpaGoodproperty : parentAttributes ){ + ArrayList zsx= QueryDB.GetGoodsPropertyALL(bpaGoodproperty.id); + ArrayList childList = new ArrayList<>(); + for(BPA_GOODPROPERTY bean:zsx){ + if(attributeNameList.contains(bean.id)){ + ResGoodProperty child = new ResGoodProperty(); + child.id = bean.id; + child.name = bean.name; + child.foreignKeyRe = bean.foreignKeyRe; + child.parentid = bpaGoodproperty.id; + child.sort = bean.sort; + child.GoodsTypeId = bean.GoodsTypeId; + child.isSelect = false; + childList.add(child); + } + } + if(!childList.isEmpty()){ + ResGoodProperty resGoodProperty = new ResGoodProperty(); + resGoodProperty.id = bpaGoodproperty.id; + resGoodProperty.name = bpaGoodproperty.name; + resGoodProperty.foreignKeyRe = bpaGoodproperty.foreignKeyRe; + resGoodProperty.parentid = ""; + resGoodProperty.sort = bpaGoodproperty.sort; + resGoodProperty.GoodsTypeId = bpaGoodproperty.GoodsTypeId; + resGoodProperty.isSelect = false; + resGoodProperty.child = new ArrayList<>(childList); + bpa_goodproperties.add(resGoodProperty); + } + + } + + List idList = new ArrayList<>(); + for (ResGoodProperty item:bpa_goodproperties) + { + int i = 0; + for (ResGoodProperty c : item.child) { + c.isSelect = i == 0; + if(i==0){ + idList.add(c.id); + } + i++; + } + } + LogUtils.d("idList = "+idList); + sxadapter = new pfsx_adapter(getContext(),bpa_goodproperties); + sxadapter.setClickCallBack(new pfsx_adapter.ItemClickCallBack() { + @Override + public void onClickItem(View view, int position, String attributeId) { + if(hasGroup()){ + viewBinding.tvGroupTip.setText("存在配方"); + viewBinding.addGroup.setText("修改名称"); + }else { + viewBinding.tvGroupTip.setText("不存在配方"); + viewBinding.addGroup.setText("新建配方"); + } + viewBinding.edittextGroup.setText(groupName); + } + }); + viewBinding.recyclerProperty.setAdapter(sxadapter); + viewBinding.recyclerProperty.postDelayed(new Runnable() { + @Override + public void run() { + if(hasGroup()){ + viewBinding.tvGroupTip.setText("存在配方"); + viewBinding.addGroup.setText("修改名称"); + }else { + viewBinding.tvGroupTip.setText("不存在配方"); + viewBinding.addGroup.setText("新建配方"); + } + viewBinding.edittextGroup.setText(groupName); + } + },100); + } + + /** + * 配方详情 + */ + + + /** + * 销毁 + */ + public void destroy(){ + MessageManager.getInstance().unRegisterMessageReceiver(activity); + goodsData = null; + mListener = null; + resMaterilas.clear(); + resMaterilas = null; + url = null; + viewBinding.recyclerProperty.setAdapter(null); + sxadapter = null; + activity = null; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_makegood_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_makegood_control.java index abd7b143..ff5c2e7e 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_makegood_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_makegood_control.java @@ -14,6 +14,7 @@ import androidx.annotation.Nullable; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.constant.ConfigName; @@ -38,6 +39,8 @@ import com.bonait.bnframework.modules.home.adapter.pfsx_adapter; import com.bonait.bnframework.modules.home.adapter.xxpf_adapter; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; @@ -61,6 +64,8 @@ public class add_makegood_control extends LinearLayout{ @BindView(R.id.chubeiliang) TextView chubeiliang; + @BindView(R.id.tv_tip) + TextView tvTip; /** * 点击事件 @@ -86,47 +91,106 @@ public class add_makegood_control extends LinearLayout{ } ArrayList bpa_goodproperties = new ArrayList<>(); + private pfsx_adapter sxadapter; private void initData() { //2.填充规则数据,查询所有属性大类 -// LinearLayoutManager layoutManager=new LinearLayoutManager(getContext()); -// layoutManager.setOrientation(LinearLayoutManager.VERTICAL); datatab_makesx.setLayoutManager(new WrapContentLinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL,false)); - //if(DataBus.getInstance().sxadapter==null) - { - bpa_goodproperties.clear(); - for (ResGoodProperty pro:DataBus.getInstance().bpa_goodproperties) - { - if(pro.GoodsTypeId!=null && !pro.GoodsTypeId.isEmpty()) - { - if(pro.GoodsTypeId.contains(Good.goodtype)) - { - bpa_goodproperties.add(pro); - } - }else - { - bpa_goodproperties.add(pro); - } + ArrayList goodsrecipenames = QueryDB.GetGoodsRecipeNameGoodId(Good.id); + assert goodsrecipenames != null; + LogUtils.d("add_makegood_control goodsrecipenames = "+goodsrecipenames.size()); + List attributeNameList = new ArrayList<>(); + for(BPA_GOODSRECIPENAME goodsrecipename1 : goodsrecipenames){ + if(goodsrecipename1.design.contains(",")){ + String[] res = goodsrecipename1.design.split(","); + attributeNameList.addAll(Arrays.asList(res)); + }else { + attributeNameList.add(goodsrecipename1.design); } + } - for (ResGoodProperty item:bpa_goodproperties) - { - int i = 0; - for (ResGoodProperty c : item.child) { - if (i == 0) { - c.isSelect = true; - }else - { - c.isSelect =false; - } - i++; + bpa_goodproperties.clear(); + ArrayList parentAttributes = QueryDB.GetGoodsPropertyByTypeId(Good.goodtype); + for(BPA_GOODPROPERTY bpaGoodproperty : parentAttributes ){ + ArrayList zsx= QueryDB.GetGoodsPropertyALL(bpaGoodproperty.id); + ArrayList childList = new ArrayList<>(); + for(BPA_GOODPROPERTY bean:zsx){ + if(attributeNameList.contains(bean.id)){ + ResGoodProperty child = new ResGoodProperty(); + child.id = bean.id; + child.name = bean.name; + child.foreignKeyRe = bean.foreignKeyRe; + child.parentid = bpaGoodproperty.id; + child.sort = bean.sort; + child.GoodsTypeId = bean.GoodsTypeId; + child.isSelect = false; + childList.add(child); } } - DataBus.getInstance().sxadapter = new pfsx_adapter(contextMian,bpa_goodproperties); + if(!childList.isEmpty()){ + ResGoodProperty resGoodProperty = new ResGoodProperty(); + resGoodProperty.id = bpaGoodproperty.id; + resGoodProperty.name = bpaGoodproperty.name; + resGoodProperty.foreignKeyRe = bpaGoodproperty.foreignKeyRe; + resGoodProperty.parentid = ""; + resGoodProperty.sort = bpaGoodproperty.sort; + resGoodProperty.GoodsTypeId = bpaGoodproperty.GoodsTypeId; + resGoodProperty.isSelect = false; + resGoodProperty.child = new ArrayList<>(childList); + bpa_goodproperties.add(resGoodProperty); + } + } - datatab_makesx.setAdapter(DataBus.getInstance().sxadapter); + List idList = new ArrayList<>(); + for (ResGoodProperty item:bpa_goodproperties) + { + int i = 0; + for (ResGoodProperty c : item.child) { + c.isSelect = i == 0; + if(i==0){ + idList.add(c.id); + } + i++; + } + } + LogUtils.d("idList = "+idList); + sxadapter = new pfsx_adapter(contextMian,bpa_goodproperties); +// sxadapter.setIdList(idList); +// sxadapter.setGoodId(Good.id); + sxadapter.setClickCallBack(new pfsx_adapter.ItemClickCallBack() { + @Override + public void onClickItem(View view, int position, String attributeId) { +// idList.set(position,attributeId); +// for(int i=0;i + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button4.xml b/app/src/main/res/drawable/button4.xml new file mode 100644 index 00000000..efe03f22 --- /dev/null +++ b/app/src/main/res/drawable/button4.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_jcsjgl.xml b/app/src/main/res/layout/activity_jcsjgl.xml index e305472f..4884506b 100644 --- a/app/src/main/res/layout/activity_jcsjgl.xml +++ b/app/src/main/res/layout/activity_jcsjgl.xml @@ -13,28 +13,24 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/app_color_blue"/> - - - - + android:layout_width="match_parent" + android:layout_height="43dp" + android:background="@drawable/qmui_list_item_bg_with_border_bottom" + android:textSize="14sp" + app:qmui_tab_selected_text_size="16sp" + app:qmui_tab_normal_text_size="14sp" + app:qmui_tab_indicator_height="2dp" + app:qmui_tab_indicator_top="false" + app:qmui_tab_has_indicator="true" + /> + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_jcsjgl_sxgl.xml b/app/src/main/res/layout/fragment_jcsjgl_sxgl.xml index aaa748ec..d37dd829 100644 --- a/app/src/main/res/layout/fragment_jcsjgl_sxgl.xml +++ b/app/src/main/res/layout/fragment_jcsjgl_sxgl.xml @@ -1,173 +1,180 @@ - - - - - - + android:fitsSystemWindows="true" + > + android:orientation="horizontal" + android:layout_height="match_parent"> + + + + - - + android:layout_height="match_parent" + android:layout_marginStart="5dp" + android:background="@color/main_background" + android:orientation="vertical"> - + + android:background="@color/qmui_config_color_white" + android:orientation="vertical" + android:paddingTop="@dimen/dp_10" + android:paddingRight="@dimen/dp_10"> - - -