[2.13.0-arch-opt] reduce unuse logic and remove notice to biz

This commit is contained in:
zhongchao
2022-12-29 20:08:38 +08:00
parent e82dc525a3
commit 61b54ee6ba
59 changed files with 37 additions and 3484 deletions

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View File

@@ -0,0 +1,48 @@
package com.mogo.eagle.function.biz.push;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.eagle.core.data.constants.MogoServicePaths;
import com.mogo.eagle.core.function.api.notice.IMoGoNoticeProvider;
import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
import com.mogo.eagle.function.biz.push.network.NoticeNetWorkManager;
import org.jetbrains.annotations.NotNull;
/**
* @author Jing
* @description 云公告公告
* @since: 10/27/21
*/
@Route(path = MogoServicePaths.PATH_AI_NOTICE)
public class NoticeProvider implements IMoGoNoticeProvider {
@NotNull
@Override
public String getFunctionName() {
return null;
}
@Override
public void onDestroy() {
NoticeSocketManager.getInstance().unRegisterSocketMessageListener();
}
@Override
public void init(Context context) {
NoticeSocketManager.getInstance().registerSocketMessageListener(context);
}
@Override
public void feedBackNoticeTraffic(String infoId, String sn, int accept) {
NoticeNetWorkManager.getInstance().sendAccidentAcceptStatus(infoId, sn, accept);
}
@Override
public void requestAccidentInfo(String infoId, String sn, NoticeNetCallBack callBack) {
NoticeNetWorkManager.getInstance().requestAccidentInfo(infoId, sn, callBack);
}
}

View File

@@ -0,0 +1,93 @@
package com.mogo.eagle.function.biz.push;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_NOTICE;
import android.content.Context;
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager;
import com.mogo.eagle.core.data.msgbox.MsgBoxBean;
import com.mogo.eagle.core.data.msgbox.MsgBoxType;
import com.mogo.eagle.core.data.msgbox.NoticeFrCloudMsg;
import com.mogo.eagle.core.data.notice.NoticeNormalData;
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData;
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.network.utils.GsonUtil;
import com.mogo.aicloud.services.socket.IMogoOnMessageListener;
/**
* @author Jing
* @description 云公告注册、反注册
* @since: 10/27/21
*/
class NoticeSocketManager {
private String TAG = "AINotice";
private static NoticeSocketManager mNoticeSocketManager;
private Context mContext;
public static synchronized NoticeSocketManager getInstance() {
synchronized (NoticeSocketManager.class) {
if (mNoticeSocketManager == null) {
mNoticeSocketManager = new NoticeSocketManager();
}
}
return mNoticeSocketManager;
}
public void registerSocketMessageListener(Context context) {
mContext = context;
MogoAiCloudSocketManager.getInstance(context).
registerOnMessageListener(301001, mTrafficNoticeListener);
MogoAiCloudSocketManager.getInstance(context).
registerOnMessageListener(100, mNormalNoticeListener);
}
public void unRegisterSocketMessageListener() {
MogoAiCloudSocketManager.getInstance(mContext).
unregisterOnMessageListener(301001, mTrafficNoticeListener);
MogoAiCloudSocketManager.getInstance(mContext).
unregisterOnMessageListener(100, mNormalNoticeListener);
}
/**
* 普通云公告
*/
private final IMogoOnMessageListener<NoticeNormalData> mNormalNoticeListener = new IMogoOnMessageListener<NoticeNormalData>() {
@Override
public Class<NoticeNormalData> target() {
return NoticeNormalData.class;
}
@Override
public void onMsgReceived(NoticeNormalData obj) {
if (obj == null) {
return;
}
CallerLogger.INSTANCE.d(M_NOTICE + TAG, "100-- 普通公告数据:" + GsonUtil.jsonFromObject(obj));
NoticeFrCloudMsg noticeFromCloudMsg = new NoticeFrCloudMsg(obj, null, 0);
CallerMsgBoxManager.INSTANCE.saveMsgBox(new MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg));
}
};
/**
* 交警类型公告弹窗
*/
private final IMogoOnMessageListener<NoticeTrafficStylePushData> mTrafficNoticeListener = new IMogoOnMessageListener<NoticeTrafficStylePushData>() {
@Override
public Class<NoticeTrafficStylePushData> target() {
return NoticeTrafficStylePushData.class;
}
@Override
public void onMsgReceived(NoticeTrafficStylePushData obj) {
if (obj == null) {
return;
}
CallerLogger.INSTANCE.d(M_NOTICE + TAG, "301001-- 交警类型公告数据:" + GsonUtil.jsonFromObject(obj));
NoticeFrCloudMsg noticeFromCloudMsg = new NoticeFrCloudMsg(null, obj, 1);
CallerMsgBoxManager.INSTANCE.saveMsgBox(new MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg));
}
};
}

View File

