|
|
|
@ -1,22 +1,20 @@
|
|
|
|
|
package com.example.aucma_mes;
|
|
|
|
|
|
|
|
|
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
import androidx.databinding.DataBindingUtil;
|
|
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
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.service.MyService;
|
|
|
|
|
import com.example.aucma_mes.utils.SharedPreferencesUtils;
|
|
|
|
|
import com.example.aucma_mes.vm.User;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.JsonObject;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
@ -25,6 +23,7 @@ public class HomePageActivity extends AppCompatActivity {
|
|
|
|
|
private Intent intent;
|
|
|
|
|
private ArrayList<String> roles;
|
|
|
|
|
private User user;
|
|
|
|
|
private Intent serviceIntent;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
@ -37,6 +36,7 @@ public class HomePageActivity extends AppCompatActivity {
|
|
|
|
|
String json = intent1.getStringExtra("info");
|
|
|
|
|
LoginInfoBeen infoBeen = new Gson().fromJson(json, LoginInfoBeen.class);
|
|
|
|
|
InfoDialog infoDialog = new InfoDialog(this);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
user = infoBeen.getUser();
|
|
|
|
@ -87,11 +87,13 @@ public class HomePageActivity extends AppCompatActivity {
|
|
|
|
|
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);
|
|
|
|
|
intent.putExtra("title","工位切换");
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
});
|
|
|
|
|
binding.homeButton5.setOnClickListener(v -> {
|
|
|
|
@ -117,11 +119,25 @@ public class HomePageActivity extends AppCompatActivity {
|
|
|
|
|
intent.putExtra("type", true);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
});
|
|
|
|
|
binding.homeButton9.setOnClickListener(v -> {
|
|
|
|
|
// 切换订单
|
|
|
|
|
// if (!roles.contains("switch_order")) {
|
|
|
|
|
// Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show();
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
intent = new Intent(this, ChangeActivity.class);
|
|
|
|
|
intent.putExtra("title","切换订单");
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show();
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serviceIntent = new Intent(this, MyService.class);
|
|
|
|
|
startService(serviceIntent);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String stationName;
|
|
|
|
@ -130,7 +146,6 @@ public class HomePageActivity extends AppCompatActivity {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
|
|
|
|
|
stationName = SharedPreferencesUtils.getstring("stationName", user.getStationName());
|
|
|
|
|
stationCode = SharedPreferencesUtils.getstring("stationCode", user.getStationCode());
|
|
|
|
|
|
|
|
|
@ -139,7 +154,9 @@ public class HomePageActivity extends AppCompatActivity {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
// 重置保存数据
|
|
|
|
|
SharedPreferencesUtils.putstring("stationName", null);
|
|
|
|
|
SharedPreferencesUtils.putstring("stationCode", null);
|
|
|
|
|
stopService(serviceIntent);// 停止服务
|
|
|
|
|
}
|
|
|
|
|
}
|