From bdebc8c98a56500ee7befabac07d42728574d4c2 Mon Sep 17 00:00:00 2001 From: wangh <123456> Date: Mon, 4 Dec 2023 15:49:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20-=20=E8=BF=94=E4=BF=AE?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/aucma_mes/BindingActivity.java | 57 ++++----------- .../com/example/aucma_mes/CheckActivity.java | 5 +- .../example/aucma_mes/HomePageActivity.java | 4 +- .../com/example/aucma_mes/RepairActivity.java | 71 ++++++++++++------ .../aucma_mes/adapter/RepairAdapter.java | 5 +- .../example/aucma_mes/base/BaseActivity.java | 54 +++++++++++--- .../example/aucma_mes/entity/DefectBeen.java | 29 +++++++- .../aucma_mes/entity/RepairMeasures.java | 9 +++ .../aucma_mes/entity/RepairSubmitInfo.java | 56 ++++++++++++++ .../com/example/aucma_mes/vm/RepairVm.java | 47 ++++++++++-- app/src/main/res/drawable/button_true.xml | 2 +- .../main/res/layout/activity_home_page.xml | 2 +- app/src/main/res/layout/activity_repair.xml | 73 ++++++++++--------- 13 files changed, 281 insertions(+), 133 deletions(-) create mode 100644 app/src/main/java/com/example/aucma_mes/entity/RepairSubmitInfo.java diff --git a/app/src/main/java/com/example/aucma_mes/BindingActivity.java b/app/src/main/java/com/example/aucma_mes/BindingActivity.java index a2703cd..503d0cb 100644 --- a/app/src/main/java/com/example/aucma_mes/BindingActivity.java +++ b/app/src/main/java/com/example/aucma_mes/BindingActivity.java @@ -45,32 +45,22 @@ public class BindingActivity extends BaseActivity { @Override protected void sanInfo(String code) { - char c = code.charAt(0); - if (title.equals("壳胆绑定")) { - if (c == 'B') { - boxCode.set(code); - selectGoodsName(code); - } else if (c == 'L') { - innerCode.set(code); - } else { - Toast.makeText(this, "条码格式不对", Toast.LENGTH_SHORT).show(); - } + if (c == 'B') { + boxCode.set(code); + selectGoodsName(code); + } else if (c == 'L' && title.equals("壳胆绑定")) { + innerCode.set(code); + } else if (title.equals("条码绑定") && code.length() >= 21) { + innerCode.set(code); } else { - if (c == 'B') { - boxCode.set(code); - selectGoodsName(code); - } else { - innerCode.set(code); - } + Toast.makeText(this, "条码格式不对", Toast.LENGTH_SHORT).show(); } - - } public void click1(View view) { - if (boxCode.get() == null || innerCode.get() == null) return; + if (boxCode.get() == null || innerCode.get() == null ||materialName.get()==null ) return; dialog.show(); String s = title.equals("壳胆绑定") ? "/api/boxBanding" : "/api/barCodeBanding"; @@ -103,27 +93,12 @@ public class BindingActivity extends BaseActivity { innerCode.set(null); } - private String codeTag = ""; - - private void selectGoodsName(String code) { - if (codeTag.equals(code)) return; - codeTag = code; - OkGo.post(url + "/api/selectGoodsName") - .tag(this) - .headers("Authorization", SharedPreferencesUtils.getstring("token", "")) - .params("code", code) - .execute(new MyRecultCall(dialog,this){ - @Override - public void onSuccess(Response response) { - super.onSuccess(response); - Result result = response.body(); - if (result.getCode()==200){ - Toast.makeText(BindingActivity.this, "查询成功", Toast.LENGTH_SHORT).show(); - materialName.set(result.getData().toString()); - }else { - Toast.makeText(BindingActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); - } - } - }); + // private String codeTag = ""; + + + @Override + public void goodsNameCall(String code) { + super.goodsNameCall(code); + materialName.set(code); } } \ No newline at end of file diff --git a/app/src/main/java/com/example/aucma_mes/CheckActivity.java b/app/src/main/java/com/example/aucma_mes/CheckActivity.java index abc6b82..bf260af 100644 --- a/app/src/main/java/com/example/aucma_mes/CheckActivity.java +++ b/app/src/main/java/com/example/aucma_mes/CheckActivity.java @@ -45,8 +45,6 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte private List list; private List submitList; private OptionsPickerView opv; - - private List options1; private List> options2; private List>> options3; @@ -64,7 +62,6 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte String stationCode = getIntent().getStringExtra("stationCode"); // 三联 opv = new OptionsPickerBuilder(this, this).build(); - OkGo.get(url + "/base/qualityInspectionItem/getQualityDefects/" + stationCode).tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).execute(new MyRecultCall(dialog, this) { @Override public void onSuccess(Response response) { @@ -161,7 +158,7 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte checkAdapter.notifyDataSetChanged(); } - +//三联添加 @Override public void onOptionsSelect(int options1, int options2, int options3, View v) { diff --git a/app/src/main/java/com/example/aucma_mes/HomePageActivity.java b/app/src/main/java/com/example/aucma_mes/HomePageActivity.java index 9e8e139..fcae534 100644 --- a/app/src/main/java/com/example/aucma_mes/HomePageActivity.java +++ b/app/src/main/java/com/example/aucma_mes/HomePageActivity.java @@ -46,14 +46,14 @@ public class HomePageActivity extends AppCompatActivity { } - String finalStationCode = stationCode; +// String finalStationCode = stationCode; binding.homeButton1.setOnClickListener(v -> { // if (!roles.contains("quality_inspection")) { // Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); // return; // } intent = new Intent(this, CheckActivity.class); - intent.putExtra("stationCode", "2001"); + intent.putExtra("stationCode", "20 01"); startActivity(intent); }); binding.homeButton2.setOnClickListener(v -> { diff --git a/app/src/main/java/com/example/aucma_mes/RepairActivity.java b/app/src/main/java/com/example/aucma_mes/RepairActivity.java index 3f3229c..0fb50e9 100644 --- a/app/src/main/java/com/example/aucma_mes/RepairActivity.java +++ b/app/src/main/java/com/example/aucma_mes/RepairActivity.java @@ -1,19 +1,18 @@ package com.example.aucma_mes; -import androidx.appcompat.app.AppCompatActivity; import androidx.databinding.DataBindingUtil; +import android.annotation.SuppressLint; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Toast; -import com.example.aucma_mes.adapter.CheckAdapter; import com.example.aucma_mes.adapter.RepairAdapter; import com.example.aucma_mes.base.BaseActivity; -import com.example.aucma_mes.databinding.ActivityMainBinding; import com.example.aucma_mes.databinding.ActivityRepairBinding; import com.example.aucma_mes.entity.DefectBeen; +import com.example.aucma_mes.entity.RepairSubmitInfo; import com.example.aucma_mes.entity.RepairMeasures; import com.example.aucma_mes.entity.Result; import com.example.aucma_mes.utils.MyRecultCall; @@ -26,12 +25,16 @@ import com.lzy.okgo.model.Response; import java.util.ArrayList; import java.util.List; -public class RepairActivity extends BaseActivity implements CheckAdapter.CheckItemClickCall { +import okhttp3.MediaType; +import okhttp3.RequestBody; + +public class RepairActivity extends BaseActivity { private ActivityRepairBinding binding; private RepairVm repairVm; private RepairAdapter adapter; - private List defectBeens; + private List defectBeens; + private List submitList; @Override protected void onCreate(Bundle savedInstanceState) { @@ -40,20 +43,21 @@ public class RepairActivity extends BaseActivity implements CheckAdapter.CheckIt adapter = new RepairAdapter(this); repairVm = new RepairVm(); binding.setVm(repairVm); + submitList = new ArrayList<>(); binding.recyclerView.setAdapter(adapter); +//查询返修措施 OkGo.get(url + "/report/repairMeasures/getRepairMeasures").tag(this) .headers("Authorization", SharedPreferencesUtils.getstring("token", "")) .execute(new MyRecultCall(dialog, this) { @Override public void onSuccess(Response response) { Result result = response.body(); - if (result.getCode()==200){ - Log.e("TAG", "真实类型:" + result.getData().getClass()); - List repairList=gson.fromJson(gson.toJson(result.getData()) - ,new TypeToken< List>(){}.getType()); + if (result.getCode() == 200) { + List repairList = gson.fromJson(gson.toJson(result.getData()) + , new TypeToken>() { + }.getType()); repairVm.setRepairList(repairList); - - }else { + } else { Toast.makeText(RepairActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); } } @@ -65,18 +69,21 @@ public class RepairActivity extends BaseActivity implements CheckAdapter.CheckIt repairVm.setCode(code); OkGo.post(url + "/api/findCheckInfoByCode").tag(this) .headers("Authorization", SharedPreferencesUtils.getstring("token", "")) - .params("code",code) + .params("code", code) .execute(new MyRecultCall(dialog, this) { + @SuppressLint("NotifyDataSetChanged") @Override public void onSuccess(Response response) { Result result = response.body(); - if (result.getCode()==200){ - - defectBeens = gson.fromJson(result.getData().toString() - ,new TypeToken>(){}.getType()); + if (result.getCode() == 200) { + defectBeens = gson.fromJson(result.getData().toString(), new TypeToken>() { + }.getType()); +// Log.e("TAG", "onSuccess:" + defectBeens.toString()); + defectBeens.forEach(t -> submitList.add(t.getObjId())); adapter.setList(defectBeens); adapter.notifyDataSetChanged(); - }else { + repairVm.setMaterialName(defectBeens.get(0).getMaterialName()); + } else { Toast.makeText(RepairActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); repairSubmit(null); } @@ -85,13 +92,31 @@ public class RepairActivity extends BaseActivity implements CheckAdapter.CheckIt } public void repairSubmit(View view) { - defectBeens.clear(); - adapter.notifyDataSetChanged(); - repairVm.setCode(null); + if (submitList.isEmpty()) return; + RepairSubmitInfo repairSubmitInfo =new RepairSubmitInfo(submitList, + SharedPreferencesUtils.getstring("userName", "pda01") + ,repairVm.getRepairName(),repairVm.getIsFlag()); + MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + RequestBody body = RequestBody.create(JSON,gson.toJson(repairSubmitInfo) ); + OkGo.post(url + "/api/submitRepair") + .tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")) + .upRequestBody(body) + .execute(new MyRecultCall(dialog, this) { + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + Result result = response.body(); + Toast.makeText(RepairActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); + if (result.getCode()==200){ + defectBeens.clear(); + adapter.notifyDataSetChanged(); + repairVm.setCode(null); + repairVm.setMaterialName(null); + submitList.clear(); + } + } + }); } - @Override - public void onClick(int positon) { - } } \ No newline at end of file diff --git a/app/src/main/java/com/example/aucma_mes/adapter/RepairAdapter.java b/app/src/main/java/com/example/aucma_mes/adapter/RepairAdapter.java index 2a728ab..20fce04 100644 --- a/app/src/main/java/com/example/aucma_mes/adapter/RepairAdapter.java +++ b/app/src/main/java/com/example/aucma_mes/adapter/RepairAdapter.java @@ -57,7 +57,7 @@ public class RepairAdapter extends RecyclerView.Adapterpost(url + "/api/selectGoodsName") + .tag(this) + .headers("Authorization", SharedPreferencesUtils.getstring("token", "")) + .params("code", code) + .execute(new MyRecultCall(dialog,this){ + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + Result result = response.body(); + if (result.getCode()==200){ + Toast.makeText(BaseActivity.this, "查询成功", Toast.LENGTH_SHORT).show(); + goodsNameCall(result.getData().toString()) ; + }else { + Toast.makeText(BaseActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); + goodsNameCall(null) ; + } + } + }); + } @Override protected void onDestroy() { super.onDestroy(); // 注销广播接收器 unregisterReceiver(receiver); } - private class MyBroad extends BroadcastReceiver{ + + private class MyBroad extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - sanInfo(intent.getStringExtra("data")) ; + sanInfo(intent.getStringExtra("data")); } } } \ No newline at end of file diff --git a/app/src/main/java/com/example/aucma_mes/entity/DefectBeen.java b/app/src/main/java/com/example/aucma_mes/entity/DefectBeen.java index b60b8c8..24d4ba9 100644 --- a/app/src/main/java/com/example/aucma_mes/entity/DefectBeen.java +++ b/app/src/main/java/com/example/aucma_mes/entity/DefectBeen.java @@ -12,12 +12,13 @@ public class DefectBeen extends BaseObservable { - public int index; - public int objId; + private int index; + private int objId; + private String materialName; private String materialCategories; private String materialSubclass; - public String qualityDefectCode; - public String qualityDefectName; + private String qualityDefectCode; + private String qualityDefectName; @@ -85,4 +86,24 @@ public class DefectBeen extends BaseObservable { this.qualityDefectName = qualityDefectName; } + public String getMaterialName() { + return materialName; + } + + public void setMaterialName(String materialName) { + this.materialName = materialName; + } + + @Override + public String toString() { + return "DefectBeen{" + + "index=" + index + + ", objId=" + objId + + ", materialName='" + materialName + '\'' + + ", materialCategories='" + materialCategories + '\'' + + ", materialSubclass='" + materialSubclass + '\'' + + ", qualityDefectCode='" + qualityDefectCode + '\'' + + ", qualityDefectName='" + qualityDefectName + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/example/aucma_mes/entity/RepairMeasures.java b/app/src/main/java/com/example/aucma_mes/entity/RepairMeasures.java index 8605d25..dd746d0 100644 --- a/app/src/main/java/com/example/aucma_mes/entity/RepairMeasures.java +++ b/app/src/main/java/com/example/aucma_mes/entity/RepairMeasures.java @@ -11,6 +11,15 @@ public class RepairMeasures { //"repairName": "返回生产线" private String repairCode; private String repairName; + private int isFlag; + + public int getIsFlag() { + return isFlag; + } + + public void setIsFlag(int isFlag) { + this.isFlag = isFlag; + } public String getRepairCode() { return repairCode; diff --git a/app/src/main/java/com/example/aucma_mes/entity/RepairSubmitInfo.java b/app/src/main/java/com/example/aucma_mes/entity/RepairSubmitInfo.java new file mode 100644 index 0000000..c9a8a80 --- /dev/null +++ b/app/src/main/java/com/example/aucma_mes/entity/RepairSubmitInfo.java @@ -0,0 +1,56 @@ +package com.example.aucma_mes.entity; + +import java.util.List; + +/** + * @author wanghao + * @date 2023/12/4 15:05 + */ +public class RepairSubmitInfo { + private List list; + private String loginName; + private String repairName; + private int isFlag; + + public RepairSubmitInfo(List list, String loginName, String repairName, int isFlag) { + this.list = list; + this.loginName = loginName; + this.repairName = repairName; + this.isFlag = isFlag; + } + + public RepairSubmitInfo() { + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public String getLoginName() { + return loginName; + } + + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + public String getRepairName() { + return repairName; + } + + public void setRepairName(String repairName) { + this.repairName = repairName; + } + + public int getIsFlag() { + return isFlag; + } + + public void setIsFlag(int isFlag) { + this.isFlag = isFlag; + } +} diff --git a/app/src/main/java/com/example/aucma_mes/vm/RepairVm.java b/app/src/main/java/com/example/aucma_mes/vm/RepairVm.java index 0ee33c8..5694944 100644 --- a/app/src/main/java/com/example/aucma_mes/vm/RepairVm.java +++ b/app/src/main/java/com/example/aucma_mes/vm/RepairVm.java @@ -18,14 +18,18 @@ import java.util.List; */ public class RepairVm extends BaseObservable { public String code;//扫描条码 - private String repairCode;//处理措施 - + private String materialName;//扫描条码 + //处理措施 + private String repairName; + private int isFlag; public List stringList; private List repairList; public void onItemClick(AdapterView parent, View view, int position, long id) { Log.e("TAG", "返修选中措施:" + position); - this.repairCode = repairList.get(position).getRepairCode(); + RepairMeasures repairMeasures = repairList.get(position); + setRepairName(repairMeasures.getRepairName()); + setIsFlag(repairMeasures.getIsFlag()); } public void setRepairList(List repairList) { this.repairList = repairList; @@ -43,13 +47,40 @@ public class RepairVm extends BaseObservable { notifyChange(); } - public String getRepairCode() { - return repairCode; + public String getRepairName() { + return repairName; + } + + public void setRepairName(String repairName) { + this.repairName = repairName; + } + + public int getIsFlag() { + return isFlag; + } + + public void setIsFlag(int isFlag) { + this.isFlag = isFlag; } - public void setRepairCode(String name) { - int i = stringList.indexOf(name); - this.repairCode = repairList.get(i).getRepairCode(); + public List getStringList() { + return stringList; + } + public void setStringList(List stringList) { + this.stringList = stringList; + } + + public List getRepairList() { + return repairList; + } + + public String getMaterialName() { + return materialName; + } + + public void setMaterialName(String materialName) { + this.materialName = materialName; + notifyChange(); } } diff --git a/app/src/main/res/drawable/button_true.xml b/app/src/main/res/drawable/button_true.xml index f685f3a..3d29c65 100644 --- a/app/src/main/res/drawable/button_true.xml +++ b/app/src/main/res/drawable/button_true.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_home_page.xml b/app/src/main/res/layout/activity_home_page.xml index 28b8128..869190d 100644 --- a/app/src/main/res/layout/activity_home_page.xml +++ b/app/src/main/res/layout/activity_home_page.xml @@ -68,7 +68,7 @@ android:id="@+id/home_button5" style="@style/radio_button_style" android:drawableTop="@mipmap/icon_info" - android:text="登录信息查询" + android:text="班次确认" app:layout_columnWeight="1" /> diff --git a/app/src/main/res/layout/activity_repair.xml b/app/src/main/res/layout/activity_repair.xml index 8f9f237..e39335a 100644 --- a/app/src/main/res/layout/activity_repair.xml +++ b/app/src/main/res/layout/activity_repair.xml @@ -10,21 +10,18 @@ type="com.example.aucma_mes.vm.RepairVm" /> - + tools:context=".RepairActivity" + android:orientation="vertical"> + android:layout_marginEnd="4dp"> + + + + + + + + + android:textColor="@color/blue" + android:text="缺陷详情" /> + android:background="@color/white" /> + android:orientation="horizontal"> - - + android:text="提交" /> + \ No newline at end of file