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 f3dc35f..2bc1fbf 100644 --- a/app/src/main/java/com/example/aucma_mes/HomePageActivity.java +++ b/app/src/main/java/com/example/aucma_mes/HomePageActivity.java @@ -121,10 +121,10 @@ public class HomePageActivity extends AppCompatActivity { }); binding.homeButton9.setOnClickListener(v -> { // 切换订单 - // if (!roles.contains("switch_order")) { - // Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); - // return; - // } + if (!roles.contains("switch_order")) { + Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); + return; + } intent = new Intent(this, ChangeActivity.class); intent.putExtra("title","切换订单"); startActivity(intent); @@ -136,7 +136,11 @@ public class HomePageActivity extends AppCompatActivity { } serviceIntent = new Intent(this, MyService.class); - startService(serviceIntent); + var userPermission = intent1.getIntExtra("userPermission", 0); + if (userPermission==2){ + startService(serviceIntent); + } + } 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 84f1c17..5978fa8 100644 --- a/app/src/main/java/com/example/aucma_mes/MainActivity.java +++ b/app/src/main/java/com/example/aucma_mes/MainActivity.java @@ -61,11 +61,7 @@ public class MainActivity extends BaseActivity { user.setTeamBeens(teamBeens); } }); - - getPda(); - - } @Override @@ -93,7 +89,6 @@ public class MainActivity extends BaseActivity { if (loginState) { SharedPreferencesUtils.putstring("pdaName", pdaList.get(index).getPdaName()); } - } else { Toast.makeText(MainActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); } @@ -130,10 +125,10 @@ public class MainActivity extends BaseActivity { // 登录 public void login(View view) { - // if (!loginState) { - // Toast.makeText(this, "设备未注册,不允许登录", Toast.LENGTH_SHORT).show(); - // return; - // } + if (!loginState) { + Toast.makeText(this, "设备未注册,不允许登录", Toast.LENGTH_SHORT).show(); + return; + } String teamCode = user.getTeamCode(); if (teamCode==null||teamCode.isEmpty()) return; dialog.show(); @@ -143,7 +138,6 @@ public class MainActivity extends BaseActivity { @Override public void onSuccess(Response response) { LoginBack loginBack = gson.fromJson(response.body(), LoginBack.class); - if (loginBack.getCode() == 200) { getUserInfo(loginBack.getToken()); } else { @@ -151,7 +145,6 @@ public class MainActivity extends BaseActivity { Toast.makeText(MainActivity.this, loginBack.getMsg(), Toast.LENGTH_SHORT).show(); } } - @Override public void onError(Response response) { super.onError(response); @@ -179,6 +172,7 @@ public class MainActivity extends BaseActivity { SharedPreferencesUtils.putstring("teamCode", user.getTeamCode()); SharedPreferencesUtils.putstring("teamName", user.getTeamName()); SharedPreferencesUtils.putstring("token", token); + intent.putExtra("userPermission", loginBack.getUserPermission()); startActivity(intent); finish(); } else { 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 7b7c823..7682b20 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.137.1:8080"; - // public static String url="http://10.100.72.10: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; public MediaType JSON = MediaType.parse("application/json; charset=utf-8"); @@ -56,7 +56,9 @@ public abstract class BaseActivity extends AppCompatActivity { public void goodsNameCall(String code) { } + private String codeTag = ""; + public void selectGoodsName(String code) { if (codeTag.equals(code)) return; codeTag = code; @@ -64,21 +66,22 @@ public abstract class BaseActivity extends AppCompatActivity { .tag(this) .headers("Authorization", SharedPreferencesUtils.getstring("token", "")) .params("code", code) - .execute(new MyRecultCall(dialog,this){ + .execute(new MyRecultCall(dialog, this) { @Override public void onSuccess(Response response) { super.onSuccess(response); Result result = response.body(); - if (result.getCode()==200){ + if (result.getCode() == 200) { Toast.makeText(BaseActivity.this, "查询成功", Toast.LENGTH_SHORT).show(); - goodsNameCall(result.getData().toString()) ; - }else { + goodsNameCall(result.getData().toString()); + } else { Toast.makeText(BaseActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); - goodsNameCall(null) ; + goodsNameCall(null); } } }); } + @Override protected void onDestroy() { super.onDestroy(); diff --git a/app/src/main/java/com/example/aucma_mes/entity/LoginBack.java b/app/src/main/java/com/example/aucma_mes/entity/LoginBack.java index 467d4cc..4253b6d 100644 --- a/app/src/main/java/com/example/aucma_mes/entity/LoginBack.java +++ b/app/src/main/java/com/example/aucma_mes/entity/LoginBack.java @@ -12,6 +12,15 @@ public class LoginBack { private int code; private String token; private ArrayList roles; + private int userPermission; + + public int getUserPermission() { + return userPermission; + } + + public void setUserPermission(int userPermission) { + this.userPermission = userPermission; + } public ArrayList getRoles() { return roles; diff --git a/app/src/main/java/com/example/aucma_mes/service/MyService.java b/app/src/main/java/com/example/aucma_mes/service/MyService.java index f5ef9c6..b4810c5 100644 --- a/app/src/main/java/com/example/aucma_mes/service/MyService.java +++ b/app/src/main/java/com/example/aucma_mes/service/MyService.java @@ -37,7 +37,6 @@ public class MyService extends Service { public int onStartCommand(Intent intent, int flags, int startId) { Log.e("TAG", "服务启动"); startQuery(); - return START_STICKY; } diff --git a/app/src/main/res/mipmap-xhdpi/icon_change2.png b/app/src/main/res/mipmap-xhdpi/icon_change2.png new file mode 100644 index 0000000..4c8d1be Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_change2.png differ