diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7f464664..c2fb97d9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,9 @@ tools:ignore="GoogleAppIndexingWarning" tools:node="merge" tools:replace="android:icon"> + 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 b994d75e..e7a8e68d 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -247,6 +247,8 @@ public class ConfigData { 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); + ConfigName.getInstance().AutomaticWaterRefill = ConfigUtil.read(ConfigName.getInstance().dishesCon, "AutomaticWaterRefill", ConfigName.getInstance().AutomaticWaterRefill); + } /** @@ -265,6 +267,8 @@ public class ConfigData { 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); + ConfigUtil.write(ConfigName.getInstance().dishesCon,"AutomaticWaterRefill", ConfigName.getInstance().AutomaticWaterRefill); + } /** 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 fc27ba1e..d4afd5e3 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -77,6 +77,10 @@ public class ExecuteTheRecipe { * 扫码信息 */ public static String Code = ""; + /** + * 出杯总量 + */ + public static int MakeGoodCount = 0; /** * 接收到扫码信息,返回 */ @@ -99,6 +103,11 @@ public class ExecuteTheRecipe { */ public static IRun CleaningComplete; + /** + * 自动排水完成 + */ + public static IRun AutoPaiShui; + /** * 当前制作商品 */ @@ -236,9 +245,8 @@ public class ExecuteTheRecipe { // } ReadCode(); - //ReadPLCStatus(); - AutoJR(); + } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } @@ -251,6 +259,23 @@ public class ExecuteTheRecipe { } }); + ThreadManager.Get().StartLong("PLC设备-自动加热补水", true, new IThread() { + @Override + public void Run() throws InterruptedException { + try { + AutoJR(); + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + Thread.sleep(3000); + } + + @Override + public void RunComplete() throws InterruptedException { + + } + }); + ThreadManager.Get().StartLong("PLC设备数据监听-信号检测", true, new IThread() { @Override public void Run() throws InterruptedException { @@ -260,7 +285,7 @@ public class ExecuteTheRecipe { } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } - Thread.sleep(50); + Thread.sleep(100); } @Override public void RunComplete() throws InterruptedException { @@ -691,6 +716,15 @@ public class ExecuteTheRecipe { }); } } + + if (ConfigName.getInstance().PLC_Address.containsKey("配料次数")) { + BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get("配料次数"); + if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) { + ModbusTcpServer.get().ReadInt(plcaddress.address, 1, (data) -> { + MakeGoodCount=data[0] ; + }); + } + } } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } finally { @@ -714,6 +748,10 @@ public class ExecuteTheRecipe { //清洗完成标志 CompleteListen( "自动清洗完成", CleaningComplete); + + //管道自动排水完成 + CompleteListen( "管道自动排水完成", AutoPaiShui); + } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } finally { @@ -762,9 +800,16 @@ public class ExecuteTheRecipe { } } } - if(ConfigName.getInstance().AutomaticHeating) - { + //自动补水 + if(ConfigName.getInstance().AutomaticWaterRefill) + { + Object yw= ReadPLC("水池液位检测"); + boolean isopen=yw==null?false:(boolean) yw; + if(!isopen) + { + WritePLC("水池进水阀",true,null); + } } } } catch (Exception ex) { 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 4582c116..6fca5600 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 @@ -290,7 +290,7 @@ public class ConfigName { add(new Res_PLCADDRESS("通道19校准开关", "M4.2", 1, 1)); add(new Res_PLCADDRESS("通道20校准开关", "M4.3", 1, 1)); - add(new Res_PLCADDRESS("配料次数", "VW90", 1, 1)); + add(new Res_PLCADDRESS("配料次数", "VD90", 1, 1)); //add(new Res_PLCADDRESS("反转时间", "VW94", 1, 1));//pl add(new Res_PLCADDRESS("基准时间", "VW96", 1, 1)); //add(new Res_PLCADDRESS("基准时间", "VW98", 1, 1)); @@ -477,6 +477,13 @@ public class ConfigName { add(new Res_PLCADDRESS("水池液位检测", "M5.2", 1, 0)); add(new Res_PLCADDRESS("出料口检测", "M5.3", 1, 0)); + + add(new Res_PLCADDRESS("水池进水阀", "M103.6", 1, 1)); + add(new Res_PLCADDRESS("水池排水阀-开", "M103.4", 1, 1)); + add(new Res_PLCADDRESS("水池排水阀-关", "M103.5", 1, 1)); + + add(new Res_PLCADDRESS("管道自动排水", "M5.4", 1, 1)); + add(new Res_PLCADDRESS("管道自动排水完成", "M5.5", 1, 1)); }}; /** * 奶茶机工序模型 @@ -591,7 +598,7 @@ public class ConfigName { add(new Res_PLCADDRESS("通道19校准开关", "M4.2", 1, 1)); add(new Res_PLCADDRESS("通道20校准开关", "M4.3", 1, 1)); - add(new Res_PLCADDRESS("配料次数", "VW90", 1, 1)); + add(new Res_PLCADDRESS("配料次数", "VD90", 1, 1)); add(new Res_PLCADDRESS("反转时间", "VW94", 1, 1));//pl //add(new Res_PLCADDRESS("基准时间", "VW96", 1, 1)); add(new Res_PLCADDRESS("基准时间", "VW98", 1, 1)); @@ -757,6 +764,12 @@ public class ConfigName { add(new Res_PLCADDRESS("实时状态", "VW500", 1, 0)); add(new Res_PLCADDRESS("水池液位检测", "M5.2", 1, 0)); add(new Res_PLCADDRESS("出料口检测", "M5.3", 1, 0)); + add(new Res_PLCADDRESS("水池进水阀", "M103.4", 1, 1)); + add(new Res_PLCADDRESS("水池排水阀-开", "M103.5", 1, 1)); + add(new Res_PLCADDRESS("水池排水阀-关", "M103.5", 1, 1)); + + add(new Res_PLCADDRESS("管道自动排水", "M5.4", 1, 1)); + add(new Res_PLCADDRESS("管道自动排水完成", "M5.5", 1, 1)); }}; /** @@ -1059,4 +1072,11 @@ public class ConfigName { */ public Boolean GT2_AutomaticHeating=false; //endregion + + //region 是否自动补水 + /** + * 是否自动补水(水池) + */ + public Boolean AutomaticWaterRefill=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 ba6ce917..9ea109c2 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 @@ -14,6 +14,7 @@ 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_SILOS; import com.bonait.bnframework.common.db.mode.BPA_SUBORDER; +import com.bonait.bnframework.common.db.mode.BPA_SUGAR; import com.bonait.bnframework.common.db.res.MakeStatus; import com.bonait.bnframework.common.db.res.ResGoodProperty; import com.bonait.bnframework.common.db.res.ResGoodsMake; @@ -32,6 +33,7 @@ import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter; import com.bonait.bnframework.modules.home.adapter.lsjy_adapter; import com.bonait.bnframework.modules.home.adapter.pfsx_adapter; import com.bonait.bnframework.modules.home.adapter.wdsz_adapter; +import com.bonait.bnframework.modules.home.adapter.zdqxchid_adapter; import com.bonait.bnframework.modules.home.fragment.mode.sdkz_control; import com.bonait.bnframework.modules.home.fragment.mode.tab_control; @@ -350,6 +352,29 @@ public class DataBus { } //endregion + //region 自动清洗 + public ArrayList zdqx = new ArrayList(); + public zdqxchid_adapter zdqxchidAdapter=null; + public void GetZDQXChid() + { + try { + zdqx.clear(); + ArrayList data= QueryDB.GetSugarALL(); + + for(BPA_SUGAR item:data) + { + zdqx.add(item); + } + if (zdqxchidAdapter!=null) + { + zdqxchidAdapter.refresh(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + //endregion + //region 手动控制 public LinearLayout sdkz_linrarlaout=null; public Activity activity; 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 17661eaf..315017a9 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 @@ -1275,7 +1275,7 @@ public class QueryDB { * 删除商品配方明细 * add fengyoufu 20230413 * - * @param data + * @param * @return 是否成功 */ public static boolean DeleteGoodsSrecipe(String id) { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java index 38d9942e..0c0e3b45 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java @@ -105,7 +105,7 @@ public class BottomNavigationMainActivity extends BaseActivity { //1.同步时间 NetworkUtils.SynchronizationTime(); //主持 - ConfigData.getInstance().GetOrganize(this); + //ConfigData.getInstance().GetOrganize(this); //判断连接环境 ConfigData.getInstance().ToggleEnvironment(); //2.初始化PLC diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java index 8384e405..0f975f49 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java @@ -57,7 +57,6 @@ public class loadinggood_adapter extends RecyclerView.Adapter { - /** - * 内部点击事件 - */ - private MyClickListener mListener; - private List datas= DataBus.getInstance().bpa_goodproperties; +public class pfsx_adapter extends RecyclerView.Adapter { + private ArrayList datas= new ArrayList<>(); int resource1; public Context contextA; - public pfsx_adapter(@NonNull Context context, int resource, @NonNull List objects) { - super(context, resource, objects); - contextA=context; - datas=objects; - this.resource1=resource; + private final LayoutInflater mLayoutInflater; + + public pfsx_adapter(Context context,ArrayList ac) { + this.contextA = context; + datas=ac; + mLayoutInflater = LayoutInflater.from(context); + } + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View inflate = mLayoutInflater.inflate(R.layout.pfsx_item, parent, false); + return new MyViewHolder(inflate); } - //每个子项被滚动到屏幕内的时候会被调用 - @NonNull + @Override - public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { - ResGoodProperty bpa_goodproperty = (ResGoodProperty) getItem(position);//得到当前项选中item实例 - //为每一个子项加载设定的布局 - View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false); - //分别获取 image view 和 textview 的实例 - TextView name = view.findViewById(R.id.name);//属性名称 + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + if (holder instanceof MyViewHolder) { + MyViewHolder myViewHolder = (MyViewHolder) holder; + ResGoodProperty bpa_goodproperty =datas.get(position); + // 设置要显示的图片和文字 - RecyclerView recyclerView=view.findViewById(R.id.recycler_view); - MyLayoutManager layout = new MyLayoutManager(); - layout.setAutoMeasureEnabled(true); - recyclerView.setLayoutManager(layout); - newpropertyselect_adapter zsxadapter = new newpropertyselect_adapter(contextA,bpa_goodproperty.child); - recyclerView.setAdapter(zsxadapter); + MyLayoutManager layout = new MyLayoutManager(); + layout.setAutoMeasureEnabled(true); + myViewHolder.recyclerView.setLayoutManager(layout); + newpropertyselect_adapter zsxadapter = new newpropertyselect_adapter(contextA,bpa_goodproperty.child); + myViewHolder.recyclerView.setAdapter(zsxadapter); - // 设置要显示的图片和文字 - name.setText(bpa_goodproperty.name); + // 设置要显示的图片和文字 + myViewHolder.name.setText(bpa_goodproperty.name); + } + } + @Override + public int getItemCount() { + return datas.size(); + } - return view; + static class MyViewHolder extends RecyclerView.ViewHolder { + RecyclerView recyclerView; + TextView name; + public MyViewHolder(View view) { + super(view); + recyclerView = view.findViewById(R.id.recycler_view); + name = view.findViewById(R.id.name); + } } + } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/zdqxchid_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/zdqxchid_adapter.java new file mode 100644 index 00000000..970ed934 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/zdqxchid_adapter.java @@ -0,0 +1,197 @@ +package com.bonait.bnframework.modules.home.adapter; + +import android.app.Activity; +import android.content.Context; +import android.content.ContextWrapper; +import android.graphics.Color; +import android.os.Handler; +import android.os.Message; +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.common.constant.ConfigName; +import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_SUGAR; +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 zdqxchid_adapter extends RecyclerView.Adapter { + + private final LayoutInflater mLayoutInflater; + + private Context context; + + public List zdqxModes = DataBus.getInstance().zdqx; + public Activity activity; + public zdqxchid_adapter(Context _context, Activity _activity) { + this.context = _context; + activity=_activity; + mLayoutInflater = LayoutInflater.from(context); + + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View inflate = mLayoutInflater.inflate(R.layout.zdqxchid_item, parent, false); + return new ZDQXViewHolder(inflate); + + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + try { + if (holder instanceof ZDQXViewHolder) { + ZDQXViewHolder myViewHolder = (ZDQXViewHolder) holder; + BPA_SUGAR goodsMake= zdqxModes.get(position); + String pssj="0.0"; + String qxsj="0.0"; + String temp="0"; + + if(goodsMake.plcvar.contains("|")) + { + String[] d= goodsMake.plcvar.split("[|]"); + if(d.length>=3) + { + pssj=d[0]; + qxsj=d[1]; + temp=d[2]; + } + } + myViewHolder.name.setText("步骤-"+position+1); + myViewHolder.edittext_pssj.setText(pssj+""); + myViewHolder.edittext_xhsj.setText(qxsj+""); + myViewHolder.edittext_qxwd.setText(temp+""); + + if(goodsMake.exp==null || goodsMake.exp.isEmpty()) + { + myViewHolder.status.setText("未开始"); + myViewHolder.status.setTextColor(Color.parseColor("#99a0aa")); + }else + { + myViewHolder.status.setText(goodsMake.exp); + + if(goodsMake.exp.equals("执行中")) + { + myViewHolder.status.setTextColor(Color.parseColor("#00A8E1")); + + if (!myViewHolder.edittext_pssj.getText().toString().equals("")) { + int k= (int)Math.round((Double.parseDouble(myViewHolder.edittext_pssj.getText().toString()) * 10)); + ExecuteTheRecipe.WritePLC("排水阀排水时间",(short)k,null); + Thread.sleep(50); + } + + if (!myViewHolder.edittext_xhsj.getText().toString().equals("")) { + int k= (int)Math.round((Double.parseDouble(myViewHolder.edittext_xhsj.getText().toString()) * 10)); + ExecuteTheRecipe.WritePLC("循环清洗时间",(short)k,null); + Thread.sleep(50); + } + + if (!myViewHolder.edittext_qxwd.getText().toString().equals("")) { + int k= Integer.parseInt(myViewHolder.edittext_qxwd.getText().toString()); + ExecuteTheRecipe.WritePLC("水池温度设置",k,null); + Thread.sleep(50); + } + + ExecuteTheRecipe.WritePLC("自动清洗开始", true,null); + + }else //执行完成 + { + myViewHolder.status.setTextColor(Color.parseColor("#FF4081")); + + } + } + + + myViewHolder.save_time.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + goodsMake.plcvar=myViewHolder.edittext_pssj.getText().toString()+"|" + +myViewHolder.edittext_xhsj.getText().toString()+"|" + +myViewHolder.edittext_qxwd.getText().toString(); + QueryDB.UpdateSugar(goodsMake); + } + }); + + myViewHolder.delete_time.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + QueryDB.DeleteSugar(goodsMake); + + zdqxModes.remove(position); + notifyDataSetChanged(); + } + }); + } + } 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.runOnUiThread(new Runnable() { + @Override + public void run() { + try { + notifyDataSetChanged(); + } catch (Exception e) { + + } + } + }); + } + + @Override + public int getItemCount() { + return zdqxModes.size(); + } + + public static class ZDQXViewHolder extends RecyclerView.ViewHolder { + EditText edittext_pssj;//排水阀排水时间 + EditText edittext_xhsj;//循环清洗时间 + EditText edittext_qxwd;//清洗温度 + Button save_time;//保存时间 + + Button delete_time; + TextView name;//保存时间 + TextView status;//保存时间 + + public ZDQXViewHolder(View view) { + super(view); + edittext_pssj =view.findViewById(R.id.edittext_pssj); + edittext_xhsj =view.findViewById(R.id.edittext_xhsj); + edittext_qxwd =view.findViewById(R.id.edittext_qxwd); + save_time =view.findViewById(R.id.save_time); + delete_time=view.findViewById(R.id.delete_time); + name =view.findViewById(R.id.name); + status =view.findViewById(R.id.status); + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java index 497f29a7..26d7d255 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java @@ -33,6 +33,7 @@ import com.bonait.bnframework.modules.home.fragment.from.fragment.JiaoYan_dzcjy_ import com.bonait.bnframework.modules.home.fragment.from.fragment.JiaoYan_lsjy_fragment; import com.bonait.bnframework.modules.home.fragment.from.fragment.JiaoYan_sdkz_fragment; import com.bonait.bnframework.modules.home.fragment.from.fragment.JiaoYan_wdsz_fragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.JiaoYan_zdbs_fragment; import com.bonait.bnframework.modules.home.fragment.from.fragment.JiaoYan_zdqx_fragment; import com.orhanobut.logger.Logger; import com.qmuiteam.qmui.widget.QMUITopBarLayout; @@ -92,32 +93,30 @@ public class JiaoYanFragment extends BaseFragment { fragmentList = new ArrayList<>(); menuModes.clear(); -// if (ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) { -// names.add("水池温度"); -// }else -// { -// names.add("水池温度"); -// names.add("果糖左温度"); -// names.add("果糖右温度"); -// } - menuModes.add(new ResMenuLeft(new JiaoYan_dzcjy_fragment(),"电子秤校验", R.mipmap.dzcjy, R.mipmap.dzcjy_select,true)); - menuModes.add(new ResMenuLeft(new JiaoYan_lsjy_fragment(),"流速校验", R.mipmap.lsjy, R.mipmap.lsjy_select,false)); - menuModes.add(new ResMenuLeft(new JiaoYan_clsfbc_fragment(),"出料算法补偿", R.mipmap.clsfbc, R.mipmap.clsfbc_selectd,false)); - - menuModes.add(new ResMenuLeft(new JiaoYan_wdsz_fragment(),"温度设置", R.mipmap.lsjy, R.mipmap.lsjy_select,false)); - menuModes.add(new ResMenuLeft(new JiaoYan_zdqx_fragment(),"自动清洗", R.mipmap.zdqx1, R.mipmap.zdqx1_select,false)); - menuModes.add(new ResMenuLeft(new JiaoYan_sdkz_fragment(),"手动控制", R.mipmap.sdkz, R.mipmap.sdkz_select,false)); + if (ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) { + menuModes.add(new ResMenuLeft(new JiaoYan_dzcjy_fragment(),"电子秤校验", R.mipmap.dzcjy, R.mipmap.dzcjy_select,true)); + menuModes.add(new ResMenuLeft(new JiaoYan_lsjy_fragment(),"流速校验", R.mipmap.lsjy, R.mipmap.lsjy_select,false)); + menuModes.add(new ResMenuLeft(new JiaoYan_clsfbc_fragment(),"出料算法补偿", R.mipmap.clsfbc, R.mipmap.clsfbc_selectd,false)); + + menuModes.add(new ResMenuLeft(new JiaoYan_wdsz_fragment(),"温度设置", R.mipmap.lsjy, R.mipmap.lsjy_select,false)); + menuModes.add(new ResMenuLeft(new JiaoYan_zdqx_fragment(),"自动清洗", R.mipmap.zdqx1, R.mipmap.zdqx1_select,false)); + menuModes.add(new ResMenuLeft(new JiaoYan_zdbs_fragment(),"自动补水", R.mipmap.zdbs, R.mipmap.zdbs_select,false)); + menuModes.add(new ResMenuLeft(new JiaoYan_sdkz_fragment(),"手动控制", R.mipmap.sdkz, R.mipmap.sdkz_select,false)); + }else + { + menuModes.add(new ResMenuLeft(new JiaoYan_dzcjy_fragment(),"电子秤校验", R.mipmap.dzcjy, R.mipmap.dzcjy_select,true)); + menuModes.add(new ResMenuLeft(new JiaoYan_lsjy_fragment(),"流速校验", R.mipmap.lsjy, R.mipmap.lsjy_select,false)); + menuModes.add(new ResMenuLeft(new JiaoYan_wdsz_fragment(),"温度设置", R.mipmap.lsjy, R.mipmap.lsjy_select,false)); + menuModes.add(new ResMenuLeft(new JiaoYan_zdqx_fragment(),"自动清洗", R.mipmap.zdqx1, R.mipmap.zdqx1_select,false)); + menuModes.add(new ResMenuLeft(new JiaoYan_zdbs_fragment(),"自动补水", R.mipmap.zdbs, R.mipmap.zdbs_select,false)); + menuModes.add(new ResMenuLeft(new JiaoYan_sdkz_fragment(),"手动控制", R.mipmap.sdkz, R.mipmap.sdkz_select,false)); + } for(ResMenuLeft item:menuModes) { fragmentList.add(item.fragment); } - //FragmentAdapter fragmentAdapter=new FragmentAdapter(getChildFragmentManager(),fragmentList); ShowFragment(menuModes.get(0).fragment); -// viewpager_jiaoyan.setAdapter(fragmentAdapter); -// viewpager_jiaoyan.setOffscreenPageLimit(5); -// viewpager_jiaoyan.setCurrentItem(0); -// viewpager_jiaoyan.addOnPageChangeListener(pageChangeListener); adapter=new jiaoyan_adapter(getContext(),menuModes); rv_left.setAdapter(adapter); rv_left.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -155,7 +154,6 @@ public class JiaoYanFragment extends BaseFragment { mPosition=position; adapter.notifyDataSetChanged(); ShowFragment(menuModes.get(position).fragment); - //viewpager_jiaoyan.setCurrentItem(position); } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java index 52626637..52167708 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java @@ -103,8 +103,6 @@ public class MakeGoodFragment extends BaseFragment { @BindView(R.id.good_gengxin) Button good_gengxin; - @BindView(R.id.cheng_clear) - Button cheng_clear; /** diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java index 6f0f8d0a..4d9eebc9 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java @@ -24,11 +24,13 @@ import com.bonait.bnframework.common.base.BaseFragment; 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_GOODPROPERTY; 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_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.lcMode; import com.bonait.bnframework.common.helper.I.IRunT; import com.bonait.bnframework.common.helper.I.MyClickListener; @@ -233,7 +235,7 @@ public class GoodPeiFangActivity extends BaseActivity { //打开新建配方界面 BPA_GOODS good=(BPA_GOODS)data; add_pf.setVisibility(View.VISIBLE); - add_pf.SetData(null,good); + add_pf.SetData(null,good,bpa_goodproperties); }else if(k==2) { //修改配方 @@ -243,7 +245,7 @@ public class GoodPeiFangActivity extends BaseActivity { //打开新建配方界面 BPA_GOODS good=(BPA_GOODS)data; add_pf.setVisibility(View.VISIBLE); - add_pf.SetData(SelectDataName,good); + add_pf.SetData(SelectDataName,good,bpa_goodproperties); } } }; @@ -266,13 +268,44 @@ public class GoodPeiFangActivity extends BaseActivity { }; } - + /** + * 属性数据 + */ + ArrayList bpa_goodproperties = new ArrayList<>(); public List Fdata = new ArrayList<>(); /** * 初始化数据 */ public void Initdata() { + + bpa_goodproperties.clear(); + ArrayList da = QueryDB.GetGoodsPropertyALL("0"); + for (BPA_GOODPROPERTY item:da) + { + ResGoodProperty re=new ResGoodProperty(); + re.id=item.id; + re.name=item.name; + + ArrayList zsx =QueryDB.GetGoodsPropertyALL(item.id); + re.child=new ArrayList<>(); + + + ArrayList _chid = new ArrayList<>(); + for (BPA_GOODPROPERTY k:zsx) + { + ResGoodProperty m=new ResGoodProperty(); + m.id=k.id; + m.name=k.name; + m.isSelect=false; + _chid.add(m); + } + re.child=_chid; + + bpa_goodproperties.add(re); + } + + //1.商品类型 goodstypes = QueryDB.GetGoodsTypeALL(); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java index 22f3a5b5..8cedf1eb 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java @@ -176,26 +176,17 @@ public class JiaoYan_lsjy_fragment extends BaseFragment { //endregion ExecuteTheRecipe.WritePLC("校准完成",false,null); - ExecuteTheRecipe.WritePLC("手自切换", false, new IWriteCallBack() { + ExecuteTheRecipe.WritePLC("手自切换", false, null); + ExecuteTheRecipe.WritePLC("通道校准", true, new IWriteCallBack() { @Override public void onSuccess() { - ExecuteTheRecipe.WritePLC("通道校准", true, new IWriteCallBack() { - @Override - public void onSuccess() { - ToastUtils.info("启动通道校准成功!"); - } - @Override - public void onFailure(String ErrorMsg) { - ToastUtils.error("启动通道校准失败!"); - } - }); + ToastUtils.info("启动通道校准成功!"); } @Override public void onFailure(String ErrorMsg) { ToastUtils.error("启动通道校准失败!"); } }); - break; case R.id.kscl://开始出料 String zltext = edittext_cl.getText().toString(); @@ -369,18 +360,19 @@ public class JiaoYan_lsjy_fragment extends BaseFragment { ExecuteTheRecipe.OnChargeMixtureComNotPar = new IRun() { @Override public void Run() { - ToastUtils.warning("通道校准完成!"); if (selectIndexSilos > 0) { final int kkk = selectIndexSilos; try { - new Handler().postDelayed(new Runnable() { + + getActivity().runOnUiThread(new Runnable() { @Override public void run() { + try { + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + ToastUtils.warning("通道校准完成!"); - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - try { // 在2秒后执行按钮操作 ExecuteTheRecipe.WritePLC("校准值"+kkk,(short) zhongliangxianshi,null); @@ -397,13 +389,15 @@ public class JiaoYan_lsjy_fragment extends BaseFragment { { lsjyAdapter.refresh(); } - } catch (Exception e) { - ToastUtils.error("重量解析显示异常!" + e.getMessage()); } - } - }); + }, 2000); + + } catch (Exception e) { + ToastUtils.error("重量解析显示异常!" + e.getMessage()); + } } - }, 1000); + }); + } catch (Exception ex) { Log.d("dsds", "Run: " + ex.getMessage()); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_zdbs_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_zdbs_fragment.java new file mode 100644 index 00000000..f506f4a9 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_zdbs_fragment.java @@ -0,0 +1,91 @@ +package com.bonait.bnframework.modules.home.fragment.from.fragment; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.orhanobut.logger.Logger; +import com.suke.widget.SwitchButton; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class JiaoYan_zdbs_fragment extends BaseFragment { + + @BindView(R.id.control_switch_zdbs) + SwitchButton control_switch_zdbs;//自动补水 + private Context context; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_jiaoyan_zdbs, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + Logger.d("我的fragment创建"); + context = getContext(); + InitView(); + } + + /** + * 初始化界面 + */ + public void InitView() { + Initdata(); + } + + /** + * 初始化数据加载 + */ + public void Initdata() { + control_switch_zdbs.setChecked(ConfigName.getInstance().AutomaticWaterRefill); + control_switch_zdbs.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(SwitchButton view, boolean isChecked) { + //设置 + ConfigName.getInstance().AutomaticWaterRefill=isChecked; + ConfigData.getInstance().SavePZ(); + if(!isChecked) //关闭 + { + ExecuteTheRecipe.WritePLC("水池进水阀",false,null); + } + } + }); + } + + @Override + public void onDestroy() { + super.onDestroy(); + Logger.d("我的fragment销毁"); + ExecuteTheRecipe.WritePLC("清洗模式",false,null); + } + + /** + * 当在activity设置viewPager + BottomNavigation + fragment时, + * 为防止viewPager左滑动切换界面,与fragment左滑返回上一界面冲突引起闪退问题, + * 必须加上此方法,禁止fragment左滑返回上一界面。 + *

+ * 切记!切记!切记!否则会闪退! + *

+ * 当在fragment设置viewPager + BottomNavigation + fragment时,则不会出现这个问题。 + */ + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_zdqx_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_zdqx_fragment.java index 17a4576b..918922ee 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_zdqx_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_zdqx_fragment.java @@ -5,6 +5,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import androidx.viewpager.widget.ViewPager; import android.content.Context; @@ -17,15 +18,22 @@ import android.widget.Button; import android.widget.EditText; import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ConfigData; import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.base.BaseFragment; import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_SUGAR; import com.bonait.bnframework.common.helper.I.IRun; import com.bonait.bnframework.common.helper.I.IWriteCallBack; import com.bonait.bnframework.common.helper.WrapContentLinearLayoutManager; +import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.modules.home.adapter.wdsz_adapter; +import com.bonait.bnframework.modules.home.adapter.zdqxchid_adapter; import com.orhanobut.logger.Logger; +import com.qmuiteam.qmui.widget.dialog.QMUIDialog; +import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; import butterknife.BindView; import butterknife.ButterKnife; @@ -33,16 +41,13 @@ import butterknife.OnClick; public class JiaoYan_zdqx_fragment extends BaseFragment { - @BindView(R.id.edittext_pssj) - EditText edittext_pssj;//排水阀排水时间 - @BindView(R.id.edittext_xhsj) - EditText edittext_xhsj;//循环清洗时间 - - @BindView(R.id.edittext_qxwd) - EditText edittext_qxwd;//清洗温度 @BindView(R.id.bt_start) - Button bt_start;//开始时间 + Button bt_start;//开始清洗 + + @BindView(R.id.Recy_zdqx) + RecyclerView Recy_zdqx;//自动清洗流程 + private Context context; @Override protected View onCreateView() { @@ -66,73 +71,78 @@ public class JiaoYan_zdqx_fragment extends BaseFragment { } boolean IsStart = false; - @OnClick({R.id.save_time,R.id.bt_start}) + @OnClick({R.id.bt_add_zdqx,R.id.bt_start}) public void onViewClicked(View view) { switch (view.getId()) { - case R.id.save_time://保存时间 - new Thread(new Runnable() { - @Override - public void run() { - try { - if (!edittext_pssj.getText().toString().equals("")) { - int k= (int)Math.round((Double.parseDouble(edittext_pssj.getText().toString()) * 10)); - ExecuteTheRecipe.WritePLC("排水阀排水时间",(short)k,null); - Thread.sleep(200); - } - - if (!edittext_xhsj.getText().toString().equals("")) { - int k= (int)Math.round((Double.parseDouble(edittext_xhsj.getText().toString()) * 10)); - ExecuteTheRecipe.WritePLC("循环清洗时间",(short)k,null); - Thread.sleep(200); - } - - if (!edittext_qxwd.getText().toString().equals("")) { - int k= Integer.parseInt(edittext_qxwd.getText().toString()); - ExecuteTheRecipe.WritePLC("水池温度设置",k,null); - Thread.sleep(200); - } - - } catch (InterruptedException e) { - - } catch (Exception e) { - - } - - } - }).start(); - ToastUtils.info("保存成功!"); + case R.id.bt_add_zdqx://增加流程 + BPA_SUGAR sugar=new BPA_SUGAR(); + sugar.plcvar="0.0|0.0|0"; + QueryDB.AddSugar(sugar); + DataBus.getInstance().GetZDQXChid(); + ToastUtils.info("增加成功!"); break; case R.id.bt_start://开始清洗 if (IsStart) { + + String title = "温馨提示!"; + String message = "客官确定要强制停止清洗吗?"; + AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + IsStart=false; + bt_start.setText("开始清洗"); + bt_start.setBackgroundResource(R.drawable.sz_bj); + } + }); ToastUtils.warning("正在清洗中,请勿重复点击!"); return; } + ExecuteTheRecipe.WritePLC("清洗模式", true, new IWriteCallBack() { + @Override + public void onSuccess() { + IsStart=true; + bt_start.setText("正在清洗"); + bt_start.setBackgroundResource(R.drawable.cp_bj); + } + @Override + public void onFailure(String ErrorMsg) { + + } + }); + new Thread(new Runnable() { @Override public void run() { try { - ExecuteTheRecipe.WritePLC("清洗模式",true,null); - ExecuteTheRecipe.WritePLC("自动清洗开始", true, new IWriteCallBack() { - @Override - public void onSuccess() { - //UI线程操作UI控件 - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - IsStart=true; - bt_start.setText("正在清洗"); - bt_start.setBackgroundResource(R.drawable.cp_bj); - } - }); - } - - @Override - public void onFailure(String ErrorMsg) { + for (BPA_SUGAR item: + DataBus.getInstance().zdqx) { + + item.exp="执行中"; + DataBus.getInstance().zdqxchidAdapter.refresh(); + + final boolean[] IsStop = {false}; + ExecuteTheRecipe.CleaningComplete=new IRun() { + @Override + public void Run() { + IsStop[0] =true; + } + }; + + long a = System.currentTimeMillis(); + while (IsStart && !IsStop[0] && IsStart) { + if ((System.currentTimeMillis() - a) > 1000 * 500) { + break; + } + Thread.sleep(100);//10 *6 } - }); + item.exp="执行完成"; + DataBus.getInstance().zdqxchidAdapter.refresh(); + } + + ExecuteTheRecipe.WritePLC("管道自动排水",true,null); } catch (Exception e) { @@ -146,23 +156,6 @@ public class JiaoYan_zdqx_fragment extends BaseFragment { //region 数据加载 - private Handler mHandler = new Handler() { - public void handleMessage(Message msg) { - switch (msg.what) { - case 0: - bt_start.setText("开始清洗"); - bt_start.setBackgroundResource(R.drawable.sz_bj); - break; - case 1: - - break; - case 2: - - break; - } - - } - }; /** * 初始化数据加载 */ @@ -172,40 +165,34 @@ public class JiaoYan_zdqx_fragment extends BaseFragment { @Override public void run() { try { - //填充数据 - Object t1= ExecuteTheRecipe.ReadPLC("排水阀排水时间"); - Object t5= ExecuteTheRecipe.ReadPLC("循环清洗时间"); - Object t7= ExecuteTheRecipe.ReadPLC("水池温度设置"); + DataBus.getInstance().GetZDQXChid(); getActivity().runOnUiThread(new Runnable() { @Override public void run() { - edittext_pssj.setText(t1==null?"0.0":(String.format ("%.1f", (Double.parseDouble(t1.toString())/10)))); - edittext_xhsj.setText(t5==null?"0.0":(String.format ("%.1f", (Double.parseDouble(t5.toString())/10)))); - edittext_qxwd.setText((t7==null?0:(int)t7) +""); + if(isAdded()) + { + Recy_zdqx.setLayoutManager(new WrapContentLinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL,false)); + DataBus.getInstance().zdqxchidAdapter = new zdqxchid_adapter(getContext(),getActivity()); + Recy_zdqx.setAdapter(DataBus.getInstance().zdqxchidAdapter); + } } }); - ExecuteTheRecipe.WritePLC("手自切换",true,null); + } catch (Exception e) { } } }).start(); - - ExecuteTheRecipe.CleaningComplete=new IRun() { + ExecuteTheRecipe.AutoPaiShui=new IRun() { @Override public void Run() { - if (IsStart) { - IsStart = false; - mHandler.sendEmptyMessage(0); - ExecuteTheRecipe.WritePLC("清洗模式",false,null); - ToastUtils.info("清洗完成"); - } + IsStart=false; + bt_start.setText("开始清洗"); + bt_start.setBackgroundResource(R.drawable.sz_bj); } }; - - } catch (Exception e) { } 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 f297e2af..8db96a68 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 @@ -11,9 +11,11 @@ import android.widget.ListView; import android.widget.TextView; import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.db.QueryDB; @@ -50,10 +52,14 @@ public class add_makegood_control extends LinearLayout{ public BPA_GOODS Good = null; @BindView(R.id.datatab_makesx) - ListView datatab_makesx;//属性 + RecyclerView datatab_makesx;//属性 @BindView(R.id.makegoodtitle) TextView makegoodtitle;//配方名称 + + @BindView(R.id.chubeiliang) + TextView chubeiliang; + /** * 点击事件 */ @@ -79,10 +85,15 @@ public class add_makegood_control extends LinearLayout{ private void initData() { //2.填充规则数据,查询所有属性大类 + LinearLayoutManager layoutManager=new LinearLayoutManager(getContext()); + layoutManager.setOrientation(LinearLayoutManager.VERTICAL); + datatab_makesx.setLayoutManager(layoutManager); + if(DataBus.getInstance().sxadapter==null) { - DataBus.getInstance().sxadapter = new pfsx_adapter(contextMian, R.layout.pfsx_item, DataBus.getInstance().bpa_goodproperties); + DataBus.getInstance().sxadapter = new pfsx_adapter(contextMian,DataBus.getInstance().bpa_goodproperties); } + datatab_makesx.setAdapter(DataBus.getInstance().sxadapter); } @@ -95,6 +106,7 @@ public class add_makegood_control extends LinearLayout{ try { Good = good; makegoodtitle.setText(Good.name + ""); + chubeiliang.setText(ExecuteTheRecipe.MakeGoodCount +"杯"); initData(); } catch (Exception ex) { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java index 8bcbe1fd..7a6a6b36 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java @@ -11,6 +11,7 @@ import android.widget.ListView; import android.widget.TextView; import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.bonait.bnframework.R; @@ -27,6 +28,7 @@ import com.bonait.bnframework.common.db.res.ResMaterilas; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.common.view.MyLayoutManager; +import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter; import com.bonait.bnframework.modules.home.adapter.newmeatrilselect_adapter; import com.bonait.bnframework.modules.home.adapter.newneatril_adapter; import com.bonait.bnframework.modules.home.adapter.pfsx_adapter; @@ -57,17 +59,14 @@ public class add_pf_control extends LinearLayout implements MyClickListener { EditText edittext;//配方名称 @BindView(R.id.datatab_sx) - ListView datatab_sx; + RecyclerView datatab_sx; @BindView(R.id.datatab_pf) ListView datatab_pf; @BindView(R.id.title) TextView title;//配方名称 - /** - * 属性数据 - */ - ArrayList bpa_goodproperties = new ArrayList<>(); + /** * 当前物料数据 @@ -75,7 +74,10 @@ public class add_pf_control extends LinearLayout implements MyClickListener { public ArrayList resMaterilas=new ArrayList<>(); - + /** + * 属性数据 + */ + ArrayList bpa_goodproperties = new ArrayList<>(); /** * 点击事件 */ @@ -128,37 +130,7 @@ public class add_pf_control extends LinearLayout implements MyClickListener { recycler_view_wl_click.setAdapter(adapter); //2.填充规则数据,查询所有属性大类 - bpa_goodproperties.clear(); - ArrayList da = QueryDB.GetGoodsPropertyALL("0"); - for (BPA_GOODPROPERTY item:da) - { - ResGoodProperty re=new ResGoodProperty(); - re.id=item.id; - re.name=item.name; - ArrayList zsx =QueryDB.GetGoodsPropertyALL(item.id); - re.child=new ArrayList<>(); - - - ArrayList _chid = new ArrayList<>(); - for (BPA_GOODPROPERTY k:zsx) - { - ResGoodProperty m=new ResGoodProperty(); - m.id=k.id; - m.name=k.name; - if(bpaGoodsrecipename!=null && bpaGoodsrecipename.design!=null && !bpaGoodsrecipename.design.isEmpty() && bpaGoodsrecipename.design.contains(k.id)) - { - m.isSelect=true; - }else - { - m.isSelect=false; - } - _chid.add(m); - } - re.child=_chid; - - bpa_goodproperties.add(re); - } if(bpaGoodsrecipename==null) { @@ -174,10 +146,28 @@ public class add_pf_control extends LinearLayout implements MyClickListener { i++; } } + }else + { + for(ResGoodProperty item:bpa_goodproperties) + { + for(ResGoodProperty c:item.child) + { + if(bpaGoodsrecipename!=null && bpaGoodsrecipename.design!=null && !bpaGoodsrecipename.design.isEmpty() && bpaGoodsrecipename.design.contains(c.id)) + { + c.isSelect=true; + }else + { + c.isSelect=false; + } + } + } } + LinearLayoutManager layoutManager=new LinearLayoutManager(getContext()); + layoutManager.setOrientation(LinearLayoutManager.VERTICAL); + datatab_sx.setLayoutManager(layoutManager); - pfsx_adapter sxadapter = new pfsx_adapter(getContext(), R.layout.pfsx_item, bpa_goodproperties); + pfsx_adapter sxadapter = new pfsx_adapter(getContext(), bpa_goodproperties); datatab_sx.setAdapter(sxadapter); InitTab(); @@ -215,9 +205,10 @@ public class add_pf_control extends LinearLayout implements MyClickListener { * 设置数据 * @param name */ - public void SetData(BPA_GOODSRECIPENAME name, BPA_GOODS good) + public void SetData(BPA_GOODSRECIPENAME name, BPA_GOODS good,ArrayList properties) { try { + bpa_goodproperties=properties; bpaGoodsrecipename=name; Good=good; if(name!=null) @@ -242,8 +233,7 @@ public class add_pf_control extends LinearLayout implements MyClickListener { peifang_queren.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - if (mListener != null) { - SaveData(); + if (mListener != null && SaveData()) { mListener.clickListenerNew(view,1,null); } } @@ -261,7 +251,7 @@ public class add_pf_control extends LinearLayout implements MyClickListener { /** * 保存数据 */ - public void SaveData() + public boolean SaveData() { if(DataValidation()) { @@ -311,7 +301,9 @@ public class add_pf_control extends LinearLayout implements MyClickListener { QueryDB.AddGoodsSrecipe(good); } } + return true; } + return false; } diff --git a/app/src/main/res/layout/activity_bottom_navigation_main.xml b/app/src/main/res/layout/activity_bottom_navigation_main.xml index 9c9a1c4d..578e0f91 100644 --- a/app/src/main/res/layout/activity_bottom_navigation_main.xml +++ b/app/src/main/res/layout/activity_bottom_navigation_main.xml @@ -45,14 +45,17 @@ android:gravity="center|top" android:orientation="vertical"> diff --git a/app/src/main/res/layout/activity_systemparameter.xml b/app/src/main/res/layout/activity_systemparameter.xml index c4594b33..1ddd2cb2 100644 --- a/app/src/main/res/layout/activity_systemparameter.xml +++ b/app/src/main/res/layout/activity_systemparameter.xml @@ -154,8 +154,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content">