[6.6.0]
[数据库添加]
This commit is contained in:
@@ -160,6 +160,17 @@ public class DateTimeUtil {
|
||||
|
||||
}
|
||||
|
||||
public static long getCurrentDateZero(){
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
return calendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
|
||||
private static final ThreadLocal<Map<String, SimpleDateFormat>> SDF_THREAD_LOCAL
|
||||
= new ThreadLocal<Map<String, SimpleDateFormat>>() {
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ android {
|
||||
useBuildCache = false
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", "shuttle_weaknet_"+project.getName())
|
||||
arg("room.schemaLocation", "$projectDir/schemas".toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +59,11 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.androidxrecyclerview
|
||||
compileOnly rootProject.ext.dependencies.recyclerviewadapterhelper
|
||||
kapt rootProject.ext.dependencies.recyclerviewadapterhelper
|
||||
|
||||
implementation rootProject.ext.dependencies.androidxroomruntime
|
||||
kapt rootProject.ext.dependencies.androidxroomcompiler
|
||||
|
||||
|
||||
implementation project(":OCH:common:common")
|
||||
implementation project(":OCH:common:data")
|
||||
|
||||
@@ -0,0 +1,545 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "09d7e5149c9755201cd38ff92f3b3d85",
|
||||
"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_csv_file_url",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"csv_file_url"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_csv_file_url` ON `${TABLE_NAME}` (`csv_file_url`)"
|
||||
},
|
||||
{
|
||||
"name": "index_contrail_data_table_csv_file_md5",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"csv_file_md5"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_csv_file_md5` ON `${TABLE_NAME}` (`csv_file_md5`)"
|
||||
},
|
||||
{
|
||||
"name": "index_contrail_data_table_txt_file_url",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"txt_file_url"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_txt_file_url` ON `${TABLE_NAME}` (`txt_file_url`)"
|
||||
},
|
||||
{
|
||||
"name": "index_contrail_data_table_txt_file_md5",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"txt_file_md5"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_txt_file_md5` ON `${TABLE_NAME}` (`txt_file_md5`)"
|
||||
},
|
||||
{
|
||||
"name": "index_contrail_data_table_contrail_save_time",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"contrail_save_time"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_contrail_save_time` ON `${TABLE_NAME}` (`contrail_save_time`)"
|
||||
},
|
||||
{
|
||||
"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, `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": "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`)"
|
||||
},
|
||||
{
|
||||
"name": "index_line_data_table_line_get_time",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"line_get_time"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_line_data_table_line_get_time` ON `${TABLE_NAME}` (`line_get_time`)"
|
||||
}
|
||||
],
|
||||
"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)",
|
||||
"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
|
||||
}
|
||||
],
|
||||
"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, `line_name` TEXT, `site_id` INTEGER, `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)",
|
||||
"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": "lineName",
|
||||
"columnName": "line_name",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "siteId",
|
||||
"columnName": "site_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": "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
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_used_task_data_table_task_id",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"task_id"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_used_task_data_table_task_id` ON `${TABLE_NAME}` (`task_id`)"
|
||||
},
|
||||
{
|
||||
"name": "index_used_task_data_table_line_id",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"line_id"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_used_task_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)"
|
||||
},
|
||||
{
|
||||
"name": "index_used_task_data_table_site_id",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"site_id"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_used_task_data_table_site_id` ON `${TABLE_NAME}` (`site_id`)"
|
||||
}
|
||||
],
|
||||
"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, '09d7e5149c9755201cd38ff92f3b3d85')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.och.weaknet.fragment.ShuttleFragment
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.provider.CommonServiceImpl
|
||||
import com.mogo.och.weaknet.model.BusLineModel
|
||||
|
||||
/**
|
||||
* 网约车小巴业务实现入口
|
||||
@@ -28,11 +29,13 @@ class ShuttleDriverProvider : CommonServiceImpl() {
|
||||
if(busFragment==null){
|
||||
busFragment = ShuttleFragment()
|
||||
}
|
||||
BusLineModel.init();
|
||||
return busFragment!!
|
||||
}
|
||||
|
||||
override fun resetFragment() {
|
||||
busFragment = null
|
||||
BusLineModel.release()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.mogo.och.weaknet.bean
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.och.weaknet.database.bean.ContrailDataBean
|
||||
import com.mogo.och.weaknet.database.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.database.bean.SiteDataBean
|
||||
import com.mogo.och.weaknet.database.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.database.repository.ContraiRepository
|
||||
import com.mogo.och.weaknet.database.repository.LineRepository
|
||||
import com.mogo.och.weaknet.database.repository.SiteRepository
|
||||
import com.mogo.och.weaknet.database.repository.TaskRepository
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
data class CarExecutableTaskResponse(val data: List<Result>?) : BaseData(){
|
||||
|
||||
data class Result(
|
||||
var line: LineInfo?,
|
||||
var siteList: List<SiteInfo>?,//站点名称
|
||||
val contrail: ContrailInfo?,//站点名称
|
||||
val taskList: List<TaskInfo>?,//站点名称
|
||||
)
|
||||
|
||||
data class LineInfo(
|
||||
val lineId:Long?,
|
||||
var lineName:String?,
|
||||
) {
|
||||
fun toDbBean(): LineDataBean {
|
||||
val result = LineDataBean()
|
||||
result.lineId = lineId
|
||||
result.lineName = lineName
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
data class SiteInfo(
|
||||
val siteId:Long?,
|
||||
var name:String?,
|
||||
var seq:Int?,
|
||||
var gcjLon:Double?,
|
||||
var gcjLat:Double?,
|
||||
var lon:Double?,
|
||||
var lat:Double?,
|
||||
){
|
||||
companion object{
|
||||
fun toDbBeans(siteListInfo: List<SiteInfo>,lineId: Long?): List<SiteDataBean> {
|
||||
val reuslts = mutableListOf<SiteDataBean>()
|
||||
var tempSiteDataBean:SiteDataBean?=null
|
||||
siteListInfo.forEach {
|
||||
tempSiteDataBean = SiteDataBean()
|
||||
tempSiteDataBean?.lineId = lineId
|
||||
tempSiteDataBean?.siteId = it.siteId
|
||||
tempSiteDataBean?.name = it.name
|
||||
tempSiteDataBean?.seq = it.seq
|
||||
tempSiteDataBean?.gcjLon = it.gcjLon
|
||||
tempSiteDataBean?.gcjLat = it.gcjLat
|
||||
tempSiteDataBean?.lon = it.lon
|
||||
tempSiteDataBean?.lat = it.lat
|
||||
reuslts.add(tempSiteDataBean!!)
|
||||
}
|
||||
return reuslts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class ContrailInfo(
|
||||
val csvFileUrl:String?,
|
||||
val csvFileMd5:String?,
|
||||
val txtFileUrl:String?,
|
||||
val txtFileMd5:String?,
|
||||
val contrailSaveTime:Long?,
|
||||
) {
|
||||
fun toDbBean(lineId: Long?): ContrailDataBean {
|
||||
val result = ContrailDataBean()
|
||||
result.lineId = lineId
|
||||
result.csvFileUrl = csvFileUrl
|
||||
result.csvFileMd5 = csvFileMd5
|
||||
result.txtFileUrl = txtFileUrl
|
||||
result.txtFileMd5 = txtFileMd5
|
||||
result.contrailSaveTime = contrailSaveTime
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
data class TaskInfo(
|
||||
val id:Long?,
|
||||
val lineId:Long?,
|
||||
val taskDate:Long?,
|
||||
val taskStartTime:Long?,
|
||||
) {
|
||||
companion object {
|
||||
fun toDbBeans(taskInfs: List<TaskInfo>, lineId: Long?
|
||||
): List<TaskDataBean> {
|
||||
val reuslts = mutableListOf<TaskDataBean>()
|
||||
var tempTaskDataBean:TaskDataBean?=null
|
||||
taskInfs.forEach {
|
||||
tempTaskDataBean = TaskDataBean()
|
||||
tempTaskDataBean?.lineId = lineId
|
||||
tempTaskDataBean?.taskId = it.id
|
||||
tempTaskDataBean?.taskDate = it.taskDate
|
||||
tempTaskDataBean?.taskStartTime = it.taskStartTime
|
||||
reuslts.add(tempTaskDataBean!!)
|
||||
}
|
||||
return reuslts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object{
|
||||
fun save2Db(data: CarExecutableTaskResponse) {
|
||||
val lineList = mutableListOf<LineDataBean>()
|
||||
val contrailList = mutableListOf<ContrailDataBean>()
|
||||
val siteList = mutableListOf<SiteDataBean>()
|
||||
|
||||
data.data?.forEach { dataInfo->
|
||||
var lineId:Long?=null
|
||||
dataInfo.line?.let { lineInfo->
|
||||
lineId = lineInfo.lineId
|
||||
lineList.add(lineInfo.toDbBean())
|
||||
}
|
||||
dataInfo.contrail?.let { contrailInfo->
|
||||
contrailList.add(contrailInfo.toDbBean(lineId))
|
||||
}
|
||||
dataInfo.siteList?.let {siteListInfo->
|
||||
siteList.addAll(SiteInfo.toDbBeans(siteListInfo,lineId))
|
||||
}
|
||||
dataInfo.taskList?.let { taskInfs ->
|
||||
val taskList = TaskInfo.toDbBeans(taskInfs, lineId)
|
||||
TaskRepository.addOrUpdate(taskList,lineId)
|
||||
}
|
||||
}
|
||||
|
||||
LineRepository.checkAndUpdate(lineList)
|
||||
ContraiRepository.addOrUpdate(contrailList)
|
||||
SiteRepository.addOrUpdate(siteList)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.mogo.och.weaknet.database
|
||||
|
||||
import android.os.Environment
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.sqlite.db.SupportSQLiteOpenHelper
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.och.weaknet.database.bean.ContrailDataBean
|
||||
import com.mogo.och.weaknet.database.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.database.bean.SiteDataBean
|
||||
import com.mogo.och.weaknet.database.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.database.bean.TaskSiteDataBean
|
||||
import com.mogo.och.weaknet.database.dao.ContrailDataDao
|
||||
import com.mogo.och.weaknet.database.dao.LineDataDao
|
||||
import com.mogo.och.weaknet.database.dao.SiteDataDao
|
||||
import com.mogo.och.weaknet.database.dao.TaskDataDao
|
||||
import com.mogo.och.weaknet.database.dao.TaskSiteDataDao
|
||||
import java.io.File
|
||||
|
||||
//注解Database告诉系统这是Room数据库对象
|
||||
//entities指定该数据库有哪些表,多张表就逗号分隔
|
||||
//version指定数据库版本号,升级时需要用到
|
||||
//数据库继承自RoomDatabase
|
||||
@Database(entities = [ContrailDataBean::class, LineDataBean::class, SiteDataBean::class, TaskDataBean::class, TaskSiteDataBean::class], version = 1)
|
||||
abstract class MyDataBase : RoomDatabase() {
|
||||
|
||||
|
||||
|
||||
private object SingleTon {
|
||||
val instance: MyDataBase = Room.databaseBuilder(
|
||||
AbsMogoApplication.getApp()!!.applicationContext, MyDataBase::class.java, ROOT_PATH+DATABASE_NAME
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun getOpenHelper(): SupportSQLiteOpenHelper {
|
||||
return super.getOpenHelper()
|
||||
}
|
||||
|
||||
abstract val contrailDataDao: ContrailDataDao?
|
||||
abstract val lineDataDao: LineDataDao?
|
||||
abstract val siteDataDao: SiteDataDao?
|
||||
abstract val taskDataDao: TaskDataDao?
|
||||
abstract val taskSiteDataDao: TaskSiteDataDao?
|
||||
|
||||
companion object {
|
||||
private const val DATABASE_NAME = "shuttle_db"
|
||||
val ROOT_PATH =
|
||||
Environment.getExternalStorageDirectory().absolutePath + File.separator + "MLog" + File.separator + "APP_catch" + File.separator //程序外部存储跟目录
|
||||
|
||||
val instance: MyDataBase
|
||||
//结合单例模式完成数据库实例创建
|
||||
get() = SingleTon.instance
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mogo.och.weaknet.database.bean
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
/**
|
||||
* 启动自驾的信息
|
||||
*/
|
||||
@Entity(tableName = ContrailDataBean.ContrailDataTable)
|
||||
data class ContrailDataBean(
|
||||
|
||||
@PrimaryKey(autoGenerate = true) var id: Int = 0,
|
||||
|
||||
/**
|
||||
* 线路id
|
||||
*/
|
||||
@ColumnInfo(name = "line_id", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var lineId: Long? = null,
|
||||
|
||||
/**
|
||||
* csv格式的轨迹文件
|
||||
*/
|
||||
@ColumnInfo(name = "csv_file_url", typeAffinity = ColumnInfo.TEXT, index = true)
|
||||
var csvFileUrl: String? = null,
|
||||
|
||||
/**
|
||||
* csv_file_url 文件的md5值
|
||||
*/
|
||||
@ColumnInfo(name = "csv_file_md5", typeAffinity = ColumnInfo.TEXT, index = true)
|
||||
var csvFileMd5: String? = null,
|
||||
|
||||
/**
|
||||
* txt格式的轨迹文件
|
||||
*/
|
||||
@ColumnInfo(name = "txt_file_url", typeAffinity = ColumnInfo.TEXT, index = true)
|
||||
var txtFileUrl: String? = null,
|
||||
|
||||
/**
|
||||
* txt文件的md5
|
||||
*/
|
||||
@ColumnInfo(name = "txt_file_md5", typeAffinity = ColumnInfo.TEXT, index = true)
|
||||
var txtFileMd5: String? = null,
|
||||
|
||||
/**
|
||||
* 文件的保存时间
|
||||
*/
|
||||
@ColumnInfo(name = "contrail_save_time", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var contrailSaveTime: Long? = null,
|
||||
|
||||
/**
|
||||
* 前几个字符拼接后做md5的值
|
||||
*/
|
||||
@ColumnInfo(name = "md5", typeAffinity = ColumnInfo.TEXT, index = true)
|
||||
var md5: String? = null,
|
||||
|
||||
) {
|
||||
companion object {
|
||||
const val ContrailDataTable: String = "contrail_data_table"
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "ContrailDataBean(lineId=$lineId, csvFileUrl=$csvFileUrl, csvFileMd5=$csvFileMd5, txtFileUrl=$txtFileUrl, txtFileMd5=$txtFileMd5, contrailSaveTime=$contrailSaveTime)"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mogo.och.weaknet.database.bean
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = EventDataBean.evnetDataTable)
|
||||
data class EventDataBean(
|
||||
|
||||
@PrimaryKey(autoGenerate = true) var id: Int = 0,
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@ColumnInfo(name = "event_type", typeAffinity = ColumnInfo.TEXT)
|
||||
var eventType: String? = null,
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
@ColumnInfo(name = "task_id", typeAffinity = ColumnInfo.INTEGER)
|
||||
var taskId: Long? = null,
|
||||
|
||||
/**
|
||||
* 业务发生的时间
|
||||
*/
|
||||
@ColumnInfo(name = "business_time", typeAffinity = ColumnInfo.INTEGER)
|
||||
var businessTime: Long? = null,
|
||||
|
||||
/**
|
||||
* 数据版本
|
||||
*/
|
||||
@ColumnInfo(name = "write_version", typeAffinity = ColumnInfo.INTEGER)
|
||||
var writeVersion: Long? = null,
|
||||
|
||||
/**
|
||||
* 站点id
|
||||
*/
|
||||
@ColumnInfo(name = "site_id", typeAffinity = ColumnInfo.INTEGER)
|
||||
var siteId: Long? = null,
|
||||
|
||||
/**
|
||||
* 站点排序
|
||||
*/
|
||||
@ColumnInfo(name = "seq", typeAffinity = ColumnInfo.INTEGER)
|
||||
var seq: Int? = null,
|
||||
|
||||
/**
|
||||
* 存储此条数据时时间戳
|
||||
*/
|
||||
@ColumnInfo(name = "event_save_time", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
val eventSaveTime: Long = System.currentTimeMillis(),
|
||||
|
||||
) {
|
||||
companion object {
|
||||
const val evnetDataTable: String = "event_data_table"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mogo.och.weaknet.database.bean
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = LineDataBean.lineDataTable)
|
||||
data class LineDataBean(
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var id: Long = 0,
|
||||
|
||||
/**
|
||||
* 线路id
|
||||
*/
|
||||
@ColumnInfo(name = "line_id", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var lineId: Long? = null,
|
||||
|
||||
/**
|
||||
* 线路名称
|
||||
*/
|
||||
@ColumnInfo(name = "line_name", typeAffinity = ColumnInfo.TEXT)
|
||||
var lineName: String? = null,
|
||||
|
||||
/**
|
||||
* 存储此条数据时时间戳
|
||||
*/
|
||||
@ColumnInfo(name = "line_get_time", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
val linegetTime: Long = System.currentTimeMillis(),
|
||||
) {
|
||||
companion object {
|
||||
const val lineDataTable: String = "line_data_table"
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as LineDataBean
|
||||
|
||||
if (lineId != other.lineId) return false
|
||||
if (lineName != other.lineName) return false
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.mogo.och.weaknet.database.bean
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = SiteDataBean.siteDataTable)
|
||||
data class SiteDataBean(
|
||||
|
||||
@PrimaryKey(autoGenerate = true) var id: Int = 0,
|
||||
/**
|
||||
* 站点id
|
||||
*/
|
||||
@ColumnInfo(name = "site_id", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var siteId: Long? = null,
|
||||
|
||||
/**
|
||||
* 站点所属线路Id
|
||||
*/
|
||||
@ColumnInfo(name = "line_id", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var lineId: Long? = null,
|
||||
|
||||
/**
|
||||
* 站点名称
|
||||
*/
|
||||
@ColumnInfo(name = "name", typeAffinity = ColumnInfo.TEXT)
|
||||
var name: String? = null,
|
||||
|
||||
/**
|
||||
* 站点韩文名称
|
||||
*/
|
||||
@ColumnInfo(name = "name_kr", typeAffinity = ColumnInfo.TEXT)
|
||||
var nameKr: String? = null,
|
||||
|
||||
/**
|
||||
* 站点排序
|
||||
*/
|
||||
@ColumnInfo(name = "seq", typeAffinity = ColumnInfo.INTEGER)
|
||||
var seq: Int? = null,
|
||||
|
||||
/**
|
||||
* 高德坐标
|
||||
*/
|
||||
@ColumnInfo(name = "gcj_lon", typeAffinity = ColumnInfo.REAL)
|
||||
var gcjLon: Double? = null,
|
||||
|
||||
/**
|
||||
* 高德坐标
|
||||
*/
|
||||
@ColumnInfo(name = "gcj_lat", typeAffinity = ColumnInfo.REAL)
|
||||
var gcjLat: Double? = null,
|
||||
|
||||
/**
|
||||
* 高精坐标
|
||||
*/
|
||||
@ColumnInfo(name = "lon", typeAffinity = ColumnInfo.REAL)
|
||||
var lon: Double? = null,
|
||||
/**
|
||||
* 高精坐标
|
||||
*/
|
||||
@ColumnInfo(name = "lat", typeAffinity = ColumnInfo.REAL)
|
||||
var lat: Double? = null,
|
||||
|
||||
/**
|
||||
* 站点介绍
|
||||
*/
|
||||
@ColumnInfo(name = "introduction", typeAffinity = ColumnInfo.TEXT)
|
||||
var introduction: String? = null,
|
||||
|
||||
/**
|
||||
* 是否播放站点介绍
|
||||
*/
|
||||
@ColumnInfo(name = "is_play_tts", typeAffinity = ColumnInfo.INTEGER)
|
||||
var isPlayTts: Boolean? = false,
|
||||
|
||||
/**
|
||||
* 除id 外其他值做的md5
|
||||
*/
|
||||
@ColumnInfo(name = "md5", typeAffinity = ColumnInfo.TEXT)
|
||||
var md5: String? = null
|
||||
) {
|
||||
companion object {
|
||||
const val siteDataTable = "site_data_table"
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "SiteDataBean(siteId=$siteId, lineId=$lineId, name=$name, nameKr=$nameKr, seq=$seq, gcjLon=$gcjLon, gcjLat=$gcjLat, lon=$lon, lat=$lat, introduction=$introduction, isPlayTts=$isPlayTts)"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.mogo.och.weaknet.database.bean
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = TaskDataBean.taskDataTable)
|
||||
class TaskDataBean(
|
||||
|
||||
@PrimaryKey(autoGenerate = true) var id: Int = 0,
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
@ColumnInfo(name = "task_id", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var taskId: Long? = null,
|
||||
|
||||
/**
|
||||
* 任务所属线路
|
||||
*/
|
||||
@ColumnInfo(name = "line_id", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var lineId: Long? = null,
|
||||
|
||||
/**
|
||||
* 任务安排的时间
|
||||
*/
|
||||
@ColumnInfo(name = "task_data", typeAffinity = ColumnInfo.INTEGER)
|
||||
var taskDate: Long? = null,
|
||||
/**
|
||||
* 任务安排的时间
|
||||
*/
|
||||
@ColumnInfo(name = "task_start_time", typeAffinity = ColumnInfo.INTEGER)
|
||||
var taskStartTime: Long? = null,
|
||||
|
||||
/**
|
||||
* 任务开始时间
|
||||
*/
|
||||
@ColumnInfo(name = "start_time", typeAffinity = ColumnInfo.INTEGER)
|
||||
var startTime: Long? = null,
|
||||
|
||||
/**
|
||||
* 任务结束时间
|
||||
*/
|
||||
@ColumnInfo(name = "end_time", typeAffinity = ColumnInfo.INTEGER)
|
||||
var endtime: Long? = null,
|
||||
|
||||
/**
|
||||
* 任务保存到数据库的时间 用来第二天删除前几天的任务
|
||||
*/
|
||||
@ColumnInfo(name = "task_get_time", typeAffinity = ColumnInfo.INTEGER)
|
||||
var taskgetTime: Long = System.currentTimeMillis(),
|
||||
|
||||
/**
|
||||
* 任务状态 (0 未使用) (1 运行中) (2 已使用)
|
||||
*/
|
||||
@ColumnInfo(name = "status", typeAffinity = ColumnInfo.INTEGER)
|
||||
var status: Long? = 0,
|
||||
) {
|
||||
companion object {
|
||||
const val taskDataTable: String = "task_data_table"
|
||||
|
||||
const val unUse = 0L
|
||||
const val useing = 1L
|
||||
const val used = 2L
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package com.mogo.och.weaknet.database.bean
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = TaskSiteDataBean.usedTaskDataTable)
|
||||
data class TaskSiteDataBean(
|
||||
|
||||
@PrimaryKey(autoGenerate = true) var id: Int = 0,
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
@ColumnInfo(name = "task_id", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var taskId: Long? = null,
|
||||
|
||||
/**
|
||||
* 线路id
|
||||
*/
|
||||
@ColumnInfo(name = "line_id", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var lineId: Long? = null,
|
||||
|
||||
/**
|
||||
* 线路名称 删除线路 特殊情况下要展示线路的冗余
|
||||
*/
|
||||
@ColumnInfo(name = "line_name", typeAffinity = ColumnInfo.TEXT)
|
||||
var lineName: String? = null,
|
||||
|
||||
/**
|
||||
* 站点id
|
||||
*/
|
||||
@ColumnInfo(name = "site_id", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
var siteId: Long? = null,
|
||||
|
||||
/**
|
||||
* 站点名称
|
||||
*/
|
||||
@ColumnInfo(name = "name", typeAffinity = ColumnInfo.TEXT)
|
||||
var name: String? = null,
|
||||
|
||||
/**
|
||||
* 站点韩文
|
||||
*/
|
||||
@ColumnInfo(name = "name_kr", typeAffinity = ColumnInfo.TEXT)
|
||||
var nameKr: String? = null,
|
||||
|
||||
/**
|
||||
* 站点排序
|
||||
*/
|
||||
@ColumnInfo(name = "seq", typeAffinity = ColumnInfo.INTEGER)
|
||||
var seq: Int? = null,
|
||||
|
||||
/**
|
||||
* 高德坐标
|
||||
*/
|
||||
@ColumnInfo(name = "gcj_lon", typeAffinity = ColumnInfo.REAL)
|
||||
var gcjLon: Double? = null,
|
||||
|
||||
/**
|
||||
* 高德坐标
|
||||
*/
|
||||
@ColumnInfo(name = "gcj_lat", typeAffinity = ColumnInfo.REAL)
|
||||
var gcjLat: Double? = null,
|
||||
|
||||
/**
|
||||
* 高精坐标
|
||||
*/
|
||||
@ColumnInfo(name = "lon", typeAffinity = ColumnInfo.REAL)
|
||||
var lon: Double? = null,
|
||||
|
||||
/**
|
||||
* 高精坐标
|
||||
*/
|
||||
@ColumnInfo(name = "lat", typeAffinity = ColumnInfo.REAL)
|
||||
var lat: Double? = null,
|
||||
|
||||
/**
|
||||
* 当前站点状态 行驶信息,0初始值;1已经过;2当前站;3未到站
|
||||
*/
|
||||
@ColumnInfo(name = "driving_status", typeAffinity = ColumnInfo.INTEGER)
|
||||
var drivingStatus: Int? = null,
|
||||
|
||||
/**
|
||||
* 是否离站
|
||||
*/
|
||||
@ColumnInfo(name = "leaving", typeAffinity = ColumnInfo.INTEGER)
|
||||
var leaving: Boolean? = null,
|
||||
|
||||
/**
|
||||
* 到站时间
|
||||
*/
|
||||
@ColumnInfo(name = "arrived_time", typeAffinity = ColumnInfo.INTEGER)
|
||||
var arrivedTime: Long? = null,
|
||||
|
||||
/**
|
||||
* 离站时间
|
||||
*/
|
||||
@ColumnInfo(name = "leave_time", typeAffinity = ColumnInfo.INTEGER)
|
||||
var leaveTime: Long? = null,
|
||||
|
||||
/**
|
||||
* 站点介绍
|
||||
*/
|
||||
@ColumnInfo(name = "introduction", typeAffinity = ColumnInfo.TEXT)
|
||||
var introduction: String? = null,
|
||||
|
||||
/**
|
||||
* 是否播放站点介绍
|
||||
*/
|
||||
@ColumnInfo(name = "is_play_tts", typeAffinity = ColumnInfo.INTEGER)
|
||||
var isPlayTts: Boolean? = null,
|
||||
|
||||
) {
|
||||
companion object {
|
||||
/**
|
||||
* 开始任务 并把第一站置为 2 当前站
|
||||
*/
|
||||
fun toTaskSiteDatas(querySites: List<SiteDataBean>, taskId:Long, lineName: String): MutableList<TaskSiteDataBean> {
|
||||
val result = mutableListOf<TaskSiteDataBean>()
|
||||
var temp: TaskSiteDataBean?=null
|
||||
querySites.forEach {
|
||||
temp = TaskSiteDataBean()
|
||||
temp?.taskId = taskId
|
||||
temp?.lineId = it.lineId
|
||||
temp?.lineName = lineName
|
||||
temp?.siteId = it.siteId
|
||||
temp?.name = it.name
|
||||
temp?.nameKr = it.nameKr
|
||||
temp?.seq = it.seq
|
||||
temp?.gcjLon = it.gcjLon
|
||||
temp?.gcjLat = it.gcjLat
|
||||
temp?.lon = it.lon
|
||||
temp?.lat = it.lat
|
||||
if(it.seq==1){
|
||||
temp?.drivingStatus = 2
|
||||
}else{
|
||||
temp?.drivingStatus = 3
|
||||
}
|
||||
temp?.leaving = false
|
||||
temp?.introduction = it.introduction
|
||||
temp?.isPlayTts = it.isPlayTts
|
||||
result.add(temp!!)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
const val usedTaskDataTable: String = "used_task_data_table"
|
||||
|
||||
const val drivingStatusInit = 0//0初始值
|
||||
const val drivingStatusPassed = 1//1已经过
|
||||
const val drivingStatusCurrent = 2//2当前站
|
||||
const val drivingStatusNotArrived = 3//3未到站
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mogo.och.weaknet.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.mogo.och.weaknet.database.bean.ContrailDataBean
|
||||
|
||||
@Dao
|
||||
interface ContrailDataDao {
|
||||
|
||||
//插入轨迹信息
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(vararg contrailDataBean: ContrailDataBean)
|
||||
|
||||
// 线路删除时同步删除所属轨迹信息
|
||||
@Query("DELETE FROM ${ContrailDataBean.ContrailDataTable} WHERE line_id = :lineId")
|
||||
fun deleteByLineId(lineId: Long)
|
||||
|
||||
//查询线路对应的轨迹信息
|
||||
@Query("SELECT * FROM ${ContrailDataBean.ContrailDataTable} WHERE line_id = :lineId")
|
||||
fun queryContrailByLineId(lineId:Long): List<ContrailDataBean>?
|
||||
|
||||
//查询线路对应的轨迹信息
|
||||
@Query("SELECT * FROM ${ContrailDataBean.ContrailDataTable} WHERE md5 = :md5")
|
||||
fun queryContrailByMd5(md5:String): List<ContrailDataBean>?
|
||||
|
||||
//查询线路对应的轨迹信息 只要一个结果
|
||||
fun queryContrailByLineIdOne(lineId: Long): ContrailDataBean?{
|
||||
val queryContrailByLineId = queryContrailByLineId(lineId)
|
||||
return if(queryContrailByLineId.isNullOrEmpty()){
|
||||
null
|
||||
}else{
|
||||
queryContrailByLineId.first()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mogo.och.weaknet.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.weaknet.database.bean.EventDataBean
|
||||
import com.mogo.och.weaknet.database.bean.LineDataBean
|
||||
|
||||
@Dao
|
||||
interface EventDataDao {
|
||||
|
||||
//插入数据
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(vararg lineDataBean: EventDataBean)
|
||||
|
||||
//删除数据
|
||||
@Delete
|
||||
fun delete(vararg lineDataBean: EventDataBean)
|
||||
|
||||
//删除非昨天添加的数据
|
||||
@Query("DELETE FROM ${EventDataBean.evnetDataTable} WHERE event_save_time < :zeroTime")
|
||||
fun deleteWeltData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Int
|
||||
|
||||
//查询当天插入的所有数据
|
||||
@Query("SELECT * FROM ${EventDataBean.evnetDataTable} WHERE event_save_time > :zeroTime")
|
||||
fun loadData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): List<LineDataBean>?
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.mogo.och.weaknet.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.weaknet.database.bean.LineDataBean
|
||||
|
||||
@Dao
|
||||
interface LineDataDao {
|
||||
//插入数据
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(vararg lineDataBean: LineDataBean)
|
||||
|
||||
//删除数据
|
||||
@Delete
|
||||
fun delete(vararg lineDataBean: LineDataBean)
|
||||
|
||||
//删除非昨天添加的数据
|
||||
@Query("DELETE FROM ${LineDataBean.lineDataTable} WHERE line_get_time < :zeroTime")
|
||||
fun deleteWeltData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Int
|
||||
|
||||
//查询当天插入的所有数据
|
||||
@Query("SELECT * FROM ${LineDataBean.lineDataTable} WHERE line_get_time > :zeroTime")
|
||||
fun loadData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): List<LineDataBean>?
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mogo.och.weaknet.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.mogo.och.weaknet.database.bean.SiteDataBean
|
||||
|
||||
@Dao
|
||||
interface SiteDataDao {
|
||||
//插入数据
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(vararg lineDataBean: SiteDataBean)
|
||||
|
||||
// 线路删除时同步删除所属站点
|
||||
@Query("DELETE FROM ${SiteDataBean.siteDataTable} WHERE line_id = :lineId")
|
||||
fun deleteByLineId(lineId: Long)
|
||||
|
||||
//查询线路对应的轨迹信息
|
||||
@Query("SELECT * FROM ${SiteDataBean.siteDataTable} WHERE md5 = :md5")
|
||||
fun querySitesByMd5(md5:String): List<SiteDataBean>?
|
||||
|
||||
@Query("SELECT * FROM ${SiteDataBean.siteDataTable} WHERE line_id = :lineId and site_id = :siteId")
|
||||
fun querySitesByLineIdAndSiteId(lineId: Long,siteId:Long):List<SiteDataBean>?
|
||||
|
||||
@Query("SELECT * FROM ${SiteDataBean.siteDataTable} WHERE line_id = :lineId")
|
||||
fun querySitesByLineId(lineId: Long):List<SiteDataBean>?
|
||||
|
||||
fun querySiteByLineIdAndSiteId(lineId: Long,siteId:Long): SiteDataBean?{
|
||||
val queryContrailByLineId = querySitesByLineIdAndSiteId(lineId,siteId)
|
||||
return if(queryContrailByLineId.isNullOrEmpty()){
|
||||
null
|
||||
}else{
|
||||
queryContrailByLineId.first()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.mogo.och.weaknet.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.weaknet.database.bean.TaskDataBean
|
||||
|
||||
@Dao
|
||||
interface TaskDataDao {
|
||||
//插入数据
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(vararg lineDataBean: TaskDataBean)
|
||||
|
||||
//删除数据
|
||||
@Delete
|
||||
fun delete(vararg lineDataBean: TaskDataBean)
|
||||
|
||||
//删除非昨天添加的数据
|
||||
@Query("DELETE FROM ${TaskDataBean.taskDataTable} WHERE task_get_time < :zeroTime")
|
||||
fun deleteDataByZero(zeroTime:Long): Int
|
||||
|
||||
//查询当天插入的所有数据
|
||||
@Query("SELECT * FROM ${TaskDataBean.taskDataTable} WHERE task_get_time > :zeroTime")
|
||||
fun loadAllData(zeroTime:Long): List<TaskDataBean>?
|
||||
|
||||
// 查询当天特定线路正在执行的任务
|
||||
@Query("SELECT * FROM ${TaskDataBean.taskDataTable} WHERE task_get_time > :zeroTime and status = ${TaskDataBean.useing} and line_id = :lineId")
|
||||
fun queryRunningTastByLineId(lineId: Long,zeroTime:Long = DateTimeUtil.getCurrentDateZero()): List<TaskDataBean>?
|
||||
|
||||
@Query("SELECT * FROM ${TaskDataBean.taskDataTable} WHERE task_get_time > :zeroTime and status = ${TaskDataBean.unUse} and line_id = :lineId")
|
||||
fun queryUnuseTask(lineId: Long,zeroTime:Long = DateTimeUtil.getCurrentDateZero()): List<TaskDataBean>?
|
||||
|
||||
@Query("DELETE FROM ${TaskDataBean.taskDataTable} WHERE task_get_time > :zeroTime and line_id = :lineId")
|
||||
fun deleteByLineId(lineId: Long,zeroTime:Long = DateTimeUtil.getCurrentDateZero())
|
||||
|
||||
@Query("SELECT * FROM ${TaskDataBean.taskDataTable} WHERE line_id = :lineId and task_get_time > :zeroTime")
|
||||
fun querySitesByLineId(lineId: Long?,zeroTime:Long = DateTimeUtil.getCurrentDateZero()):List<TaskDataBean>?
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.och.weaknet.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import com.mogo.och.weaknet.database.bean.TaskSiteDataBean
|
||||
|
||||
@Dao
|
||||
interface TaskSiteDataDao {
|
||||
//插入数据
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(vararg lineDataBean: TaskSiteDataBean)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mogo.och.weaknet.database.exception
|
||||
|
||||
class DataException: RuntimeException {
|
||||
constructor() : super()
|
||||
constructor(message: String?) : super(message)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mogo.och.weaknet.database.repository
|
||||
|
||||
import com.mogo.eagle.core.network.utils.digest.DigestUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.och.weaknet.database.MyDataBase
|
||||
import com.mogo.och.weaknet.database.bean.ContrailDataBean
|
||||
import com.mogo.och.weaknet.database.dao.ContrailDataDao
|
||||
|
||||
object ContraiRepository {
|
||||
|
||||
private var contrailDao: ContrailDataDao?=null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
contrailDao = MyDataBase.instance.contrailDataDao
|
||||
}
|
||||
}
|
||||
|
||||
fun addOrUpdate(contrailDatalist:List<ContrailDataBean>){
|
||||
// 校验数据个数
|
||||
contrailDao?.let { contrailDao->
|
||||
contrailDatalist.forEach {
|
||||
val md5Source = it.toString()
|
||||
val md5Hex = DigestUtils.md5Hex(md5Source)
|
||||
val queryContrailByMd5 = contrailDao.queryContrailByMd5(md5Hex)
|
||||
if(queryContrailByMd5.isNullOrEmpty()){// 没有值或者值有变化
|
||||
val needUpdate = contrailDao.queryContrailByLineIdOne(it.lineId!!)
|
||||
it.md5 = md5Hex
|
||||
if(needUpdate!=null){
|
||||
it.id = needUpdate.id
|
||||
}
|
||||
contrailDao.insert(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteByLineId(lineId: Long) {
|
||||
contrailDao?.deleteByLineId(lineId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mogo.och.weaknet.database.repository
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.och.weaknet.database.MyDataBase
|
||||
import com.mogo.och.weaknet.database.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.database.dao.LineDataDao
|
||||
|
||||
object LineRepository {
|
||||
|
||||
private var lineDao: LineDataDao?=null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
lineDao = MyDataBase.instance.lineDataDao
|
||||
}
|
||||
}
|
||||
|
||||
fun cleanWeltData(){
|
||||
lineDao?.deleteWeltData()
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取可用线路
|
||||
*/
|
||||
fun queryCanUseLine(): List<LineDataBean>? {
|
||||
return lineDao?.loadData()
|
||||
}
|
||||
|
||||
fun checkAndUpdate(serverDatalist:List<LineDataBean>){
|
||||
// 校验数据个数
|
||||
lineDao?.let { lineDao->
|
||||
val loadData = lineDao.loadData()
|
||||
if(loadData.isNullOrEmpty()){
|
||||
lineDao.insert(*serverDatalist.toTypedArray())
|
||||
// TODO: Ui展示需要动态刷新UI去
|
||||
return
|
||||
}
|
||||
// 后台新增数据
|
||||
val needAddDatas = serverDatalist-loadData
|
||||
// 后台没有本地数据库有的未分配线路
|
||||
val needMinusDatas = loadData-serverDatalist
|
||||
|
||||
// TODO: Ui展示需要动态刷新UI去
|
||||
|
||||
if (needAddDatas.isNotEmpty()) {
|
||||
// 新增线路
|
||||
lineDao.insert(*needAddDatas.toTypedArray())
|
||||
}
|
||||
if (needMinusDatas.isNotEmpty()) {
|
||||
// 删除线路
|
||||
lineDao.delete(*needMinusDatas.toTypedArray())
|
||||
needMinusDatas.forEach { minusLine->
|
||||
minusLine.lineId?.let { lineId->
|
||||
// 删除线路对应的站点
|
||||
|
||||
SiteRepository.deleteByLineId(lineId)
|
||||
val runingTask = TaskRepository.queryRunningTastByLineId(lineId)
|
||||
if(runingTask.isNullOrEmpty()){
|
||||
// 删除线路对应的自驾信息
|
||||
|
||||
ContraiRepository.deleteByLineId(lineId)
|
||||
|
||||
TaskRepository.deleteByLineId(lineId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mogo.och.weaknet.database.repository
|
||||
|
||||
import com.mogo.eagle.core.network.utils.digest.DigestUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.och.weaknet.database.MyDataBase
|
||||
import com.mogo.och.weaknet.database.bean.SiteDataBean
|
||||
import com.mogo.och.weaknet.database.dao.SiteDataDao
|
||||
|
||||
object SiteRepository {
|
||||
|
||||
private var siteDataDao: SiteDataDao? = null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
siteDataDao = MyDataBase.instance.siteDataDao
|
||||
}
|
||||
}
|
||||
|
||||
fun addOrUpdate(siteDateList: List<SiteDataBean>) {
|
||||
siteDataDao?.let { siteDataDao ->
|
||||
siteDateList.forEach {
|
||||
val md5Source = it.toString()
|
||||
val md5Hex = DigestUtils.md5Hex(md5Source)
|
||||
val queryContrailByMd5 = siteDataDao.querySitesByMd5(md5Hex)
|
||||
if (queryContrailByMd5.isNullOrEmpty()) {// 没有值或者值有变化
|
||||
val needUpdate =
|
||||
siteDataDao.querySiteByLineIdAndSiteId(it.lineId!!, it.siteId!!)
|
||||
it.md5 = md5Hex
|
||||
if (needUpdate != null) {
|
||||
it.id = needUpdate.id
|
||||
}
|
||||
siteDataDao.insert(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteByLineId(lineId: Long) {
|
||||
siteDataDao?.deleteByLineId(lineId)
|
||||
}
|
||||
|
||||
fun querySiteByLineId(lineId:Long):List<SiteDataBean>?{
|
||||
siteDataDao?.let { siteDataDao->
|
||||
return siteDataDao.querySitesByLineId(lineId)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.mogo.och.weaknet.database.repository
|
||||
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.och.weaknet.database.MyDataBase
|
||||
import com.mogo.och.weaknet.database.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.database.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.database.dao.TaskDataDao
|
||||
import com.mogo.och.weaknet.database.exception.DataException
|
||||
|
||||
object TaskRepository {
|
||||
|
||||
private var taskDataDao: TaskDataDao? = null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
taskDataDao = MyDataBase.instance.taskDataDao
|
||||
}
|
||||
}
|
||||
|
||||
fun addOrUpdate(serverDateList: List<TaskDataBean>, lineId: Long?) {
|
||||
taskDataDao?.let { taskDataDao ->
|
||||
val localTasks = taskDataDao.querySitesByLineId(lineId)
|
||||
if(localTasks==null){
|
||||
taskDataDao.insert(*serverDateList.toTypedArray())
|
||||
// TODO: Ui展示需要动态刷新UI去
|
||||
return
|
||||
}
|
||||
|
||||
// 后台新增数据
|
||||
val needAddDatas = serverDateList - localTasks
|
||||
// 后台没有本地数据库有的未分配线路
|
||||
val needMinusDatas = localTasks - serverDateList
|
||||
|
||||
// TODO: Ui展示需要动态刷新UI去
|
||||
|
||||
if (needAddDatas.isNotEmpty()) {
|
||||
// 新增任务
|
||||
taskDataDao.insert(*needAddDatas.toTypedArray())
|
||||
}
|
||||
if (needMinusDatas.isNotEmpty()) {
|
||||
// 删除任务
|
||||
taskDataDao.delete(*needMinusDatas.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取线路可用的任务
|
||||
*/
|
||||
fun queryCanUserTask(lineId:Long):List<TaskDataBean>?{
|
||||
taskDataDao?.let { taskDataDao->
|
||||
// 查询当天未使用的任务
|
||||
val unUseTaskS = taskDataDao.queryUnuseTask(lineId)
|
||||
// 过滤调任务时间和当前时间相差10分钟的任务
|
||||
return unUseTaskS?.filter { (System.currentTimeMillis()-it.taskStartTime!!)<10*60*1000 }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun startTask(lineDataBean: LineDataBean, taskDataBean: TaskDataBean){
|
||||
taskDataBean.startTime = System.currentTimeMillis()
|
||||
taskDataBean.status = TaskDataBean.useing
|
||||
try {
|
||||
MyDataBase.instance.runInTransaction {
|
||||
// 更新任务状态
|
||||
taskDataDao?.insert(taskDataBean)
|
||||
TaskSiteRepository.startTask(lineDataBean, taskDataBean)
|
||||
}
|
||||
}catch (e:Exception){
|
||||
if(e is DataException){
|
||||
println("数据不全")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun queryRunningTastByLineId(lineId: Long): List<TaskDataBean>? {
|
||||
return taskDataDao?.queryRunningTastByLineId(lineId)
|
||||
}
|
||||
|
||||
fun deleteByLineId(lineId: Long) {
|
||||
taskDataDao?.deleteByLineId(lineId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mogo.och.weaknet.database.repository
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.och.weaknet.database.MyDataBase
|
||||
import com.mogo.och.weaknet.database.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.database.bean.TaskDataBean
|
||||
import com.mogo.och.weaknet.database.bean.TaskSiteDataBean
|
||||
import com.mogo.och.weaknet.database.dao.TaskSiteDataDao
|
||||
import com.mogo.och.weaknet.database.exception.DataException
|
||||
|
||||
object TaskSiteRepository {
|
||||
|
||||
private var taskSiteDataDao: TaskSiteDataDao? = null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
taskSiteDataDao = MyDataBase.instance.taskSiteDataDao
|
||||
}
|
||||
}
|
||||
|
||||
// 开始线路
|
||||
fun startTask(lineDataBean: LineDataBean, taskDataBean: TaskDataBean) {
|
||||
// 获取线路的站点
|
||||
val querySites = SiteRepository.querySiteByLineId(lineDataBean.lineId!!)
|
||||
if(querySites.isNullOrEmpty()){
|
||||
throw DataException("没有站点数据")
|
||||
}
|
||||
val toTaskSiteDatas = TaskSiteDataBean.toTaskSiteDatas(
|
||||
querySites,
|
||||
taskDataBean.taskId!!,
|
||||
lineDataBean.lineName!!
|
||||
)
|
||||
// 把线路所有的站点搬迁到运行中表格中
|
||||
taskSiteDataDao?.insert(*toTaskSiteDatas.toTypedArray())
|
||||
}
|
||||
|
||||
//
|
||||
fun leaveStation(){
|
||||
|
||||
}
|
||||
|
||||
fun arriveSiteStation(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +1,116 @@
|
||||
package com.mogo.och.weaknet.model;
|
||||
package com.mogo.och.weaknet.model
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse;
|
||||
import com.mogo.och.weaknet.bean.BusQueryLinesResponse;
|
||||
import com.mogo.och.weaknet.bean.BusRoutesResponse;
|
||||
import com.mogo.och.weaknet.callback.IBusLinesCallback;
|
||||
import com.mogo.och.weaknet.net.OrderServiceManager;
|
||||
import com.mogo.och.weaknet.ui.BusSwitchLineActivity;
|
||||
import com.mogo.och.shuttle.weaknet.R;
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.network.utils.digest.DigestUtils
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||
import com.mogo.och.common.module.manager.loop.LoopInfo
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
import com.mogo.och.shuttle.weaknet.R
|
||||
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse
|
||||
import com.mogo.och.weaknet.bean.BusQueryLinesResponse
|
||||
import com.mogo.och.weaknet.bean.BusRoutesResponse
|
||||
import com.mogo.och.weaknet.bean.CarExecutableTaskResponse
|
||||
import com.mogo.och.weaknet.callback.IBusLinesCallback
|
||||
import com.mogo.och.weaknet.database.repository.LineRepository
|
||||
import com.mogo.och.weaknet.net.OrderServiceManager
|
||||
import com.mogo.och.weaknet.net.OrderServiceManager.queryBusLines
|
||||
import com.mogo.och.weaknet.net.OrderServiceManager.queryBusTaskByLineId
|
||||
import com.mogo.och.weaknet.net.OrderServiceManager.switchLine
|
||||
import com.mogo.och.weaknet.ui.BusSwitchLineActivity
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/2/9
|
||||
*/
|
||||
public class BusLineModel {
|
||||
private static volatile BusLineModel sInstance;
|
||||
private Context mContext;
|
||||
private IBusLinesCallback mBusLinesCallback;
|
||||
public static BusLineModel getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( BusLineModel.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new BusLineModel();
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object BusLineModel {
|
||||
private var mContext: Context? = null
|
||||
private var mBusLinesCallback: IBusLinesCallback? = null
|
||||
private const val TAG = "BusLineModel"
|
||||
private const val LoopCarInfo = "LoopCarInfo"
|
||||
private const val executableChangeMd5 = "EXECUTABLECHANGEMD5"
|
||||
|
||||
@JvmStatic
|
||||
fun init() {
|
||||
mContext = AbsMogoApplication.getApp()
|
||||
BizLoopManager.setLoopFunction("${TAG}_${LoopCarInfo}", LoopInfo(60, ::queryCarExecutableTaskList))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun release(){
|
||||
mContext = null
|
||||
mBusLinesCallback = null
|
||||
BizLoopManager.removeLoopFunction("${TAG}_${LoopCarInfo}")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setBusLinesCallback(callback: IBusLinesCallback?) {
|
||||
mBusLinesCallback = callback
|
||||
}
|
||||
|
||||
private fun queryCarExecutableTaskList(){
|
||||
mContext?.let {
|
||||
OrderServiceManager.queryCarExecutableTaskList(it, object : OchCommonServiceCallback<CarExecutableTaskResponse> {
|
||||
override fun onSuccess(data: CarExecutableTaskResponse) {
|
||||
// 第一次过滤 请求返回值的md5
|
||||
val currentRequest = DigestUtils.md5Hex(data.data.toString())
|
||||
val lastChangeMd5 = SharedPrefsMgr.getInstance().getString(executableChangeMd5)
|
||||
if(currentRequest==lastChangeMd5){
|
||||
return
|
||||
}
|
||||
SharedPrefsMgr.getInstance().putString(executableChangeMd5,currentRequest)
|
||||
OchChainLogManager.writeChainLog("数据发生变化","接口信息发生变化 ${lastChangeMd5} new md5${currentRequest}")
|
||||
CarExecutableTaskResponse.save2Db(data)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, failMsg: String) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
private BusLineModel() {
|
||||
|
||||
}
|
||||
public void init() {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
}
|
||||
public void setBusLinesCallback(IBusLinesCallback callback){
|
||||
mBusLinesCallback = callback;
|
||||
}
|
||||
public void queryBusLines(){
|
||||
OrderServiceManager.queryBusLines(mContext, new OchCommonServiceCallback<BusQueryLinesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusQueryLinesResponse data) {
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusLines() {
|
||||
queryBusLines(mContext!!, object : OchCommonServiceCallback<BusQueryLinesResponse> {
|
||||
override fun onSuccess(data: BusQueryLinesResponse) {
|
||||
if (null == data && mBusLinesCallback != null) {
|
||||
mBusLinesCallback.onBusLinesChange(null);
|
||||
return;
|
||||
mBusLinesCallback!!.onBusLinesChange(null)
|
||||
return
|
||||
}
|
||||
|
||||
if (mBusLinesCallback != null){
|
||||
mBusLinesCallback.onBusLinesChange(data);
|
||||
if (mBusLinesCallback != null) {
|
||||
mBusLinesCallback!!.onBusLinesChange(data)
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
override fun onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.network_error_tip))
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.request_error_tip))
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
override fun onFail(code: Int, failMsg: String) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
ToastUtils.showShort("查询所有绑定路线失败:"+failMsg);
|
||||
ToastUtils.showShort("网络异常,请稍后重试")
|
||||
} else {
|
||||
ToastUtils.showShort("查询所有绑定路线失败:$failMsg")
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,68 +118,65 @@ public class BusLineModel {
|
||||
* @param lineId 线路ID
|
||||
* @param position 位置
|
||||
*/
|
||||
public void queryBusLineTasksById(int lineId, int position,boolean autoRefresh){
|
||||
OrderServiceManager.queryBusTaskByLineId(mContext, String.valueOf(lineId),new OchCommonServiceCallback<BusQueryLineTaskResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusQueryLineTaskResponse data) {
|
||||
if (null == data && mBusLinesCallback != null) {
|
||||
mBusLinesCallback.onBusLineTasks(null,position,autoRefresh);
|
||||
return;
|
||||
@JvmStatic
|
||||
fun queryBusLineTasksById(lineId: Int, position: Int, autoRefresh: Boolean) {
|
||||
queryBusTaskByLineId(
|
||||
mContext!!,
|
||||
lineId.toString(),
|
||||
object : OchCommonServiceCallback<BusQueryLineTaskResponse> {
|
||||
override fun onSuccess(data: BusQueryLineTaskResponse) {
|
||||
if (null == data && mBusLinesCallback != null) {
|
||||
mBusLinesCallback!!.onBusLineTasks(null, position, autoRefresh)
|
||||
return
|
||||
}
|
||||
|
||||
if (mBusLinesCallback != null) {
|
||||
mBusLinesCallback!!.onBusLineTasks(data, position, autoRefresh)
|
||||
}
|
||||
}
|
||||
|
||||
if (mBusLinesCallback != null){
|
||||
mBusLinesCallback.onBusLineTasks(data,position,autoRefresh);
|
||||
override fun onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.network_error_tip))
|
||||
} else {
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.request_error_tip))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
override fun onFail(code: Int, failMsg: String) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试")
|
||||
} else {
|
||||
ToastUtils.showShort("查询所有绑定路线失败:$failMsg")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
ToastUtils.showShort("查询所有绑定路线失败:"+failMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
public void commitSwitchLineId(int taskId,int lineId){
|
||||
OrderServiceManager.switchLine(mContext,taskId, new OchCommonServiceCallback<BusRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusRoutesResponse o) {
|
||||
SharedPrefsMgr.getInstance().putInt(BusSwitchLineActivity.LASTCOMMITLINEID,lineId);
|
||||
if (mBusLinesCallback != null){
|
||||
mBusLinesCallback.onChangeLineIdSuccess();
|
||||
@JvmStatic
|
||||
fun commitSwitchLineId(taskId: Int, lineId: Int) {
|
||||
switchLine(mContext!!, taskId, object : OchCommonServiceCallback<BusRoutesResponse> {
|
||||
override fun onSuccess(o: BusRoutesResponse) {
|
||||
SharedPrefsMgr.getInstance().putInt(BusSwitchLineActivity.LASTCOMMITLINEID, lineId)
|
||||
if (mBusLinesCallback != null) {
|
||||
mBusLinesCallback!!.onChangeLineIdSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
override fun onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.network_error_tip))
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.request_error_tip))
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
override fun onFail(code: Int, failMsg: String) {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
ToastUtils.showShort("选择任务失败:"+failMsg);
|
||||
ToastUtils.showShort("网络异常,请稍后重试")
|
||||
} else {
|
||||
ToastUtils.showShort("选择任务失败:$failMsg")
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.mogo.och.weaknet.bean.BusQueryLinesResponse;
|
||||
import com.mogo.och.weaknet.bean.BusResetDrivingLineRequest;
|
||||
import com.mogo.och.weaknet.bean.BusRoutesResponse;
|
||||
import com.mogo.och.weaknet.bean.BusUpdateSiteStatusRequest;
|
||||
import com.mogo.och.weaknet.bean.CarExecutableTaskResponse;
|
||||
import com.mogo.och.weaknet.bean.WriteOffCountResponse;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@@ -109,5 +110,9 @@ public interface IBascApiService {
|
||||
@GET("och-shuttle-cabin/api/business/v1/task/writeOffCount")
|
||||
Observable<WriteOffCountResponse> writeOffCount(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("taskId") String taskId, @Query("siteId") String siteId);
|
||||
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
@GET("/och-vehicle/cabin/queryCarExecutableTaskList")
|
||||
Observable<CarExecutableTaskResponse> queryCarExecutableTaskList(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.mogo.och.weaknet.bean.BusQueryLinesResponse
|
||||
import com.mogo.och.weaknet.bean.BusResetDrivingLineRequest
|
||||
import com.mogo.och.weaknet.bean.BusRoutesResponse
|
||||
import com.mogo.och.weaknet.bean.BusUpdateSiteStatusRequest
|
||||
import com.mogo.och.weaknet.bean.CarExecutableTaskResponse
|
||||
import com.mogo.och.weaknet.bean.WriteOffCountResponse
|
||||
|
||||
/**
|
||||
@@ -189,4 +190,18 @@ object OrderServiceManager {
|
||||
.transformIoTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "writeOffCount"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryCarExecutableTaskList(
|
||||
context: Context,
|
||||
callback: OchCommonServiceCallback<CarExecutableTaskResponse>?
|
||||
) {
|
||||
mService.queryCarExecutableTaskList(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
SharedPrefsMgr.getInstance().sn,
|
||||
)
|
||||
.transformIoTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryCarExecutableTaskList"))
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
|
||||
public BusLinePresenter(BusSwitchLineView view) {
|
||||
super(view);
|
||||
BusLineModel.getInstance().init();
|
||||
BusLineModel.init();
|
||||
OrderModel.getInstance().init();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
}
|
||||
|
||||
private void initListener() {
|
||||
BusLineModel.getInstance().setBusLinesCallback(this);
|
||||
BusLineModel.setBusLinesCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +67,7 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
}
|
||||
|
||||
public void queryBusLines(){
|
||||
BusLineModel.getInstance().queryBusLines();
|
||||
BusLineModel.queryBusLines();
|
||||
}
|
||||
|
||||
public void queryBusLineTasks(int lineId, int position,boolean close){
|
||||
@@ -77,18 +77,18 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
if(close){
|
||||
return;
|
||||
}
|
||||
BusLineModel.getInstance().queryBusLineTasksById(lineId,position,false);
|
||||
BusLineModel.queryBusLineTasksById(lineId,position,false);
|
||||
subscribe = Observable.interval(3, TimeUnit.MINUTES).subscribe(aLong -> {
|
||||
BusLineModel.getInstance().queryBusLineTasksById(lineId,position,true);
|
||||
BusLineModel.queryBusLineTasksById(lineId,position,true);
|
||||
});
|
||||
}
|
||||
|
||||
public void commitSwitchLineId(int taskId,int lineId){
|
||||
BusLineModel.getInstance().commitSwitchLineId(taskId,lineId);
|
||||
BusLineModel.commitSwitchLineId(taskId,lineId);
|
||||
}
|
||||
|
||||
public void removeListener(){
|
||||
BusLineModel.getInstance().setBusLinesCallback(null);
|
||||
BusLineModel.setBusLinesCallback(null);
|
||||
}
|
||||
|
||||
public void queryBusRoutes(){
|
||||
|
||||
Reference in New Issue
Block a user