Browse Source

Merge branch 'developer_master' of https://gitlab.com/Arisono/SkWeiChat-Baidu into developer

gongpm 10 years ago
parent
commit
4067567bbd

+ 36 - 20
WeiChat/src/main/java/com/sk/weichat/ui/erp/activity/LeaveActivity.java

@@ -14,6 +14,7 @@ import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
+import com.alibaba.fastjson.JSON;
 import com.andreabaccega.widget.FormEditText;
 import com.lidroid.xutils.ViewUtils;
 import com.lidroid.xutils.view.annotation.ViewInject;
@@ -104,6 +105,11 @@ public class LeaveActivity extends BaseActivity  implements  OnClickListener{
     private String va_code;
     private String jsondata;
     private Context ct;
+
+    private String et_emcode;
+    private String et_code;
+    private String et_recoder;
+
     private CustomProgressDialog progressDialog;
     private List<String> lists = new ArrayList<String>();
     public Handler handler = new Handler() {
@@ -302,26 +308,30 @@ public class LeaveActivity extends BaseActivity  implements  OnClickListener{
                 }
             }
 
+
             /**
              * @param leaveEntities
              */
             private void initDataFromServer(List<LeaveEntity> leaveEntities) {
                 LeaveEntity leaveEntitie = leaveEntities.get(0);
                 et_leave_man.setText(leaveEntitie.getVa_emname());
-                et_leave_days.setText(String.valueOf(
-                        leaveEntitie.getVa_alldays()));
+                et_leave_days.setText(String.valueOf(leaveEntitie.getVa_alldays()));
                 et_leave_category.setText(leaveEntitie.getVa_vacationtype());
-                et_leave_hours.setText(String.valueOf(
-                        leaveEntitie.getVa_alltimes()));
+                et_leave_hours.setText(String.valueOf(leaveEntitie.getVa_alltimes()));
                 et_leave_reason.setText(leaveEntitie.getVa_remark());
                 et_leave_type.setText(leaveEntitie.getVa_holidaytype());
                 et_leave_mankind.setText(leaveEntitie.getVa_mankind());
-
                 tv_start_time.setText(leaveEntitie.getVa_startime().substring(0,leaveEntitie.getVa_startime().length()-3));
                 tv_end_time.setText(leaveEntitie.getVa_endtime().substring(0, leaveEntitie.getVa_endtime().length()-3));
-
                 String status = leaveEntities.get(0).getVa_status();
 
+                et_code=leaveEntitie.getVa_code();
+                et_recoder=leaveEntitie.getVa_recordor();
+                et_emcode=leaveEntitie.getVa_emcode();
+                System.out.println("et_code:"+et_code);
+                System.out.println("et_recoder:"+et_recoder);
+                System.out.println("et_emcode:"+et_emcode);
+                System.out.println("初始化数据:"+ JSON.toJSONString(leaveEntitie));
                 if (!StringUtils.isEmpty(status)) {
                     if ("已提交".equals(status)) {
                         bt_commit.setTextColor(getResources()
@@ -558,7 +568,6 @@ public class LeaveActivity extends BaseActivity  implements  OnClickListener{
                 "mobile/common/getPanel.action";
             String sessionId = CommonUtil.getSharedPreferences(this, "sessionId");
             Map<String, Object> params = new HashMap<String, Object>();
-
             params.put("caller", caller);
             params.put("formCondition", formCondition);
             params.put("gridCondition", gridCondition);
@@ -620,7 +629,11 @@ public class LeaveActivity extends BaseActivity  implements  OnClickListener{
         if (va_id!= 0) {
             entity.setVa_id(va_id);
         }
-        entity.setVa_code(va_code);
+        if (StringUtils.isEmpty(et_code)) {
+            entity.setVa_code(va_code);//save
+        }else{
+            entity.setVa_code(et_code);//update
+        }
         entity.setVa_status("在录入");
         entity.setVa_statuscode("ENTERING");
         entity.setVa_mankind(et_leave_mankind.getText().toString());
@@ -631,10 +644,18 @@ public class LeaveActivity extends BaseActivity  implements  OnClickListener{
         entity.setVa_vacationtype(et_leave_category.getText().toString());
         entity.setVa_remark(et_leave_reason.getText().toString());
         entity.setVa_date(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
-        entity.setVa_startime(tv_start_time.getText().toString()+":00");
-        entity.setVa_endtime(tv_end_time.getText().toString()+":00");
-        entity.setVa_recordor(CommonUtil.getSharedPreferences(ct, "erp_emname"));
-        entity.setVa_emcode(va_code);
+        entity.setVa_startime(tv_start_time.getText().toString() + ":00");
+        entity.setVa_endtime(tv_end_time.getText().toString() + ":00");
+        if (StringUtils.isEmpty(et_recoder)) {
+            entity.setVa_recordor(CommonUtil.getSharedPreferences(ct, "erp_emname"));
+        }else{
+            entity.setVa_recordor(et_recoder);
+        }
+        if (StringUtils.isEmpty(et_emcode)){
+        entity.setVa_emcode(CommonUtil.getSharedPreferences(ct, "erp_username"));}
+        else{
+            entity.setVa_emcode(et_emcode);
+        }
         return entity;
     }
 
@@ -686,16 +707,11 @@ public class LeaveActivity extends BaseActivity  implements  OnClickListener{
         Map<String, Object> params = new HashMap<String, Object>();
         params.put("id", String.valueOf(va_id));
         params.put("caller", "Ask4Leave");
-
-        if (StringUtils.isEmpty(jsondata)) {
-            LeaveEntity entity = getSaveJsonData();
-            jsondata = FlexJsonUtil.toJson(entity);
-            System.out.println("更新:"+jsondata);
-        }
-
+        LeaveEntity entity = getSaveJsonData();
+        jsondata = FlexJsonUtil.toJson(entity);
+        System.out.println("更新:"+jsondata);
         params.put("formStore", jsondata);
         params.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
-
         LinkedHashMap<String , Object> headers=new LinkedHashMap<>();
         headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
         ViewUtil.httpSendRequest(ct, url, params, handler, headers, SUCCESS_UPDATE, null, null, "get");

+ 693 - 714
WeiChat/src/main/java/com/sk/weichat/ui/erp/net/ViewUtil.java

@@ -37,6 +37,7 @@ import android.content.Intent;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.support.v4.content.LocalBroadcastManager;
 import android.text.Editable;
 import android.text.TextUtils;
 import android.text.TextWatcher;
@@ -58,100 +59,98 @@ import android.widget.Toast;
 
 @SuppressWarnings("deprecation")
 public class ViewUtil {
-	public static Context ct;
-	public static String erp_phone;
-	public static String erp_password;
-	public static String erp_master;
-	public static String erp_username;
-	public static String erp_baseurl;
-	public static String b2b_uu;
-	public static String erp_uu;//推送切公司
-	public static String erp_masterId;//推送切公司   
-	public static String erp_company;
-	public static MaterialDialog mdProcessDialog;
-
-	/**
-	 * 获取Listview的高度
-	 * 
-	 * @param listView
-	 * @return
-	 */
-	public static void setListViewHeightBasedOnChildren(ListView listView) {
-		ListAdapter listAdapter = listView.getAdapter();
-		if (listAdapter == null) {
-			return;
-		}
-
-		int totalHeight = 0;
-		for (int i = 0; i < listAdapter.getCount(); i++) {
-			View listItem = listAdapter.getView(i, null, listView);
-			listItem.measure(0, 0);
-			totalHeight += listItem.getMeasuredHeight();
-		}
-
-		ViewGroup.LayoutParams params = listView.getLayoutParams();
-		params.height = totalHeight
-				+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
-		listView.setLayoutParams(params);
-	}
-
-	
-	
-	/**
-	 * 获取Listview的高度,然后设置ViewPager的高度
-	 * 
-	 * @param listView
-	 * @return
-	 */
-	public static int setListViewHeightBasedOnChildren1(ListView listView) {
-		// 获取ListView对应的Adapter
-		ListAdapter listAdapter = listView.getAdapter();
-		if (listAdapter == null) {
-			// pre-condition
-			return 0;
-		}
-		int totalHeight = 0;
-		for (int i = 0, len = listAdapter.getCount(); i < len; i++) { // listAdapter.getCount()返回数据项的数目
-			View listItem = listAdapter.getView(i, null, listView);
-			listItem.measure(0, 0); // 计算子项View 的宽高
-			totalHeight += listItem.getMeasuredHeight(); // 统计所有子项的总高度
-		}
-
-		ViewGroup.LayoutParams params = listView.getLayoutParams();
-		params.height = totalHeight
-				+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
-		// listView.getDividerHeight()获取子项间分隔符占用的高度
-		// params.height最后得到整个ListView完整显示需要的高度
-		listView.setLayoutParams(params);
-		return params.height;
-	}
-
-
-
-	/**
-	 * 弹出Toast消息
-	 * 
-	 * @param msg
-	 */
-	public static void ToastMessage(Context cont, String msg) {
-		Toast.makeText(cont, msg, Toast.LENGTH_SHORT).show();
-	}
-
-	public static void ToastMessage(Context cont, int msg) {
-		Toast.makeText(cont, msg, Toast.LENGTH_SHORT).show();
-	}
-
-	public static void ToastMessage(Context cont, String msg, int time) {
-		Toast.makeText(cont, msg, time).show();
-	}
-
-	public static void ShowAppCrashTitle(Context ct) {
-		new MaterialDialog.Builder(ct).title("信息提示").content("系统出现未知错误,很抱歉!")
-				.show();
-	}
+    public static Context ct;
+    public static String erp_phone;
+    public static String erp_password;
+    public static String erp_master;
+    public static String erp_username;
+    public static String erp_baseurl;
+    public static String b2b_uu;
+    public static String erp_uu;//推送切公司
+    public static String erp_masterId;//推送切公司
+    public static String erp_company;
+    public static MaterialDialog mdProcessDialog;
+
+    /**
+     * 获取Listview的高度
+     *
+     * @param listView
+     * @return
+     */
+    public static void setListViewHeightBasedOnChildren(ListView listView) {
+        ListAdapter listAdapter = listView.getAdapter();
+        if (listAdapter == null) {
+            return;
+        }
+
+        int totalHeight = 0;
+        for (int i = 0; i < listAdapter.getCount(); i++) {
+            View listItem = listAdapter.getView(i, null, listView);
+            listItem.measure(0, 0);
+            totalHeight += listItem.getMeasuredHeight();
+        }
+
+        ViewGroup.LayoutParams params = listView.getLayoutParams();
+        params.height = totalHeight
+                + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
+        listView.setLayoutParams(params);
+    }
+
+
+    /**
+     * 获取Listview的高度,然后设置ViewPager的高度
+     *
+     * @param listView
+     * @return
+     */
+    public static int setListViewHeightBasedOnChildren1(ListView listView) {
+        // 获取ListView对应的Adapter
+        ListAdapter listAdapter = listView.getAdapter();
+        if (listAdapter == null) {
+            // pre-condition
+            return 0;
+        }
+        int totalHeight = 0;
+        for (int i = 0, len = listAdapter.getCount(); i < len; i++) { // listAdapter.getCount()返回数据项的数目
+            View listItem = listAdapter.getView(i, null, listView);
+            listItem.measure(0, 0); // 计算子项View 的宽高
+            totalHeight += listItem.getMeasuredHeight(); // 统计所有子项的总高度
+        }
+
+        ViewGroup.LayoutParams params = listView.getLayoutParams();
+        params.height = totalHeight
+                + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
+        // listView.getDividerHeight()获取子项间分隔符占用的高度
+        // params.height最后得到整个ListView完整显示需要的高度
+        listView.setLayoutParams(params);
+        return params.height;
+    }
+
+
+    /**
+     * 弹出Toast消息
+     *
+     * @param msg
+     */
+    public static void ToastMessage(Context cont, String msg) {
+        Toast.makeText(cont, msg, Toast.LENGTH_SHORT).show();
+    }
+
+    public static void ToastMessage(Context cont, int msg) {
+        Toast.makeText(cont, msg, Toast.LENGTH_SHORT).show();
+    }
+
+    public static void ToastMessage(Context cont, String msg, int time) {
+        Toast.makeText(cont, msg, time).show();
+    }
+
+    public static void ShowAppCrashTitle(Context ct) {
+        new MaterialDialog.Builder(ct).title("信息提示").content("系统出现未知错误,很抱歉!")
+                .show();
+    }
 
 	/*public static void ShowBasicNoTitle(Context ct) {
-		new MaterialDialog.Builder(ct).title(""
+        new MaterialDialog.Builder(ct).title(""
 				+ "信息提示").content("您还未登录,请登录!")
 				.positiveText("确定").negativeText("取消").autoDismiss(false)
 				.callback(new ButtonCallback() {
@@ -168,626 +167,606 @@ public class ViewUtil {
 				}).show();
 	}*/
 
-	public static void ShowMessageTitle(Context ct, String msg) {
-		final MaterialDialog messageDialog=  new MaterialDialog.Builder(ct).title("系統提示").content(msg)
-				.positiveText("关闭").autoDismiss(false)
-				.callback(new ButtonCallback() {
-					@Override
-					public void onPositive(MaterialDialog dialog) {
-						dialog.dismiss();
-					}
-				}).show();
-	
-		
-	}
-	
-	
-	public static void ShowMessageTitleAutoDismiss(Context ct, String msg,long time) {
-		final MaterialDialog messageDialog=  new MaterialDialog.Builder(ct).title("系統提示").content(msg)
-				.positiveText("关闭").autoDismiss(false)
-				.callback(new ButtonCallback() {
-					@Override
-					public void onPositive(MaterialDialog dialog) {
-						dialog.dismiss();
-					}
-				}).show();
-		handler.postDelayed(new Runnable() {
-			@Override
-			public void run() {
-				messageDialog.dismiss();
-			}
-		}, time);
-	}
-
-
-	private static EditText phone;
-	private static EditText password;// 密码
-	private static View positiveAction;
-
-
-
-	public static String getDataFromServer(String url,
-			Map<String, String> params, String method) {
-		String result = null;
-		HttpClient hClient = new HttpClient();
-		try {
-			if (method.equals("get")) {
-				result = hClient.sendGetRequest(url, params);
-			}
-			if (method.equals("post")) {
-				result = hClient.sendPostRequest(url, params);
-			}
-		} catch (Exception e) {
-			handler.sendEmptyMessage(Constants.SocketTimeoutException);
-		}
-		return result;
-	}
-	
-	
-
-	public static void startNetThread(final String url,
-			final Map<String, String> params, final Handler handler,
-			final int what, final Message message, final Bundle bundle,
-			final String request) {
-		new Thread(new Runnable() {
-
-			@Override
-			public void run() {
-				boolean isNetHas = true;
-				if (isNetHas) {
-					/** @注释:处理网络请求返回结果 */
-					String result = getDataFromServer(url, params, request);
-					Log.i("result","result:"+result);
-					if (result != null) {
-						if (bundle == null || message == null) {
-							Bundle bundle = new Bundle();
-							Message message = new Message();
-							bundle.putString("result", result);
-							message.setData(bundle);
-							message.what = what;
-							handler.sendMessage(message);
-						} else {
-							bundle.putString("result", result);
-							message.setData(bundle);
-							message.what = what;
-							handler.sendMessage(message);
-						}
-					} else {
-						// ToastMessage(ct, "服务器未知错误!");
-					}
-				} else {
-					// ToastMessage(ct, "网络未连接!");
-				
-				}
-			}
-		}).start();
-	}
-
-	
-	public static void startNetThread(final Context ct,final String url,
-			final Map<String, String> params, final Handler handler,
-			final int what, final Message message, final Bundle bundle,
-			final String request) {
-		new Thread(new Runnable() {
-
-			@Override
-			public void run() {
-				boolean isNetHas = CommonUtil.isNetWorkConnected(ct);
-				if (isNetHas) {
-					String result = getDataFromServer(url, params, request);
-					Log.i("result", "http:"+result);
-					if (result != null) {
-						if (bundle == null || message == null) {
-							Bundle bundle = new Bundle();
-							Message message = new Message();
-							bundle.putString("result", result);
-							message.setData(bundle);
-							message.what = what;
-							handler.sendMessage(message);
-						} else {
-							bundle.putString("result", result);
-							message.setData(bundle);
-							message.what = what;
-							handler.sendMessage(message);
-						}
-					} else {
-						// ToastMessage(ct, "服务器未知错误!");
-					}
-				} else {
-					Bundle bundle = new Bundle();
-					Message message = new Message();
-					bundle.putString("result", "{\"exception\":\"网络未连接\"}");
-					message.setData(bundle);
-					message.what = what;
-					handler.sendMessage(message);
-				}
-			}
-		}).start();
-	}
-	/** @注释:登录功能 */
-	public static void LoginTask(String user_phone, String user_password, Context ct) {
-		ViewUtil.ct=ct;
-		mdProcessDialog = new MaterialDialog.Builder(ct).title("登录")
-				.content("登录验证中,请稍等...").progress(true, 0)
-				.progressIndeterminateStyle(false).build();
-		mdProcessDialog.show();
-		String url = Constants.BASE_URL_LOGIN;
-		Map<String, String> params = new HashMap<String, String>();
-		params.put("user", user_phone);
-		params.put("password", user_password);
-		Message message = new Message();
-		Bundle bundle = new Bundle();
-		bundle.putString("phone", user_phone);
-		bundle.putString("password", user_password);
-		startNetThread(url, params, handler, Constants.SUCCESS_LOGIN, message,
-				bundle, "get");
-	}
-
-	// 登录B2B
-	public static void LoginB2BTask(String phone, String password) {
-		mdProcessDialog.setContent("正在验证B2B...");
-		String url = Constants.serviceURL;
-		Map<String, String> params = new HashMap<String, String>();
-		params.put("j_username", phone);
-		params.put("j_password", password);
-		startNetThread(url, params, handler, Constants.SUCCESS_B2B, null, null,
-				"post");
-	}
-
-	// 登录ERP
-	public static void LoginERPTask(String url, String master, String username,
-			String password) {
-		mdProcessDialog.setContent("正在验证ERP...");
-		url = url + "mobile/login.action";
-		Map<String, String> params = new HashMap<String, String>();
-		params.put("username", username);
-		params.put("password", password);
-		params.put("master", master);
-		startNetThread(url, params, handler, Constants.SUCCESS_ERP, null, null,
-				"post");
-	}
-
-	private static List<LoginEntity> erpEntities;
-	public static Handler handler= new Handler() {
-		public void handleMessage(Message msg) {
-			switch (msg.what) {
-			case Constants.SUCCESS_LOGIN:
-				LoginSucess(msg);
-				break;
-			case Constants.SUCCESS_ERP:
-				String result=msg.getData().getString("result");
-				boolean success=JSON.parseObject(result).getBoolean("success");
-				if (success) {
-					ChangeStatusERP(msg.getData().getString("result"));
-				}else{
-					String reason=JSON.parseObject(result).getString("reason");
-					ToastMessage(ct, reason);
-				}
-				break;
-			case Constants.SUCCESS_B2B:
-				ChangeStatusB2B(msg.getData().getString("result"));
-				break;
-			case Constants.SocketTimeoutException:
-				if (mdProcessDialog != null && mdProcessDialog.isShowing()) {
-					mdProcessDialog.dismiss();
-				}
-				break;
-			default:
-				break;
-			}
-		}
-
-	};
-
-	public static void ChangeStatusERP(String result) {
-		System.out.println("login erp:" + result);
-		if(mdProcessDialog!=null){
-			mdProcessDialog.setContent("UAS验证成功!");
-		}
-		if (ct==null)ct= MyApplication.getInstance();
-		Map<String, Object> dataMap = FlexJsonUtil.fromJson(result);
-		try {
-			CommonUtil.setSharedPreferences(ct, "sessionId",
-					dataMap.get("sessionId").toString());
-			CommonUtil.setSharedPreferences(ct, "erp_username",
-					dataMap.get("erpaccount").toString());
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		Log.i("liu","baseurl="+erp_baseurl);
-		Log.i("liu","phone="+erp_phone);
-		Log.i("liu", "password=" + erp_password);
-		//必须补位空,才能不覆盖原有的根路径
-		if(!StringUtils.isEmpty(erp_baseurl)){
-		CommonUtil.setSharedPreferences(ct, "erp_baseurl", erp_baseurl);
-		CommonUtil.setSharedPreferences(ct, "erp_master", erp_master);
-		CommonUtil.setSharedPreferences(ct, "erp_commpany", erp_company);
-		CommonUtil.setSharedPreferences(ct, "erp_uu", erp_uu);
-		CommonUtil.setSharedPreferences(ct, "erp_masterId", erp_masterId);
-		CommonUtil.setSharedPreferences(ct, "erp_login", true);
-		}
-		if (erp_phone != null) {
-			CommonUtil.setSharedPreferences(ct, "user_phone", erp_phone);
-			CommonUtil.setSharedPreferences(ct, "user_password", erp_password);
-		}
-		handler.postDelayed(new Runnable() {
-			@Override
-			public void run() {
-				if(mdProcessDialog!=null){
-				  mdProcessDialog.cancel();
-				}
-			}
-		}, 800);
-		if(ct instanceof Activity){
-			if (((Activity)ct) instanceof MainActivity){}else{
-				ct.startActivity(new Intent(ct, DataDownloadActivity.class));
-			}
-		}
-		sendBrodcast("ERP");
-	}
-
-	public static void ChangeStatusB2B(String result) {
-		if (erp_phone != null) {
-			CommonUtil.setSharedPreferences(ct, "user_phone", erp_phone);
-			CommonUtil.setSharedPreferences(ct, "user_password", erp_password);
-		}
-		if (ct==null)ct= MyApplication.getInstance();
-		CommonUtil.setSharedPreferences(ct, "b2b_login", true);
-		CommonUtil.setSharedPreferences(ct, "b2b_uu", b2b_uu);
-		mdProcessDialog.setContent("验证B2B成功!");
-		handler.postDelayed(new Runnable() {
-			@Override
-			public void run() {
-				mdProcessDialog.cancel();
-			}
-		}, 1000);
-		sendBrodcast("B2B");
-	}
-
-	public static void sendBrodcast(String falg) {
-		Intent intent = new Intent("com.app.home.update");
-		intent.putExtra("falg", falg);
-		if (ct != null) {
-			ct.sendBroadcast(intent);
-		}
-	}
-
-/*	public static void appRegisterPush(final String username) {
-		if (!CommonUtil.getSharedPreferencesBoolean(ct, "isPush", true)
-				&&StringUtils.isEmpty(username)) {
-			return ;
-		}
-		XGPushManager.registerPush(ct, username, new XGIOperateCallback() {
-			@Override
-			public void onSuccess(Object data, int flag) {
-				Log.i("registerPush", "信鸽注册成功!");
-				Log.i("registerPush", "信鸽注册name=" + username);
-				CommonUtil.setSharedPreferences(ct, "push_id", username);
-			}
-
-			@Override
-			public void onFail(Object data, int errCode, String msg) {
-				Log.i("registerPush", "信鸽注册失败!" + msg);
-				Log.i("registerPush", "信鸽注册name=" + username);
-			}
-		});
-	}
-
-	public static void appUnRegisterPush(final String username) {
-		   Log.i("registerPush", "信鸽反注册 name:" + username);
-		   XGPushManager.unregisterPush(ct);
-		}*/
-
-	private static void loginERPItemDialog(final String phone,
-			final String password) {
-		String[] items = new String[erpEntities.size()];
-		for (int j = 0; j < erpEntities.size(); j++) {
-			items[j] = erpEntities.get(j).getName();
-		}
-		new MaterialDialog.Builder(ct)
-				.title("选择登录的UAS账套")
-				.items(items)
-				.itemsCallbackSingleChoice(0,
-						new MaterialDialog.ListCallbackSingleChoice() {
-							@Override
-							public boolean onSelection(MaterialDialog dialog,
-									View view, int which, CharSequence text) {
-								if (!StringUtils.isEmpty(text.toString())) {
-									// 拿到公司名字,取它对应的账套信息
-									for (int j2 = 0; j2 < erpEntities.size(); j2++) {
-										if (text.toString().equals(
-												erpEntities.get(j2).getName())) {
-											LoginEntity entity = erpEntities
-													.get(j2);
-											erp_phone=phone;
-											erp_password=password;
-											erp_username = entity.getAccount();
-											erp_master = entity.getMaster();
-											erp_baseurl = entity.getWebsite();
-											erp_company = entity.getName();
-											erp_uu = String.valueOf(entity
-													.getEnuu());
-											erp_masterId=String.valueOf(entity.getMasterId());
-											LoginERPTask(entity.getWebsite(),
-													entity.getMaster(), phone, password);
-										}
-									}
-								}
-								return true; // allow selection
-							}
-						}).positiveText("确定").show();
-	}
-
-	
-	/**
-	  * @author Administrator
-	  * @功能:管理平台的返回信息处理
-	  */
-	public static void LoginSucess(Message msg) {
-		String json = msg.getData().getString("result");
-		CommonUtil.setSharedPreferences(ct, "loginJson", json);// 保存在本地
-		String phone = msg.getData().getString("phone");
-		String password = msg.getData().getString("password");
-		//appRegisterPush(phone);//注册
-		Log.i("Login", "login sucess:" + json);
-		List<LoginEntity> logMsg =JSON.parseArray(json,LoginEntity.class);
-		erpEntities = new ArrayList<LoginEntity>();
-		if (logMsg != null && !logMsg.isEmpty()) {
-			for (int i = 0; i < logMsg.size(); i++) {
-				LoginEntity map = logMsg.get(i);
-				if (map.getPlatform().equals("ERP")) {
-					erpEntities.add(map);//ERP账户累加到数组
-				} else if (map.getPlatform().equals("B2B")) {
-					b2b_uu = map.getAccount();
-					LoginB2BTask(phone, password);//登录B2B
-				}
-
-			}
-			if (erpEntities.size() == 1) {// erp账户的数量是多个,一个默认进入,多个让用户选进入
-				LoginEntity entity = erpEntities.get(0);
-				erp_phone=phone;
-				erp_password=password;
-				erp_username = entity.getAccount();
-				erp_master = entity.getMaster();
-				erp_baseurl = entity.getWebsite();
-				erp_uu = String.valueOf(entity.getEnuu());
-				erp_company = entity.getName();
-				erp_masterId=String.valueOf(entity.getMasterId());
-				LoginERPTask(entity.getWebsite(), entity.getMaster(), phone, password);
-			} else if (erpEntities.size() > 1) {
-				loginERPItemDialog(phone, password);
-			}
-		} else {
-			mdProcessDialog.setContent("手机号或者密码失败!");
-			handler.postDelayed(new Runnable() {
-				@Override
-				public void run() {
-					mdProcessDialog.cancel();
-				}
-			}, 2000);
-		}
-	};
-
-	/**
-	 * @author LiuJie
-	 * @功能:比较两个日期大小
-	 */
-	public static boolean isCheckDateTime(String DATE1, String DATE2,
-			String format) {
-		DateFormat df = new SimpleDateFormat(format);
-		try {
-			Date dt1 = df.parse(DATE1);
-			Date dt2 = df.parse(DATE2);
-			if (dt1.getTime() > dt2.getTime()) {
-				System.out.println("dt1 在dt2前");
-				return true;
-			} else if (dt1.getTime() < dt2.getTime()) {
-				System.out.println("dt1在dt2后");
-				return false;
-			} else {
-				return true;
-			}
-		} catch (Exception exception) {
-			exception.printStackTrace();
-		}
-		return true;
-	}
-
-	public static void getDataFormServer(Context ct, Handler handler,
-			String url, Map<String, String> param, int what) {
-		ViewUtil.ct = ct;
-		startNetThread(url, param, handler, what, null, null, "get");
-	}
-
-	/**
-	 * 判断某个界面是否在前台
-	 * @param context
-	 * @param className
-	 *            某个界面名称
-	 */
-	public static boolean isForeground(Context context, String className) {
-		if (context == null || TextUtils.isEmpty(className)) {
-			return false;
-		}
-		ActivityManager am = (ActivityManager) context
-				.getSystemService(Context.ACTIVITY_SERVICE);
-		List<RunningTaskInfo> list = am.getRunningTasks(1);
-		if (list != null && list.size() > 0) {
-			ComponentName cpn = list.get(0).topActivity;
-			if (className.equals(cpn.getClassName())) {
-				return true;
-			}
-		}
-
-		return false;
-	}
-	
-	/**
-	  * @author Administrator
-	  * @功能:封装网络请求 httpclient4.3
-	  */
-	public static void httpSendRequest(
-			final Context ct,
-			final String url,
-			final Map<String, Object> params,
-			final Handler handler,
-			final LinkedHashMap<String, Object> headers,
-			final int what,
-			final Message message,
-			final Bundle bundle,
-			final String request) {
-		new Thread(new Runnable() {
-
-			@Override
-			public void run() {
-				boolean isNetHas =CommonUtil.isNetWorkConnected(ct);
-				if (isNetHas) {
-					HttpUtil.Response result =httpSendTask(url, params, headers, request);
-					if (result!=null) {
-						Log.i("result", "http 请求-----------------------------------------");
-						Log.i("result", "result:"+result);
-						Log.i("result", "url:"+url);
-						Log.i("result", "parm:"+params.toString());
-						Log.i("result", "statusCode:"+result.getStatusCode());
-						Log.i("result", "text:"+result.getResponseText());
-						Log.i("result", "http 响应-----------------------------------------");
-						if (result.getStatusCode()==200) {
-							if (bundle == null || message == null) {
-								Bundle bundle = new Bundle();
-								Message message = new Message();
-								bundle.putString("result", result.getResponseText());
-								message.setData(bundle);
-								message.what = what;
-								handler.sendMessage(message);
-							} else {
-								bundle.putString("result", result.getResponseText());
-								message.setData(bundle);
-								message.what = what;
-								handler.sendMessage(message);
-							}
-						} else {
-							String exception="未知错误";
-							if (result.getStatusCode()==500) {
-								if (new JsonValidator().validate(result.responseText)) {
-									exception=JSON.parseObject(result.responseText).getString("exceptionInfo");
-								}else{
-									exception="500系统错误";
-								}
-							}
-							if(result.getStatusCode()==404){
-								exception="404系统错误";
-							}
-							Log.i("Http", "非200响应:"+result.getResponseText());
-							Bundle bundle = new Bundle();
-							Message message = new Message();
-							bundle.putString("result", exception);
-							message.setData(bundle);
-							message.what = Constants.APP_SOCKETIMEOUTEXCEPTION;
-							handler.sendMessage(message);
-						}
-					}else{
-						Bundle bundle = new Bundle();
-						Message message = new Message();
-						bundle.putString("result", "服务器异常!");
-						message.setData(bundle);
-						message.what =Constants.APP_SOCKETIMEOUTEXCEPTION;
-						handler.sendMessage(message);
-					}
-				} else {
-					Bundle bundle = new Bundle();
-					Message message = new Message();
-					bundle.putString("result", "网络未连接!");
-					message.setData(bundle);
-					message.what =Constants.APP_SOCKETIMEOUTEXCEPTION;
-					handler.sendMessage(message);
-				}
-			}
-		}).start();
-	}
-	
-	public static HttpUtil.Response httpSendTask(
-			String url,
-			Map<String, Object> params,
-			LinkedHashMap<String, Object> headers,
-			String method) {
-		    HttpUtil.Response response = null;
-			try {
-			if (method.equals("get")) {
-				response = HttpUtil.sendGetRequest(url, params, headers, false);
-			}
-			if (method.equals("post")) {
-			    response = HttpUtil.sendGetRequest(url, params, headers, false);
-			}
-			} catch (Exception e) {
-					e.printStackTrace();
-		    }
-		return response;
-	}
-	
-	public static String getExceptionMsg(Context ct, Throwable ex) {
-		StringBuffer sb = new StringBuffer();
-		sb.append("----------------------异常信息输出-------------------------------------\n");
-		Writer writer = new StringWriter();
-		PrintWriter printWriter = new PrintWriter(writer);
-		ex.printStackTrace(printWriter);
-		// 原因打印
-		Throwable cause = ex.getCause();
-		while (cause != null) {
-			cause.printStackTrace(printWriter);
-			cause = cause.getCause();
-		}
-		printWriter.close();
-		String result = writer.toString();
-		String phone=CommonUtil.getSharedPreferences(ct, "user_phone");
-		String password=CommonUtil.getSharedPreferences(ct, "user_password");
-		String master_ch=CommonUtil.getSharedPreferences(ct, "Master_ch");
-		String company =CommonUtil.getSharedPreferences(ct, "erp_commpany");
-		sb.append(result);
-		sb.append("\n----------------------用户信息输出-------------------------------------");
-		sb.append("\n phone:"+phone);
-		sb.append("\n password:"+password);
-		sb.append("\n master_ch:"+master_ch);
-		sb.append("\n company:"+company);
-		sb.append("\n----------------------设备信息输出-------------------------------------");
-		//获取设备大小
-		String deviceInfo=CommonUtil.getDeviceInfo(ct);
-	    System.out.println("deviceInfo="+deviceInfo);
-	    sb.append("\n"+deviceInfo);
-	    sb.append("\n手机型号:"+CommonUtil.getDeviceModel());
-	    sb.append("\n手机生产厂商:"+CommonUtil.getDeviceManufacturer());
-	    //获取应用程序内存使用情况
-	    sb.append("\n----------------------内存信息输出-------------------------------------\n");	    
-		sb.append(CommonUtil.getMemory());
-		//获取应用程序的当前版本号
-	    sb.append("\n----------------------版本信息输出-------------------------------------\n");	    
-	    sb.append("\n应用版本号:"+CommonUtil.ApkVersionCode(ct));
-	    return sb.toString();
-	}
-
-    /**@注释:ERP自动登录 */
-	public static void AutoLoginErp(Context ct,Handler handler){
-		Log.i("LoginErp", "自动登录...");
-		if (!StringUtils.isEmpty(Constants.getAppBaseUrl(ct))) {
-			String url = Constants.getAppBaseUrl(ct);
-			String master = CommonUtil.getSharedPreferences(ct, "erp_master");
-			String phone = CommonUtil.getSharedPreferences(ct, "user_phone");
-			String password = CommonUtil.getSharedPreferences(ct, "user_password");
-			Log.i("LoginErp", "自动登录..." + url);
-			Log.i("LoginErp", "master..." + master);
-			Log.i("LoginErp", "phone..." + phone);
-			Log.i("LoginErp", "password..." + password);
-			LoginERPTask(ct,handler,url, master, phone, password);
-		}
-
-	}
-
-	// 登录ERP
-	public static void LoginERPTask(Context ct,Handler mhandler,String url, String master, String username, String password) {
-		url = url + "mobile/login.action";
-		Map<String, Object> params = new HashMap<String,  Object>();
-		params.put("username", username);
-		params.put("password", password);
-		params.put("master", master);
-		httpSendRequest(ct, url, params, handler, null, Constants.SUCCESS_ERP, null, null, "post");
-	}
+    public static void ShowMessageTitle(Context ct, String msg) {
+        final MaterialDialog messageDialog = new MaterialDialog.Builder(ct).title("系統提示").content(msg)
+                .positiveText("关闭").autoDismiss(false)
+                .callback(new ButtonCallback() {
+                    @Override
+                    public void onPositive(MaterialDialog dialog) {
+                        dialog.dismiss();
+                    }
+                }).show();
+
+
+    }
+
+
+    public static void ShowMessageTitleAutoDismiss(Context ct, String msg, long time) {
+        final MaterialDialog messageDialog = new MaterialDialog.Builder(ct).title("系統提示").content(msg)
+                .positiveText("关闭").autoDismiss(false)
+                .callback(new ButtonCallback() {
+                    @Override
+                    public void onPositive(MaterialDialog dialog) {
+                        dialog.dismiss();
+                    }
+                }).show();
+        handler.postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                messageDialog.dismiss();
+            }
+        }, time);
+    }
+
+
+    private static EditText phone;
+    private static EditText password;// 密码
+    private static View positiveAction;
+
+
+    public static String getDataFromServer(String url,
+                                           Map<String, String> params, String method) {
+        String result = null;
+        HttpClient hClient = new HttpClient();
+        try {
+            if (method.equals("get")) {
+                result = hClient.sendGetRequest(url, params);
+            }
+            if (method.equals("post")) {
+                result = hClient.sendPostRequest(url, params);
+            }
+        } catch (Exception e) {
+            handler.sendEmptyMessage(Constants.SocketTimeoutException);
+        }
+        return result;
+    }
+
+
+    public static void startNetThread(final String url,
+                                      final Map<String, String> params, final Handler handler,
+                                      final int what, final Message message, final Bundle bundle,
+                                      final String request) {
+        new Thread(new Runnable() {
+
+            @Override
+            public void run() {
+                boolean isNetHas = true;
+                if (isNetHas) {
+                    /** @注释:处理网络请求返回结果 */
+                    String result = getDataFromServer(url, params, request);
+                    Log.i("result", "result:" + result);
+                    if (result != null) {
+                        if (bundle == null || message == null) {
+                            Bundle bundle = new Bundle();
+                            Message message = new Message();
+                            bundle.putString("result", result);
+                            message.setData(bundle);
+                            message.what = what;
+                            handler.sendMessage(message);
+                        } else {
+                            bundle.putString("result", result);
+                            message.setData(bundle);
+                            message.what = what;
+                            handler.sendMessage(message);
+                        }
+                    } else {
+                        // ToastMessage(ct, "服务器未知错误!");
+                    }
+                } else {
+                    // ToastMessage(ct, "网络未连接!");
+
+                }
+            }
+        }).start();
+    }
+
+
+    public static void startNetThread(final Context ct, final String url,
+                                      final Map<String, String> params, final Handler handler,
+                                      final int what, final Message message, final Bundle bundle,
+                                      final String request) {
+        new Thread(new Runnable() {
+
+            @Override
+            public void run() {
+                boolean isNetHas = CommonUtil.isNetWorkConnected(ct);
+                if (isNetHas) {
+                    String result = getDataFromServer(url, params, request);
+                    Log.i("result", "http:" + result);
+                    if (result != null) {
+                        if (bundle == null || message == null) {
+                            Bundle bundle = new Bundle();
+                            Message message = new Message();
+                            bundle.putString("result", result);
+                            message.setData(bundle);
+                            message.what = what;
+                            handler.sendMessage(message);
+                        } else {
+                            bundle.putString("result", result);
+                            message.setData(bundle);
+                            message.what = what;
+                            handler.sendMessage(message);
+                        }
+                    } else {
+                        // ToastMessage(ct, "服务器未知错误!");
+                    }
+                } else {
+                    Bundle bundle = new Bundle();
+                    Message message = new Message();
+                    bundle.putString("result", "{\"exception\":\"网络未连接\"}");
+                    message.setData(bundle);
+                    message.what = what;
+                    handler.sendMessage(message);
+                }
+            }
+        }).start();
+    }
+
+    /**
+     * @注释:登录功能
+     */
+    public static void LoginTask(String user_phone, String user_password, Context ct) {
+        ViewUtil.ct = ct;
+        mdProcessDialog = new MaterialDialog.Builder(ct).title("登录")
+                .content("登录验证中,请稍等...").progress(true, 0)
+                .progressIndeterminateStyle(false).build();
+        mdProcessDialog.show();
+        String url = Constants.BASE_URL_LOGIN;
+        Map<String, String> params = new HashMap<String, String>();
+        params.put("user", user_phone);
+        params.put("password", user_password);
+        Message message = new Message();
+        Bundle bundle = new Bundle();
+        bundle.putString("phone", user_phone);
+        bundle.putString("password", user_password);
+        startNetThread(url, params, handler, Constants.SUCCESS_LOGIN, message,
+                bundle, "get");
+    }
+
+    // 登录B2B
+    public static void LoginB2BTask(String phone, String password) {
+        mdProcessDialog.setContent("正在验证B2B...");
+        String url = Constants.serviceURL;
+        Map<String, String> params = new HashMap<String, String>();
+        params.put("j_username", phone);
+        params.put("j_password", password);
+        startNetThread(url, params, handler, Constants.SUCCESS_B2B, null, null,
+                "post");
+    }
+
+    // 登录ERP
+    public static void LoginERPTask(String url, String master, String username,
+                                    String password) {
+        mdProcessDialog.setContent("正在验证ERP...");
+        url = url + "mobile/login.action";
+        Map<String, String> params = new HashMap<String, String>();
+        params.put("username", username);
+        params.put("password", password);
+        params.put("master", master);
+        startNetThread(url, params, handler, Constants.SUCCESS_ERP, null, null,
+                "post");
+    }
+
+    private static List<LoginEntity> erpEntities;
+    public static Handler handler = new Handler() {
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case Constants.SUCCESS_LOGIN:
+                    LoginSucess(msg);
+                    break;
+                case Constants.SUCCESS_ERP:
+                    String result = msg.getData().getString("result");
+                    boolean success = JSON.parseObject(result).getBoolean("success");
+                    if (success) {
+                        ChangeStatusERP(msg.getData().getString("result"));
+                    } else {
+                        String reason = JSON.parseObject(result).getString("reason");
+                        ToastMessage(ct, reason);
+                    }
+                    break;
+                case Constants.SUCCESS_B2B:
+                    ChangeStatusB2B(msg.getData().getString("result"));
+                    break;
+                case Constants.SocketTimeoutException:
+                    if (mdProcessDialog != null && mdProcessDialog.isShowing()) {
+                        mdProcessDialog.dismiss();
+                    }
+                    break;
+                default:
+                    break;
+            }
+        }
+
+    };
+
+    public static void ChangeStatusERP(String result) {
+        System.out.println("login erp:" + result);
+        if (mdProcessDialog != null) {
+            mdProcessDialog.setContent("UAS验证成功!");
+        }
+        if (ct == null) ct = MyApplication.getInstance();
+        Map<String, Object> dataMap = FlexJsonUtil.fromJson(result);
+        try {
+            CommonUtil.setSharedPreferences(ct, "sessionId",
+                    dataMap.get("sessionId").toString());
+            CommonUtil.setSharedPreferences(ct, "erp_username",
+                    dataMap.get("erpaccount").toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        Log.i("liu", "baseurl=" + erp_baseurl);
+        Log.i("liu", "phone=" + erp_phone);
+        Log.i("liu", "password=" + erp_password);
+        //必须补位空,才能不覆盖原有的根路径
+        if (!StringUtils.isEmpty(erp_baseurl)) {
+            CommonUtil.setSharedPreferences(ct, "erp_baseurl", erp_baseurl);
+            CommonUtil.setSharedPreferences(ct, "erp_master", erp_master);
+            CommonUtil.setSharedPreferences(ct, "erp_commpany", erp_company);
+            CommonUtil.setSharedPreferences(ct, "erp_uu", erp_uu);
+            CommonUtil.setSharedPreferences(ct, "erp_masterId", erp_masterId);
+            CommonUtil.setSharedPreferences(ct, "erp_login", true);
+        }
+        if (erp_phone != null) {
+            CommonUtil.setSharedPreferences(ct, "user_phone", erp_phone);
+            CommonUtil.setSharedPreferences(ct, "user_password", erp_password);
+        }
+        handler.postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                if (mdProcessDialog != null) {
+                    mdProcessDialog.cancel();
+                }
+            }
+        }, 800);
+        if (ct instanceof Activity) {
+            if (((Activity) ct) instanceof MainActivity) {
+            } else {
+                ct.startActivity(new Intent(ct, DataDownloadActivity.class));
+            }
+        }
+        sendBrodcast("ERP");
+    }
+
+    public static void ChangeStatusB2B(String result) {
+        if (erp_phone != null) {
+            CommonUtil.setSharedPreferences(ct, "user_phone", erp_phone);
+            CommonUtil.setSharedPreferences(ct, "user_password", erp_password);
+        }
+        if (ct == null) ct = MyApplication.getInstance();
+        CommonUtil.setSharedPreferences(ct, "b2b_login", true);
+        CommonUtil.setSharedPreferences(ct, "b2b_uu", b2b_uu);
+        mdProcessDialog.setContent("验证B2B成功!");
+        handler.postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                mdProcessDialog.cancel();
+            }
+        }, 1000);
+        sendBrodcast("B2B");
+    }
+
+    public static void sendBrodcast(String falg) {
+        Intent intent = new Intent("com.app.home.update");
+        intent.putExtra("falg", falg);
+        if (ct != null) {
+            LocalBroadcastManager.getInstance(ct).sendBroadcast(intent);
+        }
+    }
+
+
+    private static void loginERPItemDialog(final String phone,
+                                           final String password) {
+        String[] items = new String[erpEntities.size()];
+        for (int j = 0; j < erpEntities.size(); j++) {
+            items[j] = erpEntities.get(j).getName();
+        }
+        new MaterialDialog.Builder(ct)
+                .title("选择登录的UAS账套")
+                .items(items)
+                .itemsCallbackSingleChoice(0,
+                        new MaterialDialog.ListCallbackSingleChoice() {
+                            @Override
+                            public boolean onSelection(MaterialDialog dialog,
+                                                       View view, int which, CharSequence text) {
+                                if (!StringUtils.isEmpty(text.toString())) {
+                                    // 拿到公司名字,取它对应的账套信息
+                                    for (int j2 = 0; j2 < erpEntities.size(); j2++) {
+                                        if (text.toString().equals(
+                                                erpEntities.get(j2).getName())) {
+                                            LoginEntity entity = erpEntities
+                                                    .get(j2);
+                                            erp_phone = phone;
+                                            erp_password = password;
+                                            erp_username = entity.getAccount();
+                                            erp_master = entity.getMaster();
+                                            erp_baseurl = entity.getWebsite();
+                                            erp_company = entity.getName();
+                                            erp_uu = String.valueOf(entity
+                                                    .getEnuu());
+                                            erp_masterId = String.valueOf(entity.getMasterId());
+                                            LoginERPTask(entity.getWebsite(),
+                                                    entity.getMaster(), phone, password);
+                                        }
+                                    }
+                                }
+                                return true; // allow selection
+                            }
+                        }).positiveText("确定").show();
+    }
+
+
+    /**
+     * @author Administrator
+     * @功能:管理平台的返回信息处理
+     */
+    public static void LoginSucess(Message msg) {
+        String json = msg.getData().getString("result");
+        CommonUtil.setSharedPreferences(ct, "loginJson", json);// 保存在本地
+        String phone = msg.getData().getString("phone");
+        String password = msg.getData().getString("password");
+        Log.i("Login", "login sucess:" + json);
+        List<LoginEntity> logMsg = JSON.parseArray(json, LoginEntity.class);
+        erpEntities = new ArrayList<LoginEntity>();
+        if (logMsg != null && !logMsg.isEmpty()) {
+            for (int i = 0; i < logMsg.size(); i++) {
+                LoginEntity map = logMsg.get(i);
+                if (map.getPlatform().equals("ERP")) {
+                    erpEntities.add(map);//ERP账户累加到数组
+                } else if (map.getPlatform().equals("B2B")) {
+                    b2b_uu = map.getAccount();
+                    LoginB2BTask(phone, password);//登录B2B
+                }
+
+            }
+            if (erpEntities.size() == 1) {// erp账户的数量是多个,一个默认进入,多个让用户选进入
+                LoginEntity entity = erpEntities.get(0);
+                erp_phone = phone;
+                erp_password = password;
+                erp_username = entity.getAccount();
+                erp_master = entity.getMaster();
+                erp_baseurl = entity.getWebsite();
+                erp_uu = String.valueOf(entity.getEnuu());
+                erp_company = entity.getName();
+                erp_masterId = String.valueOf(entity.getMasterId());
+                LoginERPTask(entity.getWebsite(), entity.getMaster(), phone, password);
+            } else if (erpEntities.size() > 1) {
+                loginERPItemDialog(phone, password);
+            }
+        } else {
+            mdProcessDialog.setContent("手机号或者密码失败!");
+            handler.postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    mdProcessDialog.cancel();
+                }
+            }, 2000);
+        }
+    }
+
+    ;
+
+    /**
+     * @author LiuJie
+     * @功能:比较两个日期大小
+     */
+    public static boolean isCheckDateTime(String DATE1, String DATE2,
+                                          String format) {
+        DateFormat df = new SimpleDateFormat(format);
+        try {
+            Date dt1 = df.parse(DATE1);
+            Date dt2 = df.parse(DATE2);
+            if (dt1.getTime() > dt2.getTime()) {
+                System.out.println("dt1 在dt2前");
+                return true;
+            } else if (dt1.getTime() < dt2.getTime()) {
+                System.out.println("dt1在dt2后");
+                return false;
+            } else {
+                return true;
+            }
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+        return true;
+    }
+
+    public static void getDataFormServer(Context ct, Handler handler,
+                                         String url, Map<String, String> param, int what) {
+        ViewUtil.ct = ct;
+        startNetThread(url, param, handler, what, null, null, "get");
+    }
+
+    /**
+     * 判断某个界面是否在前台
+     *
+     * @param context
+     * @param className 某个界面名称
+     */
+    public static boolean isForeground(Context context, String className) {
+        if (context == null || TextUtils.isEmpty(className)) {
+            return false;
+        }
+        ActivityManager am = (ActivityManager) context
+                .getSystemService(Context.ACTIVITY_SERVICE);
+        List<RunningTaskInfo> list = am.getRunningTasks(1);
+        if (list != null && list.size() > 0) {
+            ComponentName cpn = list.get(0).topActivity;
+            if (className.equals(cpn.getClassName())) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * @author Administrator
+     * @功能:封装网络请求 httpclient4.3
+     */
+    public static void httpSendRequest(
+            final Context ct,
+            final String url,
+            final Map<String, Object> params,
+            final Handler handler,
+            final LinkedHashMap<String, Object> headers,
+            final int what,
+            final Message message,
+            final Bundle bundle,
+            final String request) {
+        new Thread(new Runnable() {
+
+            @Override
+            public void run() {
+                boolean isNetHas = CommonUtil.isNetWorkConnected(ct);
+                if (isNetHas) {
+                    HttpUtil.Response result = httpSendTask(url, params, headers, request);
+                    if (result != null) {
+                        Log.i("result", "http 请求-----------------------------------------");
+                        Log.i("result", "result:" + result);
+                        Log.i("result", "url:" + url);
+                        Log.i("result", "parm:" + params.toString());
+                        Log.i("result", "statusCode:" + result.getStatusCode());
+                        Log.i("result", "text:" + result.getResponseText());
+                        Log.i("result", "http 响应-----------------------------------------");
+                        if (result.getStatusCode() == 200) {
+                            if (bundle == null || message == null) {
+                                Bundle bundle = new Bundle();
+                                Message message = new Message();
+                                bundle.putString("result", result.getResponseText());
+                                message.setData(bundle);
+                                message.what = what;
+                                handler.sendMessage(message);
+                            } else {
+                                bundle.putString("result", result.getResponseText());
+                                message.setData(bundle);
+                                message.what = what;
+                                handler.sendMessage(message);
+                            }
+                        } else {
+                            String exception = "未知错误";
+                            if (result.getStatusCode() == 500) {
+                                if (new JsonValidator().validate(result.responseText)) {
+                                    exception = JSON.parseObject(result.responseText).getString("exceptionInfo");
+                                } else {
+                                    exception = "500系统错误";
+                                }
+                            }
+                            if (result.getStatusCode() == 404) {
+                                exception = "404系统错误";
+                            }
+                            Log.i("Http", "非200响应:" + result.getResponseText());
+                            Bundle bundle = new Bundle();
+                            Message message = new Message();
+                            bundle.putString("result", exception);
+                            message.setData(bundle);
+                            message.what = Constants.APP_SOCKETIMEOUTEXCEPTION;
+                            handler.sendMessage(message);
+                        }
+                    } else {
+                        Bundle bundle = new Bundle();
+                        Message message = new Message();
+                        bundle.putString("result", "服务器异常!");
+                        message.setData(bundle);
+                        message.what = Constants.APP_SOCKETIMEOUTEXCEPTION;
+                        handler.sendMessage(message);
+                    }
+                } else {
+                    Bundle bundle = new Bundle();
+                    Message message = new Message();
+                    bundle.putString("result", "网络未连接!");
+                    message.setData(bundle);
+                    message.what = Constants.APP_SOCKETIMEOUTEXCEPTION;
+                    handler.sendMessage(message);
+                }
+            }
+        }).start();
+    }
+
+    public static HttpUtil.Response httpSendTask(
+            String url,
+            Map<String, Object> params,
+            LinkedHashMap<String, Object> headers,
+            String method) {
+        HttpUtil.Response response = null;
+        try {
+            if (method.equals("get")) {
+                response = HttpUtil.sendGetRequest(url, params, headers, false);
+            }
+            if (method.equals("post")) {
+                response = HttpUtil.sendGetRequest(url, params, headers, false);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return response;
+    }
+
+    public static String getExceptionMsg(Context ct, Throwable ex) {
+        StringBuffer sb = new StringBuffer();
+        sb.append("----------------------异常信息输出-------------------------------------\n");
+        Writer writer = new StringWriter();
+        PrintWriter printWriter = new PrintWriter(writer);
+        ex.printStackTrace(printWriter);
+        // 原因打印
+        Throwable cause = ex.getCause();
+        while (cause != null) {
+            cause.printStackTrace(printWriter);
+            cause = cause.getCause();
+        }
+        printWriter.close();
+        String result = writer.toString();
+        String phone = CommonUtil.getSharedPreferences(ct, "user_phone");
+        String password = CommonUtil.getSharedPreferences(ct, "user_password");
+        String master_ch = CommonUtil.getSharedPreferences(ct, "Master_ch");
+        String company = CommonUtil.getSharedPreferences(ct, "erp_commpany");
+        sb.append(result);
+        sb.append("\n----------------------用户信息输出-------------------------------------");
+        sb.append("\n phone:" + phone);
+        sb.append("\n password:" + password);
+        sb.append("\n master_ch:" + master_ch);
+        sb.append("\n company:" + company);
+        sb.append("\n----------------------设备信息输出-------------------------------------");
+        //获取设备大小
+        String deviceInfo = CommonUtil.getDeviceInfo(ct);
+        System.out.println("deviceInfo=" + deviceInfo);
+        sb.append("\n" + deviceInfo);
+        sb.append("\n手机型号:" + CommonUtil.getDeviceModel());
+        sb.append("\n手机生产厂商:" + CommonUtil.getDeviceManufacturer());
+        //获取应用程序内存使用情况
+        sb.append("\n----------------------内存信息输出-------------------------------------\n");
+        sb.append(CommonUtil.getMemory());
+        //获取应用程序的当前版本号
+        sb.append("\n----------------------版本信息输出-------------------------------------\n");
+        sb.append("\n应用版本号:" + CommonUtil.ApkVersionCode(ct));
+        return sb.toString();
+    }
+
+    /**
+     * @注释:ERP自动登录
+     */
+    public static void AutoLoginErp(Context ct, Handler handler) {
+        Log.i("LoginErp", "自动登录...");
+        if (!StringUtils.isEmpty(Constants.getAppBaseUrl(ct))) {
+            String url = Constants.getAppBaseUrl(ct);
+            String master = CommonUtil.getSharedPreferences(ct, "erp_master");
+            String phone = CommonUtil.getSharedPreferences(ct, "user_phone");
+            String password = CommonUtil.getSharedPreferences(ct, "user_password");
+            Log.i("LoginErp", "自动登录..." + url);
+            Log.i("LoginErp", "master..." + master);
+            Log.i("LoginErp", "phone..." + phone);
+            Log.i("LoginErp", "password..." + password);
+            LoginERPTask(ct, handler, url, master, phone, password);
+        }
+
+    }
+
+    // 登录ERP
+    public static void LoginERPTask(Context ct, Handler mhandler, String url, String master, String username, String password) {
+        url = url + "mobile/login.action";
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("username", username);
+        params.put("password", password);
+        params.put("master", master);
+        httpSendRequest(ct, url, params, handler, null, Constants.SUCCESS_ERP, null, null, "post");
+    }
 }

+ 6 - 2
WeiChat/src/main/java/com/sk/weichat/ui/me/MeFragment.java

@@ -8,6 +8,7 @@ import android.content.IntentFilter;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.support.v4.content.LocalBroadcastManager;
 import android.util.Log;
 import android.view.View;
 import android.widget.ImageView;
@@ -167,7 +168,7 @@ public class MeFragment extends EasyFragment implements View.OnClickListener {
 
         IntentFilter loginFilter = new IntentFilter();
         loginFilter.addAction("com.app.home.update");
-        ct.registerReceiver(updateLoginState, loginFilter);
+        LocalBroadcastManager.getInstance(ct).registerReceiver(updateLoginState, loginFilter);
 
         String loginUserId = MyApplication.getInstance().mLoginUser.getUserId();
         AvatarHelper.getInstance().displayAvatar(loginUserId, mAvatarImg, true);
@@ -326,7 +327,10 @@ public class MeFragment extends EasyFragment implements View.OnClickListener {
     }
 
 
-    // 全局登录更新登录状态
+    /**
+     * @desc:广播
+     * @author:Administrator on 2016/3/31 10:35
+     */
     private BroadcastReceiver updateLoginState = new BroadcastReceiver() {
         public void onReceive(Context context, Intent intent) {
             if (intent.getAction().equals("com.app.home.update")) {

+ 1 - 1
WeiChat/src/main/java/com/sk/weichat/ui/message/ChatActivity.java

@@ -102,7 +102,7 @@ public class ChatActivity extends ActionBackActivity
         public void handleMessage(Message msg) {
             switch (msg.what) {
                 case 5:
-
+                       Log.i("push",msg.getData().getString("result"));
                     break;
             }
         }

+ 4 - 2
WeiChat/src/main/java/com/sk/weichat/xmpp/CoreService.java

@@ -123,9 +123,11 @@ public class CoreService extends Service {
                 .setDefaults(Notification.DEFAULT_VIBRATE).setDefaults(Notification.DEFAULT_SOUND)
                 //向通知添加声音、闪灯和振动效果的最简单、最一致的方式是使用当前的用户默认设置,使用defaults属性,可以组合
                 //Notification.DEFAULT_ALL  Notification.DEFAULT_SOUND 添加声音 // requires VIBRATE permission
-                .setSmallIcon(R.drawable.notification_contacts);//设置通知小ICON
+                .setSmallIcon(R.drawable.uuu);//设置通知小ICON
 
-        mNotificationManager.notify(notifyId, mBuilder.build());
+        if (!"不明确类型".equals(content)) {
+            mNotificationManager.notify(notifyId, mBuilder.build());
+        }
     }
 
     private CoreServiceBinder mBinder;