From ef24999b0352d056f6fbee5a52f60d1a3f521586 Mon Sep 17 00:00:00 2001 From: fyf Date: Fri, 6 Oct 2023 11:38:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=A9=E5=BA=A6=E8=AE=BE=E7=BD=AE=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnframework/business/ConfigData.java | 7 +- .../common/constant/ConfigName.java | 45 +++- .../bnframework/common/constant/DataBus.java | 51 +++++ .../bnframework/common/db/res/wdszMode.java | 17 ++ .../common/tabbar/MainNavigateTabBar.java | 2 + .../modules/home/adapter/wdsz_adapter.java | 196 ++++++++++++++++++ .../from/fragment/JiaoYan_wdsz_fragment.java | 14 +- .../main/res/layout/fragment_jiaoyan_wdsz.xml | 15 +- .../main/res/layout/item/layout/wdsz_item.xml | 169 +++++++++++++++ 9 files changed, 507 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/common/db/res/wdszMode.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/adapter/wdsz_adapter.java create mode 100644 app/src/main/res/layout/item/layout/wdsz_item.xml 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 9d4d74c8..974eda83 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -244,7 +244,9 @@ public class ConfigData { ConfigName.getInstance().IsUserDownOrder = ConfigUtil.read(ConfigName.getInstance().dishesCon, "IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder); ConfigName.getInstance().Version = ConfigUtil.read(ConfigName.getInstance().dishesCon, "Version", ConfigName.getInstance().Version); ConfigName.getInstance().HuoLi = ConfigUtil.read(ConfigName.getInstance().dishesCon, "HuoLi", ConfigName.getInstance().HuoLi); - + ConfigName.getInstance().AutomaticHeating = ConfigUtil.read(ConfigName.getInstance().dishesCon, "AutomaticHeating", ConfigName.getInstance().AutomaticHeating); + ConfigName.getInstance().GT1_AutomaticHeating = ConfigUtil.read(ConfigName.getInstance().dishesCon, "GT1_AutomaticHeating", ConfigName.getInstance().GT1_AutomaticHeating); + ConfigName.getInstance().GT2_AutomaticHeating = ConfigUtil.read(ConfigName.getInstance().dishesCon, "GT2_AutomaticHeating", ConfigName.getInstance().GT2_AutomaticHeating); } /** @@ -260,6 +262,9 @@ public class ConfigData { ConfigUtil.write(ConfigName.getInstance().dishesCon, "IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder); ConfigUtil.write(ConfigName.getInstance().dishesCon, "Version", ConfigName.getInstance().Version); ConfigUtil.write(ConfigName.getInstance().dishesCon, "HuoLi", ConfigName.getInstance().HuoLi); + ConfigUtil.write(ConfigName.getInstance().dishesCon,"AutomaticHeating", ConfigName.getInstance().AutomaticHeating); + ConfigUtil.write(ConfigName.getInstance().dishesCon,"GT1_AutomaticHeating", ConfigName.getInstance().GT1_AutomaticHeating); + ConfigUtil.write(ConfigName.getInstance().dishesCon,"GT2_AutomaticHeating", ConfigName.getInstance().GT2_AutomaticHeating); } /** 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 01066304..cde1a0d0 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 @@ -387,7 +387,19 @@ public class ConfigName { //温度监控 add(new Res_PLCADDRESS("温度控制", "-------------", 0, 0)); add(new Res_PLCADDRESS("水池温度", "VD352", 1, 0)); - add(new Res_PLCADDRESS("水池温度设置", "VD360", 1, 1)); + add(new Res_PLCADDRESS("水池温度上限", "VD360", 1, 1)); + add(new Res_PLCADDRESS("水池温度下限", "VD368", 1, 1)); + add(new Res_PLCADDRESS("水池温度加热", "M104.0", 1, 0)); + + add(new Res_PLCADDRESS("果糖左温度", "VD352", 1, 0)); + add(new Res_PLCADDRESS("果糖左温度上限", "VD388", 1, 1)); + add(new Res_PLCADDRESS("果糖左温度下限", "VD392", 1, 1)); + add(new Res_PLCADDRESS("果糖左温度加热", "M104.0", 1, 0)); + + add(new Res_PLCADDRESS("果糖右温度", "VD352", 1, 0)); + add(new Res_PLCADDRESS("果糖右温度上限", "VD396", 1, 1)); + add(new Res_PLCADDRESS("果糖右温度下限", "VD400", 1, 1)); + add(new Res_PLCADDRESS("果糖右温度加热", "M104.0", 1, 0)); //手动控制 add(new Res_PLCADDRESS("手动控制", "-------------", 0, 0)); @@ -604,7 +616,20 @@ public class ConfigName { //温度监控 add(new Res_PLCADDRESS("温度控制", "-------------", 0, 0)); add(new Res_PLCADDRESS("水池温度", "VD352", 1, 0)); - add(new Res_PLCADDRESS("水池温度设置", "VD360", 1, 1)); + add(new Res_PLCADDRESS("水池温度上限", "VD360", 1, 1)); + add(new Res_PLCADDRESS("水池温度下限", "VD368", 1, 1)); + add(new Res_PLCADDRESS("水池温度加热", "VD352", 1, 0)); + + add(new Res_PLCADDRESS("果糖左温度", "VD352", 1, 0)); + add(new Res_PLCADDRESS("果糖左温度上限", "VD388", 1, 1)); + add(new Res_PLCADDRESS("果糖左温度下限", "VD392", 1, 1)); + add(new Res_PLCADDRESS("果糖左温度加热", "VD352", 1, 0)); + + add(new Res_PLCADDRESS("果糖右温度", "VD352", 1, 0)); + add(new Res_PLCADDRESS("果糖右温度上限", "VD396", 1, 1)); + add(new Res_PLCADDRESS("果糖右温度下限", "VD400", 1, 1)); + add(new Res_PLCADDRESS("果糖右温度加热", "VD352", 1, 0)); + //手动控制 add(new Res_PLCADDRESS("手动控制", "-------------", 0, 0)); @@ -866,7 +891,6 @@ public class ConfigName { public String versionSelectionEnum = "奶茶机"; //endregion - //region 主页 /** * 主页流 @@ -889,4 +913,19 @@ public class ConfigName { } }; //endregion + + //region 是否自动加热 + /** + * 是否自动加热(水池) + */ + public Boolean AutomaticHeating=false; + /** + * 果糖1 + */ + public Boolean GT1_AutomaticHeating=false; + /** + * 果糖2 + */ + public Boolean GT2_AutomaticHeating=false; + //endregion } 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 283c4c28..a26c7eaf 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 @@ -17,12 +17,14 @@ import com.bonait.bnframework.common.db.res.ResGoodsRecipe; import com.bonait.bnframework.common.db.res.SilosLsjyMode; import com.bonait.bnframework.common.db.res.StatusMode; import com.bonait.bnframework.common.db.res.lcMode; +import com.bonait.bnframework.common.db.res.wdszMode; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.helper.mode.OrderA; import com.bonait.bnframework.common.helper.mode.ResultA; import com.bonait.bnframework.modules.home.adapter.lc_adapter; import com.bonait.bnframework.modules.home.adapter.lsjy_adapter; import com.bonait.bnframework.modules.home.adapter.sp_adapter; +import com.bonait.bnframework.modules.home.adapter.wdsz_adapter; import java.util.ArrayList; import java.util.HashMap; @@ -325,4 +327,53 @@ public class DataBus { } } //endregion + + //region 温度设置 + public ArrayList wdszModes = new ArrayList(); + public wdsz_adapter wdszAdapter=null; + public void GetWdsz() + { + try { + wdszModes=new ArrayList<>(); + + List names=new ArrayList<>(); + if (ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) { + names.add("水池温度"); + }else + { + names.add("水池温度"); + names.add("果糖左温度"); + names.add("果糖右温度"); + } + for (String item:names) + { + wdszMode mode=new wdszMode(); + mode.name=item; + mode.temp=0; + Object sx=ExecuteTheRecipe.getListingValue(item+"上限"); + mode.tempup=sx==null?0:(int)sx; + Object xx=ExecuteTheRecipe.getListingValue(item+"下限"); + mode.tempdown=xx==null?0:(int)xx; + + if(item.equals("水池温度")) + { + mode.autoheat=ConfigName.getInstance().AutomaticHeating; + } else if (item.equals("果糖左温度")) { + mode.autoheat=ConfigName.getInstance().GT1_AutomaticHeating; + }else if (item.equals("果糖右温度")) { + mode.autoheat=ConfigName.getInstance().GT2_AutomaticHeating; + } + wdszModes.add(mode); + } + + + if (wdszAdapter!=null) + { + wdszAdapter.refresh(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + //endregion } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/res/wdszMode.java b/app/src/main/java/com/bonait/bnframework/common/db/res/wdszMode.java new file mode 100644 index 00000000..bba8364e --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/db/res/wdszMode.java @@ -0,0 +1,17 @@ +package com.bonait.bnframework.common.db.res; + +/** + * 温度设置 + */ +public class wdszMode { + //名称 + public String name; + //上限 + public int tempup; + //下限 + public int tempdown; + //当前温度 + public int temp; + //自动加热 + public boolean autoheat; +} diff --git a/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java b/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java index d39e307c..bc7ebfce 100644 --- a/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java +++ b/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java @@ -358,6 +358,8 @@ public class MainNavigateTabBar extends LinearLayout implements View.OnClickList { //刷新料仓 DataBus.getInstance().GetSilosLsjy(); + //刷新温度控制 + DataBus.getInstance().GetWdsz(); } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wdsz_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wdsz_adapter.java new file mode 100644 index 00000000..75afc34b --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wdsz_adapter.java @@ -0,0 +1,196 @@ +package com.bonait.bnframework.modules.home.adapter; + +import android.app.Activity; +import android.content.Context; +import android.content.ContextWrapper; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.business.MainInit; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.db.res.SilosLsjyMode; +import com.bonait.bnframework.common.db.res.wdszMode; +import com.bonait.bnframework.common.helper.I.IWriteCallBack; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.suke.widget.SwitchButton; + +import java.util.List; + +public class wdsz_adapter extends RecyclerView.Adapter { + + private final LayoutInflater mLayoutInflater; + + private Context context; + + public List wdszModes = DataBus.getInstance().wdszModes; + + public wdsz_adapter(Context context) { + this.context = context; + mLayoutInflater = LayoutInflater.from(context); + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View inflate = mLayoutInflater.inflate(R.layout.wdsz_item, parent, false); + return new WDSZViewHolder(inflate); + + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + try { + if (holder instanceof WDSZViewHolder) { + WDSZViewHolder myViewHolder = (WDSZViewHolder) holder; + wdszMode goodsMake= wdszModes.get(position); + + myViewHolder.name.setText(goodsMake.name+""); + myViewHolder.edittext_sx.setText(goodsMake.tempup+""); + myViewHolder.edittext_xx.setText(goodsMake.tempdown+""); + myViewHolder.temp.setText(goodsMake.temp+""); + myViewHolder.control_switch.setChecked(goodsMake.autoheat); + + myViewHolder.control_switch.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(SwitchButton view, boolean isChecked) { + if(goodsMake.name.equals("水池温度")) + { + ConfigName.getInstance().AutomaticHeating=goodsMake.autoheat; + } else if (goodsMake.name.equals("果糖左温度")) { + ConfigName.getInstance().GT1_AutomaticHeating=goodsMake.autoheat; + }else if (goodsMake.name.equals("果糖右温度")) { + ConfigName.getInstance().GT2_AutomaticHeating=goodsMake.autoheat; + } + ConfigData.getInstance().SavePZ(); + + if(!isChecked) //关闭加热 + { + ExecuteTheRecipe.WritePLC(goodsMake.name+"加热",false,null); + } + } + }); + + myViewHolder.save_value.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int up = Integer.parseInt((myViewHolder.edittext_sx.getText().toString().isEmpty() ? "0" : myViewHolder.edittext_sx.getText().toString())); + if (up <= 0) { + ToastUtils.error("温度上限不能小于0!请调整后重试."); + return; + } + + int down = Integer.parseInt((myViewHolder.edittext_xx.getText().toString().isEmpty() ? "0" : myViewHolder.edittext_xx.getText().toString())); + if (up <= 0) { + ToastUtils.error("温度下限不能小于0!请调整后重试."); + return; + } + + if(up<=down) + { + ToastUtils.error("温度上限不能小于等于温度下限!请调整后重试."); + return; + } + + ExecuteTheRecipe.WritePLC(goodsMake.name+"上限",up,null); + ExecuteTheRecipe.WritePLC(goodsMake.name + "下限", down, new IWriteCallBack() { + @Override + public void onSuccess() { + ToastUtils.info(goodsMake.name+"保存成功!"); + } + + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error(goodsMake.name+"保存失败!"); + } + }); + } + }); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + private Activity findActivity(@NonNull Context context) { + if (context instanceof Activity) { + return (Activity) context; + } else if (context instanceof ContextWrapper) { + return findActivity(((ContextWrapper) context).getBaseContext()); + } else { + return null; + } + } + /** + * 刷新 + * @param + */ + public void refresh(){ + Activity activity= findActivity(context); + if(activity!=null) + { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + try { + wdszModes.clear(); + wdszModes = DataBus.getInstance().wdszModes; + notifyDataSetChanged(); + } catch (Exception e) { + + } + } + }); + } + } + + @Override + public int getItemCount() { + return wdszModes.size(); + } + + public static class WDSZViewHolder extends RecyclerView.ViewHolder { + /** + * 名称 + */ + TextView name; + /** + * 温度上限 + */ + EditText edittext_sx; + /** + * 温度下限 + */ + EditText edittext_xx; + /** + * 当前温度 + */ + TextView temp; + /** + * 自动加热 + */ + SwitchButton control_switch; + /** + * 保存值 + */ + Button save_value; + public WDSZViewHolder(View view) { + super(view); + name = (TextView) view.findViewById(R.id.name); + edittext_sx=(EditText) view.findViewById(R.id.edittext_sx); + edittext_xx=(EditText) view.findViewById(R.id.edittext_xx); + temp = (TextView) view.findViewById(R.id.temp); + control_switch = (SwitchButton)view.findViewById(R.id.control_switch); + save_value=(Button) view.findViewById(R.id.save_value); + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_wdsz_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_wdsz_fragment.java index d37924a0..31d80370 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_wdsz_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_wdsz_fragment.java @@ -3,6 +3,8 @@ package com.bonait.bnframework.modules.home.fragment.from.fragment; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.content.Context; import android.os.Bundle; @@ -11,14 +13,20 @@ import android.view.View; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.helper.WrapContentLinearLayoutManager; +import com.bonait.bnframework.modules.home.adapter.lsjy_adapter; +import com.bonait.bnframework.modules.home.adapter.wdsz_adapter; import com.orhanobut.logger.Logger; +import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; public class JiaoYan_wdsz_fragment extends BaseFragment { - + @BindView(R.id.Recy_wdsz) + RecyclerView Recy_wdsz;//温度设置 private Context context; @Override protected View onCreateView() { @@ -58,6 +66,10 @@ public class JiaoYan_wdsz_fragment extends BaseFragment { */ public void Initdata() { try { + DataBus.getInstance().GetWdsz(); + Recy_wdsz.setLayoutManager(new WrapContentLinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL,false)); + DataBus.getInstance().wdszAdapter = new wdsz_adapter(getContext()); + Recy_wdsz.setAdapter(DataBus.getInstance().wdszAdapter); } catch (Exception e) { diff --git a/app/src/main/res/layout/fragment_jiaoyan_wdsz.xml b/app/src/main/res/layout/fragment_jiaoyan_wdsz.xml index 799eb384..03fe2a43 100644 --- a/app/src/main/res/layout/fragment_jiaoyan_wdsz.xml +++ b/app/src/main/res/layout/fragment_jiaoyan_wdsz.xml @@ -10,10 +10,17 @@ android:layout_height="match_parent" android:background="@color/main_background" android:orientation="vertical"> - + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item/layout/wdsz_item.xml b/app/src/main/res/layout/item/layout/wdsz_item.xml new file mode 100644 index 00000000..3786cac4 --- /dev/null +++ b/app/src/main/res/layout/item/layout/wdsz_item.xml @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +