增加 反应釜投料误差验证

master
wangh 1 year ago
parent dce00b7e29
commit 9ef7e50fa6

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

Binary file not shown.

@ -10,7 +10,7 @@
{
"type": "SINGLE",
"filters": [],
"versionCode": 1,
"versionCode": 2,
"versionName": "1.0",
"outputFile": "app-release.apk"
}

@ -15,7 +15,8 @@
android:supportsRtl="true"
android:theme="@style/Theme.PuLiT"
android:usesCleartextTraffic="true">
<activity android:name=".X3Activity"></activity>
<activity android:name=".So2Activity"></activity>
<activity android:name=".X3Activity" />
<activity android:name=".SolventActivity" />
<activity android:name=".X2Activity" />
<activity android:name=".X1Activity" />

@ -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) {

@ -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));

@ -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.<Resust>get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/GetByPumpInfo")
.params("code", info)
.execute(new MyOkGoCallback() {
@Override
public void onSuccess(Response<Resust> 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<Resust> 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.<Resust>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<Resust> 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<Resust> response) {
super.onError(response);
dialog.dismiss();
Toast.makeText(So2Activity.this, "网络请求失败", Toast.LENGTH_SHORT).show();
}
});
break;
}
}
}

@ -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.<Resust>post("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/ExecPlcState")
OkGo.<Resust>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<Resust> 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.<Resust>get("http://" + SharedPreferencesUtils.getstring("ip", null) + uri)
OkGo.<Resust>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,12 +119,12 @@ public class SolventActivity extends BaseActivity {
public void onError(Response<Resust> 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("-"));
@ -165,37 +139,17 @@ public class SolventActivity extends BaseActivity {
solventGoodsName.setText(goodsName);
//重量
String format = decimalFormat.format(
Double.parseDouble(
scanInfo.substring(scanInfo.indexOf("|") + 1, scanInfo.indexOf("kg"))
));
solventGoods.setText(format);
Double.parseDouble(scanInfo.substring(scanInfo.indexOf("|") + 1, scanInfo.indexOf("kg"))));
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) {
//称量只验证类型 也就是条码
if (planView.getMaterial_code().equals(goodsCode)) {
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);
}
}
}
}
}

@ -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.<Resust>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.<Resust>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)) {
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);

@ -66,6 +66,7 @@ public class X3Activity extends BaseActivity {
finish();
break;
case R.id.x3_scan:
super.sanCode();
break;
}
}

@ -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;
}
}

@ -71,7 +71,7 @@
android:id="@+id/home_rj_t"
style="@style/TabRadioButton"
android:drawableTop="@mipmap/home_rj"
android:text="溶剂投料" />
android:text="液体核对" />
</RadioGroup>

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".So2Activity"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@color/blue"
app:layout_constraintTop_toTopOf="parent">
<TextView
style="@style/title_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="液体核对" />
<ImageView
android:id="@+id/info_title_back"
android:layout_width="55dp"
android:layout_height="match_parent"
android:padding="15dp"
android:src="@mipmap/icon_back" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:orientation="horizontal">
<TextView
style="@style/text_view"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="扫描泵位条码" />
<TextView
android:id="@+id/solvent2_code"
style="@style/text_view2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:orientation="horizontal">
<TextView
style="@style/text_view"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="扫描拉缸条码" />
<TextView
android:id="@+id/solvent2_goods_code"
style="@style/text_view2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp" />
</LinearLayout>
<Button
android:id="@+id/solvent2_scan"
style="@style/button_style1"
android:layout_width="match_parent"
android:layout_height="54dp"
android:layout_marginStart="20dp"
android:layout_marginTop="202dp"
android:layout_marginEnd="20dp"
android:text="触发扫描" />
<Button
android:id="@+id/solvent2_submit"
style="@style/button_style2"
android:layout_width="match_parent"
android:layout_height="54dp"
android:layout_marginStart="20dp"
android:layout_marginTop="22dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="22dp"
android:text="提交" />
</LinearLayout>

@ -14,11 +14,10 @@
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/solvent_title"
style="@style/title_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="" />
android:text="液体称量" />
<ImageView
android:id="@+id/info_title_back"
@ -38,11 +37,10 @@
android:orientation="horizontal">
<TextView
android:id="@+id/solvent_frist_name"
style="@style/text_view"
android:layout_width="100dp"
android:layout_height="46dp"
android:text="" />
android:text="扫描拉缸条码" />
<TextView
android:id="@+id/solvent_code"
@ -53,27 +51,6 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:orientation="horizontal">
<TextView
style="@style/text_view"
android:layout_width="100dp"
android:layout_height="46dp"
android:text="设置误差" />
<TextView
android:id="@+id/solvent_wc"
style="@style/text_view1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"/>
</LinearLayout>
@ -88,7 +65,6 @@
android:orientation="horizontal">
<TextView
android:id="@+id/solvent_title_name"
style="@style/text_view"
android:layout_width="100dp"
android:layout_height="46dp"
@ -103,6 +79,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/s2gion"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_marginStart="10dp"
@ -114,7 +91,7 @@
style="@style/text_view"
android:layout_width="100dp"
android:layout_height="46dp"
android:text="物料名" />
android:text="物料名" />
<TextView
android:id="@+id/solvent_goodsName"
@ -123,27 +100,7 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:orientation="horizontal">
<TextView
style="@style/text_view"
android:layout_width="100dp"
android:layout_height="46dp"
android:text="物料重量" />
<TextView
android:id="@+id/solvent_goods"
style="@style/text_view1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp" />
</LinearLayout>
<Button
android:id="@+id/solvent_scan"

Loading…
Cancel
Save