修改 液体称量
parent
ac63b55a89
commit
f8b61fef03
@ -0,0 +1,129 @@
|
||||
package com.example.pulit;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.callback.StringCallback;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class ZBActivity extends BaseActivity {
|
||||
|
||||
|
||||
@BindView(R.id.zb_db)
|
||||
Spinner zbDb;
|
||||
@BindView(R.id.zb_goods_code)
|
||||
TextView zbGoodsCode;
|
||||
@BindView(R.id.zb_goodsName)
|
||||
TextView zbGoodsName;
|
||||
private int sanType;
|
||||
private boolean exist;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_zb);
|
||||
ButterKnife.bind(this);
|
||||
sanType = 0;
|
||||
|
||||
}
|
||||
|
||||
private PlanView planView;
|
||||
|
||||
@Override
|
||||
public void scanInfo(String info) {
|
||||
|
||||
try {
|
||||
checkGoods(info);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, "条码格式错误", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick({R.id.info_title_back, R.id.zb_scan, R.id.zb_submit})
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.info_title_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.zb_scan:
|
||||
super.sanCode();
|
||||
break;
|
||||
case R.id.zb_submit:
|
||||
if (planView == null) return;
|
||||
String dbaname = zbDb.getSelectedItem().toString();
|
||||
dialog.show();
|
||||
planView.setWeighbridge(dbaname);
|
||||
planView.setCylinderBarCode("00000000");
|
||||
planView.setRate( "0" );
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;"),
|
||||
JSONObject.toJSONString(planView));
|
||||
OkGo.<Resust>post("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/ExecPlcState")
|
||||
.upRequestBody(requestBody)
|
||||
.execute(new MyOkGoCallback() {
|
||||
@Override
|
||||
public void onSuccess(Response<Resust> response) {
|
||||
super.onSuccess(response);
|
||||
dialog.dismiss();
|
||||
Toast.makeText(ZBActivity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show();
|
||||
if (response.body().isSuccess()) {
|
||||
sanType = 0;
|
||||
zbGoodsCode.setText(null);
|
||||
planView = null;
|
||||
zbGoodsName.setText(null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<Resust> response) {
|
||||
super.onError(response);
|
||||
dialog.dismiss();
|
||||
Toast.makeText(ZBActivity.this, "网络请求失败", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkGoods(String scanInfo) {
|
||||
planView=new PlanView();
|
||||
zbGoodsCode.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);
|
||||
zbGoodsName.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);
|
||||
planView.setState(1);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.example.pulit.entity;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2023/11/15 16:24
|
||||
*/
|
||||
public class MaterialView {
|
||||
private String MaterialID;
|
||||
private String MaterialBarCode;
|
||||
private String MaterialName;
|
||||
private double Weight;
|
||||
private double Error;
|
||||
private int MatchOrNot;
|
||||
|
||||
public String getMaterialID() {
|
||||
return MaterialID;
|
||||
}
|
||||
|
||||
public void setMaterialID(String materialID) {
|
||||
MaterialID = materialID;
|
||||
}
|
||||
|
||||
public String getMaterialBarCode() {
|
||||
return MaterialBarCode;
|
||||
}
|
||||
|
||||
public void setMaterialBarCode(String materialBarCode) {
|
||||
MaterialBarCode = materialBarCode;
|
||||
}
|
||||
|
||||
public String getMaterialName() {
|
||||
return MaterialName;
|
||||
}
|
||||
|
||||
public void setMaterialName(String materialName) {
|
||||
MaterialName = materialName;
|
||||
}
|
||||
|
||||
public double getWeight() {
|
||||
return Weight;
|
||||
}
|
||||
|
||||
public void setWeight(double weight) {
|
||||
Weight = weight;
|
||||
}
|
||||
|
||||
public double getError() {
|
||||
return Error;
|
||||
}
|
||||
|
||||
public void setError(double error) {
|
||||
Error = error;
|
||||
}
|
||||
|
||||
public int getMatchOrNot() {
|
||||
return MatchOrNot;
|
||||
}
|
||||
|
||||
public void setMatchOrNot(int matchOrNot) {
|
||||
MatchOrNot = matchOrNot;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.example.pulit.entity;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2023/11/15 16:48
|
||||
*/
|
||||
public class X1SubmintChild {
|
||||
// "matType": "散装",
|
||||
// "barrelCode": "CZLC0009",
|
||||
// "matCode": "84012",
|
||||
// "matName": "84012",
|
||||
// "matWeight": 2.000,//实际重量,从料桶获取
|
||||
// "wholePackage": "string"
|
||||
|
||||
private String matType;// 物料类型:整包、散装
|
||||
private String barrelCode;
|
||||
private String matCode;// 物料条码
|
||||
private String matName;
|
||||
private double matWeight;//物料重量
|
||||
private String wholePackage;
|
||||
|
||||
public String getMatType() {
|
||||
return matType;
|
||||
}
|
||||
|
||||
public void setMatType(String matType) {
|
||||
this.matType = matType;
|
||||
}
|
||||
|
||||
public String getBarrelCode() {
|
||||
return barrelCode;
|
||||
}
|
||||
|
||||
public void setBarrelCode(String barrelCode) {
|
||||
this.barrelCode = barrelCode;
|
||||
}
|
||||
|
||||
public String getMatCode() {
|
||||
return matCode;
|
||||
}
|
||||
|
||||
public void setMatCode(String matCode) {
|
||||
this.matCode = matCode;
|
||||
}
|
||||
|
||||
public String getMatName() {
|
||||
return matName;
|
||||
}
|
||||
|
||||
public void setMatName(String matName) {
|
||||
this.matName = matName;
|
||||
}
|
||||
|
||||
public double getMatWeight() {
|
||||
return matWeight;
|
||||
}
|
||||
|
||||
public void setMatWeight(double matWeight) {
|
||||
this.matWeight = matWeight;
|
||||
}
|
||||
|
||||
public String getWholePackage() {
|
||||
return wholePackage;
|
||||
}
|
||||
|
||||
public void setWholePackage(String wholePackage) {
|
||||
this.wholePackage = wholePackage;
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
<?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=".zbActivity"
|
||||
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="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="地磅编号" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/zb_db"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:entries="@array/power"/>
|
||||
</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/zb_goods_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="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/zb_goodsName"
|
||||
style="@style/text_view1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
android:layout_marginLeft="10dp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/zb_scan"
|
||||
style="@style/button_style1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="22dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:text="触发扫描" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/zb_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>
|
Loading…
Reference in New Issue