[fea]
[核销逻辑]
This commit is contained in:
yangyakun
2024-11-14 16:09:16 +08:00
parent 4a5da037bc
commit ad532478e7
9 changed files with 955 additions and 235 deletions

View File

@@ -0,0 +1,61 @@
package com.mogo.och.common.module.manager.scnner
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
import com.mogo.eagle.core.data.msgbox.MsgBoxType
import com.mogo.eagle.core.data.msgbox.V2XMsg
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDevicesMsg
import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType
object ScannerClientManager {
private val TAG = "ScannerClientManager"
private val writeOfDevicefMsg = object : ILanMessageListener<WriteOffDevicesMsg> {
override fun targetLan(): Class<WriteOffDevicesMsg> = WriteOffDevicesMsg::class.java
override fun onLanMsgReceived(writeOffDevicesMsg: WriteOffDevicesMsg?){
writeOffDevicesMsg?.let {
if (it.isConnectScanner != null) {
val reason = it.reason ?: ""
if (it.isConnectScanner==true) { // 链接成功
saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_DEVICE_STATUS_NORMAL.poiType,
reason,
EventTypeEnumNew.TYPE_DEVICE_STATUS_NORMAL.tts,
""
)
)
)
} else { // 核验失败
saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_DEVICE_STATUS_ABNORMAL.poiType,
reason,
EventTypeEnumNew.TYPE_DEVICE_STATUS_ABNORMAL.tts,
""
)
)
)
}
}
}
}
}
fun load(){
// 核销设备信息
LanSocketManager.registerSocketMessageListener(DPMsgType.TYPE_WRITEOFF_DEVICES_INFO.type,writeOfDevicefMsg)
}
fun release(){
LanSocketManager.unRegisterSocketMessageListener(DPMsgType.TYPE_WRITEOFF_DEVICES_INFO.type,writeOfDevicefMsg)
}
}

View File

@@ -2,6 +2,11 @@ package com.mogo.och.common.module.manager.scnner
import android.net.Uri
import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
import com.mogo.eagle.core.data.msgbox.MsgBoxType
import com.mogo.eagle.core.data.msgbox.V2XMsg
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
@@ -10,10 +15,12 @@ import com.mogo.eagle.core.utilcode.util.StringUtils
import com.mogo.och.common.module.biz.lansocket.IOchLanPassengerStatusListener
import com.mogo.och.common.module.biz.lansocket.LoginLanPassengerSocket
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDevicesMsg
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffMsg
import com.mogo.och.common.module.constant.OchCommonConst
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDetialMsg
import com.mogo.support.serialport.client.SerialPortManager
import com.mogo.support.serialport.client.SerialPortManager.SERVICE_STATE
import com.mogo.support.serialport.client.listener.OnDeviceVerificationListener
@@ -89,7 +96,6 @@ object ScannerManager : IOchLanPassengerStatusListener {
OchChainLogManager.writeChainLogScanner(TAG +"onActiveDataReceive","扫码结果data:${data}")
data?.let {
if(data.unpackStatus==UnpackStatus.SUCCEED){
"数据类型${it.dataType.name}"
CallerLogger.d(M_BUS_P + TAG, "data $it")
if(!StringUtils.isEmpty(it.payload)){
parseParams(it.payload)
@@ -142,9 +148,47 @@ object ScannerManager : IOchLanPassengerStatusListener {
}
private val writeOfDevicefMsg = object : ILanMessageListener<WriteOffDevicesMsg> {
override fun targetLan(): Class<WriteOffDevicesMsg> = WriteOffDevicesMsg::class.java
override fun onLanMsgReceived(writeOffDevicesMsg: WriteOffDevicesMsg?){
writeOffDevicesMsg?.let {
if (writeOffDevicesMsg.isConnectScanner != null) {
val reason = if (writeOffDevicesMsg.reason == null) "" else writeOffDevicesMsg.reason!!
if (writeOffDevicesMsg.isConnectScanner==true) { // 链接成功
saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_DEVICE_STATUS_NORMAL.poiType,
reason,
EventTypeEnumNew.TYPE_DEVICE_STATUS_NORMAL.tts,
""
)
)
)
} else { // 核验失败
saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_DEVICE_STATUS_ABNORMAL.poiType,
reason,
EventTypeEnumNew.TYPE_DEVICE_STATUS_ABNORMAL.tts,
""
)
)
)
}
}
}
}
}
init {
//监听司机端消息
LoginLanPassengerSocket.addListener(TAG,this)
// 核销设备信息
LanSocketManager.registerSocketMessageListener(DPMsgType.TYPE_WRITEOFF_DEVICES_INFO.type,writeOfDevicefMsg)
serialPortManager.bindService(AbsMogoApplication.getApp(), onSerialPortListener)//绑定服务
}
@@ -155,6 +199,10 @@ object ScannerManager : IOchLanPassengerStatusListener {
stateChanageListeners[tag] = listener
}
fun removeListener(tag:String){
stateChanageListeners.remove(tag)
}
override fun onDriverConnectChangeListener(isConnect: Boolean) {
super.onDriverConnectChangeListener(isConnect)
if(isConnect) {
@@ -197,7 +245,7 @@ object ScannerManager : IOchLanPassengerStatusListener {
* 打开设备后数据异常
*/
private fun sendWriteOffMessage2Driver(message:String){
val msg = WriteOffMsg(false, "", 0, "", message,"")
val msg = WriteOffDetialMsg(code = 10001, msg = message)
CallerLogger.d(M_BUS_P + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg))
LanSocketManager.sendMsgToServer(msg)
}

View File

@@ -20,5 +20,6 @@ enum class DPMsgType(val type: Int) {
TYPE_CHANGE_BUSINESS_TYPE(10), //业务模式切换
TYPE_ENV_CHECK(11), //环境核验
TYPE_WRITEOFF_INFO_DETAIL(13), //核销信息
TYPE_WRITEOFF_INFO_RESULT(14), //核销结果
TYPE_CLIENT_REGISTER(12); //客户端注册 服务端需要
}

View File

@@ -85,6 +85,11 @@ data class WriteOffDetialMsg(
val ticketName: String?=null,
) : BaseDPMsg(DPMsgType.TYPE_WRITEOFF_INFO_DETAIL.type)
data class WriteOffResultMsg(
val code:Int,// 1成功 其他失败
val phone:String,// 手机号
) : BaseDPMsg(DPMsgType.TYPE_WRITEOFF_INFO_RESULT.type)
data class WriteOffDevicesMsg(
val isConnectScanner: Boolean?,
val reason: String?

View File

@@ -0,0 +1,703 @@
{
"formatVersion": 1,
"database": {
"version": 4,
"identityHash": "b0f45b39cb8086ad1700c5f46bc8ee82",
"entities": [
{
"tableName": "contrail_data_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `csv_file_url` TEXT, `csv_file_md5` TEXT, `txt_file_url` TEXT, `txt_file_md5` TEXT, `contrail_save_time` INTEGER, `md5` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lineId",
"columnName": "line_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "csvFileUrl",
"columnName": "csv_file_url",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "csvFileMd5",
"columnName": "csv_file_md5",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "txtFileUrl",
"columnName": "txt_file_url",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "txtFileMd5",
"columnName": "txt_file_md5",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "contrailSaveTime",
"columnName": "contrail_save_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "md5",
"columnName": "md5",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_contrail_data_table_line_id",
"unique": false,
"columnNames": [
"line_id"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)"
},
{
"name": "index_contrail_data_table_md5",
"unique": false,
"columnNames": [
"md5"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_md5` ON `${TABLE_NAME}` (`md5`)"
}
],
"foreignKeys": []
},
{
"tableName": "line_data_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `line_get_time` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lineId",
"columnName": "line_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lineName",
"columnName": "line_name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "endStationName",
"columnName": "end_station_name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "linegetTime",
"columnName": "line_get_time",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_line_data_table_line_id",
"unique": false,
"columnNames": [
"line_id"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_line_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)"
}
],
"foreignKeys": []
},
{
"tableName": "site_data_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `site_id` INTEGER, `line_id` INTEGER, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `introduction` TEXT, `is_play_tts` INTEGER, `md5` TEXT, `videoList` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "siteId",
"columnName": "site_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lineId",
"columnName": "line_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "nameKr",
"columnName": "name_kr",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "seq",
"columnName": "seq",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "gcjLon",
"columnName": "gcj_lon",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "gcjLat",
"columnName": "gcj_lat",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "lon",
"columnName": "lon",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "lat",
"columnName": "lat",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "introduction",
"columnName": "introduction",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "isPlayTts",
"columnName": "is_play_tts",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "md5",
"columnName": "md5",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "videoListDB",
"columnName": "videoList",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_site_data_table_site_id",
"unique": false,
"columnNames": [
"site_id"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_site_id` ON `${TABLE_NAME}` (`site_id`)"
},
{
"name": "index_site_data_table_line_id",
"unique": false,
"columnNames": [
"line_id"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)"
}
],
"foreignKeys": []
},
{
"tableName": "task_data_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `task_data` INTEGER, `task_start_time` INTEGER, `start_time` INTEGER, `end_time` INTEGER, `task_get_time` INTEGER NOT NULL, `status` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "taskId",
"columnName": "task_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lineId",
"columnName": "line_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "taskDate",
"columnName": "task_data",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "taskStartTime",
"columnName": "task_start_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "startTime",
"columnName": "start_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "endtime",
"columnName": "end_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "taskgetTime",
"columnName": "task_get_time",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "status",
"columnName": "status",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_task_data_table_task_id",
"unique": false,
"columnNames": [
"task_id"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_task_id` ON `${TABLE_NAME}` (`task_id`)"
},
{
"name": "index_task_data_table_line_id",
"unique": false,
"columnNames": [
"line_id"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)"
}
],
"foreignKeys": []
},
{
"tableName": "used_task_data_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `line_name` TEXT, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `driving_status` INTEGER, `leaving` INTEGER, `arrived_time` INTEGER, `leave_time` INTEGER, `introduction` TEXT, `is_play_tts` INTEGER, `event_save_time` INTEGER NOT NULL, `videoList` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "taskId",
"columnName": "task_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lineId",
"columnName": "line_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "siteId",
"columnName": "site_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lineName",
"columnName": "line_name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "nameKr",
"columnName": "name_kr",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "seq",
"columnName": "seq",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "gcjLon",
"columnName": "gcj_lon",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "gcjLat",
"columnName": "gcj_lat",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "lon",
"columnName": "lon",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "lat",
"columnName": "lat",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "drivingStatus",
"columnName": "driving_status",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "leaving",
"columnName": "leaving",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "arrivedTime",
"columnName": "arrived_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "leaveTime",
"columnName": "leave_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "introduction",
"columnName": "introduction",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "isPlayTts",
"columnName": "is_play_tts",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "eventSaveTime",
"columnName": "event_save_time",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "videoList",
"columnName": "videoList",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "event_data_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `lineId` INTEGER, `lineName` TEXT, `task_id` INTEGER, `task_start_time` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `driver_id` INTEGER, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "eventType",
"columnName": "event_type",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "lineId",
"columnName": "lineId",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lineName",
"columnName": "lineName",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "taskId",
"columnName": "task_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "taskStartTime",
"columnName": "task_start_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "businessTime",
"columnName": "business_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "writeVersion",
"columnName": "write_version",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "siteId",
"columnName": "site_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "seq",
"columnName": "seq",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "driverId",
"columnName": "driver_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "eventSaveTime",
"columnName": "event_save_time",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updateStatus",
"columnName": "update_status",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_event_data_table_event_save_time",
"unique": false,
"columnNames": [
"event_save_time"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_event_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)"
}
],
"foreignKeys": []
},
{
"tableName": "writeoff_data_table",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `expiry_time` INTEGER, `booking_time` INTEGER, `type` INTEGER, `task_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `remaining_times` INTEGER, `order_no` TEXT, `uid` TEXT, `seq` TEXT, `tick_size` INTEGER, `tick_name` TEXT, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "expiryTime",
"columnName": "expiry_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "bookingTime",
"columnName": "booking_time",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "taskId",
"columnName": "task_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lineId",
"columnName": "line_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "siteId",
"columnName": "site_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remainingTimes",
"columnName": "remaining_times",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "orderNo",
"columnName": "order_no",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "uid",
"columnName": "uid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "phone",
"columnName": "seq",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "ticketSize",
"columnName": "tick_size",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "ticketName",
"columnName": "tick_name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "eventSaveTime",
"columnName": "event_save_time",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updateStatus",
"columnName": "update_status",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_writeoff_data_table_event_save_time",
"unique": false,
"columnNames": [
"event_save_time"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_writeoff_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)"
}
],
"foreignKeys": []
}
],
"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, 'b0f45b39cb8086ad1700c5f46bc8ee82')"
]
}
}

View File

@@ -11,6 +11,7 @@ import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.och.common.module.constant.OchCommonConst
import com.mogo.och.common.module.biz.provider.CommonServiceImpl
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics
import com.mogo.och.common.module.manager.scnner.ScannerClientManager
import com.mogo.och.weaknet.repository.db.repository.EventDb
import com.mogo.och.weaknet.repository.db.repository.LineDb
import com.mogo.och.weaknet.repository.db.repository.TaskDb
@@ -48,7 +49,8 @@ class ShuttleDriverProvider : CommonServiceImpl() {
busFragment = ShuttleFragment()
}
OchAutopilotAnalytics.ochEventKey = BusAnalyticsManager
LineModel.init();
LineModel.init()
ScannerClientManager.load()
return busFragment!!
}
@@ -56,6 +58,7 @@ class ShuttleDriverProvider : CommonServiceImpl() {
busFragment = null
OchAutopilotAnalytics.ochEventKey = null
LineModel.release()
ScannerClientManager.release()
RepositoryManager.release()
}

View File

@@ -22,8 +22,7 @@ import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDetialMsg
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDevicesMsg
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffMsg
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffResultMsg
import com.mogo.och.common.module.network.OchCommonServiceCallback
import com.mogo.och.weaknet.bean.response.WriteOffCountResponse
import com.mogo.och.weaknet.bean.WriteOffPassenger
@@ -39,7 +38,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
object TicketModel : IOchOnMessageListener<WriteOffPassenger>{
object TicketModel {
private const val TAG = "TicketModel"
@@ -47,18 +46,42 @@ object TicketModel : IOchOnMessageListener<WriteOffPassenger>{
private var emitterMain: ObservableEmitter<Pair<Int,Int>>?=null
private val observable = Observable.create(ObservableOnSubscribe<Pair<Int,Int>> { emitter -> emitterMain = emitter })
private val writeOfDevicefMsg = object : ILanMessageListener<WriteOffDevicesMsg> {
override fun targetLan(): Class<WriteOffDevicesMsg> = WriteOffDevicesMsg::class.java
override fun onLanMsgReceived(obj: WriteOffDevicesMsg?) = receiveWrteOffDevicesInfo(obj)
}
private val writeOfDevicefDetialMsg = object : ILanMessageListener<WriteOffDetialMsg> {
/**
* 接受乘客端扫码数据进行云端和本地核销
*/
private val writeOffDetialMsg = object : ILanMessageListener<WriteOffDetialMsg> {
override fun targetLan(): Class<WriteOffDetialMsg> = WriteOffDetialMsg::class.java
override fun onLanMsgReceived(obj: WriteOffDetialMsg?) = receiveWrteOffDefailtInfo(obj)
}
/**
* 接受乘客端扫码数据进行云端和本地核销
*/
private val writeOffOnlineMsg = object : IOchOnMessageListener<WriteOffPassenger> {
override fun target(): Class<WriteOffPassenger> {
return WriteOffPassenger::class.java
}
override fun onMsgReceived(passenger: WriteOffPassenger?) {
//进行播报
i(SceneConstant.M_BUS + TAG, "后台socket 核验:passenger = " + GsonUtil.jsonFromObject(passenger))
if(passenger==null||passenger.passengerSize==0){
return
}
writeOffSuccess(
passenger.passengerSize,
passenger.phone ?: "",
passenger.ticketName?:"",
)
TODO("服务器端核销需要在本地报备一下 用于计算数据")
}
}
private val observable = Observable.create(ObservableOnSubscribe<Pair<Int,Int>> { emitter -> emitterMain = emitter })
fun getWriteOffCountObservable():Observable<Pair<Int,Int>>{
return observable
}
fun load(){
// 3s轮训站点核销人数 人数本地核销 直接计算就好
@@ -69,42 +92,20 @@ object TicketModel : IOchOnMessageListener<WriteOffPassenger>{
)
}
// 核销信息
LanSocketManager.registerSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO_DETAIL.type,writeOfDevicefDetialMsg)
// 核销设备信息
LanSocketManager.registerSocketMessageListener(DPMsgType.TYPE_WRITEOFF_DEVICES_INFO.type,writeOfDevicefMsg)
LanSocketManager.registerSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO_DETAIL.type,writeOffDetialMsg)
//监听核销乘客
OCHSocketMessageManager.registerSocketMessageListener(OCHSocketMessageManager.msgWriteOffPassengerType, this)
OCHSocketMessageManager.registerSocketMessageListener(OCHSocketMessageManager.msgWriteOffPassengerType, writeOffOnlineMsg)
}
fun release(){
if(RepositoryManager.supportWriteOff()) {
BizLoopManager.removeLoopFunction(SELECTWRITEOFFCOUNT)
}
LanSocketManager.unRegisterSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO_DETAIL.type,writeOfDevicefDetialMsg)
LanSocketManager.unRegisterSocketMessageListener(DPMsgType.TYPE_WRITEOFF_DEVICES_INFO.type,writeOfDevicefMsg)
LanSocketManager.unRegisterSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO_DETAIL.type,writeOffDetialMsg)
OCHSocketMessageManager.releaseSocketMessageListener(OCHSocketMessageManager.msgWriteOffPassengerType)
}
override fun target(): Class<WriteOffPassenger> {
return WriteOffPassenger::class.java
}
// 收到服务器的核验信息
override fun onMsgReceived(passenger: WriteOffPassenger?) {
//进行播报
i(SceneConstant.M_BUS + TAG, "后台socket 核验:passenger = " + GsonUtil.jsonFromObject(passenger))
if(passenger==null||passenger.passengerSize==0){
return
}
playPassenger(
passenger.passengerSize,
passenger.phone ?: "",
passenger.ticketName?:"",
)
TODO("服务器端核销需要在本地报备一下 用于计算数据")
selectWriteOffCount()
}
private fun selectWriteOffCount(){
LineManager.getStations().first?.let { firstStation->
LineModel.currentTask?.let { currentTask->
@@ -138,56 +139,15 @@ object TicketModel : IOchOnMessageListener<WriteOffPassenger>{
d(SceneConstant.M_BUS + TAG, "线路或者站点未空")
}
fun getWriteOffCountObservable():Observable<Pair<Int,Int>>{
return observable
}
private fun receiveWrteOffInfo(writeOffMsg: WriteOffMsg?) {
if(writeOffMsg!=null) {
if (writeOffMsg.isScuccess != null) {
if (writeOffMsg.isScuccess == true) { // 核验成功
if(writeOffMsg.ticketSize==null||writeOffMsg.ticketSize==0){
return
}
} else { // 核验失败
ShuttleVoiceManager.writeOffFaile(writeOffMsg.failedReason ?: "")
var tempPhone = writeOffMsg.phone
tempPhone?.let {
if (it.length > 8) {
//截取电话号码前三位
val phoneNumPre = it.substring(0, 3)
//截取电话号码后四位
val phoneNumFix = it.substring(7)
tempPhone = "$phoneNumPre****$phoneNumFix"
}
}
val reaseonAndPhone = if(tempPhone.isNullOrEmpty()) {
"${writeOffMsg.failedReason}"
}else{
"${writeOffMsg.failedReason};乘客:${tempPhone}"
}
saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X, V2XMsg(
EventTypeEnumNew.TYPE_ABNORMAL_VERIFICATION.poiType,
reaseonAndPhone,
EventTypeEnumNew.TYPE_ABNORMAL_VERIFICATION.tts,
""
)
)
)
}
}
}
}
private fun receiveWrteOffDefailtInfo(writeOffDetialMsg: WriteOffDetialMsg?) {
writeOffDetialMsg?.let {
if(writeOffDetialMsg.code!=0){
if (writeOffDetialMsg.code != 0) {
sendMessage2Driver(
writeOffDetialMsg.msg?:"",
writeOffDetialMsg.phone ?: ""
writeOffDetialMsg.msg ?: "",
writeOffDetialMsg.phone ?: "",false
)
}else {
} else {
RepositoryManager.writeOff(writeOffDetialMsg)
?.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
@@ -200,116 +160,7 @@ object TicketModel : IOchOnMessageListener<WriteOffPassenger>{
d(TAG, "receiveWrteOffDefailtInfo onError${e.printStackTrace()}")
if (e is DataException) {
CallerLogger.d(M_BUS_P + TAG, "核销失败 ${e.code}-----${e.msg}")
when (e.code) {
6002 -> {
sendMessage2Driver(
"同一订单核销间隔时间需大于2分钟",
writeOffDetialMsg.phone ?: ""
)
}
1009 -> {
sendMessage2Driver(
"车票所选乘车日期非今日",
writeOffDetialMsg.phone ?: ""
)
}
1005 -> {
sendMessage2Driver(
"车辆未登录、或没有任务",
writeOffDetialMsg.phone ?: ""
)
}
1006 -> {
sendMessage2Driver(
"车票路线信息与当前车辆执行任务的路线信息不符合",
writeOffDetialMsg.phone ?: ""
)
}
1008 -> {
sendMessage2Driver(
"车票剩余可用次数为0",
writeOffDetialMsg.phone ?: ""
)
}
6001 -> {
sendMessage2Driver(
"二维码已过期",
writeOffDetialMsg.phone ?: ""
)
}
1012 -> {
sendMessage2Driver(
"当前用户下单路线非当前的车辆所属公司",
writeOffDetialMsg.phone ?: ""
)
}
else -> {
when (e.msg) {
"6002" -> {
sendMessage2Driver(
"同一订单核销间隔时间需大于2分钟",
writeOffDetialMsg.phone ?: ""
)
}
"1009" -> {
sendMessage2Driver(
"车票所选乘车日期非今日",
writeOffDetialMsg.phone ?: ""
)
}
"1005" -> {
sendMessage2Driver(
"车辆未登录、或没有任务",
writeOffDetialMsg.phone ?: ""
)
}
"1006" -> {
sendMessage2Driver(
"车票路线信息与当前车辆执行任务的路线信息不符合",
writeOffDetialMsg.phone ?: ""
)
}
"1008" -> {
sendMessage2Driver(
"车票剩余可用次数为0",
writeOffDetialMsg.phone ?: ""
)
}
"6001" -> {
sendMessage2Driver(
"二维码已过期",
writeOffDetialMsg.phone ?: ""
)
}
"1012" -> {
sendMessage2Driver(
"当前用户下单路线非当前的车辆所属公司",
writeOffDetialMsg.phone ?: ""
)
}
else -> {
sendMessage2Driver(
e.msg,
writeOffDetialMsg.phone ?: ""
)
}
}
}
}
parseData(e.code,e.msg?:"",writeOffDetialMsg.phone?:"")
}
}
@@ -319,57 +170,86 @@ object TicketModel : IOchOnMessageListener<WriteOffPassenger>{
override fun onNext(data: PassengerWriteOffResponse.Result) {
d(TAG, "queryBusLines onNext ${data}")
selectWriteOffCount()
playPassenger(
writeOffSuccess(
data.ticketSize ?: 0,
data.phone ?: "",
data.ticketName ?: ""
)
}
})
}
}
}
private fun sendMessage2Driver(message:String,phone:String){
val msg = WriteOffMsg(false, phone, 0, "", "验票失败,${message}","")
receiveWrteOffInfo(msg)
}
private fun receiveWrteOffDevicesInfo(writeOffDevicesMsg: WriteOffDevicesMsg?) {
writeOffDevicesMsg?.let {
if (writeOffDevicesMsg.isConnectScanner != null) {
val reason = if (writeOffDevicesMsg.reason == null) "" else writeOffDevicesMsg.reason!!
if (writeOffDevicesMsg.isConnectScanner==true) { // 链接成功
saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_DEVICE_STATUS_NORMAL.poiType,
reason,
EventTypeEnumNew.TYPE_DEVICE_STATUS_NORMAL.tts,
""
)
)
)
} else { // 核验失败
saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_DEVICE_STATUS_ABNORMAL.poiType,
reason,
EventTypeEnumNew.TYPE_DEVICE_STATUS_ABNORMAL.tts,
""
)
)
)
/**
* 解析错误原因
*/
private fun parseData(code:Int,msg:String,phone: String){
when (code) {
6002 -> sendMessage2Driver("同一订单核销间隔时间需大于2分钟", phone)
1009 -> sendMessage2Driver("车票所选乘车日期非今日", phone)
1005 -> sendMessage2Driver("车辆未登录、或没有任务", phone)
1006 -> sendMessage2Driver("车票路线信息与当前车辆执行任务的路线信息不符合", phone)
1008 -> sendMessage2Driver("车票剩余可用次数为0", phone)
6001 -> sendMessage2Driver("二维码已过期", phone)
1012 -> sendMessage2Driver("当前用户下单路线非当前的车辆所属公司", phone)
else -> {
try {
val tempcode=msg.toInt()
parseData(tempcode,msg,phone)
}catch (e:Exception){
sendMessage2Driver(msg, phone)
}
}
}
}
private fun playPassenger(ticketSize: Int,phone:String,ticketName:String) {
/**
* 验票失败
*/
private fun sendMessage2Driver(message:String,phone:String,send2Source:Boolean=true){
// 发送乘客屏 通过蓝牙告知小程序
LanSocketManager.sendMsgToClient(WriteOffResultMsg(code = -1,phone = phone))
val failedReason = "验票失败,${message}"
ShuttleVoiceManager.writeOffFaile(failedReason)
var tempPhone = phone
tempPhone.let {
if (it.length > 8) {
//截取电话号码前三位
val phoneNumPre = it.substring(0, 3)
//截取电话号码后四位
val phoneNumFix = it.substring(7)
tempPhone = "$phoneNumPre****$phoneNumFix"
}
}
val reaseonAndPhone = if(tempPhone.isNullOrEmpty()) {
failedReason
}else{
"${failedReason};乘客:${tempPhone}"
}
saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X, V2XMsg(
EventTypeEnumNew.TYPE_ABNORMAL_VERIFICATION.poiType,
reaseonAndPhone,
EventTypeEnumNew.TYPE_ABNORMAL_VERIFICATION.tts,
""
)
)
)
}
/**
* 验票成功
* 1、本地核销
* 2、云端核销
*/
private fun writeOffSuccess(ticketSize: Int, phone:String, ticketName:String) {
// 发送乘客屏 通过蓝牙告知小程序
LanSocketManager.sendMsgToClient(WriteOffResultMsg(code = 1,phone = phone))
selectWriteOffCount()
ShuttleVoiceManager.writeOffCount(ticketSize)

View File

@@ -30,7 +30,7 @@ class ShuttlePassengerProvider : CommonServiceImpl() {
private var mPM2Fragment: Fragment?=null
override fun init(context: Context) {
TicketModel.load()
}
override fun getStatusBarView(context: Context): View {
@@ -59,11 +59,13 @@ class ShuttlePassengerProvider : CommonServiceImpl() {
BusPassengerRouteFragment()
}
}
TicketModel.load()
return mPM2Fragment!!
}
override fun resetFragment() {
super.resetFragment()
TicketModel.release()
mPM2Fragment = null
}

View File

@@ -7,18 +7,35 @@ import com.mogo.eagle.core.utilcode.util.RegexUtils
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
import com.mogo.och.common.module.manager.scnner.ScannerManager
import com.mogo.och.common.module.manager.scnner.StateChangeListener
import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener
import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDetialMsg
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffResultMsg
object TicketModel : StateChangeListener {
private const val TAG = "TicketModel"
init {
ScannerManager.addStateChangeListener(TAG, this)
}
fun load(){
private val writeOffResultMsg = object : ILanMessageListener<WriteOffResultMsg> {
override fun targetLan(): Class<WriteOffResultMsg> = WriteOffResultMsg::class.java
override fun onLanMsgReceived(obj: WriteOffResultMsg?) {
// 收到核销结果扫描蓝牙并写会核销结果
}
}
fun load(){
ScannerManager.addStateChangeListener(TAG, this)
// 核销信息
LanSocketManager.registerSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO_RESULT.type,writeOffResultMsg)
}
fun release(){
ScannerManager.removeListener(TAG)
LanSocketManager.unRegisterSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO_RESULT.type,writeOffResultMsg)
}
override fun parseData(params: MutableMap<String, Any>, payload: String?) {