From ecdd0d15a957880f4df554fe83f10b75c71b6feb Mon Sep 17 00:00:00 2001 From: wangh <123456> Date: Sun, 28 Apr 2024 14:51:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20-=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=AA=8C=E8=AF=81=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/aucma_mes/HomePageActivity.java | 14 +++++++++----- .../com/example/aucma_mes/MainActivity.java | 16 +++++----------- .../example/aucma_mes/base/BaseActivity.java | 17 ++++++++++------- .../example/aucma_mes/entity/LoginBack.java | 9 +++++++++ .../example/aucma_mes/service/MyService.java | 1 - app/src/main/res/mipmap-xhdpi/icon_change2.png | Bin 0 -> 1843 bytes 6 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 app/src/main/res/mipmap-xhdpi/icon_change2.png 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 0000000000000000000000000000000000000000..4c8d1be85e96a8c055001bcf43a0da56ba421dd7 GIT binary patch literal 1843 zcmb`I`CHQY9>qUj+)%_EFS(!?I!2C5xs;ZskYS?cnlo;smSi`~)SDNqRB+2wrp%4p zkSMQ}GfswSZV1;N7xWg1Y#N1 z07zdFF;wNuzYeac(mu~q!zzO=hWdDc=4WP00B94S5EXuEBRsNm zoJtq$a_1{)^qH*oRMh{v>po}JXDa2i1mvZdO`o=!-I4W8(ebY9zgS3noY>o+TCY

Jx%AdWLm-$&f5jvKk~>5ox7B!Cvdne^ag*ay<&3yCmLM>Vl`gnJVb%O&v}hA;cK{;(b^&} zK)cF5`)08Q)%Qn|BQaMVb2fQq^Z;0yXB&037}{Y*ZXgl>p?-Ekl247OzI8tNviP8y z@O=v9=(IKs-9)%N`u4Y>Xjcf_?`?q)vk&h#%NXG5opxg0&hC|exxRR9g)XZmS+K$C&gs|=R*Pcx5vF)DS1@e7CA zAcA_fK_ag~P5CJ$jZ)a(`&Le6!@3WTn1HuiilVPiqs`&y5fFvW%ql~GR@b#~PGc?P zpmBbm)+5lpZT`Y&mvLt%zek7tVWS(V=?dF|)0}gTBO=CX zV?%w+uod;@US|EqGCrvFDVK&f&gnC%BH{EQS}Ov#xWe?8W7&E?*imG z)Y`%hf4o3<773Usjs}m_0dXNokP0Ll#)WPA;F|c?40#B|j3lIU)4`yAo`9&C9iaus z;CRa%?^ZqG`}o}sy6WBVkA43By)k)=FCF=oCRlo%vuIDd?uS@%mQKo)(S|+25a8J% zO@10gXF|nwSxlDdneo$OV=zGVT3UpI6=^_#J>cTXv#$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