diff --git a/app/build.gradle b/app/build.gradle
index bc54a42..88f43bc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -10,7 +10,7 @@ android {
applicationId "com.example.pulit"
minSdkVersion 26
targetSdkVersion 30
- versionCode 1
+ versionCode 2
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
diff --git a/app/release/app-release.apk b/app/release/app-release.apk
deleted file mode 100644
index 327bc0b..0000000
Binary files a/app/release/app-release.apk and /dev/null differ
diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json
index 5d63416..f74633f 100644
--- a/app/release/output-metadata.json
+++ b/app/release/output-metadata.json
@@ -10,7 +10,7 @@
{
"type": "SINGLE",
"filters": [],
- "versionCode": 1,
+ "versionCode": 2,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 072f98c..076c104 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -15,7 +15,8 @@
android:supportsRtl="true"
android:theme="@style/Theme.PuLiT"
android:usesCleartextTraffic="true">
-
+
+
diff --git a/app/src/main/java/com/example/pulit/BaseActivity.java b/app/src/main/java/com/example/pulit/BaseActivity.java
index 1840e6f..ee46190 100644
--- a/app/src/main/java/com/example/pulit/BaseActivity.java
+++ b/app/src/main/java/com/example/pulit/BaseActivity.java
@@ -21,7 +21,7 @@ public abstract class BaseActivity extends AppCompatActivity {
private ScanBroadcastReceiver scanBroadcastReceiver;
public RequestQueue mQueue;
public MyDialog dialog;
- public DecimalFormat decimalFormat = new DecimalFormat("#.000");
+ public DecimalFormat decimalFormat = new DecimalFormat("0.000");
public TipDialog tipDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/app/src/main/java/com/example/pulit/MainActivity.java b/app/src/main/java/com/example/pulit/MainActivity.java
index 18831b9..ecc6c32 100644
--- a/app/src/main/java/com/example/pulit/MainActivity.java
+++ b/app/src/main/java/com/example/pulit/MainActivity.java
@@ -47,11 +47,9 @@ public class MainActivity extends AppCompatActivity {
break;
case R.id.home_rj_c:
intent = new Intent(this, SolventActivity.class);
- intent.putExtra("type", true);
break;
case R.id.home_rj_t:
- intent = new Intent(this, SolventActivity.class);
- intent.putExtra("type", false);
+ intent = new Intent(this, So2Activity.class);
break;
case R.id.home_setting:
textDialog.setIpAddress(SharedPreferencesUtils.getstring("ip", null));
diff --git a/app/src/main/java/com/example/pulit/So2Activity.java b/app/src/main/java/com/example/pulit/So2Activity.java
new file mode 100644
index 0000000..409a331
--- /dev/null
+++ b/app/src/main/java/com/example/pulit/So2Activity.java
@@ -0,0 +1,114 @@
+package com.example.pulit;
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.example.pulit.entity.PlanView;
+import com.example.pulit.util.MyOkGoCallback;
+import com.example.pulit.util.Resust;
+import com.example.pulit.util.SharedPreferencesUtils;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import okhttp3.MediaType;
+import okhttp3.RequestBody;
+
+public class So2Activity extends BaseActivity {
+
+ @BindView(R.id.solvent2_code)
+ TextView solvent2Code;
+ @BindView(R.id.solvent2_goods_code)
+ TextView solvent2GoodsCode;
+ private boolean sanType;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_so2);
+ ButterKnife.bind(this);
+ sanType = true;
+ }
+
+ private String Plan_Id;
+ private String PumpBarCode;
+
+ @Override
+ public void scanInfo(String info) {
+ if (sanType) {
+ solvent2Code.setText(info);
+ OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/GetByPumpInfo")
+ .params("code", info)
+ .execute(new MyOkGoCallback() {
+ @Override
+ public void onSuccess(Response response) {
+ super.onSuccess(response);
+ dialog.dismiss();
+ if (response.body().isSuccess()) {
+ JSONObject dateObj = response.body().getDateObj();
+ Plan_Id = dateObj.getString("Plan_Id");
+ PumpBarCode = dateObj.getString("PumpBarCode");
+ Toast.makeText(So2Activity.this, "查询成功", Toast.LENGTH_SHORT).show();
+ sanType = false;
+ } else {
+ Toast.makeText(So2Activity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ @Override
+ public void onError(Response response) {
+ super.onError(response);
+ dialog.dismiss();
+ Toast.makeText(So2Activity.this, "网络请求失败", Toast.LENGTH_SHORT).show();
+ }
+ });
+ } else {
+ solvent2GoodsCode.setText(info);
+ }
+ }
+
+ @OnClick({R.id.info_title_back, R.id.solvent2_scan, R.id.solvent2_submit})
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.info_title_back:
+ finish();
+ break;
+ case R.id.solvent2_scan:
+ sanCode();
+ break;
+ case R.id.solvent2_submit:
+ if (Plan_Id == null || Plan_Id.isEmpty()) return;
+ dialog.show();
+ OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/ExecState")
+ .params("planId",Plan_Id)
+ .params("pumpCode",PumpBarCode)
+ .params("cylinderCode",solvent2GoodsCode.getText().toString())
+ .execute(new MyOkGoCallback() {
+ @Override
+ public void onSuccess(Response response) {
+ super.onSuccess(response);
+ dialog.dismiss();
+ Toast.makeText(So2Activity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show();
+ if (response.body().isSuccess()) {
+ finish();
+ }
+ }
+
+ @Override
+ public void onError(Response response) {
+ super.onError(response);
+ dialog.dismiss();
+ Toast.makeText(So2Activity.this, "网络请求失败", Toast.LENGTH_SHORT).show();
+ }
+ });
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/pulit/SolventActivity.java b/app/src/main/java/com/example/pulit/SolventActivity.java
index c8e811b..f9fe1fa 100644
--- a/app/src/main/java/com/example/pulit/SolventActivity.java
+++ b/app/src/main/java/com/example/pulit/SolventActivity.java
@@ -3,7 +3,7 @@ package com.example.pulit;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
-import android.widget.Button;
+import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -23,27 +23,14 @@ import okhttp3.RequestBody;
public class SolventActivity extends BaseActivity {
- @BindView(R.id.solvent_title)
- TextView solventTitle;
- @BindView(R.id.solvent_frist_name)
- TextView solventFristName;
@BindView(R.id.solvent_code)
TextView solventCode;
- @BindView(R.id.solvent_title_name)
- TextView solventTitleName;
@BindView(R.id.solvent_goods_code)
TextView solventGoodsCode;
@BindView(R.id.solvent_goodsName)
TextView solventGoodsName;
- @BindView(R.id.solvent_goods)
- TextView solventGoods;
- @BindView(R.id.solvent_wc)
- TextView solventWc;
-
-// @BindView(R.id.solvent_submit)
-// Button solventSubmit;
-
- private boolean type;
+ @BindView(R.id.s2gion)
+ LinearLayout s2gion;
private boolean sanType;
@Override
@@ -52,15 +39,6 @@ public class SolventActivity extends BaseActivity {
setContentView(R.layout.activity_solvent);
ButterKnife.bind(this);
sanType = true;
- type = getIntent().getBooleanExtra("type", true);
- if (type) {
- solventTitle.setText("液体称量");
- solventFristName.setText("扫描拉缸条码");
- } else {
- solventTitle.setText("溶剂投料");
- solventFristName.setText("扫描泵位条码");
- solventTitleName.setText("扫描容器条码");
- }
}
private PlanView planView;
@@ -97,7 +75,7 @@ public class SolventActivity extends BaseActivity {
dialog.show();
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;"),
JSONObject.toJSONString(planView));
- OkGo.post("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/ExecPlcState")
+ OkGo.post("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/ExecPlcState")
.upRequestBody(requestBody)
.execute(new MyOkGoCallback() {
@Override
@@ -109,7 +87,6 @@ public class SolventActivity extends BaseActivity {
finish();
}
}
-
@Override
public void onError(Response response) {
super.onError(response);
@@ -122,8 +99,7 @@ public class SolventActivity extends BaseActivity {
}
private void selectSup(String info) {
- String uri = type ? "/api/Solvent/GetByCylinderCode" : "/api/Solvent/GetByPumpCode";
- OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + uri)
+ OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/GetByCylinderInfo")
.params("code", info)
.execute(new MyOkGoCallback() {
@Override
@@ -132,9 +108,7 @@ public class SolventActivity extends BaseActivity {
dialog.dismiss();
if (response.body().isSuccess()) {
planView = JSONObject.parseObject(response.body().getData(), PlanView.class);
-// Log.e("TAG", "onSuccess:" + planView.toString());
- solventWc.setText(planView.getSet_Error()+"");
- Toast.makeText(SolventActivity.this, "扫描成功", Toast.LENGTH_SHORT).show();
+ Toast.makeText(SolventActivity.this, "查询成功", Toast.LENGTH_SHORT).show();
sanType = false;
} else {
Toast.makeText(SolventActivity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show();
@@ -145,57 +119,37 @@ public class SolventActivity extends BaseActivity {
public void onError(Response response) {
super.onError(response);
dialog.dismiss();
+ Toast.makeText(SolventActivity.this, "网络请求失败", Toast.LENGTH_SHORT).show();
}
});
}
private void checkGoods(String scanInfo) {
- {
- solventGoodsCode.setText(scanInfo);
- //物料编码
- String goodsCode = scanInfo.substring(0, scanInfo.indexOf("-"));
- Log.e("TAG", "scanInfo:" + goodsCode);
- planView.setCode(goodsCode);
- //品名
- int index = scanInfo.indexOf("-", scanInfo.indexOf("-", scanInfo.indexOf("-") + 1) + 1) + 1;
- int endIndex = scanInfo.indexOf("|");
- String goodsName = scanInfo.substring(index, endIndex);
- Log.e("TAG", "scanInfo:" + goodsName);
- planView.setMaterialName(goodsName);
- solventGoodsName.setText(goodsName);
- //重量
- String format = decimalFormat.format(
- Double.parseDouble(
- scanInfo.substring(scanInfo.indexOf("|") + 1, scanInfo.indexOf("kg"))
- ));
- solventGoods.setText(format);
- double weight = Double.parseDouble(format);
-
- planView.setMaterialWeight(weight);
- planView.setWholeMaterial(scanInfo);
- double set_weight = planView.getSet_Weight();
- double set_error = planView.getSet_Error();
- if (type) {
- //称量只验证重量
-
-// double set_weight = planView.getSet_Weight();
-// double set_error = planView.getSet_Error();
- if (set_weight+set_error >= weight && set_weight-set_error <= weight) {
- planView.setState(1);
- tipDialog.showState(true);
- } else {
- planView.setState(0);
- tipDialog.showState(false);
- }
- } else {
- if (planView.getMaterial_code() .equals(goodsCode) && set_weight+set_error >= weight && set_weight-set_error <= weight) {
- planView.setState(1);
- tipDialog.showState(true);
- } else {
- planView.setState(0);
- tipDialog.showState(false);
- }
- }
+ solventGoodsCode.setText(scanInfo);
+ //物料编码
+ String goodsCode = scanInfo.substring(0, scanInfo.indexOf("-"));
+ Log.e("TAG", "scanInfo:" + goodsCode);
+ planView.setCode(goodsCode);
+ //品名
+ int index = scanInfo.indexOf("-", scanInfo.indexOf("-", scanInfo.indexOf("-") + 1) + 1) + 1;
+ int endIndex = scanInfo.indexOf("|");
+ String goodsName = scanInfo.substring(index, endIndex);
+ Log.e("TAG", "scanInfo:" + goodsName);
+ planView.setMaterialName(goodsName);
+ solventGoodsName.setText(goodsName);
+ //重量
+ String format = decimalFormat.format(
+ Double.parseDouble(scanInfo.substring(scanInfo.indexOf("|") + 1, scanInfo.indexOf("kg"))));
+ double weight = Double.parseDouble(format);
+ planView.setMaterialWeight(weight);
+ planView.setWholeMaterial(scanInfo);
+ //称量只验证类型 也就是条码
+ if (planView.getMaterial_code().equals(goodsCode)) {
+ planView.setState(1);
+ tipDialog.showState(true);
+ } else {
+ planView.setState(0);
+ tipDialog.showState(false);
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/pulit/X1Activity.java b/app/src/main/java/com/example/pulit/X1Activity.java
index f3c2358..c89d0b3 100644
--- a/app/src/main/java/com/example/pulit/X1Activity.java
+++ b/app/src/main/java/com/example/pulit/X1Activity.java
@@ -74,11 +74,9 @@ public class X1Activity extends BaseActivity {
if (info.contains("kg")) {
//整包 截取 物料编码
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);
checkItem(goodsCode, goodsWeight, "整包", info);
} else {
@@ -92,7 +90,6 @@ public class X1Activity extends BaseActivity {
}
-
@OnClick({R.id.info_title_back, R.id.x1_scan, R.id.x1_submit})
public void onClick(View view) {
switch (view.getId()) {
@@ -133,7 +130,8 @@ public class X1Activity extends BaseActivity {
private String kcode;
private int station;
-//查询 釜
+
+ //查询 釜
private void getF(String info) {
OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/GetByCode")
.params("code", info)
@@ -164,7 +162,8 @@ public class X1Activity extends BaseActivity {
}
);
}
-//查询散装
+
+ //查询散装
private void selectGoods(String info) {
OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/GetByBarrelInfo")
.params("code", info)
@@ -191,6 +190,7 @@ public class X1Activity extends BaseActivity {
}
});
}
+
//比对
private void checkItem(String goodsCode, double goodsWeight, String matType, String info) {
x1GoodsCode.setText(goodsCode);
@@ -198,11 +198,19 @@ public class X1Activity extends BaseActivity {
entrySubmit = new X1Submit();
Item item = new Item();
item.setMaterial_Code(goodsCode);
- item.setSetWeight(goodsWeight);
- if (items.contains(item)) {
- entrySubmit.setState(1);
- tipDialog.showState(true);
-
+ int index = items.indexOf(item);
+ //验证
+ if (index != -1) {
+ Item selectItem = items.get(index);
+ double selectWeight = selectItem.getSetWeight();
+ double errorWeight = selectItem.getSetError();
+ if (selectWeight - errorWeight <= goodsWeight && selectWeight + errorWeight >= goodsWeight) {
+ entrySubmit.setState(1);
+ tipDialog.showState(true);
+ } else {
+ tipDialog.showState(false);
+ entrySubmit.setState(2);
+ }
} else {
tipDialog.showState(false);
entrySubmit.setState(2);
diff --git a/app/src/main/java/com/example/pulit/X3Activity.java b/app/src/main/java/com/example/pulit/X3Activity.java
index ad4136f..6f83320 100644
--- a/app/src/main/java/com/example/pulit/X3Activity.java
+++ b/app/src/main/java/com/example/pulit/X3Activity.java
@@ -66,6 +66,7 @@ public class X3Activity extends BaseActivity {
finish();
break;
case R.id.x3_scan:
+ super.sanCode();
break;
}
}
diff --git a/app/src/main/java/com/example/pulit/entity/Item.java b/app/src/main/java/com/example/pulit/entity/Item.java
index c08127a..1458839 100644
--- a/app/src/main/java/com/example/pulit/entity/Item.java
+++ b/app/src/main/java/com/example/pulit/entity/Item.java
@@ -11,6 +11,15 @@ public class Item {
private String MaterialName;
private String Material_Code;
private double SetWeight;
+ private double SetError;
+
+ public double getSetError() {
+ return SetError;
+ }
+
+ public void setSetError(double setError) {
+ SetError = setError;
+ }
public int getID() {
return ID;
@@ -67,17 +76,11 @@ public class Item {
Item item = (Item) o;
- if (Double.compare(item.SetWeight, SetWeight) != 0) return false;
return Material_Code != null ? Material_Code.equals(item.Material_Code) : item.Material_Code == null;
}
@Override
public int hashCode() {
- int result;
- long temp;
- result = Material_Code != null ? Material_Code.hashCode() : 0;
- temp = Double.doubleToLongBits(SetWeight);
- result = 31 * result + (int) (temp ^ (temp >>> 32));
- return result;
+ return Material_Code != null ? Material_Code.hashCode() : 0;
}
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index e392cc6..5396999 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -46,7 +46,7 @@
android:id="@+id/home_xl_z"
style="@style/TabRadioButton"
android:drawableTop="@mipmap/home_xl"
- android:text="小料重量 核对" />
+ android:text="小料重量 核对" />
@@ -71,7 +71,7 @@
android:id="@+id/home_rj_t"
style="@style/TabRadioButton"
android:drawableTop="@mipmap/home_rj"
- android:text="溶剂投料" />
+ android:text="液体核对" />
diff --git a/app/src/main/res/layout/activity_so2.xml b/app/src/main/res/layout/activity_so2.xml
new file mode 100644
index 0000000..af85cfb
--- /dev/null
+++ b/app/src/main/res/layout/activity_so2.xml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_solvent.xml b/app/src/main/res/layout/activity_solvent.xml
index cde79f6..a714c78 100644
--- a/app/src/main/res/layout/activity_solvent.xml
+++ b/app/src/main/res/layout/activity_solvent.xml
@@ -14,11 +14,10 @@
app:layout_constraintTop_toTopOf="parent">
+ android:text="液体称量" />
+ android:text="扫描拉缸条码" />
-
-
-
-
-
-
@@ -88,7 +65,6 @@
android:orientation="horizontal">
+ android:text="物料品名" />
-
-
-
-
-