修改 整包称量

master
wangh 7 months ago
parent b4523a6ad5
commit 67062b8c10

@ -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"

@ -60,16 +60,13 @@ public class X1Activity extends BaseActivity {
Button x1Submit;
@BindView(R.id.x1_submit2)
Button x1Submit2;
private boolean scanStates;
private List<Item> items;
private ItemAdapter adapter;
private ListPopupWindow lpw;
private List<String> 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")) {
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());
Log.e("TAG", "" + name1+"" + name2+"" + name3);
checkItem(goodsCode, goodsWeight, "整包", "", name3);
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<MaterialView> 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);
}

Loading…
Cancel
Save