From 28104345fcbeb7ac53695af31145071d3973ef98 Mon Sep 17 00:00:00 2001 From: fyf Date: Wed, 17 Jan 2024 17:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=87=BA=E6=96=99=E7=B2=BE?= =?UTF-8?q?=E5=BA=A6=E9=97=AE=E9=A2=98=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnframework/business/ExecuteTest.java | 2 +- .../business/ExecuteTheRecipe.java | 14 +++++++-- .../common/helper/RangeInputFilter.java | 31 +++++++++++++++++++ .../home/fragment/mode/add_silos_message.java | 13 +++++--- .../home/fragment/mode/fragment_silos_cl.java | 3 +- .../item/layout/dialog_silos_message.xml | 2 +- .../item/layout/fragment_item_silos_cl.xml | 2 +- 7 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/common/helper/RangeInputFilter.java diff --git a/app/src/main/java/com/bonait/bnframework/business/ExecuteTest.java b/app/src/main/java/com/bonait/bnframework/business/ExecuteTest.java index 6a0126df..9bb1c8fd 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTest.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTest.java @@ -127,7 +127,7 @@ public class ExecuteTest { public static void Write_PLC_Material(int silos, int val) { try { if(IsForcedEnd){ return;} - ToastUtils.info("准备写入PLC仓号需求:" + silos + "," + val / 10.0); + ToastUtils.info("准备写入PLC仓号需求:" + silos + "," + val ); String name = "料仓" + silos + "下料完成"; ExecuteTheRecipe.WritePLC(name, false, null); 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 de3b3880..f1c6f7d2 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -211,11 +211,17 @@ public class ExecuteTheRecipe { String[] wl = item.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]) * 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; + ThreadWhile("料仓" + silos.num + "出量克数溢出,已按照最大出量出料!!!"); + } formulation.put(silos, val); } } @@ -337,7 +343,8 @@ public class ExecuteTheRecipe { if (ExecuteCurrentOperation != null) { ExecuteCurrentOperation.Run("液体料|" + silos.num); } - ExecuteTheRecipe.showlog("准备写入PLC仓号需求:" + silos.num + "," + val / 10.0); + //ExecuteTheRecipe.showlog("准备写入PLC仓号需求:" + silos.num + "," + val / 10.0); + ExecuteTheRecipe.showlog("准备写入PLC仓号需求:" + silos.num + "," + val); String name = "料仓" + silos.num + "下料完成"; ExecuteTheRecipe.WritePLC(name, false, null); @@ -754,7 +761,8 @@ public class ExecuteTheRecipe { val = Integer.parseInt(value); } else if (key.contains("出料克数")) { //1000.0 10000/3 3333 - cl_value = (int) Math.round((Double.parseDouble(value) * 10)); + //cl_value = (int) Math.round((Double.parseDouble(value) * 10)); + cl_value = (int) Math.round((Double.parseDouble(value))); } } diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/RangeInputFilter.java b/app/src/main/java/com/bonait/bnframework/common/helper/RangeInputFilter.java new file mode 100644 index 00000000..5c6dd506 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/helper/RangeInputFilter.java @@ -0,0 +1,31 @@ +package com.bonait.bnframework.common.helper; + +import android.text.InputFilter; +import android.text.Spanned; + +public class RangeInputFilter implements InputFilter { + private int min; + private int max; + + public RangeInputFilter(int min, int max) { + this.min = min; + this.max = max; + } + + @Override + public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { + try { + int input = Integer.parseInt(dest.toString() + source.toString()); + if (isInRange(input)) { + return null; + } + } catch (NumberFormatException e) { + return null; + } + return ""; + } + + private boolean isInRange(int value) { + return value >= min && value <= max; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_message.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_message.java index ea5bf2df..2c4a3f54 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_message.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_message.java @@ -174,12 +174,13 @@ public class add_silos_message extends LinearLayout { } int jzzl_1 = 0; try { - jzzl_1 = (int) Math.round((Double.parseDouble(jzzl) * 10)); + //jzzl_1 = (int) Math.round((Double.parseDouble(jzzl) * 10)); + jzzl_1 = (int) Math.round((Double.parseDouble(jzzl)));// ()int) Math.round((Double.parseDouble(jzzl))); } catch (Exception e) { ToastUtils.error("校准重量!" + e.getMessage()); return; } - ExecuteTheRecipe.WritePLC("料仓"+mode.num+"校准值",(short)jzzl_1,null); + ExecuteTheRecipe.WritePLC("料仓"+mode.num+"校准值",jzzl_1,null); ToastUtils.warning("调料标定成功!"); break; case R.id.save_ghtl: @@ -316,16 +317,18 @@ public class add_silos_message extends LinearLayout { @Override public void run() { - String jzz="0.0"; + String jzz="0"; Object obj1= ExecuteTheRecipe.ReadPLC("料仓"+mode.num+"校准值"); if(obj1!=null) { String s = String.valueOf(obj1); - jzz = String.format("%.1f", (Double.parseDouble(s) / 10)); + //jzz = String.format("%.1f", (Double.parseDouble(s) / 10)); + jzz = s;//String.format("%.1f", (Double.parseDouble(s))); }else { String s = String.valueOf(0); - jzz = String.format("%.1f", (Double.parseDouble(s) / 10)); + jzz = "0";//String.format("%.1f", (Double.parseDouble(s))); + //jzz = String.format("%.1f", (Double.parseDouble(s) / 10)); } String finalJzz = jzz; activity.runOnUiThread(new Runnable() { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_silos_cl.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_silos_cl.java index b15a2eda..60e09a10 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_silos_cl.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_silos_cl.java @@ -56,7 +56,8 @@ public class fragment_silos_cl extends LinearLayout { return; } - int val1 = (int)Math.round((Double.parseDouble(text) * 10)); + //int val1 = (int)Math.round((Double.parseDouble(text) * 10)); + int val1 = (int)Math.round((Double.parseDouble(text))); //Short val=(short)val1; ExecuteTheRecipe.WritePLC("料仓" + model.num + "需求值", val1, new IWriteCallBack() { diff --git a/app/src/main/res/layout/item/layout/dialog_silos_message.xml b/app/src/main/res/layout/item/layout/dialog_silos_message.xml index b8f5c968..a1d3b8c6 100644 --- a/app/src/main/res/layout/item/layout/dialog_silos_message.xml +++ b/app/src/main/res/layout/item/layout/dialog_silos_message.xml @@ -157,7 +157,7 @@ android:layout_marginTop="80dp" android:layout_marginRight="140dp" android:background="@drawable/input_bj" - android:digits="0123456789." + android:digits="0123456789" android:hint="请输入制作时长" android:inputType="text" android:maxLines="1" diff --git a/app/src/main/res/layout/item/layout/fragment_item_silos_cl.xml b/app/src/main/res/layout/item/layout/fragment_item_silos_cl.xml index 632bca00..b7bfe48a 100644 --- a/app/src/main/res/layout/item/layout/fragment_item_silos_cl.xml +++ b/app/src/main/res/layout/item/layout/fragment_item_silos_cl.xml @@ -28,7 +28,7 @@ android:background="@drawable/input_bj" android:hint="请写入需求值" android:layout_weight="1" - android:inputType="number|numberDecimal" + android:inputType="number" android:maxLines="1" android:padding="3dp" android:textSize="12dp"