From 71a1a813aa804068c5ffbd55e5f6b10f0fbc8cfc Mon Sep 17 00:00:00 2001 From: liup Date: Thu, 9 May 2024 17:34:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E3=80=81=E4=BA=91=E7=AB=AF?= =?UTF-8?q?=E8=8F=9C=E8=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnframework/Model/GoodsClassifyBean.java | 240 ++++++++++++++++++ .../bnframework/Model/ProcessValueUtil.java | 57 +++++ .../BottomNavigationNewActivity.java | 15 +- .../bnframework/business/ConfigData.java | 5 - .../common/constant/ConfigName.java | 6 +- .../common/db/mode/BPA_ATTRIBUTE.java | 7 - .../common/db/mode/BPA_GOODS_CLASSIFY.java | 2 + .../common/db/mode/BPA_SUBATTRIBUTE.java | 7 - .../common/db/util/AttributeDBUtil.java | 15 ++ .../common/db/util/SubAttributeDBUtil.java | 15 ++ .../db/util/SubAttributeGroupDBUtil.java | 14 + .../common/model/mode/GoodsClassifyBean.java | 10 - .../ui/adapter/CloudGoodsAdapter.java | 42 +-- .../ui/adapter/LocalGoodsAdapter.java | 53 +--- .../ui/fragment/CloudGoodsFragment.java | 160 +++++++++++- .../ui/fragment/HomeFoodsFragment.java | 89 ++++--- .../ui/fragment/LocalGoodsFragment.java | 42 ++- .../main/res/layout/fragment_cloud_goods.xml | 43 ++++ .../main/res/layout/fragment_home_foods.xml | 54 +--- 19 files changed, 660 insertions(+), 216 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/Model/GoodsClassifyBean.java create mode 100644 app/src/main/java/com/bonait/bnframework/Model/ProcessValueUtil.java delete mode 100644 app/src/main/java/com/bonait/bnframework/common/model/mode/GoodsClassifyBean.java create mode 100644 app/src/main/res/layout/fragment_cloud_goods.xml diff --git a/app/src/main/java/com/bonait/bnframework/Model/GoodsClassifyBean.java b/app/src/main/java/com/bonait/bnframework/Model/GoodsClassifyBean.java new file mode 100644 index 00000000..75daf988 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/Model/GoodsClassifyBean.java @@ -0,0 +1,240 @@ +package com.bonait.bnframework.Model; + +import java.util.List; + +/** + * @author: liup + * @description: 菜谱分类云端数据 + * @date: 2024/5/9 11:19. + */ +public class GoodsClassifyBean { + + private String goodsTypeId; + private String goodsTypeName; + private List goodsAttributeList; + private List goodsInfoList; + + public String getGoodsTypeId() { + return goodsTypeId; + } + + public void setGoodsTypeId(String goodsTypeId) { + this.goodsTypeId = goodsTypeId; + } + + public String getGoodsTypeName() { + return goodsTypeName; + } + + public void setGoodsTypeName(String goodsTypeName) { + this.goodsTypeName = goodsTypeName; + } + + public List getGoodsAttributeList() { + return goodsAttributeList; + } + + public void setGoodsAttributeList(List goodsAttributeList) { + this.goodsAttributeList = goodsAttributeList; + } + + public List getGoodsInfoList() { + return goodsInfoList; + } + + public void setGoodsInfoList(List goodsInfoList) { + this.goodsInfoList = goodsInfoList; + } + + public static class GoodsAttributeListBean { + private String goodsAttributeId; + private String goodsAttributeName; + private List goodsAttributeValueList; + + public String getGoodsAttributeId() { + return goodsAttributeId; + } + + public void setGoodsAttributeId(String goodsAttributeId) { + this.goodsAttributeId = goodsAttributeId; + } + + public String getGoodsAttributeName() { + return goodsAttributeName; + } + + public void setGoodsAttributeName(String goodsAttributeName) { + this.goodsAttributeName = goodsAttributeName; + } + + public List getGoodsAttributeValueList() { + return goodsAttributeValueList; + } + + public void setGoodsAttributeValueList(List goodsAttributeValueList) { + this.goodsAttributeValueList = goodsAttributeValueList; + } + + public static class GoodsAttributeValueListBean { + private String goodsAttributeId; + private String goodsAttributeValueId; + private String attributeValue; + + public String getGoodsAttributeId() { + return goodsAttributeId; + } + + public void setGoodsAttributeId(String goodsAttributeId) { + this.goodsAttributeId = goodsAttributeId; + } + + public String getGoodsAttributeValueId() { + return goodsAttributeValueId; + } + + public void setGoodsAttributeValueId(String goodsAttributeValueId) { + this.goodsAttributeValueId = goodsAttributeValueId; + } + + public String getAttributeValue() { + return attributeValue; + } + + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } + } + } + + public static class GoodsInfoListBean { + private String goodsId; + private String goodsName; + private List goodsTechnologyActionList; + + public String getGoodsId() { + return goodsId; + } + + public void setGoodsId(String goodsId) { + this.goodsId = goodsId; + } + + public String getGoodsName() { + return goodsName; + } + + public void setGoodsName(String goodsName) { + this.goodsName = goodsName; + } + + public List getGoodsTechnologyActionList() { + return goodsTechnologyActionList; + } + + public void setGoodsTechnologyActionList(List goodsTechnologyActionList) { + this.goodsTechnologyActionList = goodsTechnologyActionList; + } + + public static class GoodsTechnologyActionListBean { + /** + * 工序名称 + */ + private String stepName; + /** + * 工序参数 + */ + private String actionJson; + /** + * 子属性组合 + */ + private String goodsAttributeId; + private boolean isBatch; + private String chnologyId; + private String groupId; + private int sort; + private String goodsId; + private String deviceId; + private String warehousrTemplateId; + + public String getStepName() { + return stepName; + } + + public void setStepName(String stepName) { + this.stepName = stepName; + } + + public String getActionJson() { + return actionJson; + } + + public void setActionJson(String actionJson) { + this.actionJson = actionJson; + } + + public String getGoodsAttributeId() { + return goodsAttributeId; + } + + public void setGoodsAttributeId(String goodsAttributeId) { + this.goodsAttributeId = goodsAttributeId; + } + + public boolean isIsBatch() { + return isBatch; + } + + public void setIsBatch(boolean isBatch) { + this.isBatch = isBatch; + } + + public String getChnologyId() { + return chnologyId; + } + + public void setChnologyId(String chnologyId) { + this.chnologyId = chnologyId; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public int getSort() { + return sort; + } + + public void setSort(int sort) { + this.sort = sort; + } + + public String getGoodsId() { + return goodsId; + } + + public void setGoodsId(String goodsId) { + this.goodsId = goodsId; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getWarehousrTemplateId() { + return warehousrTemplateId; + } + + public void setWarehousrTemplateId(String warehousrTemplateId) { + this.warehousrTemplateId = warehousrTemplateId; + } + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/Model/ProcessValueUtil.java b/app/src/main/java/com/bonait/bnframework/Model/ProcessValueUtil.java new file mode 100644 index 00000000..57941b51 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/Model/ProcessValueUtil.java @@ -0,0 +1,57 @@ +package com.bonait.bnframework.Model; + +import com.apkfuns.logutils.LogUtils; + +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.HashMap; + +/** + * @author: liup + * @description: + * @date: 2024/5/9 16:57. + */ +public class ProcessValueUtil { + + public static String dealProcessJsonToValue(String json){ + StringBuilder stringBuffer = new StringBuilder(); + try{ + JSONArray array = new JSONArray(json); + for (int i =0 ;i map = new HashMap<>(); + JSONObject dataJson = array.getJSONObject(i); + if(!dataJson.optString("actionName").equals("执行步骤")){ + stringBuffer.append(dataJson.optString("actionName")).append(",").append(dataJson.optString("actionValue")).append("|"); + } + } + if(stringBuffer.length()>0){ + stringBuffer.deleteCharAt(stringBuffer.length()-1); + + } + + }catch (Exception e){ + e.printStackTrace(); + } + LogUtils.d("ProcessValueUtil dealProcessJsonToValue json="+json); + LogUtils.d("ProcessValueUtil dealProcessJsonToValue stringBuffer="+stringBuffer.toString()); + return stringBuffer.toString(); + } + + public static HashMap dealProcessValueToJson(String value){ + HashMap map = new HashMap<>(); + if (value.contains("|")) { + String[] res = value.split("[|]"); + for (String re : res) { + if (re != null && re.contains(",")) { + String[] process = re.split("[,]"); + if (process.length > 1) { + map.put("actionName", process[0]); + map.put("actionValue", process[1]); + } + } + } + } + return map; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java index 8ddd93ef..c3297dbf 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java @@ -1,7 +1,5 @@ package com.bonait.bnframework.ViewModel.ActivityViewModel; -import androidx.viewpager.widget.ViewPager; - import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; @@ -9,12 +7,16 @@ import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.viewpager.widget.ViewPager; + import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.HBL.Logs.MessageLog; import com.bonait.bnframework.HBL.Thread.IThread; import com.bonait.bnframework.HBL.Thread.ThreadManager; import com.bonait.bnframework.R; import com.bonait.bnframework.Service.ModbusHelper; +import com.bonait.bnframework.ViewModel.Adapter.FragmentAdapter; +import com.bonait.bnframework.ViewModel.FragmentViewModel.Home4Fragment; import com.bonait.bnframework.ViewModel.FragmentViewModel.HomeDeviceFragment; import com.bonait.bnframework.business.ConfigData; import com.bonait.bnframework.business.ExecuteTheRecipe; @@ -22,8 +24,8 @@ import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.MessageName; import com.bonait.bnframework.common.db.QueryDB; -import com.bonait.bnframework.common.db.mode.BPA_GOODS_OLD; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; +import com.bonait.bnframework.common.db.mode.BPA_GOODS_OLD; import com.bonait.bnframework.common.helper.CountDownTimerExt; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.message.MessageLooper; @@ -32,9 +34,7 @@ import com.bonait.bnframework.common.utils.NetworkUtils; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.common.view.BottomNavigationBar; import com.bonait.bnframework.manager.ActivityLifecycleManager; -import com.bonait.bnframework.ViewModel.Adapter.FragmentAdapter; -import com.bonait.bnframework.ViewModel.FragmentViewModel.Home4Fragment; -import com.bonait.bnframework.ViewModel.FragmentViewModel.HomeFragmentPR; +import com.bonait.bnframework.ui.fragment.HomeFoodsFragment; import com.lzy.okgo.OkGo; import com.qmuiteam.qmui.widget.QMUIViewPager; @@ -124,7 +124,8 @@ public class BottomNavigationNewActivity extends BaseActivity { */ private void initFragment() { FragmentAdapter fragmentAdapter = new FragmentAdapter(getSupportFragmentManager()); - fragmentAdapter.addFragment(new HomeFragmentPR()); + fragmentAdapter.addFragment(new HomeFoodsFragment()); +// fragmentAdapter.addFragment(new HomeFragmentPR()); fragmentAdapter.addFragment(new Home4Fragment()); // fragmentAdapter.addFragment(new HomeFragmentSBKZ()); fragmentAdapter.addFragment(new HomeDeviceFragment()); diff --git a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java index 61e7ad00..76e1a2e6 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -526,11 +526,6 @@ public class ConfigData { } } - /** - * 获取所有商品信息 - */ - - /** * 获取商品配方信息 * diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java index 9549d1dc..e41b8ba4 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java @@ -3,23 +3,20 @@ package com.bonait.bnframework.common.constant; import android.app.Application; import android.content.Context; +import com.bonait.bnframework.Model.GoodsClassifyBean; import com.bonait.bnframework.R; import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; import com.bonait.bnframework.common.db.mode.BPA_USER; import com.bonait.bnframework.common.db.mode.Res_PLCADDRESS; import com.bonait.bnframework.common.db.res.StatusMode; -import com.bonait.bnframework.common.model.AddrType; import com.bonait.bnframework.common.model.mode.CloudGood; import com.bonait.bnframework.common.model.mode.DeviceInformation; import com.bonait.bnframework.common.model.mode.OrganizeMode; import com.bonait.bnframework.common.model.mode.ProcessT; import com.bonait.bnframework.common.model.mode.ResALLData; -import com.bonait.bnframework.common.model.mode.VersionSelectionEnum; -import com.bonait.bnframework.common.utils.ScreenUtils; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -1030,6 +1027,7 @@ public class ConfigName { * 云端商品 */ public List cloudGoods = new ArrayList<>(); + public List cloudGoodsList = new ArrayList<>(); //endregion //region 选配版本信息 diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_ATTRIBUTE.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_ATTRIBUTE.java index 75972a93..d073ab6a 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_ATTRIBUTE.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_ATTRIBUTE.java @@ -19,13 +19,6 @@ public class BPA_ATTRIBUTE extends ModeBase { */ public String name; - public BPA_ATTRIBUTE(String name,String id){ - this.name = name; - this.id = id; - } - - public BPA_ATTRIBUTE(){} - @Override public String toString() { diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS_CLASSIFY.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS_CLASSIFY.java index 1bcbc42e..56890b7b 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS_CLASSIFY.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS_CLASSIFY.java @@ -15,6 +15,8 @@ public class BPA_GOODS_CLASSIFY extends ModeBase{ */ public int state; + + @Override public String toString() { return "BPA_GOODS_CLASSIFY{" + diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SUBATTRIBUTE.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SUBATTRIBUTE.java index e28599e5..c48fed56 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SUBATTRIBUTE.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SUBATTRIBUTE.java @@ -24,13 +24,6 @@ public class BPA_SUBATTRIBUTE extends ModeBase { */ public String foreignId; - public BPA_SUBATTRIBUTE(String name, String parentAttributeId){ - this.name = name; - this.parentAttributeId = parentAttributeId; - } - - public BPA_SUBATTRIBUTE(){ - } @Override public String toString() { diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/AttributeDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/AttributeDBUtil.java index 745fdf4f..26e81bc3 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/AttributeDBUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/AttributeDBUtil.java @@ -97,5 +97,20 @@ public class AttributeDBUtil { return data; } + /** + * 判断分类下的属性是否存在 + * @param classifyId + * @param name + * @return + */ + public static boolean isExist(String classifyId,String name){ + for(BPA_ATTRIBUTE attribute : getByClassify(classifyId)){ + if(attribute.name.equals(name)){ + return true; + } + } + return false; + } + } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeDBUtil.java index 0033dfb1..a4c88359 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeDBUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeDBUtil.java @@ -80,4 +80,19 @@ public class SubAttributeDBUtil { return data; } + + /** + * 判断子属性是否存在 + * @param parentAttributeId + * @param name + * @return + */ + public static boolean isExist(String parentAttributeId,String name){ + for(BPA_SUBATTRIBUTE subattribute : getByParentAttributeId(parentAttributeId)){ + if(subattribute.name.equals(name)){ + return true; + } + } + return false; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java index cb5b1ce6..9a34200d 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java @@ -133,4 +133,18 @@ public class SubAttributeGroupDBUtil { update(bean); } } + /** + * 判断子属性组合是否存在 + * @param goodsId + * @param name + * @return + */ + public static boolean isExist(String goodsId,String name){ + for(BPA_GOODS_SUBATTRIBUTE_GROUP subattribute : getByGoodsId(goodsId)){ + if(subattribute.name.equals(name)){ + return true; + } + } + return false; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/model/mode/GoodsClassifyBean.java b/app/src/main/java/com/bonait/bnframework/common/model/mode/GoodsClassifyBean.java deleted file mode 100644 index 8b611969..00000000 --- a/app/src/main/java/com/bonait/bnframework/common/model/mode/GoodsClassifyBean.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.bonait.bnframework.common.model.mode; - -/** - * @author: liup - * @description: - * @date: 2024/5/9 11:19. - */ -public class GoodsClassifyBean { - -} diff --git a/app/src/main/java/com/bonait/bnframework/ui/adapter/CloudGoodsAdapter.java b/app/src/main/java/com/bonait/bnframework/ui/adapter/CloudGoodsAdapter.java index 8e6e9529..000d32cf 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/adapter/CloudGoodsAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/ui/adapter/CloudGoodsAdapter.java @@ -1,7 +1,6 @@ package com.bonait.bnframework.ui.adapter; import android.annotation.SuppressLint; -import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -10,35 +9,20 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.bonait.bnframework.R; -import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.common.base.BaseAdapter; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.glide.GlideUtil; import com.bonait.bnframework.common.utils.DisplayManager; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.databinding.ItemCloudGoodsBinding; -import java.util.ArrayList; - /** * @author: liup * @description: 商品列表 * @date: 2024/5/8 15:36. */ -public class CloudGoodsAdapter extends RecyclerView.Adapter { - private Context context; - - private ArrayList dataList; +public abstract class CloudGoodsAdapter extends BaseAdapter { - /** - * 点击事件 - */ - public GoodsOnClickListener mListener = null; - - public CloudGoodsAdapter(Context context, int type, ArrayList data, GoodsOnClickListener _mListener) { - this.context = context; - dataList = data; - mListener = _mListener; - } @NonNull @Override @@ -52,7 +36,7 @@ public class CloudGoodsAdapter extends RecyclerView.Adapter { - private Context context; - - private ArrayList dataList; - - /** - * 点击事件 - */ - public GoodsOnClickListener mListener = null; - - public LocalGoodsAdapter(Context context, int type, ArrayList data, GoodsOnClickListener _mListener) { - this.context = context; - dataList = data; - mListener = _mListener; - } +public abstract class LocalGoodsAdapter extends BaseAdapter { @NonNull @Override @@ -57,19 +40,17 @@ public class LocalGoodsAdapter extends RecyclerView.Adapter groupList = new ArrayList<>(); + GoodsProcessDetailDBUtil.deleteByGoodsId(goods.id); + for (GoodsClassifyBean.GoodsInfoListBean.GoodsTechnologyActionListBean goodsTechnologyActionListBean:goodsInfoListBean.getGoodsTechnologyActionList()){ + //添加子属性组合 + //TODO 需确定getGoodsAttributeId 是用id列表还是name组合 app上新增的id和云端的肯定不匹配 建议用name组合 + if(!groupList.contains(goodsTechnologyActionListBean.getGoodsAttributeId())){ + if(!SubAttributeGroupDBUtil.isExist(goods.id,goodsTechnologyActionListBean.getGoodsAttributeId())){ + BPA_GOODS_SUBATTRIBUTE_GROUP group = new BPA_GOODS_SUBATTRIBUTE_GROUP(); + group.name = goodsTechnologyActionListBean.getGoodsAttributeId(); + group.id = goodsTechnologyActionListBean.getGoodsAttributeId(); + group.goodsId = goods.id; + groupList.add(goodsTechnologyActionListBean.getGoodsAttributeId()); + SubAttributeGroupDBUtil.add(group); + } + } + BPA_GOODS_PROCESS_DETAIL processDetail = new BPA_GOODS_PROCESS_DETAIL(); + processDetail.goodsSubAttributeGroupId = goodsTechnologyActionListBean.getGoodsAttributeId(); + processDetail.materialType = goodsTechnologyActionListBean.getStepName().contains("液体")?0:1; + String value = ProcessValueUtil.dealProcessJsonToValue(goodsTechnologyActionListBean.getActionJson()); + processDetail.processms = ""; + processDetail.processname = goodsTechnologyActionListBean.getStepName(); + processDetail.processvalue = value; + GoodsProcessDetailDBUtil.add(processDetail); + + } + } + break; + } + break; + } + } + + //添加所有工序 + } + return true; + } + + } diff --git a/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java b/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java index e713e10e..01188402 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java +++ b/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java @@ -12,17 +12,24 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.widget.SearchView; import androidx.core.content.ContextCompat; import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.Model.GoodsClassifyBean; import com.bonait.bnframework.R; import com.bonait.bnframework.Service.ModbusHelper; import com.bonait.bnframework.common.base.BaseFragment; import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback; import com.bonait.bnframework.common.message.MessageManager; +import com.bonait.bnframework.common.model.ResListAPI; import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.common.utils.NetworkUtils; +import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.databinding.FragmentHomeFoodsBinding; +import com.lzy.okgo.OkGo; +import com.lzy.okgo.model.HttpHeaders; +import com.lzy.okgo.model.Response; import com.orhanobut.logger.Logger; import butterknife.ButterKnife; @@ -36,8 +43,7 @@ import butterknife.OnClick; public class HomeFoodsFragment extends BaseFragment { private static final String TAG = "HomeFoodsFragment==> "; private FragmentHomeFoodsBinding viewBinding; - - + private BaseFragment fragment; /** * 选中行 */ @@ -80,6 +86,7 @@ public class HomeFoodsFragment extends BaseFragment { DisplayManager.scaleViewGroup(viewBinding.getRoot()); initTopBar(); SelectTab(1); + requestData(); } /** @@ -91,22 +98,6 @@ public class HomeFoodsFragment extends BaseFragment { viewBinding.topbar.addRightTextButton("设备状态:"+ (ModbusHelper.get().getConnected() ? "已连接" : "未连接"),R.id.status_image); handler.sendEmptyMessageDelayed(1,1000L); - viewBinding.searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { - @Override - public boolean onQueryTextSubmit(String s) { - return false; - } - - @Override - public boolean onQueryTextChange(String s) { - initData(); - return false; - } - }); - } - - private void initView(){ - } /** @@ -116,6 +107,47 @@ public class HomeFoodsFragment extends BaseFragment { } + private void requestData(){ + if (NetworkUtils.checkNetworkAvailable(context)) { + if(ConfigName.getInstance().cloudGoodsList.isEmpty()){ + //TODO 对接后台接口 + if (ConfigName.getInstance().organizeMode == null) { + return; + } + ToastUtils.info("正在请求云端数据"); + OkGo.>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetGoods, + ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceId)) + .tag(context) + .headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)) + .execute(new JsonDialogCallback>(context) { + @Override + public void onSuccess(Response> response) { + ResListAPI allDataResAPI = response.body(); + + if (allDataResAPI.succeeded && allDataResAPI.data != null && allDataResAPI.data.size() > 0) { + ConfigName.getInstance().cloudGoodsList.clear(); + ConfigName.getInstance().cloudGoodsList.addAll(allDataResAPI.data); + } + if(handler!=null){ + handler.post(new Runnable() { + @Override + public void run() { + if(fragment!=null){ + if(fragment instanceof CloudGoodsFragment){ + ((CloudGoodsFragment) fragment).updateData(); + } + } + } + }); + } + } + }); + } + } else { + ToastUtils.warning("无网络,请先连接网络!!!"); + } + } + /** * 点击事件 * @@ -131,11 +163,8 @@ public class HomeFoodsFragment extends BaseFragment { case R.id.cloudFoods: LogUtils.d("//////2"); SelectTab(2); + requestData(); break; -// case R.id.search_view: -// search_view.setIconifiedByDefault(false); -// search_view.requestFocus(); -// break; } } @@ -146,19 +175,21 @@ public class HomeFoodsFragment extends BaseFragment { */ public void SelectTab(int index) { SelectIndex = index; + if(index == 1){ + fragment = new LocalGoodsFragment(); + }else { + fragment = new CloudGoodsFragment(); + } + getChildFragmentManager().beginTransaction() + .replace(R.id.frame, fragment) + .commit(); switch (index) { case 1: - if(ConfigName.getInstance().user.name.equals("一般用户")){ - viewBinding.addClassify.setVisibility(View.GONE); - }else { - viewBinding.addClassify.setVisibility(View.VISIBLE); - } viewBinding.localFoods.setTextColor(Color.parseColor("#BEAA6A")); viewBinding.cloudFoods.setTextColor(Color.parseColor("#797373")); initData(); break; case 2: - viewBinding.addClassify.setVisibility(View.GONE); viewBinding.localFoods.setTextColor(Color.parseColor("#797373")); viewBinding.cloudFoods.setTextColor(Color.parseColor("#BEAA6A")); initData(); diff --git a/app/src/main/java/com/bonait/bnframework/ui/fragment/LocalGoodsFragment.java b/app/src/main/java/com/bonait/bnframework/ui/fragment/LocalGoodsFragment.java index 91cebcbc..a3356592 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/fragment/LocalGoodsFragment.java +++ b/app/src/main/java/com/bonait/bnframework/ui/fragment/LocalGoodsFragment.java @@ -18,6 +18,7 @@ import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY; +import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil; import com.bonait.bnframework.common.db.util.GoodsDBUtil; import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil; import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil; @@ -82,15 +83,21 @@ public class LocalGoodsFragment extends BaseFragment { OpenActivity(EditClassifyActivity.class); }); - goodsAdapter = new LocalGoodsAdapter(context, 1, goodsList, new LocalGoodsAdapter.GoodsOnClickListener() { + goodsAdapter = new LocalGoodsAdapter(){ + + @Override + protected void onItemClick(View v, int position) { + + } + @Override - public void addGoods() { - //添加菜品弹窗 + protected void uploadGoods(View v, int position) { } @Override - public void deleteGoods(int position, BPA_GOODS bean) { + protected void deleteGoods(View v, int position) { AlertDialogUtils.showCancelAndConfirmDialog((AppCompatActivity) getActivity(), R.layout.dialog_delete_classify, (layoutView, xCom) -> { + BPA_GOODS bean = mData.get(position); DialogDeleteClassifyBinding binding = DialogDeleteClassifyBinding.bind(layoutView); DisplayManager.scaleViewGroup(binding.getRoot()); binding.title.setText("删除菜品"); @@ -111,10 +118,9 @@ public class LocalGoodsFragment extends BaseFragment { } @Override - public void jumpGoods(int position, BPA_GOODS bean) { - //弹窗 fragmentdialog + protected void addGoods() { } - }); + }; viewBinding.recyclerGoods.setAdapter(goodsAdapter); classifyAdapter =new ClassifyAdapter() { @@ -136,21 +142,31 @@ public class LocalGoodsFragment extends BaseFragment { goodsList.clear(); classifyList.clear(); - -// classifyList.addAll(GoodsClassifyDBUtil.getAll()); -// if(!classifyList.isEmpty()){ -// goodsList.addAll(GoodsDBUtil.getByClassifyId(classifyList.get(0).id)); -// } - + classifyList.addAll(GoodsClassifyDBUtil.getAll()); + if(!classifyList.isEmpty()){ + goodsList.addAll(GoodsDBUtil.getByClassifyId(classifyList.get(0).id)); + } classifyAdapter.setNewData(classifyList); goodsAdapter.notifyDataSetChanged(); } + @Override + public void onPause() { + super.onPause(); + LogUtils.d("LocalGoodsFragment onPause"); + } + + @Override + public void onResume() { + super.onResume(); + LogUtils.d("LocalGoodsFragment onResume"); + } @Override public void onDestroy() { super.onDestroy(); + LogUtils.d("LocalGoodsFragment onDestroy"); if(goodsList!=null){ goodsList.clear(); classifyList.clear(); diff --git a/app/src/main/res/layout/fragment_cloud_goods.xml b/app/src/main/res/layout/fragment_cloud_goods.xml new file mode 100644 index 00000000..9a63067d --- /dev/null +++ b/app/src/main/res/layout/fragment_cloud_goods.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home_foods.xml b/app/src/main/res/layout/fragment_home_foods.xml index f5471df2..df06401c 100644 --- a/app/src/main/res/layout/fragment_home_foods.xml +++ b/app/src/main/res/layout/fragment_home_foods.xml @@ -13,8 +13,9 @@ android:layout_marginTop="?attr/qmui_topbar_height" android:layout_height="match_parent"> + android:layout_height="@dimen/dp_70"> - - - - - - - - - - - - \ No newline at end of file