Browse Source

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

RaoMeng 7 years ago
parent
commit
60c5dbeafc

+ 160 - 126
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/PushNetMessageReceiver.java

@@ -1,19 +1,25 @@
 package com.xzjmyk.pm.activity.ui;
 
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
+import android.text.TextUtils;
 import android.util.Log;
 
 import com.alibaba.fastjson.JSON;
 import com.baidu.android.pushservice.PushMessageReceiver;
 import com.common.data.JSONUtil;
 import com.common.data.StringUtil;
-import com.loopj.android.http.AsyncHttpClient;
-import com.loopj.android.http.AsyncHttpResponseHandler;
-import com.loopj.android.http.RequestParams;
 import com.core.app.MyApplication;
 import com.core.broadcast.MsgBroadcast;
 import com.core.net.http.ViewUtil;
+import com.loopj.android.http.AsyncHttpClient;
+import com.loopj.android.http.AsyncHttpResponseHandler;
+import com.loopj.android.http.RequestParams;
+import com.me.network.app.http.HttpClient;
+import com.me.network.app.http.rx.Result2Listener;
+import com.me.network.app.http.rx.ResultSubscriber;
+import com.uas.appworks.activity.ScheduleActivity;
 import com.xzjmyk.pm.activity.util.oa.CommonUtil;
 
 import org.apache.http.Header;
