修改 液体称量

master
wangh 1 year ago
parent ac63b55a89
commit f8b61fef03

@ -10,7 +10,7 @@ android {
applicationId "com.example.pulit" applicationId "com.example.pulit"
minSdkVersion 26 minSdkVersion 26
targetSdkVersion 30 targetSdkVersion 30
versionCode 7 versionCode 11
versionName "1.0" versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -42,6 +42,8 @@ dependencies {
implementation 'com.alibaba.fastjson2:fastjson2:2.0.38' implementation 'com.alibaba.fastjson2:fastjson2:2.0.38'
// https://mvnrepository.com/artifact/com.android.volley/volley // https://mvnrepository.com/artifact/com.android.volley/volley
implementation 'com.android.volley:volley:1.2.1' implementation 'com.android.volley:volley:1.2.1'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.lzy.net:okgo:3.0.4' implementation 'com.lzy.net:okgo:3.0.4'

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

@ -16,6 +16,7 @@
android:theme="@style/Theme.PuLiT" android:theme="@style/Theme.PuLiT"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<activity android:name=".PlanActivity"></activity> <activity android:name=".PlanActivity"></activity>
<activity android:name=".ZBActivity"/>
<activity android:name=".So2Activity" /> <activity android:name=".So2Activity" />
<activity android:name=".X3Activity" /> <activity android:name=".X3Activity" />
<activity android:name=".SolventActivity" /> <activity android:name=".SolventActivity" />

@ -52,9 +52,9 @@ public class MainActivity extends AppCompatActivity {
case R.id.home_rj_t: case R.id.home_rj_t:
intent = new Intent(this, So2Activity.class); intent = new Intent(this, So2Activity.class);
break; break;
// case R.id.home_plan: case R.id.home_plan:
// intent = new Intent(this, PlanActivity.class); intent = new Intent(this, ZBActivity.class);
// break; break;
case R.id.home_setting: case R.id.home_setting:
textDialog.setIpAddress(SharedPreferencesUtils.getstring("ip", null)); textDialog.setIpAddress(SharedPreferencesUtils.getstring("ip", null));
textDialog.show(); textDialog.show();

@ -39,41 +39,46 @@ public class SolventActivity extends BaseActivity {
TextView solventGoodslv; TextView solventGoodslv;
@BindView(R.id.solvent_goodslv_state) @BindView(R.id.solvent_goodslv_state)
LinearLayout solventGoodslvState; LinearLayout solventGoodslvState;
private int sanType;
private boolean sanType; private boolean exist;
private boolean sanLvType;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_solvent); setContentView(R.layout.activity_solvent);
ButterKnife.bind(this); ButterKnife.bind(this);
sanType = true; sanType = 0;
sanLvType = false;
} }
private PlanView planView; private PlanView planView;
@Override @Override
public void scanInfo(String info) { public void scanInfo(String info) {
if (sanLvType) {
solventGoodslv.setText(info.replace("%", "").trim()); switch (sanType) {
} else { case 0:
if (sanType) {
dialog.show(); dialog.show();
solventCode.setText(info); solventCode.setText(info);
String dbName = solventDb.getSelectedItem().toString(); String dbName = solventDb.getSelectedItem().toString();
selectSup(info, dbName); selectSup(info, dbName);
} else { break;
case 1:
try { try {
checkGoods(info); checkGoods(info);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Toast.makeText(this, "条码格式错误", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "条码格式错误", Toast.LENGTH_SHORT).show();
} }
} break;
case 2:
solventGoodslv.setText(info.replace("%", "").trim());
break;
} }
} }
@OnClick({R.id.info_title_back, R.id.solvent_scan, R.id.solvent_submit}) @OnClick({R.id.info_title_back, R.id.solvent_scan, R.id.solvent_submit})
@ -88,7 +93,7 @@ public class SolventActivity extends BaseActivity {
case R.id.solvent_submit: case R.id.solvent_submit:
if (planView == null) return; if (planView == null) return;
String string1 = solventGoodslv.getText().toString(); String string1 = solventGoodslv.getText().toString();
if (sanLvType && string1.isEmpty()) { if (exist && string1.isEmpty()) {
Toast.makeText(this, "必须扫描固含率", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "必须扫描固含率", Toast.LENGTH_SHORT).show();
return; return;
} }
@ -98,7 +103,7 @@ public class SolventActivity extends BaseActivity {
dialog.show(); dialog.show();
planView.setWeighbridge(dbaname); planView.setWeighbridge(dbaname);
planView.setCylinderBarCode(string); planView.setCylinderBarCode(string);
planView.setRate(string1); planView.setRate(string1.isEmpty()?"0":string1);
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;"), RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;"),
JSONObject.toJSONString(planView)); JSONObject.toJSONString(planView));
OkGo.<Resust>post("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/ExecPlcState") OkGo.<Resust>post("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/ExecPlcState")
@ -110,7 +115,14 @@ public class SolventActivity extends BaseActivity {
dialog.dismiss(); dialog.dismiss();
Toast.makeText(SolventActivity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show(); Toast.makeText(SolventActivity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show();
if (response.body().isSuccess()) { if (response.body().isSuccess()) {
finish(); sanType=0;
solventCode.setText(null);
solventGoodsCode.setText(null);
planView=null;
solventGoodsName.setText(null);
solventGoodslv.setText(null);
solventGoodslvState.setVisibility(View.GONE);
} }
} }
@ -139,12 +151,13 @@ public class SolventActivity extends BaseActivity {
String substring = body.substring(body.indexOf(":{") + 1, body.length() - 1); String substring = body.substring(body.indexOf(":{") + 1, body.length() - 1);
planView = JSONObject.parseObject(substring, PlanView.class); planView = JSONObject.parseObject(substring, PlanView.class);
Log.e("TAG", "onSuccess:" + planView.toString()); Log.e("TAG", "onSuccess:" + planView.toString());
if (planView.isExist()) { exist = planView.isExist();
if (exist) {
solventGoodslvState.setVisibility(View.VISIBLE); solventGoodslvState.setVisibility(View.VISIBLE);
} }
Toast.makeText(SolventActivity.this, "查询成功", Toast.LENGTH_SHORT).show(); Toast.makeText(SolventActivity.this, "查询成功", Toast.LENGTH_SHORT).show();
sanType = false; sanType = 1;//扫描物料
} else { } else {
Toast.makeText(SolventActivity.this, resust.getMsg(), Toast.LENGTH_SHORT).show(); Toast.makeText(SolventActivity.this, resust.getMsg(), Toast.LENGTH_SHORT).show();
} }
@ -182,7 +195,8 @@ public class SolventActivity extends BaseActivity {
if (planView.getMaterial_code().equals(goodsCode)) { if (planView.getMaterial_code().equals(goodsCode)) {
planView.setState(1); planView.setState(1);
tipDialog.showState(true); tipDialog.showState(true);
sanLvType = true; sanType= exist?2:1;
} else { } else {
planView.setState(0); planView.setState(0);
tipDialog.showState(false); tipDialog.showState(false);

@ -4,6 +4,7 @@ import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListPopupWindow; import android.widget.ListPopupWindow;
import android.widget.TextView; import android.widget.TextView;
@ -13,18 +14,22 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.example.pulit.adapter.ItemAdapter; import com.example.pulit.adapter.ItemAdapter;
import com.example.pulit.entity.Item; import com.example.pulit.entity.Item;
import com.example.pulit.entity.MaterialView;
import com.example.pulit.entity.X1; import com.example.pulit.entity.X1;
import com.example.pulit.entity.X1SubmintChild;
import com.example.pulit.entity.X1Submit; import com.example.pulit.entity.X1Submit;
import com.example.pulit.util.MyOkGoCallback; import com.example.pulit.util.MyOkGoCallback;
import com.example.pulit.util.Resust; import com.example.pulit.util.Resust;
import com.example.pulit.util.SharedPreferencesUtils; import com.example.pulit.util.SharedPreferencesUtils;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response; import com.lzy.okgo.model.Response;
import java.util.Arrays; import java.util.ArrayList;
import java.util.List; import java.util.List;
import butterknife.BindView; import butterknife.BindView;
@ -47,30 +52,45 @@ public class X1Activity extends BaseActivity {
TextView x1GoodsWeight; TextView x1GoodsWeight;
@BindView(R.id.x1_code1) @BindView(R.id.x1_code1)
LinearLayout x1Code1; LinearLayout x1Code1;
@BindView(R.id.x1_plan_code)
TextView x1PlanCode;
@BindView(R.id.x1_scan)
Button x1Scan;
@BindView(R.id.x1_submit)
Button x1Submit;
@BindView(R.id.x1_submit2)
Button x1Submit2;
private boolean scanStates; private boolean scanStates;
private List<Item> items; private List<Item> items;
private ItemAdapter adapter; private ItemAdapter adapter;
private X1Submit entrySubmit;
private ListPopupWindow lpw; private ListPopupWindow lpw;
private List<String> planList; private List<String> planList;
private String kcode;
private int station; private String planId;
private String pianId;
// 提交字段
private X1Submit entrySubmit;
private List<X1SubmintChild> submintChildList;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_x1); setContentView(R.layout.activity_x1);
ButterKnife.bind(this); ButterKnife.bind(this);
entrySubmit = new X1Submit();
scanStates = true; scanStates = true;
x1RecyclerView.setLayoutManager(new LinearLayoutManager(this)); x1RecyclerView.setLayoutManager(new LinearLayoutManager(this));
adapter = new ItemAdapter(this); adapter = new ItemAdapter(this);
lpw = new ListPopupWindow(this); lpw = new ListPopupWindow(this);
lpw.setAnchorView(x1Code1); lpw.setAnchorView(x1PlanCode);
lpw.setOnItemClickListener((adapterView, view, i, l) -> { lpw.setOnItemClickListener((adapterView, view, i, l) -> {
String planId = planList.get(i); planId = planList.get(i);
selectPlanByID(x1Code.getText().toString(), planId); selectPlanByID(x1Code.getText().toString(), planId);
submintChildList = new ArrayList<>();
lpw.dismiss(); lpw.dismiss();
}); });
} }
@ -86,13 +106,17 @@ public class X1Activity extends BaseActivity {
} else { } else {
x1Tong.setText(info); x1Tong.setText(info);
if (info.contains("kg")) { if (info.contains("kg")) {
//整包 截取 物料编码 //整包 截取 物料编码 000524-20230805-0001-CF-130|25kg
String goodsCode = info.substring(0, info.indexOf("-")); String goodsCode = info.substring(0, info.indexOf("-"));
//格式化重量 //格式化重量
String stringFormatWeight = decimalFormat.format( String stringFormatWeight = decimalFormat.format(
Double.parseDouble(info.substring(info.indexOf("|") + 1, info.indexOf("kg")))); Double.parseDouble(info.substring(info.indexOf("|") + 1, info.indexOf("kg"))));
double goodsWeight = Double.parseDouble(stringFormatWeight); double goodsWeight = Double.parseDouble(stringFormatWeight);
checkItem(goodsCode, goodsWeight, "整包", info); 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);
} else { } else {
//散装、查询接口 //散装、查询接口
selectGoods(info); selectGoods(info);
@ -104,7 +128,7 @@ public class X1Activity extends BaseActivity {
} }
@OnClick({R.id.info_title_back, R.id.x1_scan, R.id.x1_submit, R.id.x1_submit2}) @OnClick({R.id.info_title_back, R.id.x1_scan, R.id.x1_submit, R.id.x1_submit2, R.id.x1_plan_code})
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.info_title_back: case R.id.info_title_back:
@ -115,8 +139,8 @@ public class X1Activity extends BaseActivity {
break; break;
case R.id.x1_submit: case R.id.x1_submit:
if (entrySubmit == null) return; if (entrySubmit == null) return;
for(Item item:items){ for (Item item : items) {
if (!item.isState()){ if (!item.isState()) {
Toast.makeText(this, "还有物料未验证", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "还有物料未验证", Toast.LENGTH_SHORT).show();
return; return;
} }
@ -127,7 +151,9 @@ public class X1Activity extends BaseActivity {
if (entrySubmit == null) return; if (entrySubmit == null) return;
submit(entrySubmit, 0); submit(entrySubmit, 0);
break; break;
case R.id.x1_plan_code:
lpw.show();
break;
} }
} }
@ -135,8 +161,10 @@ public class X1Activity extends BaseActivity {
//提交 //提交
private void submit(X1Submit entrySubmit, int state) { private void submit(X1Submit entrySubmit, int state) {
dialog.show(); dialog.show();
entrySubmit.setkCode(x1Code.getText().toString());
entrySubmit.setState(state); entrySubmit.setState(state);
entrySubmit.setPlanId(pianId); entrySubmit.setPlanId(planId);
entrySubmit.setChild(submintChildList);
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;"), RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;"),
JSONObject.toJSONString(entrySubmit)); JSONObject.toJSONString(entrySubmit));
OkGo.<Resust>post("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/ExecPlcState") OkGo.<Resust>post("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/ExecPlcState")
@ -179,9 +207,9 @@ public class X1Activity extends BaseActivity {
lpw.setAdapter(new ArrayAdapter(X1Activity.this, lpw.setAdapter(new ArrayAdapter(X1Activity.this,
R.layout.support_simple_spinner_dropdown_item, R.layout.support_simple_spinner_dropdown_item,
planList)); planList));
lpw.show(); tipDialog.showMsg(true, "查询成功,请选择计划");
} else { } else {
Toast.makeText(X1Activity.this, "请求失败,条码不正确", Toast.LENGTH_SHORT).show(); Toast.makeText(X1Activity.this, "请求失败,反应釜条码不正确", Toast.LENGTH_SHORT).show();
} }
} }
@ -197,6 +225,7 @@ public class X1Activity extends BaseActivity {
//查询计划中的物料 //查询计划中的物料
private void selectPlanByID(String code, String planID) { private void selectPlanByID(String code, String planID) {
x1PlanCode.setText(planID);
OkGo.<Resust>get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/GetByCode") OkGo.<Resust>get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/GetByCode")
.params("code", code) .params("code", code)
.params("planId", planID) .params("planId", planID)
@ -207,15 +236,16 @@ public class X1Activity extends BaseActivity {
dialog.dismiss(); dialog.dismiss();
if (response.body().isSuccess()) { if (response.body().isSuccess()) {
X1 x1 = JSONObject.parseObject(response.body().getData(), X1.class); X1 x1 = JSONObject.parseObject(response.body().getData(), X1.class);
station = x1.getID();// entrySubmit.setStation(x1.getID());//提交的字段
kcode = x1.getBarCode();//
items = x1.getChildren(); items = x1.getChildren();
pianId = x1.getPlanId();
adapter.setList(items); adapter.setList(items);
x1RecyclerView.setAdapter(adapter); x1RecyclerView.setAdapter(adapter);
scanStates = false;//扫描 scanStates = false;//扫描
x1Tong.setText(null);
x1GoodsCode.setText(null);
x1GoodsWeight.setText(null);
} else { } else {
Toast.makeText(X1Activity.this, "请求失败,条码不正确", Toast.LENGTH_SHORT).show(); Toast.makeText(X1Activity.this, "请求失败,计划条码不正确", Toast.LENGTH_SHORT).show();
} }
} }
@ -232,16 +262,35 @@ public class X1Activity extends BaseActivity {
//查询散装 //查询散装
private void selectGoods(String info) { private void selectGoods(String info) {
OkGo.<Resust>get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/GetByBarrelInfo") OkGo.<Resust>get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/GetByBarrelInfo")
.params("kettleBarCode", x1Code.getText().toString())
.params("planId", planId)
.params("code", info) .params("code", info)
.execute(new MyOkGoCallback() { .execute(new MyOkGoCallback() {
@Override @Override
public void onSuccess(Response<Resust> response) { public void onSuccess(Response<Resust> response) {
super.onSuccess(response); super.onSuccess(response);
if (response.body().isSuccess()) { if (response.body().isSuccess()) {
JSONObject obj = response.body().getDateObj(); JSONObject jsonObject = JSONObject.parseObject(response.body().getData());
double goodsWeight = obj.getDoubleValue("Weight");
String goodsCode = obj.getString("MaterialID"); List<MaterialView> list = JSONArray.parseArray(jsonObject.get("child").toString(), MaterialView.class);
checkItem(goodsCode, goodsWeight, "散装", info);
String tipTag="";
for (MaterialView materialView : list) {
if (materialView.getMatchOrNot() == 0) {
tipTag+=materialView.getMaterialName()+"("+materialView.getMaterialBarCode()+")";
}
}
if (!tipTag.equals("")) {
tipDialog.showMsg(false, tipTag+ " 不合格");
return;
}
for (MaterialView materialView : list) {
double goodsWeight = materialView.getWeight();
String goodsCode = materialView.getMaterialBarCode();
checkItem(goodsCode, goodsWeight, "散装", info, materialView.getMaterialName());
}
} else { } else {
Toast.makeText(X1Activity.this, "查询失败,条码不正确", Toast.LENGTH_SHORT).show(); Toast.makeText(X1Activity.this, "查询失败,条码不正确", Toast.LENGTH_SHORT).show();
x1GoodsCode.setText(null); x1GoodsCode.setText(null);
@ -258,37 +307,42 @@ public class X1Activity extends BaseActivity {
} }
//比对 //比对
private void checkItem(String goodsCode, double goodsWeight, String matType, String info) { private void checkItem(String goodsCode, double goodsWeight, String matType, String info, String t) {
x1GoodsCode.setText(goodsCode); x1GoodsCode.setText(goodsCode);
x1GoodsWeight.setText(goodsWeight + ""); x1GoodsWeight.setText(goodsWeight + "");
entrySubmit = new X1Submit(); X1SubmintChild entrySubmitcChild = new X1SubmintChild();
Item item = new Item();
item.setMaterial_Code(goodsCode); int index = -1;//目标
int index = items.indexOf(item); 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);
if (selectWeight - errorWeight <= goodsWeight && selectWeight + errorWeight >= goodsWeight) {
index = i;
break A;
}
}
}
//验证 //验证
if (index != -1) { if (index != -1) {
Item selectItem = items.get(index); Item selectItem = items.get(index);
double selectWeight = selectItem.getSetWeight(); entrySubmitcChild.setMatType(matType);
double errorWeight = selectItem.getSetError(); entrySubmitcChild.setMatCode(goodsCode);
if (selectWeight - errorWeight <= goodsWeight && selectWeight + errorWeight >= goodsWeight) { entrySubmitcChild.setMatName(t);
entrySubmit.setState(1); entrySubmitcChild.setMatWeight(goodsWeight);
tipDialog.showState(true); entrySubmitcChild.setWholePackage("string");
selectItem.setState(true); entrySubmitcChild.setBarrelCode(info);
adapter.notifyDataSetChanged(); submintChildList.add(entrySubmitcChild);
} else { tipDialog.showState(true);
tipDialog.showState(false); selectItem.setState(true);
entrySubmit.setState(2); adapter.notifyDataSetChanged();
}
} else { } else {
tipDialog.showState(false); tipDialog.showState(false);
entrySubmit.setState(2);
} }
entrySubmit.setkCode(kcode);
entrySubmit.setStation(station);
entrySubmit.setMatWeight(goodsWeight);
entrySubmit.setMatCode(goodsCode);
entrySubmit.setMatType(matType);
entrySubmit.setWholePackage(info);
} }
} }

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

@ -13,7 +13,7 @@ public class Item {
private double SetWeight; private double SetWeight;
private double SetError; private double SetError;
private boolean state=false; private boolean state=false;
private boolean Fixed;
public double getSetError() { public double getSetError() {
return SetError; return SetError;
} }

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

@ -1,18 +1,17 @@
package com.example.pulit.entity; package com.example.pulit.entity;
import java.util.List;
/** /**
* @author wanghao * @author wanghao
* @date 2023/8/8 11:20 * @date 2023/8/8 11:20
*/ */
public class X1Submit { public class X1Submit {
private int station;// 釜工位——主键 private int station;// 釜工位——主键
private String PlanId; //计划ID
private String kCode;// 投料釜条码 private String kCode;// 投料釜条码
private String matCode;// 物料条码
private double matWeight;//物料重量
private String matType;// 物料类型:整包、散装
private int state;//状态 0:未扫描 1:匹配 2:报警 private int state;//状态 0:未扫描 1:匹配 2:报警
private String wholePackage; private List<X1SubmintChild> child;
private String PlanId; //计划ID
public String getPlanId() { public String getPlanId() {
@ -39,29 +38,6 @@ public class X1Submit {
this.kCode = kCode; this.kCode = kCode;
} }
public String getMatCode() {
return matCode;
}
public void setMatCode(String matCode) {
this.matCode = matCode;
}
public double getMatWeight() {
return matWeight;
}
public void setMatWeight(double matWeight) {
this.matWeight = matWeight;
}
public String getMatType() {
return matType;
}
public void setMatType(String matType) {
this.matType = matType;
}
public int getState() { public int getState() {
return state; return state;
@ -71,16 +47,13 @@ public class X1Submit {
this.state = state; this.state = state;
} }
public List<X1SubmintChild> getChild() {
return child;
public String getWholePackage() {
return wholePackage;
} }
public void setWholePackage(String wholePackage) { public void setChild(List<X1SubmintChild> child) {
this.wholePackage = wholePackage; this.child = child;
} }
} }

@ -72,12 +72,12 @@
style="@style/TabRadioButton" style="@style/TabRadioButton"
android:drawableTop="@mipmap/home_rj" android:drawableTop="@mipmap/home_rj"
android:text="液体核对" /> android:text="液体核对" />
<RadioButton <RadioButton
android:id="@+id/home_plan" android:id="@+id/home_plan"
style="@style/TabRadioButton" style="@style/TabRadioButton"
/> android:drawableTop="@mipmap/home_zb"
<!--android:drawableTop="@mipmap/home_plan" android:text="整包称量" />
android:text="计划工单"-->
</RadioGroup> </RadioGroup>
<LinearLayout <LinearLayout

@ -118,6 +118,7 @@
style="@style/text_view1" style="@style/text_view1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="10dp" /> android:layout_marginLeft="10dp" />
</LinearLayout> </LinearLayout>

@ -34,7 +34,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="46dp" android:layout_height="46dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="20dp" android:layout_marginTop="10dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:orientation="horizontal"> android:orientation="horizontal">
@ -51,7 +51,28 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="10dp"/> android:layout_marginLeft="10dp"/>
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
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/x1_plan_code"
style="@style/text_view2"
android:drawableEnd="@mipmap/xl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/x1_recycler_view" android:id="@+id/x1_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -90,7 +111,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="46dp" android:layout_height="46dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="20dp" android:layout_marginTop="10dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:orientation="horizontal"> android:orientation="horizontal">
@ -111,7 +132,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="46dp" android:layout_height="46dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="20dp" android:layout_marginTop="10dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:orientation="horizontal"> android:orientation="horizontal">
@ -134,7 +155,7 @@
style="@style/button_style1" style="@style/button_style1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="54dp" android:layout_height="54dp"
android:layout_marginStart="20dp" android:layout_marginStart="10dp"
android:layout_marginTop="22dp" android:layout_marginTop="22dp"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:text="触发扫描" /> android:text="触发扫描" />

@ -180,5 +180,5 @@
android:layout_marginTop="22dp" android:layout_marginTop="22dp"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:layout_marginBottom="22dp" android:layout_marginBottom="22dp"
android:text="补料完毕" /> android:text="开启仓门" />
</LinearLayout> </LinearLayout>

@ -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…
Cancel
Save