From ac63b55a89cbfb9caa5fd8b56d6abaac2c7f566e Mon Sep 17 00:00:00 2001 From: wangh <123456> Date: Mon, 6 Nov 2023 17:35:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=B6=B2=E4=BD=93?= =?UTF-8?q?=E7=A7=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- app/release/output-metadata.json | 2 +- app/src/main/AndroidManifest.xml | 3 +- .../java/com/example/pulit/MainActivity.java | 8 +- .../java/com/example/pulit/MyApplication.java | 6 +- .../java/com/example/pulit/PlanActivity.java | 89 ++++++++++++++ .../com/example/pulit/SolventActivity.java | 70 +++++++---- .../java/com/example/pulit/X1Activity.java | 78 +++++++++--- .../java/com/example/pulit/X2Activity.java | 42 +++++-- .../example/pulit/adapter/ItemAdapter.java | 17 ++- .../example/pulit/adapter/PlanAdapter.java | 64 ++++++++++ .../java/com/example/pulit/entity/AxPlan.java | 116 ++++++++++++++++++ .../java/com/example/pulit/entity/Item.java | 9 ++ .../com/example/pulit/entity/PlanView.java | 24 ++++ .../com/example/pulit/entity/X1Submit.java | 8 +- app/src/main/res/layout/activity_main.xml | 7 +- app/src/main/res/layout/activity_plan.xml | 71 +++++++++++ app/src/main/res/layout/activity_solvent.xml | 35 +++++- app/src/main/res/layout/item_layout.xml | 22 ++-- app/src/main/res/layout/item_plan.xml | 46 +++++++ app/src/main/res/values/arrays.xml | 5 + app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/themes.xml | 3 +- 23 files changed, 641 insertions(+), 87 deletions(-) create mode 100644 app/src/main/java/com/example/pulit/PlanActivity.java create mode 100644 app/src/main/java/com/example/pulit/adapter/PlanAdapter.java create mode 100644 app/src/main/java/com/example/pulit/entity/AxPlan.java create mode 100644 app/src/main/res/layout/activity_plan.xml create mode 100644 app/src/main/res/layout/item_plan.xml diff --git a/app/build.gradle b/app/build.gradle index 3571ce5..8a3e2f3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { applicationId "com.example.pulit" minSdkVersion 26 targetSdkVersion 30 - versionCode 4 + versionCode 7 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 7864dd8..cd3405a 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -10,7 +10,7 @@ { "type": "SINGLE", "filters": [], - "versionCode": 4, + "versionCode": 6, "versionName": "1.0", "outputFile": "app-release.apk" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 076c104..541095f 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/MainActivity.java b/app/src/main/java/com/example/pulit/MainActivity.java index ecc6c32..0c849a7 100644 --- a/app/src/main/java/com/example/pulit/MainActivity.java +++ b/app/src/main/java/com/example/pulit/MainActivity.java @@ -32,7 +32,8 @@ public class MainActivity extends AppCompatActivity { } - @OnClick({R.id.home_xl_b, R.id.home_xl_t, R.id.home_xl_z, R.id.home_rj_c, R.id.home_rj_t, R.id.home_setting, R.id.home_back}) + @OnClick({R.id.home_xl_b, R.id.home_xl_t, R.id.home_xl_z, R.id.home_rj_c, R.id.home_rj_t, + R.id.home_setting, R.id.home_back, R.id.home_plan}) public void onClick(View view) { Intent intent = null; switch (view.getId()) { @@ -42,7 +43,7 @@ public class MainActivity extends AppCompatActivity { case R.id.home_xl_t: intent = new Intent(this, X1Activity.class); break; - case R.id.home_xl_z: + case R.id.home_xl_z: intent = new Intent(this, X3Activity.class); break; case R.id.home_rj_c: @@ -51,6 +52,9 @@ public class MainActivity extends AppCompatActivity { case R.id.home_rj_t: intent = new Intent(this, So2Activity.class); break; +// case R.id.home_plan: +// intent = new Intent(this, PlanActivity.class); +// break; case R.id.home_setting: textDialog.setIpAddress(SharedPreferencesUtils.getstring("ip", null)); textDialog.show(); diff --git a/app/src/main/java/com/example/pulit/MyApplication.java b/app/src/main/java/com/example/pulit/MyApplication.java index db13522..0da94d8 100644 --- a/app/src/main/java/com/example/pulit/MyApplication.java +++ b/app/src/main/java/com/example/pulit/MyApplication.java @@ -55,11 +55,11 @@ public class MyApplication extends Application { builder.addInterceptor(loggingInterceptor); //全局的读取超时时间 - builder.readTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); + builder.readTimeout(3000, TimeUnit.MILLISECONDS); //全局的写入超时时间 - builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); + builder.writeTimeout(3000, TimeUnit.MILLISECONDS); //全局的连接超时时间 - builder.connectTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); + builder.connectTimeout(3000, TimeUnit.MILLISECONDS); //使用内存保持cookie,app退出后,cookie消失 builder.cookieJar(new CookieJarImpl(new MemoryCookieStore())); OkGo.getInstance().init(this).setOkHttpClient(builder.build()) //建议设置OkHttpClient,不设置将使用默认的 diff --git a/app/src/main/java/com/example/pulit/PlanActivity.java b/app/src/main/java/com/example/pulit/PlanActivity.java new file mode 100644 index 0000000..9456fa7 --- /dev/null +++ b/app/src/main/java/com/example/pulit/PlanActivity.java @@ -0,0 +1,89 @@ +package com.example.pulit; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Spinner; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.example.pulit.adapter.PlanAdapter; +import com.example.pulit.entity.AxPlan; +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 java.util.List; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class PlanActivity extends BaseActivity { + + @BindView(R.id.plan_type) + Spinner planType; + @BindView(R.id.plan_recycler) + RecyclerView planRecycler; + private PlanAdapter adapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_plan); + ButterKnife.bind(this); + planRecycler.setLayoutManager(new LinearLayoutManager(this)); + adapter = new PlanAdapter(this); + + + } + + @Override + public void scanInfo(String info) { + + } + + @OnClick({R.id.info_title_back, R.id.plan_select}) + public void onClick(View view) { + switch (view.getId()) { + case R.id.info_title_back: + finish(); + break; + case R.id.plan_select: + String type = planType.getSelectedItem().toString(); + String url = null; + if (type.equals("小料")) { + url = "/api/xl_material/GetXlPlanInfo"; + } else { + url = "/api/Solvent/GetSolventPlanInfo"; + } + dialog.show(); + OkGo.get("http://"+SharedPreferencesUtils.getstring("ip", null)+url).execute(new MyOkGoCallback(){ + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + dialog.dismiss(); + List list= JSON.parseArray(response.body().getData(),AxPlan.class); + Log.e("TAG", "onSuccess:" + list.toString()); + adapter.setList(list); + planRecycler.setAdapter(adapter); + } + + @Override + public void onError(Response response) { + super.onError(response); + dialog.dismiss(); + Toast.makeText(PlanActivity.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 dece05e..1b1005f 100644 --- a/app/src/main/java/com/example/pulit/SolventActivity.java +++ b/app/src/main/java/com/example/pulit/SolventActivity.java @@ -3,7 +3,6 @@ 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.Spinner; import android.widget.TextView; @@ -15,6 +14,7 @@ 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; @@ -35,8 +35,13 @@ public class SolventActivity extends BaseActivity { LinearLayout s2gion; @BindView(R.id.solvent_db) Spinner solventDb; + @BindView(R.id.solvent_goodslv) + TextView solventGoodslv; + @BindView(R.id.solvent_goodslv_state) + LinearLayout solventGoodslvState; private boolean sanType; + private boolean sanLvType; @Override protected void onCreate(Bundle savedInstanceState) { @@ -44,26 +49,31 @@ public class SolventActivity extends BaseActivity { setContentView(R.layout.activity_solvent); ButterKnife.bind(this); sanType = true; + sanLvType = false; } private PlanView planView; @Override public void scanInfo(String info) { - - if (sanType) { - dialog.show(); - solventCode.setText(info); - selectSup(info); + if (sanLvType) { + solventGoodslv.setText(info.replace("%", "").trim()); } else { - try { - checkGoods(info); - } catch (Exception e) { - e.printStackTrace(); - Toast.makeText(this, "条码格式错误", Toast.LENGTH_SHORT).show(); + if (sanType) { + dialog.show(); + solventCode.setText(info); + String dbName = solventDb.getSelectedItem().toString(); + selectSup(info, dbName); + } else { + try { + checkGoods(info); + } catch (Exception e) { + e.printStackTrace(); + Toast.makeText(this, "条码格式错误", Toast.LENGTH_SHORT).show(); + } } - } + } @OnClick({R.id.info_title_back, R.id.solvent_scan, R.id.solvent_submit}) @@ -77,11 +87,18 @@ public class SolventActivity extends BaseActivity { break; case R.id.solvent_submit: if (planView == null) return; + String string1 = solventGoodslv.getText().toString(); + if (sanLvType && string1.isEmpty()) { + Toast.makeText(this, "必须扫描固含率", Toast.LENGTH_SHORT).show(); + return; + } String dbaname = solventDb.getSelectedItem().toString(); String string = solventCode.getText().toString(); + dialog.show(); planView.setWeighbridge(dbaname); planView.setCylinderBarCode(string); + planView.setRate(string1); RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;"), JSONObject.toJSONString(planView)); OkGo.post("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/ExecPlcState") @@ -108,28 +125,36 @@ public class SolventActivity extends BaseActivity { } } - private void selectSup(String info) { - OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/GetByCylinderInfo") + private void selectSup(String info, String dbName) { + OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Solvent/GetByCylinderInfo") .params("code", info) - .execute(new MyOkGoCallback() { + .params("weighbridge", dbName) + .execute(new StringCallback() { @Override - public void onSuccess(Response response) { - super.onSuccess(response); + public void onSuccess(Response response) { dialog.dismiss(); - if (response.body().isSuccess()) { - planView = JSONObject.parseObject(response.body().getData(), PlanView.class); + String body = response.body(); + Resust resust = JSONObject.parseObject(response.body(), Resust.class); + if (resust.isSuccess()) { + String substring = body.substring(body.indexOf(":{") + 1, body.length() - 1); + planView = JSONObject.parseObject(substring, PlanView.class); + Log.e("TAG", "onSuccess:" + planView.toString()); + if (planView.isExist()) { + solventGoodslvState.setVisibility(View.VISIBLE); + + } Toast.makeText(SolventActivity.this, "查询成功", Toast.LENGTH_SHORT).show(); sanType = false; } else { - Toast.makeText(SolventActivity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show(); + Toast.makeText(SolventActivity.this, resust.getMsg(), Toast.LENGTH_SHORT).show(); } } @Override - public void onError(Response response) { + public void onError(Response response) { super.onError(response); dialog.dismiss(); - Toast.makeText(SolventActivity.this, "网络请求失败", Toast.LENGTH_SHORT).show(); + Toast.makeText(SolventActivity.this, "网络连接错误", Toast.LENGTH_SHORT).show(); } }); } @@ -157,6 +182,7 @@ public class SolventActivity extends BaseActivity { if (planView.getMaterial_code().equals(goodsCode)) { planView.setState(1); tipDialog.showState(true); + sanLvType = true; } else { planView.setState(0); tipDialog.showState(false); diff --git a/app/src/main/java/com/example/pulit/X1Activity.java b/app/src/main/java/com/example/pulit/X1Activity.java index a435dc1..d0c567d 100644 --- a/app/src/main/java/com/example/pulit/X1Activity.java +++ b/app/src/main/java/com/example/pulit/X1Activity.java @@ -12,6 +12,7 @@ import android.widget.Toast; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.example.pulit.adapter.ItemAdapter; import com.example.pulit.entity.Item; @@ -53,7 +54,10 @@ public class X1Activity extends BaseActivity { private ItemAdapter adapter; private X1Submit entrySubmit; private ListPopupWindow lpw; - + private List planList; + private String kcode; + private int station; + private String pianId; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -64,8 +68,11 @@ public class X1Activity extends BaseActivity { adapter = new ItemAdapter(this); lpw = new ListPopupWindow(this); lpw.setAnchorView(x1Code1); - lpw.setAdapter(new ArrayAdapter(this, R.layout.support_simple_spinner_dropdown_item, Arrays.asList("B20230011", "B20230300", "B20230221", "B20230192", "B20230223"))); - lpw.setOnItemClickListener((adapterView, view, i, l) -> lpw.dismiss()); + lpw.setOnItemClickListener((adapterView, view, i, l) -> { + String planId = planList.get(i); + selectPlanByID(x1Code.getText().toString(), planId); + lpw.dismiss(); + }); } @Override @@ -108,23 +115,27 @@ public class X1Activity extends BaseActivity { break; case R.id.x1_submit: if (entrySubmit == null) return; - submit(entrySubmit,1); + for(Item item:items){ + if (!item.isState()){ + Toast.makeText(this, "还有物料未验证", Toast.LENGTH_SHORT).show(); + return; + } + } + submit(entrySubmit, 1); break; - case R.id.x1_submit2: + case R.id.x1_submit2: if (entrySubmit == null) return; - submit(entrySubmit,0); + submit(entrySubmit, 0); break; } } - private String kcode; - private int station; - private String pianId; -//提交 - private void submit(X1Submit entrySubmit,int state){ + + //提交 + private void submit(X1Submit entrySubmit, int state) { dialog.show(); - entrySubmit.setStates(state); + entrySubmit.setState(state); entrySubmit.setPlanId(pianId); RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;"), JSONObject.toJSONString(entrySubmit)); @@ -137,6 +148,10 @@ public class X1Activity extends BaseActivity { dialog.dismiss(); Toast.makeText(X1Activity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show(); if (response.body().isSuccess()) { + if (state == 1) { + tipDialog.showMsg(true, "提交成功"); + return; + } finish(); } } @@ -149,10 +164,42 @@ public class X1Activity extends BaseActivity { }); } + //查询 釜 private void getF(String info) { - OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/GetByCode") + OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/GetWarehousePlan") .params("code", info) + .execute(new MyOkGoCallback() { + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + dialog.dismiss(); + if (response.body().isSuccess()) { + planList = JSON.parseArray(response.body().getData(), String.class); + lpw.setAdapter(new ArrayAdapter(X1Activity.this, + R.layout.support_simple_spinner_dropdown_item, + planList)); + lpw.show(); + } else { + Toast.makeText(X1Activity.this, "请求失败,条码不正确", Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onError(Response response) { + super.onError(response); + dialog.dismiss(); + Toast.makeText(X1Activity.this, "网络请求失败", Toast.LENGTH_SHORT).show(); + } + } + ); + } + + //查询计划中的物料 + private void selectPlanByID(String code, String planID) { + OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/Warehouse/GetByCode") + .params("code", code) + .params("planId", planID) .execute(new MyOkGoCallback() { @Override public void onSuccess(Response response) { @@ -163,11 +210,10 @@ public class X1Activity extends BaseActivity { station = x1.getID();// kcode = x1.getBarCode();// items = x1.getChildren(); - pianId=x1.getPlanId(); + pianId = x1.getPlanId(); adapter.setList(items); x1RecyclerView.setAdapter(adapter); scanStates = false;//扫描 - lpw.show(); } else { Toast.makeText(X1Activity.this, "请求失败,条码不正确", Toast.LENGTH_SHORT).show(); } @@ -227,6 +273,8 @@ public class X1Activity extends BaseActivity { if (selectWeight - errorWeight <= goodsWeight && selectWeight + errorWeight >= goodsWeight) { entrySubmit.setState(1); tipDialog.showState(true); + selectItem.setState(true); + adapter.notifyDataSetChanged(); } else { tipDialog.showState(false); entrySubmit.setState(2); diff --git a/app/src/main/java/com/example/pulit/X2Activity.java b/app/src/main/java/com/example/pulit/X2Activity.java index 6893f8a..d80fc2c 100644 --- a/app/src/main/java/com/example/pulit/X2Activity.java +++ b/app/src/main/java/com/example/pulit/X2Activity.java @@ -1,6 +1,7 @@ package com.example.pulit; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.TextView; import android.widget.Toast; @@ -35,6 +36,7 @@ public class X2Activity extends BaseActivity { private boolean sanType; private int state = 0; private int Bin_Serial; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -42,7 +44,11 @@ public class X2Activity extends BaseActivity { ButterKnife.bind(this); sanType = true; } -//1A000001、000524 + + //1A000001、000524 + private String weight; + private String goodsCode; + @Override public void scanInfo(String info) { if (sanType) { @@ -50,19 +56,27 @@ public class X2Activity extends BaseActivity { selectSup(info); } else { x2Goods.setText(info); - if (info.contains("kg")) { +// if (info.contains("kg")) { + try { //整包 截取 - String goodsCode = info.substring(0, info.indexOf("-")); + goodsCode = info.substring(0, info.indexOf("-")); checkItem(goodsCode); x2GoodsCode.setText(goodsCode); int index = info.indexOf("-", info.indexOf("-", info.indexOf("-") + 1) + 1) + 1; int endIndex = info.indexOf("|"); String goodsName = info.substring(index, endIndex); x2GoodsName.setText(goodsName); - } else { - selectGoodsInfo(info); - + weight = info.substring(endIndex + 1, info.indexOf("kg")); + Log.e("TAG", "截取的重量:" + weight); + } catch (Exception e) { + e.printStackTrace(); + Toast.makeText(this, "条码错误", Toast.LENGTH_SHORT).show(); } + +// } else { +// selectGoodsInfo(info); +// +// } } @@ -95,15 +109,17 @@ public class X2Activity extends BaseActivity { dialog.show(); OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/xl_material/ExecPlcCode") - .params("code",Bin_Serial) - .params("state",state) + .params("code", Bin_Serial) + .params("state", state) + .params("materialCode", goodsCode) + .params("weight", weight) .execute(new MyOkGoCallback() { @Override public void onSuccess(Response response) { super.onSuccess(response); dialog.dismiss(); Toast.makeText(X2Activity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show(); - if (response.body().isSuccess()){ + if (response.body().isSuccess()) { finish(); } } @@ -130,9 +146,9 @@ public class X2Activity extends BaseActivity { if (response.body().isSuccess()) { JSONObject obj = response.body().getDateObj(); x2PlanCode.setText(obj.getString("Material_code")); - Bin_Serial=obj.getInteger("Bin_Serial"); + Bin_Serial = obj.getInteger("Bin_Serial"); x2PlanName.setText(obj.getString("Material_Name")); - sanType=false; + sanType = false; } else { Toast.makeText(X2Activity.this, "请求失败,条码不正确", Toast.LENGTH_SHORT).show(); x2PlanCode.setText(null); @@ -152,7 +168,7 @@ public class X2Activity extends BaseActivity { } - private void selectGoodsInfo(String info) { +/* private void selectGoodsInfo(String info) { dialog.show(); OkGo.get("http://" + SharedPreferencesUtils.getstring("ip", null) + "/api/xl_material/GetByMaterialCode") .params("code", info) @@ -183,7 +199,7 @@ public class X2Activity extends BaseActivity { } ); - } + }*/ } \ No newline at end of file diff --git a/app/src/main/java/com/example/pulit/adapter/ItemAdapter.java b/app/src/main/java/com/example/pulit/adapter/ItemAdapter.java index 6bf216d..d5be3ea 100644 --- a/app/src/main/java/com/example/pulit/adapter/ItemAdapter.java +++ b/app/src/main/java/com/example/pulit/adapter/ItemAdapter.java @@ -1,6 +1,8 @@ package com.example.pulit.adapter; +import android.annotation.SuppressLint; import android.content.Context; +import android.graphics.Color; import android.os.Build; import android.util.Log; import android.view.LayoutInflater; @@ -49,13 +51,22 @@ public class ItemAdapter extends RecyclerView.Adapter return new MyViewHolder(view); } + @Override public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { Item been = list.get(position); - holder.index.setText(position+1+""); + holder.code.setText(been.getMaterial_Code()); holder.name.setText(been.getMaterialName()); holder.number.setText(been.getSetWeight()+""); + if (been.isState()){ + holder.state.setText("正确"); + holder.state.setTextColor(Color.GREEN); + }else{ + holder.state.setText("未验证"); + holder.state.setTextColor(Color.RED); + } + } @@ -84,7 +95,7 @@ public class ItemAdapter extends RecyclerView.Adapter //如果要点击变色必须要写,用来固定view class MyViewHolder extends RecyclerView.ViewHolder { - TextView index; + TextView state; TextView code; TextView name; TextView number; @@ -92,7 +103,7 @@ public class ItemAdapter extends RecyclerView.Adapter public MyViewHolder(View view) { super(view); - index=view.findViewById(R.id.item_index); + state=view.findViewById(R.id.item_state); code=view.findViewById(R.id.item_code); name=view.findViewById(R.id.item_name); number=view.findViewById(R.id.item_weight); diff --git a/app/src/main/java/com/example/pulit/adapter/PlanAdapter.java b/app/src/main/java/com/example/pulit/adapter/PlanAdapter.java new file mode 100644 index 0000000..3763652 --- /dev/null +++ b/app/src/main/java/com/example/pulit/adapter/PlanAdapter.java @@ -0,0 +1,64 @@ +package com.example.pulit.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.example.pulit.R; +import com.example.pulit.entity.AxPlan; + +import java.util.List; +import java.util.Optional; + +/** + * @author wanghao + * @date 2023/11/3 10:59 + */ +public class PlanAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + + public PlanAdapter(Context context) { + this.context = context; + } + + public void setList(List list) { + this.list = list; + } + + @Override + public vm onCreateViewHolder(ViewGroup parent, int viewType) { + View inflate = LayoutInflater.from(context).inflate(R.layout.item_plan, parent, false); + return new vm(inflate); + } + + @Override + public void onBindViewHolder(PlanAdapter.vm holder, int position) { + AxPlan axPlan = list.get(position); + holder.index.setText(String.valueOf(position + 1)); + holder.planID.setText(axPlan.getPlan_Id()); + holder.planState.setText(axPlan.getPlan_StateText()); + } + + @Override + @NonNull + public int getItemCount() { + return Optional.ofNullable(list).map(List::size).orElse(0); + } + + public class vm extends RecyclerView.ViewHolder { + private TextView index, planID, planState; + + public vm(View view) { + super(view); + index = view.findViewById(R.id.item_plan_index); + planID = view.findViewById(R.id.item_plan_id); + planState = view.findViewById(R.id.item_plan_state); + } + } +} diff --git a/app/src/main/java/com/example/pulit/entity/AxPlan.java b/app/src/main/java/com/example/pulit/entity/AxPlan.java new file mode 100644 index 0000000..6678a67 --- /dev/null +++ b/app/src/main/java/com/example/pulit/entity/AxPlan.java @@ -0,0 +1,116 @@ +package com.example.pulit.entity; + +/** + * @author wanghao + * @date 2023/11/3 11:14 + */ +public class AxPlan { + private String Plan_Id; //计划ID + private int Plan_Num;//计划执行数量 + private int Real_Num;//实际执行数量 + private int Plan_Serial;//划序号,我拿来传给PLC作为了唯一值 + private String Plan_Date;//计划执行时间 + private int Plan_State;//计划执行状态 + private String Plan_StateText;//中文状态标识 + private double Plan_TotalError;//合计误差 + private int Plan_TotalWeight;//合计重量 + private String RecipeID;// 配方ID + private String Recipe_Code;// 配方条码 + private String Recipe_Name;//配方名称 + + public String getPlan_Id() { + return Plan_Id; + } + + public void setPlan_Id(String plan_Id) { + Plan_Id = plan_Id; + } + + public int getPlan_Num() { + return Plan_Num; + } + + public void setPlan_Num(int plan_Num) { + Plan_Num = plan_Num; + } + + public int getReal_Num() { + return Real_Num; + } + + public void setReal_Num(int real_Num) { + Real_Num = real_Num; + } + + public int getPlan_Serial() { + return Plan_Serial; + } + + public void setPlan_Serial(int plan_Serial) { + Plan_Serial = plan_Serial; + } + + public String getPlan_Date() { + return Plan_Date; + } + + public void setPlan_Date(String plan_Date) { + Plan_Date = plan_Date; + } + + public int getPlan_State() { + return Plan_State; + } + + public void setPlan_State(int plan_State) { + Plan_State = plan_State; + } + + public String getPlan_StateText() { + return Plan_StateText; + } + + public void setPlan_StateText(String plan_StateText) { + Plan_StateText = plan_StateText; + } + + public double getPlan_TotalError() { + return Plan_TotalError; + } + + public void setPlan_TotalError(double plan_TotalError) { + Plan_TotalError = plan_TotalError; + } + + public int getPlan_TotalWeight() { + return Plan_TotalWeight; + } + + public void setPlan_TotalWeight(int plan_TotalWeight) { + Plan_TotalWeight = plan_TotalWeight; + } + + public String getRecipeID() { + return RecipeID; + } + + public void setRecipeID(String recipeID) { + RecipeID = recipeID; + } + + public String getRecipe_Code() { + return Recipe_Code; + } + + public void setRecipe_Code(String recipe_Code) { + Recipe_Code = recipe_Code; + } + + public String getRecipe_Name() { + return Recipe_Name; + } + + public void setRecipe_Name(String recipe_Name) { + Recipe_Name = recipe_Name; + } +} 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 1458839..94419da 100644 --- a/app/src/main/java/com/example/pulit/entity/Item.java +++ b/app/src/main/java/com/example/pulit/entity/Item.java @@ -12,6 +12,7 @@ public class Item { private String Material_Code; private double SetWeight; private double SetError; + private boolean state=false; public double getSetError() { return SetError; @@ -69,6 +70,14 @@ public class Item { SetWeight = setWeight; } + public boolean isState() { + return state; + } + + public void setState(boolean state) { + this.state = state; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/app/src/main/java/com/example/pulit/entity/PlanView.java b/app/src/main/java/com/example/pulit/entity/PlanView.java index df3d782..b95256c 100644 --- a/app/src/main/java/com/example/pulit/entity/PlanView.java +++ b/app/src/main/java/com/example/pulit/entity/PlanView.java @@ -40,6 +40,9 @@ public class PlanView { private String Weighbridge;//9.25新增 地磅 private String CylinderBarCode;//9.25新增 地磅 + private boolean Exist; + private String Rate; + public String getCylinderBarCode() { return CylinderBarCode; } @@ -280,6 +283,22 @@ public class PlanView { State = state; } + public boolean isExist() { + return Exist; + } + + public void setExist(boolean exist) { + Exist = exist; + } + + public String getRate() { + return Rate; + } + + public void setRate(String rate) { + Rate = rate; + } + @Override public String toString() { return "PlanView{" + @@ -304,12 +323,17 @@ public class PlanView { ", Material_name='" + Material_name + '\'' + ", Set_Weight=" + Set_Weight + ", Set_Error=" + Set_Error + + ", Material_code='" + Material_code + '\'' + ", RMatCode=" + RMatCode + ", Code='" + Code + '\'' + ", MaterialName='" + MaterialName + '\'' + ", MaterialWeight=" + MaterialWeight + ", WholeMaterial='" + WholeMaterial + '\'' + ", State=" + State + + ", Weighbridge='" + Weighbridge + '\'' + + ", CylinderBarCode='" + CylinderBarCode + '\'' + + ", IsRate=" + isExist() + + ", Rate='" + Rate + '\'' + '}'; } } diff --git a/app/src/main/java/com/example/pulit/entity/X1Submit.java b/app/src/main/java/com/example/pulit/entity/X1Submit.java index 9e71626..1958800 100644 --- a/app/src/main/java/com/example/pulit/entity/X1Submit.java +++ b/app/src/main/java/com/example/pulit/entity/X1Submit.java @@ -13,7 +13,7 @@ public class X1Submit { private int state;//状态 0:未扫描 1:匹配 2:报警 private String wholePackage; private String PlanId; //计划ID - private int State; + public String getPlanId() { return PlanId; @@ -71,13 +71,7 @@ public class X1Submit { this.state = state; } - public int getStateS() { - return State; - } - public void setStates(int state) { - this.State = state; - } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5396999..8af27ce 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -72,7 +72,12 @@ style="@style/TabRadioButton" android:drawableTop="@mipmap/home_rj" android:text="液体核对" /> - + + + + + + + + + + + + + + + + + +