@@ -27,130 +33,158 @@ import java.util.List;
  */
 public class PushNetMessageReceiver extends PushMessageReceiver {
 
-	@Override
-	public void onBind(Context context, int errorCode, String appid, String userId, String channelId,
-			String requestId) {
-		String responseString = "onBind errorCode=" + errorCode + " appid=" + appid + " userId=" + userId
-				+ " channelId=" + channelId + " requestId=" + requestId;
-		Log.i("wang", responseString);
-		RequestParams params = new RequestParams();
-		params.put("channelId", channelId);
-		params.put("access_token", MyApplication.getInstance().mAccessToken);
-		params.put("deviceId", 1);
-		AsyncHttpClient client = new AsyncHttpClient();
-		SharedPreferences configSharePre = context.getSharedPreferences("app_config", Context.MODE_PRIVATE);
-		SharedPreferences.Editor editor = configSharePre.edit();
-		String url= configSharePre.getString("apiUrl", "http://192.168.1.240/api/vg1/");
-		Log.i("wang", url+"user/channelId/set");
-		client.post(url+"user/channelId/set", params, new AsyncHttpResponseHandler() {
-
-		@Override
-		public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
-			Log.d("wang","上传失败"+arg3.toString());
-
-		}
-
-		@Override
-		public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
-			// TODO Auto-generated method stub
-			Log.d("wang", "上传channelId成功了");
-		}
-
-	});
-}
-
-	@Override
-	public void onDelTags(Context arg0, int arg1, List<String> arg2, List<String> arg3, String arg4) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void onListTags(Context arg0, int arg1, List<String> arg2, String arg3) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void onMessage(Context arg0, String arg1, String arg2) {
-		// TODO Auto-generated method stub
-
-	}
-
-	/**
-	 * @desc:待审批流程,我的任务,通知公告消息到来置顶
-	 * @author:Administrator on 2016/4/20 16:46
-	 */
-	@Override
-	public void onNotificationArrived(Context ct, String title, String content, String params) {
-		if(JSONUtil.validate(params)){
-			  String platform=JSON.parseObject(params).getString("platform");
-			String msgContent = JSON.parseObject(params).getString("content");
-			String master = JSON.parseObject(params).getString("master");
-			String pageTitle = JSON.parseObject(params).getString("pageTitle");
-			Log.i("Arison", "" + pageTitle);
-			if (!StringUtil.isEmpty(pageTitle)) {
-				if (pageTitle.contains("商务消息")) {
-					CommonUtil.pushProcessB2bMsg(ct, msgContent, master);
-				}
-			}
-
-			if (StringUtil.isEmpty(platform)) {
-				CommonUtil.pushProcessMsg(ct, MyApplication.getInstance().mLoginUser.getUserId());
-			} else {
-				MsgBroadcast.broadcastMsgUiUpdate(ct);
-			}
-
-		}
-	}
-
-
-	/**
-	 * @desc:点击操作  ERP系统或者B2B系统
-	 * @author:Administrator on 2016/4/20 16:42
-	 */
-	@Override
-	public void onNotificationClicked(Context ct, String title, String content, String params) {
-		Log.i("wang", "title=" + title);
-		Log.i("wang", "content=" + content);
-		Log.i("wang", "params=" + params);
-		if(JSONUtil.validate(params)){
-			String titlePage=JSON.parseObject(params).getString("title");
-			String url=	JSON.parseObject(params).getString("url");
-			String master=JSON.parseObject(params).getString("master");
-			String masterId=JSON.parseObject(params).getString("masterId");
-			String uu=JSON.parseObject(params).getString("uu");
-			String platform=JSON.parseObject(params).getString("platform");
-
-			if (!StringUtil.isEmpty(platform)){
-				if ("B2B".equals(platform)){
-					Log.i("wang", "params=" + platform);
-					Log.i("wang", "url=" + url);
-					Log.i("wang", "titlePage=" + titlePage);
-					CommonUtil.loadWebViewToB2B(ct,url,titlePage);
-				}
-				if("ERP".equals(platform)){
-					CommonUtil.loadWebView(ct,url,titlePage,master,masterId,uu);
-				}
-			}else{
+    @Override
+    public void onBind(Context context, int errorCode, String appid, String userId, String channelId,
+                       String requestId) {
+        String responseString = "onBind errorCode=" + errorCode + " appid=" + appid + " userId=" + userId
+                + " channelId=" + channelId + " requestId=" + requestId;
+        Log.i("wang", responseString);
+        update(channelId);
+        RequestParams params = new RequestParams();
+        params.put("channelId", channelId);
+        params.put("access_token", MyApplication.getInstance().mAccessToken);
+        params.put("deviceId", 1);
+        AsyncHttpClient client = new AsyncHttpClient();
+        SharedPreferences configSharePre = context.getSharedPreferences("app_config", Context.MODE_PRIVATE);
+        SharedPreferences.Editor editor = configSharePre.edit();
+        String url = configSharePre.getString("apiUrl", "http://192.168.1.240/api/vg1/");
+        Log.i("wang", url + "user/channelId/set");
+        client.post(url + "user/channelId/set", params, new AsyncHttpResponseHandler() {
+
+            @Override
+            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
+                Log.d("wang", "上传失败" + arg3.toString());
+
+            }
+
+            @Override
+            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
+                // TODO Auto-generated method stub
+                Log.d("wang", "上传channelId成功了");
+            }
+
+        });
+    }
+
+    private void update(String channelId) {
+        String imid = MyApplication.getInstance().getLoginUserId();
+        Log.d("wang", "channelId=" + channelId + "||imid=" + imid);
+        HttpClient mHttpClient = new HttpClient.Builder()
+                .url("channelset/saveChannelset")
+                .add("imid", imid)
+                .add("deviceType", 3)
+                .add("channelId", channelId)
+                .build();
+        HttpClient httpClient = new HttpClient.Builder("http://192.168.253.230:8080/schedule/").isDebug(false)
+                .connectTimeout(5000)
+                .readTimeout(5000).build();
+        httpClient.Api().post(mHttpClient, new ResultSubscriber<>(new Result2Listener<Object>() {
+            @Override
+            public void onResponse(Object o) {
+                Log.d("wang", "onResponse上传channelId成功了" + o.toString());
+            }
+
+            @Override
+            public void onFailure(Object t) {
+                Log.d("wang", "onResponse 上传channelId失败了" + t.toString());
+            }
+        }));
+    }
+
+    @Override
+    public void onDelTags(Context arg0, int arg1, List<String> arg2, List<String> arg3, String arg4) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void onListTags(Context arg0, int arg1, List<String> arg2, String arg3) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void onMessage(Context arg0, String arg1, String arg2) {
+        // TODO Auto-generated method stub
+
+    }
+
+    /**
+     * @desc:待审批流程,我的任务,通知公告消息到来置顶
+     * @author:Administrator on 2016/4/20 16:46
+     */
+    @Override
+    public void onNotificationArrived(Context ct, String title, String content, String params) {
+        if (JSONUtil.validate(params)) {
+            String platform = JSON.parseObject(params).getString("platform");
+            String msgContent = JSON.parseObject(params).getString("content");
+            String master = JSON.parseObject(params).getString("master");
+            String pageTitle = JSON.parseObject(params).getString("pageTitle");
+            Log.i("Arison", "" + pageTitle);
+            if (!StringUtil.isEmpty(pageTitle)) {
+                if (pageTitle.contains("商务消息")) {
+                    CommonUtil.pushProcessB2bMsg(ct, msgContent, master);
+                }
+            }
+
+            if (StringUtil.isEmpty(platform)) {
+                CommonUtil.pushProcessMsg(ct, MyApplication.getInstance().mLoginUser.getUserId());
+            } else {
+                MsgBroadcast.broadcastMsgUiUpdate(ct);
+            }
+
+        }
+    }
+
+
+    /**
+     * @desc:点击操作 ERP系统或者B2B系统
+     * @author:Administrator on 2016/4/20 16:42
+     */
+    @Override
+    public void onNotificationClicked(Context ct, String title, String content, String params) {
+        Log.i("wang", "title=" + title);
+        Log.i("wang", "content=" + content);
+        Log.i("wang", "params=" + params);
+        if (!TextUtils.isEmpty(title) && title.equals("UU日程")) {
+            ct.startActivity(new Intent(ct, ScheduleActivity.class));
+        } else if (JSONUtil.validate(params)) {
+            String titlePage = JSON.parseObject(params).getString("title");
+            String url = JSON.parseObject(params).getString("url");
+            String master = JSON.parseObject(params).getString("master");
+            String masterId = JSON.parseObject(params).getString("masterId");
+            String uu = JSON.parseObject(params).getString("uu");
+            String platform = JSON.parseObject(params).getString("platform");
+
+            if (!StringUtil.isEmpty(platform)) {
+                if ("B2B".equals(platform)) {
+                    Log.i("wang", "params=" + platform);
+                    Log.i("wang", "url=" + url);
+                    Log.i("wang", "titlePage=" + titlePage);
+                    CommonUtil.loadWebViewToB2B(ct, url, titlePage);
+                }
+                if ("ERP".equals(platform)) {
+                    CommonUtil.loadWebView(ct, url, titlePage, master, masterId, uu);
+                }
+            } else {
 //				ViewUtil.ToastMessage(ct, "缺少参数:platform");
-			}
-		}else{
-			ViewUtil.ToastMessage(ct, "服务器未指定需要的参数");
-		}
-	}
-
-	@Override
-	public void onSetTags(Context arg0, int arg1, List<String> arg2, List<String> arg3, String arg4) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void onUnbind(Context arg0, int arg1, String arg2) {
-		
-		Log.i("wang", arg1+"++++++"+arg2);
-	}
+            }
+        } else {
+            ViewUtil.ToastMessage(ct, "服务器未指定需要的参数");
+        }
+    }
+
+    @Override
+    public void onSetTags(Context arg0, int arg1, List<String> arg2, List<String> arg3, String arg4) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void onUnbind(Context arg0, int arg1, String arg2) {
+
+        Log.i("wang", arg1 + "++++++" + arg2);
+    }
 
 
 }

