From a23f0c27a9d5b2fca43ffac79bd5e27745b063f0 Mon Sep 17 00:00:00 2001 From: fyf <11621@LAPTOP-04QQU0AO> Date: Sun, 21 Jan 2024 14:53:06 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=AE=B0=E5=BD=95=E6=97=B6=E9=95=BF=E5=87=8F?= =?UTF-8?q?=E5=8E=BB=E6=89=8B=E5=8A=A8=E7=AD=89=E5=BE=85=E6=97=B6=E9=97=B4?= =?UTF-8?q?=202.=E6=89=8B=E5=8A=A8=E7=AD=89=E5=BE=85=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=9A=82=E5=81=9C=E5=80=92=E8=AE=A1=E6=97=B6=203.=E8=87=AD?= =?UTF-8?q?=E9=BC=AC=E6=97=B6=E9=97=B4=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnframework/business/ConfigData.java | 7 ++ .../business/ExecuteTheRecipe.java | 86 ++++++++++++++++++- .../common/constant/ConfigName.java | 11 +++ .../home/fragment/from/DiyActivity.java | 37 ++++++++ .../fragment/from/DiyUpdate1Activity.java | 42 +++++++++ .../home/fragment/from/DiyUpdateActivity.java | 43 ++++++++++ .../fragment/SystemCsMonitorFragment.java | 2 + 7 files changed, 226 insertions(+), 2 deletions(-) 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 de781b2b..d8a2695f 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -305,6 +305,9 @@ public class ConfigData { ConfigName.getInstance().jiarewendingCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "jiarewendingCount", ConfigName.getInstance().jiarewendingCount ); ConfigName.getInstance().RunCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "RunCount", ConfigName.getInstance().RunCount ); + ConfigName.getInstance().AutoCCTime = ConfigUtil.read(ConfigName.getInstance().dishesCon, "AutoCCTime", ConfigName.getInstance().AutoCCTime ); + ConfigName.getInstance().AutoQXTime = ConfigUtil.read(ConfigName.getInstance().dishesCon, "AutoQXTime", ConfigName.getInstance().AutoQXTime ); + } /** @@ -334,6 +337,10 @@ public class ConfigData { ConfigUtil.write(ConfigName.getInstance().dishesCon, "jiarewendingCount", ConfigName.getInstance().jiarewendingCount ); ConfigUtil.write(ConfigName.getInstance().dishesCon, "RunCount", ConfigName.getInstance().RunCount ); + + ConfigUtil.write(ConfigName.getInstance().dishesCon, "AutoCCTime", ConfigName.getInstance().AutoCCTime ); + ConfigUtil.write(ConfigName.getInstance().dishesCon, "AutoQXTime", ConfigName.getInstance().AutoQXTime ); + } /** 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 f3413c45..ec1f088f 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -9,6 +9,7 @@ import android.util.Log; import androidx.annotation.NonNull; +import com.aliyun.alink.linksdk.channel.core.base.INet; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.constant.MessageName; @@ -255,6 +256,7 @@ public class ExecuteTheRecipe { //仓号 值 HashMap formulation = new HashMap<>(); + int MaxValue=0; //region 获取仓号和值 List data = new ArrayList<>(); if (text.contains("|")) { @@ -279,9 +281,18 @@ public class ExecuteTheRecipe { if(val>=32767) { val=32767; - ThreadWhile("料仓" + silos.num + "出量克数溢出,已按照最大出量出料!!!"); + ExecuteTheRecipe.showlog("料仓" + silos.num + "出量克数溢出,已按照最大出量出料!!!"); } formulation.put(silos, val); + + Object jz_z=ReadPLC("料仓"+silos.num+"校准值"); + if(jz_z!=null) + { + int jzzz= Integer.parseInt(String.valueOf(jz_z)); + int jzzz_1=jzzz==0?500:jzzz; + int ztime= (int)(val/ (jzzz_1/5.0)); + MaxValue=ztime>MaxValue?ztime:MaxValue; + } } } } @@ -299,7 +310,7 @@ public class ExecuteTheRecipe { //一直等待下料完成 否则就一直等待 40s超时 for (Map.Entry entry : formulation.entrySet()) { BPA_SILOS silos = entry.getKey(); - ThreadWhile("料仓" + silos.num + "下料完成"); + ThreadWhile_WL("料仓" + silos.num + "下料完成",MaxValue); } long endTime = System.currentTimeMillis(); //结束时间 @@ -2063,6 +2074,7 @@ public class ExecuteTheRecipe { int mmmm=delay- (int) ((System.currentTimeMillis() - startTime)/1000); if (AtPresentTime!=mmmm) { + AtPresentTime=mmmm; if (NoticeAtPresentTime!=null){NoticeAtPresentTime.Run(mmmm);} } } catch (InterruptedException ex) { @@ -2074,7 +2086,49 @@ public class ExecuteTheRecipe { int time = (int) ((endTime - startTime) / 1000); ExecuteTheRecipe.showlog("工序线程等待结束-------总耗时:" + time); } + /** + * 线程等待 + * + * @param name + */ + public static void ThreadWhile_WL(String name,int time) { + //"炒菜位1反馈"; + int AtPresentTime=time; + if (NoticeAtPresentTime!=null){NoticeAtPresentTime.Run(AtPresentTime);} + final boolean[] IsComplete = {false}; + long a = System.currentTimeMillis(); + ExecuteTheRecipe.showlog(name + ",等待中"); + while (!IsComplete[0] && !IsForcedEnd && ConfigName.getInstance().PlcIsConnect) { + if ((System.currentTimeMillis() - a) > 1000 * whileTime) { + ExecuteTheRecipe.showlog(name + ",异常超时退出!"); + break; + } else { + Object sb = ReadPLC(name); + if (sb != null) { + IsComplete[0] = (boolean) (sb); + if(IsComplete[0]) + { + ExecuteTheRecipe.showlog(name + ",接收到信号!"); + } + } + } + try { + int mmmm=time- (int) ((System.currentTimeMillis() - a)/1000); + if (AtPresentTime!=mmmm) + { + AtPresentTime=mmmm; + if (NoticeAtPresentTime!=null){NoticeAtPresentTime.Run(mmmm);} + } + Thread.sleep(100);//10 *6 + } catch (InterruptedException e) { + IsComplete[0] = true; + ExecuteTheRecipe.showlog(name + ",异常退出!" + e.getMessage()); + } + } + if (NoticeAtPresentTime!=null){NoticeAtPresentTime.Run(0);} + ExecuteTheRecipe.showlog(name + ",等待结束!"); + } /** * 线程等待 * @@ -2116,6 +2170,10 @@ public class ExecuteTheRecipe { */ public static void ThreadWhile3(String name, int k) { //"炒菜位1反馈"; + int time=name.contains("清洗")?ConfigName.getInstance().AutoQXTime:ConfigName.getInstance().AutoCCTime; + int AtPresentTime=time; + if (NoticeAtPresentTime!=null){NoticeAtPresentTime.Run(AtPresentTime);} + final boolean[] IsComplete = {false}; long a = System.currentTimeMillis(); ExecuteTheRecipe.showlog(name + ",等待中"); @@ -2134,12 +2192,36 @@ public class ExecuteTheRecipe { } } try { + int mmmm=time- (int) ((System.currentTimeMillis() - a)/1000); + if (AtPresentTime!=mmmm) + { + AtPresentTime=mmmm; + if (NoticeAtPresentTime!=null){NoticeAtPresentTime.Run(mmmm);} + } Thread.sleep(100);//10 *6 } catch (InterruptedException e) { IsComplete[0] = true; ExecuteTheRecipe.showlog(name + ",异常退出!" + e.getMessage()); } } + int xhtime= (int) ((System.currentTimeMillis() - a)/1000); + if(name.contains("清洗")) + { + ConfigName.getInstance().AutoQXTime=xhtime; + }else + { + ConfigName.getInstance().AutoCCTime=xhtime; + } + + Activity activity = findActivity(context); + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + ConfigData.getInstance().SavePZ(); + } + }); + + if (NoticeAtPresentTime!=null){NoticeAtPresentTime.Run(0);} ExecuteTheRecipe.showlog(name + ",等待结束!"); } //endregion 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 f320655a..ae383acb 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 @@ -1482,4 +1482,15 @@ public class ConfigName { */ public int RunCount = 0; //endregion + + //region 出餐和清洗时间 + /** + * 出餐时间 + */ + public int AutoCCTime=10; + /** + * 清洗时间 + */ + public int AutoQXTime=10; + //endregion } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java index 1778bdd0..025660dc 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java @@ -501,6 +501,13 @@ public class DiyActivity extends BaseActivity { ToastUtils.info("菜谱名称已存在!"); return; } + + if(!IsHotJ()) + { + ToastUtils.warning("加热工序之前,必须先添加搅拌工序!"); + return; + } + //按钮点击 String title = "生成菜谱操作提示!"; String message = "请问客官确定要生成[" + name + "]菜谱吗?"; @@ -538,6 +545,36 @@ public class DiyActivity extends BaseActivity { } } + /** + * 判断数据是否合法 + */ + public boolean IsHotJ() + { + int index=0; + int k=0;int j=0; + for(BPA_GOODSRECIPE item:bpa_goodsrecipes) + { + if(item.processname.contains("搅拌") && k==0) + { + k=index; + } + + if(item.processname.contains("加热") && j==0) + { + j=index; + } + index++; + } + + if(j<=k) + { + return false; + }else + { + return true; + } + } + public void SetSelectPos(int index) { //移动光标 gxbz_adapter.setSelectedPosition(index); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java index 03f57b78..0bc3d12e 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java @@ -483,6 +483,13 @@ public class DiyUpdate1Activity extends BaseActivity { ToastUtils.info("菜谱名称已存在!"); return; } + + if(!IsHotJ()) + { + ToastUtils.warning("加热工序之前,必须先添加搅拌工序!"); + return; + } + //按钮点击 String title = "生成菜谱操作提示!"; String message = "请问客官确定要生成[" + name1 + "]菜谱吗?"; @@ -530,6 +537,11 @@ public class DiyUpdate1Activity extends BaseActivity { ToastUtils.info("菜谱名称已存在!"); return; } + if(!IsHotJ()) + { + ToastUtils.warning("加热工序之前,必须先添加搅拌工序!"); + return; + } //按钮点击 String title = "保存菜谱操作提示!"; String message = "请问客官确定要保存[" + name + "]菜谱吗?"; @@ -566,6 +578,36 @@ public class DiyUpdate1Activity extends BaseActivity { } } + /** + * 判断数据是否合法 + */ + public boolean IsHotJ() + { + int index=0; + int k=0;int j=0; + for(BPA_GOODSRECIPE item:bpa_goodsrecipes) + { + if(item.processname.contains("搅拌") && k==0) + { + k=index; + } + + if(item.processname.contains("加热") && j==0) + { + j=index; + } + index++; + } + + if(j<=k) + { + return false; + }else + { + return true; + } + } + public void SetSelectPos(int index) { //移动光标 gxbz_adapter.setSelectedPosition(index); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java index 38308de1..3daa6edd 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java @@ -552,6 +552,13 @@ public class DiyUpdateActivity extends BaseActivity { ToastUtils.info("菜谱名称已存在!"); return; } + + if(!IsHotJ()) + { + ToastUtils.warning("加热工序之前,必须先添加搅拌工序!"); + return; + } + //按钮点击 String title = "生成菜谱操作提示!"; String message = "请问客官确定要生成["+name1+"]菜谱吗?"; @@ -604,6 +611,12 @@ public class DiyUpdateActivity extends BaseActivity { ToastUtils.info("菜谱名称已存在!"); return; } + + if(!IsHotJ()) + { + ToastUtils.warning("加热工序之前,必须先添加搅拌工序!"); + return; + } //按钮点击 String title = "保存菜谱操作提示!"; String message = "请问客官确定要保存["+name+"]菜谱吗?"; @@ -643,6 +656,36 @@ public class DiyUpdateActivity extends BaseActivity { } } + /** + * 判断数据是否合法 + */ + public boolean IsHotJ() + { + int index=0; + int k=0;int j=0; + for(BPA_GOODSRECIPE item:bpa_goodsrecipes) + { + if(item.processname.contains("搅拌") && k==0) + { + k=index; + } + + if(item.processname.contains("加热") && j==0) + { + j=index; + } + index++; + } + + if(j<=k) + { + return false; + }else + { + return true; + } + } + public void SetSelectPos(int index) { //移动光标 diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemCsMonitorFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemCsMonitorFragment.java index 8499dceb..227e939b 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemCsMonitorFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemCsMonitorFragment.java @@ -24,6 +24,8 @@ import com.bonait.bnframework.modules.home.adapter.lc_adapter; import com.bonait.bnframework.modules.home.adapter.monitor_adapter; import com.orhanobut.logger.Logger; +import java.util.Random; + import butterknife.BindView; import butterknife.ButterKnife;