From 4bb8d2b19b287faf839034619d20195cf2965d52 Mon Sep 17 00:00:00 2001 From: wangh <123456> Date: Thu, 28 Dec 2023 14:50:53 +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 --- app/src/main/AndroidManifest.xml | 14 +- .../example/aucma_mes/BindingActivity.java | 1 + .../com/example/aucma_mes/CheckActivity.java | 159 ++++++++++------ .../example/aucma_mes/HomePageActivity.java | 40 +++-- .../com/example/aucma_mes/MainActivity.java | 154 +++++++++------- .../com/example/aucma_mes/RepairActivity.java | 4 +- .../adapter/RepaitSubmintInfoAdapter.java | 83 +++++++++ .../example/aucma_mes/base/BaseActivity.java | 4 +- .../dialog/RepairSubmintInfoDialog.java | 45 +++++ .../example/aucma_mes/entity/DefectBeen.java | 15 +- .../example/aucma_mes/entity/TeamBeen.java | 26 +++ .../example/aucma_mes/utils/MyRecultCall.java | 4 +- .../example/aucma_mes/vm/CheckViewModel.java | 84 +++++---- .../java/com/example/aucma_mes/vm/User.java | 68 ++++++- .../res/drawable/ic_launcher_background.xml | 170 ------------------ .../res/drawable/ic_launcher_foreground.xml | 30 ---- app/src/main/res/layout/activity_check.xml | 23 ++- .../main/res/layout/activity_home_page.xml | 2 +- app/src/main/res/layout/activity_main.xml | 42 +++-- app/src/main/res/layout/dialog_info.xml | 10 +- .../res/layout/dialog_repair_submint_info.xml | 41 +++++ app/src/main/res/layout/item_layout.xml | 6 +- app/src/main/res/layout/item_repair_info.xml | 64 +++++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 6 - .../mipmap-anydpi-v26/ic_launcher_round.xml | 6 - app/src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 1404 -> 0 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 2898 -> 0 bytes app/src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 982 -> 0 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 1772 -> 0 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 1900 -> 0 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 3918 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 2884 -> 0 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 5914 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 3844 -> 0 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 7778 -> 0 bytes app/src/main/res/values/strings.xml | 2 +- gradle.properties | 1 + 37 files changed, 669 insertions(+), 435 deletions(-) create mode 100644 app/src/main/java/com/example/aucma_mes/adapter/RepaitSubmintInfoAdapter.java create mode 100644 app/src/main/java/com/example/aucma_mes/dialog/RepairSubmintInfoDialog.java create mode 100644 app/src/main/java/com/example/aucma_mes/entity/TeamBeen.java delete mode 100644 app/src/main/res/drawable/ic_launcher_background.xml delete mode 100644 app/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 app/src/main/res/layout/dialog_repair_submint_info.xml create mode 100644 app/src/main/res/layout/item_repair_info.xml delete mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml delete mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml delete mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.webp delete mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.webp delete mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.webp delete mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.webp delete mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.webp delete mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp delete mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.webp delete mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp delete mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp delete mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a817741..f3cb16b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,9 +9,9 @@ android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" - android:icon="@mipmap/ic_launcher" + android:icon="@mipmap/logo2" android:label="@string/app_name" - android:roundIcon="@mipmap/ic_launcher_round" + android:roundIcon="@mipmap/logo2" android:supportsRtl="true" android:theme="@style/Theme.Aucmames" tools:targetApi="31"> @@ -32,15 +32,15 @@ - - - - + - + + + + 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 503d0cb..cccb5bd 100644 --- a/app/src/main/java/com/example/aucma_mes/BindingActivity.java +++ b/app/src/main/java/com/example/aucma_mes/BindingActivity.java @@ -74,6 +74,7 @@ public class BindingActivity extends BaseActivity { Toast.makeText(BindingActivity.this, "绑定成功", Toast.LENGTH_SHORT).show(); boxCode.set(""); innerCode.set(""); + materialName.set(""); } else { Toast.makeText(BindingActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); } 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 bf260af..3f704bb 100644 --- a/app/src/main/java/com/example/aucma_mes/CheckActivity.java +++ b/app/src/main/java/com/example/aucma_mes/CheckActivity.java @@ -17,8 +17,10 @@ import com.bigkoo.pickerview.builder.OptionsPickerBuilder; import com.bigkoo.pickerview.listener.OnOptionsSelectListener; import com.bigkoo.pickerview.view.OptionsPickerView; import com.example.aucma_mes.adapter.CheckAdapter; +import com.example.aucma_mes.adapter.RepaitSubmintInfoAdapter; import com.example.aucma_mes.base.BaseActivity; import com.example.aucma_mes.databinding.ActivityCheckBinding; +import com.example.aucma_mes.dialog.RepairSubmintInfoDialog; import com.example.aucma_mes.entity.DefectBeen; import com.example.aucma_mes.entity.DictBeen; import com.example.aucma_mes.entity.Result; @@ -36,18 +38,19 @@ import java.util.List; import okhttp3.RequestBody; -public class CheckActivity extends BaseActivity implements CheckAdapter.CheckItemClickCall/*, AdapterView.OnItemClickListener*/, OnOptionsSelectListener { +public class CheckActivity extends BaseActivity implements CheckAdapter.CheckItemClickCall/*, AdapterView.OnItemClickListener*/, OnOptionsSelectListener, RepaitSubmintInfoAdapter.CheckItemClickCall { private ActivityCheckBinding binding; private CheckViewModel checkViewModel; - // private ListPopupWindow listPopupWindow; + private RepairSubmintInfoDialog tipDialog; private CheckAdapter checkAdapter; private List list; - private List submitList; + private List submitList;// 提交缺陷列表 private OptionsPickerView opv; private List options1; private List> options2; private List>> options3; + private List topDefects; @Override protected void onCreate(Bundle savedInstanceState) { @@ -60,7 +63,92 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte checkAdapter.setList(submitList); binding.recyclerView.setAdapter(checkAdapter); String stationCode = getIntent().getStringExtra("stationCode"); -// 三联 + checkViewModel.setStationCode(stationCode); + // 三联 + initOptionpb(stationCode); + tipDialog = new RepairSubmintInfoDialog(this, this); + } + + // 扫码 + @Override + protected void sanInfo(String code) { + checkViewModel.setCode(code); + OkGo.post(url + "/api/check/select").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) { + checkViewModel.setName(result.getMsg()); + topDefects = gson.fromJson(gson.toJson(result.getData()), new TypeToken>() { + }.getType()); + if (topDefects == null || topDefects.isEmpty()) { + Toast.makeText(CheckActivity.this, "本工位无需检查返修情况", Toast.LENGTH_SHORT).show(); + return; + } + checkViewModel.setButtonVisbleState(true); + tipDialog.setList(topDefects); + tipDialog.show(); + + /*// 直接添加提交数据中submitList.addAll(defectBeens); + checkAdapter.notifyDataSetChanged();*/ + } else { + Toast.makeText(CheckActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); + } + } + }); + } + + // 弹出选择框 + public void checkSelect(View view) { + opv.show(); + } + + // 弹出返修 + public void selectRepair(View view) { + tipDialog.show(); + } + + // 提交 + public void checkSubmint(View view) { + if (checkViewModel.getName() == null || checkViewModel.getName().isEmpty()) return; + checkViewModel.setList(submitList); + checkViewModel.setMeasure(submitList.isEmpty() ? "3" : "1"); + checkViewModel.setUserName(SharedPreferencesUtils.getstring("userName", "pda01")); + checkViewModel.setTeamCode(SharedPreferencesUtils.getstring("teamCode",null)); + OkGo.post(url + "/api/checkSubmit").tag(this) + .headers("Authorization", SharedPreferencesUtils.getstring("token", "")) + .upRequestBody(RequestBody.create(JSON, gson.toJson(checkViewModel))).execute(new MyRecultCall(dialog, this) { + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + Result result = response.body(); + if (result.getCode() == 200) { + Toast.makeText(CheckActivity.this, "提交成功", Toast.LENGTH_SHORT).show(); + checkViewModel.setCode(null); + checkViewModel.setName(null); + checkViewModel.setDefect(null); + checkViewModel.setButtonVisbleState(false); + submitList.clear(); + checkAdapter.notifyDataSetChanged(); + } else { + Toast.makeText(CheckActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); + } + } + }); + } + + // 删除缺陷 + @Override + public void onClick(int positon) { + Log.e("TAG", "列表点击:" + positon); + submitList.remove(positon); + checkAdapter.notifyDataSetChanged(); + } + + // 初始化-联动选择 + private void initOptionpb(String 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 @@ -105,9 +193,6 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte options3.get(index1).get(index2).add(qualityDefectName); } }); -// Log.e("TAG", "options1:" + options1.toString()); -// Log.e("TAG", "options2:" + options2.toString()); -// Log.e("TAG", "options3:" + options3.toString()); opv.setPicker(options1, options2, options3); } else { Toast.makeText(CheckActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show(); @@ -115,60 +200,16 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte } }); - - } - - @Override - protected void sanInfo(String code) { - checkViewModel.setCode(code); - } - - //弹出框 - public void checkSelect(View view) { - opv.show(); - - } - - //提交 - public void checkSubmint(View view) { - checkViewModel.setList(submitList); - checkViewModel.setUserName(SharedPreferencesUtils.getstring("userName", "pda01")); - OkGo.post(url + "/api/checkSubmit").tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).upRequestBody(RequestBody.create(JSON, gson.toJson(checkViewModel))).execute(new MyRecultCall(dialog, this) { - @Override - public void onSuccess(Response response) { - super.onSuccess(response); - Result result = response.body(); - if (result.getCode() == 200) { - Toast.makeText(CheckActivity.this, "提交成功", Toast.LENGTH_SHORT).show(); - checkViewModel.setCode(null); - submitList.clear(); - checkAdapter.notifyDataSetChanged(); - } else { - Toast.makeText(CheckActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); - } - } - }); - } - - // 删除缺陷 - @Override - public void onClick(int positon) { - Log.e("TAG", "列表点击:" + positon); - submitList.remove(positon); - checkAdapter.notifyDataSetChanged(); } -//三联添加 + // 三联添加 @Override public void onOptionsSelect(int options1, int options2, int options3, View v) { - String defectName = this.options3.get(options1).get(options2).get(options3); checkViewModel.setDefect(defectName); DefectBeen defectBeen = new DefectBeen(); defectBeen.setQualityDefectName(defectName); - DefectBeen defectBeen1 = list.get(list.indexOf(defectBeen)); - if (submitList.contains(defectBeen1)) { Toast.makeText(this, "已经添加了", Toast.LENGTH_SHORT).show(); return; @@ -176,4 +217,18 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte submitList.add(defectBeen1); checkAdapter.notifyDataSetChanged(); } + + // 返修添加提交数据中 + @Override + public void submintRepair(int positon) { + DefectBeen defectBeen = topDefects.get(positon); + if (submitList.contains(defectBeen)) { + Toast.makeText(this, "已经添加了", Toast.LENGTH_SHORT).show(); + return; + } + Log.e("TAG", "返修提交的ID:" + defectBeen.getObjId()); + submitList.add(defectBeen); + checkAdapter.notifyDataSetChanged(); + Toast.makeText(this, "添加成功", Toast.LENGTH_SHORT).show(); + } } \ No newline at end of file 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 fcae534..22c13dd 100644 --- a/app/src/main/java/com/example/aucma_mes/HomePageActivity.java +++ b/app/src/main/java/com/example/aucma_mes/HomePageActivity.java @@ -13,6 +13,7 @@ import android.widget.Toast; import com.example.aucma_mes.databinding.ActivityHomePageBinding; import com.example.aucma_mes.dialog.InfoDialog; import com.example.aucma_mes.entity.LoginInfoBeen; +import com.example.aucma_mes.utils.SharedPreferencesUtils; import com.example.aucma_mes.vm.User; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -38,7 +39,8 @@ public class HomePageActivity extends AppCompatActivity { String stationCode = null; try { User user = infoBeen.getUser(); - + user.setTeamName(SharedPreferencesUtils.getstring("teamName",null)); + user.setTeamCode(SharedPreferencesUtils.getstring("teamCode",null)); stationCode = user.getStationCode(); infoDialog.setInfoData(infoBeen, user); }catch (Exception e){ @@ -46,38 +48,38 @@ public class HomePageActivity extends AppCompatActivity { } -// String finalStationCode = stationCode; +// String final StationCode = stationCode; binding.homeButton1.setOnClickListener(v -> { -// if (!roles.contains("quality_inspection")) { -// Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); -// return; -// } + if (!roles.contains("quality_inspection")) { + Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); + return; + } intent = new Intent(this, CheckActivity.class); - intent.putExtra("stationCode", "20 01"); + intent.putExtra("stationCode", "2001"); startActivity(intent); }); binding.homeButton2.setOnClickListener(v -> { -// if (!roles.contains("shell_bile_binding")) { -// Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); -// return; -// } + if (!roles.contains("shell_bile_binding")) { + Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); + return; + } intent = new Intent(this, BindingActivity.class); intent.putExtra("title", "壳胆绑定"); startActivity(intent); }); binding.homeButton3.setOnClickListener(v -> { -// if (!roles.contains("quality_repair")) { -// Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); -// return; -// } + if (!roles.contains("quality_repair")) { + Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); + return; + } intent = new Intent(this, RepairActivity.class); startActivity(intent); }); binding.homeButton4.setOnClickListener(v -> { -// if (!roles.contains("barcode_binding")) { -// Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); -// return; -// } + if (!roles.contains("barcode_binding")) { + Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); + return; + } intent = new Intent(this, BindingActivity.class); intent.putExtra("title", "条码绑定"); startActivity(intent); diff --git a/app/src/main/java/com/example/aucma_mes/MainActivity.java b/app/src/main/java/com/example/aucma_mes/MainActivity.java index 83e4315..c155409 100644 --- a/app/src/main/java/com/example/aucma_mes/MainActivity.java +++ b/app/src/main/java/com/example/aucma_mes/MainActivity.java @@ -19,6 +19,7 @@ import com.example.aucma_mes.databinding.ActivityMainBinding; import com.example.aucma_mes.entity.LoginBack; import com.example.aucma_mes.entity.RegisterPda; import com.example.aucma_mes.entity.Result; +import com.example.aucma_mes.entity.TeamBeen; import com.example.aucma_mes.utils.MyRecultCall; import com.example.aucma_mes.utils.SharedPreferencesUtils; import com.example.aucma_mes.vm.User; @@ -38,49 +39,68 @@ import okhttp3.RequestBody; public class MainActivity extends BaseActivity { private User user; -private boolean loginState=false; + private boolean loginState = false; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main); - user=new User(); + user = new User(); user.setUsername("pda01"); user.setPassword("aucma@123"); getSupportActionBar().hide(); // 隐藏原生标题栏 binding.setUser(user); -// Toast.makeText(this, getMacAddress()+"可以使用", Toast.LENGTH_SHORT).show(); - OkGo.get(url + "/report/pdaRecord/getPdaRecord").tag(this) - .headers("Authorization", SharedPreferencesUtils.getstring("token", "")) + + OkGo.get(url + "/base/teamMembers/getTeamMemberList").tag(this) + // .headers("Authorization", SharedPreferencesUtils.getstring("token", "")) .execute(new MyRecultCall(dialog, this) { @Override public void onSuccess(Response response) { super.onSuccess(response); - Result result = response.body(); - if (result.getCode()==200){ - List pdaList=gson.fromJson(gson.toJson( result.getData()),new TypeToken< List>(){}.getType()); -// Log.e("TAG", "onSuccess:" + pdaList.toString()); - RegisterPda registerPda=new RegisterPda(); - registerPda.setSerialCode(getMacAddress()); - int index = pdaList.indexOf(registerPda); - loginState= index >-1; - if (loginState){ - SharedPreferencesUtils.putstring("pdaName",pdaList.get(index).getPdaName()); - } - - }else { - Toast.makeText(MainActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); - } - + List teamBeens = gson.fromJson(gson.toJson(response.body().getData()), new TypeToken>() { + }.getType()); + user.setTeamBeens(teamBeens); } }); + getPda(); + + } @Override protected void sanInfo(String code) { } + + // 查询PDA Mac 地址列表 + private void getPda() { + OkGo.get(url + "/report/pdaRecord/getPdaRecord").tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).execute(new MyRecultCall(dialog, this) { + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + Result result = response.body(); + if (result.getCode() == 200) { + List pdaList = gson.fromJson(gson.toJson(result.getData()), new TypeToken>() { + }.getType()); + RegisterPda registerPda = new RegisterPda(); + registerPda.setSerialCode(getMacAddress()); + int index = pdaList.indexOf(registerPda); + loginState = index > -1; + if (loginState) { + SharedPreferencesUtils.putstring("pdaName", pdaList.get(index).getPdaName()); + } + + } else { + Toast.makeText(MainActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); + } + + } + }); + } + + // 获取本机Mac地址 public String getMacAddress() { try { List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); @@ -105,6 +125,8 @@ private boolean loginState=false; } return "02:00:00:00:00:00"; // 如果无法获取到有效的MAC地址,返回一个默认值 } + + // 登录 public void login(View view) { if (!loginState) { Toast.makeText(this, "设备未注册,不允许登录", Toast.LENGTH_SHORT).show(); @@ -113,55 +135,53 @@ private boolean loginState=false; dialog.show(); MediaType JSON = MediaType.parse("application/json; charset=utf-8"); - RequestBody body = RequestBody.create(JSON,gson.toJson(user) ); - OkGo.post(BaseActivity.url + "/login") - .tag(this) - .upRequestBody(body) - .execute(new StringCallback() { - @Override - public void onSuccess(Response response) { - LoginBack loginBack=gson.fromJson(response.body(),LoginBack.class); - - if (loginBack.getCode()==200){ - getUserInfo(loginBack.getToken()); - }else { - dialog.dismiss(); - Toast.makeText(MainActivity.this, loginBack.getMsg(), Toast.LENGTH_SHORT).show(); - } - } + RequestBody body = RequestBody.create(JSON, gson.toJson(user)); + OkGo.post(BaseActivity.url + "/login").tag(this).upRequestBody(body).execute(new StringCallback() { + @Override + public void onSuccess(Response response) { + LoginBack loginBack = gson.fromJson(response.body(), LoginBack.class); + + if (loginBack.getCode() == 200) { + getUserInfo(loginBack.getToken()); + } else { + dialog.dismiss(); + Toast.makeText(MainActivity.this, loginBack.getMsg(), Toast.LENGTH_SHORT).show(); + } + } - @Override - public void onError(Response response) { - super.onError(response); - dialog.dismiss(); - Toast.makeText(MainActivity.this, "网络错误", Toast.LENGTH_SHORT).show(); - } - }); + @Override + public void onError(Response response) { + super.onError(response); + dialog.dismiss(); + Toast.makeText(MainActivity.this, "网络错误", Toast.LENGTH_SHORT).show(); + } + }); } - private void getUserInfo(String token){ - OkGo.get(BaseActivity.url + "/getInfo") - .tag(this) - .headers("Authorization",token) - .execute(new StringCallback() { - @Override - public void onSuccess(Response response) { - dialog.dismiss(); - String body = response.body(); - LoginBack loginBack=gson.fromJson(body,LoginBack.class); - if (loginBack.getCode()==200){ - Intent intent = new Intent(MainActivity.this, HomePageActivity.class); - intent.putExtra("role",loginBack.getRoles()); - intent.putExtra("info",body); - SharedPreferencesUtils.putstring("loginName",user.username); - SharedPreferencesUtils.putstring("token",token); - startActivity(intent); - finish(); - }else { - Toast.makeText(MainActivity.this, loginBack.getMsg(), Toast.LENGTH_SHORT).show(); - } - } - }); + + // 使用token获取用户信息 + private void getUserInfo(String token) { + OkGo.get(BaseActivity.url + "/getInfo").tag(this).headers("Authorization", token).execute(new StringCallback() { + @Override + public void onSuccess(Response response) { + dialog.dismiss(); + String body = response.body(); + LoginBack loginBack = gson.fromJson(body, LoginBack.class); + if (loginBack.getCode() == 200) { + Intent intent = new Intent(MainActivity.this, HomePageActivity.class); + intent.putExtra("role", loginBack.getRoles()); + intent.putExtra("info", body); + SharedPreferencesUtils.putstring("loginName", user.username); + SharedPreferencesUtils.putstring("teamCode", user.getTeamCode()); + SharedPreferencesUtils.putstring("teamName", user.getTeamName()); + SharedPreferencesUtils.putstring("token", token); + startActivity(intent); + finish(); + } else { + Toast.makeText(MainActivity.this, loginBack.getMsg(), Toast.LENGTH_SHORT).show(); + } + } + }); } } \ No newline at end of file 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 0fb50e9..6754bbc 100644 --- a/app/src/main/java/com/example/aucma_mes/RepairActivity.java +++ b/app/src/main/java/com/example/aucma_mes/RepairActivity.java @@ -76,9 +76,9 @@ public class RepairActivity extends BaseActivity { public void onSuccess(Response response) { Result result = response.body(); if (result.getCode() == 200) { - defectBeens = gson.fromJson(result.getData().toString(), new TypeToken>() { + defectBeens = gson.fromJson(gson.toJson(result.getData()), new TypeToken>() { }.getType()); -// Log.e("TAG", "onSuccess:" + defectBeens.toString()); + Log.e("TAG", "onSuccess:" + defectBeens.toString()); defectBeens.forEach(t -> submitList.add(t.getObjId())); adapter.setList(defectBeens); adapter.notifyDataSetChanged(); diff --git a/app/src/main/java/com/example/aucma_mes/adapter/RepaitSubmintInfoAdapter.java b/app/src/main/java/com/example/aucma_mes/adapter/RepaitSubmintInfoAdapter.java new file mode 100644 index 0000000..0291a4c --- /dev/null +++ b/app/src/main/java/com/example/aucma_mes/adapter/RepaitSubmintInfoAdapter.java @@ -0,0 +1,83 @@ +package com.example.aucma_mes.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.RecyclerView; + +import com.example.aucma_mes.BR; +import com.example.aucma_mes.R; +import com.example.aucma_mes.databinding.ItemLayoutBinding; +import com.example.aucma_mes.databinding.ItemRepairInfoBinding; +import com.example.aucma_mes.entity.DefectBeen; + +import java.util.List; + +/** + * @author wanghao + * @date 2023/11/17 17:15 + */ +public class RepaitSubmintInfoAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + private LayoutInflater from; + private CheckItemClickCall checkItemClickCall; + + public RepaitSubmintInfoAdapter(Context context, CheckItemClickCall checkItemClickCall) { + this.context = context; + this.checkItemClickCall = checkItemClickCall; + from = LayoutInflater.from(context); + } + + public void setList(List list) { + this.list = list; + } + + @NonNull + @Override + public CheckAdapterVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + ItemRepairInfoBinding inflate1 = DataBindingUtil.inflate(from, R.layout.item_repair_info, parent, false); + return new CheckAdapterVH(inflate1); + } + + @Override + public void onBindViewHolder(@NonNull CheckAdapterVH holder, int position) { + DefectBeen defectBeen = list.get(position); + defectBeen.setIndex(position + 1); + ItemRepairInfoBinding databing = holder.getInflate1(); + databing.setVariable(BR.item, defectBeen); + databing.itemButtom.setOnClickListener(t -> { + checkItemClickCall.submintRepair(position); + }); + + databing.executePendingBindings(); + } + + @Override + public int getItemCount() { + return list == null ? 0 : list.size(); + } + + class CheckAdapterVH extends RecyclerView.ViewHolder { + private ItemRepairInfoBinding inflate1; + + public ItemRepairInfoBinding getInflate1() { + return inflate1; + } + + public CheckAdapterVH(ItemRepairInfoBinding inflate1) { + super(inflate1.getRoot()); + this.inflate1 = inflate1; + } + + + } + + public interface CheckItemClickCall { + void submintRepair(int positon); + } + +} diff --git a/app/src/main/java/com/example/aucma_mes/base/BaseActivity.java b/app/src/main/java/com/example/aucma_mes/base/BaseActivity.java index 1ca2264..5d517a1 100644 --- a/app/src/main/java/com/example/aucma_mes/base/BaseActivity.java +++ b/app/src/main/java/com/example/aucma_mes/base/BaseActivity.java @@ -26,8 +26,8 @@ import okhttp3.MediaType; public abstract class BaseActivity extends AppCompatActivity { private MyBroad receiver; - public static String url="http://192.168.0.101:8080"; -// public static String url = "http://172.20.10.2:8080"; + // public static String url="http://192.168.3.199:6061"; + public static String url="http://10.100.72.10:8080"; public ProgressDialog dialog; public Gson gson; public MediaType JSON = MediaType.parse("application/json; charset=utf-8"); diff --git a/app/src/main/java/com/example/aucma_mes/dialog/RepairSubmintInfoDialog.java b/app/src/main/java/com/example/aucma_mes/dialog/RepairSubmintInfoDialog.java new file mode 100644 index 0000000..36ab578 --- /dev/null +++ b/app/src/main/java/com/example/aucma_mes/dialog/RepairSubmintInfoDialog.java @@ -0,0 +1,45 @@ +package com.example.aucma_mes.dialog; + +import android.app.Dialog; +import android.content.Context; +import android.view.LayoutInflater; + +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; + +import com.example.aucma_mes.R; +import com.example.aucma_mes.adapter.RepaitSubmintInfoAdapter; +import com.example.aucma_mes.databinding.DialogInfoBinding; +import com.example.aucma_mes.databinding.DialogRepairSubmintInfoBinding; +import com.example.aucma_mes.entity.DefectBeen; +import com.example.aucma_mes.entity.LoginInfoBeen; +import com.example.aucma_mes.vm.User; + +import java.util.List; + +/** + * @author wanghao + * @date 2023/11/16 14:42 + */ +public class RepairSubmintInfoDialog extends Dialog { + private DialogRepairSubmintInfoBinding binding; + private RepaitSubmintInfoAdapter adapter; + private RepaitSubmintInfoAdapter.CheckItemClickCall itemClickCall; + public void setList(List list) { + adapter.setList(list); + binding.repairSubmintRecycler.setAdapter(adapter); + } + + public RepairSubmintInfoDialog(@NonNull Context context,RepaitSubmintInfoAdapter.CheckItemClickCall itemClickCall) { + super(context,R.style.dialog); + binding = DataBindingUtil.inflate(LayoutInflater.from(context), + R.layout.dialog_repair_submint_info, null, false); + setContentView(binding.getRoot()); + assert binding.dialogRepairSubmintbutton != null; + binding.dialogRepairSubmintbutton.setOnClickListener(t-> dismiss()); + adapter=new RepaitSubmintInfoAdapter(context,itemClickCall); + } + + + +} 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 24d4ba9..825af11 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 @@ -17,6 +17,8 @@ public class DefectBeen extends BaseObservable { private String materialName; private String materialCategories; private String materialSubclass; + + private String stationCode; private String qualityDefectCode; private String qualityDefectName; @@ -26,6 +28,13 @@ public class DefectBeen extends BaseObservable { this.index = index; } + public String getStationCode() { + return stationCode; + } + + public void setStationCode(String stationCode) { + this.stationCode = stationCode; + } @Override public boolean equals(Object o) { @@ -99,9 +108,9 @@ public class DefectBeen extends BaseObservable { return "DefectBeen{" + "index=" + index + ", objId=" + objId + - ", materialName='" + materialName + '\'' + - ", materialCategories='" + materialCategories + '\'' + - ", materialSubclass='" + materialSubclass + '\'' + + // ", materialName='" + materialName + '\'' + + // ", materialCategories='" + materialCategories + '\'' + + // ", materialSubclass='" + materialSubclass + '\'' + ", qualityDefectCode='" + qualityDefectCode + '\'' + ", qualityDefectName='" + qualityDefectName + '\'' + '}'; diff --git a/app/src/main/java/com/example/aucma_mes/entity/TeamBeen.java b/app/src/main/java/com/example/aucma_mes/entity/TeamBeen.java new file mode 100644 index 0000000..547c2c0 --- /dev/null +++ b/app/src/main/java/com/example/aucma_mes/entity/TeamBeen.java @@ -0,0 +1,26 @@ +package com.example.aucma_mes.entity; + +/** + * @author wanghao + * @date 2023/12/13 14:00 + */ +public class TeamBeen { + private String teamCode; + private String teamName; + + public String getTeamCode() { + return teamCode; + } + + public void setTeamCode(String teamCode) { + this.teamCode = teamCode; + } + + public String getTeamName() { + return teamName; + } + + public void setTeamName(String teamName) { + this.teamName = teamName; + } +} diff --git a/app/src/main/java/com/example/aucma_mes/utils/MyRecultCall.java b/app/src/main/java/com/example/aucma_mes/utils/MyRecultCall.java index ac60a62..be69444 100644 --- a/app/src/main/java/com/example/aucma_mes/utils/MyRecultCall.java +++ b/app/src/main/java/com/example/aucma_mes/utils/MyRecultCall.java @@ -38,7 +38,7 @@ public class MyRecultCall extends AbsCallback { @Override public void onSuccess(Response response) { dialog.dismiss(); - Log.e("网络请求情况", "onSuccess:"); + // Log.e("网络请求情况", "onSuccess:"); } @Override @@ -53,7 +53,7 @@ public class MyRecultCall extends AbsCallback { public void onStart(Request request) { super.onStart(request); dialog.show(); - Log.e("网络请求情况", "onStart:" ); + // Log.e("网络请求情况", "onStart:" ); } @Override diff --git a/app/src/main/java/com/example/aucma_mes/vm/CheckViewModel.java b/app/src/main/java/com/example/aucma_mes/vm/CheckViewModel.java index 1d26dfd..6eb99a9 100644 --- a/app/src/main/java/com/example/aucma_mes/vm/CheckViewModel.java +++ b/app/src/main/java/com/example/aucma_mes/vm/CheckViewModel.java @@ -17,50 +17,50 @@ import java.util.List; * @date 2023/11/17 16:26 */ public class CheckViewModel extends BaseObservable { - public String code;//产品条码 - public String name;//产品型号 - public String defect; - + private String code;//产品条码 + private String name;//产品型号 private List list;//缺陷列表 - - private String measure;//处理措施TREATMENT_MEASURE - private String measureName;//处理措施TREATMENT_MEASURE - - - private String processCode; + private String stationCode;//人的工位编码 private String userName; - - - public String getProcessCode() { - return processCode; + private String measure;//处置措施 3=放行,1=返修 + private String teamCode;//班组编号 + private boolean buttonVisbleState=false; + private String defect; + public String getCode() { + return code; } - public void setProcessCode(String processCode) { - this.processCode = processCode; + public void setCode(String code) { + this.code = code; + notifyChange(); } - public String getUserName() { - return userName; + public String getMeasure() { + return measure; } - public void setUserName(String userName) { - this.userName = userName; + public void setMeasure(String measure) { + this.measure = measure; } - - public String getMeasure() { - return measure; + public String getName() { + return name; } - - public String getCode() { - return code; + public void setName(String name) { + this.name = name; + notifyChange(); } public String getDefect() { return defect; } + public void setDefect(String defect) { + this.defect = defect; + notifyChange(); + } + public List getList() { return list; } @@ -69,14 +69,36 @@ public class CheckViewModel extends BaseObservable { this.list = list; } - public void setCode(String code) { - this.code = code; - notifyChange(); + public String getUserName() { + return userName; } - public void setDefect(String defect) { - this.defect = defect; + public void setUserName(String userName) { + this.userName = userName; + } + + public String getStationCode() { + return stationCode; + } + + public void setStationCode(String stationCode) { + this.stationCode = stationCode; + } + + public boolean isButtonVisbleState() { + return buttonVisbleState; + } + + public void setButtonVisbleState(boolean buttonVisbleState) { + this.buttonVisbleState = buttonVisbleState; notifyChange(); } + public String getTeamCode() { + return teamCode; + } + + public void setTeamCode(String teamCode) { + this.teamCode = teamCode; + } } diff --git a/app/src/main/java/com/example/aucma_mes/vm/User.java b/app/src/main/java/com/example/aucma_mes/vm/User.java index a03e2cf..be23a19 100644 --- a/app/src/main/java/com/example/aucma_mes/vm/User.java +++ b/app/src/main/java/com/example/aucma_mes/vm/User.java @@ -1,8 +1,18 @@ package com.example.aucma_mes.vm; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; + import androidx.databinding.BaseObservable; import androidx.databinding.Bindable; +import com.example.aucma_mes.entity.RepairMeasures; +import com.example.aucma_mes.entity.TeamBeen; + +import java.util.ArrayList; +import java.util.List; + /** * @author wanghao * @date 2023/11/15 9:45 @@ -13,9 +23,15 @@ public class User extends BaseObservable { @Bindable public String password; + private List list; + private List teamBeens; + + public String nickName; public String stationCode; public String stationName; + private String teamCode; + private String teamName; public String getUsername() { return username; @@ -57,14 +73,48 @@ public class User extends BaseObservable { this.stationName = stationName; } - @Override - public String toString() { - return "User{" + - "username='" + username + '\'' + - ", password='" + password + '\'' + - ", nickName='" + nickName + '\'' + - ", stationCode='" + stationCode + '\'' + - ", stationName='" + stationName + '\'' + - '}'; + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + + notifyChange(); + } + + public void onItemClick(AdapterView parent, View view, int position, long id) { + Log.e("TAG", "返修选中措施:" + position); + TeamBeen teamBeen = teamBeens.get(position); + setTeamCode(teamBeen.getTeamCode()); + setTeamName(teamBeen.getTeamName()); + } + + public List getTeamBeens() { + return teamBeens; + } + + public void setTeamBeens(List teamBeens) { + this.teamBeens = teamBeens; + list = new ArrayList<>(teamBeens.size()); + teamBeens.forEach(t -> this.list.add(t.getTeamName())); + notifyChange(); + } + + public String getTeamCode() { + return teamCode; + } + + public void setTeamCode(String teamCode) { + this.teamCode = teamCode; + } + + public String getTeamName() { + return teamName; + } + + public void setTeamName(String teamName) { + this.teamName = teamName; + notifyChange(); } } diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d1..0000000 --- a/app/src/main/res/drawable/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_check.xml b/app/src/main/res/layout/activity_check.xml index 41a90ff..0fee981 100644 --- a/app/src/main/res/layout/activity_check.xml +++ b/app/src/main/res/layout/activity_check.xml @@ -4,10 +4,10 @@ xmlns:tools="http://schemas.android.com/tools"> - + + android:layout_marginEnd="4dp"> + + @@ -106,7 +116,6 @@