@@ -0,0 +1,50 @@
package com.mogo.eagle.function.biz.push.network;
import com.mogo.eagle.core.data.BaseData;
import com.mogo.eagle.core.data.notice.NoticeNormalDetail;
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.QueryMap;
/**
* @author Jing
* @description 云公告相关的短链请求接口定义
* @since: 10/28/21
*/
public interface NoticeApiService {
/**
* 获取道路事故详情
*
* @param requestBody 请求体(infoId 交警任务id)
* @return {@link NoticeTrafficStyleInfo}
*/
@Headers("Content-Type:application/json;charset=UTF-8")
@POST("/deva/accidentInfoManage/queryMyAccidentHandleInfo/server/v1")
Observable<NoticeTrafficStyleInfo> getAccidentInfo(@Body RequestBody requestBody);
/**
* 反馈对交警事故的操作
*
* @param accidentParameters 请求数据(infoID事故ID;sn;status接受状态 0否 1是)
* @return {@link BaseData}
*/
@GET("/deva/accidentInfoManage/policeUpdateTroubleStatus")
Observable<BaseData> sendAcceptStatus(@QueryMap Map<String, String> accidentParameters);
/**
* 获取普通公告详情
*
* @param param
* @return
*/
@GET("/deva/pc/pathAndPoi/getAnnouncementByDbId")
Observable<NoticeNormalDetail> getNoticeDetail(@QueryMap Map<String, String> param);
}

View File

@@ -0,0 +1,160 @@
package com.mogo.eagle.function.biz.push.network;
import android.util.ArrayMap;
import com.mogo.cloud.network.NetConstants;
import com.mogo.cloud.network.RetrofitFactory;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.eagle.core.data.BaseData;
import com.mogo.eagle.core.data.notice.NoticeNormalDetail;
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
import com.mogo.eagle.core.network.utils.GsonUtil;
import java.util.HashMap;
import java.util.Map;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
* @author Jing
* @description 云公告网络请求类
* @since: 10/28/21
*/
public class NoticeNetWorkManager {
private static volatile NoticeNetWorkManager requestNoticeManager;
private final NoticeApiService mNoticeApiService;
private NoticeNetWorkManager() {
mNoticeApiService = RetrofitFactory.INSTANCE.getInstance(NetConstants.DEVA_HOST)
.create(NoticeApiService.class);
}
public static NoticeNetWorkManager getInstance() {
if (requestNoticeManager == null) {
synchronized (NoticeNetWorkManager.class) {
if (requestNoticeManager == null) {
requestNoticeManager = new NoticeNetWorkManager();
}
}
}
return requestNoticeManager;
}
/**
* 获取事故详细信息
*
* @param infoId 事故id
* @param callBack 回调
*/
public void requestAccidentInfo(String infoId, String sn,NoticeNetCallBack callBack) {
NoticeRequest request = new NoticeRequest(infoId);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"),
GsonUtil.jsonFromObject(request));
mNoticeApiService.getAccidentInfo(requestBody)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<NoticeTrafficStyleInfo>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull NoticeTrafficStyleInfo noticeTrafficStyleInfo) {
if (noticeTrafficStyleInfo.getResult().getAccidentInfo() != null) {
callBack.callBackWithResult(noticeTrafficStyleInfo);
}
}
@Override
public void onError(@NonNull Throwable e) {
}
@Override
public void onComplete() {
}
});
}
/**
* 反馈交警是否接受事故任务
*
* @param infoId 事故id
* @param sn
* @param status 是否接受 0否 1是
*/
public void sendAccidentAcceptStatus(String infoId, String sn, int status) {
Map<String, String> map = new ArrayMap<>();
map.put("sn", sn);
map.put("infoId", infoId);
map.put("status", String.valueOf(status));
mNoticeApiService.sendAcceptStatus(map)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseData>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseData baseData) {
}
@Override
public void onError(@NonNull Throwable e) {
}
@Override
public void onComplete() {
}
});
}
/**
* 获取普通公告的详情
*
* @param dbId
*/
public void getNoticeDetail(String dbId) {
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
Map<String, String> map = new HashMap<>();
map.put("sn", sn);
map.put("infoId", dbId);
mNoticeApiService.getNoticeDetail(map)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<NoticeNormalDetail>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull NoticeNormalDetail noticeNormalDetail) {
}
@Override
public void onError(@NonNull Throwable e) {
}
@Override
public void onComplete() {
}
});
}
}

View File

@@ -0,0 +1,22 @@
package com.mogo.eagle.function.biz.push.network;
/**
* @author Jing
* @description 描述
* @since: 11/15/21
*/
public class NoticeRequest {
private String infoId;
public NoticeRequest(String infoId) {
this.infoId = infoId;
}
public String getInfoId() {
return infoId;
}
public void setInfoId(String infoId) {
this.infoId = infoId;
}
}