[6.6.0]
[线路、任务、自驾信息、站点保存到数据库]
This commit is contained in:
@@ -19,7 +19,7 @@ object ResourcesUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun getString(@StringRes id: Int, vararg formatArgs:String): String {
|
||||
return AbsMogoApplication.getApp().getString(id,formatArgs)
|
||||
return AbsMogoApplication.getApp().getString(id,*formatArgs)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "09d7e5149c9755201cd38ff92f3b3d85",
|
||||
"identityHash": "58751308e081c3bc5fd17ee6efb92778",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "contrail_data_table",
|
||||
@@ -73,51 +73,6 @@
|
||||
"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,
|
||||
@@ -132,7 +87,7 @@
|
||||
},
|
||||
{
|
||||
"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)",
|
||||
"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",
|
||||
@@ -152,6 +107,12 @@
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "endStationName",
|
||||
"columnName": "end_station_name",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "linegetTime",
|
||||
"columnName": "line_get_time",
|
||||
@@ -174,15 +135,6 @@
|
||||
],
|
||||
"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": []
|
||||
@@ -387,7 +339,7 @@
|
||||
},
|
||||
{
|
||||
"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)",
|
||||
"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)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
@@ -407,18 +359,18 @@
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "lineName",
|
||||
"columnName": "line_name",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "siteId",
|
||||
"columnName": "site_id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "lineName",
|
||||
"columnName": "line_name",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "name",
|
||||
"columnName": "name",
|
||||
@@ -534,12 +486,84 @@
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "event_data_table",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `task_id` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `event_save_time` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "eventType",
|
||||
"columnName": "event_type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "taskId",
|
||||
"columnName": "task_id",
|
||||
"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": "eventSaveTime",
|
||||
"columnName": "event_save_time",
|
||||
"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": []
|
||||
}
|
||||
],
|
||||
"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')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '58751308e081c3bc5fd17ee6efb92778')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,16 @@ package com.mogo.och.weaknet.bean;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.och.data.bean.BusRoutesResult;
|
||||
import com.mogo.och.data.bean.BusStationBean;
|
||||
import com.mogo.och.weaknet.database.bean.ContrailDataBean;
|
||||
import com.mogo.och.weaknet.database.bean.SiteDataBean;
|
||||
import com.mogo.och.weaknet.database.repository.ContraiRepository;
|
||||
import com.mogo.och.weaknet.database.repository.SiteRepository;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 网约车小巴路线接口请求响应结果
|
||||
@@ -25,4 +35,38 @@ public class BusRoutesResponse extends BaseData {
|
||||
"data=" + data +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static void save2Db(@NotNull BusRoutesResponse data) {
|
||||
List<SiteDataBean> result = new ArrayList<>();
|
||||
SiteDataBean temp = null;
|
||||
if (data != null && data.data != null) {
|
||||
for (BusStationBean site : data.data.getSites()) {
|
||||
temp = new SiteDataBean();
|
||||
temp.setSiteId((long) site.getSiteId());
|
||||
temp.setLineId((long) (data.data.getLineId()));
|
||||
temp.setPlayTts(site.isPlayTts());
|
||||
temp.setGcjLat(site.getGcjLat());
|
||||
temp.setGcjLon(site.getGcjLon());
|
||||
temp.setLat(site.getLat());
|
||||
temp.setLon(site.getLon());
|
||||
temp.setName(site.getName());
|
||||
temp.setNameKr(site.getNameKr());
|
||||
temp.setSeq(site.getSeq());
|
||||
temp.setIntroduction(site.getIntroduction());
|
||||
result.add(temp);
|
||||
}
|
||||
SiteRepository.INSTANCE.addOrUpdate(result);
|
||||
|
||||
List<ContrailDataBean> resultContrailDataBean = new ArrayList<>();
|
||||
ContrailDataBean tempContrailDataBean = new ContrailDataBean();
|
||||
tempContrailDataBean.setContrailSaveTime(data.data.contrailSaveTime);
|
||||
tempContrailDataBean.setLineId((long) data.data.getLineId());
|
||||
tempContrailDataBean.setCsvFileMd5(data.data.csvFileMd5);
|
||||
tempContrailDataBean.setCsvFileUrl(data.data.csvFileUrl);
|
||||
tempContrailDataBean.setTxtFileUrl(data.data.txtFileUrl);
|
||||
tempContrailDataBean.setTxtFileMd5(data.data.txtFileMd5);
|
||||
resultContrailDataBean.add(tempContrailDataBean);
|
||||
ContraiRepository.INSTANCE.addOrUpdate(resultContrailDataBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,11 @@ data class CarExecutableTaskResponse(val data: List<Result>?) : BaseData(){
|
||||
val lineId:Long?,
|
||||
var lineName:String?,
|
||||
) {
|
||||
fun toDbBean(): LineDataBean {
|
||||
fun toDbBean(endStationName:String?): LineDataBean {
|
||||
val result = LineDataBean()
|
||||
result.lineId = lineId
|
||||
result.lineName = lineName
|
||||
result.endStationName = endStationName
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -118,7 +119,8 @@ data class CarExecutableTaskResponse(val data: List<Result>?) : BaseData(){
|
||||
var lineId:Long?=null
|
||||
dataInfo.line?.let { lineInfo->
|
||||
lineId = lineInfo.lineId
|
||||
lineList.add(lineInfo.toDbBean())
|
||||
val lastStation = dataInfo.siteList?.last()
|
||||
lineList.add(lineInfo.toDbBean(lastStation?.name))
|
||||
}
|
||||
dataInfo.contrail?.let { contrailInfo->
|
||||
contrailList.add(contrailInfo.toDbBean(lineId))
|
||||
|
||||
@@ -7,11 +7,13 @@ 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.EventDataBean
|
||||
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.EventDataDao
|
||||
import com.mogo.och.weaknet.database.dao.LineDataDao
|
||||
import com.mogo.och.weaknet.database.dao.SiteDataDao
|
||||
import com.mogo.och.weaknet.database.dao.TaskDataDao
|
||||
@@ -22,7 +24,7 @@ import java.io.File
|
||||
//entities指定该数据库有哪些表,多张表就逗号分隔
|
||||
//version指定数据库版本号,升级时需要用到
|
||||
//数据库继承自RoomDatabase
|
||||
@Database(entities = [ContrailDataBean::class, LineDataBean::class, SiteDataBean::class, TaskDataBean::class, TaskSiteDataBean::class], version = 1)
|
||||
@Database(entities = [ContrailDataBean::class, LineDataBean::class, SiteDataBean::class, TaskDataBean::class, TaskSiteDataBean::class, EventDataBean::class], version = 1)
|
||||
abstract class MyDataBase : RoomDatabase() {
|
||||
|
||||
|
||||
@@ -39,6 +41,7 @@ abstract class MyDataBase : RoomDatabase() {
|
||||
}
|
||||
|
||||
abstract val contrailDataDao: ContrailDataDao?
|
||||
abstract val eventDataDao: EventDataDao?
|
||||
abstract val lineDataDao: LineDataDao?
|
||||
abstract val siteDataDao: SiteDataDao?
|
||||
abstract val taskDataDao: TaskDataDao?
|
||||
@@ -47,7 +50,7 @@ abstract class MyDataBase : RoomDatabase() {
|
||||
companion object {
|
||||
private const val DATABASE_NAME = "shuttle_db"
|
||||
val ROOT_PATH =
|
||||
Environment.getExternalStorageDirectory().absolutePath + File.separator + "MLog" + File.separator + "APP_catch" + File.separator //程序外部存储跟目录
|
||||
Environment.getExternalStorageDirectory().absolutePath + File.separator + "MLog" + File.separator + "APP_cache" + File.separator //程序外部存储跟目录
|
||||
|
||||
val instance: MyDataBase
|
||||
//结合单例模式完成数据库实例创建
|
||||
|
||||
@@ -21,31 +21,31 @@ data class ContrailDataBean(
|
||||
/**
|
||||
* csv格式的轨迹文件
|
||||
*/
|
||||
@ColumnInfo(name = "csv_file_url", typeAffinity = ColumnInfo.TEXT, index = true)
|
||||
@ColumnInfo(name = "csv_file_url", typeAffinity = ColumnInfo.TEXT)
|
||||
var csvFileUrl: String? = null,
|
||||
|
||||
/**
|
||||
* csv_file_url 文件的md5值
|
||||
*/
|
||||
@ColumnInfo(name = "csv_file_md5", typeAffinity = ColumnInfo.TEXT, index = true)
|
||||
@ColumnInfo(name = "csv_file_md5", typeAffinity = ColumnInfo.TEXT)
|
||||
var csvFileMd5: String? = null,
|
||||
|
||||
/**
|
||||
* txt格式的轨迹文件
|
||||
*/
|
||||
@ColumnInfo(name = "txt_file_url", typeAffinity = ColumnInfo.TEXT, index = true)
|
||||
@ColumnInfo(name = "txt_file_url", typeAffinity = ColumnInfo.TEXT)
|
||||
var txtFileUrl: String? = null,
|
||||
|
||||
/**
|
||||
* txt文件的md5
|
||||
*/
|
||||
@ColumnInfo(name = "txt_file_md5", typeAffinity = ColumnInfo.TEXT, index = true)
|
||||
@ColumnInfo(name = "txt_file_md5", typeAffinity = ColumnInfo.TEXT)
|
||||
var txtFileMd5: String? = null,
|
||||
|
||||
/**
|
||||
* 文件的保存时间
|
||||
*/
|
||||
@ColumnInfo(name = "contrail_save_time", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
@ColumnInfo(name = "contrail_save_time", typeAffinity = ColumnInfo.INTEGER)
|
||||
var contrailSaveTime: Long? = null,
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,10 +22,16 @@ data class LineDataBean(
|
||||
@ColumnInfo(name = "line_name", typeAffinity = ColumnInfo.TEXT)
|
||||
var lineName: String? = null,
|
||||
|
||||
/**
|
||||
* 终点站名称
|
||||
*/
|
||||
@ColumnInfo(name = "end_station_name", typeAffinity = ColumnInfo.TEXT)
|
||||
var endStationName: String? = null,
|
||||
|
||||
/**
|
||||
* 存储此条数据时时间戳
|
||||
*/
|
||||
@ColumnInfo(name = "line_get_time", typeAffinity = ColumnInfo.INTEGER, index = true)
|
||||
@ColumnInfo(name = "line_get_time", typeAffinity = ColumnInfo.INTEGER)
|
||||
val linegetTime: Long = System.currentTimeMillis(),
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@@ -21,18 +21,18 @@ data class TaskSiteDataBean(
|
||||
@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 = "line_name", typeAffinity = ColumnInfo.TEXT)
|
||||
var lineName: String? = null,
|
||||
|
||||
/**
|
||||
* 站点名称
|
||||
*/
|
||||
|
||||
@@ -14,18 +14,10 @@ interface EventDataDao {
|
||||
|
||||
//插入数据
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(vararg lineDataBean: EventDataBean)
|
||||
fun insert(vararg eventDataBean: 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>?
|
||||
fun delete(vararg eventDataBean: EventDataBean)
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.ContrailDataBean
|
||||
import com.mogo.och.weaknet.database.bean.TaskDataBean
|
||||
import io.reactivex.Observable
|
||||
|
||||
@@ -40,5 +41,18 @@ interface TaskDataDao {
|
||||
@Query("SELECT * FROM ${TaskDataBean.taskDataTable} WHERE line_id = :lineId and task_get_time > :zeroTime")
|
||||
fun querySitesByLineId(lineId: Long?,zeroTime:Long = DateTimeUtil.getCurrentDateZero()):List<TaskDataBean>?
|
||||
|
||||
//查询线路对应的轨迹信息
|
||||
@Query("SELECT * FROM ${TaskDataBean.taskDataTable} WHERE task_id = :taskId")
|
||||
fun queryContrailByLineId(taskId:Long): List<TaskDataBean>?
|
||||
|
||||
|
||||
//查询线路对应的轨迹信息 只要一个结果
|
||||
fun queryTaskByTaskIdOne(taskId: Long): TaskDataBean?{
|
||||
val queryContrailByLineId = queryContrailByLineId(taskId)
|
||||
return if(queryContrailByLineId.isNullOrEmpty()){
|
||||
null
|
||||
}else{
|
||||
queryContrailByLineId.first()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,28 +11,29 @@ object ContraiRepository {
|
||||
private var contrailDao: ContrailDataDao?=null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
contrailDao = MyDataBase.instance.contrailDataDao
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
val runnable = Runnable {
|
||||
// 校验数据个数
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DbThreadUtils.runInIoThread(runnable)
|
||||
}
|
||||
|
||||
fun deleteByLineId(lineId: Long) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
import com.mogo.och.weaknet.database.dao.EventDataDao
|
||||
|
||||
object EventRepository {
|
||||
|
||||
private var eventDataDao: EventDataDao?=null
|
||||
|
||||
init {
|
||||
eventDataDao = MyDataBase.instance.eventDataDao
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -12,9 +12,7 @@ object LineRepository {
|
||||
private var lineDao: LineDataDao?=null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
lineDao = MyDataBase.instance.lineDataDao
|
||||
}
|
||||
lineDao = MyDataBase.instance.lineDataDao
|
||||
}
|
||||
|
||||
fun cleanWeltData(){
|
||||
|
||||
@@ -11,28 +11,29 @@ object SiteRepository {
|
||||
private var siteDataDao: SiteDataDao? = null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
siteDataDao = MyDataBase.instance.siteDataDao
|
||||
}
|
||||
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
|
||||
val runnable = Runnable {
|
||||
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)
|
||||
}
|
||||
siteDataDao.insert(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
DbThreadUtils.runInIoThread(runnable)
|
||||
}
|
||||
|
||||
fun deleteByLineId(lineId: Long) {
|
||||
|
||||
@@ -14,9 +14,7 @@ object TaskRepository {
|
||||
private var taskDataDao: TaskDataDao? = null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
taskDataDao = MyDataBase.instance.taskDataDao
|
||||
}
|
||||
taskDataDao = MyDataBase.instance.taskDataDao
|
||||
}
|
||||
|
||||
fun addOrUpdate(serverDateList: List<TaskDataBean>, lineId: Long?) {
|
||||
@@ -65,14 +63,18 @@ object TaskRepository {
|
||||
return null
|
||||
}
|
||||
|
||||
fun startTask(lineDataBean: LineDataBean, taskDataBean: TaskDataBean){
|
||||
taskDataBean.startTime = System.currentTimeMillis()
|
||||
taskDataBean.status = TaskDataBean.useing
|
||||
fun startTask(taskId: Long, lineId: Long,lineName:String){
|
||||
|
||||
try {
|
||||
MyDataBase.instance.runInTransaction {
|
||||
// 更新任务状态
|
||||
taskDataDao?.insert(taskDataBean)
|
||||
TaskSiteRepository.startTask(lineDataBean, taskDataBean)
|
||||
// 更新task状态
|
||||
taskDataDao?.queryTaskByTaskIdOne(taskId)?.let {
|
||||
it.startTime = System.currentTimeMillis()
|
||||
it.status = TaskDataBean.useing
|
||||
// 更新任务状态
|
||||
taskDataDao?.insert(it)
|
||||
}
|
||||
TaskSiteRepository.startTask(taskId, lineId,lineName)
|
||||
}
|
||||
}catch (e:Exception){
|
||||
if(e is DataException){
|
||||
|
||||
@@ -13,22 +13,20 @@ object TaskSiteRepository {
|
||||
private var taskSiteDataDao: TaskSiteDataDao? = null
|
||||
|
||||
init {
|
||||
ThreadUtils.runOnUiThread {
|
||||
taskSiteDataDao = MyDataBase.instance.taskSiteDataDao
|
||||
}
|
||||
taskSiteDataDao = MyDataBase.instance.taskSiteDataDao
|
||||
}
|
||||
|
||||
// 开始线路
|
||||
fun startTask(lineDataBean: LineDataBean, taskDataBean: TaskDataBean) {
|
||||
fun startTask(taskId: Long, linId: Long,lineName:String) {
|
||||
// 获取线路的站点
|
||||
val querySites = SiteRepository.querySiteByLineId(lineDataBean.lineId!!)
|
||||
val querySites = SiteRepository.querySiteByLineId(linId)
|
||||
if(querySites.isNullOrEmpty()){
|
||||
throw DataException("没有站点数据")
|
||||
}
|
||||
val toTaskSiteDatas = TaskSiteDataBean.toTaskSiteDatas(
|
||||
querySites,
|
||||
taskDataBean.taskId!!,
|
||||
lineDataBean.lineName!!
|
||||
taskId,
|
||||
lineName
|
||||
)
|
||||
// 把线路所有的站点搬迁到运行中表格中
|
||||
taskSiteDataDao?.insert(*toTaskSiteDatas.toTypedArray())
|
||||
|
||||
@@ -33,6 +33,7 @@ class FRetryWithTime11 : Function<List<LineDataBean>?, ObservableSource<List<Bus
|
||||
temp = BusQueryLinesResponse.Result()
|
||||
temp?.lineId = it.lineId
|
||||
temp?.name = it.lineName
|
||||
temp?.endSiteName = it.endStationName
|
||||
result.add(temp!!)
|
||||
}
|
||||
return Observable.just(result)
|
||||
|
||||
@@ -12,29 +12,22 @@ 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.common.module.network.OchCommonSubscribeImpl
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
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.bean.LineDataBean
|
||||
import com.mogo.och.weaknet.database.repository.LineRepository
|
||||
import com.mogo.och.weaknet.database.repository.TaskRepository
|
||||
import com.mogo.och.weaknet.database.transform.FRetryWithTime11
|
||||
import com.mogo.och.weaknet.database.transform.TransformTask
|
||||
import com.mogo.och.weaknet.database.transform.transform4DataBase
|
||||
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
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -47,11 +40,12 @@ object BusLineModel {
|
||||
private const val TAG = "BusLineModel"
|
||||
private const val LoopCarInfo = "LoopCarInfo"
|
||||
private const val executableChangeMd5 = "EXECUTABLECHANGEMD5"
|
||||
private const val executableChangeTime = "executablechangetime"
|
||||
|
||||
@JvmStatic
|
||||
fun init() {
|
||||
mContext = AbsMogoApplication.getApp()
|
||||
BizLoopManager.setLoopFunction("${TAG}_${LoopCarInfo}", LoopInfo(60, ::queryCarExecutableTaskList))
|
||||
BizLoopManager.setLoopFunction("${TAG}_${LoopCarInfo}", LoopInfo(60, ::queryCarExecutableTaskList,immediately = true))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -73,6 +67,7 @@ object BusLineModel {
|
||||
// 第一次过滤 请求返回值的md5
|
||||
val currentRequest = DigestUtils.md5Hex(data.data.toString())
|
||||
val lastChangeMd5 = SharedPrefsMgr.getInstance().getString(executableChangeMd5)
|
||||
SharedPrefsMgr.getInstance().putLong(executableChangeTime,DateTimeUtil.getCurrentTimeStamp())
|
||||
if(currentRequest==lastChangeMd5){
|
||||
return
|
||||
}
|
||||
@@ -95,7 +90,6 @@ object BusLineModel {
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusLines() {
|
||||
|
||||
LineRepository.queryCanUseLine()
|
||||
?.transform4DataBase(FRetryWithTime11())
|
||||
?.subscribe(object : Observer<List<BusQueryLinesResponse.Result>> {
|
||||
@@ -118,37 +112,6 @@ object BusLineModel {
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// queryBusLines(mContext!!, object : OchCommonServiceCallback<BusQueryLinesResponse> {
|
||||
// override fun onSuccess(data: BusQueryLinesResponse) {
|
||||
// if (null == data && mBusLinesCallback != null) {
|
||||
// mBusLinesCallback!!.onBusLinesChange(null)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if (mBusLinesCallback != null) {
|
||||
// mBusLinesCallback!!.onBusLinesChange(data)
|
||||
// }
|
||||
//
|
||||
// BusQueryLinesResponse.save2Db(data)
|
||||
// }
|
||||
//
|
||||
// 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 fun onFail(code: Int, failMsg: String) {
|
||||
// if (!NetworkUtils.isConnected(mContext)) {
|
||||
// ToastUtils.showShort("网络异常,请稍后重试")
|
||||
// } else {
|
||||
// ToastUtils.showShort("查询所有绑定路线失败:$failMsg")
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,8 +121,6 @@ object BusLineModel {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun queryBusLineTasksById(lineId: Long, position: Int, autoRefresh: Boolean) {
|
||||
|
||||
|
||||
TaskRepository.queryCanUserTask(lineId)
|
||||
?.transform4DataBase(TransformTask())
|
||||
?.subscribe(object : Observer<List<BusQueryLineTaskResponse.Result>> {
|
||||
@@ -182,42 +143,11 @@ object BusLineModel {
|
||||
}
|
||||
|
||||
})
|
||||
// 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)
|
||||
// }
|
||||
// BusQueryLineTaskResponse.save2Db(data,lineId)
|
||||
// }
|
||||
//
|
||||
// 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 fun onFail(code: Int, failMsg: String) {
|
||||
// if (!NetworkUtils.isConnected(mContext)) {
|
||||
// ToastUtils.showShort("网络异常,请稍后重试")
|
||||
// } else {
|
||||
// ToastUtils.showShort("查询所有绑定路线失败:$failMsg")
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
}
|
||||
@JvmStatic
|
||||
fun commitSwitchLineId(taskId: Long, lineId: Long) {
|
||||
switchLine(mContext!!, taskId, object : OchCommonServiceCallback<BusRoutesResponse> {
|
||||
fun commitSwitchLineId(taskId: Long, lineId: Long,lineName: String) {
|
||||
TaskRepository.startTask(taskId,lineId, lineName)
|
||||
OrderServiceManager.switchLine(mContext!!, taskId, object : OchCommonServiceCallback<BusRoutesResponse> {
|
||||
override fun onSuccess(o: BusRoutesResponse) {
|
||||
SharedPrefsMgr.getInstance().putLong(BusSwitchLineActivity.LASTCOMMITLINEID, lineId)
|
||||
if (mBusLinesCallback != null) {
|
||||
|
||||
@@ -380,6 +380,8 @@ object OrderModel {
|
||||
return
|
||||
}
|
||||
|
||||
BusRoutesResponse.save2Db(data)
|
||||
|
||||
if (busRoutesResult == null || busRoutesResult!!.writeVersion < data.result.writeVersion) {
|
||||
d(SceneConstant.M_BUS + TAG, "更新小巴路线数据: $data")
|
||||
updateBusStatus(data.result)
|
||||
@@ -827,7 +829,7 @@ object OrderModel {
|
||||
if (currentStationIndex < stationList!!.size - 1) {
|
||||
val nextStation = stationList[currentStationIndex + 1]
|
||||
nextStationName = nextStation.name
|
||||
nextStationNameKr = nextStation.nameKr
|
||||
nextStationNameKr = nextStation.nameKr?:""
|
||||
nextStationPoint.longitude = nextStation.gcjLon
|
||||
nextStationPoint.latitude = nextStation.gcjLat
|
||||
}
|
||||
|
||||
@@ -64,26 +64,6 @@ public interface IBascApiService {
|
||||
@POST("/och-shuttle-cabin/api/flow/v1/driver/arrive")
|
||||
Observable<BaseData> arriveSiteStation(@Header ("appId") String appId,@Header("ticket") String ticket,@Body BusUpdateSiteStatusRequest request);
|
||||
|
||||
/**
|
||||
* 查询车辆配置的所有路线
|
||||
* @param appId
|
||||
* @param ticket
|
||||
* @param sn
|
||||
* @return
|
||||
*/
|
||||
@GET("/och-shuttle-cabin/api/business/v1/driver/bindLine/query")
|
||||
Observable<BusQueryLinesResponse> queryBusLines(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);
|
||||
|
||||
/**
|
||||
* 查询线路的任务
|
||||
* @param appId
|
||||
* @param ticket
|
||||
* @param lineId 线路id
|
||||
* @return
|
||||
*/
|
||||
@GET("/och-shuttle-cabin/api/business/v1/driver/task/query")
|
||||
Observable<BusQueryLineTaskResponse> queryBusTaskByLineId(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("lineId") String lineId);
|
||||
|
||||
/**
|
||||
* 中止任务
|
||||
* @param appId
|
||||
|
||||
@@ -148,32 +148,6 @@ object OrderServiceManager {
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "arriveSiteStation"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusLines(context: Context, callback: OchCommonServiceCallback<BusQueryLinesResponse>?) {
|
||||
mService.queryBusLines(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
SharedPrefsMgr.getInstance().sn
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
@JvmStatic
|
||||
fun queryBusTaskByLineId(
|
||||
context: Context,
|
||||
lineId: String?,
|
||||
callback: OchCommonServiceCallback<BusQueryLineTaskResponse>?
|
||||
) {
|
||||
mService.queryBusTaskByLineId(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
lineId
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "queryBusLines"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun queryBusTaskByLineId(
|
||||
context: Context,
|
||||
|
||||
@@ -70,8 +70,8 @@ class BusLinePresenter(view: BusSwitchLineView?) : Presenter<BusSwitchLineView?>
|
||||
}
|
||||
}
|
||||
|
||||
fun commitSwitchLineId(taskId: Long, lineId: Long) {
|
||||
BusLineModel.commitSwitchLineId(taskId, lineId)
|
||||
fun commitSwitchLineId(taskId: Long, lineId: Long,lineName: String) {
|
||||
BusLineModel.commitSwitchLineId(taskId, lineId, lineName)
|
||||
}
|
||||
|
||||
fun removeListener() {
|
||||
|
||||
@@ -207,7 +207,7 @@ class BusSwitchLineActivity : MvpActivity<BusSwitchLineView?, BusLinePresenter?>
|
||||
//切换路线提交
|
||||
if (v.id == R.id.switch_line_btn_commit) {
|
||||
if(mAdapter.checkLineId!=-1L&&mAdapter.checkTaskId!=-1L){
|
||||
mPresenter?.commitSwitchLineId(mAdapter.checkTaskId,mAdapter.checkLineId)
|
||||
mPresenter?.commitSwitchLineId(mAdapter.checkTaskId,mAdapter.checkLineId,mAdapter.checkLineName)
|
||||
}else{
|
||||
ToastUtils.showLong("请选择任务")
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ class SwitchLineAdapter(
|
||||
private var mItemClickListener: LineItemClickListener? = null
|
||||
var checkLineId:Long = -1
|
||||
var checkTaskId:Long = -1
|
||||
var checkLineName:String = ""
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
@@ -66,14 +67,17 @@ class SwitchLineAdapter(
|
||||
if(isCheck) {
|
||||
checkLineId = line.lineId
|
||||
checkTaskId = line.taskList[position].id
|
||||
checkLineName = line.name
|
||||
}else{
|
||||
checkLineId=-1
|
||||
checkTaskId=-1
|
||||
checkLineName = ""
|
||||
}
|
||||
}catch (e:Exception){
|
||||
e.printStackTrace()
|
||||
checkLineId=-1
|
||||
checkTaskId=-1
|
||||
checkLineName = ""
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user