From 67062b8c100ff80ecaac2bc3d8546cff0413cfee Mon Sep 17 00:00:00 2001 From: wangh <123456> Date: Tue, 23 Apr 2024 14:35:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=95=B4=E5=8C=85?= =?UTF-8?q?=E7=A7=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../java/com/example/pulit/X1Activity.java | 75 ++++++++++++------- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 62205b0..15a0d66 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { applicationId "com.example.pulit" minSdkVersion 26 targetSdkVersion 30 - versionCode 14 + versionCode 15 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/example/pulit/X1Activity.java b/app/src/main/java/com/example/pulit/X1Activity.java index 00f12b6..a7e33fd 100644 --- a/app/src/main/java/com/example/pulit/X1Activity.java +++ b/app/src/main/java/com/example/pulit/X1Activity.java @@ -60,16 +60,13 @@ public class X1Activity extends BaseActivity { Button x1Submit; @BindView(R.id.x1_submit2) Button x1Submit2; - - private boolean scanStates; private List items; private ItemAdapter adapter; - private ListPopupWindow lpw; private List planList; - private String planId; + private String zbCode = null;//整包流水号 // 提交字段 private X1Submit entrySubmit; @@ -89,7 +86,6 @@ public class X1Activity extends BaseActivity { lpw.setOnItemClickListener((adapterView, view, i, l) -> { planId = planList.get(i); selectPlanByID(x1Code.getText().toString(), planId); - submintChildList = new ArrayList<>(); lpw.dismiss(); }); @@ -106,17 +102,30 @@ public class X1Activity extends BaseActivity { } else { x1Tong.setText(info); if (info.contains("kg")) { - //整包 截取 物料编码 000524-20230805-0001-CF-130|25kg - String goodsCode = info.substring(0, info.indexOf("-")); - //格式化重量 - String stringFormatWeight = decimalFormat.format( - Double.parseDouble(info.substring(info.indexOf("|") + 1, info.indexOf("kg")))); - double goodsWeight = Double.parseDouble(stringFormatWeight); - String name1=info.substring( info.indexOf("-")+1,info.indexOf("|"));//20230805-0001-CF-130 - String name2=name1.substring( name1.indexOf("-")+1,name1.length()); - String name3=name2.substring( name2.indexOf("-")+1,name2.length()); - Log.e("TAG", "," + name1+"," + name2+"," + name3); - checkItem(goodsCode, goodsWeight, "整包", "", name3); + try { + //整包 截取 物料编码 000524-20230805-0001-CF-130|25kg + String goodsCode = info.substring(0, info.indexOf("-")); + //格式化重量 + String stringFormatWeight = decimalFormat.format( + Double.parseDouble(info.substring(info.indexOf("|") + 1, info.indexOf("kg")))); + double goodsWeight = Double.parseDouble(stringFormatWeight); + String name1 = info.substring(info.indexOf("-") + 1, info.indexOf("|"));//20230805-0001-CF-130 + String name2 = name1.substring(name1.indexOf("-") + 1, name1.length()); + String name3 = name2.substring(name2.indexOf("-") + 1, name2.length()); + String lxh = name2.substring(0, name2.indexOf("-")); + Log.e("TAG", "流水号:" + lxh); + Log.e("TAG", "物料名称:" + name3); + if (zbCode == null) { + checkItem(goodsCode, goodsWeight, "整包", "", name3, lxh); + } else { + Toast.makeText(this, "物料已确认", Toast.LENGTH_SHORT).show(); + } + + } catch (Exception e) { + e.printStackTrace(); + Toast.makeText(this, "整包条码错误", Toast.LENGTH_SHORT).show(); + } + } else { //散装、查询接口 selectGoods(info); @@ -190,7 +199,6 @@ public class X1Activity extends BaseActivity { dialog.dismiss(); } }); - } //查询 釜 @@ -274,21 +282,21 @@ public class X1Activity extends BaseActivity { List list = JSONArray.parseArray(jsonObject.get("child").toString(), MaterialView.class); - String tipTag=""; + String tipTag = ""; for (MaterialView materialView : list) { if (materialView.getMatchOrNot() == 0) { - tipTag+=materialView.getMaterialName()+"("+materialView.getMaterialBarCode()+")"; + tipTag += materialView.getMaterialName() + "(" + materialView.getMaterialBarCode() + ")"; } } if (!tipTag.equals("")) { - tipDialog.showMsg(false, tipTag+ " 不合格"); + tipDialog.showMsg(false, tipTag + " 不合格"); return; } for (MaterialView materialView : list) { double goodsWeight = materialView.getWeight(); String goodsCode = materialView.getMaterialBarCode(); - checkItem(goodsCode, goodsWeight, "散装", info, materialView.getMaterialName()); + checkItem(goodsCode, goodsWeight, "散装", info, materialView.getMaterialName(), null); } } else { @@ -306,19 +314,27 @@ public class X1Activity extends BaseActivity { }); } - //比对 - private void checkItem(String goodsCode, double goodsWeight, String matType, String info, String t) { + /** + * 比对 + * + * @param goodsCode 扫描码 + * @param goodsWeight 重量 + * @param matType 整包、散装 + * @param info 散装码 + * @param t 物料名称 + * @param zbCode 整包流水号 + */ + private void checkItem(String goodsCode, double goodsWeight, String matType, String info, String t, String zbCode) { x1GoodsCode.setText(goodsCode); x1GoodsWeight.setText(goodsWeight + ""); X1SubmintChild entrySubmitcChild = new X1SubmintChild(); - int index = -1;//目标 - A: for (int i = 0; i < items.size(); i++) { + A:for (int i = 0; i < items.size(); i++) { Item indexItem = items.get(i); if (!indexItem.isState() && indexItem.getMaterial_Code().equals(goodsCode)) { - double selectWeight = indexItem.getSetWeight(); - double errorWeight = indexItem.getSetError(); - Log.e("TAG", "checkItem:" + selectWeight+","+errorWeight); + double selectWeight = indexItem.getSetWeight();//列表中的重量 + double errorWeight = indexItem.getSetError();//误差 整包后台应该传0 + Log.e("TAG", "checkItem:" + selectWeight + "," + errorWeight); if (selectWeight - errorWeight <= goodsWeight && selectWeight + errorWeight >= goodsWeight) { index = i; break A; @@ -339,6 +355,9 @@ public class X1Activity extends BaseActivity { tipDialog.showState(true); selectItem.setState(true); adapter.notifyDataSetChanged(); + if (matType.equals("整包")) { + this.zbCode = zbCode; + } } else { tipDialog.showState(false); }