[6.6.0]
[event 上报]
This commit is contained in:
@@ -48,6 +48,12 @@ object OchChainLogManager {
|
||||
|
||||
const val EVENT_KEY_INFO_VOICE_TTS = "analytics_event_och_voice_tts"
|
||||
|
||||
const val EVENT_KEY_INFO_DB = "analytics_event_och_db"
|
||||
|
||||
|
||||
fun writeChainLogDb( title: String, info: String) {
|
||||
writeChainLog(title, info, true, EVENT_KEY_INFO_DB)
|
||||
}
|
||||
|
||||
|
||||
fun writeChainLogNet(mustUpdate: Boolean, title: String, info: String) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "58751308e081c3bc5fd17ee6efb92778",
|
||||
"identityHash": "da53315ef85c8d9609891e105a315a62",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "contrail_data_table",
|
||||
@@ -489,7 +489,7 @@
|
||||
},
|
||||
{
|
||||
"tableName": "event_data_table",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `task_id` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `event_save_time` INTEGER NOT NULL)",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `task_id` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
@@ -538,6 +538,12 @@
|
||||
"columnName": "event_save_time",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updateStatus",
|
||||
"columnName": "update_status",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
@@ -563,7 +569,7 @@
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '58751308e081c3bc5fd17ee6efb92778')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'da53315ef85c8d9609891e105a315a62')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.och.weaknet.bean
|
||||
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.network.utils.digest.DigestUtils
|
||||
import com.mogo.och.weaknet.database.bean.EventDataBean
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/3/22
|
||||
*
|
||||
* 根据车机行驶线路站点信息
|
||||
*/
|
||||
data class ShuttleEventRequest(val requestId: String, val sn: String, val businessType: Int,val eventList:MutableList<Event>){
|
||||
companion object{
|
||||
val businessTypeShuttle = 11
|
||||
fun transformDb2Net(waitUpdateEvent: List<EventDataBean>): ShuttleEventRequest {
|
||||
val md5Hex = DigestUtils.md5Hex(waitUpdateEvent.toString())
|
||||
val eventList4Request = mutableListOf<Event>()
|
||||
var tempEvent:Event?=null
|
||||
waitUpdateEvent.forEach {
|
||||
tempEvent = Event(it.eventType,
|
||||
EventData(it.taskId,it.businessTime,it.writeVersion,it.siteId,it.seq)
|
||||
)
|
||||
eventList4Request.add(tempEvent!!)
|
||||
}
|
||||
return ShuttleEventRequest(md5Hex, SharedPrefsMgr.getInstance().sn,businessTypeShuttle,eventList4Request)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class Event(var eventType: String?,val eventData:EventData)
|
||||
|
||||
data class EventData(
|
||||
var taskId: Long?,
|
||||
var businessTime: Long?,
|
||||
var writeVersion: Long?,
|
||||
var siteId: Long?,
|
||||
var seq: Int?
|
||||
)
|
||||
@@ -50,6 +50,9 @@ data class EventDataBean(
|
||||
@ColumnInfo(name = "event_save_time", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
val eventSaveTime: Long = System.currentTimeMillis(),
|
||||
|
||||
@ColumnInfo(name = "update_status", typeAffinity = ColumnInfo.INTEGER)
|
||||
var updateStatus:Int = 0
|
||||
|
||||
) {
|
||||
companion object {
|
||||
const val evnetDataTable: String = "event_data_table"
|
||||
@@ -60,7 +63,9 @@ data class EventDataBean(
|
||||
const val TaskEnd = "TaskEnd"
|
||||
|
||||
|
||||
|
||||
const val notUpdate = 0
|
||||
const val updating = 1
|
||||
const val updated = 2
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,7 @@ interface EventDataDao {
|
||||
@Delete
|
||||
fun delete(vararg eventDataBean: EventDataBean)
|
||||
|
||||
@Query("SELECT * FROM ${EventDataBean.evnetDataTable} WHERE update_status = ${EventDataBean.notUpdate} LIMIT 10 OFFSET 0")
|
||||
fun queryEventByStatusWithPage():List<EventDataBean>?
|
||||
|
||||
}
|
||||
|
||||
@@ -71,6 +71,14 @@ object EventRepository {
|
||||
}
|
||||
}
|
||||
|
||||
fun queryWaitUpdateEvent(): List<EventDataBean>? {
|
||||
return eventDataDao?.queryEventByStatusWithPage()
|
||||
}
|
||||
|
||||
fun saveUpdateSuccess(waitUpdateEvent: List<EventDataBean>) {
|
||||
eventDataDao?.insert(*waitUpdateEvent.toTypedArray())
|
||||
}
|
||||
|
||||
interface EventCallback {
|
||||
fun notifySyn()
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ object BusLineModel {
|
||||
@JvmStatic
|
||||
fun init() {
|
||||
mContext = AbsMogoApplication.getApp()
|
||||
EventModel.load()
|
||||
BizLoopManager.setLoopFunction(
|
||||
"${TAG}_${LoopCarInfo}",
|
||||
LoopInfo(60, ::queryCarExecutableTaskList, immediately = true)
|
||||
@@ -77,6 +78,7 @@ object BusLineModel {
|
||||
@JvmStatic
|
||||
fun release() {
|
||||
mContext = null
|
||||
EventModel.release()
|
||||
mBusLinesCallback = null
|
||||
BizLoopManager.removeLoopFunction("${TAG}_${LoopCarInfo}")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.mogo.och.weaknet.model
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
import com.mogo.och.weaknet.bean.ShuttleEventRequest
|
||||
import com.mogo.och.weaknet.database.bean.EventDataBean
|
||||
import com.mogo.och.weaknet.database.repository.EventRepository
|
||||
import com.mogo.och.weaknet.net.OrderServiceManager
|
||||
|
||||
object EventModel : EventRepository.EventCallback {
|
||||
|
||||
|
||||
|
||||
|
||||
fun load(){
|
||||
EventRepository.eventCallback = this
|
||||
}
|
||||
|
||||
fun release(){
|
||||
EventRepository.eventCallback = null
|
||||
}
|
||||
|
||||
override fun notifySyn() {
|
||||
updateEvent()
|
||||
}
|
||||
|
||||
|
||||
private fun updateEvent(){
|
||||
ThreadUtils.getSinglePool().submit {
|
||||
val waitUpdateEvent = EventRepository.queryWaitUpdateEvent()
|
||||
if(waitUpdateEvent.isNullOrEmpty()){
|
||||
OchChainLogManager.writeChainLogDb("上报event","没有数据需要上报${Thread.currentThread().name}")
|
||||
return@submit
|
||||
}
|
||||
OchChainLogManager.writeChainLogDb("上报event","开始上报:${Thread.currentThread().name}")
|
||||
val transformDb2Net = ShuttleEventRequest.transformDb2Net(waitUpdateEvent)
|
||||
OrderServiceManager.reportCabinEvent(AbsMogoApplication.getApp()!!,transformDb2Net,object :OchCommonServiceCallback<BaseData>{
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
waitUpdateEvent.forEach {
|
||||
it.updateStatus = EventDataBean.updated
|
||||
}
|
||||
OchChainLogManager.writeChainLogDb("上报event成功","$transformDb2Net ${Thread.currentThread().name}")
|
||||
EventRepository.saveUpdateSuccess(waitUpdateEvent)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
OchChainLogManager.writeChainLogDb("上报event失败","$transformDb2Net ${Thread.currentThread().name}")
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
super.onError()
|
||||
OchChainLogManager.writeChainLogDb("上报event失败","$transformDb2Net ${Thread.currentThread().name}")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.mogo.och.weaknet.model
|
||||
|
||||
import com.elegant.network.utils.GsonUtil
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.env.ProjectUtils
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
@@ -52,7 +53,12 @@ object TicketModel : IOchOnMessageListener<WriteOffPassenger>{
|
||||
|
||||
fun load(){
|
||||
// 3s轮训站点核销人数
|
||||
BizLoopManager.setLoopFunction(SELECTWRITEOFFCOUNT, LoopInfo(3, TicketModel::selectWriteOffCount,scheduler = Schedulers.io()))
|
||||
if(ProjectUtils.isDali()) {
|
||||
BizLoopManager.setLoopFunction(
|
||||
SELECTWRITEOFFCOUNT,
|
||||
LoopInfo(3, TicketModel::selectWriteOffCount, scheduler = Schedulers.io())
|
||||
)
|
||||
}
|
||||
// 核销信息
|
||||
LanSocketManager.registerSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO.type,writeOffMsg)
|
||||
// 核销设备信息
|
||||
@@ -62,7 +68,9 @@ object TicketModel : IOchOnMessageListener<WriteOffPassenger>{
|
||||
}
|
||||
|
||||
fun release(){
|
||||
BizLoopManager.removeLoopFunction(SELECTWRITEOFFCOUNT)
|
||||
if(ProjectUtils.isDali()) {
|
||||
BizLoopManager.removeLoopFunction(SELECTWRITEOFFCOUNT)
|
||||
}
|
||||
LanSocketManager.unRegisterSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO.type,writeOffMsg)
|
||||
LanSocketManager.unRegisterSocketMessageListener(DPMsgType.TYPE_WRITEOFF_DEVICES_INFO.type,writeOfDevicefMsg)
|
||||
OCHSocketMessageManager.releaseSocketMessageListener(OCHSocketMessageManager.msgWriteOffPassengerType)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.mogo.och.weaknet.net;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.och.weaknet.bean.BusQueryLineStationsRequest;
|
||||
import com.mogo.och.weaknet.bean.BusRoutesResponse;
|
||||
import com.mogo.och.weaknet.bean.CarExecutableTaskResponse;
|
||||
import com.mogo.och.weaknet.bean.ShuttleEventRequest;
|
||||
import com.mogo.och.weaknet.bean.WriteOffCountResponse;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@@ -40,5 +42,9 @@ public interface IBascApiService {
|
||||
@GET("/och-vehicle/cabin/queryCarExecutableTaskList")
|
||||
Observable<CarExecutableTaskResponse> queryCarExecutableTaskList(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
|
||||
|
||||
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
|
||||
@POST( "/och-vehicle/cabin/reportCabinEvent" )
|
||||
Observable<BaseData> reportCabinEvent(@Header ("appId") String appId, @Header("ticket") String ticket, @Body ShuttleEventRequest request);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.och.weaknet.net
|
||||
import android.content.Context
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
@@ -12,6 +13,7 @@ import com.mogo.och.common.module.network.interceptor.transformTry
|
||||
import com.mogo.och.weaknet.bean.BusQueryLineStationsRequest
|
||||
import com.mogo.och.weaknet.bean.BusRoutesResponse
|
||||
import com.mogo.och.weaknet.bean.CarExecutableTaskResponse
|
||||
import com.mogo.och.weaknet.bean.ShuttleEventRequest
|
||||
import com.mogo.och.weaknet.bean.WriteOffCountResponse
|
||||
|
||||
/**
|
||||
@@ -72,4 +74,20 @@ object OrderServiceManager {
|
||||
.transformIoTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryCarExecutableTaskList"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun reportCabinEvent(
|
||||
context: Context,
|
||||
data: ShuttleEventRequest,
|
||||
callback: OchCommonServiceCallback<BaseData>?,
|
||||
) {
|
||||
mService.reportCabinEvent(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
data,
|
||||
)
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "reportCabinEvent"))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user