From 3471f2779f277d4b306aa5b3417a608d26ae7fe2 Mon Sep 17 00:00:00 2001 From: wangh <123456> Date: Thu, 14 Mar 2024 16:00:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20-=20=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=B7=A5=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 16 +++-- .../com/example/aucma_mes/ChangeActivity.java | 70 +++++++++++++++++++ .../com/example/aucma_mes/CheckActivity.java | 8 +-- .../example/aucma_mes/HomePageActivity.java | 40 +++++++++-- .../com/example/aucma_mes/MainActivity.java | 6 +- .../example/aucma_mes/base/BaseActivity.java | 2 +- .../example/aucma_mes/entity/DefectBeen.java | 10 +++ app/src/main/res/layout/activity_change.xml | 57 +++++++++++++++ .../main/res/layout/activity_home_page.xml | 8 +++ 9 files changed, 198 insertions(+), 19 deletions(-) create mode 100644 app/src/main/java/com/example/aucma_mes/ChangeActivity.java create mode 100644 app/src/main/res/layout/activity_change.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f3cb16b..d601607 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,12 +1,15 @@ - - + + + + + @@ -31,14 +38,13 @@ android:label="质量检测" /> - - + android:exported="true"> + diff --git a/app/src/main/java/com/example/aucma_mes/ChangeActivity.java b/app/src/main/java/com/example/aucma_mes/ChangeActivity.java new file mode 100644 index 0000000..b6a0113 --- /dev/null +++ b/app/src/main/java/com/example/aucma_mes/ChangeActivity.java @@ -0,0 +1,70 @@ +package com.example.aucma_mes; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.databinding.DataBindingUtil; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.Toast; + +import com.example.aucma_mes.base.BaseActivity; +import com.example.aucma_mes.databinding.ActivityChangeBinding; +import com.example.aucma_mes.entity.DefectBeen; +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.google.gson.reflect.TypeToken; +import com.lzy.okgo.OkGo; +import com.lzy.okgo.model.Response; + +import java.util.ArrayList; +import java.util.List; + +public class ChangeActivity extends BaseActivity { + private List list; + public List tagList; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + ActivityChangeBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_change); + tagList = new ArrayList<>(); + binding.setVm(this); + OkGo.get(url + "/base/productLine/findProductLineList?productLineType=2&stationType=2").tag(this) + .headers("Authorization", SharedPreferencesUtils.getstring("token", "")).execute(new MyRecultCall(dialog, this) { + @Override + public void onSuccess(Response response) { + var body = response.body(); + if (body.getCode() == 200) { + list = gson.fromJson(gson.toJson(body.getData()), new TypeToken>() { + }.getType()); + list.forEach(t -> tagList.add(t.getProductLineName())); + binding.setList(tagList); + } + Toast.makeText(ChangeActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show(); + } + }); + + } + + @Override + protected void sanInfo(String code) { + + } + private String tag; + public void onItemClick(AdapterView parent, View view, int position, long id) { + tag = tagList.get(position); + + productLineCode = list.get(position).getProductLineCode(); + Log.e("TAG", "选中工位:" + tag); + } + private String productLineCode; + public void changeSubmit(View view){ + SharedPreferencesUtils.putstring("stationName",tag); + SharedPreferencesUtils.putstring("stationCode",productLineCode); + finish(); + } +} \ 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 59d704b..bf93caa 100644 --- a/app/src/main/java/com/example/aucma_mes/CheckActivity.java +++ b/app/src/main/java/com/example/aucma_mes/CheckActivity.java @@ -115,10 +115,7 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte tipDialog.show(); } - // 测试 - public void checkSubmint1(View view) { - sanInfo("B24010181060282920007"); - } + // 提交 public void checkSubmint(View view) { if (checkViewModel.getName() == null || checkViewModel.getName().isEmpty()) return; @@ -160,7 +157,8 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte // 初始化-联动选择 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) { + 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) { super.onSuccess(response); 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 626b103..1434b84 100644 --- a/app/src/main/java/com/example/aucma_mes/HomePageActivity.java +++ b/app/src/main/java/com/example/aucma_mes/HomePageActivity.java @@ -24,6 +24,7 @@ public class HomePageActivity extends AppCompatActivity { ActivityHomePageBinding binding; private Intent intent; private ArrayList roles; + private User user; @Override protected void onCreate(Bundle savedInstanceState) { @@ -37,19 +38,22 @@ public class HomePageActivity extends AppCompatActivity { // Log.e("TAG", "onCreate:" + infoBeen.getUserPermission()); InfoDialog infoDialog = new InfoDialog(this); try { - User user = infoBeen.getUser(); + + user = infoBeen.getUser(); user.setUsername(SharedPreferencesUtils.getstring("pdaName", "")); user.setTeamName(SharedPreferencesUtils.getstring("teamName", null)); user.setTeamCode(SharedPreferencesUtils.getstring("teamCode", null)); infoDialog.setInfoData(infoBeen, user); + 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", user.getStationCode()); - intent.putExtra("stationName",user.getStationName()); + + intent.putExtra("stationCode", stationCode); + intent.putExtra("stationName", stationName); startActivity(intent); }); binding.homeButton2.setOnClickListener(v -> { @@ -68,8 +72,8 @@ public class HomePageActivity extends AppCompatActivity { } // 返修 intent = new Intent(this, RepairActivity.class); - intent.putExtra("userPermission",infoBeen.getUserPermission()); - intent.putExtra("stationName",user.getStationName()); + intent.putExtra("userPermission", infoBeen.getUserPermission()); + intent.putExtra("stationName", stationName); startActivity(intent); }); binding.homeButton4.setOnClickListener(v -> { @@ -81,14 +85,40 @@ public class HomePageActivity extends AppCompatActivity { intent.putExtra("title", "条码绑定"); startActivity(intent); }); + binding.homeButton6.setOnClickListener(v -> { + if (!roles.contains("switch_station")) { + Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); + return; + } + intent = new Intent(this, ChangeActivity.class); + startActivity(intent); + }); binding.homeButton5.setOnClickListener(v -> { infoDialog.show(); }); + } catch (Exception e) { Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } } + private String stationName; + private String stationCode; + + @Override + protected void onResume() { + super.onResume(); + + stationName = SharedPreferencesUtils.getstring("stationName", user.getStationName()); + stationCode = SharedPreferencesUtils.getstring("stationCode", user.getStationCode()); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + SharedPreferencesUtils.putstring("stationName",null); + SharedPreferencesUtils.putstring("stationCode",null); + } } \ No newline at end of file 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 cedfdb0..f720439 100644 --- a/app/src/main/java/com/example/aucma_mes/MainActivity.java +++ b/app/src/main/java/com/example/aucma_mes/MainActivity.java @@ -45,10 +45,10 @@ public class MainActivity extends BaseActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main); - String loginName = SharedPreferencesUtils.getstring("loginName", ""); + String loginName = SharedPreferencesUtils.getstring("pdaName", ""); user = new User(); - // user.setUsername(loginName); - // user.setPassword("123456"); + user.setUsername(loginName); + user.setPassword("123456"); getSupportActionBar().hide(); // 隐藏原生标题栏 binding.setUser(user); 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 057ac36..7f72f5f 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,7 +26,7 @@ import okhttp3.MediaType; public abstract class BaseActivity extends AppCompatActivity { private MyBroad receiver; - // public static String url="http://192.168.0.102:8080"; + // public static String url="http://192.168.137.1:8080"; public static String url="http://10.100.72.10:8080"; public ProgressDialog dialog; public Gson gson; 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 0340159..9868a6d 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 @@ -23,6 +23,16 @@ public class DefectBeen extends BaseObservable { private String qualityDefectName; private String processResult;//返修结果 private String productLineName;//pda 工位名称 + private String productLineCode; + + + public String getProductLineCode() { + return productLineCode; + } + + public void setProductLineCode(String productLineCode) { + this.productLineCode = productLineCode; + } public String getProductLineName() { return productLineName; diff --git a/app/src/main/res/layout/activity_change.xml b/app/src/main/res/layout/activity_change.xml new file mode 100644 index 0000000..f4dea29 --- /dev/null +++ b/app/src/main/res/layout/activity_change.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + +