|
@@ -157,7 +157,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// 在适当的地方调用以下代码开始执行
|
|
|
+ // 在适当的地方调用以下代码开始执行
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void event(PaymentMessage messageEvent) {
|
|
|
switch (messageEvent.getName()) {
|
|
@@ -204,7 +204,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void event(ApiMessageEvent messageEvent) {
|
|
|
- Log.d(TAG, "Service event: ApiMessageEvent"+messageEvent.getName());
|
|
|
+ Log.d(TAG, "Service event: ApiMessageEvent" + messageEvent.getName());
|
|
|
switch (messageEvent.getName()) {
|
|
|
case "statusType1":
|
|
|
//同步数据
|
|
@@ -256,23 +256,25 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
// updateEqeStatus((Integer) messageEvent.getData());
|
|
|
break;
|
|
|
case "eliminate":
|
|
|
- Constant.reasonKey="";
|
|
|
- HashMap<String, String> params = new HashMap<>();
|
|
|
- params.put("clientId", Heartbeat.deviceId);
|
|
|
- addSubscriptionNew(NoPayOrderStringApi.api.eliminateClean(params),String.class,
|
|
|
- new HttpResultObserver<String>(view, getApplicationContext()) {
|
|
|
- @Override
|
|
|
- public void onNext(String s) {
|
|
|
- Log.d(TAG, "报警eliminateApionNext: " + s);
|
|
|
- LogUtils.logWrite("消除报警next");
|
|
|
- }
|
|
|
+ if (!Constant.reasonKey.equals("")) {
|
|
|
+ Constant.reasonKey = "";
|
|
|
+ HashMap<String, String> params = new HashMap<>();
|
|
|
+ params.put("clientId", Heartbeat.deviceId);
|
|
|
+ addSubscriptionNew(NoPayOrderStringApi.api.eliminateClean(params), String.class,
|
|
|
+ new HttpResultObserver<String>(view, getApplicationContext()) {
|
|
|
+ @Override
|
|
|
+ public void onNext(String s) {
|
|
|
+ Log.d(TAG, "报警eliminateApionNext: " + s);
|
|
|
+ LogUtils.logWrite("消除报警next");
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void onError(Throwable t) {
|
|
|
- super.onError(t);
|
|
|
- Log.d(TAG, "报警eliminateApi onError: "+t.getMessage());
|
|
|
- }
|
|
|
- });
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable t) {
|
|
|
+ super.onError(t);
|
|
|
+ Log.d(TAG, "报警eliminateApi onError: " + t.getMessage());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
break;
|
|
|
case "dosugar":
|
|
|
// makingmarshmallows((String) messageEvent.getData());
|
|
@@ -447,7 +449,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
public void run() {
|
|
|
WeaverUtil.creditCardSessionComplete();
|
|
|
}
|
|
|
- }, 5000);
|
|
|
+ }, 5000);
|
|
|
break;
|
|
|
case "humidification":
|
|
|
// startHumidification();
|
|
@@ -659,7 +661,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
new HttpResultNotActivityObserver<String>(view, getApplicationContext()) {
|
|
|
@Override
|
|
|
public void onNext(String data) {
|
|
|
- Log.d(TAG, "onNext:is_sleep1 "+data);
|
|
|
+ Log.d(TAG, "onNext:is_sleep1 " + data);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -685,7 +687,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
new HttpResultNotActivityObserver<String>(view, getApplicationContext()) {
|
|
|
@Override
|
|
|
public void onNext(String data) {
|
|
|
- Log.d(TAG, "onNext:is_sleep "+data);
|
|
|
+ Log.d(TAG, "onNext:is_sleep " + data);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -719,14 +721,15 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void event(ErrorApiMessageEvent messageEvent) {
|
|
|
- switch (messageEvent.getName()){
|
|
|
+ switch (messageEvent.getName()) {
|
|
|
case Name.WARNING_ALARM:
|
|
|
- Log.d(TAG, "event: WARNING_ALARM"+messageEvent.getData());
|
|
|
- setError1(messageEvent.getId(), (String) messageEvent.getData(),messageEvent.getLevel());
|
|
|
+ Log.d(TAG, "event: WARNING_ALARM" + messageEvent.getData());
|
|
|
+ setError1(messageEvent.getId(), (String) messageEvent.getData(), messageEvent.getLevel());
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
//获取个推id
|
|
|
private Timer timerGeTui;
|
|
|
private TimerTask taskGeTui;
|
|
@@ -746,7 +749,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
stopGeTui();
|
|
|
}
|
|
|
} else {
|
|
|
- LogUtil.d(TAG, "run: cid1!=null"+Heartbeat.clientId);
|
|
|
+ LogUtil.d(TAG, "run: cid1!=null" + Heartbeat.clientId);
|
|
|
// stopGeTui();
|
|
|
}
|
|
|
|
|
@@ -851,6 +854,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
};
|
|
|
timerHeartbeat.schedule(taskHeartbeat, 30000, 1000 * 60 * 5);
|
|
|
}
|
|
|
+
|
|
|
private IView view;
|
|
|
|
|
|
/**
|
|
@@ -912,7 +916,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
@Override
|
|
|
public void onNext(String s) {
|
|
|
Logger.i(TAG + "收到结果" + s);
|
|
|
- Log.d(TAG, "onNext: 测试 :"+ s);
|
|
|
+ Log.d(TAG, "onNext: 测试 :" + s);
|
|
|
if (s.equals("心跳成功")) {
|
|
|
// ToastUtil.showToast(UiUtil.getStringRes(R.string.heart_success));
|
|
|
LogUtil.d(TAG, "onNext: 心跳成功");
|
|
@@ -977,7 +981,9 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
|
|
|
return super.onStartCommand(intent, flags, startId);
|
|
|
}
|
|
|
+
|
|
|
private CompositeDisposable mDisposables;
|
|
|
+
|
|
|
/**
|
|
|
* 检测心跳数据以及开始心跳
|
|
|
*/
|
|
@@ -995,6 +1001,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
Logger.i(TAG + "系统管理id为空");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
protected void addSubscriptionNew(Observable observable, Class clazz, DisposableObserver observer) {
|
|
|
if (mDisposables == null) {
|
|
|
mDisposables = new CompositeDisposable();
|
|
@@ -1009,7 +1016,8 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
.subscribe(observer);
|
|
|
mDisposables.add(observer);
|
|
|
}
|
|
|
- protected void addSubscription(Observable observable, DisposableObserver observer) {
|
|
|
+
|
|
|
+ protected void addSubscription(Observable observable, DisposableObserver observer) {
|
|
|
if (mDisposables == null) {
|
|
|
mDisposables = new CompositeDisposable();
|
|
|
}
|
|
@@ -1020,6 +1028,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
.subscribe(observer);
|
|
|
mDisposables.add(observer);
|
|
|
}
|
|
|
+
|
|
|
private void stopHeartbeat() {
|
|
|
if (timerHeartbeat != null) {
|
|
|
taskHeartbeat.cancel();
|
|
@@ -1029,6 +1038,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
}
|
|
|
|
|
|
private boolean ampAddress = false;//记录地图是否上传成功 false表示没有 true表示成功了
|
|
|
+
|
|
|
/**
|
|
|
* 上传地址,经纬度
|
|
|
*/
|
|
@@ -1061,6 +1071,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
@SuppressLint("CheckResult")
|
|
|
private void OrderStatusInquiry(String sn, int i) {
|
|
|
LogUtils.logWrite("调用OrderStatusInquiry");
|
|
@@ -1171,7 +1182,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
Log.d(TAG, "RemoteSupportServiceonDestroy: ");
|
|
|
}
|
|
|
|
|
|
- public void setError1(int key, String reason,String level) {
|
|
|
+ public void setError1(int key, String reason, String level) {
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
if (currentTime - Constant.lastProcessedTime < 3000) {
|
|
|
return;
|
|
@@ -1196,18 +1207,18 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
|
|
|
//上传到服务器
|
|
|
if (!Constant.reasonKey.equals(reason)) {
|
|
|
- upError(body, 0,reason);
|
|
|
+ upError(body, 0, reason);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void upError(RequestBody body, int alarmErrorNumber,String reason) {
|
|
|
+ private void upError(RequestBody body, int alarmErrorNumber, String reason) {
|
|
|
addSubscriptionNew(NoPayOrderStringApi.api.addAlarmRecord(body), String.class,
|
|
|
new HttpResultNotActivityObserver<String>(view, BaseApplication.getContext()) {
|
|
|
@Override
|
|
|
public void onNext(String o) {
|
|
|
- Log.d(TAG, "onNext报警测试1: "+o);
|
|
|
- Constant.reasonKey=reason;
|
|
|
+ Log.d(TAG, "onNext报警测试1: " + o);
|
|
|
+ Constant.reasonKey = reason;
|
|
|
if (o != null) {
|
|
|
Log.d("AddAlarmRecordApi3", "onNext: " + o);
|
|
|
}
|
|
@@ -1216,7 +1227,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
@Override
|
|
|
public void onError(Throwable t) {
|
|
|
super.onError(t);
|
|
|
- Log.d(TAG, "onNext报警测试2: "+t.getMessage());
|
|
|
+ Log.d(TAG, "onNext报警测试2: " + t.getMessage());
|
|
|
if (t instanceof ApiException) {
|
|
|
ApiException a = (ApiException) t;
|
|
|
//后台返回
|
|
@@ -1229,7 +1240,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
if (alarmErrorNumber >= 3) {//重试三次。
|
|
|
return;
|
|
|
}
|
|
|
- upError(body, alarmErrorNumber + 1,Constant.reasonKey);
|
|
|
+ upError(body, alarmErrorNumber + 1, Constant.reasonKey);
|
|
|
Log.d(TAG, "run: asdfasdfasdf");
|
|
|
LogUtils.logWrite("报警了,但是上传失败,需要重新上传");
|
|
|
}
|
|
@@ -1275,9 +1286,11 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
private void SetAnAlarm() {
|
|
|
- setAlarmClock();
|
|
|
+ setAlarmClock();
|
|
|
}
|
|
|
+
|
|
|
public void setAlarmClock() {
|
|
|
/**
|
|
|
* 1. 用户点击添加的时候,那么我就开始设置闹钟。
|
|
@@ -1299,6 +1312,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public int setAlarmClock(int number, AlarmClockBean alarmClockBean, String type, int alarmNumber) throws ParseException {
|
|
|
|
|
|
for (int i = number; i < alarmNumber; i++) {//清除所有的闹钟
|
|
@@ -1386,6 +1400,7 @@ public class RemoteSupportService extends Service implements SendCallback {
|
|
|
number = number + week.size();//累积。
|
|
|
return number;
|
|
|
}
|
|
|
+
|
|
|
public void stopTimerAndTimerTask(Timer timer, TimerTask task) {
|
|
|
if (timer != null) {
|
|
|
task.cancel();
|