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 55a5ee30..2b3cb80a 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -169,7 +169,7 @@ public class ExecuteTheRecipe { if (!text.isEmpty()) { //仓号 值 - HashMap formulation = new HashMap<>(); + HashMap formulation = new HashMap<>(); //region 获取仓号和值 List data = new ArrayList<>(); if (text.contains("|")) { @@ -190,26 +190,26 @@ public class ExecuteTheRecipe { List bpa_silos = QueryDB.GetSolisByMaterialName(name); if (bpa_silos.size() > 0 && val > 0) { BPA_SILOS silos = bpa_silos.get(0); - formulation.put(silos.num, val); + formulation.put(silos, val); } } } } //endregion //写入PLC,直接出料,不用等待 - for (Map.Entry entry : formulation.entrySet()) { - Integer key = entry.getKey(); + for (Map.Entry entry : formulation.entrySet()) { + BPA_SILOS silos = entry.getKey(); Integer value = entry.getValue(); - Write_PLC_Material(key, value); + Write_PLC_Material(silos, value); } Thread.sleep(200);//等待写入完成 //一直等待下料完成 否则就一直等待 40s超时 - for (Map.Entry entry : formulation.entrySet()) { - Integer num = entry.getKey(); + for (Map.Entry entry : formulation.entrySet()) { + BPA_SILOS silos = entry.getKey(); Integer val = entry.getValue(); - String name = "料仓" + num + "下料完成"; + String name = "料仓" + silos.num + "下料完成"; final boolean[] IsComplete = {false}; long a = System.currentTimeMillis(); while (!IsComplete[0]) { @@ -302,26 +302,26 @@ public class ExecuteTheRecipe { /** * 写入仓号需求值 * - * @param num + * @param silos * @param val */ - private static void Write_PLC_Material(int num, int val) { + private static void Write_PLC_Material(BPA_SILOS silos, int val) { try { if(ExecuteCurrentOperation!=null) { - ExecuteCurrentOperation.Run("液体料|"+num); + ExecuteCurrentOperation.Run("液体料|"+silos.num); } - ToastUtils.info("准备写入PLC仓号需求:" + num + "," + val/10.0); + ToastUtils.info("准备写入PLC仓号需求:" + silos.num + "," + val/10.0); - String name = "料仓" + num + "下料完成"; + String name = "料仓" + silos.num + "下料完成"; ExecuteTheRecipe.WritePLC(name, false, null); final boolean[] IsComplete = {false}; - WritePLC("料仓" + num + "需求值", val, new IWriteCallBack() { + WritePLC("料仓" + silos.num + "需求值", val, new IWriteCallBack() { @Override public void onSuccess() { - BottomClick("料仓" + num + "下料"); + BottomClick("料仓" + silos.num + "下料"); IsComplete[0] = true; } @@ -336,7 +336,11 @@ public class ExecuteTheRecipe { } Thread.sleep(100);//10 *6 } - ToastUtils.info("写入PLC仓号需求:" + num + "," + val/10.0); + + //減去料仓数量 + int otherG=silos.silosmargin-(val/10); + QueryDB.UpdateYL(silos.id,otherG>=0?otherG:0); + //ToastUtils.info("写入PLC仓号需求:" + num + "," + val/10.0); } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } @@ -774,6 +778,17 @@ public class ExecuteTheRecipe { try { ToastUtils.info("准备出菜!"); + //先延迟 + for (HashMap.Entry entry : data.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + ToastUtils.info("工序:" + key + "," + value); + if (key.contains("(秒)")) { + int val = Integer.parseInt(value); + Thread.sleep(val * 1000); + } + } + BottomClick("出菜"); //一直等待机器移动到该位置,否则就一直等待 6s超时 @@ -792,16 +807,6 @@ public class ExecuteTheRecipe { Thread.sleep(100);//10 *6 } - - for (HashMap.Entry entry : data.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - ToastUtils.info("工序:" + key + "," + value); - if (key.contains("(秒)")) { - int val = Integer.parseInt(value); - Thread.sleep(val * 1000); - } - } ToastUtils.info("出菜完成,结束制作!"); } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); 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 4c28bac0..8fc1e675 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 @@ -375,7 +375,7 @@ public class ConfigName { add(new ProcessT("液体料", new ArrayList<>())); add(new ProcessT("加水", Arrays.asList("时长(秒)"))); add(new ProcessT("延迟", Arrays.asList("延迟(秒)"))); - add(new ProcessT("出菜", Arrays.asList("延迟(秒)"))); + add(new ProcessT("出菜", Arrays.asList("等待(秒)"))); }}; /** @@ -587,7 +587,7 @@ public class ConfigName { add(new ProcessT("液体料", new ArrayList<>())); add(new ProcessT("加水", Arrays.asList("时长(秒)"))); add(new ProcessT("延迟", Arrays.asList("延迟(秒)"))); - add(new ProcessT("出菜", Arrays.asList("延迟(秒)"))); + add(new ProcessT("出菜", Arrays.asList("等待(秒)"))); }}; /** * 小炒基础PLC模型 @@ -798,7 +798,7 @@ public class ConfigName { add(new ProcessT("液体料", new ArrayList<>())); add(new ProcessT("加水", Arrays.asList("时长(秒)"))); add(new ProcessT("延迟", Arrays.asList("延迟(秒)"))); - add(new ProcessT("出菜", Arrays.asList("延迟(秒)"))); + add(new ProcessT("出菜", Arrays.asList("等待(秒)"))); }}; /** 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 f9f96e6c..d377a7e8 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 @@ -703,6 +703,20 @@ public class QueryDB { Update(BPA_GOODS.class, goods); } } + + /** + * 修改烹饪时长 + * + * @param id + * @param + */ + public static void UpdateGoodsMakeTime(String id, int time) { + BPA_GOODS goods = GetGoodsId(id); + if (goods != null) { + goods.maketime = time; + Update(BPA_GOODS.class, goods); + } + } /** * 获取所有商品 * diff --git a/app/src/main/java/com/bonait/bnframework/common/image/MyBitmapUtils.java b/app/src/main/java/com/bonait/bnframework/common/image/MyBitmapUtils.java index 4fc66fe0..36bf17f4 100644 --- a/app/src/main/java/com/bonait/bnframework/common/image/MyBitmapUtils.java +++ b/app/src/main/java/com/bonait/bnframework/common/image/MyBitmapUtils.java @@ -27,7 +27,7 @@ public class MyBitmapUtils { } public void disPlay(ImageView ivPic, String url) { - ivPic.setImageResource(R.mipmap.loading2); + ivPic.setImageResource(R.mipmap.loading123); Bitmap bitmap; //内存缓存 String name=""; diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java index 79538eff..6f03eaea 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java @@ -303,6 +303,7 @@ public class BottomNavigationNewActivity extends BaseActivity { while (true) { try { if (ExecuteTheRecipe.IsStart && goods != null) { + long startTime= System.currentTimeMillis(); //起始时间 try { //获取工艺 ArrayList goodsrecipes = QueryDB.GetGoodsSrecipeID(goods.id); @@ -329,7 +330,6 @@ public class BottomNavigationNewActivity extends BaseActivity { } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } finally { - ExecuteTheRecipe.WritePLC("搅拌", false, null); ExecuteTheRecipe.WritePLC("加热", false, null); ConfigName.getInstance().IsOpenHuoLi = false; @@ -338,6 +338,11 @@ public class BottomNavigationNewActivity extends BaseActivity { MakeCipe = null; goodsrecipesL = null; ExecuteTheRecipe.IsStart = false; + + long endTime = System.currentTimeMillis(); //结束时间 + int time=(int) ((endTime-startTime)/1000); + Log.e("运行时长",String.format("方法使用时间 %d s",time)); + if (!ExecuteTheRecipe.IsForcedEnd){QueryDB.UpdateGoodsMakeTime(goods.id,time);} runOnUiThread(new Runnable() { @Override public void run() { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter2.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter2.java new file mode 100644 index 00000000..accc9039 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter2.java @@ -0,0 +1,56 @@ +package com.bonait.bnframework.modules.home.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; + +import java.util.ArrayList; + +public class gongxubuzhou_adapter2 extends ArrayAdapter { + /** + * 内部点击事件 + */ + private ArrayList datas= new ArrayList<>(); + + private int selectedPosition = -1;// 选中的位置 + int resource1; + public gongxubuzhou_adapter2(@NonNull Context context, int resource, @NonNull ArrayList objects) { + super(context, resource, objects); + datas=objects; + this.resource1=resource; + } + + public int getSelectedPosition() + { + return selectedPosition; + } + + public void setSelectedPosition(int position) { + selectedPosition = position; + } + //每个子项被滚动到屏幕内的时候会被调用 + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + BPA_GOODSRECIPE lc = (BPA_GOODSRECIPE) getItem(position);//得到当前项选中item实例 + //为每一个子项加载设定的布局 + View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false); + //分别获取 image view 和 textview 的实例 + TextView num = view.findViewById(R.id.num); + TextView name = view.findViewById(R.id.name); + TextView text = view.findViewById(R.id.text); + num.setText((position+1)+""); + name.setText(lc.processname+""); + text.setText(lc.processvalue+""); + return view; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java index f1ab0664..4798c344 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java @@ -506,6 +506,7 @@ public class Home1Fragment extends BaseFragment { try { if (Status && good != null) { + long startTime= System.currentTimeMillis(); //起始时间 try { //获取工艺 ArrayList goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id); @@ -531,6 +532,13 @@ public class Home1Fragment extends BaseFragment { gongxuIndex = 10000; MakeCipe = null; goodsrecipesL = null; + + long endTime = System.currentTimeMillis(); //结束时间 + int time=(int) ((endTime-startTime)/1000); + Log.e("运行时长",String.format("方法使用时间 %d s",time)); + + if (!ExecuteTheRecipe.IsForcedEnd){QueryDB.UpdateGoodsMakeTime(good.id,time);} + Activity activity = getActivity(); if (activity != null) { activity.runOnUiThread(new Runnable() { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java index d0f89289..bb8ec362 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java @@ -31,15 +31,19 @@ import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.constant.MessageName; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; import com.bonait.bnframework.common.helper.I.IWriteCallBack; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.message.MessageManager; import com.bonait.bnframework.common.model.mode.MouthFacingEnum; import com.bonait.bnframework.common.model.mode.SpeedEnum; +import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.modules.home.adapter.gongxubuzhou_adapter; import com.bonait.bnframework.modules.home.adapter.gongxubuzhou_adapter1; +import com.bonait.bnframework.modules.home.adapter.gongxubuzhou_adapter2; import com.bonait.bnframework.modules.home.fragment.mode.fragment_gx; import com.bonait.bnframework.modules.home.fragment.mode.imagebuttom; import com.bonait.bnframework.modules.home.fragment.mode.imagebuttom3; @@ -135,6 +139,9 @@ public class DishTestActivity extends BaseActivity { @BindView(R.id.datatab_gxbz) ListView datatab_gxbz; + @BindView(R.id.datatab_gxbz1) + ListView datatab_gxbz1; + public int ShowIndex=0; @BindView(R.id.goodname) @@ -172,7 +179,8 @@ public class DishTestActivity extends BaseActivity { public String liaohetext4=""; - + @BindView(R.id.gongyibuzhoujilu) + RelativeLayout gongyibuzhoujilu;//记录 //endregion //region 界面实例 @@ -254,8 +262,10 @@ public class DishTestActivity extends BaseActivity { ShowIndex=0; SetShowNameData(ShowIndex); + gongyibuzhoujilu.setVisibility(View.GONE); } public gongxubuzhou_adapter1 gxbz_adapter=null; + public gongxubuzhou_adapter2 gxbz_adapter2=null; /** * 刷新工序 @@ -267,6 +277,9 @@ public class DishTestActivity extends BaseActivity { public void run() { gxbz_adapter = new gongxubuzhou_adapter1(getContext(), R.layout.newgx_item, DataBus.getInstance().bpa_goodsrecipes); datatab_gxbz.setAdapter(gxbz_adapter); + + gxbz_adapter2=new gongxubuzhou_adapter2(getContext(), R.layout.newgx_item1, DataBus.getInstance().bpa_goodsrecipes); + datatab_gxbz1.setAdapter(gxbz_adapter2); } }); } @@ -383,8 +396,8 @@ public class DishTestActivity extends BaseActivity { * * @param view */ - @OnClick({R.id.tingzhijiashui,R.id.click_cpmc,R.id.click_lhdata - ,R.id.click_lhdata_fh,R.id.goodname}) + @OnClick({R.id.tingzhijiashui,R.id.click_cpmc,R.id.click_lhdata,R.id.click_savemncz + ,R.id.click_lhdata_fh,R.id.goodname,R.id.close_from}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.tingzhijiashui://停止加水 @@ -430,6 +443,53 @@ public class DishTestActivity extends BaseActivity { ShowIndex=0; SetShowNameData(ShowIndex); break; + case R.id.click_savemncz://保存菜谱并模拟炒制 + //按钮点击 + String title = "生成菜谱操作提示!"; + String message = "请问客官确定要生成["+DataBus.getInstance().ShowGoodName+"]菜谱吗?"; + AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + boolean isSucess= QueryDB.GetGoodsIs(DataBus.getInstance().ShowGoodName); + if(isSucess) + { + DataBus.getInstance().ShowGoodName=DataBus.getInstance().ShowGoodName+"_副本"; + } + + int sc=DataBus.getInstance().TimeOut<=0?180:DataBus.getInstance().TimeOut; + + ArrayList goods= QueryDB.GetGoodsALL(); + BPA_GOODS good1=new BPA_GOODS(); + good1.name=DataBus.getInstance().ShowGoodName; + good1.status=1; + good1.sort=goods.size()+1; + good1.maketime=sc; + good1.issc=0; + good1.url=""; + QueryDB.AddGoods(good1); + for (int k=0;k0)//如果大于0,那么加一个延迟 - { - DataBus.getInstance().bpa_goodsrecipes.add(Get延迟(time_c)); - } + BPA_GOODSRECIPE data=Get出菜(time_c); DataBus.getInstance().bpa_goodsrecipes.add(data); new Thread(new Runnable() { @Override @@ -1057,13 +1102,13 @@ public class DishTestActivity extends BaseActivity { * 获取出菜 * @return */ - public BPA_GOODSRECIPE Get出菜() + public BPA_GOODSRECIPE Get出菜(int k) { BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE(); pf.materialType=1; pf.processname="出菜"; - pf.processms="出菜(0)"; - pf.processvalue="延迟(秒),0"; + pf.processms="出菜("+k+")"; + pf.processvalue="等待(秒),"+k; return pf; } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java index ac18d2e3..ce774cc2 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java @@ -298,12 +298,7 @@ public class DiyMemoryActivity extends BaseActivity { case R.id.zidongchucan://自动出餐 if(isRunClick()) { - if(time_c>0)//如果大于0,那么加一个延迟 - { - DataBus.getInstance().bpa_goodsrecipes.add(Get延迟(time_c)); - } - - BPA_GOODSRECIPE data1=Get出菜(); + BPA_GOODSRECIPE data1=Get出菜(time_c); DataBus.getInstance().bpa_goodsrecipes.add(data1); MakeRecipe(data1); ClikTime=time; @@ -529,13 +524,13 @@ public class DiyMemoryActivity extends BaseActivity { * 获取出菜 * @return */ - public BPA_GOODSRECIPE Get出菜() + public BPA_GOODSRECIPE Get出菜(int k) { BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE(); pf.materialType=1; pf.processname="出菜"; - pf.processms="出菜(0)"; - pf.processvalue="延迟(秒),0"; + pf.processms="出菜("+k+")"; + pf.processvalue="等待(秒),"+k; return pf; } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/jingdutiao1.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/jingdutiao1.java index 777a6521..1ad9737c 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/jingdutiao1.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/jingdutiao1.java @@ -96,6 +96,7 @@ public class jingdutiao1 extends LinearLayout { int bfb=0; int yl=data.silosmargin; int zl=data.siloszl; + int gj=data.warningValue; if(zl==0) { bfb=0; @@ -105,6 +106,13 @@ public class jingdutiao1 extends LinearLayout { } value=bfb; t_progressBar.setProgress(bfb); + if(yl<=gj) + { + t_progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progress_gj)); + }else + { + t_progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progress_zc)); + } t_text.setText(bfb+"%"); } diff --git a/app/src/main/res/drawable/gongyi_bj.xml b/app/src/main/res/drawable/gongyi_bj.xml new file mode 100644 index 00000000..54b5db9e --- /dev/null +++ b/app/src/main/res/drawable/gongyi_bj.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/layer_list_progress_vertical_high.xml b/app/src/main/res/drawable/layer_list_progress_vertical_high.xml index ee2516a4..d610a243 100644 --- a/app/src/main/res/drawable/layer_list_progress_vertical_high.xml +++ b/app/src/main/res/drawable/layer_list_progress_vertical_high.xml @@ -9,15 +9,16 @@ - //进度条 + //此属性限定为竖向 + android:clipOrientation="vertical"> - + - //第二进度条,可选性添加 + diff --git a/app/src/main/res/drawable/progress_gj.xml b/app/src/main/res/drawable/progress_gj.xml new file mode 100644 index 00000000..a06b05b9 --- /dev/null +++ b/app/src/main/res/drawable/progress_gj.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/progress_zc.xml b/app/src/main/res/drawable/progress_zc.xml new file mode 100644 index 00000000..47be9cfd --- /dev/null +++ b/app/src/main/res/drawable/progress_zc.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_dishtest.xml b/app/src/main/res/layout/activity_dishtest.xml index 90f97840..5f430bf5 100644 --- a/app/src/main/res/layout/activity_dishtest.xml +++ b/app/src/main/res/layout/activity_dishtest.xml @@ -720,6 +720,90 @@ + + + + + + + +