|
|
@@ -4,6 +4,7 @@ import static com.ygtx.emcs.comm.BaseApplication.mScanManager;
|
|
|
import static com.ygtx.emcs.util.Constant.CACHE_BIND_CONFIG;
|
|
|
import static com.ygtx.emcs.util.Constant.CACHE_BIND_CONTROL;
|
|
|
import static com.ygtx.emcs.util.Constant.CACHE_LOGIN_KEY;
|
|
|
+import static com.ygtx.emcs.util.Constant.PRINTER_ITEM_SEL_KEY;
|
|
|
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
@@ -30,6 +31,8 @@ import com.ygtx.emcs.R;
|
|
|
import com.ygtx.emcs.activity.adapter.FunctionMenuAdapter;
|
|
|
import com.ygtx.emcs.activity.adapter.MainListViewAdapter;
|
|
|
import com.ygtx.emcs.activity.model.ConfigModel;
|
|
|
+import com.ygtx.emcs.activity.model.DeviceModel;
|
|
|
+import com.ygtx.emcs.activity.model.DictModel;
|
|
|
import com.ygtx.emcs.activity.model.EventMessage;
|
|
|
import com.ygtx.emcs.activity.model.MainModel;
|
|
|
import com.ygtx.emcs.activity.model.MaterialStockModel;
|
|
|
@@ -80,6 +83,7 @@ public class HomeActivity extends BaseActivity {
|
|
|
private PopupWindow popupWindow2;
|
|
|
private List<MenuModel> menuModels = new ArrayList<>();
|
|
|
private FunctionMenuAdapter mainViewAdapter;
|
|
|
+ private DeviceModel deviceModel;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -145,6 +149,96 @@ public class HomeActivity extends BaseActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void getDevice(){
|
|
|
+ MyProgress myProgress = MyProgress.getInstance();
|
|
|
+ myProgress.show(context, "提示", "正在加载");
|
|
|
+ RequestParams params = httParams(Constant.GET_DEVICE+"/" + getMac());
|
|
|
+ x.http().get(params, new Callback.CommonCallback<JSONObject>() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(JSONObject rs) {
|
|
|
+ mylog.info(rs.toString());
|
|
|
+ try {
|
|
|
+ if (rs.getInt("code") == 200) {
|
|
|
+ if(!rs.has("data")){
|
|
|
+ register();
|
|
|
+ }else{
|
|
|
+ deviceModel = new Gson().fromJson(rs.get("data").toString(), DeviceModel.class);
|
|
|
+ if(!"0".equals(deviceModel.getStatus())){
|
|
|
+ ToastUtils.showToast(context, "设备无效");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(rs.getInt("code") == 401){
|
|
|
+ ToastUtils.showToast(context, "会话过期");
|
|
|
+ logoutAuth(rs.getInt("code"));
|
|
|
+ }else{
|
|
|
+ ToastUtils.showToast(context, rs.getString("msg"));
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable ex, boolean isOnCallback) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ HttpsUtil.parserError(HomeActivity.this, ex);
|
|
|
+ mylog.error("请求异常:", ex);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onFinished() {
|
|
|
+ myProgress.close();
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onCancelled(CancelledException arg0) {
|
|
|
+ mylog.error("onRead:", arg0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void register(){
|
|
|
+ MyProgress myProgress = MyProgress.getInstance();
|
|
|
+ myProgress.show(context, "提示", "正在提交数据");
|
|
|
+ RequestParams params = httParams(Constant.ADD_DEVICE);
|
|
|
+ params.addBodyParameter("deviceCode", getMac());
|
|
|
+ x.http().post(params, new Callback.CommonCallback<JSONObject>() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(JSONObject rs) {
|
|
|
+ mylog.info(rs.toString());
|
|
|
+ try {
|
|
|
+ if (rs.getInt("code") == 200) {
|
|
|
+ ToastUtils.showToast(context, "注册成功");
|
|
|
+ }else if(rs.getInt("code") == 401){
|
|
|
+ ToastUtils.showToast(context, "会话过期");
|
|
|
+ logoutAuth(rs.getInt("code"));
|
|
|
+ }else{
|
|
|
+ ToastUtils.showToast(context, rs.getString("msg"));
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }finally {
|
|
|
+ myProgress.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable ex, boolean isOnCallback) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ HttpsUtil.parserError(HomeActivity.this, ex);
|
|
|
+ mylog.error("请求异常:", ex);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFinished() {
|
|
|
+ myProgress.close();
|
|
|
+ submit.setEnabled(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCancelled(CancelledException arg0) {
|
|
|
+ mylog.error("onRead:", arg0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
private void initView(){
|
|
|
ImageView back = findViewById(R.id.c_iv_common_back);
|
|
|
back.setVisibility(View.VISIBLE);
|
|
|
@@ -237,6 +331,7 @@ public class HomeActivity extends BaseActivity {
|
|
|
}
|
|
|
getUserInfo(loginName, loginPwd);
|
|
|
getConfig();
|
|
|
+ getDevice();
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
mylog.error(e);
|