+ 14 - 2
app_core/common/src/main/java/com/core/base/BaseActivity.java

@@ -1,7 +1,9 @@
 package com.core.base;
 
 import android.app.Activity;
+import android.app.ActivityManager;
 import android.content.BroadcastReceiver;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
@@ -69,13 +71,23 @@ public abstract class BaseActivity extends ActionBackActivity {
                     && intent.getAction() != null
                     && intent.getAction().equals(PROMPT_ACTION)) {
                 String content = intent.getStringExtra(CONTENT);
-                if (!StringUtil.isEmpty(content)) {
+                if (!StringUtil.isEmpty(content) && isTopActivity()) {
                     new SchedulePromptPop(BaseActivity.this, content).showPopupWindow();
                 }
             }
         }
     };
 
+    private boolean isTopActivity() {
+        boolean isTop = false;
+        ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
+        ComponentName cn = am.getRunningTasks(1).get(0).topActivity;
+        if (cn.getClassName().contains(TAG)) {
+            isTop = true;
+        }
+        return isTop;
+    }
+
     public void preOnCreacte() {
     }
 
@@ -272,7 +284,7 @@ public abstract class BaseActivity extends ActionBackActivity {
                 break;
 
         }
-        //0.85 小, 1 标准大小, 1.15 大,1.3 超大 ,1.45 特大 
+        //0.85 小, 1 标准大小, 1.15 大,1.3 超大 ,1.45 特大
         DisplayMetrics metrics = new DisplayMetrics();
         getWindowManager().getDefaultDisplay().getMetrics(metrics);
         metrics.scaledDensity = configuration.fontScale * metrics.density;

+ 11 - 6
app_modular/appworks/src/main/java/com/uas/appworks/activity/SchedulerCreateActivity.java

@@ -197,8 +197,7 @@ public class SchedulerCreateActivity extends BaseNetActivity {
                             @Override
                             public void result(boolean clickSure) {
                                 if (clickSure) {
-                                    startActivity(new Intent("com.modular.booking.BookingListActivity")
-                                            .putExtra("whichPage", "timeHelper"));
+                                    startActivity(new Intent("com.modular.booking.BookingListActivity"));
                                 }
                             }
                         });
@@ -272,11 +271,13 @@ public class SchedulerCreateActivity extends BaseNetActivity {
     private SwitchView.OnCheckedChangeListener mOnCheckedChangeListener = new SwitchView.OnCheckedChangeListener() {
         @Override
         public void onCheckedChanged(View view, boolean isChecked) {
-            mSchedule.setAllDay(isChecked ? 1 : 0);
-            String format = mSchedule.getAllDay() == 1 ? DateFormatUtil.YMD : DateFormatUtil.YMD_HM;
-            startTimeTv.setText(DateFormatUtil.long2Str(mSchedule.getStartTime(), format));
-            endTimeTv.setText(DateFormatUtil.long2Str(mSchedule.getEndTime(), format));
             if (isChecked) {
+                mSchedule.setStartTime(DateFormatUtil.str2Long(
+                        DateFormatUtil.long2Str(mSchedule.getStartTime(), DateFormatUtil.YMD) + " 00:00:01"
+                        , DateFormatUtil.YMD_HMS));
+                mSchedule.setEndTime(DateFormatUtil.str2Long(
+                        DateFormatUtil.long2Str(mSchedule.getEndTime(), DateFormatUtil.YMD) + " 23:59:59"
+                        , DateFormatUtil.YMD_HMS));
                 mSchedule.setWarnTime(8);
                 mSchedule.setWarnRealTime(mSchedule.getStartTime());
                 warnTimeTv.setText(warns2[1]);
@@ -285,6 +286,10 @@ public class SchedulerCreateActivity extends BaseNetActivity {
                 mSchedule.setWarnRealTime(mSchedule.getStartTime());
                 warnTimeTv.setText(warns[1]);
             }
+            mSchedule.setAllDay(isChecked ? 1 : 0);
+            String format = mSchedule.getAllDay() == 1 ? DateFormatUtil.YMD : DateFormatUtil.YMD_HM;
+            startTimeTv.setText(DateFormatUtil.long2Str(mSchedule.getStartTime(), format));
+            endTimeTv.setText(DateFormatUtil.long2Str(mSchedule.getEndTime(), format));
         }
     };
     private View.OnClickListener mOnClickListener = new View.OnClickListener() {