|
|
@@ -1,17 +1,36 @@
|
|
|
package com.xzjmyk.pm.activity.ui.erp.activity.datainquiry;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
import android.widget.ListView;
|
|
|
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
+
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by RaoMeng on 2017/8/3.
|
|
|
* 选择查询业务菜单页面
|
|
|
*/
|
|
|
public class DataInquiryActivity extends BaseActivity {
|
|
|
+ private final int GET_MENU_DATA = 0x08;
|
|
|
private ListView mMenuListView;
|
|
|
+ private List<GridMenuDataInquiryBean> mGridMenuDataInquiryBeans;
|
|
|
+ private DataInquiryMenuListAdapter mDataInquiryMenuListAdapter;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -20,5 +39,96 @@ public class DataInquiryActivity extends BaseActivity {
|
|
|
getSupportActionBar().setTitle(R.string.select_query_service);
|
|
|
|
|
|
mMenuListView = (ListView) findViewById(R.id.data_inquiry_menu_lv);
|
|
|
+ mGridMenuDataInquiryBeans = new ArrayList<>();
|
|
|
+ mDataInquiryMenuListAdapter = new DataInquiryMenuListAdapter(this, mGridMenuDataInquiryBeans);
|
|
|
+ mMenuListView.setAdapter(mDataInquiryMenuListAdapter);
|
|
|
+
|
|
|
+ getMenuData();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getMenuData() {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = Constants.getAppBaseUrl(this) + "/mobile/qry/queryJsp.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("emcode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(this, url, params, mHandler, headers, GET_MENU_DATA, null, null, "get");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Handler mHandler = new Handler() {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ switch (msg.what) {
|
|
|
+ case GET_MENU_DATA:
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ if (result != null) {
|
|
|
+ LogUtil.prinlnLongMsg("menudata", result);
|
|
|
+ try {
|
|
|
+ JSONObject resultObject = new JSONObject(result);
|
|
|
+ JSONArray dataArray = resultObject.optJSONArray("data");
|
|
|
+ if (dataArray != null) {
|
|
|
+ for (int i = 0; i < dataArray.length(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.optJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ GridMenuDataInquiryBean gridMenuDataInquiryBean = new GridMenuDataInquiryBean();
|
|
|
+ String modelName = optStringNotNull(dataObject, "modelName");
|
|
|
+ gridMenuDataInquiryBean.setModelName(modelName);
|
|
|
+ JSONArray listArray = dataObject.optJSONArray("list");
|
|
|
+ if (listArray != null) {
|
|
|
+ List<GridMenuDataInquiryBean.QueryScheme> querySchemes = new ArrayList<>();
|
|
|
+ for (int j = 0; j < listArray.length(); j++) {
|
|
|
+ JSONObject listObject = listArray.optJSONObject(j);
|
|
|
+ if (listObject != null) {
|
|
|
+ String title = optStringNotNull(listObject, "title");
|
|
|
+ String caller = optStringNotNull(listObject, "caller");
|
|
|
+ JSONArray schemeArray = listObject.optJSONArray("schemes");
|
|
|
+ if (schemeArray != null) {
|
|
|
+ for (int k = 0; k < schemeArray.length(); k++) {
|
|
|
+ JSONObject schemeObject = schemeArray.optJSONObject(k);
|
|
|
+ if (schemeObject != null) {
|
|
|
+ String scheme = optStringNotNull(schemeObject, "scheme");
|
|
|
+ String schemeId = optStringNotNull(schemeObject, "schemeId");
|
|
|
+
|
|
|
+ GridMenuDataInquiryBean.QueryScheme queryScheme = new GridMenuDataInquiryBean.QueryScheme();
|
|
|
+ queryScheme.setTitle(title);
|
|
|
+ queryScheme.setCaller(caller);
|
|
|
+ queryScheme.setScheme(scheme);
|
|
|
+ queryScheme.setSchemeId(schemeId);
|
|
|
+
|
|
|
+ querySchemes.add(queryScheme);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gridMenuDataInquiryBean.setQuerySchemes(querySchemes);
|
|
|
+ }
|
|
|
+ mGridMenuDataInquiryBeans.add(gridMenuDataInquiryBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mDataInquiryMenuListAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
+ progressDialog.dismiss();
|
|
|
+ ToastMessage(msg.getData().getString("result"));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ public String optStringNotNull(JSONObject json, String key) {
|
|
|
+ if (json.isNull(key)) {
|
|
|
+ return "";
|
|
|
+ } else {
|
|
|
+ return json.optString(key, "");
|
|
|
+ }
|
|
|
}
|
|
|
}
|