From ce5772be030c03a502fe2b0afe99bd36bccfd73f Mon Sep 17 00:00:00 2001 From: liup <1454939542@qq.com> Date: Fri, 27 Dec 2024 17:50:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E5=8D=95=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/other.xml | 340 ++++++++++++++++++ .../bnframework/HBL/Thread/ThreadManager.java | 16 +- .../business/ExecuteTheRecipe.java | 132 +++---- .../common/db/util/OrderDetailUtil.java | 27 +- .../db/util/SubAttributeGroupDBUtil.java | 9 + .../common/utils/CookTimeUtils.java | 108 +++--- .../bnframework/event/MakingStepEvent.java | 2 +- .../bnframework/modbus/ModbusCenter.java | 9 +- .../newui/activity/LoginHActivity.java | 6 + .../newui/activity/MainHActivity.java | 2 +- .../newui/activity/WelcomeActivity.java | 2 +- .../newui/adapter/order/OrderInfoAdapter.java | 15 + .../newui/dialog/check/FoodInfoDialog.java | 58 ++- .../dialog/control/FoodPosSetDialog.java | 99 ++++- .../dialog/control/WokControlDialog.java | 13 +- .../fragment/cooking/CookingFragment.java | 33 +- .../fragment/main/HomeDevicesFragment.java | 2 +- .../fragment/main/HomeOrderFragment.java | 268 ++++++++++---- .../newui/widget/FoodPosSetView.java | 40 ++- .../res/layout/item/layout/item_step_desc.xml | 2 +- .../layout/new/layout/dialog_food_info.xml | 16 +- .../layout/new/layout/dialog_food_pos_set.xml | 50 ++- .../layout/new/layout/fragment_cooking.xml | 12 +- .../res/layout/new/layout/item_order_info.xml | 15 +- .../layout/new/layout/view_food_pos_set.xml | 8 +- 25 files changed, 1043 insertions(+), 241 deletions(-) create mode 100644 .idea/other.xml diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 00000000..b45a6e02 --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,340 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/HBL/Thread/ThreadManager.java b/app/src/main/java/com/bonait/bnframework/HBL/Thread/ThreadManager.java index 999d8ca9..1617cb2b 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/Thread/ThreadManager.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/Thread/ThreadManager.java @@ -58,24 +58,30 @@ public class ThreadManager { public void StartLong(String Key, boolean IsRestart, IThread _thread) { if (!tm.containsKey(Key)) { tm.put(Key, new ThreadModel()); + if(tm.get(Key)==null){ + return; + } tm.get(Key).Task = _thread; - tm.get(Key).ThreadObj = new Thread(() -> { MessageLog.ShowInfo("启动线程:" + Key); - while (!tm.get(Key).IsCancel) { + while (tm.get(Key)!=null&&!tm.get(Key).IsCancel) { if (IsRestart) { try { - tm.get(Key).Task.Run(); + if(!tm.isEmpty() && tm.get(Key)!=null){ + tm.get(Key).Task.Run(); + } } catch (Exception ex) { MessageLog.ShowError("多线程:[" + Key + "] 运行发生异常,已重启,错误信息:" + ex.toString()); LogUtils.d("多线程:[" + Key + "] 运行发生异常,已重启,错误信息:" + ex.toString()); Sleep(RestartInterval); + ex.printStackTrace(); } } else { try { tm.get(Key).Task.Run(); } catch (Exception e) { - MessageLog.ShowError("多线程:[" + Key + "] 运行发生异常,已重启,错误信息:" + e.toString()); + MessageLog.ShowError("多线程:[" + Key + "] 运行发生异常2,已重启,错误信息:" + e.toString()); + e.printStackTrace(); } } } @@ -123,7 +129,7 @@ public class ThreadManager { for (HashMap.Entry entry : tm.entrySet()) { entry.getValue().IsCancel = true; } - tm.clear(); +// tm.clear(); } } 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 90520bcd..ce93b1ea 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -9,10 +9,13 @@ import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; +import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP; import com.bonait.bnframework.common.db.mode.BPA_ORDER_DETAIL; import com.bonait.bnframework.common.db.mode.BPA_SILOS; import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil; import com.bonait.bnframework.common.db.util.OrderDetailUtil; +import com.bonait.bnframework.common.db.util.SubAttributeDBUtil; +import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil; import com.bonait.bnframework.common.helper.I.IWriteCallBack; import com.bonait.bnframework.event.MakingStepEvent; import com.bonait.bnframework.modbus.ModbusCenter; @@ -60,30 +63,29 @@ public class ExecuteTheRecipe { if (ConfigName.MakeStatus[orderDetail.deviceNum -1] && orderDetail != null) { boolean isError = false; long startTime = System.currentTimeMillis(); //起始时间 - showlog("开始烹饪菜谱【" + orderDetail.goodsName + "】"); + showlog(orderDetail.deviceNum,"开始烹饪菜谱【" + orderDetail.goodsName + "】"); try { //获取工艺 - ArrayList goodsrecipes = GoodsProcessDetailDBUtil.getByGroupId(orderDetail.groupId); + ArrayList goodsrecipes = new ArrayList<>(); if(orderDetail.deviceNum ==1){ Wok1ModbusTcpServer.get().WriteBool("M52.0", (boolean) true, null); - ConfigName.goodsProcess1.clear(); - ConfigName.goodsProcess1.addAll(goodsrecipes); + goodsrecipes = ConfigName.goodsProcess1; }else if(orderDetail.deviceNum ==2){ Wok2ModbusTcpServer.get().WriteBool("M52.0", (boolean) true, null); - ConfigName.goodsProcess2.clear(); - ConfigName.goodsProcess2.addAll(goodsrecipes); + goodsrecipes = ConfigName.goodsProcess2; }else if(orderDetail.deviceNum ==3){ Wok3ModbusTcpServer.get().WriteBool("M52.0", (boolean) true, null); - ConfigName.goodsProcess3.clear(); - ConfigName.goodsProcess3.addAll(goodsrecipes); + goodsrecipes = ConfigName.goodsProcess3; }else if(orderDetail.deviceNum ==4){ Wok4ModbusTcpServer.get().WriteBool("M52.0", (boolean) true, null); - ConfigName.goodsProcess4.clear(); - ConfigName.goodsProcess4.addAll(goodsrecipes); + goodsrecipes = ConfigName.goodsProcess4; } int m = 0; if(!goodsrecipes.isEmpty()){ ConfigName.hasClear[orderDetail.deviceNum -1] = goodsrecipes.get(goodsrecipes.size()-1).processname.contains("清洗"); + }else { + NewToastUtil.getInstance().showToast("商品工序为空!"); + return; } for (BPA_GOODS_PROCESS_DETAIL item : goodsrecipes) { @@ -94,7 +96,6 @@ public class ExecuteTheRecipe { while (ConfigName.IsPause[orderDetail.deviceNum -1]) { NewToastUtil.getInstance().showToast("当前菜品已暂停制作!"); RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.deviceNum +"号炒锅-"+",当前菜品已暂停制作"); - Thread.sleep(500); } if(!ConfigName.IsStart[orderDetail.deviceNum -1]){ @@ -114,14 +115,14 @@ public class ExecuteTheRecipe { boolean status = Execute(orderDetail.deviceNum,item, goodsrecipes, m); m++; } + long endTime = System.currentTimeMillis(); //结束时间 + int time = (int) ((endTime - startTime) / 1000); + SubAttributeGroupDBUtil.updateMakeTime(orderDetail.groupId,time); } catch (Exception ex) { LogUtils.d("制作订单 异常信息:" + ex.getMessage()); isError = true; - orderDetail.status = 3; - OrderDetailUtil.update(orderDetail); showToastErrorTip("异常信息:" + ex.getMessage()); - EventBus.getDefault().post(new MakingStepEvent(orderDetail.deviceNum,-1)); RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.deviceNum +"号炒锅("+orderDetail.goodsName+"-"+orderDetail.groupName+")-制作异常:"+ex.getMessage()); RecordManager.getInstance().addOrderRecords(orderDetail,orderDetail.deviceNum +"号炒锅-"+"异常"); } finally { @@ -131,24 +132,19 @@ public class ExecuteTheRecipe { WritePLC(orderDetail.deviceNum,"暂停开关", false, null); Make位置(orderDetail.deviceNum,"原点位"); if(orderDetail.deviceNum ==1){ - ConfigName.goodsProcess1.clear(); Wok1ModbusTcpServer.get().WriteBool("M52.0", (boolean) false, null); }else if(orderDetail.deviceNum ==2){ - ConfigName.goodsProcess2.clear(); Wok2ModbusTcpServer.get().WriteBool("M52.0", (boolean) false, null); }else if(orderDetail.deviceNum ==3){ - ConfigName.goodsProcess3.clear(); Wok3ModbusTcpServer.get().WriteBool("M52.0", (boolean) false, null); }else if(orderDetail.deviceNum ==4){ - ConfigName.goodsProcess4.clear(); Wok4ModbusTcpServer.get().WriteBool("M52.0", (boolean) false, null); } 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.deviceNum,"结束烹饪菜谱【" + orderDetail.goodsName + "】,关闭搅拌、关闭加热," + String.format("方法使用时间 %d s", time)); if (ConfigName.IsForcedEnd[orderDetail.deviceNum -1])//强制结束 { @@ -159,7 +155,7 @@ public class ExecuteTheRecipe { showToastErrorTip("客官,当前菜品已强制结束!!!"); //初始化 // BottomClick("初始化"); - showlog("菜谱【" + orderDetail.goodsName + "】已强制结束..."); + showlog(orderDetail.deviceNum,"菜谱【" + orderDetail.goodsName + "】已强制结束..."); ConfigName.IsForcedEnd[orderDetail.deviceNum -1] = false; RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.deviceNum +"号炒锅("+orderDetail.goodsName+"-"+orderDetail.groupName+")-制作取消"); RecordManager.getInstance().addOrderRecords(orderDetail,orderDetail.deviceNum +"号炒锅-"+"取消"); @@ -171,6 +167,10 @@ public class ExecuteTheRecipe { EventBus.getDefault().post(new MakingStepEvent(orderDetail.deviceNum,-3)); RecordManager.getInstance().addLogRecord("订单处理日志",orderDetail.deviceNum +"号炒锅("+orderDetail.goodsName+"-"+orderDetail.groupName+")-制作完成"); RecordManager.getInstance().addOrderRecords(orderDetail,orderDetail.deviceNum +"号炒锅-"+"完成"); + }else { + orderDetail.status = 3; + OrderDetailUtil.update(orderDetail); + EventBus.getDefault().post(new MakingStepEvent(orderDetail.deviceNum,-1)); } } reset1(orderDetail.deviceNum); @@ -193,17 +193,18 @@ public class ExecuteTheRecipe { public static boolean Execute(int deviceNum,BPA_GOODS_PROCESS_DETAIL recipe, ArrayList all, int index) { LogUtils.d(TAG+" Execute recipe="+recipe.toString()); boolean status = false; + NewToastUtil.getInstance().showToast(deviceNum+"号炒锅,执行步骤:"+(index+1)+"."+recipe.processname); try { //1.解析 if (ConfigName.IsForcedEnd[deviceNum-1]) { - showlog("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); + showlog(deviceNum,"客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); return false; } if(deviceNum==1){ while (!Wok1ModbusTcpServer.get().plcIsConnect||!Robot1ModbusTcpServer.get().plcIsConnect &&!ConfigName.IsForcedEnd[deviceNum-1]){ try{ - showlog("客官,检测到硬件已经断开连接,等待重连!!!"); + showlog(deviceNum,"客官,检测到硬件已经断开连接,等待重连!!!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+" 检测到硬件已经断开连接,等待连接中 Wok:" + Wok1ModbusTcpServer.get().plcIsConnect+" Robot:"+ Robot1ModbusTcpServer.get().plcIsConnect); Thread.sleep(100); @@ -215,7 +216,7 @@ public class ExecuteTheRecipe { while (!Wok2ModbusTcpServer.get().plcIsConnect||!Robot1ModbusTcpServer.get().plcIsConnect &&!ConfigName.IsForcedEnd[deviceNum-1]){ try{ - showlog("客官,检测到硬件已经断开连接,等待重连!!!"); + showlog(deviceNum,"客官,检测到硬件已经断开连接,等待重连!!!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+" 检测到硬件已经断开连接,等待连接中 Wok:" +Wok2ModbusTcpServer.get().plcIsConnect+" Robot:"+ Robot1ModbusTcpServer.get().plcIsConnect); Thread.sleep(100); @@ -227,7 +228,7 @@ public class ExecuteTheRecipe { while (!Wok3ModbusTcpServer.get().plcIsConnect||!Robot2ModbusTcpServer.get().plcIsConnect &&!ConfigName.IsForcedEnd[deviceNum-1]){ try{ - showlog("客官,检测到硬件已经断开连接,等待重连!!!"); + showlog(deviceNum,"客官,检测到硬件已经断开连接,等待重连!!!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+" 检测到硬件已经断开连接,等待连接中 Wok:" +Wok3ModbusTcpServer.get().plcIsConnect+" Robot:"+ Robot2ModbusTcpServer.get().plcIsConnect); Thread.sleep(100); @@ -239,7 +240,7 @@ public class ExecuteTheRecipe { while (!Wok4ModbusTcpServer.get().plcIsConnect||!Robot1ModbusTcpServer.get().plcIsConnect &&!ConfigName.IsForcedEnd[deviceNum-1]){ try{ - showlog("客官,检测到硬件已经断开连接,等待重连!!!"); + showlog(deviceNum,"客官,检测到硬件已经断开连接,等待重连!!!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+" 检测到硬件已经断开连接,等待连接中 Wok:" +Wok4ModbusTcpServer.get().plcIsConnect+" Robot:"+ Robot2ModbusTcpServer.get().plcIsConnect); Thread.sleep(100); @@ -257,7 +258,7 @@ 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 = "客官硬件加热异常,请联系海科人员,已强制停止炒制!"; @@ -328,7 +329,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); @@ -405,7 +406,8 @@ public class ExecuteTheRecipe { if (formulation.size() > 0) { switch (processname){ case "主料": - case "辅料": + case "调料小盆": + case "调料中盆": case "出菜": boolean isJre; Object K = ReadPLC(deviceNum,"加热"); @@ -502,7 +504,7 @@ public class ExecuteTheRecipe { Write_PLC_MainAccessory(deviceNum,formulation,1); ConfigName.RobotIsWorking[deviceNum-1] = false; break; - case "调料大盆": + case "调料中盆": ConfigName.RobotIsWorking[deviceNum-1] = true; Write_PLC_MainAccessory(deviceNum,formulation,2); ConfigName.RobotIsWorking[deviceNum-1] = false; @@ -549,14 +551,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; } @@ -590,7 +592,7 @@ public class ExecuteTheRecipe { if (key.contains("(秒)")) { val = Integer.parseInt(value); } else { - showlog("工序:" + key + "," + value); + showlog(deviceNum,"工序:" + key + "," + value); writeValue = GetMXValue(key, value); int finalWriteValue = writeValue; WritePLC(deviceNum,key, writeValue, new IWriteCallBack() { @@ -899,7 +901,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; @@ -908,7 +910,7 @@ public class ExecuteTheRecipe { for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - showlog("工序:" + key + "," + value); + showlog(deviceNum,"工序:" + key + "," + value); if (key.contains("(秒)") && !ConfigName.IsForcedEnd[deviceNum-1]) { int val = Integer.parseInt(value); ThreadDelay(deviceNum,val,"Write_PLC_CleanPan"); @@ -941,7 +943,7 @@ public class ExecuteTheRecipe { //等待清洗完成 ThreadWhileClear(deviceNum,"炒锅清洗反馈", 5); Make位置(deviceNum,"原点位"); - showlog("炒锅清洗完成!"); + showlog(deviceNum,"炒锅清洗完成!"); NewToastUtil.getInstance().showToast("炒锅清洗完成"); } catch (Exception ex) { showToastErrorTip("异常信息:" + ex.getMessage()); @@ -981,7 +983,7 @@ public class ExecuteTheRecipe { */ public static void Write_PLC_MainIngredients(int deviceNum,HashMap data) { try { - showlog("准备倒入主料!"); + showlog(deviceNum,"准备倒入主料!"); //判断炒制位置 String czwz = "炒菜位高"; String foodPosition = "Z1"; @@ -1055,7 +1057,7 @@ public class ExecuteTheRecipe { */ public static void Write_PLC_MainIngredients_shoudong(int deviceNum,HashMap data) { try { - showlog("准备倒入主料!"); + showlog(deviceNum,"准备倒入主料!"); //判断炒制位置 String czwz = "炒菜位高"; String foodPosition = "Z1"; @@ -1109,14 +1111,14 @@ public class ExecuteTheRecipe { } /** - * 写PLC投辅料 + * 写PLC投调料 * * @param data - * @param type 1:小盆 2:大盆 + * @param type 1:小盆 2:中盆 */ public static void Write_PLC_MainAccessory(int deviceNum,HashMap data,int type) { try { - showlog("准备倒入辅料!"); + showlog(deviceNum,"准备倒入调料"+(type==1?"小盆":"中盆")); //判断炒制位置 String czwz = "炒菜位高"; String foodPosition = "F1"; @@ -1127,9 +1129,9 @@ public class ExecuteTheRecipe { String value = entry.getValue(); if (key.contains("炒制位置")) { czwz = value; - }else if(key.contains("调料小盆位置")||key.contains("调料大盆位置")){ + }else if(key.contains("调料小盆位置")||key.contains("调料中盆位置")){ foodPosition = value.replace("t","").replace("T",""); - }else if(key.contains("辅料名称")){ + }else if(key.contains("调料名称")){ foodName = value; } } @@ -1186,12 +1188,12 @@ public class ExecuteTheRecipe { } /** - * 手动控制倒辅料 + * 手动控制倒调料 * @param data */ public static void Write_PLC_MainAccessory_shoudong(int deviceNum,HashMap data,int type) { try { - showlog("准备倒入辅料!"); + showlog(deviceNum,"准备倒入调料!"+(type==1?"小盆":"中盆")); //判断炒制位置 String czwz = "炒菜位高"; String foodPosition = "F1"; @@ -1202,7 +1204,7 @@ public class ExecuteTheRecipe { String value = entry.getValue(); if (key.contains("炒制位置")) { czwz = value; - }else if(key.contains("调料小盆位置")||key.contains("调料大盆位置")){ + }else if(key.contains("调料小盆位置")||key.contains("调料中盆位置")){ foodPosition = value.replace("t","").replace("T",""); }else if(key.contains("调料名称")){ foodName = value; @@ -1254,20 +1256,20 @@ public class ExecuteTheRecipe { */ public static void Write_PLC_MainOutdishes(int deviceNum,HashMap data,int index) { try { - showlog("准备出菜!"); + showlog(deviceNum,"准备出菜!"); //先延迟 for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - showlog("工序:" + key + "," + value); + showlog(deviceNum,"工序:" + key + "," + value); if (key.contains("(秒)")) { int val = Integer.parseInt(value); ThreadDelay(deviceNum,val,"Write_PLC_MainOutdishes"); } } WritePLC(deviceNum,"加热", false, null); - showlog("关闭搅拌、关闭加热!"); + showlog(deviceNum,"关闭搅拌、关闭加热!"); Wait_Robot_No_Working(deviceNum);//等待机器人空闲 int num = deviceNum>2?(deviceNum-2):deviceNum; @@ -1393,7 +1395,7 @@ public class ExecuteTheRecipe { }else { ThreadWhile(deviceNum,num+"#炒锅出餐完成"); } - showlog("出菜完成,锅体准备回到原位!"); + showlog(deviceNum,"出菜完成,锅体准备回到原位!"); } catch (Exception ex) { showToastErrorTip("异常信息:" + ex.getMessage()); } @@ -1420,7 +1422,7 @@ public class ExecuteTheRecipe { public void onFailure(String ErrorMsg) { } }); - showlog("火力按钮点击,当前级别:" + data); + showlog(deviceNum,"火力按钮点击,当前级别:" + data); } catch (Exception ex) { showToastErrorTip("异常信息:" + ex.getMessage()); @@ -1519,7 +1521,7 @@ public class ExecuteTheRecipe { int mmmm = delay - (int) ((System.currentTimeMillis() - startTime) / 1000); if (AtPresentTime != mmmm) { AtPresentTime = mmmm; - showlog(deviceNum+"号炒锅,延迟等待中,剩余"+AtPresentTime+"秒"); + showlog(deviceNum,deviceNum+"号炒锅,延迟等待中,剩余"+AtPresentTime+"秒"); } } catch (InterruptedException ex) { } @@ -1540,8 +1542,8 @@ public class ExecuteTheRecipe { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"等待物料("+name+")出料等待"); while (!IsComplete[0] && !ConfigName.IsForcedEnd[deviceNum-1]) { - if ((System.currentTimeMillis() - a) > 1000 * whileTime) { - showlog(name + ",异常超时退出!"); + if ((System.currentTimeMillis() - a) > 1000 * 300) { + showlog(deviceNum,name + ",异常超时退出!"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"异常超时退出"); break; } else { @@ -1552,7 +1554,7 @@ public class ExecuteTheRecipe { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"true"); }else { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"false"); - showlog(deviceNum+"号炒锅,等待"+name); + showlog(deviceNum,deviceNum+"号炒锅,等待"+name); } }else { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile_WL-"+"null"); @@ -1563,7 +1565,7 @@ public class ExecuteTheRecipe { if (AtPresentTime != mmmm) { AtPresentTime = mmmm; } - + showlog(deviceNum,deviceNum+"号炒锅出料剩余时间:"+mmmm+"秒"); Thread.sleep(500);//10 *6 } catch (InterruptedException e) { IsComplete[0] = true; @@ -1601,7 +1603,7 @@ public class ExecuteTheRecipe { showToastErrorTip(deviceNum+"号锅取原料——"+name.replace("检测","未检测到位")+",请检查是否放置正确!"); } RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile-"+name + ",false"); - showlog(deviceNum+"号炒锅,等待"+name); + showlog(deviceNum,deviceNum+"号炒锅,等待"+name); LogUtils.d(TAG+" ThreadWhile name="+name+" false"); } }else { @@ -1628,7 +1630,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 { @@ -1644,7 +1646,7 @@ public class ExecuteTheRecipe { BottomClick1(deviceNum,value); } RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhile-"+name + ",false"); - showlog(deviceNum+"号炒锅,等待"+name); + showlog(deviceNum,deviceNum+"号炒锅,等待"+name); LogUtils.d(TAG+" ThreadWhile name="+name+" false"); } }else { @@ -1675,7 +1677,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 { @@ -1685,11 +1687,11 @@ public class ExecuteTheRecipe { if (IsComplete[0]) { LogUtils.d(TAG+" ThreadWhileClear name="+name+" true"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhileClear-"+name + ",true"); - showlog(deviceNum+"号炒锅,清洗完成"); + showlog(deviceNum,deviceNum+"号炒锅,清洗完成"); }else { LogUtils.d(TAG+" ThreadWhileClear name="+name+" false"); RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhileClear-"+name + ",false"); - showlog(deviceNum+"号炒锅,清洗中..."); + showlog(deviceNum,deviceNum+"号炒锅,清洗中..."); } }else { RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-ThreadWhileClear-"+name + ",null"); @@ -1710,11 +1712,11 @@ public class ExecuteTheRecipe { /** * 显示日志 */ - public static void showlog(String msg) { + public static void showlog(int deviceNum,String msg) { LogUtils.d(TAG+" showlog msg="+msg); - RecordManager.getInstance().addLogRecord("订单处理日志","炒锅-showlog-"+msg + ""); + RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"炒锅-showlog-"+msg + ""); if(ConfigName.getInstance().showCookingToast){ - NewToastUtil.getInstance().showToast(msg); + NewToastUtil.getInstance().showToast(deviceNum+"号炒锅,"+msg); } } 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 1bde9522..1b15e5af 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 @@ -128,14 +129,13 @@ public class OrderDetailUtil { public static BPA_ORDER_DETAIL resetOrder() { String orderby = QueryDB.Desc_Time_Up; - String where = "isDelete=? and status!=0"; + String where = "isDelete=?"; String[] args = new String[]{"0"}; ArrayList obj = QueryDB.Get(BPA_ORDER_DETAIL.class, where, args, orderby); for (Object k : obj) { - if(((BPA_ORDER_DETAIL) k).status!=0){ - ((BPA_ORDER_DETAIL) k).status=0; - update((BPA_ORDER_DETAIL) k); - } + ((BPA_ORDER_DETAIL) k).status=0; + ((BPA_ORDER_DETAIL) k).deviceNum=0; + update((BPA_ORDER_DETAIL) k); } return obj.size() > 0 ? (BPA_ORDER_DETAIL) obj.get(0) : null; } @@ -151,4 +151,21 @@ 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; } + + public static List getByFilterMaking(int deviceNum) { + String orderby = QueryDB.Desc_Time_Up; + String where = "isDelete=? and status!=0 and deviceNum!=0 and deviceNum!=?"; + String[] args = new String[]{"0",deviceNum+""}; + 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); + } + } + LogUtils.d("OrderDetailUtil getByAllMaking data=" + data.toString()); + return data; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java index df024a24..38cfd61c 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java @@ -274,6 +274,15 @@ public class SubAttributeGroupDBUtil { update(bean); } } + + public static int getMakeTime(String id){ + BPA_GOODS_SUBATTRIBUTE_GROUP bean = getById(id); + if (bean != null) { + return bean.maketime; + }else { + return 0; + } + } /** * 判断子属性组合是否存在 * @param goodsId diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/CookTimeUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/CookTimeUtils.java index 670b1789..90f6b1f7 100644 --- a/app/src/main/java/com/bonait/bnframework/common/utils/CookTimeUtils.java +++ b/app/src/main/java/com/bonait/bnframework/common/utils/CookTimeUtils.java @@ -2,6 +2,8 @@ package com.bonait.bnframework.common.utils; import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.Service.AnalogConvert; +import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.business.RecordManager; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; @@ -13,6 +15,7 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; public class CookTimeUtils { @@ -109,77 +112,84 @@ public class CookTimeUtils { LogUtils.d(" measureCookTime materialType="+item.materialType+"; processvalue="+item.processvalue); if(item.materialType == 0){ String values = item.processvalue; + //仓号 值 + HashMap formulation = new HashMap<>(); + int MaxValue = 0; + //region 获取仓号和值 List data = new ArrayList<>(); if (values.contains("|")) { String[] res = values.split("[|]"); - data.addAll(Arrays.asList(res)); + for (int i = 0; i < res.length; i++) { + data.add(res[i]); + } } else { data.add(values); } - LogUtils.d(" //////////////////// "+data); - for (String value : data) { - if (value !=null && value.contains(",")) { - String[] wl = value.split("[,]"); - if (wl.length == 2) { - float val; - String name = wl[0]; - val = Float.parseFloat(wl[1]); + for (String s : data) { + if (!s.isEmpty() && s.contains(",")) { + String[] wl = s.split("[,]"); + if (wl != null && wl.length == 2) { + String name = wl[0]; + //int val = (int) Math.round((Double.parseDouble(wl[1]) * 10)); + int val = (int) Math.round((Double.parseDouble(wl[1]))); + //int val = Integer.parseInt(wl[1]); + List bpa_silos = QueryDB.GetSolisByMaterialName(name); + if (bpa_silos.size() > 0 && val > 0) { + BPA_SILOS silos = bpa_silos.get(0); + if (val >= 32767) { + val = 32767; + } + formulation.put(silos, val); - // 根据名称查询料仓号 重量需根据校准值换算成时间 - List silos = QueryDB.GetSolisByMaterialName(name); - if(!silos.isEmpty()){ - BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE) QueryDB.GetSilosCalibrateByNum( silos.get(0).num); - int valueDeal = AnalogConvert.Scale( val, bean.inputWightMax, bean.inputWightMin, - bean.outputTimeMax, bean.outputTimeMin)/100; - time += valueDeal; - LogUtils.d("measureCookTime name="+name+";重量="+val+";换算时间="+valueDeal); + Object jz_z = ExecuteTheRecipe.ReadPLC(1,"料仓" + 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)); + time +=ztime; + } } } } } }else { String value = item.processvalue; - if(value!=null && value.contains("(秒),")){ - String[] res = value.split("秒"); - if(res.length==2){ - int val = 0; - if(res[1].contains(".")){ - val = (int) Math.round((Double.parseDouble(res[1].substring(2)))); - }else { - val = Integer.parseInt(res[1].substring(2)); - } - time += val; + //工序名称和值 + HashMap formulation = new HashMap<>(); + //region 获取仓号和值 + List data = new ArrayList<>(); + if (value.contains("|")) { + String[] res = value.split("[|]"); + for (int i = 0; i < res.length; i++) { + data.add(res[i]); } - }else if(value!=null && value.contains("上升")||value.contains("下降")){ - time += 10; - }else if(value!=null && value.contains("(克),")){ - String[] res = value.split("克"); - if(res.length==2){ - float val = 0; - val = Float.parseFloat(res[1].substring(2)); - //1 - if(item.processname.contains("加水")){ - BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE) QueryDB.GetSilosCalibrateByNum(10); - int valueDeal = AnalogConvert.Scale( val, bean.inputWightMax, bean.inputWightMin, - bean.outputTimeMax, bean.outputTimeMin)/100; - LogUtils.d("measureCookTime 加水重量="+val+";换算加水时间="+valueDeal); - time += valueDeal; - }else if(item.processname.contains("勾芡")){ - BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE) QueryDB.GetSilosCalibrateByNum(11); - int valueDeal = AnalogConvert.Scale( val, bean.inputWightMax, bean.inputWightMin, - bean.outputTimeMax, bean.outputTimeMin)/100; - LogUtils.d("measureCookTime 加水重量="+val+";换算加水时间="+valueDeal); - time += valueDeal; + } else { + data.add(value); + } + for (String s : data) { + if (!s.isEmpty() && s.contains(",")) { + String[] wl = s.split("[,]"); + if (wl != null && wl.length == 2) { + String name = wl[0]; + String val = wl[1]; + formulation.put(name, val); } - - } } + for (HashMap.Entry entry : formulation.entrySet()) { + String key = entry.getKey(); + String num = entry.getValue(); + if (key.contains("(秒)")) { + time += Integer.parseInt(num); + } + } + } } LogUtils.d(" measureCookTime total=" +time); }catch (Exception e){ e.printStackTrace(); + LogUtils.d("measureCookTime 异常 "+e.getMessage()); } return time>0?time:180; } diff --git a/app/src/main/java/com/bonait/bnframework/event/MakingStepEvent.java b/app/src/main/java/com/bonait/bnframework/event/MakingStepEvent.java index e10c20f4..ac5e4abb 100644 --- a/app/src/main/java/com/bonait/bnframework/event/MakingStepEvent.java +++ b/app/src/main/java/com/bonait/bnframework/event/MakingStepEvent.java @@ -11,7 +11,7 @@ public class MakingStepEvent { */ public int process; /** - * 1号炒锅 2号炒锅 + * 1号炒锅 2号炒锅 3 4 */ public int type; public MakingStepEvent(int type,int process){ diff --git a/app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java b/app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java index 34617732..1e6ee35a 100644 --- a/app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java +++ b/app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java @@ -204,8 +204,15 @@ public class ModbusCenter { } } + private static boolean TestLog = false; public static void showLog(boolean test,String desc){ - LogUtils.d(desc); + if(test){ + if(TestLog){ + LogUtils.d(desc); + } + }else { + LogUtils.d(desc); + } } public static void Listening() { diff --git a/app/src/main/java/com/bonait/bnframework/newui/activity/LoginHActivity.java b/app/src/main/java/com/bonait/bnframework/newui/activity/LoginHActivity.java index 2c8a1fee..9086deb3 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/activity/LoginHActivity.java +++ b/app/src/main/java/com/bonait/bnframework/newui/activity/LoginHActivity.java @@ -23,7 +23,9 @@ import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.Constants; import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_ORDER_DETAIL; import com.bonait.bnframework.common.db.mode.BPA_USER; +import com.bonait.bnframework.common.db.util.OrderDetailUtil; import com.bonait.bnframework.common.utils.AppUtils; import com.bonait.bnframework.common.utils.DisplayManager; import com.bonait.bnframework.common.utils.KeyboardToolUtils; @@ -55,6 +57,10 @@ public class LoginHActivity extends BaseActivity { initEvent(); initData(); ModbusCenter.closePLC(); +// for(BPA_ORDER_DETAIL bean : OrderDetailUtil.getAll()){ +// bean.deviceNum = 0; +// OrderDetailUtil.update(bean); +// } } /** 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 0b19ebb3..5feb9638 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 @@ -374,7 +374,7 @@ public class MainHActivity extends BaseActivity { if(handler!=null){ handler.sendEmptyMessage(1); } - if(isFirst){ + if(isFirst && PreferenceUtils.getBoolean(ConfigName.rootTip,false)){ isFirst = false; RootTipDialog dialog = new RootTipDialog(); dialog.show(getSupportFragmentManager(),"开机自检"); diff --git a/app/src/main/java/com/bonait/bnframework/newui/activity/WelcomeActivity.java b/app/src/main/java/com/bonait/bnframework/newui/activity/WelcomeActivity.java index 273ac2fa..8f0ae4d3 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/activity/WelcomeActivity.java +++ b/app/src/main/java/com/bonait/bnframework/newui/activity/WelcomeActivity.java @@ -51,7 +51,7 @@ public class WelcomeActivity extends BaseActivity { // QMUI 框架初始化 QMUISwipeBackActivityManager.init(ConfigName.getInstance().app); setContentView(R.layout.activity_welcome); - ThreadManager.get().release(); +// ThreadManager.get().release(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); diff --git a/app/src/main/java/com/bonait/bnframework/newui/adapter/order/OrderInfoAdapter.java b/app/src/main/java/com/bonait/bnframework/newui/adapter/order/OrderInfoAdapter.java index c8093552..65ef480e 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/adapter/order/OrderInfoAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/newui/adapter/order/OrderInfoAdapter.java @@ -8,6 +8,7 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil; import com.bonait.bnframework.newui.adapter.base.BaseAdapter; import com.bonait.bnframework.common.db.mode.BPA_ORDER_DETAIL; import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil; @@ -41,24 +42,30 @@ public abstract class OrderInfoAdapter extends BaseAdapter0?("制作时长:"+ dealtTime(makeTime)):""); }else if(bean.status==3){ holder.binding.progressBar.setMax(1); holder.binding.progressBar.setProgress(0); + holder.binding.tvProcess.setText(""); }else if(bean.status==0){ holder.binding.progressBar.setMax(100); holder.binding.progressBar.setProgress(0); + holder.binding.tvProcess.setText(makeTime>0?("预计时长:"+ dealtTime(makeTime)):""); } }else { holder.binding.progressBar.setMax(1); holder.binding.progressBar.setProgress(0); + holder.binding.tvProcess.setText(makeTime>0?("预计时长:"+ dealtTime(makeTime)):""); } holder.binding.sort.setText((position+1)+""); holder.binding.goodsName.setText(bean.goodsName+""); @@ -112,6 +119,14 @@ public abstract class OrderInfoAdapter extends BaseAdapter ovenMap = new LinkedHashMap<>(); + private BPA_ORDER_DETAIL order; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -108,6 +110,9 @@ public class FoodInfoDialog extends DialogFragment { }); freshView(); initClick(); + viewBinding.tvTip.setOnClickListener(v->{ + NewToastUtil.getInstance().showToast("订单正在执行,无法修改位置"); + }); } private void freshView(){ @@ -123,12 +128,26 @@ public class FoodInfoDialog extends DialogFragment { viewBinding.right4.setText(""); viewBinding.right5.setText(""); viewBinding.right6.setText(""); - BPA_ORDER_DETAIL order = OrderDetailUtil.getById(orderId); + order = OrderDetailUtil.getById(orderId); if(order==null){ dismiss(); return; } + viewBinding.tvTip.setVisibility(order.status!=0?View.VISIBLE:View.GONE); List details = GoodsProcessDetailDBUtil.getByGroupId(order.groupId); + if(order.deviceNum ==1){ + details.clear(); + details.addAll(ConfigName.goodsProcess1); + }else if(order.deviceNum ==2){ + details.clear(); + details.addAll(ConfigName.goodsProcess2); + }else if(order.deviceNum ==3){ + details.clear(); + details.addAll(ConfigName.goodsProcess3); + }else if(order.deviceNum ==4){ + details.clear(); + details.addAll(ConfigName.goodsProcess4); + } for(BPA_GOODS_PROCESS_DETAIL detail:details){ if(detail.processname.equals("主料")||detail.processname.equals("调料")){ if(!detail.processvalue.isEmpty()){ @@ -373,6 +392,43 @@ public class FoodInfoDialog extends DialogFragment { detail.processvalue = detail.processvalue.replace(posInfo,"调料中盆位置,"+positionName); detail.processms = detail.processms.replace(res2[1],positionName); } + if(order.deviceNum ==1){ + if(!ConfigName.goodsProcess1.isEmpty()){ + for(BPA_GOODS_PROCESS_DETAIL bean:ConfigName.goodsProcess1){ + if(detail.id.equals(bean.id)){ + bean.processvalue = detail.processvalue; + bean.processms = detail.processms; + } + } + } + }else if(order.deviceNum ==2){ + if(!ConfigName.goodsProcess2.isEmpty()){ + for(BPA_GOODS_PROCESS_DETAIL bean:ConfigName.goodsProcess2){ + if(detail.id.equals(bean.id)){ + bean.processvalue = detail.processvalue; + bean.processms = detail.processms; + } + } + } + }else if(order.deviceNum ==3){ + if(!ConfigName.goodsProcess3.isEmpty()){ + for(BPA_GOODS_PROCESS_DETAIL bean:ConfigName.goodsProcess3){ + if(detail.id.equals(bean.id)){ + bean.processvalue = detail.processvalue; + bean.processms = detail.processms; + } + } + } + }else if(order.deviceNum ==4){ + if(!ConfigName.goodsProcess4.isEmpty()){ + for(BPA_GOODS_PROCESS_DETAIL bean:ConfigName.goodsProcess4){ + if(detail.id.equals(bean.id)){ + bean.processvalue = detail.processvalue; + bean.processms = detail.processms; + } + } + } + } if(GoodsProcessDetailDBUtil.update(detail)){ freshView(); xCom.dismissX(); 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 4bf7fe98..20261245 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 @@ -11,6 +11,7 @@ import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; +import androidx.annotation.FontRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; @@ -25,8 +26,13 @@ import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.utils.AdbCommandUtil; import com.bonait.bnframework.common.utils.DisplayManager; import com.bonait.bnframework.databinding.DialogFoodPosSetBinding; +import com.bonait.bnframework.modbus.Wok1ModbusTcpServer; +import com.bonait.bnframework.modbus.Wok2ModbusTcpServer; +import com.bonait.bnframework.modbus.Wok3ModbusTcpServer; +import com.bonait.bnframework.modbus.Wok4ModbusTcpServer; import com.bonait.bnframework.newui.fragment.setting.SceneSetFragment; import com.bonait.bnframework.newui.widget.FoodPosSetView; +import com.bonait.bnframework.newui.widget.NewToastUtil; import java.util.ArrayList; import java.util.List; @@ -106,12 +112,42 @@ public class FoodPosSetDialog extends DialogFragment { dismiss(); return; } - selectWok(order.deviceNum); + viewBinding.tvWok1.setSelected(order.deviceNum==1); + viewBinding.wokImage1.setVisibility(order.deviceNum==1?View.VISIBLE:View.GONE); + viewBinding.tvWok2.setSelected(order.deviceNum==2); + viewBinding.wokImage2.setVisibility(order.deviceNum==2?View.VISIBLE:View.GONE); + viewBinding.tvWok3.setSelected(order.deviceNum==3); + viewBinding.wokImage3.setVisibility(order.deviceNum==3?View.VISIBLE:View.GONE); + viewBinding.tvWok4.setSelected(order.deviceNum==4); + viewBinding.wokImage4.setVisibility(order.deviceNum==4?View.VISIBLE:View.GONE); + viewBinding.tvTip.setVisibility(order.deviceNum == 0?View.VISIBLE:View.GONE); data1.clear(); data2.clear(); data3.clear(); List details = GoodsProcessDetailDBUtil.getByGroupId(order.groupId); + if(order.deviceNum ==1){ + if(!ConfigName.goodsProcess1.isEmpty()){ + details.clear(); + details.addAll(ConfigName.goodsProcess1); + } + }else if(order.deviceNum ==2){ + if(!ConfigName.goodsProcess2.isEmpty()){ + details.clear(); + details.addAll(ConfigName.goodsProcess2); + } + }else if(order.deviceNum ==3){ + if(!ConfigName.goodsProcess3.isEmpty()){ + details.clear(); + details.addAll(ConfigName.goodsProcess3); + } + }else if(order.deviceNum ==4){ + if(!ConfigName.goodsProcess4.isEmpty()){ + details.clear(); + details.addAll(ConfigName.goodsProcess4); + } + } + for(BPA_GOODS_PROCESS_DETAIL detail:details){ if(detail.processname.equals("主料")){ data1.add(detail); @@ -135,9 +171,42 @@ public class FoodPosSetDialog extends DialogFragment { viewBinding.flWok4.setOnClickListener(v->{ selectWok(4); }); + viewBinding.tvTip.setOnClickListener(v->{ + NewToastUtil.getInstance().showToast("请先选择炒锅位置"); + }); } private void selectWok(int deviceNum){ + if(order.deviceNum == deviceNum){ + if(order.deviceNum ==1){ + ConfigName.goodsProcess1.clear(); + }else if(order.deviceNum ==2){ + ConfigName.goodsProcess2.clear(); + }else if(order.deviceNum ==3){ + ConfigName.goodsProcess3.clear(); + }else if(order.deviceNum ==4){ + ConfigName.goodsProcess4.clear(); + } + viewBinding.tvWok1.setSelected(false); + viewBinding.wokImage1.setVisibility(View.GONE); + viewBinding.tvWok2.setSelected(false); + viewBinding.wokImage2.setVisibility(View.GONE); + viewBinding.tvWok3.setSelected(false); + viewBinding.wokImage3.setVisibility(View.GONE); + viewBinding.tvWok4.setSelected(false); + viewBinding.wokImage4.setVisibility(View.GONE); + order.deviceNum = 0; + viewBinding.tvTip.setVisibility(order.deviceNum == 0?View.VISIBLE:View.GONE); + OrderDetailUtil.update(order); + return; + } + + for(BPA_ORDER_DETAIL bean : OrderDetailUtil.getAll()){ + if(bean.deviceNum == deviceNum){ + NewToastUtil.getInstance().showToastError(bean.deviceNum+"号炒锅已绑定菜品【"+bean.goodsName+"】"); + return; + } + } viewBinding.tvWok1.setSelected(deviceNum==1); viewBinding.wokImage1.setVisibility(deviceNum==1?View.VISIBLE:View.GONE); viewBinding.tvWok2.setSelected(deviceNum==2); @@ -148,6 +217,23 @@ public class FoodPosSetDialog extends DialogFragment { viewBinding.wokImage4.setVisibility(deviceNum==4?View.VISIBLE:View.GONE); order.deviceNum = deviceNum; OrderDetailUtil.update(order); + + ArrayList goodsrecipes = GoodsProcessDetailDBUtil.getByGroupId(order.groupId); + if(order.deviceNum ==1){ + ConfigName.goodsProcess1.clear(); + ConfigName.goodsProcess1.addAll(goodsrecipes); + }else if(order.deviceNum ==2){ + ConfigName.goodsProcess2.clear(); + ConfigName.goodsProcess2.addAll(goodsrecipes); + }else if(order.deviceNum ==3){ + ConfigName.goodsProcess3.clear(); + ConfigName.goodsProcess3.addAll(goodsrecipes); + }else if(order.deviceNum ==4){ + ConfigName.goodsProcess4.clear(); + ConfigName.goodsProcess4.addAll(goodsrecipes); + } + viewBinding.tvTip.setVisibility(order.deviceNum == 0?View.VISIBLE:View.GONE); + updateView(); } private void updateView(){ @@ -156,17 +242,18 @@ public class FoodPosSetDialog extends DialogFragment { viewBinding.llContentTz.removeAllViews(); for (BPA_GOODS_PROCESS_DETAIL bean : data1){ - FoodPosSetView view = new FoodPosSetView(viewBinding.llContentZ.getContext(), null,bean); + FoodPosSetView view = new FoodPosSetView(viewBinding.llContentZ.getContext(), null,bean,order.deviceNum); viewBinding.llContentZ.addView(view); } for (BPA_GOODS_PROCESS_DETAIL bean : data2){ - FoodPosSetView view = new FoodPosSetView(viewBinding.llContentTx.getContext(), null,bean); - viewBinding.llContentTz.addView(view); + FoodPosSetView view = new FoodPosSetView(viewBinding.llContentTz.getContext(), null,bean,order.deviceNum); + viewBinding.llContentTx.addView(view); } for (BPA_GOODS_PROCESS_DETAIL bean : data3){ - FoodPosSetView view = new FoodPosSetView(viewBinding.llContentTz.getContext(), null,bean); - viewBinding.llContentTx.addView(view); + FoodPosSetView view = new FoodPosSetView(viewBinding.llContentTx.getContext(), null,bean,order.deviceNum); + viewBinding.llContentTz.addView(view); } + } private MyClickListener listener; 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 c70e6b67..4b6e1016 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 @@ -273,6 +273,7 @@ public class WokControlDialog extends DialogFragment { @SuppressLint("ClickableViewAccessibility") private void initView(){ viewBinding.changeToRobot.setVisibility(showRobot?View.VISIBLE:View.GONE); + viewBinding.changeToRobot2.setVisibility(showRobot?View.VISIBLE:View.GONE); ArrayList silosArrayList = QueryDB.GetSilosALL(); List nameList = new ArrayList<>(); @@ -494,34 +495,34 @@ public class WokControlDialog extends DialogFragment { if(silos1.num==1){ List materials = QueryDB.GetMaterialBySilosID(silos1.id); if(!materials.isEmpty()){ - viewBinding.yeliao1.setText("液料1:"+materials.get(0).name+"\n长按出料"); + viewBinding.yeliao1.setText("液料1-"+materials.get(0).name+"\n长按出料"); } }else if(silos1.num==2){ List materials = QueryDB.GetMaterialBySilosID(silos1.id); if(!materials.isEmpty()){ - viewBinding.yeliao2.setText("液料2:"+materials.get(0).name+"\n长按出料"); + viewBinding.yeliao2.setText("液料2-"+materials.get(0).name+"\n长按出料"); } }else if(silos1.num==3){ List materials = QueryDB.GetMaterialBySilosID(silos1.id); if(!materials.isEmpty()){ - viewBinding.yeliao3.setText("液料3:"+materials.get(0).name+"\n长按出料"); + viewBinding.yeliao3.setText("液料3-"+materials.get(0).name+"\n长按出料"); } } //4是水阀 else if(silos1.num==5){ List materials = QueryDB.GetMaterialBySilosID(silos1.id); if(!materials.isEmpty()){ - viewBinding.yeliao5.setText("液料5:"+materials.get(0).name+"\n长按出料"); + viewBinding.yeliao5.setText("液料5-"+materials.get(0).name+"\n长按出料"); } }else if(silos1.num==6){ List materials = QueryDB.GetMaterialBySilosID(silos1.id); if(!materials.isEmpty()){ - viewBinding.yeliao6.setText("液料6:"+materials.get(0).name+"\n长按出料"); + viewBinding.yeliao6.setText("液料6-"+materials.get(0).name+"\n长按出料"); } }else if(silos1.num==7){ List materials = QueryDB.GetMaterialBySilosID(silos1.id); if(!materials.isEmpty()){ - viewBinding.yeliao7.setText("液料7:"+materials.get(0).name+"\n长按出料"); + viewBinding.yeliao7.setText("液料7-"+materials.get(0).name+"\n长按出料"); } } } diff --git a/app/src/main/java/com/bonait/bnframework/newui/fragment/cooking/CookingFragment.java b/app/src/main/java/com/bonait/bnframework/newui/fragment/cooking/CookingFragment.java index 89c2edb9..bc584408 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/fragment/cooking/CookingFragment.java +++ b/app/src/main/java/com/bonait/bnframework/newui/fragment/cooking/CookingFragment.java @@ -30,11 +30,15 @@ import com.bonait.bnframework.common.db.util.OrderDetailUtil; import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil; import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.databinding.DialogTipBinding; import com.bonait.bnframework.databinding.DialogWithCancelConfirmBinding; import com.bonait.bnframework.databinding.FragmentCookingBinding; import com.bonait.bnframework.event.MakingStepEvent; import com.bonait.bnframework.modbus.ModbusCenter; import com.bonait.bnframework.modbus.Wok1ModbusTcpServer; +import com.bonait.bnframework.modbus.Wok2ModbusTcpServer; +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.XComDialog; import com.bonait.bnframework.oldui.adapter.step.StepAdapter; @@ -348,7 +352,34 @@ public class CookingFragment extends BaseFragment { * 制作线程 */ private void startMakingThread(BPA_ORDER_DETAIL orderDetail){ - ExecuteTheRecipe.startMakingThread(orderDetail); + ArrayList goodsrecipes = new ArrayList<>(); + if(orderDetail.deviceNum ==1){ + goodsrecipes = ConfigName.goodsProcess1; + }else if(orderDetail.deviceNum ==2){ + goodsrecipes = ConfigName.goodsProcess2; + }else if(orderDetail.deviceNum ==3){ + goodsrecipes = ConfigName.goodsProcess3; + }else if(orderDetail.deviceNum ==4){ + goodsrecipes = ConfigName.goodsProcess4; + } + if(goodsrecipes.isEmpty()){ + NewToastUtil.getInstance().showToast("商品工序为空!"); + return; + } + AlertDialogUtils.showCancelAndConfirmDialog(getActivity(), R.layout.dialog_tip, (layoutView, xCom) -> { + DialogTipBinding binding = DialogTipBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); + binding.title.setText("确认制作"); + binding.message.setText("【"+orderDetail.goodsName+"】"+orderDetail.deviceNum+"号炒锅\n是否重新制作?"); + binding.close.setOnClickListener(view1->{ + xCom.dismissX(); + }); + binding.submit.setOnClickListener(view1 -> { + xCom.dismissX(); + ExecuteTheRecipe.startMakingThread(orderDetail); + }); + }); + } 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 f562ff37..fbba08b3 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 @@ -78,7 +78,7 @@ public class HomeDevicesFragment extends BaseFragment { viewBinding.titleType2.setSelected(true); viewBinding.wokname1.setText("点击调试\n3号炒锅"); viewBinding.wokname2.setText("点击调试\n4号炒锅"); - viewBinding.robotName.setText("点击调试\n1号机器人"); + viewBinding.robotName.setText("点击调试\n2号机器人"); }); viewBinding.btnRobot.setOnClickListener(v->{ 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 7c7a538a..5e64237c 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 @@ -14,7 +14,6 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.LifecycleObserver; import com.apkfuns.logutils.LogUtils; -import com.bonait.bnframework.Model.CheckPositionBean; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.business.RecordManager; @@ -28,20 +27,12 @@ import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.DisplayManager; import com.bonait.bnframework.common.utils.PreferenceUtils; -import com.bonait.bnframework.common.utils.ProcessValueUtil; import com.bonait.bnframework.databinding.DialogOrderBinding; import com.bonait.bnframework.databinding.DialogTipBinding; -import com.bonait.bnframework.databinding.DialogWokTipBinding; import com.bonait.bnframework.databinding.FragmentHomeOrderBinding; import com.bonait.bnframework.event.FreshOrderEvent; import com.bonait.bnframework.event.MakingStepEvent; import com.bonait.bnframework.modbus.ModbusCenter; -import com.bonait.bnframework.modbus.Robot1ModbusTcpServer; -import com.bonait.bnframework.modbus.Robot2ModbusTcpServer; -import com.bonait.bnframework.modbus.Wok1ModbusTcpServer; -import com.bonait.bnframework.modbus.Wok2ModbusTcpServer; -import com.bonait.bnframework.modbus.Wok3ModbusTcpServer; -import com.bonait.bnframework.modbus.Wok4ModbusTcpServer; import com.bonait.bnframework.newui.activity.CookingHActivity; import com.bonait.bnframework.newui.adapter.order.FoodInfoAdapter; import com.bonait.bnframework.newui.adapter.order.OrderInfoAdapter; @@ -155,6 +146,8 @@ public class HomeOrderFragment extends BaseFragment { foodInfoAdapter.setNewData(foodInfoList); viewBinding.recyclerNameList.setAdapter(foodInfoAdapter); foodInfoList.clear(); + viewBinding.btnFoodPosSet.setVisibility(View.GONE); + viewBinding.btnLocationInfo.setVisibility(View.GONE); orderAdapter1 = new OrderInfoAdapter(){ @Override protected void onItemClick(View v, int position) { @@ -176,11 +169,15 @@ public class HomeOrderFragment extends BaseFragment { return; } if(mData.get(position).status==0){ + if(mData.get(position).deviceNum==0){ + NewToastUtil.getInstance().showToast("请先设置炒锅位置"); + return; + } AlertDialogUtils.showCancelAndConfirmDialog(getActivity(), R.layout.dialog_tip, (layoutView, xCom) -> { DialogTipBinding binding = DialogTipBinding.bind(layoutView); DisplayManager.scaleViewGroup(binding.getRoot()); binding.title.setText("提示"); - binding.message.setText("是否已设置配料位置?"); + binding.message.setText("【"+mData.get(position).goodsName+"】"+mData.get(position).deviceNum+"号炒锅\n是否已设置配料位置?"); binding.close.setOnClickListener(view1->{ xCom.dismissX(); }); @@ -202,35 +199,7 @@ public class HomeOrderFragment extends BaseFragment { viewBinding.recyclerInfo.setAdapter(orderAdapter1); viewBinding.btnLocationInfo.setOnClickListener(v->{ - if(ConfigName.getInstance().isFastClick()){ - return; - } - if(foodInfoList.isEmpty()){ - return; - } - FoodInfoDialog foodInfoDialog = new FoodInfoDialog(); - Bundle bundle = new Bundle(); - bundle.putString("orderId",orderDetail.id); - foodInfoDialog.setArguments(bundle); - foodInfoDialog.setListener(new MyClickListener() { - @Override - public void clickListener(View v, Object data) { - orderDetails1.clear(); - orderDetails1.addAll(OrderDetailUtil.getAll()); - orderAdapter1.notifyDataSetChanged(); - if(orderAdapter1.getCurrentPosition()>=0){ - orderClick(orderAdapter1.getData().get(orderAdapter1.getCurrentPosition())); - } - } - - @Override - public void clickListenerNew(View v, int k, Object data) { - - } - }); - if(getActivity()!=null){ - foodInfoDialog.show(getActivity().getSupportFragmentManager(),"配料信息"); - } + lookPosition(); }); viewBinding.btnFoodPosSet.setOnClickListener(v->{ if(ConfigName.getInstance().isFastClick()){ @@ -254,6 +223,7 @@ public class HomeOrderFragment extends BaseFragment { if(orderAdapter1.getCurrentPosition()>=0){ orderClick(orderAdapter1.getData().get(orderAdapter1.getCurrentPosition())); } + lookPosition(); } @Override @@ -266,6 +236,41 @@ public class HomeOrderFragment extends BaseFragment { changeRightBtn(); } + /** + * 查看位置信息 + */ + private void lookPosition(){ + if(ConfigName.getInstance().isFastClick()){ + return; + } + if(foodInfoList.isEmpty()){ + return; + } + FoodInfoDialog foodInfoDialog = new FoodInfoDialog(); + Bundle bundle = new Bundle(); + bundle.putString("orderId",orderDetail.id); + foodInfoDialog.setArguments(bundle); + foodInfoDialog.setListener(new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + orderDetails1.clear(); + orderDetails1.addAll(OrderDetailUtil.getAll()); + orderAdapter1.notifyDataSetChanged(); + if(orderAdapter1.getCurrentPosition()>=0){ + orderClick(orderAdapter1.getData().get(orderAdapter1.getCurrentPosition())); + } + } + + @Override + public void clickListenerNew(View v, int k, Object data) { + + } + }); + if(getActivity()!=null){ + foodInfoDialog.show(getActivity().getSupportFragmentManager(),"配料信息"); + } + } + /** * 隐藏 显示右边位置按钮 */ @@ -275,7 +280,7 @@ public class HomeOrderFragment extends BaseFragment { viewBinding.btnFoodPosSet.setVisibility(View.GONE); }else { viewBinding.btnLocationInfo.setVisibility(View.VISIBLE); - viewBinding.btnFoodPosSet.setVisibility(View.VISIBLE); +// viewBinding.btnFoodPosSet.setVisibility(View.VISIBLE); } } @@ -303,7 +308,7 @@ public class HomeOrderFragment extends BaseFragment { String name = mData.get(position).goodsName +"—"+ (mData.get(position).groupName==null?"":mData.get(position).groupName); if(mData.get(position).status == 0){ if(OrderDetailUtil.getByMaking(mData.get(position).deviceNum)!=null){ - NewToastUtil.getInstance().showToast("请确认上一个订单已完成"); + NewToastUtil.getInstance().showToast("请确认"+mData.get(position).deviceNum+"号炒锅上一个订单已完成"); return; } @@ -363,7 +368,7 @@ public class HomeOrderFragment extends BaseFragment { return; } - String error = checkPosition(mData.get(position)); + String error = checkPositionReadPlc(mData.get(position)); makingOrderDialog( mData.get(position),error.isEmpty()?0:-1,name,error,position); return; } @@ -386,31 +391,30 @@ public class HomeOrderFragment extends BaseFragment { */ private void orderClick(BPA_ORDER_DETAIL bean){ orderDetail = bean; + viewBinding.btnFoodPosSet.setVisibility(orderDetail.status!=0?View.GONE:View.VISIBLE); viewBinding.orderName.setText(orderDetail.goodsName+(orderDetail.groupName==null?"":("\n"+orderDetail.groupName))); //刷新右侧配料信息 foodInfoList.clear(); List details = GoodsProcessDetailDBUtil.getByGroupId(orderDetail.groupId); - if(orderDetail.status!=0){ - if(orderDetail.deviceNum == 1){ - if(!ConfigName.goodsProcess1.isEmpty()){ - details.clear(); - details.addAll(ConfigName.goodsProcess1); - } - }else if(orderDetail.deviceNum==2){ - if(!ConfigName.goodsProcess2.isEmpty()){ - details.clear(); - details.addAll(ConfigName.goodsProcess2); - } - }else if(orderDetail.deviceNum==3){ - if(!ConfigName.goodsProcess3.isEmpty()){ - details.clear(); - details.addAll(ConfigName.goodsProcess3); - } - }else if(orderDetail.deviceNum==4){ - if(!ConfigName.goodsProcess4.isEmpty()){ - details.clear(); - details.addAll(ConfigName.goodsProcess4); - } + if(orderDetail.deviceNum == 1){ + if(!ConfigName.goodsProcess1.isEmpty()){ + details.clear(); + details.addAll(ConfigName.goodsProcess1); + } + }else if(orderDetail.deviceNum==2){ + if(!ConfigName.goodsProcess2.isEmpty()){ + details.clear(); + details.addAll(ConfigName.goodsProcess2); + } + }else if(orderDetail.deviceNum==3){ + if(!ConfigName.goodsProcess3.isEmpty()){ + details.clear(); + details.addAll(ConfigName.goodsProcess3); + } + }else if(orderDetail.deviceNum==4){ + if(!ConfigName.goodsProcess4.isEmpty()){ + details.clear(); + details.addAll(ConfigName.goodsProcess4); } } // for(BPA_GOODS_PROCESS_DETAIL detail:details){ @@ -430,6 +434,12 @@ public class HomeOrderFragment extends BaseFragment { orderAdapter1.notifyItemChanged(0); if(orderDetails1.size()>1){ orderAdapter1.notifyItemChanged(1); + if(orderDetails1.size()>2){ + orderAdapter1.notifyItemChanged(2); + } + if(orderDetails1.size()>3){ + orderAdapter1.notifyItemChanged(3); + } } } } @@ -469,11 +479,22 @@ public class HomeOrderFragment extends BaseFragment { if (ConfigName.getInstance().isFastClick()){ return; } + if(orderDetails1.get(position).deviceNum ==1){ + ConfigName.goodsProcess1.clear(); + }else if(orderDetails1.get(position).deviceNum ==2){ + ConfigName.goodsProcess2.clear(); + }else if(orderDetails1.get(position).deviceNum ==3){ + ConfigName.goodsProcess3.clear(); + }else if(orderDetails1.get(position).deviceNum ==4){ + ConfigName.goodsProcess4.clear(); + } BPA_ORDER_DETAIL orderDetail1 = OrderDetailUtil.getById(orderDetails1.get(position).id); OrderDetailUtil.deleteById(orderDetails1.get(position).id); orderDetails1.remove(position); orderAdapter1.setCurrentPosition(-1); foodInfoList.clear(); + viewBinding.btnFoodPosSet.setVisibility(View.GONE); + viewBinding.btnLocationInfo.setVisibility(View.GONE); foodInfoAdapter.notifyDataSetChanged(); orderAdapter1.notifyDataSetChanged(); NewToastUtil.getInstance().showToast("删除成功"); @@ -543,12 +564,17 @@ public class HomeOrderFragment extends BaseFragment { switch (status){ case -1: case 0: + if(checkPositionResue()){ + return; + } orderDetails1.get(position).status = 1; BPA_ORDER_DETAIL bean = orderDetails1.get(position); bean.createTime = "0"; OrderDetailUtil.update(bean); orderAdapter1.setCurrentPosition(-1); foodInfoList.clear(); + viewBinding.btnFoodPosSet.setVisibility(View.GONE); + viewBinding.btnLocationInfo.setVisibility(View.GONE); foodInfoAdapter.notifyDataSetChanged(); orderAdapter1.notifyDataSetChanged(); startMakingThread(bean); @@ -561,13 +587,26 @@ public class HomeOrderFragment extends BaseFragment { if(position == orderAdapter1.getCurrentPosition()){ orderAdapter1.setCurrentPosition(-1); foodInfoList.clear(); + viewBinding.btnFoodPosSet.setVisibility(View.GONE); + viewBinding.btnLocationInfo.setVisibility(View.GONE); foodInfoAdapter.notifyDataSetChanged(); changeRightBtn(); } + if(orderDetails1.get(position).deviceNum ==1){ + ConfigName.goodsProcess1.clear(); + }else if(orderDetails1.get(position).deviceNum ==2){ + ConfigName.goodsProcess2.clear(); + }else if(orderDetails1.get(position).deviceNum ==3){ + ConfigName.goodsProcess3.clear(); + }else if(orderDetails1.get(position).deviceNum ==4){ + ConfigName.goodsProcess4.clear(); + } OrderDetailUtil.deleteById(orderDetails1.get(position).id); orderDetails1.remove(position); orderAdapter1.setCurrentPosition(-1); foodInfoList.clear(); + viewBinding.btnFoodPosSet.setVisibility(View.GONE); + viewBinding.btnLocationInfo.setVisibility(View.GONE); foodInfoAdapter.notifyDataSetChanged(); orderAdapter1.notifyDataSetChanged(); break; @@ -580,6 +619,9 @@ public class HomeOrderFragment extends BaseFragment { } xCom.dismissX(); if(status==0){ + if(checkPositionResue()){ + return; + } orderDetails1.get(position).status = 1; BPA_ORDER_DETAIL bean = orderDetails1.get(position); bean.createTime = "0"; @@ -588,6 +630,8 @@ public class HomeOrderFragment extends BaseFragment { orderDetails1.addAll(OrderDetailUtil.getAll()); orderAdapter1.setCurrentPosition(-1); foodInfoList.clear(); + viewBinding.btnFoodPosSet.setVisibility(View.GONE); + viewBinding.btnLocationInfo.setVisibility(View.GONE); foodInfoAdapter.notifyDataSetChanged(); orderAdapter1.notifyDataSetChanged(); viewBinding.recyclerInfo.smoothScrollToPosition(0); @@ -600,11 +644,102 @@ public class HomeOrderFragment extends BaseFragment { }); } + /** + * 检查位置是否重复使用 + */ + private boolean checkPositionResue(){ + try { + List goodsrecipes = new ArrayList<>(); + List otherCooking = new ArrayList<>(); + + // 1 2共用一个货架 3 4共用一个货架 + if(orderDetail.deviceNum ==1){ + goodsrecipes = ConfigName.goodsProcess1; + if(ConfigName.IsStart[1]){ + otherCooking.addAll(ConfigName.goodsProcess2); + } + }else if(orderDetail.deviceNum ==2){ + goodsrecipes = ConfigName.goodsProcess2; + if(ConfigName.IsStart[0]){ + otherCooking.addAll(ConfigName.goodsProcess1); + } + }else if(orderDetail.deviceNum ==3){ + goodsrecipes = ConfigName.goodsProcess3; + if(ConfigName.IsStart[3]){ + otherCooking.addAll(ConfigName.goodsProcess4); + } + }else if(orderDetail.deviceNum ==4){ + goodsrecipes = ConfigName.goodsProcess4; + if(ConfigName.IsStart[2]){ + otherCooking.addAll(ConfigName.goodsProcess3); + } + } + if(goodsrecipes.isEmpty()){ + NewToastUtil.getInstance().showToast("商品工序为空!"); + return true; + } + + StringBuffer desc = new StringBuffer(); + for(BPA_GOODS_PROCESS_DETAIL detail : goodsrecipes){ + if(detail.processname.equals("主料")||detail.processname.equals("调料小盆")||detail.processname.equals("调料中盆")){ + for(BPA_GOODS_PROCESS_DETAIL detailing : otherCooking){ + if(detail.processname.equals(detailing.processname)){ + String[] position1 = detail.processvalue.split("\\|"); + String[] position2 = detailing.processvalue.split("\\|"); + if(position1[1].equals(position2[1])){ + desc.append(position2[1]).append("|"); + break; + } + } + } + } + } + if(desc.length()>0){ + desc.append("\n库位正在被其他设备使用,请更换位置重试"); + }else { + List posList = new ArrayList<>(); + for(BPA_GOODS_PROCESS_DETAIL detail : goodsrecipes){ + if(detail.processname.equals("主料")||detail.processname.equals("调料小盆")||detail.processname.equals("调料中盆")){ + String[] position1 = detail.processvalue.split("\\|"); + if(posList.contains(position1[1])){ + desc.append(position1[1]).append("|"); + }else { + posList.add(position1[1]); + } + } + } + if(desc.length()>0){ + desc.append("\n库位被重复使用,请更换位置重试"); + } + } + if(desc.length()>0){ + AlertDialogUtils.showCancelAndConfirmDialog(getActivity(), R.layout.dialog_tip, (layoutView, xCom) -> { + DialogTipBinding binding = DialogTipBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); + binding.title.setText("警告"); + binding.message.setText(desc.toString()); + binding.close.setOnClickListener(view1->{ + xCom.dismissX(); + }); + binding.submit.setOnClickListener(view1 -> { + xCom.dismissX(); + }); + }); + return true; + } + return false; + }catch (Exception e){ + NewToastUtil.getInstance().showToastError("startMakingThread 下单异常:"+e.getMessage()); + RecordManager.getInstance().addLogRecord("角色操作日志","startMakingThread 下单异常:"+e.getMessage()); + return true; + } + } + private int test = 1; /** - * 检测位置 + * 检测位置是否检测到位 */ - private String checkPosition(BPA_ORDER_DETAIL orderDetail){ + private String checkPositionReadPlc(BPA_ORDER_DETAIL orderDetail){ if(ConfigName.TEST){ return ""; } @@ -719,7 +854,6 @@ public class HomeOrderFragment extends BaseFragment { ConfigName.IsStart[orderDetail.deviceNum -1] = false; } - @Override public void onPause() { super.onPause(); @@ -782,6 +916,8 @@ public class HomeOrderFragment extends BaseFragment { orderAdapter1.setCurrentPosition(-1); orderAdapter1.notifyDataSetChanged(); foodInfoList.clear(); + viewBinding.btnFoodPosSet.setVisibility(View.GONE); + viewBinding.btnLocationInfo.setVisibility(View.GONE); changeRightBtn(); viewBinding.orderName.setText(""); foodInfoAdapter.notifyDataSetChanged(); diff --git a/app/src/main/java/com/bonait/bnframework/newui/widget/FoodPosSetView.java b/app/src/main/java/com/bonait/bnframework/newui/widget/FoodPosSetView.java index cc989129..a1d64307 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/widget/FoodPosSetView.java +++ b/app/src/main/java/com/bonait/bnframework/newui/widget/FoodPosSetView.java @@ -12,6 +12,7 @@ import android.widget.LinearLayout; import com.bonait.bnframework.R; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; +import com.bonait.bnframework.common.db.mode.BPA_ORDER_DETAIL; import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil; import com.bonait.bnframework.common.db.util.OrderDetailUtil; import com.bonait.bnframework.common.utils.AlertDialogUtils; @@ -32,15 +33,49 @@ public class FoodPosSetView extends LinearLayout { private ViewFoodPosSetBinding viewBinding; private BPA_GOODS_PROCESS_DETAIL detail; + private int deviceNum = 0; - public FoodPosSetView(Context context, AttributeSet attrs, BPA_GOODS_PROCESS_DETAIL detail) { + public FoodPosSetView(Context context, AttributeSet attrs, BPA_GOODS_PROCESS_DETAIL detail,int deviceNum) { super(context, attrs); View root= LayoutInflater.from(context).inflate(R.layout.view_food_pos_set, this); viewBinding = ViewFoodPosSetBinding.bind(root); DisplayManager.scaleViewGroup(viewBinding.getRoot()); this.detail = detail; + this.deviceNum = deviceNum; init(); } + + private void updateData(BPA_GOODS_PROCESS_DETAIL detail){ + if(deviceNum ==1){ + for(BPA_GOODS_PROCESS_DETAIL bean:ConfigName.goodsProcess1){ + if(detail.id.equals(bean.id)){ + bean.processvalue = detail.processvalue; + bean.processms = detail.processms; + } + } + }else if(deviceNum ==2){ + for(BPA_GOODS_PROCESS_DETAIL bean:ConfigName.goodsProcess2){ + if(detail.id.equals(bean.id)){ + bean.processvalue = detail.processvalue; + bean.processms = detail.processms; + } + } + }else if(deviceNum ==3){ + for(BPA_GOODS_PROCESS_DETAIL bean:ConfigName.goodsProcess3){ + if(detail.id.equals(bean.id)){ + bean.processvalue = detail.processvalue; + bean.processms = detail.processms; + } + } + }else if(deviceNum ==4){ + for(BPA_GOODS_PROCESS_DETAIL bean:ConfigName.goodsProcess4){ + if(detail.id.equals(bean.id)){ + bean.processvalue = detail.processvalue; + bean.processms = detail.processms; + } + } + } + } private void init(){ if(detail!=null){ @@ -71,6 +106,7 @@ public class FoodPosSetView extends LinearLayout { detail.processvalue = detail.processvalue.replace(posInfo,"主料位置,"+viewBinding.spinner.getSelectedItem().toString()); detail.processms = detail.processms.replace(res2[1],viewBinding.spinner.getSelectedItem().toString()); GoodsProcessDetailDBUtil.update(detail); + updateData(detail); } @Override public void onNothingSelected(AdapterView adapterView) { @@ -110,6 +146,7 @@ public class FoodPosSetView extends LinearLayout { detail.processvalue = detail.processvalue.replace(posInfo,"调料小盆位置,"+viewBinding.spinner.getSelectedItem().toString()); detail.processms = detail.processms.replace(res2[1],viewBinding.spinner.getSelectedItem().toString()); GoodsProcessDetailDBUtil.update(detail); + updateData(detail); } @Override public void onNothingSelected(AdapterView adapterView) { @@ -148,6 +185,7 @@ public class FoodPosSetView extends LinearLayout { detail.processvalue = detail.processvalue.replace(posInfo,"调料中盆位置,"+viewBinding.spinner.getSelectedItem().toString()); detail.processms = detail.processms.replace(res2[1],viewBinding.spinner.getSelectedItem().toString()); GoodsProcessDetailDBUtil.update(detail); + updateData(detail); } @Override public void onNothingSelected(AdapterView adapterView) { diff --git a/app/src/main/res/layout/item/layout/item_step_desc.xml b/app/src/main/res/layout/item/layout/item_step_desc.xml index 26cc571d..ebf86d9a 100644 --- a/app/src/main/res/layout/item/layout/item_step_desc.xml +++ b/app/src/main/res/layout/item/layout/item_step_desc.xml @@ -15,7 +15,7 @@ android:paddingTop="3dp" android:paddingBottom="3dp" app:layout_constraintLeft_toLeftOf="parent" - android:maxLines="3" + android:maxLines="2" android:ellipsize="end" app:layout_constraintTop_toTopOf="parent" android:textColor="@drawable/selector_select_step_text_color" diff --git a/app/src/main/res/layout/new/layout/dialog_food_info.xml b/app/src/main/res/layout/new/layout/dialog_food_info.xml index 5a806bd3..779992cb 100644 --- a/app/src/main/res/layout/new/layout/dialog_food_info.xml +++ b/app/src/main/res/layout/new/layout/dialog_food_info.xml @@ -269,7 +269,7 @@ android:layout_height="@dimen/dp_80" android:background="@drawable/bg_round25_top_yellow" style="@style/TextView_btn_dialog" - android:text="货架料盒位置详情" + android:text="配料位置实图-检查是否正确" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" /> @@ -285,6 +285,20 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/new/layout/dialog_food_pos_set.xml b/app/src/main/res/layout/new/layout/dialog_food_pos_set.xml index a440a0ed..214d71ab 100644 --- a/app/src/main/res/layout/new/layout/dialog_food_pos_set.xml +++ b/app/src/main/res/layout/new/layout/dialog_food_pos_set.xml @@ -43,7 +43,6 @@ android:layout_below="@id/tip" android:orientation="vertical" android:layout_marginTop="30dp" - android:background="@drawable/bg_round25_white" android:layout_marginStart="20dp" android:layout_marginBottom="20dp" android:layout_height="match_parent"> @@ -89,6 +88,7 @@ android:src="@drawable/ic_true" android:visibility="gone" tools:visibility="visible" + android:layout_marginBottom="5dp" /> @@ -148,6 +149,7 @@ android:layout_marginEnd="30dp" android:layout_gravity="center_vertical|end" android:src="@drawable/ic_true" + android:layout_marginBottom="5dp" android:visibility="gone" /> @@ -178,6 +180,7 @@ android:layout_marginEnd="30dp" android:layout_gravity="center_vertical|end" android:src="@drawable/ic_true" + android:layout_marginBottom="5dp" android:visibility="gone" /> @@ -210,7 +213,6 @@ android:textSize="32sp" android:textStyle="bold" android:text="调料小盆位置" - android:text="主料位置" android:gravity="center" android:layout_height="wrap_content"/> @@ -241,7 +242,7 @@ android:id="@+id/ll_content_z" android:layout_width="420dp" android:orientation="vertical" - android:layout_marginTop="50dp" + android:layout_marginTop="20dp" android:layout_marginBottom="20dp" android:layout_height="wrap_content"> @@ -249,36 +250,40 @@ @@ -286,17 +291,24 @@ - - - - - - + android:visibility="gone" + tools:visibility="visible" + android:textStyle="bold" + android:textSize="42sp" + android:textColor="@color/white" + android:text="←请先选择左侧炒锅位置" + android:gravity="center" + android:layout_height="match_parent"/> @@ -48,7 +48,7 @@ android:layout_width="@dimen/dp_80" android:layout_height="50dp" android:layout_alignParentEnd="true" - android:layout_marginTop="30dp" + android:layout_marginTop="15dp" android:layout_below="@id/start_goodmake" android:layout_marginEnd="5dp" android:src="@mipmap/zhizuo_zt" @@ -67,8 +67,8 @@ android:orientation="vertical" android:paddingStart="15dp" android:paddingEnd="15dp" - android:paddingTop="15dp" - android:paddingBottom="15dp" + android:paddingTop="10dp" + android:paddingBottom="10dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/new/layout/item_order_info.xml b/app/src/main/res/layout/new/layout/item_order_info.xml index ac10c63e..0442cec1 100644 --- a/app/src/main/res/layout/new/layout/item_order_info.xml +++ b/app/src/main/res/layout/new/layout/item_order_info.xml @@ -99,9 +99,22 @@ android:layout_gravity="bottom" android:paddingStart="5dp" android:textSize="28sp" - tools:text="1号炒锅——Z1库位" + tools:text="1号炒锅" android:textColor="@color/black" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/new/layout/view_food_pos_set.xml b/app/src/main/res/layout/new/layout/view_food_pos_set.xml index 9f052072..e5da19a8 100644 --- a/app/src/main/res/layout/new/layout/view_food_pos_set.xml +++ b/app/src/main/res/layout/new/layout/view_food_pos_set.xml @@ -3,11 +3,13 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="420dp" - android:layout_height="@dimen/dp_130" + android:layout_height="@dimen/dp_110" android:id="@+id/root" android:orientation="horizontal" - android:paddingTop="20dp" - android:paddingBottom="20dp" + android:paddingTop="10dp" + android:paddingBottom="10dp" + android:paddingStart="10dp" + android:paddingEnd="10dp" >