From 13a80b264b27ec163ebfdd1f6cfa8d99588142f4 Mon Sep 17 00:00:00 2001 From: liup <1454939542@qq.com> Date: Tue, 17 Dec 2024 18:03:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/other.xml | 329 ++++++++++++++++++ app/src/main/AndroidManifest.xml | 7 +- .../business/ExecuteTheRecipe.java | 294 +++++++++------- .../common/constant/ConfigName.java | 4 + .../common/db/util/OrderDetailUtil.java | 21 ++ .../newui/activity/MainHActivity.java | 9 +- .../newui/activity/PlcDebugActivity.java | 134 +++++++ .../newui/activity/SystemSetActivity.java | 28 +- .../newui/adapter/order/FoodInfoAdapter.java | 20 +- .../newui/adapter/order/OrderInfoAdapter.java | 2 +- .../dialog/check/ChuCanPenCheckDialog.java | 172 +++++++++ .../dialog/control/FoodPosSetDialog.java | 13 +- .../dialog/control/RobotControlDialog.java | 2 +- .../dialog/control/WokControlDialog.java | 22 +- .../fragment/main/HomeDevicesFragment.java | 24 +- .../fragment/main/HomeMainsFragment.java | 30 +- .../fragment/main/HomeOrderFragment.java | 92 ++++- .../fragment/setting/SceneSetFragment.java | 3 + .../setting/WokDirectionSetFragment.java | 45 ++- .../newui/widget/DeviceStatusView.java | 59 ++-- app/src/main/res/drawable/bg_order.xml | 2 +- .../main/res/layout/activity_plc_debug.xml | 121 +++++++ .../main/res/layout/activity_system_set.xml | 109 ++---- app/src/main/res/layout/dialog_psw.xml | 82 +++++ .../main/res/layout/fragment_scene_set.xml | 22 ++ .../new/layout/dialog_chu_can_pen_check.xml | 125 +++++++ .../layout/new/layout/dialog_food_control.xml | 12 +- .../layout/new/layout/dialog_wok_make_tip.xml | 2 +- .../new/layout/fragment_home_device_debug.xml | 106 ++++-- .../layout/new/layout/fragment_home_order.xml | 48 +-- .../new/layout/fragment_wok_direction_set.xml | 26 +- .../layout/new/layout/view_device_status.xml | 46 ++- 32 files changed, 1632 insertions(+), 379 deletions(-) create mode 100644 .idea/other.xml create mode 100644 app/src/main/java/com/bonait/bnframework/newui/activity/PlcDebugActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/newui/dialog/check/ChuCanPenCheckDialog.java create mode 100644 app/src/main/res/layout/activity_plc_debug.xml create mode 100644 app/src/main/res/layout/dialog_psw.xml create mode 100644 app/src/main/res/layout/new/layout/dialog_chu_can_pen_check.xml diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 00000000..104e542e --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,329 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 309655db..793ec80c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -83,8 +83,11 @@ android:windowSoftInputMode="adjustPan" android:screenOrientation="landscape" android:exported="false" /> - - + goodsrecipes = GoodsProcessDetailDBUtil.getByGroupId(orderDetail.groupId); @@ -93,27 +90,51 @@ public class ExecuteTheRecipe { if(!goodsrecipes.isEmpty()){ ConfigName.hasClear[orderDetail.type-1] = goodsrecipes.get(goodsrecipes.size()-1).processname.contains("清洗"); } + EventBus.getDefault().post(new MakingStepEvent(orderDetail.type,1)); + orderDetail.process=1; + orderDetail.status=1; + OrderDetailUtil.update(orderDetail); + //是否允许取料 + String name = "翻转轴1允许机器人放盒取盒"; + String name2 = "翻转轴2允许机器人放盒取盒"; + boolean permissionTakePen = false; + long a = System.currentTimeMillis(); + while (!permissionTakePen && !ConfigName.IsForcedEnd[orderDetail.type-1]) { + if ((System.currentTimeMillis() - a) > 1000 * (whileTime)) { + return; + } else { + Object object1 = ReadPLC(orderDetail.type,name);//ListeningValue.get(name); + Object object2 = ReadPLC(orderDetail.type,name2);//ListeningValue.get(name); + if (object1 != null) { + permissionTakePen = (boolean) (object1) && (boolean) (object2); + } + + LogUtils.d(" Write_PLC_RebackPen:"+orderDetail.type +" 允许机器人放盒取盒"+object1+object2); + if (permissionTakePen) { + RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.type+"号炒锅-" + ",允许机器人放盒取盒:"+object1+object2); + }else { + RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.type+"号炒锅-" + ",不允许机器人放盒取盒:"+object1+object2); + showToastErrorTip(orderDetail.type+"号炒锅-"+"不允许机器人放盒取盒"); + } + } + Thread.sleep(100); + } Wait_Robot_No_Working(orderDetail.type); ConfigName.RobotIsWorking[orderDetail.type-1] = true; ModbusCenter.robotWritePlc(true,orderDetail.mainPosition+"#库取原料",true,null); RobotModbusTcpServer.get().WriteShort("GI1", (short) orderDetail.type, null); - Thread.sleep(5000); + Thread.sleep(1000); ThreadWhile(orderDetail.type,orderDetail.type+"#炒锅放原料盆完成"); ConfigName.RobotIsWorking[orderDetail.type-1] = false; - EventBus.getDefault().post(new MakingStepEvent(orderDetail.type,1)); - orderDetail.process=1; - orderDetail.status=1; - OrderDetailUtil.update(orderDetail); - for (BPA_GOODS_PROCESS_DETAIL item : goodsrecipes) { if(!ConfigName.MakeStatus[orderDetail.type-1]){ RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.type+"号炒锅-"+",MakeStatus=false"); return; } while (ConfigName.IsPause[orderDetail.type-1]) { - NewToastUtil.getInstance().showToast("当前菜品已暂停制作!"); + showToastTip(orderDetail.type+"号炒锅,"+"当前菜品已暂停制作!"); RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.type+"号炒锅-"+",当前菜品已暂停制作"); Thread.sleep(500); @@ -141,7 +162,7 @@ public class ExecuteTheRecipe { isError = true; orderDetail.status = 3; OrderDetailUtil.update(orderDetail); - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(orderDetail.type+"号炒锅,"+"异常信息:" + ex.getMessage()); EventBus.getDefault().post(new MakingStepEvent(orderDetail.type,-1)); RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.type+"号炒锅("+orderDetail.goodsName+"-"+orderDetail.groupName+")-制作异常:"+ex.getMessage()); RecordManager.getInstance().addOrderRecords(orderDetail,orderDetail.type+"号炒锅-"+"异常"); @@ -169,7 +190,7 @@ public class ExecuteTheRecipe { long endTime = System.currentTimeMillis(); //结束时间 int time = (int) ((endTime - startTime) / 1000); Log.e("运行时长", String.format("方法使用时间 %d s", time)); - showlog("结束烹饪菜谱【" + orderDetail.goodsName + "】,关闭搅拌、关闭加热," + String.format("方法使用时间 %d s", time)); + showlog(orderDetail.type,"结束烹饪菜谱【" + orderDetail.goodsName + "】," + String.format("方法使用时间 %d s", time)); if (ConfigName.IsForcedEnd[orderDetail.type-1])//强制结束 @@ -178,10 +199,8 @@ public class ExecuteTheRecipe { orderDetail.process = 0; OrderDetailUtil.update(orderDetail); EventBus.getDefault().post(new MakingStepEvent(orderDetail.type,-2)); - NewToastUtil.getInstance().showToast("客官,当前菜品已强制结束!!!"); - //初始化 // BottomClick("初始化"); - showlog("菜谱【" + orderDetail.goodsName + "】已强制结束..."); + showlog(orderDetail.type,"菜谱【" + orderDetail.goodsName + "】已强制结束..."); ConfigName.IsForcedEnd[orderDetail.type-1] = false; RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.type+"号炒锅("+orderDetail.goodsName+"-"+orderDetail.groupName+")-制作取消"); RecordManager.getInstance().addOrderRecords(orderDetail,orderDetail.type+"号炒锅-"+"取消"); @@ -200,7 +219,9 @@ public class ExecuteTheRecipe { } Thread.sleep(1000); } catch (InterruptedException e) { - NewToastUtil.getInstance().showToast("异常信息:" + e.getMessage()); + showToastTip(orderDetail.type+"号炒锅,"+"异常信息:" + e.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.type+"号炒锅,"+"异常信息:" + e.getMessage()); + } } })); @@ -218,14 +239,14 @@ public class ExecuteTheRecipe { try { //1.解析 if (ConfigName.IsForcedEnd[deviceNum-1]) { - showlog("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); + showlog(deviceNum,"客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); return false; } if(deviceNum==1){ while (!Wok1ModbusTcpServer.get().plcIsConnect||!RobotModbusTcpServer.get().plcIsConnect &&!ConfigName.IsForcedEnd[deviceNum-1]){ try{ - showlog("客官,检测到硬件已经断开连接,等待重连!!!"); + showlog(deviceNum,"客官,检测到硬件已经断开连接,等待重连!!!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+" 检测到硬件已经断开连接,等待连接中 Wok:" +deviceNum + Wok1ModbusTcpServer.get().plcIsConnect+" Robot:"+RobotModbusTcpServer.get().plcIsConnect); Thread.sleep(100); @@ -237,7 +258,7 @@ public class ExecuteTheRecipe { while (!Wok2ModbusTcpServer.get().plcIsConnect||!RobotModbusTcpServer.get().plcIsConnect &&!ConfigName.IsForcedEnd[deviceNum-1]){ try{ - showlog("客官,检测到硬件已经断开连接,等待重连!!!"); + showlog(deviceNum,"客官,检测到硬件已经断开连接,等待重连!!!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+" 检测到硬件已经断开连接,等待连接中 Wok:" +deviceNum +Wok2ModbusTcpServer.get().plcIsConnect+" Robot:"+RobotModbusTcpServer.get().plcIsConnect); Thread.sleep(100); @@ -249,7 +270,7 @@ public class ExecuteTheRecipe { while (!Wok3ModbusTcpServer.get().plcIsConnect||!RobotModbusTcpServer.get().plcIsConnect &&!ConfigName.IsForcedEnd[deviceNum-1]){ try{ - showlog("客官,检测到硬件已经断开连接,等待重连!!!"); + showlog(deviceNum,"客官,检测到硬件已经断开连接,等待重连!!!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+" 检测到硬件已经断开连接,等待连接中 Wok:" +deviceNum +Wok3ModbusTcpServer.get().plcIsConnect+" Robot:"+RobotModbusTcpServer.get().plcIsConnect); Thread.sleep(100); @@ -261,7 +282,7 @@ public class ExecuteTheRecipe { while (!Wok4ModbusTcpServer.get().plcIsConnect||!RobotModbusTcpServer.get().plcIsConnect &&!ConfigName.IsForcedEnd[deviceNum-1]){ try{ - showlog("客官,检测到硬件已经断开连接,等待重连!!!"); + showlog(deviceNum,"客官,检测到硬件已经断开连接,等待重连!!!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+" 检测到硬件已经断开连接,等待连接中 Wok:" +deviceNum +Wok4ModbusTcpServer.get().plcIsConnect+" Robot:"+RobotModbusTcpServer.get().plcIsConnect); Thread.sleep(100); @@ -283,12 +304,12 @@ public class ExecuteTheRecipe { { Object gz = ReadPLC(deviceNum,"异常加热故障信息"); if (gz != null && (boolean) gz && !ConfigName.TEST) { - showlog("客官,检测到硬件加热异常,已主动停止炒制,请联系海科人员!!!"); + showlog(deviceNum,"客官,检测到硬件加热异常,已主动停止炒制,请联系海科人员!!!"); ConfigName.IsForcedEnd[deviceNum-1] = true; String title = "加热异常-温馨提示!"; String message = "客官硬件加热异常,请联系海科人员,已强制停止炒制!"; RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-加热异常"); - NewToastUtil.getInstance().showToastError(title+message); + showToastErrorTip(deviceNum+"号炒锅,"+title+message); return false; } } @@ -306,8 +327,10 @@ public class ExecuteTheRecipe { ExecuteOperationSteps(deviceNum,recipe.processname, recipe.processvalue,mainPosition); } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); status = false; + LogUtils.d("异常信息:" + ex.getMessage()); } finally { return status; } @@ -354,7 +377,7 @@ public class ExecuteTheRecipe { BPA_SILOS silos = bpa_silos.get(0); if (val >= 32767) { val = 32767; - showlog("料仓" + silos.num + "出量克数溢出,已按照最大出量出料!!!"); + showlog(deviceNum,"料仓" + silos.num + "出量克数溢出,已按照最大出量出料!!!"); } formulation.put(silos, val); @@ -365,8 +388,9 @@ public class ExecuteTheRecipe { int ztime = (int) (val / (jzzz_1 / 5.0)); MaxValue = ztime > MaxValue ? ztime : MaxValue; }else { - NewToastUtil.getInstance().showToastError("料仓" + silos.num + "校准值为空"); - RecordManager.getInstance().addLogRecord("订单处理日志","料仓" + silos.num + "校准值为空"); + showToastErrorTip(deviceNum+"号炒锅,"+"料仓" + silos.num + "校准值为空"); + LogUtils.d("料仓" + silos.num + "校准值为空"); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"料仓" + silos.num + "校准值为空"); } } } @@ -389,7 +413,9 @@ public class ExecuteTheRecipe { } } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -430,10 +456,8 @@ public class ExecuteTheRecipe { //写入PLC if (formulation.size() > 0) { switch (processname){ - case "主料": case "辅料": case "出菜": - //等待机器人工作 关闭加热或搅拌 boolean isJre; Object K = ReadPLC(deviceNum,"加热"); @@ -525,9 +549,7 @@ public class ExecuteTheRecipe { Write_PLC_Heating(deviceNum,formulation); break; case "主料": - ConfigName.RobotIsWorking[deviceNum-1] = true; Write_PLC_MainIngredients(deviceNum,formulation); - ConfigName.RobotIsWorking[deviceNum-1] = false; break; case "辅料": ConfigName.RobotIsWorking[deviceNum-1] = true; @@ -552,7 +574,9 @@ public class ExecuteTheRecipe { } } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -576,14 +600,14 @@ public class ExecuteTheRecipe { @Override public void onSuccess() { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-"+"物料"+"料仓" + silos.num + "需求值"+val+"写入成功"); -// showlog("需求值写入成功!"); +// showlog(deviceNum,"需求值写入成功!"); IsComplete[0] = true; } @Override public void onFailure(String ErrorMsg) { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-"+"物料"+"料仓" + silos.num + "需求值"+val+"写入失败:"+ErrorMsg); - showlog("需求值写入失败!尝试再次写入...错误原因:" + ErrorMsg); + showlog(deviceNum,"需求值写入失败!尝试再次写入...错误原因:" + ErrorMsg); WritePLC(deviceNum,"料仓" + silos.num + "需求值", val, null); IsComplete[0] = true; } @@ -597,7 +621,9 @@ public class ExecuteTheRecipe { int otherG = silos.silosmargin - (val / 10); QueryDB.UpdateYL(silos.id, otherG >= 0 ? otherG : 0); } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -617,7 +643,7 @@ public class ExecuteTheRecipe { if (key.contains("(秒)")) { val = Integer.parseInt(value); } else { - NewToastUtil.getInstance().showToast("工序:" + key + "," + value); + showToastTip(deviceNum+"号炒锅,"+"工序:" + key + "," + value); writeValue = GetMXValue(key, value); int finalWriteValue = writeValue; WritePLC(deviceNum,key, writeValue, new IWriteCallBack() { @@ -664,7 +690,9 @@ public class ExecuteTheRecipe { ThreadDelay(deviceNum,val,"Write_PLC_Stir"); } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -707,7 +735,9 @@ public class ExecuteTheRecipe { ThreadDelay(deviceNum,val,"Write_PLC_Location"); } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -839,7 +869,9 @@ public class ExecuteTheRecipe { } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -895,7 +927,9 @@ public class ExecuteTheRecipe { ThreadDelay(deviceNum,val,"Write_PLC_ParallelDischarge"); } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -915,7 +949,9 @@ public class ExecuteTheRecipe { } } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -926,7 +962,7 @@ public class ExecuteTheRecipe { */ private static void Write_PLC_CleanPan(int deviceNum,HashMap data) { try { - showlog("准备清洗!"); + showlog(deviceNum,"准备清洗!"); String qx_type = "一般清洗"; int val_csl=0; int clearTime = 150; @@ -935,7 +971,7 @@ public class ExecuteTheRecipe { for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - NewToastUtil.getInstance().showToast("工序:" + key + "," + value); + showToastTip(deviceNum+"号炒锅,"+"工序:" + key + "," + value); if (key.contains("(秒)") && !ConfigName.IsForcedEnd[deviceNum-1]) { int val = Integer.parseInt(value); ThreadDelay(deviceNum,val,"Write_PLC_CleanPan"); @@ -968,10 +1004,12 @@ public class ExecuteTheRecipe { //等待清洗完成 ThreadWhileClear(deviceNum,"炒锅清洗反馈", 5); Make位置(deviceNum,"原点位"); - showlog("炒锅清洗完成!"); - NewToastUtil.getInstance().showToast("炒锅清洗完成"); + showlog(deviceNum,"炒锅清洗完成!"); + showToastTip(deviceNum+"号炒锅,"+"炒锅清洗完成"); } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -998,7 +1036,9 @@ public class ExecuteTheRecipe { } }catch (Exception ex){ - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -1009,10 +1049,11 @@ public class ExecuteTheRecipe { */ public static void Write_PLC_MainIngredients(int deviceNum,HashMap data) { try { - showlog("准备倒入主料!"); + Thread.sleep(50); + showlog(deviceNum,"准备倒入主料!"); //判断炒制位置 String czwz = "炒菜位高"; - String foodPosition = "Z1"; + String foodPosition = "1号位"; String foodName = ""; for (HashMap.Entry entry : data.entrySet()) { @@ -1021,36 +1062,18 @@ public class ExecuteTheRecipe { if (key.contains("炒制位置")) { czwz = value; }else if(key.contains("主料位置")){ - foodPosition = value.replace("Z",""); + if (value.contains("1号位") || value.contains("2号位")) { + foodPosition = value; + } }else if(key.contains("主料名称")){ foodName = value; } } - boolean isJre = false; - Object K = ReadPLC(deviceNum,"加热"); - isJre = K == null ? false : (boolean) K; - if (isJre && ConfigName.getInstance().WhetherManualFeedingSuspended.contains("是")) { - WritePLC(deviceNum,"加热", false, null); - }//提前关闭加热 - - Make位置(deviceNum,"原点位"); - //检测盆是否存在 -// ThreadWhile(foodPosition+"#料仓检测有无"); - - Wait_Robot_No_Working(deviceNum);//等待机器人空闲 - if(!ConfigName.MakeStatus[deviceNum-1]){ - return; - } - ModbusCenter.robotWritePlc(true,foodPosition+"#位取原料",true,null); - RobotModbusTcpServer.get().WriteShort("GI1", (short) deviceNum, null); - - Thread.sleep(2000); - ThreadWhile(deviceNum,deviceNum+"#炒锅放原料盆完成"); - - if (isJre && ConfigName.getInstance().WhetherManualFeedingSuspended.contains("是")) { - WritePLC(deviceNum,"加热", true, null); - }//再次释放加热 + Make位置(deviceNum,"炒菜位高"); + //2.给倒菜启动 + BottomClick1(deviceNum,"主料" + foodPosition); + ThreadWhile(deviceNum,foodPosition + "倒菜完成"); Make位置(deviceNum,czwz); //判断是否有烹饪时间 @@ -1069,7 +1092,9 @@ public class ExecuteTheRecipe { Thread.sleep(5000); } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); }finally { } } @@ -1080,7 +1105,7 @@ public class ExecuteTheRecipe { */ public static void Write_PLC_MainIngredients_shoudong(int deviceNum,HashMap data) { try { - showlog("准备倒入主料!"); + showlog(deviceNum,"准备倒入主料!"); //判断炒制位置 String czwz = "炒菜位高"; String foodPosition = "Z1"; @@ -1124,7 +1149,9 @@ public class ExecuteTheRecipe { Make位置(deviceNum,czwz); } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); }finally { } } @@ -1136,7 +1163,8 @@ public class ExecuteTheRecipe { */ public static void Write_PLC_MainAccessory(int deviceNum,HashMap data) { try { - showlog("准备倒入辅料!"); + Thread.sleep(50); + showlog(deviceNum,"准备倒入辅料!"); //判断炒制位置 String czwz = "炒菜位高"; String foodPosition = "F1"; @@ -1195,7 +1223,9 @@ public class ExecuteTheRecipe { Thread.sleep(5000); } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); }finally { } } @@ -1206,7 +1236,7 @@ public class ExecuteTheRecipe { */ public static void Write_PLC_MainAccessory_shoudong(int deviceNum,HashMap data) { try { - showlog("准备倒入辅料!"); + showlog(deviceNum,"准备倒入辅料!"); //判断炒制位置 String czwz = "炒菜位高"; String foodPosition = "F1"; @@ -1250,7 +1280,9 @@ public class ExecuteTheRecipe { Make位置(deviceNum,czwz); } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); }finally { } } @@ -1262,13 +1294,14 @@ public class ExecuteTheRecipe { */ public static void Write_PLC_MainOutdishes(int deviceNum,HashMap data,int mainPosition) { try { - showlog("准备出菜!"); + Thread.sleep(50); + showlog(deviceNum,"准备出菜!"); //先延迟 for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - NewToastUtil.getInstance().showToast("工序:" + key + "," + value); + showToastTip(deviceNum+"号炒锅,"+"工序:" + key + "," + value); if (key.contains("(秒)")) { int val = Integer.parseInt(value); ThreadDelay(deviceNum,val,"Write_PLC_MainOutdishes"); @@ -1277,7 +1310,7 @@ public class ExecuteTheRecipe { WritePLC(deviceNum,"加热", false, null); - showlog("关闭搅拌、关闭加热!"); + showlog(deviceNum,"关闭搅拌、关闭加热!"); Wait_Robot_No_Working(deviceNum);//等待机器人空闲 @@ -1298,7 +1331,7 @@ public class ExecuteTheRecipe { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",空盆库位检测有无:异常"); } if(!isCheck){ - NewToastUtil.getInstance().showToast("请检测出餐盆是否放置正确!"); + showToastTip(deviceNum+"号炒锅,"+"请检测出餐盆是否放置正确!"); }else { if(deviceNum==1){ index = 31; @@ -1421,9 +1454,11 @@ public class ExecuteTheRecipe { } ConfigName.getInstance().isPutFinish = true; } - showlog("出菜完成,锅体准备回到原位!"); + showlog(deviceNum,"出菜完成,锅体准备回到原位!"); } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -1454,7 +1489,7 @@ public class ExecuteTheRecipe { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",允许机器人放盒取盒:"+object1+object2); }else { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",不允许机器人放盒取盒:"+object1+object2); - NewToastUtil.getInstance().showToastError(deviceNum+"号炒锅-"+"允许机器人放盒取盒"); + showToastErrorTip(deviceNum+"号炒锅-"+"不允许机器人放盒取盒"); } } Thread.sleep(100); @@ -1464,7 +1499,7 @@ public class ExecuteTheRecipe { return; } ConfigName.RobotIsWorking[deviceNum-1] = true; - NewToastUtil.getInstance().showToastError(deviceNum + "#炒锅投料位取原料空盆 放回Z"+mainPosition); + showToastTip(deviceNum + "#炒锅投料位取原料空盆 放回Z"+mainPosition); ModbusCenter.robotWritePlc(true, deviceNum + "#炒锅投料位取原料空盆", true, new IWriteCallBack() { @Override public void onSuccess() { @@ -1491,7 +1526,9 @@ public class ExecuteTheRecipe { ThreadWhile(deviceNum,mainPosition+"#库原料空盆放回完成"); ConfigName.RobotIsWorking[deviceNum-1] = false; }catch (Exception ex){ - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); }finally { ConfigName.RobotIsWorking[deviceNum-1] = false; } @@ -1518,10 +1555,12 @@ public class ExecuteTheRecipe { public void onFailure(String ErrorMsg) { } }); - NewToastUtil.getInstance().showToast("火力按钮点击,当前级别:" + data); + showToastTip(deviceNum+"号炒锅,"+"火力按钮点击,当前级别:" + data); } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip(deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅,"+"异常信息:" + ex.getMessage()); } } @@ -1592,7 +1631,8 @@ public class ExecuteTheRecipe { } } } catch (Exception ex) { - NewToastUtil.getInstance().showToastError("异常信息:" + ex.getMessage()); + showToastErrorTip("异常信息:" + ex.getMessage()); + LogUtils.d("异常信息:" + ex.getMessage()); } finally { return ReturnsVariable[0]; } @@ -1617,7 +1657,7 @@ public class ExecuteTheRecipe { int mmmm = delay - (int) ((System.currentTimeMillis() - startTime) / 1000); if (AtPresentTime != mmmm) { AtPresentTime = mmmm; - NewToastUtil.getInstance().showToast(deviceNum+"号炒锅,延迟等待中,剩余"+AtPresentTime+"秒"); +// showToastTip(deviceNum+"号炒锅,延迟等待中,剩余"+AtPresentTime+"秒"); } } catch (InterruptedException ex) { } @@ -1639,7 +1679,7 @@ public class ExecuteTheRecipe { while (!IsComplete[0] && !ConfigName.IsForcedEnd[deviceNum-1]) { if ((System.currentTimeMillis() - a) > 1000 * whileTime) { - showlog(name + ",异常超时退出!"); + showlog(deviceNum,name + ",异常超时退出!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"异常超时退出"); break; } else { @@ -1650,7 +1690,7 @@ public class ExecuteTheRecipe { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"true"); }else { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"false"); - NewToastUtil.getInstance().showToast(deviceNum+"号炒锅,等待"+name); +// showToastTip(deviceNum+"号炒锅,等待"+name); } }else { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"null"); @@ -1665,7 +1705,7 @@ public class ExecuteTheRecipe { Thread.sleep(500);//10 *6 } catch (InterruptedException e) { IsComplete[0] = true; - showlog(name + ",异常退出!" + e.getMessage()); + showlog(deviceNum,name + ",异常退出!" + e.getMessage()); } } RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"等待物料("+name+")出料完成"); @@ -1684,7 +1724,7 @@ public class ExecuteTheRecipe { while (!IsComplete[0] && !ConfigName.IsForcedEnd[deviceNum-1] && !ConfigName.TEST) { if ((System.currentTimeMillis() - a) > 1000 * whileTime) { - showlog(name + ",异常超时退出!"); + showlog(deviceNum,name + ",异常超时退出!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile-"+name + ",异常超时退出"); break; } else { @@ -1695,11 +1735,8 @@ public class ExecuteTheRecipe { LogUtils.d(TAG+" ThreadWhile name="+name+" true ////"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile-"+name + ",true"); }else { - if(name.equals("出料空盆检测有无")){ - NewToastUtil.getInstance().showToastError("出料空盆没有盆,请检查传感器或放置空盆!"); - } RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile-"+name + ",false"); - NewToastUtil.getInstance().showToast(deviceNum+"号炒锅,等待"+name); +// showToastTip(deviceNum+"号炒锅,等待"+name); LogUtils.d(TAG+" ThreadWhile name="+name+" false"); } }else { @@ -1710,7 +1747,7 @@ public class ExecuteTheRecipe { Thread.sleep(500);//10 *6 } catch (InterruptedException e) { IsComplete[0] = true; - showlog(name + ",异常退出!" + e.getMessage()); + showlog(deviceNum,name + ",异常退出!" + e.getMessage()); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile-"+name + ",异常退出"); } } @@ -1726,7 +1763,7 @@ public class ExecuteTheRecipe { while (!IsComplete[0] && !ConfigName.IsForcedEnd[deviceNum-1] && !ConfigName.TEST) { if ((System.currentTimeMillis() - a) > 1000 * whileTime) { - showlog(name + ",异常超时退出!"); + showlog(deviceNum,name + ",异常超时退出!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile-"+name + ",异常超时退出"); break; } else { @@ -1742,7 +1779,7 @@ public class ExecuteTheRecipe { BottomClick1(deviceNum,value); } RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile-"+name + ",false"); - NewToastUtil.getInstance().showToast(deviceNum+"号炒锅,等待"+name); +// showToastTip(deviceNum+"号炒锅,等待"+name); LogUtils.d(TAG+" ThreadWhile name="+name+" false"); } }else { @@ -1753,7 +1790,7 @@ public class ExecuteTheRecipe { Thread.sleep(500);//10 *6 } catch (InterruptedException e) { IsComplete[0] = true; - showlog(name + ",异常退出!" + e.getMessage()); + showlog(deviceNum,name + ",异常退出!" + e.getMessage()); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile-"+name + ",异常退出"); } } @@ -1773,7 +1810,7 @@ public class ExecuteTheRecipe { while (!IsComplete[0] && !ConfigName.IsForcedEnd[deviceNum-1]&& !ConfigName.TEST) { if ((System.currentTimeMillis() - a) > 1000 * whileTime * k) { - showlog(name + ",异常超时退出!"); + showlog(deviceNum,name + ",异常超时退出!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhileClear-"+name + ",异常超时退出"); break; } else { @@ -1783,11 +1820,11 @@ public class ExecuteTheRecipe { if (IsComplete[0]) { LogUtils.d(TAG+" ThreadWhileClear name="+name+" true"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhileClear-"+name + ",true"); - NewToastUtil.getInstance().showToast(deviceNum+"号炒锅,清洗完成"); +// showToastTip(deviceNum+"号炒锅,清洗完成"); }else { LogUtils.d(TAG+" ThreadWhileClear name="+name+" false"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhileClear-"+name + ",false"); - NewToastUtil.getInstance().showToast(deviceNum+"号炒锅,清洗中..."); +// showToastTip(deviceNum+"号炒锅,清洗中..."); } }else { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhileClear-"+name + ",null"); @@ -1797,7 +1834,7 @@ public class ExecuteTheRecipe { Thread.sleep(500);//10 *6 } catch (InterruptedException e) { IsComplete[0] = true; - showlog(name + ",异常退出!" + e.getMessage()); + showlog(deviceNum,name + ",异常退出!" + e.getMessage()); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhileClear-"+name + ",转换异常"); } } @@ -1813,10 +1850,21 @@ public class ExecuteTheRecipe { /** * 显示日志 */ - public static void showlog(String msg) { + public static void showlog(int deviceNum,String msg) { LogUtils.d(TAG+" showlog msg="+msg); - NewToastUtil.getInstance().showToast(msg); - RecordManager.getInstance().addLogRecord("订单处理日志","炒锅-showlog-"+msg + ""); + showToastTip(deviceNum+"号炒锅,"+msg); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-showlog-"+msg + ""); + } + + public static void showToastTip(String content){ + LogUtils.d(TAG+" showToastTip content="+content); + if(ConfigName.getInstance().showCookingToast){ + NewToastUtil.getInstance().showToast(content); + } + } + public static void showToastErrorTip(String content){ + LogUtils.d(TAG+" showToastErrorTip content="+content); + NewToastUtil.getInstance().showToastError(content); } } 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 394f2e8c..31a0d030 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 @@ -224,6 +224,7 @@ public class ConfigName { add(new Res_PLCADDRESS("炒锅工作范围下限", "VD206", 0, 1)); add(new Res_PLCADDRESS("炒锅工作范围上限", "VD210", 0, 1)); + //自动投料-翻转轴 add(new Res_PLCADDRESS("翻转轴控制1", "-------------", 0, 0)); add(new Res_PLCADDRESS("翻转1-伺服当前值", "VD260", 1, 1)); @@ -551,6 +552,7 @@ public class ConfigName { public final static String deviceLocationDetail="deviceLocationDetail"; public final static String storesNum="storesNum"; public final static String rootTip="rootTip"; + public final static String cookToast="cookToast"; public final static String SHARE_KEY_loginNum="SHARE_KEY_loginNum"; /** @@ -558,6 +560,8 @@ public class ConfigName { */ public String WhetherManualFeedingSuspended="是"; + public boolean showCookingToast = true; + /** * 判断重复点击 */ diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/OrderDetailUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/OrderDetailUtil.java index 4f015da5..07d56dc7 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/OrderDetailUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/OrderDetailUtil.java @@ -12,6 +12,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP; import com.bonait.bnframework.common.db.mode.BPA_ORDER_DETAIL; import java.util.ArrayList; +import java.util.List; /** * @author: liup @@ -151,4 +152,24 @@ public class OrderDetailUtil { ArrayList obj = QueryDB.Get(BPA_ORDER_DETAIL.class, where, args, orderby); return obj.size() > 0 ? (BPA_ORDER_DETAIL) obj.get(0) : null; } + + /** + * 获取正在制作的订单 + * @return + */ + public static List getByAllMaking() { + String orderby = QueryDB.Desc_Time_Up; + String where = "isDelete=? and status!=0"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = QueryDB.Get(BPA_ORDER_DETAIL.class, where, args, orderby); + for (Object k : obj) { + if(((BPA_ORDER_DETAIL) k).status!=0){ + data.add(0,(BPA_ORDER_DETAIL) k); + }else { + data.add((BPA_ORDER_DETAIL) k); + } + } + return data; + } } diff --git a/app/src/main/java/com/bonait/bnframework/newui/activity/MainHActivity.java b/app/src/main/java/com/bonait/bnframework/newui/activity/MainHActivity.java index 2c158926..e93bc47d 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/activity/MainHActivity.java +++ b/app/src/main/java/com/bonait/bnframework/newui/activity/MainHActivity.java @@ -81,7 +81,7 @@ public class MainHActivity extends BaseActivity { desc = "烹饪异常"; } viewBinding.tvWok1.setVisibility(View.VISIBLE); - viewBinding.tvWok1.setText("1号炒锅:菜品【"+detail1.goodsName+(detail1.groupName==null?"":detail1.groupName)+"】"+desc); + viewBinding.tvWok1.setText("1号炒锅:【"+detail1.goodsName+"】"+desc); }else { viewBinding.tvWok1.setVisibility(View.GONE); viewBinding.tvWok1.setText(""); @@ -96,7 +96,7 @@ public class MainHActivity extends BaseActivity { desc = "烹饪异常"; } viewBinding.tvWok2.setVisibility(View.VISIBLE); - viewBinding.tvWok2.setText("2号炒锅:菜品【"+detail2.goodsName+(detail2.groupName==null?"":detail2.groupName)+"】"+desc); + viewBinding.tvWok2.setText("2号炒锅:【"+detail2.goodsName+"】"+desc); }else { viewBinding.tvWok2.setVisibility(View.GONE); viewBinding.tvWok2.setText(""); @@ -111,7 +111,7 @@ public class MainHActivity extends BaseActivity { desc = "烹饪异常"; } viewBinding.tvWok3.setVisibility(View.VISIBLE); - viewBinding.tvWok3.setText("3号炒锅:菜品【"+detail3.goodsName+(detail3.groupName==null?"":detail3.groupName)+"】"+desc); + viewBinding.tvWok3.setText("3号炒锅:【"+detail3.goodsName+"】"+desc); }else { viewBinding.tvWok3.setVisibility(View.GONE); viewBinding.tvWok3.setText(""); @@ -126,7 +126,7 @@ public class MainHActivity extends BaseActivity { desc = "烹饪异常"; } viewBinding.tvWok4.setVisibility(View.VISIBLE); - viewBinding.tvWok4.setText("4号炒锅:菜品【"+detail4.goodsName+(detail4.groupName==null?"":detail4.groupName)+"】"+desc); + viewBinding.tvWok4.setText("4号炒锅:【"+detail4.goodsName+"】"+desc); }else { viewBinding.tvWok4.setVisibility(View.GONE); viewBinding.tvWok4.setText(""); @@ -323,6 +323,7 @@ public class MainHActivity extends BaseActivity { RootTipDialog dialog = new RootTipDialog(); dialog.show(getSupportFragmentManager(),"开机自检"); } + ConfigName.getInstance().showCookingToast = PreferenceUtils.getBoolean(ConfigName.cookToast,true); } } diff --git a/app/src/main/java/com/bonait/bnframework/newui/activity/PlcDebugActivity.java b/app/src/main/java/com/bonait/bnframework/newui/activity/PlcDebugActivity.java new file mode 100644 index 00000000..639a51f1 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/newui/activity/PlcDebugActivity.java @@ -0,0 +1,134 @@ +package com.bonait.bnframework.newui.activity; + +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.Nullable; +import androidx.viewpager.widget.ViewPager; + +import com.bonait.bnframework.common.base.BaseActivity; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.databinding.ActivityPlcDebugBinding; +import com.bonait.bnframework.databinding.ActivitySystemSetBinding; +import com.bonait.bnframework.newui.adapter.base.FragmentAdapter; +import com.bonait.bnframework.newui.fragment.setting.PicManagerFragment; +import com.bonait.bnframework.newui.fragment.setting.PlcAddressFragment; +import com.bonait.bnframework.newui.fragment.setting.SceneSetFragment; +import com.bonait.bnframework.newui.fragment.setting.WokDirectionSetFragment; + +/** + * @author: liup + * @description: 系统设置 + * @date: 2024/5/30 15:31. + */ +public class PlcDebugActivity extends BaseActivity { + + private ActivityPlcDebugBinding viewBinding; + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + viewBinding = ActivityPlcDebugBinding.inflate(getLayoutInflater()); + setContentView(viewBinding.getRoot()); + DisplayManager.scaleViewGroup(viewBinding.getRoot()); + initTopBar(); + initView(); + } + + private void initView(){ + initFragment(); + viewBinding.viewpager.addOnPageChangeListener(pageChangeListener); + // 设置viewPager缓存多少个fragment + viewBinding.viewpager.setOffscreenPageLimit(1); +// viewBinding.navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); + updateTopBar(1); + + viewBinding.ll4.setOnClickListener(v->{ + viewBinding.viewpager.setCurrentItem(0); + }); + } + + private void updateTopBar(int pos){ + viewBinding.img4.setSelected(pos==1); + viewBinding.tvTitle4.setSelected(pos==1); + } + + private void initTopBar(){ +// viewBinding.topbar.setTitle("系统设置"); + viewBinding.back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + } + + /** + * viewPager里添加fragment + */ + private void initFragment() { + FragmentAdapter fragmentAdapter = new FragmentAdapter(getSupportFragmentManager()); + fragmentAdapter.addFragment(new PlcAddressFragment()); + + viewBinding.viewpager.setAdapter(fragmentAdapter); + } + +// /** +// * 配置bottom底部菜单栏监听器,手指点击底部菜单监听 +// */ +// private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener +// = new BottomNavigationView.OnNavigationItemSelectedListener() { +// +// @Override +// public boolean onNavigationItemSelected(@NonNull MenuItem item) { +// switch (item.getItemId()) { +// case R.id.bottom_navigation_1: +// viewBinding.viewpager.setCurrentItem(0); +// return true; +// case R.id.bottom_navigation_2: +// viewBinding.viewpager.setCurrentItem(1); +// return true; +// case R.id.bottom_navigation_3: +// viewBinding.viewpager.setCurrentItem(2); +// return true; +// case R.id.bottom_navigation_4: +// viewBinding.viewpager.setCurrentItem(3); +// return true; +// } +// return false; +// } +// }; + + + /** + * 配置ViewPager监听器,手指滑动监听 + */ + private ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { +// MenuItem menuItem = viewBinding.navigation.getMenu().getItem(position); + } + + @Override + public void onPageSelected(int position) { +// viewBinding.navigation.getMenu().getItem(position).setChecked(true); + updateTopBar(position+1); + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }; + + @Override + protected String getClassName() { + return "系统设置页"; + } + + @Override + protected boolean canDragBack() { + return false; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/newui/activity/SystemSetActivity.java b/app/src/main/java/com/bonait/bnframework/newui/activity/SystemSetActivity.java index e02f9e70..58e088e2 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/activity/SystemSetActivity.java +++ b/app/src/main/java/com/bonait/bnframework/newui/activity/SystemSetActivity.java @@ -52,9 +52,7 @@ public class SystemSetActivity extends BaseActivity { viewBinding.ll3.setOnClickListener(v->{ viewBinding.viewpager.setCurrentItem(2); }); - viewBinding.ll4.setOnClickListener(v->{ - viewBinding.viewpager.setCurrentItem(3); - }); + } private void updateTopBar(int pos){ @@ -64,8 +62,7 @@ public class SystemSetActivity extends BaseActivity { viewBinding.tvTitle2.setSelected(pos==2); viewBinding.img3.setSelected(pos==3); viewBinding.tvTitle3.setSelected(pos==3); - viewBinding.img4.setSelected(pos==4); - viewBinding.tvTitle4.setSelected(pos==4); + } private void initTopBar(){ @@ -76,26 +73,6 @@ public class SystemSetActivity extends BaseActivity { finish(); } }); - viewBinding.btnSubmit.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - String s=viewBinding.edittextQuanxian.getText().toString(); - if (s.isEmpty()) - { - ToastUtils.warning("权限密码不能为空!"); - }else - { - if(s.equals(ConfigName.getInstance().user.pass)) - { - viewBinding.rlQuanxian.setVisibility(View.GONE); - viewBinding.viewpager.setVisibility(View.VISIBLE); - }else - { - ToastUtils.warning("权限密码不正确!"); - } - } - } - }); } /** @@ -106,7 +83,6 @@ public class SystemSetActivity extends BaseActivity { fragmentAdapter.addFragment(new SceneSetFragment()); fragmentAdapter.addFragment(new PicManagerFragment()); fragmentAdapter.addFragment(new WokDirectionSetFragment()); - fragmentAdapter.addFragment(new PlcAddressFragment()); viewBinding.viewpager.setAdapter(fragmentAdapter); } diff --git a/app/src/main/java/com/bonait/bnframework/newui/adapter/order/FoodInfoAdapter.java b/app/src/main/java/com/bonait/bnframework/newui/adapter/order/FoodInfoAdapter.java index b4941115..5968c827 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/adapter/order/FoodInfoAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/newui/adapter/order/FoodInfoAdapter.java @@ -1,6 +1,10 @@ package com.bonait.bnframework.newui.adapter.order; import android.annotation.SuppressLint; +import android.graphics.Color; +import android.text.Spannable; +import android.text.SpannableStringBuilder; +import android.text.style.ForegroundColorSpan; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -8,6 +12,9 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; +import com.bonait.bnframework.common.utils.ProcessValueUtil; +import com.bonait.bnframework.modbus.Wok1ModbusTcpServer; import com.bonait.bnframework.newui.adapter.base.BaseAdapter; import com.bonait.bnframework.common.utils.DisplayManager; import com.bonait.bnframework.databinding.ItemFoodInfoBinding; @@ -17,7 +24,7 @@ import com.bonait.bnframework.databinding.ItemFoodInfoBinding; * @description: 订单右边的配料信息 * @date: 2024/5/9 9:02. */ -public class FoodInfoAdapter extends BaseAdapter { +public class FoodInfoAdapter extends BaseAdapter { @NonNull @Override @@ -32,7 +39,16 @@ public class FoodInfoAdapter extends BaseAdapter= Build.VERSION_CODES.JELLY_BEAN) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + // 全屏显示,隐藏状态栏和导航栏,拉出状态栏和导航栏显示一会儿后消失。 + // 启动游戏模式,设置状态栏和导航栏中的图标变小,变模糊或者弱化其效果 + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LOW_PROFILE + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } else { + // 全屏显示,隐藏状态栏 + window.getDecorView().setSystemUiVisibility(View.INVISIBLE); + } + } + } + @Override + public void onStart() { + super.onStart(); + if (getDialog() != null) { + Window window = getDialog().getWindow(); + assert window != null; + fullScreen(window); + window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + WindowManager.LayoutParams params = window.getAttributes(); + params.gravity = Gravity.CENTER; + params.width = ViewGroup.LayoutParams.WRAP_CONTENT; + params.height = ViewGroup.LayoutParams.WRAP_CONTENT; + window.setAttributes(params); + } + AdbCommandUtil.hideStatusBar(true); + + initView(); + } + + private void initView(){ + viewBinding.btnClose1.setOnClickListener(v->{ + dismiss(); + }); + + freshView(); + handler.sendEmptyMessageDelayed(1,200); + } + + @SuppressLint("SetTextI18n") + private void freshView(){ + if(RobotModbusTcpServer.get().plcIsConnect){ + ThreadManager.get().execute(()->{ + for(int i=1;i<=4;i++){ + Object kongPen = ModbusCenter.ReadPlc(i,i+"#空盆库位检测有无"); + if(kongPen != null){ + kongPenList[i-1] = (Boolean) kongPen; + }else{ + kongPenList[i-1] = false; + } + } + }); + }else { + viewBinding.tvChucan1.setText("出餐盘1:无盆"); + viewBinding.tvChucan2.setText("出餐盘2:无盆"); + viewBinding.tvChucan3.setText("出餐盘3:无盆"); + viewBinding.tvChucan4.setText("出餐盘4:无盆"); + viewBinding.tvChucan1.setSelected(false); + viewBinding.tvChucan2.setSelected(false); + viewBinding.tvChucan3.setSelected(false); + viewBinding.tvChucan4.setSelected(false); + } + } + @Override + public void dismiss() { + super.dismiss(); + if(handler!=null){ + handler.removeCallbacksAndMessages(null); + handler = null; + } + } + @Override + public void onDestroy() { + super.onDestroy(); + if(handler!=null){ + handler.removeCallbacksAndMessages(null); + handler = null; + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/newui/dialog/control/FoodPosSetDialog.java b/app/src/main/java/com/bonait/bnframework/newui/dialog/control/FoodPosSetDialog.java index 62f6c126..99eb7e56 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/dialog/control/FoodPosSetDialog.java +++ b/app/src/main/java/com/bonait/bnframework/newui/dialog/control/FoodPosSetDialog.java @@ -129,7 +129,12 @@ public class FoodPosSetDialog extends DialogFragment { ArrayAdapter spinnerAdapter3 = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, posList); spinnerAdapter3.setDropDownViewResource(R.layout.spinner_dropdown_item); viewBinding.spinnerPosition.setAdapter(spinnerAdapter3); - viewBinding.spinnerPosition.setSelection(0); + + if(order.mainPosition!=0){ + viewBinding.spinnerPosition.setSelection(order.mainPosition-1); + }else { + viewBinding.spinnerPosition.setSelection(0); + } mainPosition = Integer.parseInt(viewBinding.spinnerPosition.getSelectedItem().toString().substring(1)); viewBinding.spinnerPosition.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override @@ -151,7 +156,11 @@ public class FoodPosSetDialog extends DialogFragment { ArrayAdapter spinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, wokList); spinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item); viewBinding.spinnerWok.setAdapter(spinnerAdapter); - viewBinding.spinnerWok.setSelection(0); + if(order.type!=0){ + viewBinding.spinnerWok.setSelection(order.type-1); + }else { + viewBinding.spinnerWok.setSelection(0); + } deviceNum = Integer.parseInt(viewBinding.spinnerWok.getSelectedItem().toString().substring(0,1)); viewBinding.spinnerWok.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override diff --git a/app/src/main/java/com/bonait/bnframework/newui/dialog/control/RobotControlDialog.java b/app/src/main/java/com/bonait/bnframework/newui/dialog/control/RobotControlDialog.java index 262662c0..b5853f5a 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/dialog/control/RobotControlDialog.java +++ b/app/src/main/java/com/bonait/bnframework/newui/dialog/control/RobotControlDialog.java @@ -402,7 +402,7 @@ public class RobotControlDialog extends DialogFragment { return; } - WaitProcessUtil.getInstance().show(getContext(),"提示","机器人正在向炒锅投主料"+data.get("主料位置")+",请等待完成,不要进行其他操作!"); + WaitProcessUtil.getInstance().show(getContext(),"提示","机器人正在向炒锅放主料盆Z"+position+",请等待完成,不要进行其他操作!"); ThreadManager.get().execute(new Thread(new Runnable() { @Override public void run() { diff --git a/app/src/main/java/com/bonait/bnframework/newui/dialog/control/WokControlDialog.java b/app/src/main/java/com/bonait/bnframework/newui/dialog/control/WokControlDialog.java index 89b0ea19..604b699f 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/dialog/control/WokControlDialog.java +++ b/app/src/main/java/com/bonait/bnframework/newui/dialog/control/WokControlDialog.java @@ -47,6 +47,7 @@ import com.bonait.bnframework.modbus.Wok1ModbusTcpServer; import com.bonait.bnframework.modbus.Wok3ModbusTcpServer; import com.bonait.bnframework.modbus.Wok4ModbusTcpServer; import com.bonait.bnframework.newui.widget.NewToastUtil; +import com.bonait.bnframework.newui.widget.WaitProcessUtil; import com.qmuiteam.qmui.widget.dialog.QMUIDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; @@ -500,12 +501,25 @@ public class WokControlDialog extends DialogFragment { } }); freshSilos(); - //todo 投料 viewBinding.mainFoodTouliao1.setOnClickListener(v->{ - + WaitProcessUtil.getInstance().show(getContext(),"提示",deviceNum+"号炒锅正在投放主料1号位,请等待完成,不要进行其他操作!"); + ThreadManager.get().execute(()->{ + ExecuteTheRecipe.Make位置(deviceNum,"炒菜位高"); + ExecuteTheRecipe.BottomClick1(deviceNum,"主料1号位"); + ExecuteTheRecipe.ThreadWhile(deviceNum, "1号位倒菜完成"); + WaitProcessUtil.getInstance().dismiss(); + NewToastUtil.getInstance().showToast("投料完成"); + }); }); - viewBinding.mainFoodTouliao1.setOnClickListener(v->{ - + viewBinding.mainFoodTouliao2.setOnClickListener(v->{ + WaitProcessUtil.getInstance().show(getContext(),"提示",deviceNum+"号炒锅正在投放主料2号位,请等待完成,不要进行其他操作!"); + ThreadManager.get().execute(()->{ + ExecuteTheRecipe.Make位置(deviceNum,"炒菜位高"); + ExecuteTheRecipe.BottomClick1(deviceNum,"主料2号位"); + ExecuteTheRecipe.ThreadWhile(deviceNum, "2号位倒菜完成"); + WaitProcessUtil.getInstance().dismiss(); + NewToastUtil.getInstance().showToast("投料完成"); + }); }); } diff --git a/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeDevicesFragment.java b/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeDevicesFragment.java index e2ecd55a..e1b34fd0 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeDevicesFragment.java +++ b/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeDevicesFragment.java @@ -23,6 +23,7 @@ import com.bonait.bnframework.modbus.Wok2ModbusTcpServer; import com.bonait.bnframework.modbus.Wok1ModbusTcpServer; import com.bonait.bnframework.modbus.Wok3ModbusTcpServer; import com.bonait.bnframework.modbus.Wok4ModbusTcpServer; +import com.bonait.bnframework.newui.dialog.check.ChuCanPenCheckDialog; import com.bonait.bnframework.newui.dialog.control.RobotControlDialog; import com.bonait.bnframework.newui.dialog.control.WokControlDialog; import com.bonait.bnframework.newui.widget.NewToastUtil; @@ -80,6 +81,27 @@ public class HomeDevicesFragment extends BaseFragment { } showWokDialog(2); }); + viewBinding.btnChaoguo3.setOnClickListener(v->{ + if(ConfigName.getInstance().isFastClick()){ + return; + } + showWokDialog(3); + }); + viewBinding.btnChaoguo4.setOnClickListener(v->{ + if(ConfigName.getInstance().isFastClick()){ + return; + } + showWokDialog(4); + }); + viewBinding.btnChuCan.setOnClickListener(v->{ + if(ConfigName.getInstance().isFastClick()){ + return; + } + if(getActivity()!=null){ + ChuCanPenCheckDialog dialog = new ChuCanPenCheckDialog(); + dialog.show(getActivity().getSupportFragmentManager(),"空盆检测"); + } + }); } /** @@ -97,7 +119,7 @@ public class HomeDevicesFragment extends BaseFragment { bundle.putBoolean("showTip",showTip); dialog.setArguments(bundle); if(getActivity()!=null){ - dialog.show(getActivity().getSupportFragmentManager(),"投料控制2"); + dialog.show(getActivity().getSupportFragmentManager(),"机器人控制"); } } diff --git a/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeMainsFragment.java b/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeMainsFragment.java index ee848b83..080b617f 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeMainsFragment.java +++ b/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeMainsFragment.java @@ -19,6 +19,8 @@ import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.DisplayManager; import com.bonait.bnframework.common.utils.UpdateAppUtils; +import com.bonait.bnframework.databinding.DialogOrderBinding; +import com.bonait.bnframework.databinding.DialogPswBinding; import com.bonait.bnframework.databinding.DialogWithCancelConfirmBinding; import com.bonait.bnframework.databinding.FragmentHomeMainsBinding; import com.bonait.bnframework.manager.ActivityLifecycleManager; @@ -27,6 +29,7 @@ import com.bonait.bnframework.newui.activity.EditGoodsHActivity; import com.bonait.bnframework.newui.activity.LogRecordHActivity; import com.bonait.bnframework.newui.activity.LoginHActivity; import com.bonait.bnframework.newui.activity.OrderRecordHActivity; +import com.bonait.bnframework.newui.activity.PlcDebugActivity; import com.bonait.bnframework.newui.widget.XComDialog; import com.bonait.bnframework.newui.activity.SetSeasoningActivity; import com.bonait.bnframework.newui.activity.SystemSetActivity; @@ -107,7 +110,7 @@ public class HomeMainsFragment extends BaseFragment { OpenActivity(OrderRecordHActivity.class); }); - binding.llSetting.setOnClickListener(v->{ + binding.llSetting.setOnClickListener(view->{ if(!ConfigName.getInstance().user.name.equals("管理员")){ NewToastUtil.getInstance().showToast("管理员才能进行操作"); return; @@ -115,7 +118,30 @@ public class HomeMainsFragment extends BaseFragment { if(ConfigName.getInstance().isFastClick()){ return; } - OpenActivity(SystemSetActivity.class); + AlertDialogUtils.showCancelAndConfirmDialog((AppCompatActivity) getActivity(), R.layout.dialog_psw, (layoutView, xCom) -> { + DialogPswBinding binding = DialogPswBinding.bind(layoutView); + binding.title.setText("提示"); + binding.submit.setText("确认"); + binding.submit.setOnClickListener(v->{ + String psw = binding.edit.getText().toString(); + if(psw.equals("123")){ + OpenActivity(PlcDebugActivity.class); + xCom.dismissX(); + }else if(psw.equals("123456")){ + OpenActivity(SystemSetActivity.class); + xCom.dismissX(); + }else { + NewToastUtil.getInstance().showToastError("密码错误"); + } + }); + binding.cancel.setOnClickListener(v->{ + xCom.dismissX(); + }); + binding.btnClose.setOnClickListener(v->{ + xCom.dismissX(); + }); + }); + }); binding.llUpdate.setOnClickListener(v->{ if(ConfigName.getInstance().user.name.equals("一般用户")){ diff --git a/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeOrderFragment.java b/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeOrderFragment.java index c8b1cfe4..b16c3b64 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeOrderFragment.java +++ b/app/src/main/java/com/bonait/bnframework/newui/fragment/main/HomeOrderFragment.java @@ -2,13 +2,19 @@ package com.bonait.bnframework.newui.fragment.main; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; import android.view.LayoutInflater; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleEventObserver; import androidx.lifecycle.LifecycleObserver; +import androidx.lifecycle.LifecycleOwner; import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.Model.CheckPositionBean; @@ -58,17 +64,44 @@ import java.util.List; * @description: 首页订单 * @date: 2024/5/24 13:30. */ -public class HomeOrderFragment extends BaseFragment { +public class HomeOrderFragment extends BaseFragment{ private String TAG = "HomeOrderFragment==>"; private FragmentHomeOrderBinding viewBinding; private OrderInfoAdapter orderAdapter1;//订单列表 private FoodInfoAdapter foodInfoAdapter;// 订单右边的配料信息 private List orderDetails1; - private List foodInfoList = new ArrayList<>(); + private List foodInfoList = new ArrayList<>(); private BPA_ORDER_DETAIL orderDetail; private DeviceStatusView deviceStatusView1,deviceStatusView2,deviceStatusView3,deviceStatusView4; + private Handler handler = new Handler(Looper.getMainLooper()){ + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + if(msg.what==1){ + if(viewBinding!=null){ + if(deviceStatusView1!=null){ + deviceStatusView1.init(); + } + if(deviceStatusView2!=null){ + deviceStatusView2.init(); + } + if(deviceStatusView3!=null){ + deviceStatusView3.init(); + } + if(deviceStatusView4!=null){ + deviceStatusView4.init(); + } + if(handler.hasMessages(1)){ + handler.removeMessages(1); + } + handler.sendEmptyMessageDelayed(1,1000); + } + } + } + }; + @Override protected View onCreateView() { View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_home_order, null); @@ -95,6 +128,8 @@ public class HomeOrderFragment extends BaseFragment { viewBinding.llDevices.addView(deviceStatusView3); viewBinding.llDevices.addView(deviceStatusView4); LogUtils.d("Home4Fragment onViewCreated"); + + handler.sendEmptyMessage(1); } @Override @@ -161,6 +196,7 @@ public class HomeOrderFragment extends BaseFragment { xCom.dismissX(); orderMaking(mData,position); }); + }); }else { orderMaking(mData,position); @@ -264,9 +300,33 @@ public class HomeOrderFragment extends BaseFragment { */ private boolean checkPosition(int mainPosition,int deviceNum){ if(mainPosition==0|deviceNum==0){ - NewToastUtil.getInstance().showToastError("请设置位置信息"); + NewToastUtil.getInstance().showToastError("请先绑定位置信息"); + AlertDialogUtils.showTipDialog((AppCompatActivity) getActivity(), "警告", + "请先绑定位置信息,在页面右下角点击“设置位置", new AlertDialogUtils.DialogClickListener() { + @Override + public void onConfirm() { + } + @Override + public void onCancel() { + } + }); return false; } + List orderDetails = OrderDetailUtil.getByAllMaking(); + for(BPA_ORDER_DETAIL bean : orderDetails){ + if (bean.mainPosition == mainPosition){ + AlertDialogUtils.showTipDialog((AppCompatActivity) getActivity(), "警告", + "Z"+mainPosition+"库位正在使用,请更换位置", new AlertDialogUtils.DialogClickListener() { + @Override + public void onConfirm() { + } + @Override + public void onCancel() { + } + }); + return false; + } + } if(mainPosition==1 || mainPosition == 2 || mainPosition == 3){ if(deviceNum == 1 || deviceNum == 4){ return true; @@ -276,8 +336,8 @@ public class HomeOrderFragment extends BaseFragment { return true; } } - AlertDialogUtils.showTipDialog((AppCompatActivity) getActivity(), "提示", - "Z1 Z2 Z3库位只能绑定1号和4号炒锅,Z4 Z5 Z6库位只能绑定2号和3号炒锅", new AlertDialogUtils.DialogClickListener() { + AlertDialogUtils.showTipDialog((AppCompatActivity) getActivity(), "警告", + "Z1 Z2 Z3库位只能绑定1号和4号炒锅\nZ4 Z5 Z6库位只能绑定2号和3号炒锅", new AlertDialogUtils.DialogClickListener() { @Override public void onConfirm() { } @@ -285,7 +345,6 @@ public class HomeOrderFragment extends BaseFragment { public void onCancel() { } }); - NewToastUtil.getInstance().showToastError("Z1 Z2 Z3库位只能绑定1号和4号炒锅,Z4 Z5 Z6库位只能绑定2号和3号炒锅"); return false; } @@ -341,6 +400,7 @@ public class HomeOrderFragment extends BaseFragment { NewToastUtil.getInstance().showToastError("请放置对应出餐空盆!"); AlertDialogUtils.showCancelAndConfirmDialog((AppCompatActivity) getActivity(), R.layout.dialog_order, (layoutView, xCom) -> { DialogOrderBinding binding = DialogOrderBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); binding.title.setText("出菜盆检测警告"); binding.edit.setText(mData.get(position).type+"号炒锅未检测到出菜盆,请放置对应出餐空盆!或检测盆是否放置正确"); binding.cancel.setVisibility(View.GONE); @@ -351,6 +411,9 @@ public class HomeOrderFragment extends BaseFragment { binding.cancel.setOnClickListener(v->{ xCom.dismissX(); }); + binding.btnClose.setOnClickListener(v->{ + xCom.dismissX(); + }); }); return; } @@ -398,9 +461,10 @@ public class HomeOrderFragment extends BaseFragment { } } } - for(BPA_GOODS_PROCESS_DETAIL detail:details){ - foodInfoList.add(detail.processname+":"+ ProcessValueUtil.getProcessSms(detail.processname,detail.processvalue)); - } +// for(BPA_GOODS_PROCESS_DETAIL detail:details){ +// foodInfoList.add(detail.processname+":"+ ProcessValueUtil.getProcessSms(detail.processname,detail.processvalue)); +// } + foodInfoList.addAll(details); foodInfoAdapter.notifyDataSetChanged(); changeRightBtn(); } @@ -428,6 +492,7 @@ public class HomeOrderFragment extends BaseFragment { AlertDialogUtils.showCancelAndConfirmDialog((AppCompatActivity) getActivity(), R.layout.dialog_order, (layoutView, xCom) -> { String name = goodsName +"-"+ (groupName==null?"":groupName); DialogOrderBinding binding = DialogOrderBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); String desc = "是否取消【"+name+"】订单?"; binding.submit.setText("删除"); @@ -446,7 +511,6 @@ public class HomeOrderFragment extends BaseFragment { desc = "【"+name+"】订单出现异常,是否删除?"; break; } - DisplayManager.scaleViewGroup(binding.getRoot()); binding.title.setText("取消订单"); binding.edit.setText(desc); binding.submit.setOnClickListener(view1 -> { @@ -490,6 +554,7 @@ public class HomeOrderFragment extends BaseFragment { // } AlertDialogUtils.showCancelAndConfirmDialog((AppCompatActivity) getActivity(), R.layout.dialog_order, (layoutView, xCom) -> { DialogOrderBinding binding = DialogOrderBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); String desc = "【"+name+"】订单"; switch (status){ case -1: @@ -514,7 +579,6 @@ public class HomeOrderFragment extends BaseFragment { break; } - DisplayManager.scaleViewGroup(binding.getRoot()); binding.title.setText("制作订单"); binding.edit.setText(desc); binding.submit.setOnClickListener(view1 -> { @@ -697,6 +761,9 @@ public class HomeOrderFragment extends BaseFragment { public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if(isVisibleToUser){ + if(handler!=null){ + handler.sendEmptyMessage(1); + } LogUtils.d("HomeOrderFragment setUserVisibleHint true"); if(orderDetails1!=null){ orderDetails1.clear(); @@ -712,6 +779,9 @@ public class HomeOrderFragment extends BaseFragment { } EventBus.getDefault().register(this); }else { + if(handler!=null){ + handler.removeCallbacksAndMessages(null); + } LogUtils.d("HomeOrderFragment setUserVisibleHint false"); EventBus.getDefault().unregister(this); } diff --git a/app/src/main/java/com/bonait/bnframework/newui/fragment/setting/SceneSetFragment.java b/app/src/main/java/com/bonait/bnframework/newui/fragment/setting/SceneSetFragment.java index 831f3521..4c4c8602 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/fragment/setting/SceneSetFragment.java +++ b/app/src/main/java/com/bonait/bnframework/newui/fragment/setting/SceneSetFragment.java @@ -105,6 +105,7 @@ public class SceneSetFragment extends BaseFragment { viewBinding.editDeviceNumber.setText(PreferenceUtils.getString(ConfigName.deviceNumber,"")); viewBinding.zijianSwitch.setChecked(PreferenceUtils.getBoolean(ConfigName.rootTip,true)); + viewBinding.switchToast.setChecked(PreferenceUtils.getBoolean(ConfigName.cookToast,true)); viewBinding.btnUpdateKey.setOnClickListener(v->{ ThreadManager.get().execute(new Thread(()->{ HomeGoodsViewModel.GetServiceKey(new HomeGoodsViewModel.CallBack() { @@ -131,6 +132,8 @@ public class SceneSetFragment extends BaseFragment { PreferenceUtils.setString(ConfigName.serviceKey,viewBinding.editKey.getText().toString()); PreferenceUtils.setString(ConfigName.deviceNumber,viewBinding.editDeviceNumber.getText().toString()); PreferenceUtils.setBoolean(ConfigName.rootTip,viewBinding.zijianSwitch.isChecked()); + PreferenceUtils.setBoolean(ConfigName.cookToast,viewBinding.switchToast.isChecked()); + ConfigName.getInstance().showCookingToast = viewBinding.switchToast.isChecked(); DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_SYSTEMSET.class,null); ConfigName.getInstance().DeviceAutoKey = viewBinding.editDeviceNumber.getText().toString(); diff --git a/app/src/main/java/com/bonait/bnframework/newui/fragment/setting/WokDirectionSetFragment.java b/app/src/main/java/com/bonait/bnframework/newui/fragment/setting/WokDirectionSetFragment.java index d20fc04a..41141f49 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/fragment/setting/WokDirectionSetFragment.java +++ b/app/src/main/java/com/bonait/bnframework/newui/fragment/setting/WokDirectionSetFragment.java @@ -9,11 +9,13 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.widget.ArrayAdapter; import android.widget.EditText; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.HBL.Thread.ThreadManager; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ExecuteTheRecipe; @@ -27,6 +29,9 @@ import com.bonait.bnframework.databinding.FragmentWokDirectionSetBinding; import com.bonait.bnframework.modbus.ModbusCenter; import com.bonait.bnframework.newui.widget.NewToastUtil; +import java.util.ArrayList; +import java.util.List; + /** * @author: liup * @description: 设备信息设置 @@ -155,17 +160,37 @@ public class WokDirectionSetFragment extends BaseFragment { } }); + List wokList = new ArrayList<>(); + wokList.add("1"); + wokList.add("2"); + wokList.add("3"); + wokList.add("4"); + ArrayAdapter spinnerAdapter2 = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, wokList); + spinnerAdapter2.setDropDownViewResource(R.layout.spinner_dropdown_item); + viewBinding.spinnerWok.setAdapter(spinnerAdapter2); + viewBinding.spinnerWok.setSelection(0); viewBinding.deviceNumSave.setOnClickListener(v->{ - String num = viewBinding.edtDeviceNum.getText().toString(); - if(num.equals("2")){ - deviceNum = 2; - RefreshThread(); - }else if(num.equals("1")){ - deviceNum = 1; - RefreshThread(); - }else { - NewToastUtil.getInstance().showToastError("请输入有效设备号!"); - return; + String num = viewBinding.spinnerWok.getSelectedItem().toString(); + switch (num) { + case "1": + deviceNum = 1; + RefreshThread(); + break; + case "2": + deviceNum = 2; + RefreshThread(); + break; + case "3": + deviceNum = 3; + RefreshThread(); + break; + case "4": + deviceNum = 4; + RefreshThread(); + break; + default: + NewToastUtil.getInstance().showToastError("请输入有效设备号!"); + return; } viewBinding.tvDeviceNum.setText(deviceNum+"号设备"); }); diff --git a/app/src/main/java/com/bonait/bnframework/newui/widget/DeviceStatusView.java b/app/src/main/java/com/bonait/bnframework/newui/widget/DeviceStatusView.java index 06fbc889..274a6e96 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/widget/DeviceStatusView.java +++ b/app/src/main/java/com/bonait/bnframework/newui/widget/DeviceStatusView.java @@ -40,24 +40,24 @@ public class DeviceStatusView extends FrameLayout implements LifecycleEventObser private static final Logger log = LoggerFactory.getLogger(DeviceStatusView.class); private ViewDeviceStatusBinding viewBinding; - private int deviceNum = 1; + private int deviceNum = 0; private boolean isResume = true; - private Handler handler = new Handler(Looper.getMainLooper()){ - @Override - public void handleMessage(@NonNull Message msg) { - super.handleMessage(msg); - if(msg.what==1){ - if(viewBinding!=null){ - init(); - if(handler.hasMessages(1)){ - handler.removeMessages(1); - } - handler.sendEmptyMessageDelayed(1,1000); - } - } - } - }; +// private Handler handler = new Handler(Looper.getMainLooper()){ +// @Override +// public void handleMessage(@NonNull Message msg) { +// super.handleMessage(msg); +// if(msg.what==1){ +// if(viewBinding!=null){ +// init(); +// if(handler.hasMessages(1)){ +// handler.removeMessages(1); +// } +// handler.sendEmptyMessageDelayed(1,1000); +// } +// } +// } +// }; public DeviceStatusView(Context context, AttributeSet attrs, int deviceNum) { super(context, attrs); @@ -68,20 +68,23 @@ public class DeviceStatusView extends FrameLayout implements LifecycleEventObser init(); } - private void init(){ + public void init(){ try { + if(deviceNum==0 || viewBinding.name==null){ + return; + } BPA_ORDER_DETAIL orderDetail = OrderDetailUtil.getByMaking(deviceNum); viewBinding.name.setText(deviceNum+"号炒锅"); if(orderDetail==null){ viewBinding.tvGoods.setText(""); }else { - viewBinding.tvGoods.setText(orderDetail.goodsName+"-"+orderDetail.groupName); + viewBinding.tvGoods.setText(orderDetail.goodsName); } Object val_wd = ModbusCenter.getWokListingValue(deviceNum,"当前锅底温度"); if (val_wd != null) { - viewBinding.tvWendu.setText("锅内温度:"+val_wd + "°C"); + viewBinding.tvWendu.setText(val_wd + "°C"); } else { - viewBinding.tvWendu.setText("锅内温度:"+"??°C"); + viewBinding.tvWendu.setText("??°C"); } if(Wok1ModbusTcpServer.get().plcIsConnect){ @@ -106,16 +109,16 @@ public class DeviceStatusView extends FrameLayout implements LifecycleEventObser public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) { switch (event) { case ON_PAUSE: - if(handler!=null){ - handler.removeCallbacksAndMessages(null); - LogUtils.d("DeviceStatusView onStateChanged ON_PAUSE"); - } +// if(handler!=null){ +// handler.removeCallbacksAndMessages(null); +// LogUtils.d("DeviceStatusView onStateChanged ON_PAUSE"); +// } break; case ON_RESUME: - if(handler!=null){ - handler.sendEmptyMessage(1); - LogUtils.d("DeviceStatusView onStateChanged ON_RESUME"); - } +// if(handler!=null){ +// handler.sendEmptyMessage(1); +// LogUtils.d("DeviceStatusView onStateChanged ON_RESUME"); +// } break; } } diff --git a/app/src/main/res/drawable/bg_order.xml b/app/src/main/res/drawable/bg_order.xml index d810875d..526c6e59 100644 --- a/app/src/main/res/drawable/bg_order.xml +++ b/app/src/main/res/drawable/bg_order.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_plc_debug.xml b/app/src/main/res/layout/activity_plc_debug.xml new file mode 100644 index 00000000..52be81cd --- /dev/null +++ b/app/src/main/res/layout/activity_plc_debug.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_system_set.xml b/app/src/main/res/layout/activity_system_set.xml index 58732ca2..588b1437 100644 --- a/app/src/main/res/layout/activity_system_set.xml +++ b/app/src/main/res/layout/activity_system_set.xml @@ -78,12 +78,12 @@ android:layout_marginTop="5dp" android:layout_height="match_parent"> - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - -